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

Documentation generated on Fri, 16 Oct 2009 09:28:14 +0200 by phpDocumentor 1.4.1