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 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 (!class_exists('auth')) {
  13.   include_once("../lib/lib_common.php");
  14.   ReloadIndex('admin');
  15. }
  16. ////////////
  17.  
  18. //////////// Check Droits utilisateur ////////////
  19. if (!$l21auth->isSuperAdmin()) 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></li>
  26.     <li><a href="<?php echo $rub_link?>" id="chemin_<?php echo $rub?>" class="chemin_rub"><?php echo _t('menu','newsletter')?></a></li>
  27.     <li><span><?php echo formatNavTitle(_t('newsletter','add'))?></span></li>
  28. </ul>
  29. </div>
  30. <!--end barre haute -->
  31. <?php
  32. $form_title='';
  33. $form_body='';
  34. $mask_statut_D='checked="checked"';
  35. $mask_statut_W='';
  36.  
  37. $xml simplexml_load_file(override("../newsletter/input/template.html"THEME_PUBLIC_PATH));
  38. $form_body str_replace('##CONTENTS##''<p>'._t('newsletter''content').'</p>'$xml->body->asXML());
  39.  
  40.  
  41.  
  42. $newsletter_object new newsletter;
  43.  
  44. if(isset($_POST['enregistrer'])) {
  45.   $data_table=unserialize(urldecode($_POST['data_table']));
  46.   $result=$newsletter_object->AddNewsletter($data_table$sql_object);
  47.   $link_confirm="confirm.php?rub=".$rub."&todo=".$todo;
  48.   if(is_numeric($result)) header("Location: ".$link_confirm);
  49.   else  system_error();
  50. }
  51.  
  52. if(isset($_POST['valider'])) {
  53.   $table[0]=$_POST['newsletter_title'];
  54.   
  55.   $html $_POST['newsletter_body'];
  56.   if (get_magic_quotes_gpc()) $html=stripslashes($html);
  57.   $html removeEmptyP($html);
  58.   
  59.   // we get only the text contained into #main div
  60.   include_once('../lib/vendor/simpleDOM/SimpleDOM.php');
  61.   $xml simpledom_load_string($html);
  62.  
  63.   $att 'id';
  64.   $body_content '';
  65.  
  66.   foreach ($xml->children(as $el{
  67.     if($el->attributes()->$att == 'main'{
  68.       $body_content $el->innerHTML();
  69.     }
  70.   }
  71.  
  72.   $table[1]=$body_content;
  73.   $table[2]=$l21auth->GetSessionElement('id')// ID posteur
  74.   $table[3]=$_POST['newsletter_statut'];
  75.  
  76.   $newsletter_objectnew newsletter;
  77.   $integrity=$newsletter_object->CheckDataIntegrity($table);
  78.  
  79.   if(is_string($integrity)) {
  80.     $text_format='2FIELD';
  81.     $body_content=$_POST['newsletter_body'];
  82.   else {
  83.     $text_format='2HTML';
  84.   }
  85.   $form_title=formatText($_POST['newsletter_title']$text_format);
  86.   $form_body=formatText($body_content$text_format);
  87.  
  88.  
  89.   if($_POST['newsletter_statut']=='D'$mask_statut_D="checked=\"checked\""else $mask_statut_D='';
  90.   if($_POST['newsletter_statut']=='W'$mask_statut_W="checked=\"checked\""else $mask_statut_P='';
  91.   $table=urlencode(serialize($table));
  92. }
  93.  
  94. include_once(THEME_ADMIN_PATH."quickicons.php");
  95.  
  96. ?>
  97.  
  98. <?php
  99. if(!isset($integrity|| is_string($integrity)) {
  100.   ?>
  101. <div class="contentcontainer"><?php
  102. include_once(override($dir.'/menurub.php'THEME_ADMIN_PATH));
  103. ?>
  104. <div id="content"><?php
  105. if(isset($integrity&& is_string($integrity)) display_errors($integrity);
  106. ?>
  107. <h2><?php echo formatTitleh2(_t('newsletter','add_title'))?></h2>
  108. <form id="addnews" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  109. <p>
  110.   <label for="newsletter_title"><?php echo mb_ucfirst(_t('newsletter','title'))?> : *</label>
  111.   <input name="newsletter_title" type="text" class="textfield" id="newsletter_title" maxlength="200" value="<?php echo $form_title?>" />
  112. </p>
  113. <p>
  114.   <label for="newsletter_body"><?php echo mb_ucfirst(_t('newsletter','body'))?> : *</label>
  115.   <textarea id="newsletter_body" name="newsletter_body" class="largetextfield" <?php echo AREA_SETTINGS?>><?php echo $form_body?></textarea>
  116. </p>
  117. <div class="label"><?php echo mb_ucfirst(_t('newsletter','statut'))?> : *</div>
  118. <div class="rightpanel">
  119.   <input name="newsletter_statut" type="radio" id="statut_D" value="D" <?php echo $mask_statut_D?> />
  120.   <label for="statut_D"><?php echo mb_ucfirst(_t('statut','draft'))?></label>
  121.   <input name="newsletter_statut" type="radio" id="statut_W" value="W" <?php echo $mask_statut_W?> />
  122.   <label for="statut_W"><?php echo mb_ucfirst(_t('newsletter','nightsend'))?></label>
  123. </div>
  124. <div>
  125.   <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  126.   <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  127.   <?php echo cancel_button('javascript:history.go(-1);')?>
  128.   <input name="valider" type="submit" value="<?php echo _t('btn','valid'?>" class="button" id="valider" />
  129. </div>
  130. </form>
  131. </div>
  132. <?php include_once(override($dir.'/help.php'THEME_ADMIN_PATH))?></div>
  133. <?php
  134. // Récapitulatif
  135. else    {
  136.  
  137.   ?>
  138. <div class="contentcontainer"><?php
  139. include_once(override($dir.'/menurub.php'THEME_ADMIN_PATH));
  140. ?>
  141. <div id="content">
  142. <h2><?php echo formatTitleh2(_t('recap','title'))?></h2>
  143. <?php
  144. echo "<dl class=\"dl3\">\n";
  145. echo "<dt>".mb_ucfirst(_t('newsletter','title'))." :</dt>\n";
  146. echo "<dd>"$form_title."</dd>\n";
  147. echo "<dt>".mb_ucfirst(_t('newsletter','body'))." :</dt>\n";
  148. echo "<dd>".linkin_content($form_body)."</dd>\n";
  149. echo "<dt>".mb_ucfirst(_t('divers','statut'))." :</dt>\n";
  150. echo "<dd>"display_statut($_POST['newsletter_statut'])"</dd>\n";
  151. echo "</dl>\n";
  152. ?>
  153. <form id="addscale" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  154. <div>
  155.   <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  156.   <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  157.   <input name="data_table" type="hidden" value="<?php echo $table?>" id="data_table" />
  158.   <?php echo cancel_button('?rub=newsletter&amp;todo=list')?>
  159.   <input name="retour" type="button" value="<?php echo _t('btn','preview')?>" class="button" id="retour" onclick="history.go(-1);" />
  160.   <input name="enregistrer" type="submit" value="<?php echo _t('btn','save')?>" class="button" id="valider" />
  161. </div>
  162. </form>
  163. </div>
  164. <?php include_once(override($dir.'/help.php'THEME_ADMIN_PATH))?></div>
  165. <?php
  166. }
  167. ?>

Documentation generated on Mon, 08 Apr 2013 18:11:47 +0200 by phpDocumentor 1.4.1