Changeset 32186
- Timestamp:
- May 8, 2020, 1:54:19 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/meta_og/main.inc.php
r32185 r32186 90 90 $metaog['type']="website"; 91 91 if(empty($metaog['metaogtitle'])){$metaog['metaogtitle']=$albums['name'];} 92 if(empty($metaog['metaogdescription'])){$metaog['metaogdescription']=$albums['comment'];} 93 if(empty($metaog['metaogimage'])){ 94 if(isset($albums['representative_picture_id'])){ 95 $images = pwg_db_fetch_assoc(pwg_query("SELECT id,path FROM " . IMAGES_TABLE . " WHERE id = '".$albums['representative_picture_id']."';")); 96 } 97 }else{ 98 $images = pwg_db_fetch_assoc(pwg_query("SELECT id,path FROM " . IMAGES_TABLE . " WHERE id = '".$metaog['metaogimage']."';")); 99 } 100 if(isset($images)){ 101 $metaog['metaogimage']=PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 102 if (file_exists($metaog['metaogimage']) AND $conf['mogsize']!='original'){ 103 $metaog['metaogimage']=get_absolute_root_url().PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 104 }else{ 105 $metaog['metaogimage']=get_absolute_root_url().substr($images['path'],2); 106 } 107 } 108 }else if (!empty($page['image_id'])) { 109 $metaog = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . METAOG_TABLE . " WHERE type = 2 AND idobj = '".$page['image_id']."';")); 110 if(empty($metaog)){ 111 $metaog['metaogtitle']=''; 112 $metaog['metaogdescription']=''; 113 $metaog['metaogimage']=''; 114 } 115 116 $images = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . IMAGES_TABLE . " WHERE id = '".$page['image_id']."';")); 117 $metaog['type']="website"; 118 if(empty($metaog['metaogtitle'])){$metaog['metaogtitle']=$images['name'];} 119 if(empty($metaog['metaogdescription'])){$metaog['metaogdescription']=$images['comment'];} 120 if(!empty($metaog['metaogimage'])){ 121 $images2 = pwg_db_fetch_assoc(pwg_query("SELECT id,path FROM " . IMAGES_TABLE . " WHERE id = '".$metaog['metaogimage']."';")); 122 $images['path']=$images2['path']; 123 } 124 $metaog['metaogimage']=PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 125 if (file_exists($metaog['metaogimage']) AND $conf['mogsize']!='original'){ 126 $metaog['metaogimage']=get_absolute_root_url().PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 127 }else{ 128 $metaog['metaogimage']=get_absolute_root_url().substr($images['path'],2); 129 } 130 }else if(isset($page['section']) and empty($page['category']['id'])) { 131 if($page['section'] == 'additional_page'){ 132 $metaog = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . METAOG_TABLE . " WHERE type =4 AND page = '".$page['additional_page']['id']."';")); 133 }else{ 134 $metaog = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . METAOG_TABLE . " WHERE type =1 AND page = '".$page['section']."';")); 135 } 136 if(empty($metaog)){ 137 $metaog['metaogtitle']=''; 138 $metaog['metaogdescription']=''; 139 $metaog['metaogimage']=''; 140 } 141 if(!empty($metaog['metaogimage'])){ 142 $images = pwg_db_fetch_assoc(pwg_query("SELECT id,path FROM " . IMAGES_TABLE . " WHERE id = '".$metaog['metaogimage']."';")); 143 $metaog['metaogimage']=PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 144 if (file_exists($metaog['metaogimage']) AND $conf['mogsize']!='original'){ 145 $metaog['metaogimage']=get_absolute_root_url().PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 146 }else{ 147 $metaog['metaogimage']=get_absolute_root_url().substr($images['path'],2); 148 } 149 } 150 $metaog['type']="website"; 151 }else if(script_basename() == 'tags' ||script_basename() == 'comments'||script_basename() == 'about'||script_basename() == 'search'||script_basename() == 'notification'){ 152 $metaog = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . METAOG_TABLE . " WHERE type = 1 AND page = '".script_basename()."';")); 153 if(empty($metaog)){ 154 $metaog['metaogtitle']=''; 155 $metaog['metaogdescription']=''; 156 $metaog['metaogimage']=''; 157 } 158 159 if(!empty($metaog['metaogimage']) AND $conf['mogsize']!='original'){ 160 $images = pwg_db_fetch_assoc(pwg_query("SELECT id,path FROM " . IMAGES_TABLE . " WHERE id = '".$metaog['metaogimage']."';")); 161 $metaog['metaogimage']=PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 162 if (file_exists($metaog['metaogimage'])){ 163 $metaog['metaogimage']=get_absolute_root_url().PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 164 }else{ 165 $metaog['metaogimage']=get_absolute_root_url().substr($images['path'],2); 166 } 167 } 168 $metaog['type']="website"; 169 }else{ 170 $metaog['type']="website"; 171 $metaog['metaogtitle']=$template->get_template_vars('PAGE_TITLE'); 172 $metaog['metaogdescription']=$template->get_template_vars('INFO_FILE'); 173 } 174 175 176 if (isset($pwg_loaded_plugins['ExtendedDescription'])){ 177 add_event_handler('AP_render_content', 'get_user_language_desc'); 178 } 179 // og:url 180 if (!empty($metaogurl)) { 181 $template->append('head_elements', '<meta property="og:url" content="' . $metaogurl . '">'); 182 } 183 // og:type 184 if (!empty($metaog['type'])) { 185 $template->append('head_elements', '<meta property="og:type" content="' . $metaog['type'] . '">'); 186 } 187 188 // og:title 189 if (!empty($metaog['metaogtitle'])) { 190 $template->append('head_elements', '<meta property="og:title" content="' . strip_tags(trigger_change('AP_render_content', $metaog['metaogtitle'])) . '">'); 191 } 192 193 // og:description 194 if (!empty($metaog['metaogdescription'])) { 195 if (isset($pwg_loaded_plugins['ExtendedDescription']) and !empty($page['category']['id']) and empty($page['image_id'])){ 92 if(empty($metaog['metaogdescription'])){ 93 $metaog['metaogdescription']=$albums['comment'];} 94 if (isset($pwg_loaded_plugins['ExtendedDescription'])){ 196 95 if( strstr($metaog['metaogdescription'],'<!--complete-->')) { 197 96 $desc=explode('<!--complete-->', $metaog['metaogdescription']); … … 207 106 } 208 107 } 108 if(empty($metaog['metaogimage'])){ 109 if(isset($albums['representative_picture_id'])){ 110 $images = pwg_db_fetch_assoc(pwg_query("SELECT id,path FROM " . IMAGES_TABLE . " WHERE id = '".$albums['representative_picture_id']."';")); 111 } 112 }else{ 113 $images = pwg_db_fetch_assoc(pwg_query("SELECT id,path FROM " . IMAGES_TABLE . " WHERE id = '".$metaog['metaogimage']."';")); 114 } 115 if(isset($images)){ 116 $metaog['metaogimage']=PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 117 if (file_exists($metaog['metaogimage']) AND $conf['mogsize']!='original'){ 118 $metaog['metaogimage']=get_absolute_root_url().PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 119 }else{ 120 $metaog['metaogimage']=get_absolute_root_url().substr($images['path'],2); 121 } 122 } 123 }else if (!empty($page['image_id'])) { 124 $metaog = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . METAOG_TABLE . " WHERE type = 2 AND idobj = '".$page['image_id']."';")); 125 if(empty($metaog)){ 126 $metaog['metaogtitle']=''; 127 $metaog['metaogdescription']=''; 128 $metaog['metaogimage']=''; 129 } 130 131 $images = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . IMAGES_TABLE . " WHERE id = '".$page['image_id']."';")); 132 $metaog['type']="website"; 133 if(empty($metaog['metaogtitle'])){$metaog['metaogtitle']=$images['name'];} 134 if(empty($metaog['metaogdescription'])){$metaog['metaogdescription']=$images['comment'];} 135 if(!empty($metaog['metaogimage'])){ 136 $images2 = pwg_db_fetch_assoc(pwg_query("SELECT id,path FROM " . IMAGES_TABLE . " WHERE id = '".$metaog['metaogimage']."';")); 137 $images['path']=$images2['path']; 138 } 139 $metaog['metaogimage']=PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 140 if (file_exists($metaog['metaogimage']) AND $conf['mogsize']!='original'){ 141 $metaog['metaogimage']=get_absolute_root_url().PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 142 }else{ 143 $metaog['metaogimage']=get_absolute_root_url().substr($images['path'],2); 144 } 145 }else if(isset($page['section']) and empty($page['category']['id'])) { 146 if($page['section'] == 'additional_page'){ 147 $metaog = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . METAOG_TABLE . " WHERE type =4 AND page = '".$page['additional_page']['id']."';")); 148 }else{ 149 $metaog = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . METAOG_TABLE . " WHERE type =1 AND page = '".$page['section']."';")); 150 } 151 if(empty($metaog)){ 152 $metaog['metaogtitle']=''; 153 $metaog['metaogdescription']=''; 154 $metaog['metaogimage']=''; 155 } 156 if(!empty($metaog['metaogimage'])){ 157 $images = pwg_db_fetch_assoc(pwg_query("SELECT id,path FROM " . IMAGES_TABLE . " WHERE id = '".$metaog['metaogimage']."';")); 158 $metaog['metaogimage']=PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 159 if (file_exists($metaog['metaogimage']) AND $conf['mogsize']!='original'){ 160 $metaog['metaogimage']=get_absolute_root_url().PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 161 }else{ 162 $metaog['metaogimage']=get_absolute_root_url().substr($images['path'],2); 163 } 164 } 165 $metaog['type']="website"; 166 }else if(script_basename() == 'tags' ||script_basename() == 'comments'||script_basename() == 'about'||script_basename() == 'search'||script_basename() == 'notification'){ 167 $metaog = pwg_db_fetch_assoc(pwg_query("SELECT * FROM " . METAOG_TABLE . " WHERE type = 1 AND page = '".script_basename()."';")); 168 if(empty($metaog)){ 169 $metaog['metaogtitle']=''; 170 $metaog['metaogdescription']=''; 171 $metaog['metaogimage']=''; 172 } 173 174 if(!empty($metaog['metaogimage']) AND $conf['mogsize']!='original'){ 175 $images = pwg_db_fetch_assoc(pwg_query("SELECT id,path FROM " . IMAGES_TABLE . " WHERE id = '".$metaog['metaogimage']."';")); 176 $metaog['metaogimage']=PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 177 if (file_exists($metaog['metaogimage'])){ 178 $metaog['metaogimage']=get_absolute_root_url().PWG_DERIVATIVE_DIR.substr($images['path'], 2, -4)."-".$conf['mogsize'].substr($images['path'],-4); 179 }else{ 180 $metaog['metaogimage']=get_absolute_root_url().substr($images['path'],2); 181 } 182 } 183 $metaog['type']="website"; 184 }else{ 185 $metaog['type']="website"; 186 $metaog['metaogtitle']=$template->get_template_vars('PAGE_TITLE'); 187 $metaog['metaogdescription']=$template->get_template_vars('INFO_FILE'); 188 } 189 190 191 if (isset($pwg_loaded_plugins['ExtendedDescription'])){ 192 add_event_handler('AP_render_content', 'get_user_language_desc'); 193 } 194 // og:url 195 if (!empty($metaogurl)) { 196 $template->append('head_elements', '<meta property="og:url" content="' . $metaogurl . '">'); 197 } 198 // og:type 199 if (!empty($metaog['type'])) { 200 $template->append('head_elements', '<meta property="og:type" content="' . $metaog['type'] . '">'); 201 } 202 203 // og:title 204 if (!empty($metaog['metaogtitle'])) { 205 $template->append('head_elements', '<meta property="og:title" content="' . strip_tags(trigger_change('AP_render_content', $metaog['metaogtitle'])) . '">'); 206 } 207 208 // og:description 209 if (!empty($metaog['metaogdescription'])) { 209 210 $template->append('head_elements', '<meta property="og:description" content="' . strip_tags(trigger_change('AP_render_content', $metaog['metaogdescription'])) . '">'); 210 211 }
Note: See TracChangeset
for help on using the changeset viewer.