<?PHP
/************************************************************************/
/* DYNAMIC THEME engine for NPDS V / Net Portal Dynamic System          */
/* ===========================                                          */
/*                                                                      */
/* This version name NPDS Copyright (c) 2002-2004 by Philippe Brunier   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
require_once("modules/meta-lang/meta_lang.php");
require_once("modules/aide-contextuelle/AC.php");

function local_aid($aid) {
   global $sid, $admin;
   $holder = mysql_query("SELECT url, email FROM authors where aid='$aid'");
   if ($holder) {
      list($url, $email) = mysql_fetch_row($holder);
      if (isset($url)) {
         $auteur="<a href=\"$url\">$aid</a>";
      } elseif (isset($email)) {
         $auteur="<a href=\"mailto:$email\">$aid</a>";
      } else {
         $auteur=$aid;
      }
   }
   if (($sid!="") and ($admin))
      $auteur.="&nbsp;&nbsp;[ <a href=\"admin.php?op=EditStory&amp;sid=$sid\">".translate("Edit")."</a> | <a href=\"admin.php?op=RemoveStory&amp;sid=$sid\">".translate("Delete")."</a> ]";
   return ($auteur);

}

function local_var($Xcontent) {
   if (strstr($Xcontent,"!var!")) {
      $deb=strpos($Xcontent,"!var!",0)+5;
      $fin=strpos($Xcontent," ",$deb);
      if ($fin) {
         $H_var=substr($Xcontent,$deb,$fin-$deb);
      } else {
         $H_var=substr($Xcontent,$deb);
      }
      return ($H_var);
   }
}

function themeindex ($aid, $informant, $time, $title, $counter, $topic, $thetext, $notes, $morelink, $topicname, $topicimage, $topictext) {
   global $tipath, $theme, $nuke_url;
   if (file_exists("themes/$theme/html/index-news.html")) {
      $H_var=local_var($thetext);
      if ($H_var!="") {
         ${$H_var}=true;
         $thetext=str_replace("!var!$H_var","",$thetext);
      }
      ob_start();
         include("themes/$theme/html/index-news.html");
         $Xcontent=ob_get_contents();
      ob_end_clean();
      $npds_METALANG_words=array(
      "'!N_publicateur!'i"=>local_aid($aid),
      "'!N_emetteur!'i"=>"<a href=\"user.php?op=userinfo&amp;uname=$informant\">$informant</a>",
      "'!N_date!'i"=>"$time",
      "'!N_titre!'i"=>"$title",
      "'!N_sujet!'i"=>"<a href=\"search.php?query=&amp;topic=$topic\"><img src=\"".$tipath.$topicimage."\" alt=\"".$topictext."\" border=\"0\" /></a>",
      "'!N_texte!'i"=>"$thetext",
      "'!N_note!'i"=>"$notes",
      "'!N_nb_lecture!'i"=>"$counter",
      "'!N_suite!'i"=>"$morelink"
      );
      echo meta_lang(aff_langue(preg_replace(array_keys($npds_METALANG_words),array_values($npds_METALANG_words), $Xcontent)));
   } else {
      echo "index-news.html manquant / not find !<br />";
      die();
   }
}

function themearticle ($aid, $informant, $datetime, $title, $thetext, $topic, $topicname, $topicimage, $topictext) {
   global $tipath, $theme, $nuke_url;
   if (file_exists("themes/$theme/html/detail-news.html")) {
      $H_var=local_var($thetext);
      if ($H_var!="") {
         ${$H_var}=true;
         $thetext=str_replace("!var!$H_var","",$thetext);
      }
      ob_start();
         include("themes/$theme/html/detail-news.html");
         $Xcontent=ob_get_contents();
      ob_end_clean();
      $npds_METALANG_words=array(
      "'!N_publicateur!'i"=>local_aid($aid),
      "'!N_emetteur!'i"=>"<a href=\"user.php?op=userinfo&amp;uname=$informant\">$informant</a>",
      "'!N_date!'i"=>"$datetime",
      "'!N_titre!'i"=>"$title",
      "'!N_sujet!'i"=>"<a href=\"search.php?query=&amp;topic=$topic\"><img src=\"".$nuke_url."/".$tipath.$topicimage."\" alt=\"$topictext\" border=\"0\" /></a>",
      "'!N_texte!'i"=>"$thetext",
      "'!N_note!'i"=>"$notes"
      );
      echo meta_lang(aff_langue(preg_replace(array_keys($npds_METALANG_words),array_values($npds_METALANG_words), $Xcontent)));
   } else {
      echo "detail-news.html manquant / not find !<br />";
      die();
   }
}

function themesidebox($title, $content) {
   global $theme, $B_class_title, $B_class_content, $bloc_side;
   $inclusion=false;
   if (file_exists("themes/$theme/html/bloc-right.html") and ($bloc_side=="RIGHT")) {
      $inclusion="themes/$theme/html/bloc-right.html";
   }
   if (file_exists("themes/$theme/html/bloc-left.html") and ($bloc_side=="LEFT")) {
      $inclusion="themes/$theme/html/bloc-left.html";
   }
   if (!$inclusion) {
      if (file_exists("themes/$theme/html/bloc.html")) {
         $inclusion="themes/$theme/html/bloc.html";
      } else {
        echo "bloc.html manquant / not find !<br />";
        die();
      }
   }
   ob_start();
      include($inclusion);
      $Xcontent=ob_get_contents();
   ob_end_clean();
   $npds_METALANG_words=array(
   "'!B_title!'i"=>AidBlocRequestX($title),
   "'!B_class_title!'i"=>"$B_class_title",
   "'!B_class_content!'i"=>"$B_class_content",
   "'!B_content!'i"=>"$content"
   );
   echo meta_lang(preg_replace(array_keys($npds_METALANG_words),array_values($npds_METALANG_words), $Xcontent));
}

function themedito($content) {
   global $theme;
   $inclusion=false;
   if (file_exists("themes/$theme/html/editorial.html")) {
      $inclusion="themes/$theme/html/editorial.html";
   }
   if ($inclusion) {
      ob_start();
         include($inclusion);
         $Xcontent=ob_get_contents();
      ob_end_clean();
      $npds_METALANG_words=array(
      "'!editorial_content!'i"=>"$content"
      );
      echo meta_lang(preg_replace(array_keys($npds_METALANG_words),array_values($npds_METALANG_words), $Xcontent));
   }
   return ($inclusion);
}
?>