Changeset 7518
- Timestamp:
- Oct 31, 2010, 6:19:18 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/meta/main.inc.php
r7469 r7518 29 29 30 30 //Gestion des meta dans le header 31 add_event_handler('loc_begin_page_header', 'add_meta' ); 31 add_event_handler('loc_begin_page_header', 'add_meta',56 ); 32 add_event_handler('loc_begin_page_header', 'add_metacat',61 ); 33 add_event_handler('loc_begin_page_header', 'add_metaimg',71 ); 34 add_event_handler('loc_after_page_header', 'set_meta_back',81); 35 32 36 function add_meta() 33 37 { 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'); 35 44 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 } 90 function add_metacat() 91 { 92 global $template, $page, $meta_infos; 36 93 $meta_infos = array(); 37 94 $meta_infos['author'] = $template->get_template_vars('INFO_AUTHOR'); 38 95 $meta_infos['related_tags'] = $template->get_template_vars('related_tags'); 39 96 $meta_infos['info'] = $template->get_template_vars('INFO_FILE'); 97 $meta_infos['comment'] = $template->get_template_vars('COMMENT_IMG'); 98 40 99 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 86 101 if ( !empty($page['category']['id']) ) 87 102 { 88 89 103 $query = ' 90 104 select id,metaKeycat … … 111 125 $template->clear_assign('INFO_FILE'); 112 126 } 113 114 115 116 127 } 128 } 117 129 118 130 function 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'); 119 138 //meta images 120 139 if ( !empty($page['image_id']) ) … … 148 167 } 149 168 150 add_event_handler('loc_after_page_header', 'set_meta_back'); 169 151 170 function set_meta_back() 152 171 { 153 172 global $template, $meta_infos; 154 173 155 $template->assign(array( 174 $template->assign 175 (array 176 ( 156 177 'INFO_AUTHOR' => $meta_infos['author'], 157 178 'related_tags' => $meta_infos['related_tags'], 158 'INFO_FILE' => $meta_infos['info'] 179 'INFO_FILE' => $meta_infos['info'], 180 'COMMENT_IMG' => $meta_infos['comment'] 159 181 ) 160 182 );
Note: See TracChangeset
for help on using the changeset viewer.