Bug fixes
This commit is contained in:
parent
69e1de657e
commit
99bf979597
|
@ -1,7 +1,16 @@
|
||||||
<?php
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||||
|
|
||||||
// DEBUG: Estas funciones llamarlas despues que el usuario se logueo, en la parte de administracion.
|
// ============================================================================
|
||||||
$dbPosts->regenerate();
|
// Functions
|
||||||
$dbPages->regenerate();
|
// ============================================================================
|
||||||
|
|
||||||
?>
|
// ============================================================================
|
||||||
|
// POST Method
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// Main
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
$_newPosts = $dbPosts->regenerate();
|
||||||
|
$_newPages = $dbPages->regenerate();
|
||||||
|
|
|
@ -21,6 +21,15 @@ function setSettings($args)
|
||||||
$args['advancedOptions'] = 'false';
|
$args['advancedOptions'] = 'false';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add slash at the begin and end.
|
||||||
|
// This fields are in the settings->advanced mode
|
||||||
|
if(isset($args['advanced'])) {
|
||||||
|
$args['url'] = Text::addSlashes($args['url'],false,true);
|
||||||
|
$args['uriPost'] = Text::addSlashes($args['uriPost']);
|
||||||
|
$args['uriPage'] = Text::addSlashes($args['uriPage']);
|
||||||
|
$args['uriTag'] = Text::addSlashes($args['uriTag']);
|
||||||
|
}
|
||||||
|
|
||||||
if( $Site->set($args) ) {
|
if( $Site->set($args) ) {
|
||||||
Alert::set('Settings has been saved successfully');
|
Alert::set('Settings has been saved successfully');
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,10 @@ a:hover {
|
||||||
text-decoration: none !important;
|
text-decoration: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------- FONTS AWESOME ----------- */
|
/* ----------- FONTS AWESOME ----------- */
|
||||||
.fa-right {
|
.fa-right {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
|
@ -55,7 +59,7 @@ a:hover {
|
||||||
}
|
}
|
||||||
|
|
||||||
#sidebar li {
|
#sidebar li {
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------- ALERT ----------- */
|
/* ----------- ALERT ----------- */
|
||||||
|
@ -78,6 +82,70 @@ h2.title {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------- TABLE ----------- */
|
||||||
|
table {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
table thead {
|
||||||
|
border-bottom: 2px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------- DASHBOARD ----------- */
|
||||||
|
div.dashboardBox {
|
||||||
|
box-shadow: 0 1px 2px rgba(0,0,0,.26);
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 2px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.dashboardBox div.content {
|
||||||
|
border-top: 1px solid #ddd;
|
||||||
|
padding: 10px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.dashboardBox div.contentBlue {
|
||||||
|
background-color: #64b5f6 !important;
|
||||||
|
color: #e3f2fd !important;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.dashboardBox div.contentGreen {
|
||||||
|
background-color: #81c784 !important;
|
||||||
|
color: #e8f5e9 !important;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.dashboardBox .nav {
|
||||||
|
margin: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
div.dashboardBox i.iconContent {
|
||||||
|
bottom: -1rem;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
font-size: 4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.dashboardBox div.bigContent {
|
||||||
|
font-size: 1.8em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.dashboardBox h2 {
|
||||||
|
color: #666;
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-weight: normal;
|
||||||
|
margin: 0;
|
||||||
|
padding: 10px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------- FORMS ----------- */
|
/* ----------- FORMS ----------- */
|
||||||
|
|
||||||
form h4 {
|
form h4 {
|
||||||
|
@ -99,12 +167,12 @@ p.advOptions {
|
||||||
|
|
||||||
/* ----------- PLUGINS ----------- */
|
/* ----------- PLUGINS ----------- */
|
||||||
div.pluginBox {
|
div.pluginBox {
|
||||||
background: rgba(234, 234, 234, 0.18) none repeat scroll 0 0;
|
box-shadow: 0 1px 2px rgba(0,0,0,.26);
|
||||||
|
background-color: #fff;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
padding: 10px;
|
box-sizing: border-box;
|
||||||
|
padding: 20px;
|
||||||
width: 70%;
|
width: 70%;
|
||||||
box-shadow: 0 2px 5px 0 rgba(183, 183, 183, 0.26);
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
div.pluginBox p {
|
div.pluginBox p {
|
||||||
|
|
|
@ -1,2 +1,55 @@
|
||||||
<h2 class="title">Dashboard</h2>
|
<h2 class="title">Dashboard</h2>
|
||||||
<p>Not implemented...</p>
|
|
||||||
|
<div class="units-row">
|
||||||
|
|
||||||
|
<div class="unit-40">
|
||||||
|
|
||||||
|
<div class="dashboardBox">
|
||||||
|
<div class="content contentBlue">
|
||||||
|
<div class="bigContent"><?php echo $dbPosts->count() ?></div>
|
||||||
|
<div class="littleContent">posts</div>
|
||||||
|
<i class="iconContent fa fa-pie-chart"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dashboardBox">
|
||||||
|
<div class="content contentGreen">
|
||||||
|
<div class="bigContent"><?php echo $dbUsers->count() ?></div>
|
||||||
|
<div class="littleContent">Users</div>
|
||||||
|
<i class="iconContent fa fa-user"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="unit-60">
|
||||||
|
<?php if($_newPosts || $_newPages) { ?>
|
||||||
|
<div class="dashboardBox">
|
||||||
|
<div class="content contentGreen">
|
||||||
|
<div class="bigContent">Database regenerated</div>
|
||||||
|
<div class="littleContent">New posts and pages synchronized.</div>
|
||||||
|
<i class="iconContent fa fa-pie-chart"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
<div class="dashboardBox">
|
||||||
|
<h2>Notifications</h2>
|
||||||
|
<div class="content">
|
||||||
|
<nav class="nav">
|
||||||
|
<ul>
|
||||||
|
<li>New comment</li>
|
||||||
|
<li>Admin session started at 07:00pm</li>
|
||||||
|
<li>Failed login with username diego</li>
|
||||||
|
<li>Database regenerated</li>
|
||||||
|
<li>New session started at 01:00pm</li>
|
||||||
|
<li>New post added</li>
|
||||||
|
<li>New page added</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
Content <span class="forms-desc">HTML and Markdown code supported.</span>
|
Content <span class="forms-desc">HTML and Markdown code supported.</span>
|
||||||
<textarea name="content" rows="10" class="width-70"><?php echo $_Page->contentRaw() ?></textarea>
|
<textarea name="content" rows="10" class="width-70"><?php echo htmlspecialchars($_Page->contentRaw(), ENT_COMPAT|ENT_HTML5, CHARSET) ?></textarea>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<form method="post" action="" class="forms">
|
<form method="post" action="" class="forms">
|
||||||
|
|
||||||
<input type="hidden" id="key" name="key" value="<?php echo $_Post->key() ?>">
|
<input type="hidden" id="key" name="key" value="<?php echo $_Post->key() ?>">
|
||||||
|
<?php var_dump($_Post->title()); ?>
|
||||||
<label>
|
<label>
|
||||||
Title
|
Title
|
||||||
<input id="title" name="title" type="text" class="width-70" value="<?php echo $_Post->title() ?>">
|
<input id="title" name="title" type="text" class="width-70" value="<?php echo $_Post->title() ?>">
|
||||||
|
|
|
@ -16,8 +16,7 @@ class dbJSON
|
||||||
{
|
{
|
||||||
$lines = file($file);
|
$lines = file($file);
|
||||||
|
|
||||||
if($firstLine)
|
if($firstLine) {
|
||||||
{
|
|
||||||
// Remove the first line.
|
// Remove the first line.
|
||||||
unset($lines[0]);
|
unset($lines[0]);
|
||||||
}
|
}
|
||||||
|
@ -32,6 +31,11 @@ class dbJSON
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function count()
|
||||||
|
{
|
||||||
|
return count($this->db);
|
||||||
|
}
|
||||||
|
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
if($this->firstLine)
|
if($this->firstLine)
|
||||||
|
|
|
@ -7,9 +7,10 @@ class fileContent
|
||||||
|
|
||||||
function __construct($pathSlug)
|
function __construct($pathSlug)
|
||||||
{
|
{
|
||||||
if($this->build($pathSlug)===false)
|
if($this->build($pathSlug)===false) {
|
||||||
$this->vars = false;
|
$this->vars = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return true if valid
|
// Return true if valid
|
||||||
public function isValid()
|
public function isValid()
|
||||||
|
@ -42,9 +43,6 @@ class fileContent
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path
|
|
||||||
//$this->setField('path', $this->path);
|
|
||||||
|
|
||||||
// Database Key
|
// Database Key
|
||||||
$this->setField('key', $pathSlug);
|
$this->setField('key', $pathSlug);
|
||||||
|
|
||||||
|
@ -84,7 +82,10 @@ class fileContent
|
||||||
array_unshift($output, $parts[1]);
|
array_unshift($output, $parts[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->vars['content'] = implode($output);
|
$implode = implode($output);
|
||||||
|
|
||||||
|
// Sanitize content.
|
||||||
|
$this->vars['content'] = Sanitize::html($implode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,13 +54,15 @@ define('JSON', function_exists('json_encode'));
|
||||||
// TRUE if new posts hand-made set published, or FALSE for draft.
|
// TRUE if new posts hand-made set published, or FALSE for draft.
|
||||||
define('HANDMADE_PUBLISHED', true);
|
define('HANDMADE_PUBLISHED', true);
|
||||||
|
|
||||||
|
define('CHARSET', 'UTF-8');
|
||||||
|
|
||||||
if(MB_STRING)
|
if(MB_STRING)
|
||||||
{
|
{
|
||||||
// Tell PHP that we're using UTF-8 strings until the end of the script.
|
// Tell PHP that we're using UTF-8 strings until the end of the script.
|
||||||
mb_internal_encoding('UTF-8');
|
mb_internal_encoding(CHARSET);
|
||||||
|
|
||||||
// Tell PHP that we'll be outputting UTF-8 to the browser.
|
// Tell PHP that we'll be outputting UTF-8 to the browser.
|
||||||
mb_http_output('UTF-8');
|
mb_http_output(CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abstract Classes
|
// Abstract Classes
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
class dbLanguage extends dbJSON
|
class dbLanguage extends dbJSON
|
||||||
{
|
{
|
||||||
public $en_EN;
|
public $en_US;
|
||||||
|
|
||||||
function __construct($language)
|
function __construct($language)
|
||||||
{
|
{
|
||||||
parent::__construct(PATH_LANGUAGES.'en_EN.json', false);
|
parent::__construct(PATH_LANGUAGES.'en_US.json', false);
|
||||||
$this->en_EN = $this->db;
|
$this->en_US = $this->db;
|
||||||
|
|
||||||
parent::__construct(PATH_LANGUAGES.$language.'.json', false);
|
parent::__construct(PATH_LANGUAGES.$language.'.json', false);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ class dbLanguage extends dbJSON
|
||||||
return $this->db[$key];
|
return $this->db[$key];
|
||||||
|
|
||||||
// If the key is not translated then return the English translation.
|
// If the key is not translated then return the English translation.
|
||||||
return $this->en_EN[$key];
|
return $this->en_US[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the translation.
|
// Print the translation.
|
||||||
|
|
|
@ -146,7 +146,7 @@ class dbPages extends dbJSON
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the directory. Recursive.
|
// Move the directory from old key to new key.
|
||||||
if($newKey!==$args['key'])
|
if($newKey!==$args['key'])
|
||||||
{
|
{
|
||||||
if( Filesystem::mv(PATH_PAGES.$args['key'], PATH_PAGES.$newKey) === false ) {
|
if( Filesystem::mv(PATH_PAGES.$args['key'], PATH_PAGES.$newKey) === false ) {
|
||||||
|
@ -157,7 +157,7 @@ class dbPages extends dbJSON
|
||||||
|
|
||||||
// Make the index.txt and save the file.
|
// Make the index.txt and save the file.
|
||||||
$data = implode("\n", $dataForFile);
|
$data = implode("\n", $dataForFile);
|
||||||
if( file_put_contents(PATH_PAGES.$newKey.'/index.txt', $data) === false ) {
|
if( file_put_contents(PATH_PAGES.$newKey.DS.'index.txt', $data) === false ) {
|
||||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file index.txt');
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file index.txt');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ class dbPages extends dbJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the index.txt file.
|
// Delete the index.txt file.
|
||||||
if( Filesystem::rmfile(PATH_PAGES.$key.'/index.txt') === false ) {
|
if( Filesystem::rmfile(PATH_PAGES.$key.DS.'index.txt') === false ) {
|
||||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file index.txt');
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file index.txt');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,18 +313,18 @@ class dbPages extends dbJSON
|
||||||
{
|
{
|
||||||
$key = basename($directory);
|
$key = basename($directory);
|
||||||
|
|
||||||
if(file_exists($directory.'/index.txt')){
|
if(file_exists($directory.DS.'index.txt')){
|
||||||
// The key is the directory name
|
// The key is the directory name
|
||||||
$paths[$key] = true;
|
$paths[$key] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recovery pages from subdirectories
|
// Recovery pages from subdirectories
|
||||||
$subPaths = glob($directory.'/*', GLOB_ONLYDIR);
|
$subPaths = glob($directory.DS.'*', GLOB_ONLYDIR);
|
||||||
foreach($subPaths as $subDirectory)
|
foreach($subPaths as $subDirectory)
|
||||||
{
|
{
|
||||||
$subKey = basename($subDirectory);
|
$subKey = basename($subDirectory);
|
||||||
|
|
||||||
if(file_exists($subDirectory.'/index.txt')) {
|
if(file_exists($subDirectory.DS.'index.txt')) {
|
||||||
// The key is composed by the directory/subdirectory
|
// The key is composed by the directory/subdirectory
|
||||||
$paths[$key.'/'.$subKey] = true;
|
$paths[$key.'/'.$subKey] = true;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ class dbPages extends dbJSON
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return $this->db!=$db;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ class dbPosts extends dbJSON
|
||||||
|
|
||||||
// Make the index.txt and save the file.
|
// Make the index.txt and save the file.
|
||||||
$data = implode("\n", $dataForFile);
|
$data = implode("\n", $dataForFile);
|
||||||
if( file_put_contents(PATH_POSTS.$key.'/index.txt', $data) === false ) {
|
if( file_put_contents(PATH_POSTS.$key.DS.'index.txt', $data) === false ) {
|
||||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file index.txt');
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file index.txt');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ class dbPosts extends dbJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the index.txt file.
|
// Delete the index.txt file.
|
||||||
if( Filesystem::rmfile(PATH_POSTS.$key.'/index.txt') === false ) {
|
if( Filesystem::rmfile(PATH_POSTS.$key.DS.'index.txt') === false ) {
|
||||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file index.txt');
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file index.txt');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,8 +195,9 @@ class dbPosts extends dbJSON
|
||||||
// Username
|
// Username
|
||||||
$fields['username'] = 'admin';
|
$fields['username'] = 'admin';
|
||||||
|
|
||||||
if(HANDMADE_PUBLISHED)
|
if(HANDMADE_PUBLISHED) {
|
||||||
$fields['status']='published';
|
$fields['status']='published';
|
||||||
|
}
|
||||||
|
|
||||||
// Recovery pages from the first level of directories
|
// Recovery pages from the first level of directories
|
||||||
$tmpPaths = glob(PATH_POSTS.'*', GLOB_ONLYDIR);
|
$tmpPaths = glob(PATH_POSTS.'*', GLOB_ONLYDIR);
|
||||||
|
@ -204,7 +205,7 @@ class dbPosts extends dbJSON
|
||||||
{
|
{
|
||||||
$key = basename($directory);
|
$key = basename($directory);
|
||||||
|
|
||||||
if(file_exists($directory.'/index.txt')) {
|
if(file_exists($directory.DS.'index.txt')) {
|
||||||
// The key is the directory name
|
// The key is the directory name
|
||||||
$paths[$key] = true;
|
$paths[$key] = true;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +221,13 @@ class dbPosts extends dbJSON
|
||||||
$this->db[$slug] = $fields;
|
$this->db[$slug] = $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->save();
|
// Save the database.
|
||||||
|
if( $this->save() === false ) {
|
||||||
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->db!=$db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPage($pageNumber, $postPerPage, $draftPosts=false)
|
public function getPage($pageNumber, $postPerPage, $draftPosts=false)
|
||||||
|
|
|
@ -9,7 +9,7 @@ class dbSite extends dbJSON
|
||||||
'footer'=> array('inFile'=>false, 'value'=>''),
|
'footer'=> array('inFile'=>false, 'value'=>''),
|
||||||
'postsperpage'=>array('inFile'=>false, 'value'=>''),
|
'postsperpage'=>array('inFile'=>false, 'value'=>''),
|
||||||
'language'=> array('inFile'=>false, 'value'=>'en'),
|
'language'=> array('inFile'=>false, 'value'=>'en'),
|
||||||
'locale'=> array('inFile'=>false, 'value'=>'en_EN'),
|
'locale'=> array('inFile'=>false, 'value'=>'en_US'),
|
||||||
'timezone'=> array('inFile'=>false, 'value'=>'America/Argentina/Buenos_Aires'),
|
'timezone'=> array('inFile'=>false, 'value'=>'America/Argentina/Buenos_Aires'),
|
||||||
'theme'=> array('inFile'=>false, 'value'=>'pure'),
|
'theme'=> array('inFile'=>false, 'value'=>'pure'),
|
||||||
'adminTheme'=> array('inFile'=>false, 'value'=>'kure'),
|
'adminTheme'=> array('inFile'=>false, 'value'=>'kure'),
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Sanitize {
|
||||||
// new
|
// new
|
||||||
public static function html($text)
|
public static function html($text)
|
||||||
{
|
{
|
||||||
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
|
return htmlspecialchars($text, ENT_COMPAT|ENT_HTML5, CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function pathFile($path, $file)
|
public static function pathFile($path, $file)
|
||||||
|
|
|
@ -4,6 +4,23 @@ class Text {
|
||||||
|
|
||||||
// New
|
// New
|
||||||
|
|
||||||
|
public static function addSlashes($text, $begin=true, $end=true)
|
||||||
|
{
|
||||||
|
if($begin) {
|
||||||
|
$text = '/' . ltrim($text, '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($end) {
|
||||||
|
$text = rtrim($text, '/') . '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($text=='//') {
|
||||||
|
return '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
public static function endsWith($string, $endsString)
|
public static function endsWith($string, $endsString)
|
||||||
{
|
{
|
||||||
$endsPosition = (-1)*self::length($endsString);
|
$endsPosition = (-1)*self::length($endsString);
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
||||||
|
|
||||||
class Language extends DB_SERIALIZE
|
|
||||||
{
|
|
||||||
public $en_EN;
|
|
||||||
|
|
||||||
function __construct($language)
|
|
||||||
{
|
|
||||||
parent::__construct(PATH_LANGUAGES.'en_EN.json', false);
|
|
||||||
$this->en_EN = $this->vars;
|
|
||||||
|
|
||||||
parent::__construct(PATH_LANGUAGES.$language.'.json', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the translation, if the translation does'n exist then return the English translation.
|
|
||||||
public function get($text)
|
|
||||||
{
|
|
||||||
$key = Text::lowercase($text);
|
|
||||||
$key = Text::replace(' ', '-', $key);
|
|
||||||
|
|
||||||
if(isset($this->vars[$key]))
|
|
||||||
return $this->vars[$key];
|
|
||||||
|
|
||||||
// If the key is not translated then return the English translation.
|
|
||||||
return $this->en_EN[$key];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print the translation.
|
|
||||||
public function p($text)
|
|
||||||
{
|
|
||||||
echo $this->get($text);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
Loading…
Reference in New Issue