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

Documentation generated on Fri, 16 Oct 2009 09:37:13 +0200 by phpDocumentor 1.4.1