--- a/web/wp-content/themes/IRI-Theme/functions.php Tue Mar 16 14:14:44 2010 +0000
+++ b/web/wp-content/themes/IRI-Theme/functions.php Thu Mar 18 09:56:33 2010 +0000
@@ -1,5 +1,19 @@
<?php
+function theme_init(){
+ if (class_exists('xili_language')) {
+ define('THEME_TEXTDOMAIN','IriTheme');
+ define('THEME_LANGS_FOLDER','/language');
+ } else {
+ load_theme_textdomain('IriTheme', get_template_directory() . '/languages');
+ }
+}
+add_action ('init', 'theme_init');
+
+
+//
+define('THEME_TEXTDOMAIN','IriTheme');
+define('THEME_LANGS_FOLDER','/language');
require( "lib/zip.lib.php" ) ; //indiquez le chemin d'accès à la lib
//error_reporting(E_ALL);
@@ -12,8 +26,7 @@
include('searchform.php');
}
-if ( function_exists('register_sidebar') )
-{
+if ( function_exists('register_sidebar') ){
register_sidebar
( array
(
@@ -66,9 +79,287 @@
);
}
+// Need the tag Cloud Plug In
+// piece together the flash code
+function xilimlSam_wp_cumulus_createflashcode( $widget=false, $atts=NULL ){
+
+
+ // get the options
+ if( $widget == true ){
+ $options = get_option('wpcumulus_widget');
+ $soname = "widget_so";
+ $divname = "wpcumuluswidgetcontent";
+ // get compatibility mode variable from the main options
+ $mainoptions = get_option('wpcumulus_options');
+ $options['compmode'] = $mainoptions['compmode'];
+ $options['showwptags'] = $mainoptions['showwptags'];
+ } else if( $atts != NULL ){
+ $options = shortcode_atts( get_option('wpcumulus_options'), $atts );
+ $soname = "shortcode_so";
+ $divname = "wpcumuluscontent";
+ } else {
+ $options = get_option('wpcumulus_options');
+ $soname = "so";
+ $divname = "wpcumuluscontent";
+ }
+ // get the tag cloud...
+ if( $options['mode'] != "cats" ){
+ ob_start();
+ //wp_tag_cloud( $options['args'] );
+ xili_tidy_tag_cloud('tagsgroup='.the_curlang());
+ $tagcloud = urlencode( str_replace( " ", " ", ob_get_clean() ) );
+ }
+ // get categories
+ if( $options['mode'] != "tags" ){
+ ob_start();
+ xili_tidy_tag_cloud('tagsgroup='.the_curlang());//
+ $cats = urlencode( ob_get_clean() );
+ }
+ // get some paths
+ if( function_exists('plugins_url') ){
+ // 2.6 or better
+ $movie = plugins_url('wp-cumulus/tagcloud.swf');
+ $path = plugins_url('wp-cumulus/');
+ } else {
+ // pre 2.6
+ $movie = get_bloginfo('wpurl') . "/wp-content/plugins/wp-cumulus/tagcloud.swf";
+ $path = get_bloginfo('wpurl')."/wp-content/plugins/wp-cumulus/";
+ }
+ // add random seeds to so name and movie url to avoid collisions and force reloading (needed for IE)
+ $soname .= rand(0,9999999);
+ $movie .= '?r=' . rand(0,9999999);
+ $divname .= rand(0,9999999);
+ // write flash tag
+ if( $options['compmode']!='true' ){
+ $flashtag = '<!-- SWFObject embed by Geoff Stearns geoff@deconcept.com http://blog.deconcept.com/swfobject/ -->';
+ $flashtag .= '<script type="text/javascript" src="'.$path.'swfobject.js"></script>';
+ // ------------------------------------------------------------------------------------
+ $flashtag .= '<div id="'.$divname.'" style="position:absolute;z-index:0;">';
+ if( $options['showwptags'] == 'true' ){ $flashtag .= '<p>'; } else { $flashtag .= '<p style="display:none;">'; };
+ // alternate content
+ if( $options['mode'] != "cats" ){ $flashtag .= urldecode($tagcloud); }
+ if( $options['mode'] != "tags" ){ $flashtag .= urldecode($cats); }
+ $flashtag .= '</p><!-- WP Cumulus Flash tag cloud by <a href="http://www.roytanck.com">Roy Tanck</a> and <a href="http://lukemorton.co.uk/">Luke Morton</a> requires <a href="http://www.macromedia.com/go/getflashplayer">Flash Player</a> 9 or better. --></div>';
+ $flashtag .= '<script type="text/javascript">';
+ $flashtag .= 'var '.$soname.' = new SWFObject("'.$movie.'", "tagcloudflash", "'.$options['width'].'", "'.$options['height'].'", "9", "#'.$options['bgcolor'].'");';
+ if( $options['trans'] == 'true' ){
+ $flashtag .= $soname.'.addParam("wmode", "transparent");';
+ }
+ $flashtag .= $soname.'.addParam("allowScriptAccess", "always");';
+ $flashtag .= $soname.'.addVariable("tcolor", "0x'.$options['tcolor'].'");';
+ $flashtag .= $soname.'.addVariable("tcolor2", "0x' . ($options['tcolor2'] == "" ? $options['tcolor'] : $options['tcolor2']) . '");';
+ $flashtag .= $soname.'.addVariable("hicolor", "0x' . ($options['hicolor'] == "" ? $options['tcolor'] : $options['hicolor']) . '");';
+ $flashtag .= $soname.'.addVariable("tspeed", "'.$options['speed'].'");';
+ $flashtag .= $soname.'.addVariable("distr", "'.$options['distr'].'");';
+ $flashtag .= $soname.'.addVariable("mode", "'.$options['mode'].'");';
+ // put tags in flashvar
+ if( $options['mode'] != "cats" ){
+ $flashtag .= $soname.'.addVariable("tagcloud", "'.urlencode('<tags>') . $tagcloud . urlencode('</tags>').'");';
+ }
+ // put categories in flashvar
+ if( $options['mode'] != "tags" ){
+ $flashtag .= $soname.'.addVariable("categories", "' . $cats . '");';
+ }
+ $flashtag .= $soname.'.write("'.$divname.'");';
+ $flashtag .= '</script>';
+ } else {
+ $flashtag = '<object type="application/x-shockwave-flash" data="'.$movie.'" width="'.$options['width'].'" height="'.$options['height'].'" wmode="opaque">';
+ $flashtag .= '<param name="movie" value="'.$movie.'" />';
+ $flashtag .= '<param name="bgcolor" value="#'.$options['bgcolor'].'" />';
+ $flashtag .= '<param name="AllowScriptAccess" value="always" />';
+ $flashtag .= '<param name="wmode" value="opaque" />';
+ if( $options['trans'] == 'true' ){
+ $flashtag .= '<param name="wmode" value="transparent" />';
+ }
+ $flashtag .= '<param name="flashvars" value="';
+ $flashtag .= 'tcolor=0x'.$options['tcolor'];
+ $flashtag .= '&tcolor2=0x'.$options['tcolor2'];
+ $flashtag .= '&hicolor=0x'.$options['hicolor'];
+ $flashtag .= '&tspeed='.$options['speed'];
+ $flashtag .= '&distr='.$options['distr'];
+ $flashtag .= '&mode='.$options['mode'];
+ // put tags in flashvar
+ if( $options['mode'] != "cats" ){
+ $flashtag .= '&tagcloud='.urlencode('<tags>') . $tagcloud . urlencode('</tags>');
+ }
+ // put categories in flashvar
+ if( $options['mode'] != "tags" ){
+ $flashtag .= '&categories=' . $cats;
+ }
+ $flashtag .= '" />';
+ // alternate content
+ if( $options['mode'] != "cats" ){ $flashtag .= '<p>'.urldecode($tagcloud).'</p>'; }
+ if( $options['mode'] != "tags" ){ $flashtag .= '<p>'.urldecode($cats).'</p>'; }
+ $flashtag .= '<!-- WP-Cumulus by <a href="http://www.roytanck.com/">Roy Tanck</a> and <a href="http://lukemorton.co.uk/">Luke Morton</a> requires <a href="http://www.macromedia.com/go/getflashplayer">Flash Player</a> 9 or better. -->';
+ $flashtag .= '</object>';
+ }
+ return $flashtag;
+}
+
+// Copy of the current category widget plugin adapted to xiliml
+function xilimlSam_post_of_current_category (){
+ global $wpdb;
+
+ $defaults = array(
+ 'limit' => 30,
+ 'AscDesc' => "DSC",
+ 'OrderBy' =>'ID',
+ );
+
+ $args = $defaults;
+ $lang = the_curlang();//echo ($lang);
+ extract($args);
+
+ $limit = (int) abs($limit);
+
+ if(is_category()){
+ $curCategoryID = get_query_var('cat');
+ }
+
+ if (is_single()) {
+ $curCategoryID = '';
+
+ foreach (get_the_category() as $catt) {
+ $curCategoryID .= $catt->cat_ID.' ';
+ }
+
+ $curCategoryID = str_replace(" ", ",", trim($curCategoryID));
+ }
+
+ if (!intval($curCategoryID)) $curCategoryID='';
+ $query = "&category=$curCategoryID&showposts=$limit&orderby=$OrderBy&order=$AscDesc";
+ $posts = get_posts($query); //get posts
+ $postlist = '';
+
+ foreach ($posts as $post) {
+
+ $CurLang = get_cur_post_lang_dir ($post->ID);//echo ($post->ID."-> ".$CurLang["lang"]." <br/>");
+ if($CurLang["lang"]==$lang){
+ $post_title_s = htmlspecialchars(stripslashes(cache_cutter($post->post_title)));
+ $post_title_l = htmlspecialchars(stripslashes(text_cutter($post->post_title,200)));
+ $postlist .= '<li> <a href="' . get_permalink($post->ID) . '" title="'. $post_title_s .'" >' . $post_title_l . ' </a> </li>';
+ }
+ }
+
+ echo '<ul class="advanced-recent-posts">';
+ echo $postlist;
+ echo '</ul>';
+
+}
+
+#
+function xilimlSam_page2cat_output_Hook($cat){
+
+ if( function_exists(page2cat_output) and function_exists(xiliml_the_other_posts) ){
+
+ global $wpdb;
+ $mypage = $wpdb->get_row("SELECT * FROM {$wpdb->page2cat} WHERE cat_ID = '".$cat."';",OBJECT);
+ $pageid = $mypage->page_ID;
+ $pageInOtherLang = xiliml_the_other_posts ($pageid,'','','array');
+
+ if($pageInOtherLang[the_curlang()]!=null){
+ $pageid=$pageInOtherLang[the_curlang()];
+ }
+
+ if($pageid != ""):
+
+ switch($style):
+
+ case 'inline':
+ default:
+ ?>
+ <div id="category-page-header">
+ <?php
+ $pagina = "SELECT * FROM {$wpdb->posts} WHERE ID='".$pageid."' AND post_type = 'page';";
+ $mine = $wpdb->get_results($pagina);
+ if($mine[0]->post_title!=""){
+ ?>
+ <div id="p2c-header">
+ <h2><?php echo $mine[0]->post_title; ?></h2>
+ <p><?php echo wptexturize($mine[0]->post_content,1); ?></p>
+ </div>
+ <div class="category-page-cleaner"></div>
+ </div>
+ <?php
+ }
+ break;
+
+
+ endswitch;
+ endif;
+ }
+
+ /*
+ $current_lang = the_cur_lang_dir();
+ page2cat_output($cat);
+
+ $MyPost = xiliml_the_other_posts($post_ID,"","","array");
+ //var_dump($MyPost);
+ //echo($current_lang['lang']." -> ".$MyPost[$current_lang['lang']]);
+
+ if (in_array($current_lang['lang'],$MyPost)){
+ return ($post_ID);
+ } else {
+ return ($MyPost[$current_lang['lang']]);
+
+ }
+ */
+}
+
+#
+function xilimlSam_other_posts($post_ID){
+
+ if (class_exists('xili_language')) {
+
+ $current_lang = the_cur_lang_dir();
+
+ $MyPost = xiliml_the_other_posts($post_ID,"","","array");
+ //var_dump($MyPost);
+ //echo($current_lang['lang']." -> ".$MyPost[$current_lang['lang']]);
+
+ if (in_array($current_lang['lang'],$MyPost)){
+ return ($post_ID);
+ } else {
+ return ($MyPost[$current_lang['lang']]);
+
+ }
+
+ } else {
+ return ($post_ID);
+ }
+
+}
+
+#
+function xilimlSam_other_pages($post_ID){
+
+ if (class_exists('xili_language')) {
+
+ $current_lang = the_cur_lang_dir();
+
+ $MyPost = xiliml_the_other_posts($post_ID,"","","array");
+ //var_dump($MyPost);
+ //echo($current_lang['lang']." -> ".$MyPost[$current_lang['lang']]);
+
+ if (in_array($current_lang['lang'],$MyPost)){
+ return ($post_ID);
+ } else {
+ return ($MyPost[$current_lang['lang']]);
+
+ }
+
+ } else {
+ return ($post_ID);
+ }
+}
+
# Displays a list of categories
function dp_list_categories($Eparam='') {
+ if (class_exists('xili_language')) {
+ $current_lang = the_cur_lang_dir();
+ }
+
$categories = get_categories('hide_empty=1'.$Eparam);
$first = true;
$count = 0;
@@ -78,18 +369,60 @@
if ($category->parent<1) {
echo ('<li class="menu-h-li">');
- echo ('<a href="'.get_category_link($category->cat_ID).'">'.$category->name.' </a>');
+
+ if (class_exists('xili_language')) {
+ echo ('<a href="'.xiliml_get_category_link($category->cat_ID).'?lang='.$current_lang['lang'].'">'.__($category->name,'IriTheme').' </a>');
+ } else {
+ echo ('<a href="'.get_category_link($category->cat_ID).'">'.__($category->name,'IriTheme').' </a>');
+ }
echo '<ul>';
-
- $category_posts = get_posts('numberposts=15&category='.$category->cat_ID);
+ $category_posts = get_posts('numberposts=15&order=ASC&orderby=parent&category='.$category->cat_ID);
$count2 = 0;
- //echo("<!-- ".sizeof($category_posts)." -->");
+ /*$categoryN2 = get_category_link($category->cat_ID);
+
+ foreach($categoryN2 as $catN2) {
+
+ //$category_posts = get_posts('numberposts=15&order=ASC&orderby=parent&category='.$category->cat_ID);
+ echo ('<li class="menu-h-li2"><a href="'.get_category_link($catN2->cat_ID).'"> XX '.$catN2->name.' </a></li>');
+ }*/
+
+ //echo("<!-- ".sizeof($category_posts)." -->");
foreach($category_posts as $post) {
- echo '<li class="menu-h-li2" title="'.cache_cutter($post->post_title).'"><a href="'.$post->guid.'">'.text_cutter($post->post_title,200).'</a></li>';
- //echo '<li class="menu-h-li2" title="'.$count2.'"><a href="'.$post->guid.'">'.$post->post_title.'</a></li>';
- $count2++; //if ($count2>6) break;
+
+ if (class_exists('xili_language')) {
+ // Affiche les posts de la langue courante + les indéfinis
+ //if (get_cur_language($post->ID)==$current_lang['lang'] or get_cur_language($post->ID)==""){
+ // Affiche seulement les posts de la langue courante + les indéfinis
+ if (get_cur_language($post->ID)==$current_lang['lang']){
+
+ // gestion des niv 2 ajout de class si nécessaire
+ $MyCategoryPost = get_the_category($post->ID);
+ //var_dump($MyCategoryPost);
+
+ $MoreStyle="";
+ $title ="";
+ if (count($MyCategoryPost)>1){
+ foreach($MyCategoryPost as $MyCategory) {
+ $MoreStyle.= " ".$MyCategory->category_nicename;
+ $title.= " ".$MyCategory->category_nicename;
+ //category_parent!=0
+ }
+ } else {
+ $MoreStyle ="menu-h-li2";
+ }
+
+ echo '<li class="'.$MoreStyle.'" title="'.cache_cutter($post->post_title)." : ".$MoreStyle.'"><a href="'.get_permalink($post->ID).'">'.text_cutter($post->post_title,200).'</a></li>';
+ $count2++; //if ($count2>6) break;
+ }
+
+ } else {
+
+ echo '<li class="menu-h-li2" title="'.cache_cutter($post->post_title).'"><a href="'.get_permalink($post->ID).'">'.text_cutter($post->post_title,200).'</a></li>';
+ $count2++; //if ($count2>6) break;
+ }
+
};
@@ -287,14 +620,23 @@
return (str_replace( "<!-- cut -->", "", $text));
}
-
+# Créer le menu du footer
function dp_list_posts($Eparam='') {
- $category_posts = get_posts($Eparam);
-
+ $category_posts = get_posts($Eparam);
+
+ if (class_exists('xili_language')) {
+ $current_lang = the_cur_lang_dir();
foreach($category_posts as $post) {
- echo '<li><a href="'.$post->guid.'">'.$post->post_title.'</a></li>';
+ if (get_cur_language($post->ID)==$current_lang['lang']){
+ echo '<li><a href="'.get_permalink($post->ID).'">'.__($post->post_title,'IriTheme').'</a></li>';
+ }
};
+ } else {
+ foreach($category_posts as $post) {
+ echo '<li><a href="'.get_permalink($post->ID).'">'.__($post->post_title,'IriTheme').'</a></li>';
+ };
+ }
}
@@ -448,4 +790,5 @@
endif;
return $img_arr;
}
+
?>
\ No newline at end of file