linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file mod.php

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

Documentation generated on Sat, 08 Nov 2008 14:53:31 +0100 by phpDocumentor 1.4.1