Improves on the url system

This commit is contained in:
dignajar 2015-11-29 21:45:30 -03:00
parent aaac775983
commit ff54ff230b
14 changed files with 137 additions and 100 deletions

View File

@ -26,9 +26,13 @@
background: #1F5FC4;
}
.uk-form legend {
legend {
width: 70% !important;
margin-top: 40px;
margin-top: 40px !important;
}
legend.first-child {
margin-top: 0px !important;
}
.uk-navbar-nav > li > a {

View File

@ -117,7 +117,9 @@ class HTML {
public static function legend($args)
{
$html = '<legend>'.$args['value'].'</legend>';
$class = empty($args['class']) ? '' : 'class="'.$args['class'].'"';
$html = '<legend '.$class.'>'.$args['value'].'</legend>';
echo $html;
}

View File

@ -19,7 +19,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
'value'=>$_user['username']
));
HTML::legend(array('value'=>$L->g('Profile')));
HTML::legend(array('value'=>$L->g('Profile'), 'class'=>'first-child'));
HTML::formInputText(array(
'name'=>'usernameDisable',

View File

@ -15,38 +15,38 @@ echo '
<tbody>
';
foreach($plugins['all'] as $Plugin)
{
echo '
<tr>
<td>
<div class="plugin-name">'.$Plugin->name().'</div>
<div class="plugin-links">
';
foreach($plugins['all'] as $Plugin)
{
echo '
<tr>
<td>
<div class="plugin-name">'.$Plugin->name().'</div>
<div class="plugin-links">
';
if($Plugin->installed()) {
if(method_exists($Plugin, 'form')) {
echo '<a class="configure" href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$Plugin->className().'">'.$L->g('Configure').'</a>';
echo '<span class="separator"> | </span>';
}
echo '<a class="uninstall" href="'.HTML_PATH_ADMIN_ROOT.'uninstall-plugin/'.$Plugin->className().'">'.$L->g('Uninstall').'</a>';
if($Plugin->installed()) {
if(method_exists($Plugin, 'form')) {
echo '<a class="configure" href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$Plugin->className().'">'.$L->g('Configure').'</a>';
echo '<span class="separator"> | </span>';
}
else {
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-plugin/'.$Plugin->className().'">'.$L->g('Install').'</a>';
}
echo '
</div>
</td>
<td>'.$Plugin->description().'</td>
<td class="uk-text-center">'.$Plugin->version().'</td>
<td class="uk-text-center"><a targe="_blank" href="'.$Plugin->website().'">'.$Plugin->author().'</a></td>
';
echo '</tr>';
echo '<a class="uninstall" href="'.HTML_PATH_ADMIN_ROOT.'uninstall-plugin/'.$Plugin->className().'">'.$L->g('Deactivate').'</a>';
}
else {
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-plugin/'.$Plugin->className().'">'.$L->g('Activate').'</a>';
}
echo '
</div>
</td>
<td>'.$Plugin->description().'</td>
<td class="uk-text-center">'.$Plugin->version().'</td>
<td class="uk-text-center"><a targe="_blank" href="'.$Plugin->website().'">'.$Plugin->author().'</a></td>
';
echo '</tr>';
}
echo '
</tbody>
</table>
';
';

View File

@ -9,7 +9,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'value'=>$Security->getTokenCSRF()
));
HTML::legend(array('value'=>$L->g('General')));
HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child'));
HTML::formSelect(array(
'name'=>'postsperpage',

View File

@ -10,7 +10,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'value'=>$Security->getTokenCSRF()
));
HTML::legend(array('value'=>$L->g('Site')));
HTML::legend(array('value'=>$L->g('Site information'), 'class'=>'first-child'));
HTML::formInputText(array(
'name'=>'title',

View File

@ -9,6 +9,8 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'value'=>$Security->getTokenCSRF()
));
HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child'));
HTML::formSelect(array(
'name'=>'language',
'label'=>$L->g('Language'),
@ -35,6 +37,8 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'tip'=>$L->g('you-can-use-this-field-to-define-a-set-off')
));
HTML::legend(array('value'=>$L->g('Date and time formats')));
HTML::formInputText(array(
'name'=>'dateFormat',
'label'=>$L->g('Date format'),

View File

@ -15,31 +15,31 @@ echo '
<tbody>
';
foreach($themes as $theme)
{
echo '
<tr>
<td>
<div class="plugin-name">'.$theme['name'].'</div>
<div class="plugin-links">
';
foreach($themes as $theme)
{
echo '
<tr>
<td>
<div class="plugin-name">'.$theme['name'].'</div>
<div class="plugin-links">
';
if($theme['dirname']!=$Site->theme()) {
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'">'.$L->g('Install').'</a>';
}
echo '
</div>
</td>
<td>'.$theme['description'].'</td>
<td class="uk-text-center">'.$theme['version'].'</td>
<td class="uk-text-center"><a targe="_blank" href="'.$theme['website'].'">'.$theme['author'].'</a></td>
';
echo '</tr>';
if($theme['dirname']!=$Site->theme()) {
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'">'.$L->g('Activate').'</a>';
}
echo '
</div>
</td>
<td>'.$theme['description'].'</td>
<td class="uk-text-center">'.$theme['version'].'</td>
<td class="uk-text-center"><a targe="_blank" href="'.$theme['website'].'">'.$theme['author'].'</a></td>
';
echo '</tr>';
}
echo '
</tbody>
</table>
';
';

View File

@ -194,11 +194,10 @@ define('PATH_THEME_JS', PATH_THEME.'js'.DS);
define('PATH_THEME_IMG', PATH_THEME.'img'.DS);
define('PATH_THEME_LANG', PATH_THEME.'languages'.DS);
// Objects with dependency
// --- Objects with dependency ---
$Language = new dbLanguage( $Site->locale() );
$Login = new Login( $dbUsers );
$Url->checkFilters( $Site->uriFilters() );
// Objects shortcuts
// --- Objects shortcuts ---
$L = $Language;

View File

@ -152,6 +152,22 @@ class dbSite extends dbJSON
public function domain()
{
// If the URL field is not set, try detect the domain.
if(Text::isEmpty( $this->url() ))
{
if(!empty($_SERVER['HTTPS'])) {
$protocol = 'https://';
}
else {
$protocol = 'http://';
}
$domain = $_SERVER['HTTP_HOST'];
return $protocol.$domain.HTML_PATH_ROOT;
}
// Parse the domain from the field URL.
$parse = parse_url($this->url());
$domain = $parse['scheme']."://".$parse['host'];

View File

@ -165,11 +165,13 @@ class Text {
return ucfirst($string);
}
// Find position of first occurrence of substring in a string.
public static function strpos($string, $substring)
// Find position of first occurrence of substring in a string otherwise returns FALSE.
public static function stringPosition($string, $substring)
{
if(MB_STRING)
if(MB_STRING) {
return mb_strpos($string, $substring, 0, 'UTF-8');
}
return strpos($string, $substring);
}

View File

@ -32,7 +32,7 @@ class Url
$this->filters = array();
}
// Filters may be changed for different languages
// Filters change for different languages
// Ex (Spanish): Array('post'=>'/publicacion/', 'tag'=>'/etiqueta/', ....)
// Ex (English): Array('post'=>'/post/', 'tag'=>'/tag/', ....)
public function checkFilters($filters)
@ -41,35 +41,33 @@ class Url
$adminFilter['admin'] = $filters['admin'];
unset($filters['admin']);
// Sort by filter length
// Sort filters by length
uasort($filters, array($this, 'sortByLength'));
// Push the admin filter first
$filters = $adminFilter + $filters;
$this->filters = $filters;
foreach($filters as $filterKey=>$filter)
foreach($filters as $filterName=>$filterURI)
{
// getSlugAfterFilter() set the variable $this->slug
$slug = $this->getSlugAfterFilter($filter);
// $slug will be FALSE if the filter is not included in the URI.
$slug = $this->getSlugAfterFilter($filterURI);
// If the filter is included in the URI.
if($slug!==false)
{
// Where Am I is the filter now, because is in the URI.
$this->whereAmI = $filterKey;
$this->slug = $slug;
$this->whereAmI = $filterName;
// If the slug empty
if(empty($slug))
// If the slug is empty
if(Text::isEmpty($slug))
{
if($filter==='/')
if($filterURI==='/')
{
$this->whereAmI = 'home';
break;
}
if($filter===$adminFilter['admin'])
if($filterURI===$adminFilter['admin'])
{
$this->whereAmI = 'admin';
$this->slug = 'dashboard';
@ -140,43 +138,50 @@ class Url
$this->notFound = $error;
}
public function getDomain()
{
if(!empty($_SERVER['HTTPS'])) {
$protocol = 'https://';
}
else {
$protocol = 'http://';
}
$domain = $_SERVER['HTTP_HOST'];
return $protocol.$domain.HTML_PATH_ROOT;
}
// Return the slug after the $filter
// Returns the slug after the $filter, the slug could be an empty string
// If the filter is not included in the uri, returns FALSE
// If the filter is included in the uri and the slug is not empty, returns the slug
// ex: http://domain.com/cms/$filter/slug123 => slug123
// ex: http://domain.com/cms/$filter/name/lastname => name/lastname
// ex: http://domain.com/cms/$filter/ => empty string
// ex: http://domain.com/cms/$filter => empty string
private function getSlugAfterFilter($filter)
{
if($filter=='/') {
$filter = HTML_PATH_ROOT;
}
// Remove both slash from the filter
$filter = trim($filter, '/');
// Add to the filter the root directory
$filter = HTML_PATH_ROOT.$filter;
// Check if the filter is in the uri.
$position = Text::strpos($this->uri, $filter);
$position = Text::stringPosition($this->uri, $filter);
// If the position is FALSE, the filter isn't in the URI.
if($position===false) {
return false;
}
// Start position to cut
$start = $position + Text::length($filter);
// End position to cut
$end = $this->uriStrlen;
// Get the slug from the URI
$slug = Text::cut($this->uri, $start, $end);
$this->slug = trim($slug, '/');
return $slug;
if(Text::isEmpty($slug)) {
return '';
}
if($slug[0]=='/') {
return ltrim($slug, '/');
}
if($filter==HTML_PATH_ROOT) {
return $slug;
}
return false;
}
private function sortByLength($a, $b)
@ -184,4 +189,4 @@ class Url
return strlen($b)-strlen($a);
}
}
}

View File

@ -213,5 +213,10 @@
"the-about-page-is-very-important": "The about page is an important and powerful tool for potential clients and partners. For those who wonder who is behind the website, your About page is the first source of information.",
"change-this-pages-content-on-the-admin-panel": "Change this page's content on the admin panel, manage, pages and click on the about page.",
"about-your-site-or-yourself": "About your site or yourself",
"welcome-to-bludit": "Welcome to Bludit"
"welcome-to-bludit": "Welcome to Bludit",
"site-information": "Site information",
"date-and-time-formats": "Date and time formats",
"activate": "Activate",
"deactivate": "Deactivate"
}

View File

@ -2,7 +2,7 @@
"theme-data":
{
"name": "Pure",
"description": "Simple and clean theme, based on the framework Pure.css.",
"description": "Simple and clean, based on the framework Pure.css.",
"author": "Bludit",
"email": "",
"website": "https://github.com/dignajar/bludit-themes",