Absolute url, and more constanst for themes and plugins

This commit is contained in:
Diego Najar 2017-05-30 21:54:09 +02:00
parent 85f863f586
commit 4a7daf45a2
7 changed files with 46 additions and 49 deletions

View File

@ -245,9 +245,18 @@ define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/');
define('JQUERY', HTML_PATH_ROOT.'bl-kernel/js/jquery.min.js');
// --- Objects with dependency ---
$Language = new dbLanguage( $Site->locale() );
$Login = new Login( $dbUsers );
$Url->checkFilters( $Site->uriFilters() );
// --- Objects shortcuts ---
$L = $Language;
// --- CONSTANTS with dependency ---
// --- PHP paths with dependency ---
// This paths are absolutes for the OS
// Depreacted, use THEME_DIR and THEME_DIR_XXX
define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS);
define('THEME_DIR_PHP', THEME_DIR.'php'.DS);
define('THEME_DIR_CSS', THEME_DIR.'css'.DS);
@ -258,7 +267,7 @@ define('THEME_DIR_LANG', THEME_DIR.'languages'.DS);
// --- Absolute paths with domain ---
// This paths are absolutes for the user / web browsing.
define('DOMAIN', $Site->domain());
define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT);
define('DOMAIN_BASE', $Site->url());
define('DOMAIN_THEME', DOMAIN.HTML_PATH_THEME);
define('DOMAIN_THEME_CSS', DOMAIN.HTML_PATH_THEME_CSS);
define('DOMAIN_THEME_JS', DOMAIN.HTML_PATH_THEME_JS);
@ -266,16 +275,10 @@ define('DOMAIN_THEME_IMG', DOMAIN.HTML_PATH_THEME_IMG);
define('DOMAIN_UPLOADS', DOMAIN.HTML_PATH_UPLOADS);
define('DOMAIN_UPLOADS_PROFILES', DOMAIN.HTML_PATH_UPLOADS_PROFILES);
define('DOMAIN_UPLOADS_THUMBNAILS', DOMAIN.HTML_PATH_UPLOADS_THUMBNAILS);
define('DOMAIN_TAGS', trim(DOMAIN_BASE, '/').'/'.$Url->filters('tag',$trim=true).'/');
define('DOMAIN_CATEGORY', trim(DOMAIN_BASE, '/').'/'.$Url->filters('category',$trim=true).'/');
define('DOMAIN_PAGE', trim(DOMAIN_BASE, '/').'/'.$Url->filters('page',$trim=true).'/');
// --- Objects with dependency ---
$Language = new dbLanguage( $Site->locale() );
$Login = new Login( $dbUsers );
$Url->checkFilters( $Site->uriFilters() );
// --- Objects shortcuts ---
$L = $Language;
// --- CONSTANTS with dependency ---
define('ORDER_BY', $Site->orderBy());
$ADMIN_CONTROLLER = '';

View File

@ -152,29 +152,13 @@ class Page {
public function permalink($absolute=true)
{
global $Url;
global $Site;
$url = trim(DOMAIN_BASE,'/');
$key = $this->key();
$filter = trim($Url->filters('page'), '/');
$htmlPath = trim(HTML_PATH_ROOT,'/');
if(empty($filter)) {
$tmp = $key;
}
else {
$tmp = $filter.'/'.$key;
}
if($absolute) {
return $url.'/'.$tmp;
return DOMAIN_PAGE.$key;
}
if(empty($htmlPath)) {
return '/'.$tmp;
}
return '/'.$htmlPath.'/'.$tmp;
$filter = $Url->filters('page', true);
return trim(HTML_PATH_ROOT,'/').'/'.$filter.'/'.$key;
}
// Returns the category key
@ -319,7 +303,7 @@ class Page {
}
if($absolute) {
return HTML_PATH_UPLOADS.$fileName;
return DOMAIN_UPLOADS.$fileName;
}
return $fileName;

View File

@ -42,7 +42,7 @@ class pluginCategories extends Plugin {
// By default the database of categories are alphanumeric sorted
foreach( $dbCategories->db as $key=>$fields ) {
$html .= '<li>';
$html .= '<a href="'.DOMAIN_BASE.$filter.'/'.$key.'">';
$html .= '<a href="'.DOMAIN_CATEGORY.$key.'">';
$html .= $fields['name'];
$html .= ' ('.count($fields['list']).')';
$html .= '</a>';

View File

@ -29,6 +29,7 @@ class pluginOpenGraph extends Plugin {
global $Site;
global $WHERE_AM_I;
global $pages;
global $page;
$og = array(
'locale' =>$Site->locale(),
@ -45,12 +46,12 @@ class pluginOpenGraph extends Plugin {
// The user filter by page
case 'page':
$og['type'] = 'article';
$og['title'] = $Page->title();
$og['description'] = $Page->description();
$og['url'] = $Page->permalink($absolute=true);
$og['image'] = $Page->coverImage($absolute=true);
$og['title'] = $page->title();
$og['description'] = $page->description();
$og['url'] = $page->permalink($absolute=true);
$og['image'] = $page->coverImage($absolute=true);
$content = $Page->content();
$content = $page->content();
break;
// The user is in the homepage

View File

@ -30,16 +30,15 @@ class pluginTags extends Plugin {
$filter = $Url->filters('tag');
$html = '<div class="plugin plugin-tags">';
$html .= '<h2>'.$this->getDbField('label').'</h2>';
$html .= '<h2 class="plugin-label">'.$this->getDbField('label').'</h2>';
$html .= '<div class="plugin-content">';
$html .= '<ul>';
// By default the database of tags are alphanumeric sorted
foreach( $dbTags->db as $key=>$fields ) {
$html .= '<li>';
$html .= '<a href="'.DOMAIN_BASE.$filter.'/'.$key.'">';
$html .= '<a href="'.DOMAIN_TAGS.$key.'">';
$html .= $fields['name'];
$html .= ' ('.count($fields['list']).')';
$html .= '</a>';
$html .= '</li>';
}

View File

@ -2,28 +2,24 @@
/* Plugins
------------------------------------------------------------------------------ */
div.plugin {
}
div.plugin h2.plugin-label {
div.plugin h2.plugin-label {
border-bottom: solid 3px #f56a6a;
display: inline-block;
margin: 0 0 2em 0;
padding: 0 0.75em 0.5em 0;
}
div.plugin ul {
div.plugin ul {
list-style: none;
}
div.plugin ul li {
div.plugin ul li {
border-top: solid 1px rgba(210, 215, 217, 0.75);
margin: 0.5em 0 0 0;
padding: 0.5em 0 0 0;
}
div.plugin a {
div.plugin a {
border-bottom: 0;
color: inherit;
cursor: pointer;
@ -32,6 +28,19 @@ div.plugin a {
padding: 0.625em 0;
}
/* Plugin Tags
------------------------------------------------------------------------------ */
div.plugin-tags ul li {
border: none;
display: inline-block;
}
div.plugin-tags a {
display: inline-block;
margin: 5px;
}
/* Plugin Menu
------------------------------------------------------------------------------ */

View File

@ -451,7 +451,8 @@ function install($adminPassword, $email, $timezone)
array(
'position'=>0,
'homeLink'=>true,
'label'=>$Language->get('Pages')
'label'=>$Language->get('Pages'),
'amountOfItems'=>5
),
JSON_PRETTY_PRINT),
LOCK_EX