Changeset 31491


Ignore:
Timestamp:
Mar 22, 2016, 11:25:43 AM (8 years ago)
Author:
ddtddt
Message:

[extensions] - meta - 2.8

Location:
extensions/meta
Files:
4 added
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/meta/initadmin.php

    r29429 r31491  
    11<?php
     2// +-----------------------------------------------------------------------+
     3// | meta plugin for Piwigo                                                |
     4// +-----------------------------------------------------------------------+
     5// | Copyright(C) 2008-2016 ddtddt               http://temmii.com/piwigo/ |
     6// +-----------------------------------------------------------------------+
     7// | This program is free software; you can redistribute it and/or modify  |
     8// | it under the terms of the GNU General Public License as published by  |
     9// | the Free Software Foundation                                          |
     10// |                                                                       |
     11// | This program is distributed in the hope that it will be useful, but   |
     12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
     13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
     14// | General Public License for more details.                              |
     15// |                                                                       |
     16// | You should have received a copy of the GNU General Public License     |
     17// | along with this program; if not, write to the Free Software           |
     18// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
     19// | USA.                                                                  |
     20// +-----------------------------------------------------------------------+
    221
    322if (!defined('PHPWG_ROOT_PATH'))
    423    die('Hacking attempt!');
    5 
    624
    725//Add link menu
     
    927
    1028function meta_admin_menu($menu) {
    11     load_language('plugin.lang', meta_PATH);
    12     array_push($menu, array(
    13         'NAME' => l10n('Manage tag Metadata'),
    14         'URL' => get_admin_plugin_menu_link(meta_PATH . 'admin/admin.php')));
    15     return $menu;
     29  $menu[] = array(
     30    'NAME' => l10n('Manage tag Metadata'),
     31    'URL' => META_ADMIN,
     32  );
     33  return $menu;
    1634}
    1735
     
    2139
    2240function metaPadminf() {
    23     global $template;
    24     $template->set_prefilter('picture_modify', 'metaPadminfT');
     41  global $template;
     42  $template->set_prefilter('picture_modify', 'metaPadminfT');
    2543}
    2644
    2745function metaPadminfT($content, &$smarty) {
    28     $search = '#</form>#';
     46  $search = '#<p style="margin:40px 0 0 0">#';
     47  $replacement = '
     48        <p>
     49      <strong>{\'Metadata - Plugin meta\'|@translate}</strong>
     50      <br>
     51          <span style="margin: 0 0 0 20px">{\'meta_compimg\'|@translate}</span>
     52          <br>
     53      <span style="margin: 0 0 0 20px"><textarea rows="2" cols="60" {if $useED==1}placeholder="{\'Use Extended Description tags...\'|@translate}"{/if} name="insermetaKP" id="insermetaKP" class="insermetaKP">{$metaCONTENT}</textarea></span>
     54          <br>
     55          <span style="margin: 0 0 0 20px">{\'meta_compimgdes\'|@translate}</span>
     56          <br>
     57          <span style="margin: 0 0 0 20px"><textarea rows="2" cols="60" {if $useED==1}placeholder="{\'Use Extended Description tags...\'|@translate}"{/if} name="insermetaDP" id="insermetaDP" class="insermetaDP">{$metaCONTENT2}</textarea>
     58          ({\'meta_compcatdeshelp\'|@translate})</span>
     59        </p> 
     60<p style="margin:40px 0 0 0">';
    2961
    30     $replacement = '
    31         <div>
    32                 <fieldset>
    33                   <br>
    34                         <legend>{\'Metadata - Plugin meta\'|@translate}</legend>
    35                                 {\'meta_compimg\'|@translate}&nbsp;:&nbsp;<input type="text" name="insermetaKP" value="{$metaCONTENT}" size="110" maxlenght="110">
    36                         <br>   
    37                         <br>
    38                                 {\'meta_compimgdes\'|@translate}&nbsp;:&nbsp;<input type="text" name="insermetaDP" value="{$metaCONTENT2}" size="110" maxlenght="110">
    39                                 ({\'meta_compcatdeshelp\'|@translate})
    40                         <br>   
    41                         <br>
    42                                 <div style="text-align:center;">
    43                                 <input class="submit" name="submetaphoto" type="submit" value="{\'meta_inscat\'|@translate}" {$TAG_INPUT_ENABLED} />
    44                                 </div>
    45                 </fieldset>
    46         </div> 
    47 </form>';
    48 
    49     return preg_replace($search, $replacement, $content);
     62  return preg_replace($search, $replacement, $content);
    5063}
    5164
    5265function metaPadminA() {
    53     load_language('plugin.lang', meta_PATH);
    54     if (isset($_GET['image_id'])) {
    55         global $template, $prefixeTable;
    56         $query = '
    57 select id,metaKeyimg,metadesimg
    58   FROM ' . meta_img_TABLE . '
    59   WHERE id = ' . $_GET['image_id'] . '
    60   ;';
    61         $result = pwg_query($query);
    62         $row = pwg_db_fetch_assoc($result);
    63         $chvalimg = $row['metaKeyimg'];
    64         $chvalimgdes = $row['metadesimg'];
    65 
    66         $template->assign(
    67                 array(
    68                     'metaCONTENT' => $chvalimg,
    69                     'metaCONTENT2' => $chvalimgdes,
    70         ));
     66  if (isset($_GET['image_id'])){
     67        global $template, $prefixeTable;
     68        $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
     69        if($PAED['state'] == 'active'){
     70          $template->assign('useED',1);
     71    }else{
     72      $template->assign('useED',0);
    7173    }
    72 
    73     if (isset($_POST['submetaphoto'])) {
    74         $query = '
    75 DELETE
    76   FROM ' . meta_img_TABLE . '
    77   WHERE id = ' . $_GET['image_id'] . '
    78   ;';
    79         $result = pwg_query($query);
    80         $q = '
    81 INSERT INTO ' . $prefixeTable . 'meta_img(id,metaKeyimg,metadesimg)VALUES (' . $_GET['image_id'] . ',"' . $_POST['insermetaKP'] . '","' . $_POST['insermetaDP'] . '");';
    82         pwg_query($q);
    83 
    84         $template->assign(
    85                 array(
    86                     'metaCONTENT' => $_POST['insermetaKP'],
    87                     'metaCONTENT2' => $_POST['insermetaDP'],
    88         ));
    89     }
     74        $query = 'SELECT id,metaKeyimg,metadesimg FROM ' . meta_img_TABLE . ' WHERE id = ' . $_GET['image_id'] . ';';
     75        $result = pwg_query($query);
     76        $row = pwg_db_fetch_assoc($result);
     77        $template->assign(
     78        array(
     79          'metaCONTENT' => $row['metaKeyimg'],
     80          'metaCONTENT2' => $row['metadesimg'],
     81        ));
     82  }
     83  if (isset($_POST['insermetaKP']) or isset($_POST['insermetaDP'])){
     84    $query = 'DELETE FROM ' . meta_img_TABLE . ' WHERE id = ' . $_GET['image_id'] . ';';
     85    $result = pwg_query($query);
     86    $q = 'INSERT INTO ' . $prefixeTable . 'meta_img(id,metaKeyimg,metadesimg)VALUES (' . $_GET['image_id'] . ',"' . $_POST['insermetaKP'] . '","' . $_POST['insermetaDP'] . '");';
     87    pwg_query($q);
     88        $template->assign(
     89          array(
     90                'metaCONTENT' => $_POST['insermetaKP'],
     91                'metaCONTENT2' => $_POST['insermetaDP'],
     92        ));
     93  }
    9094}
    9195
    9296//add prefiltre album
    93 add_event_handler('loc_end_cat_modify', 'metaAadminf');
    94 add_event_handler('loc_end_cat_modify', 'metaAadminA');
     97add_event_handler('loc_begin_admin', 'metaAadminf');
     98add_event_handler('loc_begin_admin_page', 'metaAadminA');
    9599
    96100function metaAadminf() {
    97     global $template;
    98     $template->set_prefilter('album_properties', 'metaAadminfT');
     101  global $template;
     102  $template->set_prefilter('album_properties', 'metaAadminfT');
    99103}
    100104
    101 function metaAadminfT($content, &$smarty) {
    102     $search = '#</form>#';
    103 
    104     $replacement = '
    105         <div>
    106                
    107                         <fieldset>
    108                                 <legend>{\'Metadata - Plugin meta\'|@translate}</legend>
    109                                         {\'meta_compcat\'|@translate}&nbsp;:&nbsp;<input type="text" name="insermetaKA" value="{$metaCONTENT}" size="110" maxlenght="110">
    110                                 <br>   
    111                                 <br>   
    112                                         {\'meta_compcatdes\'|@translate}&nbsp;:&nbsp;<input type="text" name="insermetaDA" value="{$metaCONTENT2}" size="110" maxlenght="110">&nbsp;:&nbsp;({\'meta_compcatdeshelp\'|@translate})
    113                                 <br>   
    114                                 <br>
    115                                         <div style="text-align:center;">
    116                                         <input class="submit" name="submetaalbum" type="submit" value="{\'meta_inscat\'|@translate}" {$TAG_INPUT_ENABLED} />
    117                                         </div>
    118                         </fieldset>
    119                
    120         </div>
    121 </form>
    122        
     105function metaAadminfT($content, &$smarty){
     106  $search = '#<p style="margin:0">#';
     107  $replacement = '
     108        <p>
     109      <strong>{\'Metadata - Plugin meta\'|@translate}</strong>
     110      <br>
     111          <span style="margin: 0 0 0 20px">{\'meta_compcat\'|@translate}</span>
     112          <br>
     113      <span style="margin: 0 0 0 20px"><textarea rows="2" cols="60" {if $useED==1}placeholder="{\'Use Extended Description tags...\'|@translate}"{/if} name="insermetaKA" id="insermetaKA" class="insermetaKA">{$metaCONTENTA}</textarea></span>
     114          <br>
     115          <span style="margin: 0 0 0 20px">{\'meta_compcatdes\'|@translate}</span>
     116          <br>
     117          <span style="margin: 0 0 0 20px"><textarea rows="2" cols="60" {if $useED==1}placeholder="{\'Use Extended Description tags...\'|@translate}"{/if} name="insermetaDA" id="insermetaDA" class="insermetaDA">{$metaCONTENTA2}</textarea>
     118          ({\'meta_compcatdeshelp\'|@translate})</span>
     119        </p> 
     120<p style="margin:0">
    123121  ';
    124 
    125     return preg_replace($search, $replacement, $content);
     122  return preg_replace($search, $replacement, $content);
    126123}
    127124
    128 function metaAadminA() {
    129     load_language('plugin.lang', meta_PATH);
    130     if (isset($_GET['cat_id'])) {
    131         global $template, $prefixeTable;
    132         $query = '
    133 select id,metaKeycat,metadescat
    134   FROM ' . meta_cat_TABLE . '
    135   WHERE id = ' . $_GET['cat_id'] . '
    136   ;';
    137         $result = pwg_query($query);
    138         $row = pwg_db_fetch_assoc($result);
    139         $chvalcat = $row['metaKeycat'];
    140         $chvalcatdes = $row['metadescat'];
     125function metaAadminA(){
     126  if (isset($_GET['cat_id'])) {
     127        global $template, $prefixeTable;
     128        $query = 'SELECT id,metaKeycat,metadescat FROM ' . meta_cat_TABLE . ' WHERE id = ' . $_GET['cat_id'] . ';';
     129        $result = pwg_query($query);
     130        $row = pwg_db_fetch_assoc($result);
     131        $template->assign(
     132          array(
     133                'metaCONTENTA' => $row['metaKeycat'],
     134                'metaCONTENTA2' => $row['metadescat'],
     135        ));
     136  }
    141137
    142         $template->assign(
    143                 array(
    144                     'metaCONTENT' => $chvalcat,
    145                     'metaCONTENT2' => $chvalcatdes,
    146         ));
    147     }
    148 
    149     if (isset($_POST['submetaalbum'])) {
    150         $query = '
    151 DELETE
    152   FROM ' . meta_cat_TABLE . '
    153   WHERE id = ' . $_GET['cat_id'] . '
    154   ;';
    155         $result = pwg_query($query);
    156         $q = '
    157 INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat,metadescat)VALUES (' . $_GET['cat_id'] . ',"' . $_POST['insermetaKA'] . '","' . $_POST['insermetaDA'] . '");';
    158         pwg_query($q);
    159 
    160         $template->assign(
    161                 array(
    162                     'metaCONTENT' => $_POST['insermetaKA'],
    163                     'metaCONTENT2' => $_POST['insermetaDA'],
    164         ));
    165     }
     138  if (isset($_POST['insermetaKA']) or isset($_POST['insermetaDA']) ) {
     139    $query = 'DELETE FROM ' . meta_cat_TABLE . ' WHERE id = ' . $_GET['cat_id'] . ';';
     140        $result = pwg_query($query);
     141        $q = 'INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat,metadescat)VALUES (' . $_GET['cat_id'] . ',"' . $_POST['insermetaKA'] . '","' . $_POST['insermetaDA'] . '");';
     142        pwg_query($q);
     143        $template->assign(
     144          array(
     145                'metaCONTENTA' => $_POST['insermetaKA'],
     146                'metaCONTENTA2' => $_POST['insermetaDA'],
     147        ));
     148  }
    166149}
    167150
  • extensions/meta/language/en_UK/plugin.lang.php

    r24455 r31491  
    11<?php
    2 
     2// +-----------------------------------------------------------------------+
     3// | meta plugin for Piwigo                                                |
     4// +-----------------------------------------------------------------------+
     5// | Copyright(C) 2008-2016 ddtddt               http://temmii.com/piwigo/ |
     6// +-----------------------------------------------------------------------+
     7// | This program is free software; you can redistribute it and/or modify  |
     8// | it under the terms of the GNU General Public License as published by  |
     9// | the Free Software Foundation                                          |
     10// |                                                                       |
     11// | This program is distributed in the hope that it will be useful, but   |
     12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
     13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
     14// | General Public License for more details.                              |
     15// |                                                                       |
     16// | You should have received a copy of the GNU General Public License     |
     17// | along with this program; if not, write to the Free Software           |
     18// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
     19// | USA.                                                                  |
     20// +-----------------------------------------------------------------------+
    321$lang['Manage tag Metadata'] = 'Manage meta tags';
    422
     
    5472$lang['Keywords of Additional Pages to be completed'] = '"keywords" meta of additional page to complete';
    5573$lang['Description of Additional Pages to be completed'] = '"description" meta of additional page to complete';
     74$lang['Choose it page'] = 'Choose it page';
     75
    5676?>
  • extensions/meta/language/fr_FR/plugin.lang.php

    r24449 r31491  
    11<?php
    2 
     2// +-----------------------------------------------------------------------+
     3// | meta plugin for Piwigo                                                |
     4// +-----------------------------------------------------------------------+
     5// | Copyright(C) 2008-2016 ddtddt               http://temmii.com/piwigo/ |
     6// +-----------------------------------------------------------------------+
     7// | This program is free software; you can redistribute it and/or modify  |
     8// | it under the terms of the GNU General Public License as published by  |
     9// | the Free Software Foundation                                          |
     10// |                                                                       |
     11// | This program is distributed in the hope that it will be useful, but   |
     12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
     13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
     14// | General Public License for more details.                              |
     15// |                                                                       |
     16// | You should have received a copy of the GNU General Public License     |
     17// | along with this program; if not, write to the Free Software           |
     18// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
     19// | USA.                                                                  |
     20// +-----------------------------------------------------------------------+
    321$lang['Manage tag Metadata'] = 'Gèrer balises Métadonnées';
    422
     
    5472$lang['Keywords of Additional Pages to be completed'] = 'Mots clés de la page additionelle à complèter';
    5573$lang['Description of Additional Pages to be completed'] = 'Description de la page additionellet à complèter';
    56 
     74$lang['Choose it page'] = 'Choisir une page';
    5775
    5876?>
  • extensions/meta/main.inc.php

    r29429 r31491  
    11<?php
    2 
    32/*
    4   Plugin Name: meta
    5   Version: auto
    6   Description: Allows to add metadata
    7   Plugin URI: http://piwigo.org/ext/extension_view.php?eid=220
    8   Author: ddtddt
    9   Author URI: http://piwigo.org/
    10  */
     3Plugin Name: meta
     4Version: auto
     5Description: Allows to add metadata
     6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=220
     7Author: ddtddt
     8Author URI: http://temmii.com/piwigo/
     9*/
     10
     11// +-----------------------------------------------------------------------+
     12// | meta plugin for Piwigo                                                |
     13// +-----------------------------------------------------------------------+
     14// | Copyright(C) 2008-2016 ddtddt               http://temmii.com/piwigo/ |
     15// +-----------------------------------------------------------------------+
     16// | This program is free software; you can redistribute it and/or modify  |
     17// | it under the terms of the GNU General Public License as published by  |
     18// | the Free Software Foundation                                          |
     19// |                                                                       |
     20// | This program is distributed in the hope that it will be useful, but   |
     21// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
     22// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
     23// | General Public License for more details.                              |
     24// |                                                                       |
     25// | You should have received a copy of the GNU General Public License     |
     26// | along with this program; if not, write to the Free Software           |
     27// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
     28// | USA.                                                                  |
     29// +-----------------------------------------------------------------------+
    1130
    1231if (!defined('PHPWG_ROOT_PATH'))
     
    2039define('meta_img_TABLE', $prefixeTable . 'meta_img');
    2140define('meta_cat_TABLE', $prefixeTable . 'meta_cat');
    22 define('METAPERSO_TABLE', $prefixeTable . 'metaperso');
    23 define('META_AP_TABLE', $prefixeTable . 'meta_ap');
     41if (!defined('METAPERSO_TABLE'))
     42  define('METAPERSO_TABLE', $prefixeTable . 'metaperso');
     43if (!defined('META_AP_TABLE'))
     44  define('META_AP_TABLE', $prefixeTable . 'meta_ap');
     45define('META_ADMIN',get_root_url().'admin.php?page=plugin-'.meta_DIR);
     46
     47add_event_handler('loading_lang', 'meta_loading_lang');   
     48function meta_loading_lang(){
     49  load_language('plugin.lang', meta_PATH);
     50}
    2451
    2552// Plugin for admin
     
    3562add_event_handler('loc_after_page_header', 'set_meta_back');
    3663
    37 function Change_Meta() {
    38     global $template;
    39     $template->set_prefilter('header', 'upmata');
    40 
    41     $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
    42     if ($PAED['state'] == 'active')
    43         add_event_handler('AP_render_content', 'get_user_language_desc');
    44 }
    45 
    46 function upmata($content, &$smarty) {
    47     $search = '#<meta name="description" content=".*?">#';
    48 
    49     $replacement = '<meta name="description" content="{$PLUG_META}">';
    50 
    51     return preg_replace($search, $replacement, $content);
    52 }
    53 
    54 function add_meta() {
    55     global $template, $page, $meta_infos;
    56     $meta_infos = array();
    57     $meta_infos['author'] = $template->get_template_vars('INFO_AUTHOR');
    58     $meta_infos['related_tags'] = $template->get_template_vars('related_tags');
    59     $meta_infos['info'] = $template->get_template_vars('INFO_FILE');
    60     $meta_infos['title'] = $template->get_template_vars('PAGE_TITLE');
    61 
    62     $query = '
    63   select id,metaname,metaval
    64     FROM ' . meta_TABLE . '
    65     WHERE metaname IN (\'author\', \'keywords\', \'Description\', \'robots\')
    66     ;';
    67     $result = pwg_query($query);
    68     $meta = array();
    69     while ($row = pwg_db_fetch_assoc($result)) {
    70         $meta[$row['metaname']] = $row['metaval'];
    71         $metaED[$row['metaname']] = trigger_change('AP_render_content', $meta[$row['metaname']]);
     64function Change_Meta(){
     65  global $template;
     66  $template->set_prefilter('header', 'upmata');
     67  $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
     68  if ($PAED['state'] == 'active')
     69    add_event_handler('AP_render_content', 'get_user_language_desc');
     70}
     71
     72function upmata($content, &$smarty){
     73  $search = '#<meta name="description" content=".*?">#';
     74  $replacement = '<meta name="description" content="{$PLUG_META}">';
     75  return preg_replace($search, $replacement, $content);
     76}
     77
     78function add_meta(){
     79  global $template, $page, $meta_infos;
     80  $meta_infos = array();
     81  $meta_infos['author'] = $template->get_template_vars('INFO_AUTHOR');
     82  $meta_infos['related_tags'] = $template->get_template_vars('related_tags');
     83  $meta_infos['info'] = $template->get_template_vars('INFO_FILE');
     84  $meta_infos['title'] = $template->get_template_vars('PAGE_TITLE');
     85
     86  $query = 'SELECT id,metaname,metaval FROM ' . meta_TABLE . ' WHERE metaname IN (\'author\', \'keywords\', \'Description\', \'robots\');';
     87  $result = pwg_query($query);
     88  $meta = array();
     89  while ($row = pwg_db_fetch_assoc($result)){
     90    $meta[$row['metaname']] = $row['metaval'];
     91    $metaED[$row['metaname']] = trigger_change('AP_render_content', $meta[$row['metaname']]);
     92  }
     93
     94  // Authors
     95  if (!empty($meta_infos['author']) and ! empty($metaED['author'])){
     96    $template->assign('INFO_AUTHOR', $meta_infos['author'] . ' - ' . $metaED['author']);
     97  } elseif (!empty($metaED['author'])){
     98    $template->assign('INFO_AUTHOR', $metaED['author']);
     99  }
     100
     101  // Keywords
     102  if (!empty($metaED['keywords'])){
     103    $template->append('related_tags', array('name' => $metaED['keywords']));
     104  }
     105
     106  // Description
     107  if (!empty($meta_infos['title']) and ! empty($meta_infos['info']) and ! empty($metaED['Description'])) {
     108    $template->assign('PLUG_META', $meta_infos['title'] . ' - ' . $meta_infos['info'] . ', ' . $metaED['Description']);
     109  } elseif (!empty($meta_infos['title']) and ! empty($metaED['Description'])) {
     110    $template->assign('PLUG_META', $meta_infos['title'] . ' - ' . $metaED['Description']);
     111  } elseif (!empty($metaED['Description'])) {
     112    $template->assign('PLUG_META', $metaED['Description']);
     113  }
     114
     115  // Robots
     116  if (!empty($meta['robots'])) {
     117    $template->append('head_elements', '<meta name="robots" content="' . $meta['robots'] . '">');
     118  }
     119
     120  //Metaperso
     121  if (script_basename() !== 'admin') {
     122    $metapersos = pwg_query("SELECT * FROM " . METAPERSO_TABLE . ";");
     123
     124    if (pwg_db_num_rows($metapersos)) {
     125      while ($metaperso = pwg_db_fetch_assoc($metapersos)) {
     126        $items = array(
     127          'METANAME' => $metaperso['metaname'],
     128          'METAVAL' => $metaperso['metaval'],
     129          'METATYPE' => $metaperso['metatype']
     130        );
     131        $template->append('metapersos', $items);
     132      }
    72133    }
    73134
    74     // Authors
    75     if (!empty($meta_infos['author']) and ! empty($metaED['author'])) {
    76         $template->assign('INFO_AUTHOR', $meta_infos['author'] . ' - ' . $metaED['author']);
    77     } elseif (!empty($metaED['author'])) {
    78         $template->assign('INFO_AUTHOR', $metaED['author']);
     135    $template->set_filename('PERSO_META', realpath(meta_PATH . 'persometa.tpl'));
     136    $template->append('head_elements', $template->parse('PERSO_META', true));
     137  }
     138
     139  $MPC = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';"));
     140  if ($MPC['state'] == 'active'){
     141    global $conf;
     142    if (isset($page['section']) and $page['section'] == 'contact' and isset($conf['contactmeta']) and strpos($conf['contactmeta'], ',') !== false){
     143      $metacontact = explode(',', $conf['contactmeta']);
     144      $metakeyED = trigger_change('AP_render_content', $metacontact[0]);
     145      $metadesED = trigger_change('AP_render_content', $metacontact[1]);
     146      if (!empty($metakeyED)){
     147        $template->append('related_tags', array('name' => $metakeyED));
     148      }
     149      if (!empty($metadesED)){
     150        $template->assign('PLUG_META', $metadesED);
     151      }
    79152    }
    80 
    81     // Keywords
    82     if (!empty($metaED['keywords'])) {
    83         $template->append('related_tags', array('name' => $metaED['keywords']));
     153  }
     154
     155  $MAP = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'AdditionalPages';"));
     156  if ($MAP['state'] == 'active') {
     157    if (!empty($page['additional_page']['id'])) {
     158      $lire = $page['additional_page']['id'];
     159      $query = 'SELECT id, metaKeyap, metadesap FROM ' . META_AP_TABLE . ' WHERE id = \'' . $lire . '\';';
     160          $result = pwg_query($query);
     161          $row = pwg_db_fetch_assoc($result);
     162          $metaKeyapap = $row['metaKeyap'];
     163          $metadesapap = $row['metadesap'];
     164          $metaKeyapapED = trigger_change('AP_render_content', $metaKeyapap);
     165          $metadesapED = trigger_change('AP_render_content', $metadesapap);
    84166    }
    85 
    86     // Description
    87     if (!empty($meta_infos['title']) and ! empty($meta_infos['info']) and ! empty($metaED['Description'])) {
    88         $template->assign('PLUG_META', $meta_infos['title'] . ' - ' . $meta_infos['info'] . ', ' . $metaED['Description']);
    89     } elseif (!empty($meta_infos['title']) and ! empty($metaED['Description'])) {
    90         $template->assign('PLUG_META', $meta_infos['title'] . ' - ' . $metaED['Description']);
    91     } elseif (!empty($metaED['Description'])) {
    92         $template->assign('PLUG_META', $metaED['Description']);
    93     }
    94 
    95     // Robots
    96     if (!empty($meta['robots'])) {
    97         $template->append('head_elements', '<meta name="robots" content="' . $meta['robots'] . '">');
    98     }
    99 
    100     //Metaperso
    101     if (script_basename() !== 'admin') {
    102         $metapersos = pwg_query("SELECT * FROM " . METAPERSO_TABLE . ";");
    103 
    104         if (pwg_db_num_rows($metapersos)) {
    105             while ($metaperso = pwg_db_fetch_assoc($metapersos)) {
    106                 $items = array(
    107                     'METANAME' => $metaperso['metaname'],
    108                     'METAVAL' => $metaperso['metaval'],
    109                     'METATYPE' => $metaperso['metatype']
    110                 );
    111 
    112                 $template->append('metapersos', $items);
    113             }
    114         }
    115 
    116         $template->set_filename('PERSO_META', realpath(meta_PATH . 'persometa.tpl'));
    117         $template->append('head_elements', $template->parse('PERSO_META', true));
    118     }
    119 
    120     $MPC = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';"));
    121     if ($MPC['state'] == 'active') {
    122         global $conf;
    123         if (isset($page['section']) and $page['section'] == 'contact' and isset($conf['contactmeta']) and strpos($conf['contactmeta'], ',') !== false) {
    124             $metacontact = explode(',', $conf['contactmeta']);
    125             $metakeyED = trigger_change('AP_render_content', $metacontact[0]);
    126             $metadesED = trigger_change('AP_render_content', $metacontact[1]);
    127             if (!empty($metakeyED)) {
    128                 $template->append('related_tags', array('name' => $metakeyED));
    129             }
    130             if (!empty($metadesED)) {
    131                 $template->assign('PLUG_META', $metadesED);
    132             }
    133         }
    134     }
    135 
    136     $MAP = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'AdditionalPages';"));
    137     if ($MAP['state'] == 'active') {
    138         if (!empty($page['additional_page']['id'])) {
    139             $lire = $page['additional_page']['id'];
    140             $query = '
    141   select id, metaKeyap, metadesap
    142   FROM ' . META_AP_TABLE . '
    143   WHERE id = \'' . $lire . '\'
    144   ;';
    145             $result = pwg_query($query);
    146             $row = pwg_db_fetch_assoc($result);
    147             $metaKeyapap = $row['metaKeyap'];
    148             $metadesapap = $row['metadesap'];
    149             $metaKeyapapED = trigger_change('AP_render_content', $metaKeyapap);
    150             $metadesapED = trigger_change('AP_render_content', $metadesapap);
    151         }
    152         if (isset($page['section']) and $page['section'] == 'additional_page') {
    153             if (!empty($metaKeyapapED)) {
    154                 $template->append('related_tags', array('name' => $metaKeyapapED));
    155             }
    156             if (!empty($metadesapED)) {
    157                 $template->assign('PLUG_META', $metadesapED);
    158             }
    159         }
    160     }
     167        if (isset($page['section']) and $page['section'] == 'additional_page') {
     168          if (!empty($metaKeyapapED)) {
     169                $template->append('related_tags', array('name' => $metaKeyapapED));
     170          }
     171          if (!empty($metadesapED)) {
     172                $template->assign('PLUG_META', $metadesapED);
     173          }
     174        }
     175  }
    161176}
    162177
    163178function add_metacat() {
    164     global $template, $page, $meta_infos;
    165     //meta categories
    166     if (!empty($page['category']['id'])) {
    167         $query = '
    168     select id,metaKeycat
    169       FROM ' . meta_cat_TABLE . '
    170       WHERE id = \'' . $page['category']['id'] . '\'
    171       ;';
    172         $result = pwg_query($query);
    173         $row = pwg_db_fetch_assoc($result);
    174         $albumKeyED = trigger_change('AP_render_content', $row['metaKeycat']);
    175         if (!empty($row['metaKeycat'])) {
    176             $template->append('related_tags', array('name' => $albumKeyED));
    177         }
    178 
    179         $query = '
    180     select id,metadescat
    181       FROM ' . meta_cat_TABLE . '
    182       WHERE id = \'' . $page['category']['id'] . '\'
    183       ;';
    184         $result = pwg_query($query);
    185         $row = pwg_db_fetch_assoc($result);
    186         $albumDesED = trigger_change('AP_render_content', $row['metadescat']);
    187         if (!empty($row['metadescat'])) {
    188             $template->assign('PLUG_META', $albumDesED);
    189         }
    190     }
    191 }
    192 
    193 function add_metaimg() {
    194     global $template, $page, $meta_infos;
    195 //meta images
    196     if (!empty($page['image_id'])) {
    197         $query = '
    198     select id,metaKeyimg
    199       FROM ' . meta_img_TABLE . '
    200       WHERE id = \'' . $page['image_id'] . '\'
    201       ;';
    202         $result = pwg_query($query);
    203         $row = pwg_db_fetch_assoc($result);
    204         $photoKeyED = trigger_change('AP_render_content', $row['metaKeyimg']);
    205         if (!empty($row['metaKeyimg'])) {
    206             $template->append('related_tags', array('name' => $photoKeyED));
    207         }
    208 
    209         $query = '
    210     select id,metadesimg
    211       FROM ' . meta_img_TABLE . '
    212       WHERE id = \'' . $page['image_id'] . '\'
    213       ;';
    214         $result = pwg_query($query);
    215         $row = pwg_db_fetch_assoc($result);
    216         $photoDesED = trigger_change('AP_render_content', $row['metadesimg']);
    217         if (!empty($row['metadesimg'])) {
    218             $template->assign('PLUG_META', $photoDesED);
    219         } else {
    220             $meta_infosph = array();
    221             $meta_infosph['title'] = $template->get_template_vars('PAGE_TITLE');
    222             $meta_infosph['gt'] = $template->get_template_vars('GALLERY_TITLE');
    223             $meta_infosph['descimg'] = $template->get_template_vars('COMMENT_IMG');
    224             if (!empty($meta_infosph['descimg'])) {
    225                 $template->assign('PLUG_META', strip_tags($meta_infosph['descimg']) . ' - ' . $meta_infosph['title']);
    226             } else {
    227                 $template->assign('PLUG_META', $meta_infosph['title'] . ' - ' . $meta_infosph['gt']);
    228             }
    229         }
    230     }
    231 }
    232 
    233 function set_meta_back() {
    234     global $template, $meta_infos;
    235     $template->assign
    236             (array
    237         (
    238         'INFO_AUTHOR' => $meta_infos['author'],
    239         'related_tags' => $meta_infos['related_tags'],
    240         'INFO_FILE' => $meta_infos['info'],
    241             )
    242     );
     179  global $template, $page, $meta_infos;
     180  if (!empty($page['category']['id'])) {
     181    $query = 'SELECT id,metaKeycat,metadescat FROM ' . meta_cat_TABLE . ' WHERE id = \'' . $page['category']['id'] . '\';';
     182        $result = pwg_query($query);
     183        $row = pwg_db_fetch_assoc($result);
     184        $albumKeyED = trigger_change('AP_render_content', $row['metaKeycat']);
     185        if (!empty($row['metaKeycat'])) {
     186          $template->append('related_tags', array('name' => $albumKeyED));
     187        }
     188        $albumDesED = trigger_change('AP_render_content', $row['metadescat']);
     189        if (!empty($row['metadescat'])) {
     190          $template->assign('PLUG_META', $albumDesED);
     191        }
     192  }
     193}
     194
     195function add_metaimg(){
     196  global $template, $page, $meta_infos;
     197  if (!empty($page['image_id'])) {
     198    $query = 'SELECT id,metaKeyimg,metadesimg FROM ' . meta_img_TABLE . ' WHERE id = \'' . $page['image_id'] . '\';';
     199        $result = pwg_query($query);
     200        $row = pwg_db_fetch_assoc($result);
     201        $photoKeyED = trigger_change('AP_render_content', $row['metaKeyimg']);
     202        if (!empty($row['metaKeyimg'])) {
     203          $template->append('related_tags', array('name' => $photoKeyED));
     204        }
     205        $photoDesED = trigger_change('AP_render_content', $row['metadesimg']);
     206        if (!empty($row['metadesimg'])) {
     207          $template->assign('PLUG_META', $photoDesED);
     208        }else{
     209          $meta_infosph = array();
     210          $meta_infosph['title'] = $template->get_template_vars('PAGE_TITLE');
     211          $meta_infosph['gt'] = $template->get_template_vars('GALLERY_TITLE');
     212          $meta_infosph['descimg'] = $template->get_template_vars('COMMENT_IMG');
     213          if (!empty($meta_infosph['descimg'])) {
     214                $template->assign('PLUG_META', strip_tags($meta_infosph['descimg']) . ' - ' . $meta_infosph['title']);
     215          }else{
     216                $template->assign('PLUG_META', $meta_infosph['title'] . ' - ' . $meta_infosph['gt']);
     217          }
     218        }
     219  }
     220}
     221
     222function set_meta_back(){
     223  global $template, $meta_infos;
     224  $template->assign(
     225    array(
     226      'INFO_AUTHOR' => $meta_infos['author'],
     227      'related_tags' => $meta_infos['related_tags'],
     228      'INFO_FILE' => $meta_infos['info'],
     229    )
     230   );
    243231}
    244232
Note: See TracChangeset for help on using the changeset viewer.