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

Documentation generated on Fri, 01 Apr 2011 09:27:27 +0200 by phpDocumentor 1.4.1