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

Source for file mod.php

Documentation is available at mod.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage newsletter
  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.  
  19. if (isset($_GET['id']))    $id=$_GET['id'];
  20. if (isset($_POST['id'])) $id=$_POST['id'];
  21.  
  22. $newsletter_object new newsletter;
  23.  
  24. $mask_statut_D='';
  25. $mask_statut_W='';
  26.  
  27.  
  28.  
  29. if(isset($_POST['enregistrer'])) {
  30.   $data_table=unserialize(urldecode($_POST['data_table']));
  31.   $result=$newsletter_object->ModifyNewsletter($id$data_table$sql_object);
  32.   $link_confirm="confirm.php?rub=".$rub."&todo=".$todo;
  33.   if($resultheader("Location: ".$link_confirm);
  34.   else  system_error();
  35. }
  36.  
  37. // Titre de la newsletter en cours de modification
  38. $requete=SQL_getNewsletterTitle($id);
  39. $result=$sql_object->DBSelect($requete);
  40. if($result==|| count($result)!=1exit;
  41. else $news_current_title=formatText($result[0]['newsletter_title'],'2HTML');
  42.  
  43.  
  44. // Obtention des données  de la BDD
  45. $req_detSQL_getoneCompleteNewsletter($id);
  46. $result=$sql_object->DBSelect($req_det);
  47. if($result==|| count($result)!=1exit;
  48.  
  49. $form_title=formatText($result[0]['newsletter_title']'2FIELD');
  50.  
  51. $xml simplexml_load_file(themePath("../newsletter/input/template.html"THEME_PUBLIC_PATH));
  52. $form_body str_replace('##CONTENTS##'formatText($result[0]['newsletter_body']'2FIELD')$xml->body->asXML());
  53. // $form_body=formatText($result[0]['newsletter_body'], '2FIELD');
  54. $form_statut=$result[0]['newsletter_statut'];
  55. $news_owner $result[0]['newsletter_posted_by'];
  56.  
  57. //////////// Check Droits utilisateur + statut newsletter courante ////////////
  58. if (!IsSuperAdmin(|| $form_statut=='P'ReloadIndex('admin');
  59. ////////////
  60.  
  61. if(isset($_POST['valider'])) {
  62.   $table[0]=$_POST['newsletter_title'];
  63.   
  64.   $html $_POST['newsletter_body'];
  65.   if (get_magic_quotes_gpc()) $html=stripslashes($html);
  66.   $html removeEmptyP($html);
  67.   
  68.     // we get only the text contained into #main div
  69.   include_once('../lib/vendor/simpleDOM/SimpleDOM.php');
  70.   $xml simpledom_load_string($html);
  71.  
  72.   $att 'id';
  73.   $body_content '';
  74.  
  75.   foreach ($xml->children(as $el{
  76.     if($el->attributes()->$att == 'main'{
  77.       $body_content $el->innerHTML();
  78.     }
  79.   }
  80.  
  81.   $table[1]=$body_content;
  82.   
  83.   $table[2]=$_POST['newsletter_statut'];
  84.  
  85.   $integrity=$newsletter_object->CheckDataIntegrity($table);
  86.  
  87.   if(is_string($integrity)) {
  88.     $text_format='2FIELD';
  89.     $body_content=$_POST['newsletter_body'];
  90.   else {
  91.     $text_format='2HTML';
  92.   }
  93.   $form_title=formatText($_POST['newsletter_title'],$text_format);
  94.   $form_body=formatText($body_content$text_format);
  95.   $form_statut=$_POST['newsletter_statut'];
  96.  
  97.  
  98.   if($_POST['newsletter_statut']=='D'$mask_statut_D='checked="checked"'else $mask_statut_D='';
  99.   if($_POST['newsletter_statut']=='P'$mask_statut_P='checked="checked"'else $mask_statut_W='';
  100.   $table=urlencode(serialize($table));
  101. }
  102.  
  103. // radio statut
  104. if($form_statut=='W'$mask_statut_W='checked="checked"';
  105. if($form_statut=='D'$mask_statut_D='checked="checked"';
  106.  
  107.  
  108.  
  109. ?>
  110.  
  111.  
  112. <div id="chemin">
  113. <ul>
  114.     <li><a href="index.php" class="chemin_home"><?php echo _t('way','home')?></a></li>
  115.     <li><a href="<?php echo $rub_link?>" id="chemin_<?php echo $rub?>" class="chemin_rub"><?php echo _t('menu','newsletter');?></a></li>
  116.     <li><span><?php echo formatNavTitle(_t('newsletter','mod')' : '.$news_current_title)?></span></li>
  117. </ul>
  118. </div>
  119. <!--end barre haute -->
  120. <?php
  121. include_once(THEME_ADMIN_PATH."quickicons.php");
  122. ?>
  123.  
  124. <?php
  125. if(!isset($integrity|| is_string($integrity)) {
  126.   ?>
  127. <div class="contentcontainer"><?php
  128. include_once($dir."/menurub.php");
  129. ?>
  130. <div id="content"><?php
  131. if(isset($integrity&& is_string($integrity)) display_errors($integrity);
  132. ?>
  133. <h2><?php echo formatTitleh2($news_current_title)?></h2>
  134. <form id="modnews" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post" enctype="multipart/form-data">
  135. <p>
  136.   <label for="newsletter_title"><?php echo _t('newsletter','title')?> : *</label>
  137.   <input name="newsletter_title" type="text" class="textfield" id="newsletter_title" maxlength="200"     value="<?php echo $form_title?>" />
  138. </p>
  139. <p>
  140.   <label for="newsletter_body"><?php echo _t('newsletter','body')?> : *</label>
  141.   <textarea id="newsletter_body" name="newsletter_body" class="largetextfield" <?php echo AREA_SETTINGS?>><?php echo $form_body?></textarea>
  142. </p>
  143. <div class="label"><?php echo _t('newsletter','statut')?> : </div>
  144. <div class="rightpanel">
  145.   <input name="newsletter_statut" type="radio" id="statut_D" value="D" <?php echo $mask_statut_D?> />
  146.   <label for="statut_D"><?php echo _t('statut','draft')?></label>
  147.   <input name="newsletter_statut" type="radio" id="statut_W" value="W" <?php echo $mask_statut_W?> />
  148.   <label for="statut_W"><?php echo _t('newsletter','nightsend')?></label>
  149. </div>
  150. <div>
  151.   <input name="id" type="hidden" value="<?php echo $id?>" id="id" />
  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. <div class="contentcontainer"><?php
  165. include_once($dir."/menurub.php");
  166. ?>
  167. <div id="content">
  168. <h2><?php echo formatTitleh2(_t('recap','title'))?></h2>
  169. <?php
  170. echo "<dl class=\"dl3\">\n";
  171. echo "<dt>"._t('newsletter','title')."</dt>\n";
  172. echo "<dd>".$form_title."</dd>\n";
  173. echo "<dt>"._t('newsletter','body')." :</dt>\n";
  174. echo "<dd>".linkin_content($form_body)."</dd>\n";
  175. echo "<dt>"._t('divers','statut'."</dt>\n";
  176. echo "<dd>"display_statut($_POST['newsletter_statut'])"</dd>\n";
  177. echo "</dl>\n";
  178. ?>
  179. <form id="modscale" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  180. <div>
  181.   <input name="id" type="hidden" value="<?php echo $id?>" id="id" />
  182.   <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  183.   <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  184.   <input name="data_table" type="hidden" value="<?php echo $table?>" id="data_table" />
  185.   <?php echo cancel_button('?rub=newsletter&amp;todo=list')?>
  186.   <input name="retour" type="button" value="<?php echo _t('btn','preview')?>" class="button" id="retour" onclick="history.go(-1);" />
  187.   <input name="enregistrer" type="submit" value="<?php echo _t('btn','save')?>" class="button" id="valider" />
  188.   </div>
  189.   </form>
  190. </div>
  191. <?php include_once($dir."/help.php")?></div>
  192. <?php
  193. }
  194. ?>

Documentation generated on Thu, 03 May 2012 15:06:28 +0200 by phpDocumentor 1.4.1