From 5800bb6804a2aba16cc1bb58f92115ad9ab13f1b Mon Sep 17 00:00:00 2001 From: danrwalker Date: Mon, 25 Mar 2019 15:51:00 +0000 Subject: [PATCH] Added the ability to extend the managers meta data --- .../packages/manager/Routes/Manager.route.php | 3 +++ dist/packages/manager/Views/_base.tpl | 4 ++-- dist/twist/Core/Helpers/Route.helper.php | 19 ++++++++++++++---- dist/twist/Core/Models/Route/Meta.model.php | 20 +++++++++++-------- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/dist/packages/manager/Routes/Manager.route.php b/dist/packages/manager/Routes/Manager.route.php index 07f365ad..9c915a82 100755 --- a/dist/packages/manager/Routes/Manager.route.php +++ b/dist/packages/manager/Routes/Manager.route.php @@ -38,6 +38,9 @@ public function load(){ \Twist::define('TWIST_MANAGER_PACKAGE',realpath(dirname(__FILE__).'/../')); + $this->meta()->title('TwistPHP Manager'); + $this->meta()->robots('noindex,nofollow'); + //Allow the manager to still be accessible even in maintenance mode $this->bypassMaintenanceMode( '/%' ); diff --git a/dist/packages/manager/Views/_base.tpl b/dist/packages/manager/Views/_base.tpl index 980eec82..12aea5ef 100755 --- a/dist/packages/manager/Views/_base.tpl +++ b/dist/packages/manager/Views/_base.tpl @@ -1,7 +1,6 @@ - TwistPHP Manager @@ -14,8 +13,9 @@ + {resource:manager} - {resource:manager} + {meta:tags} diff --git a/dist/twist/Core/Helpers/Route.helper.php b/dist/twist/Core/Helpers/Route.helper.php index 6c4da5f8..310faa59 100755 --- a/dist/twist/Core/Helpers/Route.helper.php +++ b/dist/twist/Core/Helpers/Route.helper.php @@ -1342,10 +1342,21 @@ public function serve($blExitOnComplete = true){ \Twist::respond(403,null,$blExitOnComplete); }else{ - $this->meta()->title(\Twist::framework()->setting('SITE_NAME')); - $this->meta()->description(\Twist::framework()->setting('SITE_DESCRIPTION')); - $this->meta()->author(\Twist::framework()->setting('SITE_AUTHOR')); - $this->meta()->keywords(\Twist::framework()->setting('SITE_KEYWORDS')); + if(is_null($this->meta()->get('title','title'))){ + $this->meta()->title(\Twist::framework()->setting('SITE_NAME')); + } + + if(is_null($this->meta()->get('meta','description'))){ + $this->meta()->description(\Twist::framework()->setting('SITE_DESCRIPTION')); + } + + if(is_null($this->meta()->get('meta','author'))){ + $this->meta()->author(\Twist::framework()->setting('SITE_AUTHOR')); + } + + if(is_null($this->meta()->get('meta','keywords'))){ + $this->meta()->keywords(\Twist::framework()->setting('SITE_KEYWORDS')); + } //Load the page from cache $this->loadPageCache($arrRoute['cache_key']); diff --git a/dist/twist/Core/Models/Route/Meta.model.php b/dist/twist/Core/Models/Route/Meta.model.php index 80033891..c0226668 100755 --- a/dist/twist/Core/Models/Route/Meta.model.php +++ b/dist/twist/Core/Models/Route/Meta.model.php @@ -45,6 +45,10 @@ protected function add($strType,$strName,$strValue){ ); } + public function get($strType,$strName){ + return (array_key_exists(sprintf('%s-%s',$strType,$strName),$this->arrTags)) ? [sprintf('%s-%s',$strType,$strName)] : null; + } + public function getTags(){ $arrOut = array(); @@ -102,6 +106,14 @@ public function custom($strKey,$strValue){ $this->add('meta',$strKey,$strValue); } + public function css($strFile,$strRel = 'stylesheet'){ + $this->add('link',$strFile,$strRel); + } + + public function js($strFile){ + $this->add('script',$strFile,''); + } + public function ogTitle($strContent){ $this->add('og','title',$strContent); } @@ -276,14 +288,6 @@ public function ogCustom($strKey,$strContent){ $this->add('og',$strKey,$strContent); } - public function css($strFile,$strRel = 'stylesheet'){ - $this->add('link',$strFile,$strRel); - } - - public function js($strFile){ - $this->add('script',$strFile,''); - } - public function generate(){ $strOut = '';