linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file add.php

Documentation is available at add.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage news
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. //////////// Check Inclusion de pages ////////////
  12. if (!function_exists('AuthenthificationProcess')) {
  13.   include_once("../lib/lib_common.php");
  14.   ReloadIndex('admin');
  15. }
  16. ////////////
  17.  
  18. //////////// Check Droits utilisateur ////////////
  19. if (!hasRight('news')) ReloadIndex('admin');
  20. ////////////
  21. ?>
  22.  
  23. <div id="chemin">
  24. <ul>
  25.     <li><a href="index.php" class="chemin_home"><?php echo _t('way','home')?></a>
  26.     </li>
  27.     <li><a href="<?php echo $rub_link?>" id="chemin_<?php echo $rub?>"
  28.         class="chemin_rub"><?php echo _t('menu','news')?></a></li>
  29.     <li><span><?php echo formatNavTitle(_t('news','add'))?></span></li>
  30. </ul>
  31. </div>
  32. <!--end barre haute -->
  33. <?php
  34. $form_title='';
  35. $form_header='';
  36. $form_body='';
  37. $form_theme=-1;
  38. $form_scale=-1;
  39. $form_level=-1;
  40. $mask_statut_P="checked=\"checked\"";
  41. $mask_statut_D='';
  42.  
  43.  
  44. $news_object new news;
  45.  
  46. if(isset($_POST['enregistrer'])) {
  47.   $data_table=unserialize(urldecode($_POST['data_table']));
  48.   $result=$news_object->AddNews($data_table$sql_object);
  49.   $link_confirm="confirm.php?rub=".$rub."&todo=".$todo;
  50.   if(is_numeric($result)) header("Location: ".$link_confirm);
  51.   else  system_error();
  52. }
  53.  
  54. if(isset($_POST['valider'])) {
  55.   $table[0]=$_POST['news_title'];
  56.   $table[1]=$_POST['news_header'];
  57.   $table[2]=$_POST['news_body'];
  58.   $table[3]=$_POST['news_theme'];
  59.   $table[4]=$_POST['news_scale'];
  60.   $table[5]=$_POST['news_level'];
  61.   $table[6]=0//range
  62.   $table[7]=GetSessionElement('id')// ID posteur
  63.   $table[8]=''// date de péremption
  64.   $table[9]='N'// is_national
  65.   $table[10]=$_POST['news_statut'];
  66.  
  67.   $news_objectnew news;
  68.   $integrity=$news_object->CheckDataIntegrity($table);
  69.  
  70.  
  71.   if(is_string($integrity)) {
  72.     $text_format='2FIELD';
  73.   else {
  74.     $text_format='2HTML';
  75.   }
  76.   $form_title=formatText($_POST['news_title']$text_format);
  77.   $form_header=formatText($_POST['news_header']$text_format);
  78.   $form_body=formatText($_POST['news_body']$text_format);
  79.   $form_theme=$_POST['news_theme'];
  80.   $form_scale=$_POST['news_scale'];
  81.   $form_level=$_POST['news_level'];
  82.  
  83.  
  84.   if($_POST['news_statut']=='D'$mask_statut_D="checked=\"checked\""else $mask_statut_D='';
  85.   if($_POST['news_statut']=='P'$mask_statut_P="checked=\"checked\""else $mask_statut_P='';
  86.   $table=urlencode(serialize($table));
  87. }
  88.  
  89.  
  90. if(!isset($integrity|| is_string($integrity)) {
  91.   include_once("../lib/input_helpers.php");
  92.  
  93.   // select-box de thèmes
  94.   $data=$sql_object->DBSelect($req_list_theme);
  95.   $select_theme=ThemeSelectBox($data"news_theme"$form_theme);
  96.  
  97.   // select-box des échelles
  98.   $data=$sql_object->DBSelect($req_list_scale);
  99.   $select_scale=ScaleSelectBox($data"news_scale"$form_scale);
  100.  
  101.   // select-box des niveaux
  102.   $data=$sql_object->DBSelect($req_list_level);
  103.   $select_level=LevelSelectBox($data"news_level"$form_level);
  104.  
  105. }
  106.  
  107. include_once(THEME_ADMIN_PATH."quickicons.php");
  108.  
  109. ?>
  110.  
  111. <?php
  112. if(!isset($integrity|| is_string($integrity)) {
  113. ?>
  114. <div class="contentcontainer"><?php
  115. include_once($dir."/menurub.php");
  116. ?>
  117. <div id="content"><?php
  118. if(isset($integrity&& is_string($integrity)) display_errors($integrity);
  119. ?>
  120. <h2><?php echo formatTitleh2(_t('news','add_title'))?></h2>
  121. <form id="addnews" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  122. <p>
  123.   <label for="news_title"><?php echo _t('news','title')?> : *</label>
  124.   <input name="news_title" type="text" maxlength="200" id="news_title" class="textfield" value="<?php echo $form_title?>" />
  125. </p>
  126. <p>
  127.   <label for="news_header"><?php echo _t('news','header')?> : *</label>
  128.   <textarea id="news_header" name="news_header" class="largetextfield" <?php echo AREA_SETTINGS?>><?php echo $form_header?></textarea>
  129. </p>
  130. <p>
  131.   <label for="news_body"><?php echo _t('news','body')?> : *</label>
  132.   <textarea id="news_body" name="news_body" class="largetextfield" <?php echo AREA_SETTINGS?>><?php echo $form_body?></textarea>
  133. </p>
  134. <p>
  135.   <label for="news_theme"><?php echo _t('news','theme')?> : *</label>
  136.   <?php echo $select_theme?>
  137. </p>
  138. <p>
  139. <label for="news_scale"><?php echo _t('news','scale')?> : *</label>
  140.   <?php echo $select_scale?>
  141. </p>
  142. <p>
  143.   <label for="news_level"><?php echo _t('news','level')?> : </label>
  144.   <?php echo $select_level?>
  145. </p>
  146.   <div class="label"><?php echo _t('news','statut')?> : </div>
  147.   <div class="rightpanel">
  148.   <input name="news_statut" type="radio" id="statut_P" value="P" <?php echo $mask_statut_P?> /><label for="statut_P"><?php echo _t('statut','public')?></label>
  149.   <input name="news_statut" type="radio" id="statut_D" value="D" <?php echo $mask_statut_D?> /><label for="statut_D"><?php echo _t('statut','draft')?></label>
  150.   </div>
  151. <div>
  152.   <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  153.   <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  154.   <?php echo cancel_button('javascript:history.go(-1);')?>
  155.   <input name="valider" type="submit" value="<?php echo _t('btn','valid'?>" class="button" id="valider" />
  156. </div>
  157. </form>
  158. </div>
  159.     <?php include_once($dir."/help.php")?></div>
  160.     <?php
  161.     // Récapitulatif
  162. else    {
  163.  
  164.   $requete=SQL_getonethemeName($form_theme);
  165.   $result=$sql_object->DBSelect($requete);
  166.   if($result==|| count($result)!=1exit;
  167.   else $theme_denomination=formatText($result[0]['theme_name']'2HTML');
  168.  
  169.   $requete=SQL_getonescaleDenomination($form_scale);
  170.   $result=$sql_object->DBSelect($requete);
  171.   if($result==|| count($result)!=1exit;
  172.   else $scale_denomination=formatText($result[0]['scale_denomination']'2HTML');
  173.  
  174.   if($form_level <> -1{
  175.     $requete=SQL_getonelevelName($form_level);
  176.     $result=$sql_object->DBSelect($requete);
  177.     if($result==|| count($result)!=1exit;
  178.     else $level_denomination=formatText($result[0]['level_name']'2HTML');
  179.   }else $level_denomination=_t('divers','none');
  180.  
  181.  
  182.   ?>
  183. <div class="contentcontainer"><?php
  184. include_once($dir."/menurub.php");
  185. ?>
  186. <div id="content">
  187. <h2><?php echo formatTitleh2(_t('recap','title'))?></h2>
  188. <?php
  189. echo "<dl class=\"dl3\">\n";
  190. echo "<dt>"._t('news','title')."</dt>\n";
  191. echo "<dd>"$form_title."</dd>\n";
  192. echo "<dt>"_t('news','header')"</dt>\n";
  193. echo "<dd>".empty_nc(linkin_content($form_header))."</dd>\n";
  194. echo "<dt>"._t('news','body')." :</dt>\n";
  195. echo "<dd>".linkin_content($form_body)."</dd>\n";
  196. echo "<dt>"._t('news','theme')." :</dt>\n";
  197. echo "<dd>".$theme_denomination."</dd>\n";
  198. echo "<dt>"._t('news','scale')." :</dt>\n";
  199. echo "<dd>".$scale_denomination."</dd>\n";
  200. echo "<dt>"._t('news','level')." :</dt>\n";
  201. echo "<dd>".$level_denomination."</dd>\n";
  202. echo "<dt>"._t('divers','statut')."</dt>\n";
  203. echo "<dd>"display_statut($_POST['news_statut'])"</dd>\n";
  204. echo "</dl>\n";
  205. ?>
  206. <form id="addscale" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  207.   <div>
  208.     <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  209.     <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  210.     <input name="data_table" type="hidden" value="<?php echo $table?>" id="data_table" />
  211.     <?php echo cancel_button('?rub=news&amp;todo=list')?>
  212.     <input name="retour" type="button" value="<?php echo _t('btn','preview')?>" class="button" id="retour" onclick="history.go(-1);" />
  213.     <input name="enregistrer" type="submit" value="<?php echo _t('btn','save')?>" class="button" id="valider" />
  214.   </div>
  215. </form>
  216. </div>
  217. <?php include_once($dir."/help.php")?></div>
  218. <?php
  219. }
  220. ?>

Documentation generated on Thu, 03 May 2012 15:01:54 +0200 by phpDocumentor 1.4.1