Robots plugin, dynamic titles, fix permissions when upload images
This commit is contained in:
parent
be8cf51393
commit
f9b65c5a13
|
@ -35,6 +35,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
Alert::set( $Language->g('The changes have been saved') );
|
||||
}
|
||||
} else {
|
||||
// If the checkbox is not selected the form doesn't send the field
|
||||
$_POST['noindex'] = isset($_POST['noindex'])?true:false;
|
||||
$_POST['nofollow'] = isset($_POST['nofollow'])?true:false;
|
||||
$_POST['noarchive'] = isset($_POST['noarchive'])?true:false;
|
||||
|
||||
$key = editPage($_POST);
|
||||
if ($key!==false) {
|
||||
Alert::set( $Language->g('The changes have been saved') );
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
// ============================================================================
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
// If the checkbox is not selected the form doesn't send the field
|
||||
$_POST['noindex'] = isset($_POST['noindex'])?true:false;
|
||||
$_POST['nofollow'] = isset($_POST['nofollow'])?true:false;
|
||||
$_POST['noarchive'] = isset($_POST['noarchive'])?true:false;
|
||||
|
||||
createPage($_POST);
|
||||
Redirect::page('content');
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
<!-- CSS -->
|
||||
<?php
|
||||
echo Theme::bootstrapCSS();
|
||||
echo Theme::cssBootstrap();
|
||||
echo Theme::css(array(
|
||||
'jquery-auto-complete.css',
|
||||
'open-iconic-bootstrap.min.css',
|
||||
|
@ -23,7 +23,7 @@
|
|||
<!-- Javascript -->
|
||||
<?php
|
||||
echo Theme::jquery();
|
||||
echo Theme::bootstrapJS();
|
||||
echo Theme::jsBootstrap();
|
||||
echo Theme::js(array(
|
||||
'jquery-auto-complete.min.js',
|
||||
'jquery.datetimepicker.full.min.js'
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
<!-- CSS -->
|
||||
<?php
|
||||
echo Theme::bootstrapCSS();
|
||||
echo Theme::cssBootstrap();
|
||||
echo Theme::css(array(
|
||||
'bludit.css'
|
||||
), DOMAIN_ADMIN_THEME_CSS);
|
||||
|
@ -20,7 +20,7 @@
|
|||
<!-- Javascript -->
|
||||
<?php
|
||||
echo Theme::jquery();
|
||||
echo Theme::bootstrapJS();
|
||||
echo Theme::jsBootstrap();
|
||||
?>
|
||||
|
||||
<!-- Plugins -->
|
||||
|
|
|
@ -78,16 +78,9 @@
|
|||
<textarea id="jseditor" style="display:none;"><?php echo $page->contentRaw(false) ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group mt-2">
|
||||
<button id="jsbuttonSave" type="button" class="btn btn-primary"><?php echo $L->g('Save') ?></button>
|
||||
<button id="jsbuttonDraft" type="button" class="btn btn-secondary"><?php echo $L->g('Save as draft') ?></button>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT ?>dashboard" class="btn btn-secondary"><?php echo $L->g('Cancel') ?></a>
|
||||
<?php
|
||||
if (count($page->children())===0) {
|
||||
echo '<button id="jsbuttonDelete" type="button" class="btn btn-secondary">'.$L->g('Delete').'</button>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php if($page->draft()): ?>
|
||||
<div class="alert alert-primary mt-2 mb-2">The content is saved as a draft. To publish it click on the button <b>Publish</b> or if you still working on it click on <b>Save as draft</b>.</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -226,6 +219,18 @@
|
|||
?>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div class="form-group mt-2">
|
||||
<button id="jsbuttonSave" type="button" class="btn btn-primary"><?php echo ($page->draft()?$L->g('Publish'):$L->g('Update')) ?></button>
|
||||
<button id="jsbuttonDraft" type="button" class="btn btn-secondary"><?php echo $L->g('Save as draft') ?></button>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT ?>dashboard" class="btn btn-secondary"><?php echo $L->g('Cancel') ?></a>
|
||||
<?php
|
||||
if (count($page->children())===0) {
|
||||
echo '<button id="jsbuttonDelete" type="button" class="btn btn-secondary">'.$L->g('Delete').'</button>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<!-- Modal for Categories -->
|
||||
<div id="jscategoryModal" class="modal fade" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
|
|
@ -72,12 +72,6 @@
|
|||
<textarea id="jseditor" style="display:none;"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group mt-2">
|
||||
<button id="jsbuttonSave" type="button" class="btn btn-primary"><?php echo $L->g('Publish') ?></button>
|
||||
<button id="jsbuttonDraft" type="button" class="btn btn-secondary"><?php echo $L->g('Save as draft') ?></button>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT ?>dashboard" class="btn btn-secondary"><?php echo $L->g('Cancel') ?></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- TABS IMAGES -->
|
||||
|
@ -205,6 +199,13 @@
|
|||
?>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div class="form-group mt-2">
|
||||
<button id="jsbuttonSave" type="button" class="btn btn-primary"><?php echo $L->g('Publish') ?></button>
|
||||
<button id="jsbuttonDraft" type="button" class="btn btn-secondary"><?php echo $L->g('Save as draft') ?></button>
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT ?>dashboard" class="btn btn-secondary"><?php echo $L->g('Cancel') ?></a>
|
||||
</div>
|
||||
|
||||
<!-- Modal for Categories -->
|
||||
<div id="jscategoryModal" class="modal fade" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
|
|
@ -169,6 +169,48 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
|||
'tip'=>'Allow unicode characters in the URL and some part of the system.'
|
||||
));
|
||||
|
||||
echo Bootstrap::formTitle(array('title'=>$L->g('Title formats')));
|
||||
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'titleFormatHomepage',
|
||||
'label'=>'Homepage',
|
||||
'value'=>$Site->titleFormatHomepage(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>'Variables allowed: <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
|
||||
'placeholder'=>''
|
||||
));
|
||||
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'titleFormatPages',
|
||||
'label'=>'Pages',
|
||||
'value'=>$Site->titleFormatPages(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>'Variables allowed: <code>{{page-title}}</code> <code>{{page-description}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
|
||||
'placeholder'=>''
|
||||
));
|
||||
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'titleFormatCategory',
|
||||
'label'=>'Category',
|
||||
'value'=>$Site->titleFormatCategory(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>'Variables allowed: <code>{{category-name}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
|
||||
'placeholder'=>''
|
||||
));
|
||||
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'titleFormatTag',
|
||||
'label'=>'Tag',
|
||||
'value'=>$Site->titleFormatTag(),
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>'Variables allowed: <code>{{tag-name}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
|
||||
'placeholder'=>''
|
||||
));
|
||||
|
||||
echo Bootstrap::formTitle(array('title'=>$L->g('URL Filters')));
|
||||
|
||||
echo Bootstrap::formInputText(array(
|
||||
|
|
|
@ -10,6 +10,7 @@ foreach ($_FILES['bluditInputFiles']['name'] as $key=>$filename) {
|
|||
|
||||
// Move from temporary directory to uploads folder
|
||||
rename($_FILES['bluditInputFiles']['tmp_name'][$key], PATH_UPLOADS.$nextFilename);
|
||||
chmod(PATH_UPLOADS.$nextFilename, 0644);
|
||||
|
||||
// Generate Thumbnail
|
||||
|
||||
|
|
|
@ -443,6 +443,38 @@ class dbPages extends dbJSON
|
|||
return ++$tmp;
|
||||
}
|
||||
|
||||
// Returns the next page key of the current page key
|
||||
public function nextPageKey($currentKey)
|
||||
{
|
||||
if ($this->db[$currentKey]['status']=='published') {
|
||||
$keys = array_keys($this->db);
|
||||
$position = array_search($currentKey, $keys) - 1;
|
||||
if (isset($keys[$position])) {
|
||||
$nextKey = $keys[$position];
|
||||
if ($this->db[$nextKey]['status']=='published') {
|
||||
return $nextKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns the previous page key of the current page key
|
||||
public function previousPageKey($currentKey)
|
||||
{
|
||||
if ($this->db[$currentKey]['status']=='published') {
|
||||
$keys = array_keys($this->db);
|
||||
$position = array_search($currentKey, $keys) + 1;
|
||||
if (isset($keys[$position])) {
|
||||
$prevKey = $keys[$position];
|
||||
if ($this->db[$prevKey]['status']=='published') {
|
||||
return $prevKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns an array with a list of key of pages, FALSE if out of range
|
||||
// The database is sorted by date or by position
|
||||
// (int) $pageNumber, the page number
|
||||
|
|
|
@ -34,7 +34,11 @@ class dbSite extends dbJSON
|
|||
'linkedin'=> array('inFile'=>false, 'value'=>''),
|
||||
'orderBy'=> array('inFile'=>false, 'value'=>'date'), // date or position
|
||||
'extremeFriendly'=> array('inFile'=>false, 'value'=>true),
|
||||
'autosaveInterval'=> array('inFile'=>false, 'value'=>2)
|
||||
'autosaveInterval'=> array('inFile'=>false, 'value'=>2),
|
||||
'titleFormatHomepage'=> array('inFile'=>false, 'value'=>'{{site-slogan}} | {{site-title}}'),
|
||||
'titleFormatPages'=> array('inFile'=>false, 'value'=>'{{page-title}} | {{site-title}}'),
|
||||
'titleFormatCategory'=> array('inFile'=>false, 'value'=>'{{category-name}} | {{site-title}}'),
|
||||
'titleFormatTag'=> array('inFile'=>false, 'value'=>'{{tag-name}} | {{site-title}}')
|
||||
);
|
||||
|
||||
function __construct()
|
||||
|
@ -209,6 +213,26 @@ class dbSite extends dbJSON
|
|||
return $this->getField('footer');
|
||||
}
|
||||
|
||||
public function titleFormatPages()
|
||||
{
|
||||
return $this->getField('titleFormatPages');
|
||||
}
|
||||
|
||||
public function titleFormatHomepage()
|
||||
{
|
||||
return $this->getField('titleFormatHomepage');
|
||||
}
|
||||
|
||||
public function titleFormatCategory()
|
||||
{
|
||||
return $this->getField('titleFormatCategory');
|
||||
}
|
||||
|
||||
public function titleFormatTag()
|
||||
{
|
||||
return $this->getField('titleFormatTag');
|
||||
}
|
||||
|
||||
// Returns the full domain and base url
|
||||
// For example, https://www.domain.com/bludit
|
||||
public function url()
|
||||
|
@ -216,6 +240,8 @@ class dbSite extends dbJSON
|
|||
return $this->getField('url');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Returns the protocol and the domain, without the base url
|
||||
// For example, http://www.domain.com
|
||||
public function domain()
|
||||
|
|
|
@ -61,6 +61,10 @@ function buildPage($key) {
|
|||
// Get the keys of the child
|
||||
$page->setField('childrenKeys', $dbPages->getChildren($key));
|
||||
|
||||
// Set previous and next page key
|
||||
$page->setField('previousKey', $dbPages->previousPageKey($key));
|
||||
$page->setField('nextKey', $dbPages->nextPageKey($key));
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,41 +53,52 @@ class Theme {
|
|||
return DOMAIN_ADMIN;
|
||||
}
|
||||
|
||||
// Return the metatag <title> with a predefine structure
|
||||
public static function headTitle()
|
||||
public static function metaTags($tag)
|
||||
{
|
||||
global $Url;
|
||||
global $Site;
|
||||
if ($tag=='title') {
|
||||
return self::metaTagTitle();
|
||||
} elseif ($tag=='description') {
|
||||
return self::metaTagDescription();
|
||||
}
|
||||
}
|
||||
|
||||
public static function metaTagTitle()
|
||||
{
|
||||
global $url;
|
||||
global $site;
|
||||
global $dbTags;
|
||||
global $dbCategories;
|
||||
global $WHERE_AM_I;
|
||||
global $page;
|
||||
|
||||
$title = $Site->title();
|
||||
|
||||
if (Text::isNotEmpty($Site->slogan())) {
|
||||
$title = $Site->slogan().' | '.$Site->title();
|
||||
}
|
||||
|
||||
if ($WHERE_AM_I=='page') {
|
||||
$title = $page->title().' | '.$Site->title();
|
||||
$format = $site->titleFormatPages();
|
||||
$format = Text::replace('{{page-title}}', $page->title(), $format);
|
||||
$format = Text::replace('{{page-description}}', $page->description(), $format);
|
||||
}
|
||||
elseif ($WHERE_AM_I=='tag') {
|
||||
$tagKey = $Url->slug();
|
||||
$tagKey = $url->slug();
|
||||
$tagName = $dbTags->getName($tagKey);
|
||||
$title = $tagName.' | '.$Site->title();
|
||||
$format = $site->titleFormatTag();
|
||||
$format = Text::replace('{{tag-name}}', $tagName, $format);
|
||||
}
|
||||
elseif ($WHERE_AM_I=='category') {
|
||||
$categoryKey = $Url->slug();
|
||||
$categoryKey = $url->slug();
|
||||
$categoryName = $dbCategories->getName($categoryKey);
|
||||
$title = $categoryName.' | '.$Site->title();
|
||||
$format = $site->titleFormatCategory();
|
||||
$format = Text::replace('{{category-name}}', $categoryName, $format);
|
||||
} else {
|
||||
$format = $site->titleFormatHomepage();
|
||||
}
|
||||
|
||||
return '<title>'.$title.'</title>'.PHP_EOL;
|
||||
$format = Text::replace('{{site-title}}', $site->title(), $format);
|
||||
$format = Text::replace('{{site-slogan}}', $site->slogan(), $format);
|
||||
$format = Text::replace('{{site-description}}', $site->description(), $format);
|
||||
|
||||
return '<title>'.$format.'</title>'.PHP_EOL;
|
||||
}
|
||||
|
||||
// Return the metatag <decription> with a predefine structure
|
||||
public static function headDescription()
|
||||
public static function metaTagDescription()
|
||||
{
|
||||
global $Site;
|
||||
global $WHERE_AM_I;
|
||||
|
@ -102,6 +113,20 @@ class Theme {
|
|||
return '<meta name="description" content="'.$description.'">'.PHP_EOL;
|
||||
}
|
||||
|
||||
// DEPRECATED v3.0.0
|
||||
// Return the metatag <title> with a predefine structure
|
||||
public static function headTitle()
|
||||
{
|
||||
return self::metaTagTitle();
|
||||
}
|
||||
|
||||
// DEPRECATED v3.0.0
|
||||
// Return the metatag <decription> with a predefine structure
|
||||
public static function headDescription()
|
||||
{
|
||||
return self::metaTagDescription();
|
||||
}
|
||||
|
||||
public static function charset($charset)
|
||||
{
|
||||
return '<meta charset="'.$charset.'">'.PHP_EOL;
|
||||
|
@ -171,12 +196,12 @@ class Theme {
|
|||
return '<script charset="utf-8" src="'.DOMAIN_CORE_JS.'jquery.min.js?version='.BLUDIT_VERSION.'"></script>'.PHP_EOL;
|
||||
}
|
||||
|
||||
public static function bootstrapJS()
|
||||
public static function jsBootstrap()
|
||||
{
|
||||
return '<script charset="utf-8" src="'.DOMAIN_CORE_JS.'bootstrap-bundle.min.js?version='.BLUDIT_VERSION.'"></script>'.PHP_EOL;
|
||||
}
|
||||
|
||||
public static function bootstrapCSS()
|
||||
public static function cssBootstrap()
|
||||
{
|
||||
return '<link rel="stylesheet" type="text/css" href="'.DOMAIN_CORE_CSS.'bootstrap.min.css?version='.BLUDIT_VERSION.'">'.PHP_EOL;
|
||||
}
|
||||
|
|
|
@ -208,6 +208,18 @@ class Page {
|
|||
return HTML_PATH_ROOT.PAGE_URI_FILTER.$key;
|
||||
}
|
||||
|
||||
// Returns the previous page key
|
||||
public function previousKey()
|
||||
{
|
||||
return $this->getValue('previousKey');
|
||||
}
|
||||
|
||||
// Returns the next page key
|
||||
public function nextKey()
|
||||
{
|
||||
return $this->getValue('nextKey');
|
||||
}
|
||||
|
||||
// Returns the category name
|
||||
public function category()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Robots",
|
||||
"description": "You can use a special HTML meta tag to tell robots not to index the content of a page, and/or not scan it for links to follow."
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"author": "Bludit",
|
||||
"email": "",
|
||||
"website": "https://plugins.bludit.com",
|
||||
"version": "3.0",
|
||||
"releaseDate": "2018-01-23",
|
||||
"license": "MIT",
|
||||
"compatible": "3.0",
|
||||
"notes": ""
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
class pluginRobots extends Plugin {
|
||||
|
||||
public function siteHead()
|
||||
{
|
||||
global $WHERE_AM_I;
|
||||
global $page;
|
||||
|
||||
$html = PHP_EOL.'<!-- Robots plugin -->'.PHP_EOL;
|
||||
|
||||
if ($WHERE_AM_I=='page') {
|
||||
$robots = array();
|
||||
|
||||
if ($page->noindex()) {
|
||||
$robots['noindex'] = 'noindex';
|
||||
}
|
||||
|
||||
if ($page->nofollow()) {
|
||||
$robots['nofollow'] = 'nofollow';
|
||||
}
|
||||
|
||||
if ($page->noarchive()) {
|
||||
$robots['noarchive'] = 'noarchive';
|
||||
}
|
||||
|
||||
if (!empty($robots)) {
|
||||
$robots = implode(' ', $robots);
|
||||
$html .= '<meta name="robots" content="'.$robots.'">'.PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
|
@ -28,8 +28,11 @@
|
|||
|
||||
<!-- Javascript -->
|
||||
<?php
|
||||
// Include Jquery file from Bludit Core
|
||||
echo Theme::jquery();
|
||||
echo Theme::bootstrapJS();
|
||||
|
||||
// Include javascript Bootstrap file from Bludit Core
|
||||
echo Theme::jsBootstrap();
|
||||
?>
|
||||
|
||||
<!-- Load Bludit Plugins: Site Body End -->
|
||||
|
|
|
@ -3,18 +3,18 @@
|
|||
<meta name="author" content="Bludit CMS">
|
||||
|
||||
<!-- Dynamic title tag -->
|
||||
<?php echo Theme::headTitle(); ?>
|
||||
<?php echo Theme::metaTags('title'); ?>
|
||||
|
||||
<!-- Dynamic description tag -->
|
||||
<?php echo Theme::headDescription(); ?>
|
||||
<?php echo Theme::metaTags('description'); ?>
|
||||
|
||||
<!-- Favicon -->
|
||||
<!-- Include Favicon -->
|
||||
<?php echo Theme::favicon('img/favicon.png'); ?>
|
||||
|
||||
<!-- CSS: Bootstrap -->
|
||||
<?php echo Theme::bootstrapCSS(); ?>
|
||||
<!-- Include Bootstrap CSS file bootstrap.css -->
|
||||
<?php echo Theme::cssBootstrap(); ?>
|
||||
|
||||
<!-- CSS: Styles for this theme -->
|
||||
<!-- Include CSS Styles from this theme -->
|
||||
<?php echo Theme::css('css/style.css'); ?>
|
||||
|
||||
<!-- Load Bludit Plugins: Site head -->
|
||||
|
|
|
@ -46,8 +46,11 @@
|
|||
|
||||
<!-- Javascript -->
|
||||
<?php
|
||||
// Include Jquery file from Bludit Core
|
||||
echo Theme::jquery();
|
||||
echo Theme::bootstrapJS();
|
||||
|
||||
// Include javascript Bootstrap file from Bludit Core
|
||||
echo Theme::jsBootstrap();
|
||||
?>
|
||||
|
||||
<!-- Load Bludit Plugins: Site Body End -->
|
||||
|
|
|
@ -3,18 +3,18 @@
|
|||
<meta name="author" content="Bludit CMS">
|
||||
|
||||
<!-- Dynamic title tag -->
|
||||
<?php echo Theme::headTitle(); ?>
|
||||
<?php echo Theme::metaTags('title'); ?>
|
||||
|
||||
<!-- Dynamic description tag -->
|
||||
<?php echo Theme::headDescription(); ?>
|
||||
<?php echo Theme::metaTags('description'); ?>
|
||||
|
||||
<!-- Favicon -->
|
||||
<!-- Include Favicon -->
|
||||
<?php echo Theme::favicon('img/favicon.png'); ?>
|
||||
|
||||
<!-- CSS: Bootstrap -->
|
||||
<?php echo Theme::bootstrapCSS(); ?>
|
||||
<!-- Include Bootstrap CSS file bootstrap.css -->
|
||||
<?php echo Theme::cssBootstrap(); ?>
|
||||
|
||||
<!-- CSS: Styles for this theme -->
|
||||
<!-- Include CSS Styles from this theme -->
|
||||
<?php echo Theme::css('css/style.css'); ?>
|
||||
|
||||
<!-- Load Bludit Plugins: Site head -->
|
||||
|
|
Loading…
Reference in New Issue