1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 04:38:27 +01:00

Preparations for WebP conversions. e107::title() added to eventually replace defining e_PAGETITLE.

This commit is contained in:
Cameron 2020-12-08 18:15:08 -08:00
parent afaac88003
commit 7229aa6c50
7 changed files with 95 additions and 54 deletions

View File

@ -880,6 +880,8 @@ class media_admin_ui extends e_admin_ui
// 'convert_to_jpeg' => array('title'=> IMALAN_182, 'type'=>'number', 'data'=>'int', 'writeParms'=> array('tdClassRight'=>'form-inline', 'post'=> CORE_LAN_KB), 'help'=>IMALAN_183),
'convert_to_jpeg' => array('title'=> IMALAN_182, 'type'=>'boolean', 'data'=>'int', 'writeParms'=>'', 'help'=>IMALAN_183),
'convert_to_webp' => array('title'=> IMALAN_187, 'type'=>'boolean', 'data'=>'int', 'writeParms'=>'', 'help'=>IMALAN_189),
'thumb_to_webp' => array('title'=> IMALAN_188, 'type'=>'boolean', 'data'=>'int', 'writeParms'=>'', 'help'=>IMALAN_189),
'im_width' => array('title'=> IMALAN_75, 'type'=>'number', 'data'=>'int', 'writeParms'=>'', 'help'=>IMALAN_76),
'im_height' => array('title'=> IMALAN_77, 'type'=>'number', 'data'=>'int', 'writeParms'=>'', 'help'=>IMALAN_76),

View File

