Changeset 31553


Ignore:
Timestamp:
Apr 17, 2016, 10:06:37 PM (8 years ago)
Author:
ddtddt
Message:

[extensions] - manage_properties_photos - no use $confpicture_informations when plugin activate

Location:
extensions/manage_properties_photos
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/manage_properties_photos/initadmin.php

    r31409 r31553  
    2323add_event_handler('get_admin_plugin_menu_links', 'add_info_photo_admin_menu');
    2424
    25 function add_info_photo_admin_menu($menu) {
     25function add_info_photo_admin_menu($menu){
    2626    load_language('plugin.lang', ADD_PROP_PHOTO_PATH);
    2727    $menu[] = array(
     
    3535    EVENT_HANDLER_PRIORITY_NEUTRAL);
    3636
    37 function aip_tabsheet_before_select($sheets, $id)
    38 {
    39     global $template, $page;
    40   if ($id == 'photo')
    41   {
     37function aip_tabsheet_before_select($sheets, $id){
     38  global $template, $page;
     39  if ($id == 'photo'){
    4240    $sheets['iap'] = array(
    4341      'caption' => l10n('Properties additionals'),
     
    5250add_event_handler('element_set_global_action', 'MPP_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    5351 
    54 function MPP_loc_end_element_set_global()
    55  {
    56  load_language('plugin.lang', ADD_PROP_PHOTO_PATH);
    57         global $template;
    58        
    59 $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_TABLE . ' WHERE edit=1';
    60         $test = pwg_query($q);
    61         $row = pwg_db_fetch_assoc($test);
    62         if (count($row) > 0) {
    63                
    64   $propertieslist = array();
    65   $propertieslist2 = tab_add_info_by_photo();
    66 
    67   $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
    68         if($PAED['state'] == 'active'){
     52function MPP_loc_end_element_set_global(){
     53  global $template;
     54  $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_TABLE . ' WHERE edit=1';
     55  $test = pwg_query($q);
     56  $row = pwg_db_fetch_assoc($test);
     57  if (count($row) > 0){
     58        $propertieslist = array();
     59        $propertieslist2 = tab_add_info_by_photo();
     60        $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
     61          if($PAED['state'] == 'active'){
    6962                add_event_handler('AP_render_content', 'get_user_language_desc');
    7063                $template->assign('useED',1);
    71     }else{
     64      }else{
    7265        $template->assign('useED',0);
    73     }
    74 
    75   while ($row = pwg_db_fetch_assoc($propertieslist2))
    76   {
    77     $propertieslist[$row['id_prop_pho']] = trigger_change('AP_render_content', $row['wording']);
     66      }
     67        while ($row = pwg_db_fetch_assoc($propertieslist2)){
     68          $propertieslist[$row['id_prop_pho']] = trigger_change('AP_render_content', $row['wording']);
     69        }
     70    $template->set_filename('MMPP', realpath(ADD_PROP_PHOTO_PATH.'mmp.tpl'));
     71    $template->assign('propertieslist', $propertieslist);
     72    $template->append('element_set_global_plugins_actions', array(
     73      'ID' => 'MPP',
     74      'NAME' => l10n('Change photos properties'),
     75      'CONTENT' => $template->parse('MMPP', true)
     76        ));
    7877  }
    79 $template->set_filename('MMPP', realpath(ADD_PROP_PHOTO_PATH.'mmp.tpl'));
    80 $template->assign('propertieslist', $propertieslist);
    81 $template->append('element_set_global_plugins_actions', array(
    82     'ID' => 'MPP',
    83     'NAME' => l10n('Change photos properties'),
    84     'CONTENT' => $template->parse('MMPP', true)
    85         ));
    86         }
    87  }
     78}
    8879 
    89  function MPP_element_set_global_action($action, $collection)
    90  {
    91   load_language('plugin.lang', ADD_PROP_PHOTO_PATH);
    92         if ($action == 'MPP')
    93   {
    94     global $page,$template,$prefixeTable;
    95    
    96         $id_prop_pho= $_POST['IDMPP'];
     80function MPP_element_set_global_action($action, $collection){
     81  if ($action == 'MPP'){
     82        global $page,$template,$prefixeTable;
     83    $id_prop_pho= $_POST['IDMPP'];
    9784        $data= $_POST['dataglob'];     
    98        
    99     if (!empty($_POST['check_MPP']))
    100     {
    101     foreach ($collection as $image_id)
    102       {
     85        if (!empty($_POST['check_MPP'])){
     86          foreach ($collection as $image_id){
    10387                $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
    10488                pwg_query($query);
    10589      }
    106     }
    107     else
    108     {
    109     foreach ($collection as $image_id)
    110       {
     90    }else{
     91      foreach ($collection as $image_id){
    11192            $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
    11293        $test = pwg_query($q);
    11394        $row = pwg_db_fetch_assoc($test);
    11495        if (count($row) > 0) {
    115             if ($data != '') {
    116                 $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
    117                 pwg_query($query);
    118             } else {
    119                 $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
    120                 pwg_query($query);
    121             }
    122         } else if ($data != '') {
     96                  if ($data != '') {
     97                        $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
     98                        pwg_query($query);
     99                  }else{
     100                        $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
     101                        pwg_query($query);
     102                  }
     103        }else if ($data != ''){
    123104            $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_data(id_img,id_prop_pho,data) VALUES (' . $image_id . ',' . $id_prop_pho . ',"' . $data . '");';
    124105            pwg_query($query);
     
    127108    }
    128109  }
    129  }
     110}
    130111 
    131  
     112add_event_handler('loc_begin_admin_page', 'mpp_change_admin_show');
     113function mpp_change_admin_show(){
     114  global $template;
     115  $template->set_prefilter('config', 'mpp_change_admin_show_prefilter');
     116}
     117
     118function mpp_change_admin_show_prefilter($content, &$smarty){
     119  $search = '#(<fieldset id="pictureInfoConf">).*</fieldset>#ms';
     120  return preg_replace($search, '
     121  <fieldset id="pictureInfoConf">
     122    <legend>{\'Photo Properties\'|@translate}</legend>
     123          <a href="'.ADD_PROP_PHOTO_ADMIN.'">{\'Manage properties photos\'|@translate}</a>
     124  </fieldset>
     125  ', $content);
     126}
  • extensions/manage_properties_photos/initpicture.php

    r31409 r31553  
    3636   $repla='<dl id="standard" class="imageInfoTable">{strip}
    3737{foreach from=$add_info_photos item=addinfophotos}
    38     {if $addinfophotos.AIPID == 1 and $display_info.author and isset($INFO_AUTHOR)}
     38    {if $addinfophotos.AIPID == 1 and isset($INFO_AUTHOR)}
    3939        <div id="Author" class="imageInfo">
    4040                <dt>{\'Author\'|@translate}</dt>
    4141                <dd>{$INFO_AUTHOR}</dd>
    4242        </div>
    43     {else if $addinfophotos.AIPID == 2 and $display_info.created_on and isset($INFO_CREATION_DATE)}
     43    {else if $addinfophotos.AIPID == 2 and isset($INFO_CREATION_DATE)}
    4444        <div id="datecreate" class="imageInfo">
    4545                <dt>{\'Created on\'|@translate}</dt>
    4646                <dd>{$INFO_CREATION_DATE}</dd>
    4747        </div>
    48     {else if $addinfophotos.AIPID == 3 and $display_info.posted_on and isset($INFO_POSTED_DATE)}
     48    {else if $addinfophotos.AIPID == 3 and isset($INFO_POSTED_DATE)}
    4949        <div id="datepost" class="imageInfo">
    5050                <dt>{\'Posted on\'|@translate}</dt>
    5151                <dd>{$INFO_POSTED_DATE}</dd>
    5252        </div>
    53     {else if $addinfophotos.AIPID == 4 and $display_info.dimensions and isset($INFO_DIMENSIONS)}
     53    {else if $addinfophotos.AIPID == 4 and isset($INFO_DIMENSIONS)}
    5454        <div id="Dimensions" class="imageInfo">
    5555                <dt>{\'Dimensions\'|@translate}</dt>
    5656                <dd>{$INFO_DIMENSIONS}</dd>
    5757        </div>
    58     {else if $addinfophotos.AIPID == 5 and $display_info.file}
     58    {else if $addinfophotos.AIPID == 5}
    5959        <div id="File" class="imageInfo">
    6060                <dt>{\'File\'|@translate}</dt>
    6161                <dd>{$INFO_FILE}</dd>
    6262        </div>
    63     {else if $addinfophotos.AIPID == 6 and $display_info.filesize and isset($INFO_FILESIZE)}
     63    {else if $addinfophotos.AIPID == 6 and isset($INFO_FILESIZE)}
    6464        <div id="Filesize" class="imageInfo">
    6565                <dt>{\'Filesize\'|@translate}</dt>
    6666                <dd>{$INFO_FILESIZE}</dd>
    6767        </div>
    68     {else if $addinfophotos.AIPID == 7 and $display_info.tags and isset($related_tags)}
     68    {else if $addinfophotos.AIPID == 7 and isset($related_tags)}
    6969        <div id="Tags" class="imageInfo">
    7070        <dt>{\'Tags\'|@translate}</dt>
     
    7373                </dd>
    7474        </div>
    75     {else if $addinfophotos.AIPID == 8 and $display_info.categories and isset($related_categories)}
     75    {else if $addinfophotos.AIPID == 8 and isset($related_categories)}
    7676        <div id="Categories" class="imageInfo">
    7777            <dt>{\'Albums\'|@translate}</dt>
     
    8484            </dd>
    8585        </div>
    86     {else if $addinfophotos.AIPID == 9 and $display_info.visits}
     86    {else if $addinfophotos.AIPID == 9}
    8787        <div id="Visits" class="imageInfo">
    8888                <dt>{\'Visits\'|@translate}</dt>
    8989                <dd>{$INFO_VISITS}</dd>
    9090        </div>
    91     {else if $addinfophotos.AIPID == 10 and $display_info.rating_score and isset($rate_summary)}
     91    {else if $addinfophotos.AIPID == 10 and isset($rate_summary)}
    9292        <div id="Average" class="imageInfo">
    9393                <dt>{\'Rating score\'|@translate}</dt>
  • extensions/manage_properties_photos/main.inc.php

    r31409 r31553  
    4242include_once(ADD_PROP_PHOTO_PATH . 'include/function.aip.inc.php');
    4343
     44add_event_handler('loading_lang', 'manage_properties_photos_loading_lang');       
     45function manage_properties_photos_loading_lang(){
     46  load_language('plugin.lang', ADD_PROP_PHOTO_PATH);
     47}
     48
    4449 // Plugin on picture page
    45 if (script_basename() == 'picture') 
    46 
     50if (script_basename() == 'picture'){
    4751  include_once(dirname(__FILE__).'/initpicture.php');
    4852}
    4953
    50 
    5154  // Plugin for admin
    52 if (script_basename() == 'admin')   
    53 {
     55if (script_basename() == 'admin'){
    5456  include_once(dirname(__FILE__).'/initadmin.php');
    5557}
  • extensions/manage_properties_photos/maintain.class.php

    r31409 r31553  
    3131
    3232  function install($plugin_version, &$errors=array()){
    33        global $prefixeTable;
     33       global $prefixeTable, $conf;
    3434
    3535if (!defined('ADD_PROP_PHOTO_TABLE')) define('ADD_PROP_PHOTO_TABLE', $prefixeTable.'add_properties_photos');
     
    5050PRIMARY KEY (id_img,id_prop_pho))DEFAULT CHARSET=utf8;";
    5151        $result = pwg_query($query);
    52        
    53 $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (1,"author",1,0,0);';
    54     pwg_query($q);
    55 $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (2,"Created on",2,0,0);';
    56     pwg_query($q);
    57 $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (3,"Posted on",3,0,0);';
    58     pwg_query($q);
    59 $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (4,"Dimensions",4,0,0);';
    60     pwg_query($q);   
    61 $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (5,"File",5,0,0);';
    62     pwg_query($q);         
    63 $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (6,"Filesize",6,0,0);';
    64     pwg_query($q);
    65 $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (7,"Tags",7,0,0);';
    66     pwg_query($q);   
    67 $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (8,"Albums",8,0,0);';
    68     pwg_query($q);     
    69 $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (9,"Visits",9,0,0);';
    70     pwg_query($q);       
    71 $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (10,"Average",10,0,0);';
    72     pwg_query($q);
    73 $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (11,"Who can see this photo?",11,0,0);';
    74     pwg_query($q);
     52  $activ=unserialize($conf['picture_informations']);
     53  if($activ['author']==true){$activauteur=0;}else{$activauteur=1;}
     54  if($activ['created_on']==true){$activco=0;}else{$activco=1;}
     55  if($activ['posted_on']==true){$activpo=0;}else{$activpo=1;}
     56  if($activ['dimensions']==true){$activdim=0;}else{$activdim=1;}
     57  if($activ['file']==true){$activfile=0;}else{$activfile=1;}
     58  if($activ['filesize']==true){$activfilesize=0;}else{$activfilesize=1;}
     59  if($activ['tags']==true){$activtags=0;}else{$activtags=1;}
     60  if($activ['categories']==true){$activcategories=0;}else{$activcategories=1;}
     61  if($activ['visits']==true){$activvisits=0;}else{$activvisits=1;}
     62  if($activ['rating_score']==true){$activrs=0;}else{$activrs=1;}
     63  if($activ['privacy_level']==true){$activpl=0;}else{$activpl=1;}
     64  $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES
     65        (1,"author",1,'.$activauteur.',0),
     66        (2,"Created on",2,'.$activco.',0),
     67        (3,"Posted on",3,'.$activpo.',0),
     68        (4,"Dimensions",4,'.$activdim.',0),
     69        (5,"File",5,'.$activfile.',0),
     70        (6,"Filesize",6,'.$activfilesize.',0),
     71        (7,"Tags",7,'.$activtags.',0),
     72        (8,"Albums",8,'.$activcategories.',0),
     73        (9,"Visits",9,'.$activvisits.',0),
     74        (10,"Average",10,'.$activrs.',0),
     75        (11,"Who can see this photo?",11,'.$activpl.',0)
     76        ;';
     77  pwg_query($q);
    7578   
    7679  }
Note: See TracChangeset for help on using the changeset viewer.