Static objects names
This commit is contained in:
parent
22ead489e2
commit
0f6a8a43f8
|
@ -18,14 +18,14 @@ function addUser($args)
|
|||
global $dbUsers;
|
||||
|
||||
// Check if the username already exist in db.
|
||||
if( $dbUsers->userExists($args['username']) || helperText::isEmpty($args['username']) )
|
||||
if( $dbUsers->userExists($args['username']) || Text::isEmpty($args['username']) )
|
||||
{
|
||||
Alert::set('Username already exists or is empty');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate password.
|
||||
if( ($args['password'] != $args['confirm-password'] ) || helperText::isEmpty($args['password']) )
|
||||
if( ($args['password'] != $args['confirm-password'] ) || Text::isEmpty($args['password']) )
|
||||
{
|
||||
Alert::set('The password and confirmation password do not match');
|
||||
return false;
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
$dbPosts->regenerate();
|
||||
$dbPages->regenerate();
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -10,7 +10,7 @@ function editUser($args)
|
|||
|
||||
if(isset($args['password']))
|
||||
{
|
||||
if( ($args['password']===$args['confirm-password']) && !helperText::isEmpty($args['password']) ) {
|
||||
if( ($args['password']===$args['confirm-password']) && !Text::isEmpty($args['password']) ) {
|
||||
return $dbUsers->set($args);
|
||||
}
|
||||
else {
|
||||
|
@ -59,4 +59,4 @@ if($_user===false) {
|
|||
Redirect::page('admin', 'users');
|
||||
}
|
||||
|
||||
$_user['username'] = $layout['parameters'];
|
||||
$_user['username'] = $layout['parameters'];
|
||||
|
|
|
@ -27,4 +27,4 @@ function addPage($args)
|
|||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
addPage($_POST);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,4 +27,4 @@ function addPost($args)
|
|||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
addPost($_POST);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,3 +23,6 @@ h1.title {
|
|||
font-size: 4em;
|
||||
}
|
||||
|
||||
td {
|
||||
text-align: center;
|
||||
}
|
|
@ -90,4 +90,4 @@ $(document).ready(function() {
|
|||
echo "DEBUG: Load time: ".(microtime(true) - $loadTime).'<br>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -25,4 +25,4 @@ function makeNavbar($type)
|
|||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.$link.'">'.$nav['text'].'</a></li>';
|
||||
}
|
||||
echo '</ul></nav>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,4 +50,4 @@
|
|||
echo "DEBUG: Load time: ".(microtime(true) - $loadTime).'<br>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -35,4 +35,4 @@
|
|||
|
||||
<input type="submit" class="btn btn-blue" value="Add" name="add-user">
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>" class="btn">Cancel</a>
|
||||
</form>
|
||||
</form>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<h2 class="title">Dashboard</h2>
|
||||
<p>Not implemented...</p>
|
||||
<p>Not implemented...</p>
|
||||
|
|
|
@ -123,4 +123,4 @@ $(document).ready(function()
|
|||
|
||||
});
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -75,4 +75,4 @@ $(document).ready(function()
|
|||
|
||||
});
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -10,4 +10,4 @@
|
|||
<p>
|
||||
<button class="btn btn-blue width-100">Log in</button>
|
||||
</p>
|
||||
</form>
|
||||
</form>
|
||||
|
|
|
@ -32,4 +32,4 @@
|
|||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
|
|
@ -24,4 +24,4 @@
|
|||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
|
|
@ -107,4 +107,4 @@ $(document).ready(function()
|
|||
|
||||
});
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -72,4 +72,4 @@ $(document).ready(function()
|
|||
|
||||
});
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<h2 class="title"><i class="fa fa-adjust"></i> Themes</h2>
|
||||
<p>Not implemented...</p>
|
||||
<p>Not implemented...</p>
|
||||
|
|
|
@ -29,4 +29,4 @@
|
|||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
|
|
@ -5,6 +5,7 @@ Diego Najar
|
|||
Implementar
|
||||
- Links a Google+, Facebook y Twitter
|
||||
- Plugins
|
||||
- Plugins SEO, description, opengaph, etc..
|
||||
- Comentarios
|
||||
- Notificaciones
|
||||
- Dashboard, parecido a Nibbleblog, me gusta.
|
||||
|
@ -37,6 +38,7 @@ helperUrl::
|
|||
find . -type f -name "*.php" -print0 | xargs -0 sed -i 's/Text/helperText/g'
|
||||
find . -type f -name "*.php" -print0 | xargs -0 sed -i 's/Url/helperUrl/g'
|
||||
|
||||
find . -type f -name '*.php' -exec sed -i '' s/helperText/Text/ {} +
|
||||
————
|
||||
|
||||
Editar una pagina
|
||||
|
|
12
install.php
12
install.php
|
@ -47,35 +47,35 @@ function checkSystem()
|
|||
|
||||
if(!file_exists(PATH_ROOT.'.htaccess'))
|
||||
{
|
||||
$errorText = 'Missing file, upload the file .htaccess';
|
||||
$errorText = 'Missing file, upload the file .htaccess (ERR_201)';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
}
|
||||
|
||||
if(!version_compare(phpversion(), '5.2', '>'))
|
||||
{
|
||||
$errorText = 'Current PHP version '.phpversion().', but you need > 5.3';
|
||||
$errorText = 'Current PHP version '.phpversion().', you need > 5.3. (ERR_202)';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
}
|
||||
|
||||
if(!in_array('dom', $phpModules))
|
||||
{
|
||||
$errorText = 'PHP module DOM does not exist';
|
||||
$errorText = 'PHP module DOM does not exist. (ERR_203)';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
}
|
||||
|
||||
if(!in_array('json', $phpModules))
|
||||
{
|
||||
$errorText = 'PHP module JSON does not exist';
|
||||
$errorText = 'PHP module JSON does not exist. (ERR_204)';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
}
|
||||
|
||||
if(!is_writable(PATH_CONTENT))
|
||||
{
|
||||
$errorText = 'Writing test on content directory failed';
|
||||
$errorText = 'Writing test failure, check directory content permissions. (ERR_205)';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
}
|
||||
|
@ -319,4 +319,4 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -76,7 +76,7 @@ class Content
|
|||
$parts = array_map('trim', explode(':', $line, 2));
|
||||
|
||||
// Lowercase variable
|
||||
$parts[0] = helperText::lowercase($parts[0]);
|
||||
$parts[0] = Text::lowercase($parts[0]);
|
||||
|
||||
if($parts[0]==='content')
|
||||
{
|
||||
|
|
|
@ -77,4 +77,4 @@ class dbJSON
|
|||
var_dump($this->db);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ class fileContent
|
|||
$parts = array_map('trim', explode(':', $line, 2));
|
||||
|
||||
// Lowercase variable
|
||||
$parts[0] = helperText::lowercase($parts[0]);
|
||||
$parts[0] = Text::lowercase($parts[0]);
|
||||
|
||||
// If variables is content then break the foreach and process the content after.
|
||||
if($parts[0]==='content')
|
||||
|
@ -89,4 +89,4 @@ class fileContent
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,4 +120,4 @@ class Plugin {
|
|||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,4 +23,4 @@ elseif( $_POST['type']==='post' ) {
|
|||
|
||||
echo json_encode( array('slug'=>$slug) );
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -60,4 +60,4 @@ else
|
|||
// Load view and theme
|
||||
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().'/'.$layout['template']) )
|
||||
include(PATH_ADMIN_THEMES.$Site->adminTheme().'/'.$layout['template']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ function build_plugins()
|
|||
global $plugins;
|
||||
|
||||
// List plugins directories
|
||||
$list = helperFilesystem::listDirectories(PATH_PLUGINS);
|
||||
$list = Filesystem::listDirectories(PATH_PLUGINS);
|
||||
|
||||
// Get declared clasess before load plugins clasess
|
||||
$currentDeclaredClasess = get_declared_classes();
|
||||
|
|
|
@ -6,4 +6,4 @@ if($Url->notFound())
|
|||
header('HTTP/1.0 404 Not Found');
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -18,4 +18,4 @@ if( Sanitize::pathFile(PATH_THEMES, $Site->theme().'/init.php') )
|
|||
|
||||
// Theme HTML
|
||||
if( Sanitize::pathFile(PATH_THEMES, $Site->theme().'/index.php') )
|
||||
include(PATH_THEMES.$Site->theme().'/index.php');
|
||||
include(PATH_THEMES.$Site->theme().'/index.php');
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
class dbPages extends DB_SERIALIZE
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct(PATH_DATABASES.'pages.php');
|
||||
}
|
||||
|
||||
// Return an array with the database for a page
|
||||
public function getDb($slug)
|
||||
{
|
||||
return $this->vars['pages'][$slug];
|
||||
}
|
||||
|
||||
// Return TRUE if the page exists, FALSE otherwise.
|
||||
public function validPage($slug)
|
||||
{
|
||||
return isset($this->vars['pages'][$slug]);
|
||||
}
|
||||
|
||||
// Return an array with all page's databases.
|
||||
public function getAll()
|
||||
{
|
||||
return $this->vars['pages'];
|
||||
}
|
||||
|
||||
public function regenerate()
|
||||
{
|
||||
$db = $this->vars['pages'];
|
||||
$paths = array();
|
||||
|
||||
$fields = array(
|
||||
'title'=>'',
|
||||
'content'=>'',
|
||||
'username'=>'',
|
||||
'status'=>'draft',
|
||||
'author'=>'',
|
||||
'unixstamp'=>Date::unixstamp(),
|
||||
'date'=>'',
|
||||
'timeago'=>'',
|
||||
'slug'=>'',
|
||||
'permalink'=>'',
|
||||
'parent'=>''
|
||||
);
|
||||
|
||||
if(HANDMADE_PUBLISHED)
|
||||
$fields['status']='published';
|
||||
|
||||
// Recovery pages from the first level of directories
|
||||
$tmpPaths = glob(PATH_PAGES.'*', GLOB_ONLYDIR);
|
||||
foreach($tmpPaths as $directory)
|
||||
{
|
||||
$key = basename($directory);
|
||||
|
||||
if(file_exists($directory.'/index.txt'))
|
||||
// The key is the directory name
|
||||
$paths[$key] = true;
|
||||
|
||||
// Recovery pages from subdirectories
|
||||
$subPaths = glob($directory.'/*', GLOB_ONLYDIR);
|
||||
foreach($subPaths as $subDirectory)
|
||||
{
|
||||
$subKey = basename($subDirectory);
|
||||
|
||||
if(file_exists($subDirectory.'/index.txt'))
|
||||
// The key is composed by the directory/subdirectory
|
||||
$paths[$key.'/'.$subKey] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove old posts from db
|
||||
foreach( array_diff_key($db, $paths) as $slug=>$data )
|
||||
unset($this->vars['pages'][$slug]);
|
||||
|
||||
// Insert new posts to db
|
||||
foreach( array_diff_key($paths, $db) as $slug=>$data )
|
||||
{
|
||||
$this->vars['pages'][$slug] = $fields;
|
||||
|
||||
// Get the parent if exists
|
||||
$explode = explode('/', $slug);
|
||||
if(!empty($explode[1]))
|
||||
$this->vars['pages'][$slug]['parent'] = $explode[0];
|
||||
}
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,121 +0,0 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
class dbPosts extends DB_SERIALIZE
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct(PATH_DATABASES.'posts.php');
|
||||
}
|
||||
|
||||
// Return an array with the database for a post.
|
||||
public function getDb($slug)
|
||||
{
|
||||
return $this->vars['posts'][$slug];
|
||||
}
|
||||
|
||||
// Return TRUE if the post exists, FALSE otherwise.
|
||||
public function validPost($slug)
|
||||
{
|
||||
return isset($this->vars['posts'][$slug]);
|
||||
}
|
||||
|
||||
public function regenerate()
|
||||
{
|
||||
$db = $this->vars['posts'];
|
||||
$paths = array();
|
||||
|
||||
$fields = array(
|
||||
'title'=>'',
|
||||
'content'=>'',
|
||||
'username'=>'',
|
||||
'status'=>'draft',
|
||||
'author'=>'',
|
||||
'unixstamp'=>Date::unixstamp(),
|
||||
'date'=>'',
|
||||
'timeago'=>'',
|
||||
'slug'=>'',
|
||||
'permalink'=>''
|
||||
);
|
||||
|
||||
if(HANDMADE_PUBLISHED)
|
||||
$fields['status']='published';
|
||||
|
||||
// Scan all directories from /content/post/
|
||||
$tmpPaths = glob(PATH_POSTS.'*', GLOB_ONLYDIR);
|
||||
foreach($tmpPaths as $directory)
|
||||
{
|
||||
// Each directory is a post
|
||||
if(file_exists($directory.'/index.txt')) {
|
||||
$key = basename($directory);
|
||||
$paths[$key] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove old posts from db
|
||||
foreach( array_diff_key($db, $paths) as $slug=>$data )
|
||||
unset($this->vars['posts'][$slug]);
|
||||
|
||||
// Insert new posts to db
|
||||
foreach( array_diff_key($paths, $db) as $slug=>$data )
|
||||
$this->vars['posts'][$slug] = $fields;
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function getPage($pageNumber, $postPerPage)
|
||||
{
|
||||
$init = (int) $postPerPage * $pageNumber;
|
||||
$end = (int) min( ($init + $postPerPage - 1), count($this->vars['posts']) - 1 );
|
||||
|
||||
$outrange = $init<0 ? true : $init > $end;
|
||||
|
||||
// DEBUG: Ver una mejor manera de eliminar draft post antes de ordenarlos
|
||||
$this->removeUnpublished();
|
||||
|
||||
$tmp = $this->sortByDate();
|
||||
|
||||
if(!$outrange)
|
||||
return array_slice($tmp, $init, $end+1, true);
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
// DEBUG: Ver una mejor manera de eliminar draft post antes de ordenarlos
|
||||
private function removeUnpublished()
|
||||
{
|
||||
$tmp = array();
|
||||
|
||||
foreach($this->vars['posts'] as $key=>$value)
|
||||
{
|
||||
if($value['status']==='published')
|
||||
$tmp[$key]=$value;
|
||||
}
|
||||
|
||||
$this->vars['posts'] = $tmp;
|
||||
}
|
||||
|
||||
private function sortByDate($low_to_high=false)
|
||||
{
|
||||
// high to low
|
||||
function high_to_low($a, $b) {
|
||||
return $a['unixstamp']<$b['unixstamp'];
|
||||
}
|
||||
|
||||
// low to high
|
||||
function low_to_high($a, $b) {
|
||||
return $a['unixstamp']>$b['unixstamp'];
|
||||
}
|
||||
|
||||
$tmp = $this->vars['posts'];
|
||||
|
||||
if($low_to_high)
|
||||
uasort($tmp, 'low_to_high');
|
||||
else
|
||||
uasort($tmp, 'high_to_low');
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,26 +0,0 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
class dbUsers extends DB_SERIALIZE
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct(PATH_DATABASES.'users.php');
|
||||
}
|
||||
|
||||
// Return an array with the username databases
|
||||
function get($username)
|
||||
{
|
||||
if($this->validUsername($username)) {
|
||||
return $this->vars['users'][$username];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return TRUE if the post exists, FALSE otherwise.
|
||||
public function validUsername($username)
|
||||
{
|
||||
return isset($this->vars['users'][$username]);
|
||||
}
|
||||
|
||||
}
|
|
@ -15,8 +15,8 @@ class dbLanguage extends dbJSON
|
|||
// Return the translation, if the translation does'n exist then return the English translation.
|
||||
public function get($text)
|
||||
{
|
||||
$key = helperText::lowercase($text);
|
||||
$key = helperText::replace(' ', '-', $key);
|
||||
$key = Text::lowercase($text);
|
||||
$key = Text::replace(' ', '-', $key);
|
||||
|
||||
if(isset($this->db[$key]))
|
||||
return $this->db[$key];
|
||||
|
@ -31,4 +31,4 @@ class dbLanguage extends dbJSON
|
|||
echo $this->get($text);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class dbPages extends dbJSON
|
|||
|
||||
// The user is always the one loggued.
|
||||
$args['username'] = Session::get('username');
|
||||
if( helperText::isEmpty($args['username']) ) {
|
||||
if( Text::isEmpty($args['username']) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class dbPages extends dbJSON
|
|||
|
||||
// Check where the field will be written, in file or database.
|
||||
if($options['inFile']) {
|
||||
$dataForFile[$field] = $field.':'.$tmpValue;
|
||||
$dataForFile[$field] = Text::firstCharUp($field).': '.$tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ class dbPages extends dbJSON
|
|||
}
|
||||
|
||||
// Make the directory. Recursive.
|
||||
if( helperFilesystem::mkdir(PATH_PAGES.$key, true) === false ) {
|
||||
if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_PAGES.$key);
|
||||
return false;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class dbPages extends dbJSON
|
|||
|
||||
// The user is always the one loggued.
|
||||
$args['username'] = Session::get('username');
|
||||
if( helperText::isEmpty($args['username']) ) {
|
||||
if( Text::isEmpty($args['username']) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ class dbPages extends dbJSON
|
|||
|
||||
// Check where the field will be written, if in the file or in the database.
|
||||
if($options['inFile']) {
|
||||
$dataForFile[$field] = $field.':'.$tmpValue;
|
||||
$dataForFile[$field] = Text::firstCharUp($field).': '.$tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ class dbPages extends dbJSON
|
|||
// Make the directory. Recursive.
|
||||
if($newKey!==$args['key'])
|
||||
{
|
||||
if( helperFilesystem::mv(PATH_PAGES.$args['key'], PATH_PAGES.$newKey) === false ) {
|
||||
if( Filesystem::mv(PATH_PAGES.$args['key'], PATH_PAGES.$newKey) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to move the directory to '.PATH_PAGES.$newKey);
|
||||
return false;
|
||||
}
|
||||
|
@ -183,12 +183,12 @@ class dbPages extends dbJSON
|
|||
}
|
||||
|
||||
// Delete the index.txt file.
|
||||
if( helperFilesystem::rmfile(PATH_PAGES.$key.'/index.txt') === false ) {
|
||||
if( Filesystem::rmfile(PATH_PAGES.$key.'/index.txt') === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file index.txt');
|
||||
}
|
||||
|
||||
// Delete the directory.
|
||||
if( helperFilesystem::rmdir(PATH_PAGES.$key) === false ) {
|
||||
if( Filesystem::rmdir(PATH_PAGES.$key) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the directory '.PATH_PAGES.$key);
|
||||
}
|
||||
|
||||
|
@ -237,15 +237,15 @@ class dbPages extends dbJSON
|
|||
// Generate a valid Key/Slug.
|
||||
public function generateKey($text, $parent=NO_PARENT_CHAR, $returnSlug=false, $oldKey='')
|
||||
{
|
||||
if(helperText::isEmpty($text)) {
|
||||
if(Text::isEmpty($text)) {
|
||||
$text = 'empty';
|
||||
}
|
||||
|
||||
if( helperText::isEmpty($parent) || ($parent==NO_PARENT_CHAR) ) {
|
||||
$newKey = helperText::cleanUrl($text);
|
||||
if( Text::isEmpty($parent) || ($parent==NO_PARENT_CHAR) ) {
|
||||
$newKey = Text::cleanUrl($text);
|
||||
}
|
||||
else {
|
||||
$newKey = helperText::cleanUrl($parent).'/'.helperText::cleanUrl($text);
|
||||
$newKey = Text::cleanUrl($parent).'/'.Text::cleanUrl($text);
|
||||
}
|
||||
|
||||
if($newKey!==$oldKey)
|
||||
|
@ -253,7 +253,7 @@ class dbPages extends dbJSON
|
|||
// Verify if the key is already been used.
|
||||
if( isset($this->db[$newKey]) )
|
||||
{
|
||||
if( !helperText::endsWithNumeric($newKey) ) {
|
||||
if( !Text::endsWithNumeric($newKey) ) {
|
||||
$newKey = $newKey.'-0';
|
||||
}
|
||||
|
||||
|
@ -350,4 +350,4 @@ class dbPages extends dbJSON
|
|||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ class dbPosts extends dbJSON
|
|||
// Generate a valid Key/Slug.
|
||||
public function generateKey($text, $oldKey='')
|
||||
{
|
||||
if(helperText::isEmpty($text)) {
|
||||
if(Text::isEmpty($text)) {
|
||||
$text = 'empty';
|
||||
}
|
||||
|
||||
$newKey = helperText::cleanUrl($text);
|
||||
$newKey = Text::cleanUrl($text);
|
||||
|
||||
if($newKey===$oldKey) {
|
||||
return $newKey;
|
||||
|
@ -41,7 +41,7 @@ class dbPosts extends dbJSON
|
|||
// Verify if the key is already been used.
|
||||
if( isset($this->db[$newKey]) )
|
||||
{
|
||||
if( !helperText::endsWithNumeric($newKey) ) {
|
||||
if( !Text::endsWithNumeric($newKey) ) {
|
||||
$newKey = $newKey.'-0';
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ class dbPosts extends dbJSON
|
|||
|
||||
// The user is always the one loggued.
|
||||
$args['username'] = Session::get('username');
|
||||
if( helperText::isEmpty($args['username']) ) {
|
||||
if( Text::isEmpty($args['username']) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ class dbPosts extends dbJSON
|
|||
|
||||
// Check where the field will be written, if in the file or in the database.
|
||||
if($options['inFile']) {
|
||||
$dataForFile[$field] = $field.':'.$tmpValue;
|
||||
$dataForFile[$field] = Text::firstCharUp($field).': '.$tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ class dbPosts extends dbJSON
|
|||
}
|
||||
|
||||
// Make the directory.
|
||||
if( helperFilesystem::mkdir(PATH_POSTS.$key) === false ) {
|
||||
if( Filesystem::mkdir(PATH_POSTS.$key) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_POSTS.$key);
|
||||
return false;
|
||||
}
|
||||
|
@ -150,12 +150,12 @@ class dbPosts extends dbJSON
|
|||
}
|
||||
|
||||
// Delete the index.txt file.
|
||||
if( helperFilesystem::rmfile(PATH_POSTS.$key.'/index.txt') === false ) {
|
||||
if( Filesystem::rmfile(PATH_POSTS.$key.'/index.txt') === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file index.txt');
|
||||
}
|
||||
|
||||
// Delete the directory.
|
||||
if( helperFilesystem::rmdir(PATH_POSTS.$key) === false ) {
|
||||
if( Filesystem::rmdir(PATH_POSTS.$key) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the directory '.PATH_POSTS.$key);
|
||||
}
|
||||
|
||||
|
|
|
@ -184,4 +184,4 @@ class dbSite extends dbJSON
|
|||
return date_default_timezone_set($timezone);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ class dbUsers extends dbJSON
|
|||
$dataForDb['registered'] = Date::unixTime();
|
||||
|
||||
// Password
|
||||
$dataForDb['salt'] = helperText::randomText(SALT_LENGTH);
|
||||
$dataForDb['salt'] = Text::randomText(SALT_LENGTH);
|
||||
$dataForDb['password'] = sha1($dataForDb['password'].$dataForDb['salt']);
|
||||
|
||||
// Save the database
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Nibbleblog -
|
||||
* http://www.nibbleblog.com
|
||||
* Author Diego Najar
|
||||
|
||||
* All Nibbleblog code is released under the GNU General Public License.
|
||||
* See COPYRIGHT.txt and LICENSE.txt.
|
||||
*/
|
||||
|
||||
class Category {
|
||||
|
||||
public static function id()
|
||||
{
|
||||
global $category;
|
||||
|
||||
return $category['id'];
|
||||
}
|
||||
|
||||
public static function name()
|
||||
{
|
||||
global $category;
|
||||
|
||||
return $category['name'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,6 +1,6 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
class helperFilesystem {
|
||||
class Filesystem {
|
||||
|
||||
// NEW
|
||||
public static function listDirectories($path, $regex='*')
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Nibbleblog -
|
||||
* http://www.nibbleblog.com
|
||||
* Author Diego Najar
|
||||
|
||||
* All Nibbleblog code is released under the GNU General Public License.
|
||||
* See COPYRIGHT.txt and LICENSE.txt.
|
||||
*/
|
||||
|
||||
class Image {
|
||||
|
||||
/**
|
||||
* Get either a Gravatar URL or complete image tag for a specified email address.
|
||||
*
|
||||
* @param string $email The email address
|
||||
* @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
|
||||
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
|
||||
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
|
||||
* @return String containing either just a URL
|
||||
* @source http://gravatar.com/site/implement/images/php/
|
||||
*/
|
||||
public static function get_gravatar($email, $s = 80, $d = 'mm', $r = 'g')
|
||||
{
|
||||
$url = 'http://www.gravatar.com/avatar/';
|
||||
$url .= md5( strtolower( trim( $email ) ) );
|
||||
$url .= "?s=$s&d=$d&r=$r";
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Nibbleblog -
|
||||
* http://www.nibbleblog.com
|
||||
* Author Diego Najar
|
||||
|
||||
* All Nibbleblog code is released under the GNU General Public License.
|
||||
* See COPYRIGHT.txt and LICENSE.txt.
|
||||
*/
|
||||
|
||||
class Language {
|
||||
|
||||
private $lang = array();
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
$key = strtoupper($key);
|
||||
|
||||
$key = str_replace(' ','_',$key);
|
||||
|
||||
if(isset($this->lang[$key]))
|
||||
return $this->lang[$key];
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function set($array)
|
||||
{
|
||||
// Set an array with all keys from array uppercased
|
||||
$this->lang = array_change_key_case($array, CASE_UPPER);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function add($array)
|
||||
{
|
||||
$this->lang = array_merge($this->lang, $array);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -7,4 +7,4 @@ class Log {
|
|||
error_log($text, $type);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Nibbleblog -
|
||||
* http://www.nibbleblog.com
|
||||
* Author Diego Najar
|
||||
|
||||
* All Nibbleblog code is released under the GNU General Public License.
|
||||
* See COPYRIGHT.txt and LICENSE.txt.
|
||||
*/
|
||||
|
||||
class Number {
|
||||
|
||||
public static function random_number($min, $max)
|
||||
{
|
||||
return( rand($min, $max) );
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Nibbleblog -
|
||||
* http://www.nibbleblog.com
|
||||
* Author Diego Najar
|
||||
|
||||
* All Nibbleblog code is released under the GNU General Public License.
|
||||
* See COPYRIGHT.txt and LICENSE.txt.
|
||||
*/
|
||||
|
||||
class Page {
|
||||
|
||||
public static function title()
|
||||
{
|
||||
global $page;
|
||||
|
||||
return $page['title'];
|
||||
}
|
||||
|
||||
public static function permalink($absolute=false)
|
||||
{
|
||||
global $page;
|
||||
|
||||
return helperUrl::page($page,$absolute);
|
||||
}
|
||||
|
||||
public static function published($format=false)
|
||||
{
|
||||
global $page;
|
||||
global $settings;
|
||||
|
||||
$format = $format===false?$settings['timestamp_format']:$format;
|
||||
|
||||
return Date::format($page['pub_date_unix'], $format);
|
||||
}
|
||||
|
||||
public static function modified($format=false)
|
||||
{
|
||||
global $page;
|
||||
global $settings;
|
||||
|
||||
$format = $format===false?$settings['timestamp_format']:$format;
|
||||
|
||||
return Date::format($page['mod_date_unix'], $format);
|
||||
}
|
||||
|
||||
public static function content()
|
||||
{
|
||||
global $page;
|
||||
|
||||
return $page['content'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,107 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Nibbleblog -
|
||||
* http://www.nibbleblog.com
|
||||
* Author Diego Najar
|
||||
|
||||
* All Nibbleblog code is released under the GNU General Public License.
|
||||
* See COPYRIGHT.txt and LICENSE.txt.
|
||||
*/
|
||||
|
||||
class Pager {
|
||||
|
||||
public static function href_newer()
|
||||
{
|
||||
global $pager;
|
||||
|
||||
return $pager['href_newer'];
|
||||
}
|
||||
|
||||
public static function href_older()
|
||||
{
|
||||
global $pager;
|
||||
|
||||
return $pager['href_older'];
|
||||
}
|
||||
|
||||
public static function num_posts()
|
||||
{
|
||||
global $pager;
|
||||
|
||||
return $pager['num_posts'];
|
||||
}
|
||||
|
||||
public static function num_pages()
|
||||
{
|
||||
global $pager;
|
||||
|
||||
return $pager['num_pages'];
|
||||
}
|
||||
|
||||
public static function current()
|
||||
{
|
||||
global $pager;
|
||||
|
||||
return $pager['current'];
|
||||
}
|
||||
|
||||
public static function next()
|
||||
{
|
||||
global $pager;
|
||||
|
||||
return $pager['next'];
|
||||
}
|
||||
|
||||
public static function prev()
|
||||
{
|
||||
global $pager;
|
||||
|
||||
return $pager['prev'];
|
||||
}
|
||||
|
||||
public static function next_link($text=NULL)
|
||||
{
|
||||
global $pager;
|
||||
global $Language;
|
||||
|
||||
if(!$pager['show_newer'])
|
||||
return false;
|
||||
|
||||
$text = isset($text)?$text:$Language->get('NEWER_POSTS').' →';
|
||||
|
||||
$html = '<a class="next-page" href="'.$pager['href_newer'].'">'.$text.'</a>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function prev_link($text=NULL)
|
||||
{
|
||||
global $pager;
|
||||
global $Language;
|
||||
|
||||
if(!$pager['show_older'])
|
||||
return false;
|
||||
|
||||
$text = isset($text)?$text:'← '.$Language->get('OLDER_POSTS');
|
||||
|
||||
$html = '<a class="prev-page" href="'.$pager['href_older'].'">'.$text.'</a>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function home_link($text=NULL)
|
||||
{
|
||||
global $pager;
|
||||
global $Language;
|
||||
|
||||
$text = isset($text)?$text:$Language->get('HOME');
|
||||
|
||||
$html = '<a class="home-page" href="'.HTML_PATH_ROOT.'">'.$text.'</a>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Nibbleblog -
|
||||
* http://www.nibbleblog.com
|
||||
* Author Diego Najar
|
||||
|
||||
* All Nibbleblog code is released under the GNU General Public License.
|
||||
* See COPYRIGHT.txt and LICENSE.txt.
|
||||
*/
|
||||
|
||||
class Plugin {
|
||||
|
||||
public static function title()
|
||||
{
|
||||
global $page;
|
||||
|
||||
return $page['title'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,243 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Nibbleblog -
|
||||
* http://www.nibbleblog.com
|
||||
* Author Diego Najar
|
||||
|
||||
* All Nibbleblog code is released under the GNU General Public License.
|
||||
* See COPYRIGHT.txt and LICENSE.txt.
|
||||
*/
|
||||
|
||||
class Post {
|
||||
|
||||
public static function title()
|
||||
{
|
||||
global $post;
|
||||
|
||||
return $post['title'];
|
||||
}
|
||||
|
||||
public static function description()
|
||||
{
|
||||
global $post;
|
||||
|
||||
return $post['description'];
|
||||
}
|
||||
|
||||
public static function comments()
|
||||
{
|
||||
global $post;
|
||||
global $_DB_COMMENTS;
|
||||
|
||||
$comments = $_DB_COMMENTS->get_list_by_post( array('id_post'=>$post['id']) );
|
||||
|
||||
return $comments;
|
||||
}
|
||||
|
||||
public static function num_comments()
|
||||
{
|
||||
global $post;
|
||||
|
||||
return count($post['comments']);
|
||||
}
|
||||
|
||||
public static function category($field=false)
|
||||
{
|
||||
global $post;
|
||||
global $_DB_CATEGORIES;
|
||||
|
||||
$category = $_DB_CATEGORIES->get( array('id'=>$post['id_cat']) );
|
||||
|
||||
if($field=='id')
|
||||
return $category['id'];
|
||||
|
||||
if($field=='slug')
|
||||
return $category['slug'];
|
||||
|
||||
if($field=='permalink')
|
||||
return helperUrl::category($category['slug']);
|
||||
|
||||
return $category['name'];
|
||||
}
|
||||
|
||||
public static function read_more()
|
||||
{
|
||||
global $post;
|
||||
|
||||
return $post['read_more'];
|
||||
}
|
||||
|
||||
public static function allow_comments()
|
||||
{
|
||||
global $post;
|
||||
|
||||
return $post['allow_comments'];
|
||||
}
|
||||
|
||||
public static function permalink($absolute=false)
|
||||
{
|
||||
global $post;
|
||||
|
||||
return helperUrl::post($post,$absolute);
|
||||
}
|
||||
|
||||
public static function tags($return2array=false)
|
||||
{
|
||||
global $post;
|
||||
global $_DB_TAGS;
|
||||
|
||||
$tags = $_DB_TAGS->get_by_idpost( array('id_post'=>$post['id']) );
|
||||
|
||||
if($return2array)
|
||||
return $tags;
|
||||
|
||||
$html = '<ul>';
|
||||
foreach($tags as $tag)
|
||||
$html .= '<li><a class="tag" href="'.helperUrl::tag($tag['name']).'">'.$tag['name_human'].'</a></li>';
|
||||
$html .= '</ul>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function comment_count_link()
|
||||
{
|
||||
global $post;
|
||||
global $theme;
|
||||
global $Language;
|
||||
global $Comment;
|
||||
|
||||
if(!$post['allow_comments'])
|
||||
return false;
|
||||
|
||||
if( $Comment->disqus_enabled() )
|
||||
{
|
||||
$url = helperUrl::post($post, true);
|
||||
return '<a href="'.$url.'#disqus_thread">'.$Language->get('COMMENTS').'</a>';
|
||||
}
|
||||
elseif( $Comment->facebook_enabled() )
|
||||
{
|
||||
$url = helperUrl::post($post, true);
|
||||
return '<a href="'.$post['permalink'].'#comment_form">'.$Language->get('COMMENTS').' (<fb:comments-count href="'.$url.'"></fb:comments-count>)</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
return '<a href="'.$post['permalink'].'#comment_form">'.$Language->get('COMMENTS').' ('.count($post['comments']).')</a>';
|
||||
}
|
||||
}
|
||||
|
||||
// DEPRECATED
|
||||
// Last version available 4.0.3
|
||||
public static function tweet_link()
|
||||
{
|
||||
global $post;
|
||||
|
||||
$url = helperUrl::post($post, true);
|
||||
return 'https://twitter.com/share?url='.urlencode($url);
|
||||
}
|
||||
|
||||
public static function twitter($text=false)
|
||||
{
|
||||
global $post;
|
||||
|
||||
$text = $text===false?'':$text;
|
||||
|
||||
$url = helperUrl::post($post, true);
|
||||
return 'http://twitter.com/home?status='.urlencode($text.' '.$url);
|
||||
}
|
||||
|
||||
public static function facebook($text=false)
|
||||
{
|
||||
global $post;
|
||||
|
||||
$text = $text===false?'':$text;
|
||||
|
||||
$url = helperUrl::post($post, true);
|
||||
return 'https://www.facebook.com/sharer/sharer.php?u='.urlencode($text.' '.$url);
|
||||
}
|
||||
|
||||
public static function linkedin($title=false, $text=false)
|
||||
{
|
||||
global $post;
|
||||
|
||||
$title = $title===false?'':$title;
|
||||
$text = $text===false?'':$text;
|
||||
|
||||
$url = helperUrl::post($post, true);
|
||||
return 'http://www.linkedin.com/shareArticle?mini=true&url='.urlencode($url).'&title='.urlencode($title).'&summary='.urlencode($text);
|
||||
}
|
||||
|
||||
public static function googleplus($text=false)
|
||||
{
|
||||
global $post;
|
||||
|
||||
$text = $text===false?'':$text;
|
||||
|
||||
$url = helperUrl::post($post, true);
|
||||
return 'https://plus.google.com/share?url='.urlencode($text.' '.$url);
|
||||
}
|
||||
|
||||
public static function mailto($text=false)
|
||||
{
|
||||
global $post;
|
||||
|
||||
$text = $text===false?'':$text;
|
||||
|
||||
$url = helperUrl::post($post, true);
|
||||
return 'mailto:?subject='.rawurlencode(Blog::name().' - '.$text).'&body='.urlencode($url);
|
||||
}
|
||||
|
||||
public static function published($format=false)
|
||||
{
|
||||
global $post;
|
||||
global $settings;
|
||||
|
||||
$format = $format===false?$settings['timestamp_format']:$format;
|
||||
|
||||
return Date::format($post['pub_date_unix'], $format);
|
||||
}
|
||||
|
||||
public static function modified($format=false)
|
||||
{
|
||||
global $post;
|
||||
global $settings;
|
||||
|
||||
$format = $format===false?$settings['timestamp_format']:$format;
|
||||
|
||||
return Date::format($post['mod_date_unix'], $format);
|
||||
}
|
||||
|
||||
public static function content($full=false)
|
||||
{
|
||||
global $post;
|
||||
global $theme;
|
||||
|
||||
if($post['type']=='quote')
|
||||
{
|
||||
$html = '<blockquote>'.$post['quote'].'</blockquote>';
|
||||
}
|
||||
elseif($post['type']=='video')
|
||||
{
|
||||
$video_width = !isset($theme['video_width'])?640:$theme['video_width'];
|
||||
$video_height = !isset($theme['video_height'])?320:$theme['video_height'];
|
||||
|
||||
$video_info = Video::video_get_info($post['video'], $video_width, $video_height);
|
||||
|
||||
$html = '<div class="video-embed">';
|
||||
$html .= $video_info['embed'];
|
||||
$html .= '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if($full)
|
||||
$html = $post['content'][0];
|
||||
else
|
||||
$html = $post['content'][1];
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -23,4 +23,4 @@ class Redirect {
|
|||
self::url(HTML_PATH_ROOT);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,244 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Nibbleblog -
|
||||
* http://www.nibbleblog.com
|
||||
* Author Diego Najar
|
||||
|
||||
* All Nibbleblog code is released under the GNU General Public License.
|
||||
* See COPYRIGHT.txt and LICENSE.txt.
|
||||
*/
|
||||
|
||||
class Resize {
|
||||
|
||||
// *** Class variables
|
||||
private $image;
|
||||
private $width;
|
||||
private $height;
|
||||
private $imageResized;
|
||||
|
||||
public function setImage($fileName, $newWidth, $newHeight, $option="auto")
|
||||
{
|
||||
// *** Open up the file
|
||||
$this->image = $this->openImage($fileName);
|
||||
|
||||
// *** Get width and height
|
||||
$this->width = imagesx($this->image);
|
||||
$this->height = imagesy($this->image);
|
||||
|
||||
$this->resizeImage($newWidth, $newHeight, $option);
|
||||
}
|
||||
|
||||
public function saveImage($savePath, $imageQuality="100", $force_jpg=false)
|
||||
{
|
||||
$extension = strtolower(pathinfo($savePath, PATHINFO_EXTENSION));
|
||||
|
||||
// Remove the extension
|
||||
$filename = substr($savePath, 0,strrpos($savePath,'.'));
|
||||
|
||||
$path_complete = $filename.'.'.$extension;
|
||||
|
||||
if($force_jpg)
|
||||
{
|
||||
imagejpeg($this->imageResized, $filename.'.jpg', $imageQuality);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch($extension)
|
||||
{
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
if (imagetypes() & IMG_JPG) {
|
||||
imagejpeg($this->imageResized, $path_complete, $imageQuality);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'gif':
|
||||
if (imagetypes() & IMG_GIF) {
|
||||
imagegif($this->imageResized, $path_complete);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'png':
|
||||
// *** Scale quality from 0-100 to 0-9
|
||||
$scaleQuality = round(($imageQuality/100) * 9);
|
||||
|
||||
// *** Invert quality setting as 0 is best, not 9
|
||||
$invertScaleQuality = 9 - $scaleQuality;
|
||||
|
||||
if (imagetypes() & IMG_PNG) {
|
||||
imagepng($this->imageResized, $path_complete, $invertScaleQuality);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// *** No extension - No save.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
imagedestroy($this->imageResized);
|
||||
}
|
||||
|
||||
private function openImage($file)
|
||||
{
|
||||
// *** Get extension
|
||||
$extension = strtolower(strrchr($file, '.'));
|
||||
|
||||
switch($extension)
|
||||
{
|
||||
case '.jpg':
|
||||
case '.jpeg':
|
||||
$img = imagecreatefromjpeg($file);
|
||||
break;
|
||||
case '.gif':
|
||||
$img = imagecreatefromgif($file);
|
||||
break;
|
||||
case '.png':
|
||||
$img = imagecreatefrompng($file);
|
||||
break;
|
||||
default:
|
||||
$img = false;
|
||||
break;
|
||||
}
|
||||
return $img;
|
||||
}
|
||||
|
||||
private function resizeImage($newWidth, $newHeight, $option)
|
||||
{
|
||||
// *** Get optimal width and height - based on $option
|
||||
$optionArray = $this->getDimensions($newWidth, $newHeight, $option);
|
||||
|
||||
$optimalWidth = $optionArray['optimalWidth'];
|
||||
$optimalHeight = $optionArray['optimalHeight'];
|
||||
|
||||
|
||||
// *** Resample - create image canvas of x, y size
|
||||
$this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight);
|
||||
imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height);
|
||||
|
||||
|
||||
// *** if option is 'crop', then crop too
|
||||
if ($option == 'crop') {
|
||||
$this->crop($optimalWidth, $optimalHeight, $newWidth, $newHeight);
|
||||
}
|
||||
}
|
||||
|
||||
private function getDimensions($newWidth, $newHeight, $option)
|
||||
{
|
||||
|
||||
if( ($this->width < $newWidth) and ($this->height < $newHeight) )
|
||||
{
|
||||
return array('optimalWidth' => $this->width, 'optimalHeight' => $this->height);
|
||||
}
|
||||
|
||||
switch ($option)
|
||||
{
|
||||
case 'exact':
|
||||
$optimalWidth = $newWidth;
|
||||
$optimalHeight= $newHeight;
|
||||
break;
|
||||
case 'portrait':
|
||||
$optimalWidth = $this->getSizeByFixedHeight($newHeight);
|
||||
$optimalHeight= $newHeight;
|
||||
break;
|
||||
case 'landscape':
|
||||
$optimalWidth = $newWidth;
|
||||
$optimalHeight= $this->getSizeByFixedWidth($newWidth);
|
||||
break;
|
||||
case 'auto':
|
||||
$optionArray = $this->getSizeByAuto($newWidth, $newHeight);
|
||||
$optimalWidth = $optionArray['optimalWidth'];
|
||||
$optimalHeight = $optionArray['optimalHeight'];
|
||||
break;
|
||||
case 'crop':
|
||||
$optionArray = $this->getOptimalCrop($newWidth, $newHeight);
|
||||
$optimalWidth = $optionArray['optimalWidth'];
|
||||
$optimalHeight = $optionArray['optimalHeight'];
|
||||
break;
|
||||
}
|
||||
|
||||
return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
|
||||
}
|
||||
|
||||
private function getSizeByFixedHeight($newHeight)
|
||||
{
|
||||
$ratio = $this->width / $this->height;
|
||||
$newWidth = $newHeight * $ratio;
|
||||
return $newWidth;
|
||||
}
|
||||
|
||||
private function getSizeByFixedWidth($newWidth)
|
||||
{
|
||||
$ratio = $this->height / $this->width;
|
||||
$newHeight = $newWidth * $ratio;
|
||||
return $newHeight;
|
||||
}
|
||||
|
||||
private function getSizeByAuto($newWidth, $newHeight)
|
||||
{
|
||||
if ($this->height < $this->width)
|
||||
// *** Image to be resized is wider (landscape)
|
||||
{
|
||||
$optimalWidth = $newWidth;
|
||||
$optimalHeight= $this->getSizeByFixedWidth($newWidth);
|
||||
}
|
||||
elseif ($this->height > $this->width)
|
||||
// *** Image to be resized is taller (portrait)
|
||||
{
|
||||
$optimalWidth = $this->getSizeByFixedHeight($newHeight);
|
||||
$optimalHeight= $newHeight;
|
||||
}
|
||||
else
|
||||
// *** Image to be resizerd is a square
|
||||
{
|
||||
if ($newHeight < $newWidth) {
|
||||
$optimalWidth = $newWidth;
|
||||
$optimalHeight= $this->getSizeByFixedWidth($newWidth);
|
||||
} else if ($newHeight > $newWidth) {
|
||||
$optimalWidth = $this->getSizeByFixedHeight($newHeight);
|
||||
$optimalHeight= $newHeight;
|
||||
} else {
|
||||
// *** Sqaure being resized to a square
|
||||
$optimalWidth = $newWidth;
|
||||
$optimalHeight= $newHeight;
|
||||
}
|
||||
}
|
||||
|
||||
return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
|
||||
}
|
||||
|
||||
private function getOptimalCrop($newWidth, $newHeight)
|
||||
{
|
||||
|
||||
$heightRatio = $this->height / $newHeight;
|
||||
$widthRatio = $this->width / $newWidth;
|
||||
|
||||
if ($heightRatio < $widthRatio) {
|
||||
$optimalRatio = $heightRatio;
|
||||
} else {
|
||||
$optimalRatio = $widthRatio;
|
||||
}
|
||||
|
||||
$optimalHeight = $this->height / $optimalRatio;
|
||||
$optimalWidth = $this->width / $optimalRatio;
|
||||
|
||||
return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
|
||||
}
|
||||
|
||||
private function crop($optimalWidth, $optimalHeight, $newWidth, $newHeight)
|
||||
{
|
||||
// *** Find center - this will be used for the crop
|
||||
$cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 );
|
||||
$cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 );
|
||||
|
||||
$crop = $this->imageResized;
|
||||
//imagedestroy($this->imageResized);
|
||||
|
||||
// *** Now crop from center to exact requested size
|
||||
$this->imageResized = imagecreatetruecolor($newWidth , $newHeight);
|
||||
imagecopyresampled($this->imageResized, $crop , 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight , $newWidth, $newHeight);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Site
|
||||
{
|
||||
private static $content;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
self::$content = '';
|
||||
}
|
||||
|
||||
public static function content()
|
||||
{
|
||||
return self::$content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Nibbleblog -
|
||||
* http://www.nibbleblog.com
|
||||
* Author Diego Najar
|
||||
|
||||
* All Nibbleblog code is released under the GNU General Public License.
|
||||
* See COPYRIGHT.txt and LICENSE.txt.
|
||||
*/
|
||||
|
||||
class Social {
|
||||
|
||||
public static function twitter_share($args = array())
|
||||
{
|
||||
// HTML Code
|
||||
$code = '<a href="https://twitter.com/share" class="twitter-share-button" data-url="'.$args['url'].'" data-text="'.$args['text'].'">Tweet</a>';
|
||||
$code .= '<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>';
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
public static function facebook_share($args = array())
|
||||
{
|
||||
// HTML Code
|
||||
$code = '<fb:share-button type="button" href="'.$args['url'].'" />';
|
||||
$code .= '<script type="text/javascript" src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"></script>';
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
public static function facebook_like($args = array())
|
||||
{
|
||||
// HTML Code
|
||||
$code = '<iframe src="https://www.facebook.com/plugins/like.php?href='.$args['url'].'&layout=button_count" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:21px;"></iframe>';
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,6 +1,6 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
class helperText {
|
||||
class Text {
|
||||
|
||||
// New
|
||||
|
||||
|
@ -65,13 +65,31 @@ class helperText {
|
|||
}
|
||||
|
||||
// String to lowercase
|
||||
public static function lowercase($string)
|
||||
public static function lowercase($string, $encoding='UTF-8')
|
||||
{
|
||||
if(MB_STRING)
|
||||
return mb_strtolower($string, 'UTF-8');
|
||||
if(MB_STRING) {
|
||||
return mb_strtolower($string, $encoding);
|
||||
}
|
||||
|
||||
return strtolower($string);
|
||||
}
|
||||
|
||||
// Make a string's first character uppercase
|
||||
public static function firstCharUp($string, $encoding='UTF-8')
|
||||
{
|
||||
// Thanks http://stackoverflow.com/questions/2517947/ucfirst-function-for-multibyte-character-encodings
|
||||
if(MB_STRING)
|
||||
{
|
||||
$strlen = mb_strlen($string, $encoding);
|
||||
$firstChar = mb_substr($string, 0, 1, $encoding);
|
||||
$then = mb_substr($string, 1, $strlen - 1, $encoding);
|
||||
|
||||
return mb_strtoupper($firstChar, $encoding).$then;
|
||||
}
|
||||
|
||||
return ucfirst($string);
|
||||
}
|
||||
|
||||
// Find position of first occurrence of substring in a string.
|
||||
public static function strpos($string, $substring)
|
||||
{
|
||||
|
|
|
@ -1,140 +0,0 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
class helperUrl
|
||||
{
|
||||
private static $uri;
|
||||
private static $uri_strlen;
|
||||
private static $whereAmI;
|
||||
private static $slug;
|
||||
private static $filters; // Filters for the URI
|
||||
private static $notFound;
|
||||
|
||||
// Filters may be changed for different languages
|
||||
// Ex (Spanish): Array('post'=>'/publicacion/', 'tag'=>'/etiqueta/', ....)
|
||||
// Ex (English): Array('post'=>'/post/', 'tag'=>'/tag/', ....)
|
||||
public static function init($filters)
|
||||
{
|
||||
// Decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character.
|
||||
self::$uri = urldecode($_SERVER['REQUEST_URI']);
|
||||
|
||||
// URI Lowercase
|
||||
//self::$uri = helperText::lowercase(self::$uri);
|
||||
|
||||
self::$uri_strlen = helperText::length(self::$uri);
|
||||
|
||||
self::$whereAmI = 'home';
|
||||
|
||||
self::$notFound = false;
|
||||
|
||||
self::$slug = false;
|
||||
|
||||
self::$filters = $filters;
|
||||
|
||||
// Check if filtering by post
|
||||
// Primero verifico que no haya ningun slug filtrado, asi no lo piso.
|
||||
if(self::$slug===false)
|
||||
self::is_post($filters['post']);
|
||||
|
||||
// Check if filtering by tag
|
||||
// Primero verifico que no haya ningun slug filtrado, asi no lo piso.
|
||||
if(self::$slug===false)
|
||||
self::is_tag($filters['tag']);
|
||||
|
||||
// Check if filtering by page
|
||||
// Primero verifico que no haya ningun slug filtrado, asi no lo piso.
|
||||
if(self::$slug===false)
|
||||
self::is_page($filters['page']);
|
||||
}
|
||||
|
||||
public static function slug()
|
||||
{
|
||||
return self::$slug;
|
||||
}
|
||||
|
||||
public static function uri()
|
||||
{
|
||||
return self::$uri;
|
||||
}
|
||||
|
||||
// Return the filter used
|
||||
public static function filters($type)
|
||||
{
|
||||
return self::$filters[$type];
|
||||
}
|
||||
|
||||
// Return: home, tag, post
|
||||
public static function whereAmI()
|
||||
{
|
||||
return self::$whereAmI;
|
||||
}
|
||||
|
||||
public static function setWhereAmI($where)
|
||||
{
|
||||
self::$whereAmI = $where;
|
||||
}
|
||||
|
||||
|
||||
public static function notFound()
|
||||
{
|
||||
return self::$notFound;
|
||||
}
|
||||
|
||||
public static function setNotFound($error = true)
|
||||
{
|
||||
self::$whereAmI = 'page';
|
||||
self::$notFound = $error;
|
||||
}
|
||||
|
||||
public static function is_tag($filter)
|
||||
{
|
||||
if(self::filter_slug($filter)===false)
|
||||
return false;
|
||||
|
||||
self::$whereAmI = 'tag';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function is_post($filter)
|
||||
{
|
||||
if(self::filter_slug($filter)===false)
|
||||
return false;
|
||||
|
||||
self::$whereAmI = 'post';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function is_page($filter)
|
||||
{
|
||||
if(self::filter_slug($filter)===false)
|
||||
return false;
|
||||
|
||||
self::$whereAmI = 'page';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return the slug after the $filter
|
||||
// ex: http://domain.com/cms/$filter/slug123 => slug123
|
||||
private static function filter_slug($filter)
|
||||
{
|
||||
$position = helperText::strpos(self::$uri, $filter);
|
||||
|
||||
if($position===false)
|
||||
return false;
|
||||
|
||||
$start = $position + helperText::length($filter);
|
||||
$end = self::$uri_strlen;
|
||||
|
||||
self::$slug = helperText::cut(self::$uri, $start, $end);
|
||||
|
||||
if(empty(self::$slug))
|
||||
return false;
|
||||
|
||||
return self::$slug;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Nibbleblog -
|
||||
* http://www.nibbleblog.com
|
||||
* Author Diego Najar
|
||||
|
||||
* All Nibbleblog code is released under the GNU General Public License.
|
||||
* See COPYRIGHT.txt and LICENSE.txt.
|
||||
*/
|
||||
|
||||
class Video {
|
||||
|
||||
// Get video info on array
|
||||
// If the video does not exist or is invalid, returns false
|
||||
public static function video_get_info($url, $width = 640, $height = 360)
|
||||
{
|
||||
if( helperText::is_substring($url, 'youtube.com') )
|
||||
{
|
||||
return( self::video_get_youtube($url, $width, $height) );
|
||||
}
|
||||
elseif( helperText::is_substring($url, 'vimeo.com') )
|
||||
{
|
||||
return( self::video_get_vimeo($url, $width, $height) );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function video_get_youtube($url, $width = 640, $height = 360)
|
||||
{
|
||||
// Youtube ID
|
||||
preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $url, $matches);
|
||||
$video_id = $matches[1];
|
||||
|
||||
// Check if a valid url
|
||||
if(!Net::check_http_code('http://gdata.youtube.com/feeds/api/videos/'.$video_id,200))
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
// GET INFO
|
||||
$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/'.$video_id);
|
||||
$media = $xml->children('http://search.yahoo.com/mrss/');
|
||||
|
||||
$info = array();
|
||||
$info['id'] = $video_id;
|
||||
$info['title'] = (string)$media->group->title;
|
||||
$info['description'] = (string)$media->group->description;
|
||||
|
||||
$info['thumb'][0] = (string)$media->group->thumbnail[0]->attributes()->url;
|
||||
$info['thumb'][1] = (string)$media->group->thumbnail[1]->attributes()->url;
|
||||
$info['thumb'][2] = (string)$media->group->thumbnail[2]->attributes()->url;
|
||||
$info['thumb'][3] = (string)$media->group->thumbnail[3]->attributes()->url;
|
||||
|
||||
$info['embed'] = '<iframe class="youtube_embed" width="'.$width.'" height="'.$height.'" src="http://www.youtube.com/embed/'.$video_id.'?rel=0" frameborder="0" allowfullscreen></iframe>';
|
||||
|
||||
return($info);
|
||||
}
|
||||
|
||||
private static function video_get_vimeo($url, $width = 640, $height = 360)
|
||||
{
|
||||
preg_match('/vimeo\.com\/([0-9]{1,10})/', $url, $matches);
|
||||
$video_id = $matches[1];
|
||||
|
||||
// Check if a valid url
|
||||
if(!Net::check_http_code('http://vimeo.com/api/v2/video/'.$video_id.'.php',200))
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
$hash = unserialize(file_get_contents('http://vimeo.com/api/v2/video/'.$video_id.'.php'));
|
||||
|
||||
$info = array();
|
||||
$info['id'] = $video_id;
|
||||
$info['title'] = $hash[0]['title'];
|
||||
$info['description'] = $hash[0]['description'];
|
||||
|
||||
$info['thumb'][0] = $hash[0]['thumbnail_medium'];
|
||||
$info['thumb'][1] = $hash[0]['thumbnail_small'];
|
||||
|
||||
$info['embed'] = '<iframe class="vimeo_embed" width="'.$width.'" height="'.$height.'" src="http://player.vimeo.com/video/'.$video_id.'" frameborder="0" allowFullScreen></iframe>';
|
||||
|
||||
return($info);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -71,4 +71,4 @@ function checkSlug(type, text, parentPage, key, writeResponse)
|
|||
}
|
||||
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -15,8 +15,8 @@ class Language extends DB_SERIALIZE
|
|||
// Return the translation, if the translation does'n exist then return the English translation.
|
||||
public function get($text)
|
||||
{
|
||||
$key = helperText::lowercase($text);
|
||||
$key = helperText::replace(' ', '-', $key);
|
||||
$key = Text::lowercase($text);
|
||||
$key = Text::replace(' ', '-', $key);
|
||||
|
||||
if(isset($this->vars[$key]))
|
||||
return $this->vars[$key];
|
||||
|
|
|
@ -22,7 +22,7 @@ class Url
|
|||
|
||||
$this->parameters = $_GET;
|
||||
|
||||
$this->uriStrlen = helperText::length($this->uri);
|
||||
$this->uriStrlen = Text::length($this->uri);
|
||||
|
||||
$this->whereAmI = 'home';
|
||||
|
||||
|
@ -147,15 +147,15 @@ class Url
|
|||
}
|
||||
|
||||
// Check if the filter is in the uri.
|
||||
$position = helperText::strpos($this->uri, $filter);
|
||||
$position = Text::strpos($this->uri, $filter);
|
||||
if($position===false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$start = $position + helperText::length($filter);
|
||||
$start = $position + Text::length($filter);
|
||||
$end = $this->uriStrlen;
|
||||
|
||||
$slug = helperText::cut($this->uri, $start, $end);
|
||||
$slug = Text::cut($this->uri, $start, $end);
|
||||
$this->slug = trim($slug, '/');
|
||||
|
||||
return $slug;
|
||||
|
|
|
@ -49,6 +49,15 @@ th, td {
|
|||
padding: 0.5em 1em;
|
||||
}
|
||||
|
||||
pre, code {
|
||||
white-space: pre-wrap !important;
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 13px !important;
|
||||
padding: 5px !important;
|
||||
}
|
||||
|
||||
#layout {
|
||||
padding: 0;
|
||||
}
|
||||
|
@ -78,13 +87,13 @@ th, td {
|
|||
|
||||
.sidebar h2 {
|
||||
font-weight: lighter;
|
||||
margin: -15px 0 20px;
|
||||
margin: -15px 0 5px;
|
||||
padding: 0;
|
||||
font-size: 2.2em;
|
||||
}
|
||||
|
||||
.sidebar div.links {
|
||||
margin: 20px 0;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.sidebar p.about {
|
||||
|
|
|
@ -51,4 +51,4 @@ echo "DEBUG: Load time: ".(microtime(true) - $loadTime).'<br>';
|
|||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<div class="pure-menu pure-menu-horizontal">
|
||||
<p><?php echo $Site->footer(); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -19,4 +19,4 @@
|
|||
</div>
|
||||
</section>
|
||||
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
@ -8,4 +8,4 @@
|
|||
<div class="page-content">
|
||||
<?php echo $Page->content() ?>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
|
|
@ -15,4 +15,4 @@
|
|||
<div class="post-description">
|
||||
<?php echo $Post->content() ?>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
<h1><?php echo $Site->title() ?></h1>
|
||||
<h2><?php echo $Site->slogan() ?></h2>
|
||||
<p class="about"><?php echo $Site->description() ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Links
|
||||
echo '<div class="links">';
|
||||
echo '<a class="homelink" href="'.HTML_PATH_ROOT.'">Home</a>';
|
||||
echo '<span> | </span>';
|
||||
echo '<span> - </span>';
|
||||
echo '<a class="homelink" href="'.HTML_PATH_ROOT.'">Twitter</a>';
|
||||
echo '</div>';
|
||||
|
||||
|
@ -30,7 +29,7 @@ foreach($parents as $parent)
|
|||
echo '<ul>';
|
||||
foreach($children as $child)
|
||||
{
|
||||
echo '<li><a class="children" href="'.HTML_PATH_ROOT.$child->key().'">'.$child->title().'</a></li>';
|
||||
echo '<li><a class="children" href="'.HTML_PATH_ROOT.$child->key().'">— '.$child->title().'</a></li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
|
@ -38,4 +37,4 @@ foreach($parents as $parent)
|
|||
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue