Skip to content

Commit

Permalink
Added the ability to extend the managers meta data
Browse files Browse the repository at this point in the history
  • Loading branch information
danrwalker committed Mar 25, 2019
1 parent 9bfabc6 commit 5800bb6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
3 changes: 3 additions & 0 deletions dist/packages/manager/Routes/Manager.route.php
Expand Up @@ -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( '/%' );

Expand Down
4 changes: 2 additions & 2 deletions dist/packages/manager/Views/_base.tpl
@@ -1,7 +1,6 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-gb" dir="ltr">
<head>
<title>TwistPHP Manager</title>
<!--================================ META ================================-->
<meta charset="utf-8">
<!--[if lt IE 9]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
Expand All @@ -14,8 +13,9 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<!--================================ INTERFACE RESOURCES ================================-->

{resource:manager}
{resource:manager}
{meta:tags}

<!--================================ LINKED DOCUMENTS ================================-->
<link rel="shortcut icon" type="image/x-icon" href="{core:logo-favicon}">
Expand Down
19 changes: 15 additions & 4 deletions dist/twist/Core/Helpers/Route.helper.php
Expand Up @@ -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']);
Expand Down
20 changes: 12 additions & 8 deletions dist/twist/Core/Models/Route/Meta.model.php
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 = '';
Expand Down

0 comments on commit 5800bb6

Please sign in to comment.