Changeset 7518


Ignore:
Timestamp:
Oct 31, 2010, 6:19:18 PM (13 years ago)
Author:
ddtddt
Message:

[extensions] - meta - update for priority / metasimple

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/meta/main.inc.php

    r7469 r7518  
    2929
    3030//Gestion des meta dans le header
    31 add_event_handler('loc_begin_page_header', 'add_meta' );
     31add_event_handler('loc_begin_page_header', 'add_meta',56 );
     32add_event_handler('loc_begin_page_header', 'add_metacat',61 );
     33add_event_handler('loc_begin_page_header', 'add_metaimg',71 );
     34add_event_handler('loc_after_page_header', 'set_meta_back',81);
     35
    3236function add_meta()
    3337{
    34   global $template, $page, $meta_infos;
     38                global $template, $page, $meta_infos;
     39        $meta_infos = array();
     40        $meta_infos['author'] = $template->get_template_vars('INFO_AUTHOR');
     41        $meta_infos['related_tags'] = $template->get_template_vars('related_tags');
     42        $meta_infos['info'] = $template->get_template_vars('INFO_FILE');
     43        $meta_infos['comment'] = $template->get_template_vars('COMMENT_IMG');
    3544
     45        $query = '
     46  select id,metaname,metaval
     47    FROM ' . meta_TABLE . '
     48    WHERE metaname IN (\'author\', \'keywords\', \'Description\', \'robots\')
     49    ;';
     50        $result = pwg_query($query);
     51        $meta = array();
     52                while ($row = mysql_fetch_assoc($result))
     53                        {
     54                        $meta[$row['metaname']] = $row['metaval'];
     55                        }
     56
     57        // Authors
     58        if (!empty($meta_infos['author']) and !empty($meta['author']))
     59        {
     60                $template->assign('INFO_AUTHOR', $meta_infos['author'] . ' - ' . $meta['author']);
     61        }
     62        elseif (!empty($meta['author']))
     63        {
     64    $template->assign('INFO_AUTHOR', $meta['author']);
     65        }
     66 
     67        // Keywords
     68        if (!empty($meta['keywords']))
     69        {
     70    $template->append('related_tags', array('name' => $meta['keywords']));
     71        }
     72
     73        // Description
     74        if (!empty($meta_infos['info']) and !empty($meta['Description']))
     75        {
     76    $template->assign('INFO_FILE', $meta_infos['info'] . ', ' . $meta['Description']);
     77        }
     78        elseif (!empty($meta['Description']))
     79        {
     80    $template->assign('INFO_FILE', $meta['Description']);
     81        }
     82
     83        // Robots
     84        if (!empty($meta['robots']))
     85        {
     86    $template->append('head_elements', '<meta name="robots" content="'.$meta['robots'].'">');
     87        }
     88
     89 }
     90function add_metacat()
     91{
     92        global $template, $page, $meta_infos;
    3693  $meta_infos = array();
    3794  $meta_infos['author'] = $template->get_template_vars('INFO_AUTHOR');
    3895  $meta_infos['related_tags'] = $template->get_template_vars('related_tags');
    3996  $meta_infos['info'] = $template->get_template_vars('INFO_FILE');
     97  $meta_infos['comment'] = $template->get_template_vars('COMMENT_IMG');
     98 
    4099
    41   $query = '
    42   select id,metaname,metaval
    43     FROM ' . meta_TABLE . '
    44     WHERE metaname IN (\'author\', \'keywords\', \'Description\', \'robots\')
    45     ;';
    46   $result = pwg_query($query);
    47   $meta = array();
    48   while ($row = mysql_fetch_assoc($result))
    49   {
    50     $meta[$row['metaname']] = $row['metaval'];
    51   }
    52 
    53   // Authors
    54   if (!empty($meta_infos['author']) and !empty($meta['author']))
    55   {
    56     $template->assign('INFO_AUTHOR', $meta_infos['author'] . ' - ' . $meta['author']);
    57   }
    58   elseif (!empty($meta['author']))
    59   {
    60     $template->assign('INFO_AUTHOR', $meta['author']);
    61   }
    62  
    63   // Keywords
    64   if (!empty($meta['keywords']))
    65   {
    66     $template->append('related_tags', array('name' => $meta['keywords']));
    67   }
    68 
    69   // Description
    70   if (!empty($meta_infos['info']) and !empty($meta['Description']))
    71   {
    72     $template->assign('INFO_FILE', $meta_infos['info'] . ', ' . $meta['Description']);
    73   }
    74   elseif (!empty($meta['Description']))
    75   {
    76     $template->assign('INFO_FILE', $meta['Description']);
    77   }
    78 
    79   // Robots
    80   if (!empty($meta['robots']))
    81   {
    82     $template->append('head_elements', '<meta name="robots" content="'.$meta['robots'].'">');
    83   }
    84 
    85   //meta categories
     100        //meta categories
    86101  if ( !empty($page['category']['id']) )   
    87102  {
    88 
    89103    $query = '
    90104    select id,metaKeycat
     
    111125          $template->clear_assign('INFO_FILE');
    112126    }
    113        
    114        
    115        
    116127  }
     128}
    117129
    118 
     130function add_metaimg()
     131{
     132        global $template, $page, $meta_infos;
     133  $meta_infos = array();
     134  $meta_infos['author'] = $template->get_template_vars('INFO_AUTHOR');
     135  $meta_infos['related_tags'] = $template->get_template_vars('related_tags');
     136  $meta_infos['info'] = $template->get_template_vars('INFO_FILE');
     137  $meta_infos['comment'] = $template->get_template_vars('COMMENT_IMG');
    119138  //meta images
    120139  if ( !empty($page['image_id']) )   
     
    148167}
    149168
    150 add_event_handler('loc_after_page_header', 'set_meta_back');
     169
    151170function set_meta_back()
    152171{
    153172  global $template, $meta_infos;
    154173 
    155   $template->assign(array(
     174  $template->assign
     175  (array
     176        (
    156177    'INFO_AUTHOR'  => $meta_infos['author'],
    157178    'related_tags' => $meta_infos['related_tags'],
    158     'INFO_FILE'    => $meta_infos['info']
     179    'INFO_FILE'    => $meta_infos['info'],
     180        'COMMENT_IMG'  => $meta_infos['comment']
    159181    )
    160182  );
Note: See TracChangeset for help on using the changeset viewer.