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.  
  38. include_once('../lib/vendor/simple_html_dom.php');
  39.  
  40. $html = file_get_html(override("../newsletter/input/template.html", THEME_PUBLIC_PATH));
  41. $html = str_replace('##SITEURL##', SITE_ROOT_URL, $html);
  42. $form_body = str_replace('##CONTENTS##', '<p>'._t('newsletter', 'content').'</p>', $html);
  43.  
  44.  
  45.  
  46. $newsletter_object = new newsletter;
  47.  
  48. if(isset($_POST['enregistrer'])) {
  49.   $data_table=unserialize(urldecode($_POST['data_table']));
  50.   $result=$newsletter_object->AddNewsletter($data_table, $sql_object);
  51.   $link_confirm="confirm.php?rub=".$rub."&todo=".$todo;
  52.   if(is_numeric($result)) header("Location: ".$link_confirm);
  53.   else  system_error();
  54. }
  55.  
  56. if(isset($_POST['valider'])) {
  57.   $table[0]=$_POST['newsletter_title'];
  58.   
  59.   $html = $_POST['newsletter_body'];
  60.   if (get_magic_quotes_gpc()) $html=stripslashes($html);
  61.   
  62.   $html = removeEmptyP($html);
  63.  
  64.  
  65.   
  66.   $flow = str_get_html($html);
  67.   $body_content = $flow->find('#main', 0)->innertext;
  68.   _debug($body_content);
  69.  
  70.   $table[1]=$body_content;
  71.   $table[2]=$l21auth->GetSessionElement('id'); // ID posteur
  72.   $table[3]=$_POST['newsletter_statut'];
  73.  
  74.   $newsletter_object= new newsletter;
  75.   $integrity=$newsletter_object->CheckDataIntegrity($table);
  76.  
  77.   if(is_string($integrity)) {
  78.     $text_format='2FIELD';
  79.     $body_content=$_POST['newsletter_body'];
  80.   } else {
  81.     $text_format='2HTML';
  82.   }
  83.   $form_title=formatText($_POST['newsletter_title'], $text_format);
  84.   $form_body=formatText($body_content, $text_format);
  85.  
  86.  
  87.   if($_POST['newsletter_statut']=='D') $mask_statut_D="checked=\"checked\""; else $mask_statut_D='';
  88.   if($_POST['newsletter_statut']=='W') $mask_statut_W="checked=\"checked\""; else $mask_statut_P='';
  89.   $table=urlencode(serialize($table));
  90. }
  91.  
  92. include_once(THEME_ADMIN_PATH."quickicons.php");
  93.  
  94. ?>
  95.  
  96. <?php
  97. if(!isset($integrity) || is_string($integrity)) {
  98.   ?>
  99. <div class="contentcontainer"><?php
  100. include_once(override($dir.'/menurub.php', THEME_ADMIN_PATH));
  101. ?>
  102. <div id="content"><?php
  103. if(isset($integrity) && is_string($integrity)) display_errors($integrity);
  104. ?>
  105. <h2><?php echo formatTitleh2(_t('newsletter','add_title')); ?></h2>
  106. <form id="addnews" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
  107. <p>
  108.   <label for="newsletter_title"><?php echo mb_ucfirst(_t('newsletter','title')); ?> : *</label>
  109.   <input name="newsletter_title" type="text" class="textfield" id="newsletter_title" maxlength="200" value="<?php echo $form_title; ?>" />
  110. </p>
  111. <p>
  112.   <label for="newsletter_body"><?php echo mb_ucfirst(_t('newsletter','body')); ?> : *</label>
  113.   <textarea id="newsletter_body" name="newsletter_body" class="largetextfield" <?php echo AREA_SETTINGS; ?>><?php echo $form_body; ?></textarea>
  114. </p>
  115. <div class="label"><?php echo mb_ucfirst(_t('newsletter','statut')); ?> : *</div>
  116. <div class="rightpanel">
  117.   <input name="newsletter_statut" type="radio" id="statut_D" value="D" <?php echo $mask_statut_D; ?> />
  118.   <label for="statut_D"><?php echo mb_ucfirst(_t('statut','draft')); ?></label>
  119.   <input name="newsletter_statut" type="radio" id="statut_W" value="W" <?php echo $mask_statut_W; ?> />
  120.   <label for="statut_W"><?php echo mb_ucfirst(_t('newsletter','nightsend')); ?></label>
  121. </div>
  122. <div>
  123.   <input name="rub" type="hidden" value="<?php echo $rub; ?>" id="rub" />
  124.   <input name="todo" type="hidden" value="<?php echo $todo; ?>" id="todo" />
  125.   <?php echo cancel_button('javascript:history.go(-1);'); ?>
  126.   <input name="valider" type="submit" value="<?php echo _t('btn','valid') ?>" class="button" id="valider" />
  127. </div>
  128. </form>
  129. </div>
  130. <?php include_once(override($dir.'/help.php', THEME_ADMIN_PATH)); ?></div>
  131. <?php
  132. // Récapitulatif
  133. } else    {
  134.  
  135.   ?>
  136. <div class="contentcontainer"><?php
  137. include_once(override($dir.'/menurub.php', THEME_ADMIN_PATH));
  138. ?>
  139. <div id="content">
  140. <h2><?php echo formatTitleh2(_t('recap','title')); ?></h2>
  141. <?php
  142. echo "<dl class=\"summary\">\n";
  143. echo "<dt>".mb_ucfirst(_t('newsletter','title'))." :</dt>\n";
  144. echo "<dd>". $form_title."</dd>\n";
  145. echo "<dt>".mb_ucfirst(_t('newsletter','body'))." :</dt>\n";
  146. echo "<dd>".linkin_content($form_body)."</dd>\n";
  147. echo "<dt>".mb_ucfirst(_t('divers','statut'))." :</dt>\n";
  148. echo "<dd>". display_statut($_POST['newsletter_statut']). "</dd>\n";
  149. echo "</dl>\n";
  150. ?>
  151. <form id="addscale" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
  152. <div>
  153.   <input name="rub" type="hidden" value="<?php echo $rub; ?>" id="rub" />
  154.   <input name="todo" type="hidden" value="<?php echo $todo; ?>" id="todo" />
  155.   <input name="data_table" type="hidden" value="<?php echo $table; ?>" id="data_table" />
  156.   <?php echo cancel_button('?rub=newsletter&amp;todo=list'); ?>
  157.   <input name="retour" type="button" value="<?php echo _t('btn','preview'); ?>" class="button" id="retour" onclick="history.go(-1);" />
  158.   <input name="enregistrer" type="submit" value="<?php echo _t('btn','save'); ?>" class="button" id="valider" />
  159. </div>
  160. </form>
  161. </div>
  162. <?php include_once(override($dir.'/help.php', THEME_ADMIN_PATH)); ?></div>
  163. <?php
  164. }
  165. ?>

Documentation generated on Thu, 20 Mar 2014 16:45:48 +0100 by phpDocumentor 1.4.1