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 content
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  *  'Content' module is used by 'Publication' and 'Workshop' modules
  10.  */
  11.  
  12. //////////// Check Inclusion de pages ////////////
  13. if (!function_exists('AuthenthificationProcess')) {
  14.     include_once("../lib/lib_common.php");
  15.     ReloadIndex('admin');
  16. } 
  17. ////////////
  18.  
  19. $contents_object = new contents;
  20. $complete_type=strtoupper($mod_inc);
  21. $mask_template=array_fill(1, 3, '');
  22. $form_title='';
  23. $form_body='';
  24. $layer_tpl_1 = "style=\"display:block;\"";
  25.  
  26. if(isset($_POST['enregistrer'])) {
  27.     $data_table=unserialize(urldecode($_POST['data_table']));
  28.     $result=$contents_object->AddContents($parent, $data_table, $complete_type, $sql_object);
  29.     $link_confirm="confirm.php?rub=".$rub."&todo=".$todo."&type=".$type."&id=".$parent;
  30.     echo $result;
  31.     if($result===true) header("Location: ".$link_confirm);
  32.     else  system_error();
  33. }
  34.  
  35. if(isset($_POST['valider'])) {
  36.     $table[0]=$_POST['part_title'];
  37.     $table[1]=$_POST['part_body'];
  38.  
  39.     if($type=='P') {
  40.         $table[2]=$_POST['part_template'];
  41.         $table[3]=isset($_FILES['visuel1']['name']) ? $_FILES['visuel1']['name'] : '' ;
  42.     }
  43.     $integrity=$contents_object->CheckDataIntegrity($table,$type, 'ROCK');
  44.     
  45.     if(!is_string($integrity)) {
  46.         if (isset($_POST['part_template']) && $_POST['part_template'] != 3) {
  47.             include_once('../class/system/class.upload.php');
  48.             include_once('../class/system/class.image.php');
  49.             $image_object = new image;
  50.             $upload_object = new upload;
  51.             $upload1 = $_FILES['visuel1'];
  52.             $size_integrity=$upload_object->CheckMaxFile($upload1['size'], $contents_object->P_UPLOAD_MAX_MO);
  53.             if(is_string($size_integrity)) $integrity=$size_integrity;
  54.             $format_integrity=$upload_object->CheckExtImage($upload1['name']);
  55.             if(is_string($format_integrity)) $integrity=$format_integrity;
  56.  
  57.             if(!is_string($integrity)) {
  58.                 $result=$sql_object->DBSelect($req_max_publi_content_id, 'OBJECT');
  59.                 $file_name=($result[0]->maxid+1);
  60.                 $destination="../".$contents_object->P_URI_INPUT;
  61.                 $final_name=$file_name.".".$upload_object->GetExtension($upload1['name']);
  62.                 $visual_link1=$destination.$final_name;
  63.                 $table[3]=$contents_object->P_URI_INPUT.$final_name;
  64.                 $result_upload=$upload_object->UploadFile($upload1, $final_name, $destination);
  65.                 
  66.                 // création des thumbs
  67.                 $min_name=get_min_name($destination.$final_name);
  68.                 $image_object->ThumbCreate($destination.$final_name, $min_name , $contents_object->P_MAX_PHOTO_MIN_WIDTH);
  69.                 
  70.                 // on retaille l'original au besoin.
  71.                 if(PHOTO_RESIZE===true && ExcedMaxSize($destination.$final_name, $contents_object->P_MAX_PHOTO_MAX_WIDTH)) {
  72.                     $image_object->ThumbCreate($destination.$final_name, $destination.$final_name , $contents_object->P_MAX_PHOTO_MAX_WIDTH);
  73.                 }
  74.                 
  75.                 // préparation de l'affichage de la miniature
  76.                 $visual_link1=EnlargeImage($visual_link1);
  77.             }
  78.         } elseif(isset($_POST['part_template'])) $table[3]='';
  79.     }
  80.  
  81.     
  82.     if(is_string($integrity)) {
  83.         $text_format='2FIELD';
  84.     } else {
  85.         $text_format='2HTML';
  86.     }
  87.     $form_title=formatText($_POST['part_title'], $text_format);
  88.     $form_body=formatText($_POST['part_body'], $text_format);
  89.     if($type=='P') {
  90.         $mask_template[$_POST['part_template']]=' selected="selected"';
  91.         if($_POST['part_template']==3) $layer_tpl_1 = "style=\"display:none;\"";
  92.     }
  93.     
  94.     $table=urlencode(serialize($table));
  95. }
  96.  
  97. if($type=='P') {
  98.     $requete= SQL_getPublicationTitle($parent);
  99.     $result=$sql_object->DBSelect($requete);
  100.     $current_title=FormatText($result[0]['publi_title']);
  101.     $publi_owner=$result[0]['publi_posted_by'];
  102.     //////////// Check Droits utilisateur ////////////
  103.     if (!HaveRight('publication')) ReloadIndex('admin');
  104.     if (GetSessionElement('id')!=$publi_owner && !IsSuperAdmin()) ReloadIndex('admin');
  105.     ///////////
  106.     
  107.     // select-box Templates
  108.     $select_template="<select name=\"part_template\" id=\"part_template\" onchange=\"ShowFilesLayer(this.value, 'contents')\">\n";
  109.     $select_template.="<option value=\"1\"".$mask_template[1].">".$contents_object->GetTemplateName(1)."</option>\n";
  110.     $select_template.="<option value=\"2\"".$mask_template[2].">".$contents_object->GetTemplateName(2)."</option>\n";
  111.     $select_template.="<option value=\"3\"".$mask_template[3].">".$contents_object->GetTemplateName(3)."</option>\n";
  112.     $select_template.="</select>\n";
  113. }
  114.  
  115. if($type=='W') {
  116.     $requete= SQL_getWorkshopRepTitleAndGroup($parent);
  117.     $result=$sql_object->DBSelect($requete);
  118.     $current_title=FormatText($result[0]['workrep_title']).' ('.FormatText($result[0]['workshop_denomination']).')';
  119.     $workshop_id=$result[0]['workrep_workshop_id'];
  120.     //////////// Check Droits utilisateur ////////////
  121.     if (!HaveRight('workshop')) ReloadIndex('admin');
  122.     if (!AuthUser4Workshop($workshop_id, $sql_object) && !IsSuperAdmin()) ReloadIndex('admin');
  123.     ///////////
  124. }
  125.  
  126.  
  127.  
  128.  
  129. ?>
  130.  
  131. <div id="chemin">
  132.     <ul>
  133.         <li>
  134.             <a href="index.php"><? echo $GLOBALS['lang']['way']['home'] ?></a>
  135.         </li>
  136.         <li>
  137.             <a href="<?php echo $rub_link; ?>"><? echo $GLOBALS['lang']['menu'][$mod_inc]?></a>
  138.         </li>
  139.         <li>
  140.             <span><? echo formatNavTitle($GLOBALS['lang']['contents'][$mod_inc.'_type']." : ". $current_title); ?></span>
  141.         </li>
  142.     </ul>
  143. </div>
  144. <!--end barre haute -->
  145. <?php
  146. include_once("quickicons.php");
  147. ?>
  148.  
  149. <?php
  150. if(!isset($integrity) || is_string($integrity)) {
  151. ?>
  152. <div class="contentcontainer">
  153.         <?php
  154.         include_once($dir."/menurub.php");
  155.         ?>
  156.         <div id="content">
  157.             <?php
  158.             if(isset($integrity) && is_string($integrity)) display_errors($integrity);
  159.             ?>
  160.             <h2><? echo formatTitleh2($GLOBALS['lang']['contents'][$mod_inc.'_type']." : ". $current_title); ?></h2>
  161.             <form id="addpart" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post" enctype="multipart/form-data">
  162.                 <p>
  163.                 <label for="part_title"><? echo $GLOBALS['lang']['contents']['title']; ?> : *</label>
  164.                 <input name="part_title" type="text" class="textfield" id="part_title" maxlength="200" value="<?php echo $form_title; ?>" />
  165.                 </p>
  166.                 <p>
  167.                 <label for="part_body"><? echo $GLOBALS['lang']['contents']['body']; ?> : *</label>
  168.                 <textarea id="part_body" name="part_body" class="largetextfield" <?php echo AREA_SETTINGS; ?>><?php echo $form_body; ?></textarea>
  169.                 </p>
  170.                 <p>
  171.                 <?php  if($type=='P') { ?>
  172.                 <label for="part_template" ><? echo $GLOBALS['lang']['contents']['template']; ?> : </label>
  173.                 <?php echo $select_template; ?>
  174.                 </p>
  175.                 <p id="layervisuel1" <?php echo $layer_tpl_1; ?>>
  176.                     <label for="visuel1"><?php echo $GLOBALS['lang']['contents']['visu1']; ?></label>
  177.                     <input name="visuel1" type="file" size="47" id="visuel1"  class="file" /><br /><br />
  178.                 </p>
  179.                 <?php } ?>
  180.                 <div>
  181.                 <input name="rub" type="hidden" value="<?php echo $rub; ?>" id="rub" />
  182.                 <input name="todo" type="hidden" value="<?php echo $todo; ?>" id="todo" />
  183.                 <input name="type" type="hidden" value="<?php echo $type; ?>" id="type" />
  184.                 <input name="parent" type="hidden" value="<?php echo $parent; ?>" id="parent" />
  185.                 <?php echo cancel_button($cancel_link); ?>
  186.                 <input name="valider" type="submit" value="<? echo $GLOBALS['lang']['btn']['valid'] ?>" class="button" id="valider" />
  187.                 </div>
  188.             </form>
  189.         </div>
  190. <?php include_once($dir."/help.php"); ?>
  191. </div>
  192. <?php
  193. // Récapitulatif
  194. } else    {
  195.  
  196. if($type=='P') {
  197.     if($_POST['part_template']==3) {
  198.         $display_visual=$GLOBALS['lang']['divers']['none'];
  199.     } else {
  200.         $display_visual=$visual_link1;
  201.     }
  202.     $display_template_choice=$contents_object->GetTemplateName($_POST['part_template']);
  203. }
  204.  
  205. ?>
  206. <div class="contentcontainer">
  207. <?php
  208. include_once($dir."/menurub.php");
  209. ?>
  210. <div id="content">
  211.             <h2><? echo $GLOBALS['lang']['recap']['title'] ?></h2>
  212.             <?php
  213.             echo "<dl class=\"dl3\">\n";
  214.             echo "<dt>".$GLOBALS['lang']['contents']['title']."</dt>\n";
  215.             echo "<dd>".$form_title."</dd>\n";
  216.             echo "<dt>".$GLOBALS['lang']['contents']['body']."</dt>\n";
  217.             echo "<dd>".linkin_content($form_body)."</dd>\n";
  218.             if($type=='P') {
  219.                 echo "<dt>".$GLOBALS['lang']['contents']['template']."</dt>\n";
  220.                 echo "<dd>".$display_template_choice."</dd>\n";
  221.                 echo "<dt>".$GLOBALS['lang']['contents']['visu1']."</dt>\n";
  222.                 echo "<dd>".$display_visual."</dd>\n";
  223.             }
  224.             echo "</dl>\n";
  225.             ?>
  226.             <form id="addscale" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
  227.                 <div>
  228.                 <input name="rub" type="hidden" value="<?php echo $rub; ?>" id="rub" />
  229.                 <input name="todo" type="hidden" value="<?php echo $todo; ?>" id="todo" />
  230.                 <input name="type" type="hidden" value="<?php echo $type; ?>" id="type" />
  231.                 <input name="parent" type="hidden" value="<?php echo $parent; ?>" id="parent" />
  232.                 <input name="data_table" type="hidden" value="<?php echo $table; ?>" id="data_table" />
  233.                 <input name="retour" type="button" value="<? echo $GLOBALS['lang']['btn']['preview'] ?>" class="button" id="retour" onclick="history.go(-1);" />
  234.                 <input name="enregistrer" type="submit" value="<? echo $GLOBALS['lang']['btn']['save'] ?>" class="button" id="valider" />
  235.                 </div>
  236.             </form>
  237.         </div>
  238.     <?php include_once($dir."/help.php"); ?>
  239. </div>
  240. <?php
  241. }
  242. ?>

Documentation generated on Sat, 08 Nov 2008 14:50:40 +0100 by phpDocumentor 1.4.1