@ -139,6 +139,14 @@ else
echo (defined("CORE_LC")) ? "<meta http-equiv='content-language' content='".CORE_LC."' />\n" : "";
}
// Load early
if(!defined('e_PAGETITLE') && ($_PAGE_TITLE = e107::getSingleton('eResponse')->getMetaTitle())) // use e107::title() to set.
{
define('e_PAGETITLE', $_PAGE_TITLE);
unset($_PAGE_TITLE);
}
//
// C: Send start of HTML
//
@ -147,13 +155,13 @@ if(!empty($pref['meta_copyright'][e_LANGUAGE])) e107::meta('dcterms.rights',$pre
if(!empty($pref['meta_author'][e_LANGUAGE])) e107::meta('author',$pref['meta_author'][e_LANGUAGE]);
if(!empty($pref['sitebutton']))
{
$siteButton = (strpos($pref['sitebutton'],'{e_MEDIA') !== false) ? $tp->thumbUrl($pref['sitebutton'],'w=800',false, true) : $tp->replaceConstants($pref['sitebutton'],'full');
$siteButton = (strpos($pref['sitebutton'],'{e_MEDIA') !== false) ? e107::getParser()->thumbUrl($pref['sitebutton'],'w=800',false, true) : e107::getParser()->replaceConstants($pref['sitebutton'],'full');
e107::meta('og:image',$siteButton);
unset($siteButton);
}
elseif(!empty($pref['sitelogo'])) // fallback to sitelogo
{
$siteLogo = (strpos($pref['sitelogo'],'{e_MEDIA') !== false) ? $tp->thumbUrl($pref['sitelogo'],'w=800',false, true) : $tp->replaceConstants($pref['sitelogo'],'full');
$siteLogo = (strpos($pref['sitelogo'],'{e_MEDIA') !== false) ? e107::getParser()->thumbUrl($pref['sitelogo'],'w=800',false, true) : e107::getParser()->replaceConstants($pref['sitelogo'],'full');
e107::meta('og:image',$siteLogo);
unset($siteLogo);
}
@ -185,7 +193,10 @@ if (deftrue('e_FRONTPAGE'))
}
else
{
echo "<title>".(defined('e_PAGETITLE') ? e_PAGETITLE.' - ' : (defined('PAGE_NAME') ? PAGE_NAME.' - ' : "")).SITENAME."</title>\n\n";
echo "<title>".(deftrue('e_PAGETITLE') ? e_PAGETITLE.' - ' : (defined('PAGE_NAME') ? PAGE_NAME.' - ' : "")).SITENAME."</title>\n\n";
unset($_PAGE_TITLE);
}
@ -194,7 +205,7 @@ else
//
$e_js = e107::getJs();
$e_pref = e107::getConfig('core');
$e_pref = e107::getConfig();
// Other Meta tags.
@ -216,7 +227,7 @@ if(THEME_LEGACY === true || !deftrue('BOOTSTRAP'))
// re-initalize in case globals are destroyed from $e_headers includes
$e_js = e107::getJs();
$e_pref = e107::getConfig('core');
$e_pref = e107::getConfig();
// --- Load plugin Meta files - now possible to add to all zones! --------
@ -246,7 +257,7 @@ if (is_array($pref['e_meta_list']))
if(isset($pref['sitebutton']))
{
$appleIcon = $tp->thumbUrl($pref['sitebutton'],'w=144&h=144&crop=1',null, true);
$appleIcon = e107::getParser()->thumbUrl($pref['sitebutton'],'w=144&h=144&crop=1',null, true);
echo "<link rel='apple-touch-icon' href='".$appleIcon."' />\n";
unset($appleIcon);
}
@ -318,7 +329,7 @@ else
{
//echo '
//<link rel="stylesheet" href="'.THEME_ABS.strtolower(TEXTDIRECTION).'.css" type="text/css" media="all" />';
$e_js->themeCSS(TEXTDIRECTION.'.css', 'all');
$e_js->themeCSS(TEXTDIRECTION.'.css');
}
}
@ -343,7 +354,7 @@ $CSSORDER = deftrue('CSSORDER') ? explode(",",CSSORDER) : array('library', 'othe
foreach($CSSORDER as $val)
{
$cssId = $val."_css";
$e_js->renderJs($cssId, false, 'css', false);
$e_js->renderJs($cssId, false, 'css');
}
unset($CSSORDER);
@ -483,6 +494,10 @@ if(function_exists('theme_head'))
$diz_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_description'][e_LANGUAGE]) ? $pref['meta_description'][e_LANGUAGE]." " : "";
$key_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_keywords'][e_LANGUAGE]) ? $pref['meta_keywords'][e_LANGUAGE]."," : "";
/**
* @param $type
* @return string
*/
function render_meta($type)
{
$tp = e107::getParser();
@ -633,8 +648,8 @@ echo "</head>\n";
// echo "MODE 0.6";
if($def == 'legacyCustom')
{
$HEADER = ($CUSTOMHEADER) ? $CUSTOMHEADER : $HEADER;
$FOOTER = ($CUSTOMFOOTER) ? $CUSTOMFOOTER : $FOOTER;
$HEADER = isset($CUSTOMHEADER) ? $CUSTOMHEADER : $HEADER;
$FOOTER = isset($CUSTOMFOOTER) ? $CUSTOMFOOTER : $FOOTER;
}
}
elseif($def && $def != "legacyCustom" && (isset($CUSTOMHEADER[$def]) || isset($CUSTOMFOOTER[$def]))) // 0.7/1.x themes
@ -659,12 +674,12 @@ echo "</head>\n";
if(deftrue('e_IFRAME'))
{
$HEADER = deftrue('e_IFRAME_HEADER',"");
$FOOTER = deftrue('e_IFRAME_FOOTER',"");
$HEADER = deftrue('e_IFRAME_HEADER');
$FOOTER = deftrue('e_IFRAME_FOOTER');
$body_onload .= " class='e-iframe'";
}
$HEADER = str_replace("{e_PAGETITLE}",deftrue('e_PAGETITLE',''),$HEADER);
$HEADER = str_replace("{e_PAGETITLE}",deftrue('e_PAGETITLE'),$HEADER);
//$body_onload .= " id='layout-".e107::getForm()->name2id(THEME_LAYOUT)."' ";
@ -672,7 +687,7 @@ if($noBody === true) // New in v2.2.2 - remove need for BODYTAG.
{
echo "\n<!-- Start theme.html -->\n";
}
elseif(!deftrue('BODYTAG')) // @deprecated.
elseif(!defined('BODYTAG')) // @deprecated.
{
$body_onload .= " id='layout-".e107::getForm()->name2id(THEME_LAYOUT)."' ";
echo "<body".$body_onload.">\n";
@ -767,8 +782,8 @@ if ($e107_popup != 1) {
'{BODY_ONLOAD}' => $body_onload,
'{LAYOUT_ID}' => 'layout-'.e107::getForm()->name2id(THEME_LAYOUT),
'{---MODAL---}' => (isset($LAYOUT['_modal_']) ? $LAYOUT['_modal_'] : '') ,
'{---HEADER---}' => $tp->parseTemplate('{HEADER}',true),
'{---FOOTER---}' => $tp->parseTemplate('{FOOTER}',true),
'{---HEADER---}' => e107::getParser()->parseTemplate('{HEADER}',true),
'{---FOOTER---}' => e107::getParser()->parseTemplate('{FOOTER}',true),
);
parseheader($HEADER, $psc);

View File

@ -4454,12 +4454,17 @@ class eResponse
* @param string $title
* @return eResponse
*/
function addMetaTitle($title)
public function addMetaTitle($title, $reset=false)
{
if($reset)
{
$this->_e_PAGETITLE = array();
}
return $this->addMetaData('e_PAGETITLE', $title);
}
function getMetaTitle()
public function getMetaTitle()
{
return $this->getMetaData('e_PAGETITLE', $this->_meta_title_separator);
}

View File

@ -2491,16 +2491,27 @@ class e107
if($name === 'description')
{
$response->addMetaDescription($content); //Cam: TBD
$response->addMetaDescription($content);
}
if($name === 'keywords')
{
$response->addMetaKeywords($content); //Cam: TBD
$response->addMetaKeywords($content);
}
return $response->addMeta($name, $content, $extended);
// return self::getUrl()->response()->addMeta($name, $content, $extended);
}
/**
* Set the Page Title ie. <title>Whatever</title>
* @param string $title
*/
public static function title($title)
{
/** @var eResponse $response */
$response = self::getSingleton('eResponse');
$response->addMetaTitle($title, true);
}
/**

View File

@ -3839,7 +3839,7 @@ class e_parser
protected $bootstrap = null;
protected $fontawesome = null;
protected $convertToWebp = false;
protected $removedList = array();
protected $nodesToDelete = array();
@ -3949,6 +3949,11 @@ class e_parser
$this->staticUrl = e_HTTP_STATIC;
}
// if(e107::pref('core', 'thumb_to_webp', false))
{
$this->convertToWebp = true;
}
}
/**
@ -4045,6 +4050,14 @@ class e_parser
$this->bootstrap = (int) $version;
}
/**
* @param bool $bool
*/
public function setConvertToWebp($bool)
{
$this->convertToWebp = (bool) $bool;
}
/**
* Add leading zeros to a number. eg. 3 might become 000003

View File

@ -211,3 +211,7 @@ define("IMALAN_183", "PNG and GIF files will be automatically converted to jpeg
define("IMALAN_184", "Default Image Sizes");
define("IMALAN_185", "Maximum height in pixels");
define("IMALAN_186", "Enter some text to filter results");
define("IMALAN_187", "Convert to webp during import");
define("IMALAN_188", "Convert to webp during render");
define("IMALAN_189", "JPEG, PNG and GIF files will be automatically converted to webp format. (icons excluded)");

View File

@ -192,6 +192,7 @@ class news_front
return e107::getMenu()->renderMenu('forum','newforumposts_menu', $parms, true);
}
return null;
}
@ -248,6 +249,8 @@ class news_front
{
echo $this->renderComments($this->comments);
}
return null;
}
private function setActions()
@ -424,6 +427,8 @@ class news_front
public function debug()
{
$title = e107::getSingleton('eResponse')->getMetaTitle();
echo "<div class='alert alert-info'>";
echo "<h4>News Debug Info</h4>";
echo "<table class='table table-striped table-bordered'>";
@ -431,7 +436,7 @@ class news_front
echo "<tr><td><b>subaction:</b></td><td>".$this->subAction."</td></tr>";
echo "<tr><td><b>route:</b></td><td>".$this->route."</td></tr>";
echo "<tr><td><b>e_QUERY:</b></td><td>".e_QUERY."</td></tr>";
echo "<tr><td><b>e_PAGETITLE:</b></td><td>".defset('e_PAGETITLE','(unassigned)')."</td></tr>";
echo "<tr><td><b>e_PAGETITLE:</b></td><td>".vartrue($title,'(unassigned)')."</td></tr>";
echo "<tr><td><b>PAGE_NAME:</b></td><td>".defset('PAGE_NAME','(unassigned)')."</td></tr>";
echo "<tr><td><b>CacheTimeout:</b></td><td>".$this->cacheRefreshTime."</td></tr>";
echo "<tr><td><b>_GET:</b></td><td>".print_r($_GET,true)."</td></tr>";
@ -494,7 +499,7 @@ class news_front
$newsAr = $sql -> db_getList();
}
$i = $this->interval;
// $i = $this->interval;
// require_once(e_CORE.'shortcodes/batch/news_archives.php');
@ -549,23 +554,20 @@ class news_front
case "tag":
case "author":
if(!defined('e_PAGETITLE'))
{
define('e_PAGETITLE', $this->subAction);
e107::meta('og:title', $this->subAction);
}
e107::title($this->subAction);
e107::meta('og:title', $this->subAction);
e107::meta('robots', 'noindex');
break;
case "list":
$title = $tp->toHTML($news['category_name'],false,'TITLE_PLAIN');
if(!defined('e_PAGETITLE'))
{
define('e_PAGETITLE', $title );
e107::meta('og:title', $title);
}
e107::title($title);
e107::meta('og:title', $title);
e107::meta('robots', 'noindex');
break;
case "day":
@ -587,11 +589,8 @@ class news_front
$this->dayMonth = $title;
if(!defined('e_PAGETITLE'))
{
define('e_PAGETITLE', $title );
e107::meta('og:title', $title);
}
e107::title($title);
e107::meta('og:title', $title);
e107::meta('robots', 'noindex');
break;
@ -613,9 +612,9 @@ class news_front
e107::meta('robots', $news['news_meta_robots']);
}
if($news['news_title'] && !defined('e_PAGETITLE'))
if($news['news_title'])
{
define('e_PAGETITLE', $news['news_title']);
e107::title($news['news_title']);
e107::meta('og:title',$news['news_title']);
e107::meta('og:type','article');
e107::meta('twitter:card', 'summary');
@ -699,9 +698,9 @@ class news_front
if($news['category_name'] && !defined('e_PAGETITLE') && $type == 'cat')
if($news['category_name'] && $type == 'cat')
{
define('e_PAGETITLE', $tp->toHTML($news['category_name'],false,'TITLE_PLAIN'));
e107::title($tp->toHTML($news['category_name'],false,'TITLE_PLAIN'));
}
if($news['category_meta_keywords'] && !defined('META_KEYWORDS'))
@ -727,7 +726,7 @@ class news_front
$e107cache->set($cache_tag, $cache_data);
$e107cache->set($cache_tag."_caption", $this->caption);
$e107cache->set($cache_tag."_title", defined("e_PAGETITLE") ? e_PAGETITLE : '');
$e107cache->set($cache_tag."_title", e107::getSingleton('eResponse')->getMetaTitle());
$e107cache->set($cache_tag."_diz", defined("META_DESCRIPTION") ? META_DESCRIPTION : '');
$e107cache->set($cache_tag."_rows", e107::serialize($rowData,'json'));
@ -776,7 +775,7 @@ class news_front
if($etitle)
{
define('e_PAGETITLE', $etitle);
e107::title($etitle);
}
if($ediz)
@ -980,7 +979,7 @@ class news_front
// {
// define('e_PAGETITLE', $tp->toHTML($category_name,FALSE,'TITLE'));
// }
e107::getDebug()->log("PageTitle: ".e_PAGETITLE);
$currentNewsAction = $this->action;
$action = $currentNewsAction;
@ -1568,14 +1567,6 @@ class news_front
break;
}
/*if($action != "" && !is_numeric($action))
{
if($action == "item" && $this->pref['meta_news_summary'] && $newsAr[1]['news_title'])
{
define("META_DESCRIPTION",SITENAME.": ".$newsAr[1]['news_title']." - ".$newsAr[1]['news_summary']);
}
define("e_PAGETITLE", $p_title);
}*/
$currentNewsAction = $this->action;