From a74378b350cac229c86b0971370e85d775f0f413 Mon Sep 17 00:00:00 2001 From: Fahri YARDIMCI Date: Fri, 8 Jan 2016 22:42:59 +0200 Subject: [PATCH 01/80] Update TR_tr.json --- languages/tr_TR.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/languages/tr_TR.json b/languages/tr_TR.json index 1e0c4e04..09949f7d 100644 --- a/languages/tr_TR.json +++ b/languages/tr_TR.json @@ -220,5 +220,9 @@ "activate": "Aktifleştir", "deactivate": "Deaktive et", - "cover-image": "Kapak resmi" + "cover-image": "Kapak resmi", + "blog": "Blog", + "more-images": "Daha çok resim", + "double-click-on-the-image-to-add-it": "Eklemek istediğiniz resime çift tıklayın.", + "click-here-to-cancel": "İptal etmek için tıklayın." } From 640b58ecdf356245d3351431d537304bd8d0d41d Mon Sep 17 00:00:00 2001 From: dignajar Date: Mon, 11 Jan 2016 19:51:00 -0300 Subject: [PATCH 02/80] RSS Plugin, improves on code --- kernel/abstract/plugin.class.php | 13 +++- kernel/boot/init.php | 10 +++ kernel/boot/rules/71.pages.php | 5 ++ kernel/dbsite.class.php | 9 +-- kernel/page.class.php | 20 ++++-- kernel/post.class.php | 2 +- plugins/rss/information.json | 12 ++++ plugins/rss/languages/en_US.json | 12 ++++ plugins/rss/plugin.php | 102 +++++++++++++++++++++++++++++++ plugins/sitemap/plugin.php | 7 --- 10 files changed, 174 insertions(+), 18 deletions(-) create mode 100644 plugins/rss/information.json create mode 100644 plugins/rss/languages/en_US.json create mode 100644 plugins/rss/plugin.php diff --git a/kernel/abstract/plugin.class.php b/kernel/abstract/plugin.class.php index 49284713..5ca8e245 100644 --- a/kernel/abstract/plugin.class.php +++ b/kernel/abstract/plugin.class.php @@ -68,6 +68,11 @@ class Plugin { return PATH_PLUGINS.$this->directoryName.DS; } + public function phpPathDB() + { + return PATH_PLUGINS_DATABASES.$this->directoryName.DS; + } + // Returns the item from plugin-data. public function getData($key) { @@ -181,7 +186,13 @@ class Plugin { public function uninstall() { - unlink($this->filenameDb); + // Delete all files. + $files = Filesystem::listFiles( $this->phpPathDB() ); + foreach($files as $file) { + unlink($file); + } + + // Delete the directory. rmdir(PATH_PLUGINS_DATABASES.$this->directoryName); } diff --git a/kernel/boot/init.php b/kernel/boot/init.php index 7b1731f4..8a88339b 100644 --- a/kernel/boot/init.php +++ b/kernel/boot/init.php @@ -218,6 +218,16 @@ define('PATH_THEME_JS', PATH_THEME.'js'.DS); define('PATH_THEME_IMG', PATH_THEME.'img'.DS); define('PATH_THEME_LANG', PATH_THEME.'languages'.DS); +// --- Absolute paths with domain --- +define('DOMAIN', $Site->domain()); +define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT); +define('DOMAIN_THEME_CSS', DOMAIN.HTML_PATH_THEME_CSS); +define('DOMAIN_THEME_JS', DOMAIN.HTML_PATH_THEME_JS); +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); + // --- Objects with dependency --- $Language = new dbLanguage( $Site->locale() ); $Login = new Login( $dbUsers ); diff --git a/kernel/boot/rules/71.pages.php b/kernel/boot/rules/71.pages.php index 06d0c2bf..0d0c739f 100644 --- a/kernel/boot/rules/71.pages.php +++ b/kernel/boot/rules/71.pages.php @@ -59,6 +59,11 @@ function buildPage($key) $content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS); // Parse img src relative to absolute. $Page->setField('content', $content, true); + // Pagebrake + $explode = explode(PAGE_BREAK, $content); + $Page->setField('breakContent', $explode[0], true); + $Page->setField('readMore', !empty($explode[1]), true); + // Date format $pageDate = $Page->date(); $Page->setField('dateRaw', $pageDate, true); diff --git a/kernel/dbsite.class.php b/kernel/dbsite.class.php index 25e29a3b..add96d88 100644 --- a/kernel/dbsite.class.php +++ b/kernel/dbsite.class.php @@ -170,16 +170,17 @@ class dbSite extends dbJSON $protocol = 'http://'; } - $domain = $_SERVER['HTTP_HOST']; + $domain = trim($_SERVER['HTTP_HOST'], '/'); - return $protocol.$domain.HTML_PATH_ROOT; + return $protocol.$domain; } // Parse the domain from the field URL. $parse = parse_url($this->url()); - $domain = $parse['scheme']."://".$parse['host']; - return $domain; + $domain = trim($parse['host'], '/'); + + return $parse['scheme'].'://'.$domain; } // Returns TRUE if the cli mode is enabled, otherwise FALSE. diff --git a/kernel/page.class.php b/kernel/page.class.php index fdbf92df..2af00c61 100644 --- a/kernel/page.class.php +++ b/kernel/page.class.php @@ -15,21 +15,31 @@ class Page extends fileContent { return $this->getField('title'); } - - // Returns the content. This content is markdown parser. - // (boolean) $html, TRUE returns the content without satinize, FALSE otherwise. - public function content($html=true) + // Returns the content. + // This content is markdown parser. + // (boolean) $fullContent, TRUE returns all content, if FALSE returns the first part of the content. + // (boolean) $raw, TRUE returns the content without sanitized, FALSE otherwise. + public function content($fullContent=true, $raw=true) { // This content is not sanitized. $content = $this->getField('content'); - if($html) { + if(!$fullContent) { + $content = $this->getField('breakContent'); + } + + if($raw) { return $content; } return Sanitize::html($content); } + public function readMore() + { + return $this->getField('readMore'); + } + // Returns the content. This content is not markdown parser. // (boolean) $raw, TRUE returns the content without sanitized, FALSE otherwise. public function contentRaw($raw=true) diff --git a/kernel/post.class.php b/kernel/post.class.php index c8789bc3..b3fa9a8d 100644 --- a/kernel/post.class.php +++ b/kernel/post.class.php @@ -186,7 +186,7 @@ class Post extends fileContent global $Url; global $Site; - $url = trim($Site->url(),'/'); + $url = trim(DOMAIN_BASE,'/'); $key = $this->key(); $filter = trim($Url->filters('post'), '/'); $htmlPath = trim(HTML_PATH_ROOT,'/'); diff --git a/plugins/rss/information.json b/plugins/rss/information.json new file mode 100644 index 00000000..6f9fde99 --- /dev/null +++ b/plugins/rss/information.json @@ -0,0 +1,12 @@ +{ + "plugin-data": + { + "name": "RSS", + "description": "This plugin generate a file rss.xml.", + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-07" + } +} \ No newline at end of file diff --git a/plugins/rss/languages/en_US.json b/plugins/rss/languages/en_US.json new file mode 100644 index 00000000..6f9fde99 --- /dev/null +++ b/plugins/rss/languages/en_US.json @@ -0,0 +1,12 @@ +{ + "plugin-data": + { + "name": "RSS", + "description": "This plugin generate a file rss.xml.", + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-07" + } +} \ No newline at end of file diff --git a/plugins/rss/plugin.php b/plugins/rss/plugin.php new file mode 100644 index 00000000..1bff0f62 --- /dev/null +++ b/plugins/rss/plugin.php @@ -0,0 +1,102 @@ +'; + $xml .= ''; + $xml .= ''; + $xml .= ''.$Site->title().''; + $xml .= ''.$Site->url().''; + $xml .= ''.$Site->description().''; + + $posts = buildPostsForPage(0, 10, true); + foreach($posts as $Post) + { + $xml .= ''; + $xml .= ''.$Post->title().''; + $xml .= ''.$Post->permalink(true).''; + $xml .= ''.$Post->description().''; + $xml .= ''; + } + + $xml .= ''; + + // New DOM document + $doc = new DOMDocument(); + + // Friendly XML code + $doc->formatOutput = true; + + $doc->loadXML($xml); + + $doc->save(PATH_PLUGINS_DATABASES.$this->directoryName.DS.'rss.xml'); + } + + public function install($position = 0) + { + parent::install($position); + + $this->createXML(); + } + + public function afterPostCreate() + { + $this->createXML(); + } + + public function afterPageCreate() + { + $this->createXML(); + } + + public function afterPostModify() + { + $this->createXML(); + } + + public function afterPageModify() + { + $this->createXML(); + } + + public function afterPostDelete() + { + $this->createXML(); + } + + public function afterPageDelete() + { + $this->createXML(); + } + + public function beforeRulesLoad() + { + global $Url; + + if( $Url->uri() === HTML_PATH_ROOT.'rss.xml' ) + { + // Send XML header + header('Content-type: text/xml'); + + // New DOM document + $doc = new DOMDocument(); + + // Load XML + $doc->load(PATH_PLUGINS_DATABASES.$this->directoryName.DS.'rss.xml'); + + // Print the XML + echo $doc->saveXML(); + + // Stop Bludit running + exit; + } + } + +} \ No newline at end of file diff --git a/plugins/sitemap/plugin.php b/plugins/sitemap/plugin.php index 2f7e180a..48af4b94 100644 --- a/plugins/sitemap/plugin.php +++ b/plugins/sitemap/plugin.php @@ -2,13 +2,6 @@ class pluginSitemap extends Plugin { - public function init() - { - $this->dbFields = array( - 'label'=>'Tags' - ); - } - private function createXML() { global $Site; From 696d49c9bc60e49c0a5669405c91f9764f893c3e Mon Sep 17 00:00:00 2001 From: dignajar Date: Mon, 11 Jan 2016 23:18:20 -0300 Subject: [PATCH 03/80] RSS Plugin, improves on code --- kernel/abstract/content.class.php | 274 ++++++++++++++++++++++++++ kernel/abstract/filecontent.class.php | 90 --------- kernel/boot/init.php | 2 +- kernel/helpers/filesystem.class.php | 50 +---- kernel/page.class.php | 198 ++----------------- kernel/post.class.php | 197 +----------------- 6 files changed, 295 insertions(+), 516 deletions(-) create mode 100644 kernel/abstract/content.class.php delete mode 100644 kernel/abstract/filecontent.class.php diff --git a/kernel/abstract/content.class.php b/kernel/abstract/content.class.php new file mode 100644 index 00000000..710605f5 --- /dev/null +++ b/kernel/abstract/content.class.php @@ -0,0 +1,274 @@ +build($path)===false) { + $this->vars = false; + } + } + + // Return true if valid + public function isValid() + { + return($this->vars!==false); + } + + public function getField($field) + { + if(isset($this->vars[$field])) { + return $this->vars[$field]; + } + + return false; + } + + // $notoverwrite true if you don't want to replace the value if are set previusly + public function setField($field, $value, $overwrite=true) + { + if($overwrite || empty($this->vars[$field])) { + $this->vars[$field] = $value; + } + + return true; + } + + private function build($path) + { + if( !Sanitize::pathFile($path, 'index.txt') ) { + return false; + } + + $tmp = 0; + $lines = file($path.'index.txt'); + foreach($lines as $lineNumber=>$line) + { + $parts = array_map('trim', explode(':', $line, 2)); + + // Lowercase variable + $parts[0] = Text::lowercase($parts[0]); + + // If variables is content then break the foreach and process the content after. + if($parts[0]==='content') + { + $tmp = $lineNumber; + break; + } + + if( !empty($parts[0]) && !empty($parts[1]) ) { + // Sanitize all fields, except Content. + $this->vars[$parts[0]] = Sanitize::html($parts[1]); + } + } + + // Process the content. + if($tmp!==0) + { + // Next line after "Content:" variable + $tmp++; + + // Remove lines after Content + $output = array_slice($lines, $tmp); + + if(!empty($parts[1])) { + array_unshift($output, "\n"); + array_unshift($output, $parts[1]); + } + + $implode = implode($output); + $this->vars['content'] = $implode; + + // Sanitize content. + //$this->vars['content'] = Sanitize::html($implode); + } + + } + + // Returns the post title. + public function title() + { + return $this->getField('title'); + } + + // Returns the content. + // This content is markdown parser. + // (boolean) $fullContent, TRUE returns all content, if FALSE returns the first part of the content. + // (boolean) $raw, TRUE returns the content without sanitized, FALSE otherwise. + public function content($fullContent=true, $raw=true) + { + // This content is not sanitized. + $content = $this->getField('content'); + + if(!$fullContent) { + $content = $this->getField('breakContent'); + } + + if($raw) { + return $content; + } + + return Sanitize::html($content); + } + + public function readMore() + { + return $this->getField('readMore'); + } + + // Returns the content. This content is not markdown parser. + // (boolean) $raw, TRUE returns the content without sanitized, FALSE otherwise. + public function contentRaw($raw=true) + { + // This content is not sanitized. + $content = $this->getField('contentRaw'); + + if($raw) { + return $content; + } + + return Sanitize::html($content); + } + + public function key() + { + return $this->getField('key'); + } + + // Returns TRUE if the post is published, FALSE otherwise. + public function published() + { + return ($this->getField('status')==='published'); + } + + // Returns TRUE if the post is scheduled, FALSE otherwise. + public function scheduled() + { + return ($this->getField('status')==='scheduled'); + } + + // Returns TRUE if the post is draft, FALSE otherwise. + public function draft() + { + return ($this->getField('status')=='draft'); + } + + public function coverImage($absolute=true) + { + $fileName = $this->getField('coverImage'); + + if(empty($fileName)) { + return false; + } + + if($absolute) { + return HTML_PATH_UPLOADS.$fileName; + } + + return $fileName; + } + + public function profilePicture() + { + return HTML_PATH_UPLOADS_PROFILES.$this->username().'.jpg'; + } + + // Returns the user object if $field is false, otherwise returns the field's value. + public function user($field=false) + { + // Get the user object. + $User = $this->getField('user'); + + if($field) { + return $User->getField($field); + } + + return $User; + } + + public function username() + { + return $this->getField('username'); + } + + public function description() + { + return $this->getField('description'); + } + + // Returns the post date according to locale settings and format settings. + public function date() + { + return $this->getField('date'); + } + + // Returns the post date according to locale settings and format as database stored. + public function dateRaw($format=false) + { + $date = $this->getField('dateRaw'); + + if($format) { + return Date::format($date, DB_DATE_FORMAT, $format); + } + + return $date; + } + + public function tags($returnsArray=false) + { + global $Url; + + $tags = $this->getField('tags'); + + if($returnsArray) { + + if($tags==false) { + return array(); + } + + return $tags; + } + else { + if($tags==false) { + return false; + } + + // Return string with tags separeted by comma. + return implode(', ', $tags); + } + } + + public function permalink($absolute=false) + { + global $Url; + global $Site; + + $filterType = $this->getField('filterType'); + + $url = trim(DOMAIN_BASE,'/'); + $key = $this->key(); + $filter = trim($Url->filters($filterType), '/'); + $htmlPath = trim(HTML_PATH_ROOT,'/'); + + if(empty($filter)) { + $tmp = $key; + } + else { + $tmp = $filter.'/'.$key; + } + + if($absolute) { + return $url.'/'.$tmp; + } + + if(empty($htmlPath)) { + return '/'.$tmp; + } + + return '/'.$htmlPath.'/'.$tmp; + } + + +} diff --git a/kernel/abstract/filecontent.class.php b/kernel/abstract/filecontent.class.php deleted file mode 100644 index ffd5b80e..00000000 --- a/kernel/abstract/filecontent.class.php +++ /dev/null @@ -1,90 +0,0 @@ -build($path)===false) { - $this->vars = false; - } - } - - // Return true if valid - public function isValid() - { - return($this->vars!==false); - } - - public function getField($field) - { - if(isset($this->vars[$field])) { - return $this->vars[$field]; - } - - return false; - } - - // $notoverwrite true if you don't want to replace the value if are set previusly - public function setField($field, $value, $overwrite=true) - { - if($overwrite || empty($this->vars[$field])) { - $this->vars[$field] = $value; - } - - return true; - } - - private function build($path) - { - if( !Sanitize::pathFile($path, 'index.txt') ) { - return false; - } - - $tmp = 0; - $lines = file($path.'index.txt'); - foreach($lines as $lineNumber=>$line) - { - $parts = array_map('trim', explode(':', $line, 2)); - - // Lowercase variable - $parts[0] = Text::lowercase($parts[0]); - - // If variables is content then break the foreach and process the content after. - if($parts[0]==='content') - { - $tmp = $lineNumber; - break; - } - - if( !empty($parts[0]) && !empty($parts[1]) ) { - // Sanitize all fields, except Content. - $this->vars[$parts[0]] = Sanitize::html($parts[1]); - } - } - - // Process the content. - if($tmp!==0) - { - // Next line after "Content:" variable - $tmp++; - - // Remove lines after Content - $output = array_slice($lines, $tmp); - - if(!empty($parts[1])) { - array_unshift($output, "\n"); - array_unshift($output, $parts[1]); - } - - $implode = implode($output); - $this->vars['content'] = $implode; - - // Sanitize content. - //$this->vars['content'] = Sanitize::html($implode); - } - - } - -} diff --git a/kernel/boot/init.php b/kernel/boot/init.php index 8a88339b..a69e0f8e 100644 --- a/kernel/boot/init.php +++ b/kernel/boot/init.php @@ -113,7 +113,7 @@ if(MB_STRING) // Inclde Abstract Classes include(PATH_ABSTRACT.'dbjson.class.php'); -include(PATH_ABSTRACT.'filecontent.class.php'); +include(PATH_ABSTRACT.'content.class.php'); include(PATH_ABSTRACT.'plugin.class.php'); // Inclde Classes diff --git a/kernel/helpers/filesystem.class.php b/kernel/helpers/filesystem.class.php index a05fef82..5db132f2 100644 --- a/kernel/helpers/filesystem.class.php +++ b/kernel/helpers/filesystem.class.php @@ -2,8 +2,6 @@ class Filesystem { - // NEW - // Returns an array with the absolutes directories. public static function listDirectories($path, $regex='*') { @@ -52,50 +50,4 @@ class Filesystem { return unlink($filename); } - // OLD - public static function get_images($regex) - { - return self::ls(PATH_UPLOAD, $regex, '*', false, false, false); - } - - // Devuelve un arreglo con el listado de archivos - // $path con una barra al final, ej: /home/ - // $file_expression : *.0.*.*.*.*.*.*.*.* - // $ext : xml - // $flag_dir : si quiero listar directorios - // $sort_asc_numeric : ordeno ascedente numerico - // $sort_desc_numeric : ordeno descendente numerico - public static function ls($path, $file_expression = NULL, $ext, $flag_dir = false, $sort_asc_numeric = false, $sort_desc_numeric = true) - { - if($flag_dir) - { - $files = glob($path . $file_expression, GLOB_ONLYDIR); - } - else - { - $files = glob($path . $file_expression . '.' . $ext); - } - - if( ($files==false) || (empty($files)) ) - { - $files = array(); - } - - foreach($files as $key=>$file) - { - $files[$key] = basename($file); - } - - // Sort - if($sort_asc_numeric) - { - sort($files, SORT_NUMERIC); - } - elseif($sort_desc_numeric) - { - rsort($files, SORT_NUMERIC); - } - - return $files; - } -} +} \ No newline at end of file diff --git a/kernel/page.class.php b/kernel/page.class.php index 2af00c61..7fcceb96 100644 --- a/kernel/page.class.php +++ b/kernel/page.class.php @@ -1,182 +1,37 @@ setField('key', $key); + // Set filterType + $this->setField('filterType', 'page'); + parent::__construct(PATH_PAGES.$key.DS); } - // Returns the post title. - public function title() - { - return $this->getField('title'); - } - // Returns the content. - // This content is markdown parser. - // (boolean) $fullContent, TRUE returns all content, if FALSE returns the first part of the content. - // (boolean) $raw, TRUE returns the content without sanitized, FALSE otherwise. - public function content($fullContent=true, $raw=true) - { - // This content is not sanitized. - $content = $this->getField('content'); - - if(!$fullContent) { - $content = $this->getField('breakContent'); - } - - if($raw) { - return $content; - } - - return Sanitize::html($content); - } - - public function readMore() - { - return $this->getField('readMore'); - } - - // Returns the content. This content is not markdown parser. - // (boolean) $raw, TRUE returns the content without sanitized, FALSE otherwise. - public function contentRaw($raw=true) - { - // This content is not sanitized. - $content = $this->getField('contentRaw'); - - if($raw) { - return $content; - } - - return Sanitize::html($content); - } - - public function description() - { - return $this->getField('description'); - } - - public function tags($returnsArray=false) - { - global $Url; - - $tags = $this->getField('tags'); - - if($returnsArray) { - - if($tags==false) { - return array(); - } - - return $tags; - } - else { - if($tags==false) { - return false; - } - - // Return string with tags separeted by comma. - return implode(', ', $tags); - } - } - + // Returns the page position. public function position() { return $this->getField('position'); } - // Returns the post date according to locale settings and format settings. - public function date() - { - return $this->getField('date'); - } - - // Returns the post date according to locale settings and format as database stored. - public function dateRaw($format=false) - { - $date = $this->getField('dateRaw'); - - if($format) { - return Date::format($date, DB_DATE_FORMAT, $format); - } - - return $date; - } - // Returns the page slug. public function slug() { $explode = explode('/', $this->getField('key')); - if(!empty($explode[1])) + + // Check if the page have a parent. + if(!empty($explode[1])) { return $explode[1]; + } return $explode[0]; } - public function key() - { - return $this->getField('key'); - } - - public function coverImage($absolute=true) - { - $fileName = $this->getField('coverImage'); - - if(empty($fileName)) { - return false; - } - - if($absolute) { - return HTML_PATH_UPLOADS.$fileName; - } - - return $fileName; - } - - // Returns TRUE if the page is published, FALSE otherwise. - public function published() - { - return ($this->getField('status')==='published'); - } - - // Returns TRUE if the post is draft, FALSE otherwise. - public function draft() - { - return ($this->getField('status')=='draft'); - } - - // Returns the page permalink. - public function permalink($absolute=false) - { - global $Url; - global $Site; - - $url = trim($Site->url(),'/'); - $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; - } - - if(empty($htmlPath)) { - return '/'.$tmp; - } - - return '/'.$htmlPath.'/'.$tmp; - } - // Returns the parent key, if the page doesn't have a parent returns FALSE. public function parentKey() { @@ -212,35 +67,4 @@ class Page extends fileContent return $tmp; } - // Returns the user object if $field is false, otherwise returns the field's value. - public function user($field=false) - { - // Get the user object. - $User = $this->getField('user'); - - if($field) { - return $User->getField($field); - } - - return $User; - } - - // DEPRECATED - public function username() - { - return $this->getField('username'); - } - - // DEPRECATED - public function authorFirstName() - { - return $this->getField('authorFirstName'); - } - - // DEPRECATED - public function authorLastName() - { - return $this->getField('authorLastName'); - } - -} +} \ No newline at end of file diff --git a/kernel/post.class.php b/kernel/post.class.php index b3fa9a8d..ddeafdde 100644 --- a/kernel/post.class.php +++ b/kernel/post.class.php @@ -1,69 +1,26 @@ setField('key', $key); + // Set filterType + $this->setField('filterType', 'post'); + parent::__construct(PATH_POSTS.$key.DS); } - // Returns the post title. - public function title() - { - return $this->getField('title'); - } - - // Returns the content. - // This content is markdown parser. - // (boolean) $fullContent, TRUE returns all content, if FALSE returns the first part of the content. - // (boolean) $raw, TRUE returns the content without sanitized, FALSE otherwise. - public function content($fullContent=true, $raw=true) - { - // This content is not sanitized. - $content = $this->getField('content'); - - if(!$fullContent) { - $content = $this->getField('breakContent'); - } - - if($raw) { - return $content; - } - - return Sanitize::html($content); - } - - public function readMore() - { - return $this->getField('readMore'); - } - - // Returns the content. This content is not markdown parser. - // (boolean) $raw, TRUE returns the content without sanitized, FALSE otherwise. - public function contentRaw($raw=true) - { - // This content is not sanitized. - $content = $this->getField('contentRaw'); - - if($raw) { - return $content; - } - - return Sanitize::html($content); - } - public function key() { return $this->getField('key'); } - // Returns TRUE if the post is published, FALSE otherwise. - public function published() + public function slug() { - return ($this->getField('status')==='published'); + return $this->getField('key'); } // Returns TRUE if the post is scheduled, FALSE otherwise. @@ -71,142 +28,4 @@ class Post extends fileContent { return ($this->getField('status')==='scheduled'); } - - // Returns TRUE if the post is draft, FALSE otherwise. - public function draft() - { - return ($this->getField('status')=='draft'); - } - - public function coverImage($absolute=true) - { - $fileName = $this->getField('coverImage'); - - if(empty($fileName)) { - return false; - } - - if($absolute) { - return HTML_PATH_UPLOADS.$fileName; - } - - return $fileName; - } - - public function profilePicture() - { - return HTML_PATH_UPLOADS_PROFILES.$this->username().'.jpg'; - } - - // Returns the user object if $field is false, otherwise returns the field's value. - public function user($field=false) - { - // Get the user object. - $User = $this->getField('user'); - - if($field) { - return $User->getField($field); - } - - return $User; - } - - // DEPRECATED - public function username() - { - return $this->getField('username'); - } - - // DEPRECATED - public function authorFirstName() - { - return $this->getField('authorFirstName'); - } - - // DEPRECATED - public function authorLastName() - { - return $this->getField('authorLastName'); - } - - public function description() - { - return $this->getField('description'); - } - - // Returns the post date according to locale settings and format settings. - public function date() - { - return $this->getField('date'); - } - - // Returns the post date according to locale settings and format as database stored. - public function dateRaw($format=false) - { - $date = $this->getField('dateRaw'); - - if($format) { - return Date::format($date, DB_DATE_FORMAT, $format); - } - - return $date; - } - - public function tags($returnsArray=false) - { - global $Url; - - $tags = $this->getField('tags'); - - if($returnsArray) { - - if($tags==false) { - return array(); - } - - return $tags; - } - else { - if($tags==false) { - return false; - } - - // Return string with tags separeted by comma. - return implode(', ', $tags); - } - } - - public function slug() - { - return $this->getField('key'); - } - - public function permalink($absolute=false) - { - global $Url; - global $Site; - - $url = trim(DOMAIN_BASE,'/'); - $key = $this->key(); - $filter = trim($Url->filters('post'), '/'); - $htmlPath = trim(HTML_PATH_ROOT,'/'); - - if(empty($filter)) { - $tmp = $key; - } - else { - $tmp = $filter.'/'.$key; - } - - if($absolute) { - return $url.'/'.$tmp; - } - - if(empty($htmlPath)) { - return '/'.$tmp; - } - - return '/'.$htmlPath.'/'.$tmp; - } - -} +} \ No newline at end of file From 6772b4179996fc78070d8fd776984f70e8cfe372 Mon Sep 17 00:00:00 2001 From: dignajar Date: Tue, 12 Jan 2016 00:36:48 -0300 Subject: [PATCH 04/80] Hashing posts and pages --- .../default/css/jquery.auto-complete.css | 9 ++++++++ kernel/admin/themes/default/index.php | 2 ++ kernel/admin/themes/default/init.php | 22 +++++++++++++++++++ .../default/js/jquery.auto-complete.min.js | 3 +++ kernel/admin/views/edit-page.php | 5 +++-- kernel/admin/views/edit-post.php | 5 +++-- kernel/admin/views/new-page.php | 5 +++-- kernel/admin/views/new-post.php | 5 +++-- kernel/dbpages.class.php | 9 ++++++++ kernel/dbposts.class.php | 5 +++++ 10 files changed, 62 insertions(+), 8 deletions(-) create mode 100755 kernel/admin/themes/default/css/jquery.auto-complete.css create mode 100755 kernel/admin/themes/default/js/jquery.auto-complete.min.js diff --git a/kernel/admin/themes/default/css/jquery.auto-complete.css b/kernel/admin/themes/default/css/jquery.auto-complete.css new file mode 100755 index 00000000..4261b1d0 --- /dev/null +++ b/kernel/admin/themes/default/css/jquery.auto-complete.css @@ -0,0 +1,9 @@ +.autocomplete-suggestions { + text-align: left; cursor: default; border: 1px solid #ccc; border-top: 0; background: #fff; box-shadow: -1px 1px 3px rgba(0,0,0,.1); + + /* core styles should not be changed */ + position: absolute; display: none; z-index: 9999; max-height: 254px; overflow: hidden; overflow-y: auto; box-sizing: border-box; +} +.autocomplete-suggestion { position: relative; padding: 0 .6em; line-height: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.02em; color: #333; } +.autocomplete-suggestion b { font-weight: normal; color: #1f8dd6; } +.autocomplete-suggestion.selected { background: #f0f0f0; } diff --git a/kernel/admin/themes/default/index.php b/kernel/admin/themes/default/index.php index 94432b29..d90c144e 100644 --- a/kernel/admin/themes/default/index.php +++ b/kernel/admin/themes/default/index.php @@ -20,12 +20,14 @@ + + diff --git a/kernel/admin/themes/default/init.php b/kernel/admin/themes/default/init.php index f131cc83..00e44f33 100644 --- a/kernel/admin/themes/default/init.php +++ b/kernel/admin/themes/default/init.php @@ -52,6 +52,28 @@ class HTML { echo $html; } + public static function formInputAutocomplete($args) + { + self::formInputText($args); + +$script = ''; + + echo $script; + + } + public static function formInputPassword($args) { $args['type'] = 'password'; diff --git a/kernel/admin/themes/default/js/jquery.auto-complete.min.js b/kernel/admin/themes/default/js/jquery.auto-complete.min.js new file mode 100755 index 00000000..6fdb3bc6 --- /dev/null +++ b/kernel/admin/themes/default/js/jquery.auto-complete.min.js @@ -0,0 +1,3 @@ +// jQuery autoComplete v1.0.7 +// https://github.com/Pixabay/jQuery-autoComplete +!function(e){e.fn.autoComplete=function(t){var o=e.extend({},e.fn.autoComplete.defaults,t);return"string"==typeof t?(this.each(function(){var o=e(this);"destroy"==t&&(e(window).off("resize.autocomplete",o.updateSC),o.off("blur.autocomplete focus.autocomplete keydown.autocomplete keyup.autocomplete"),o.data("autocomplete")?o.attr("autocomplete",o.data("autocomplete")):o.removeAttr("autocomplete"),e(o.data("sc")).remove(),o.removeData("sc").removeData("autocomplete"))}),this):this.each(function(){function t(e){var t=s.val();if(s.cache[t]=e,e.length&&t.length>=o.minChars){for(var a="",c=0;c'),s.data("sc",s.sc).data("autocomplete",s.attr("autocomplete")),s.attr("autocomplete","off"),s.cache={},s.last_val="",s.updateSC=function(t,o){if(s.sc.css({top:s.offset().top+s.outerHeight(),left:s.offset().left,width:s.outerWidth()}),!t&&(s.sc.show(),s.sc.maxHeight||(s.sc.maxHeight=parseInt(s.sc.css("max-height"))),s.sc.suggestionHeight||(s.sc.suggestionHeight=e(".autocomplete-suggestion",s.sc).first().outerHeight()),s.sc.suggestionHeight))if(o){var a=s.sc.scrollTop(),c=o.offset().top-s.sc.offset().top;c+s.sc.suggestionHeight-s.sc.maxHeight>0?s.sc.scrollTop(c+s.sc.suggestionHeight+a-s.sc.maxHeight):0>c&&s.sc.scrollTop(c+a)}else s.sc.scrollTop(0)},e(window).on("resize.autocomplete",s.updateSC),s.sc.appendTo("body"),s.sc.on("mouseleave",".autocomplete-suggestion",function(){e(".autocomplete-suggestion.selected").removeClass("selected")}),s.sc.on("mouseenter",".autocomplete-suggestion",function(){e(".autocomplete-suggestion.selected").removeClass("selected"),e(this).addClass("selected")}),s.sc.on("mousedown",".autocomplete-suggestion",function(t){var a=e(this),c=a.data("val");return(c||a.hasClass("autocomplete-suggestion"))&&(s.val(c),o.onSelect(t,c,a),s.sc.hide()),!1}),s.on("blur.autocomplete",function(){try{over_sb=e(".autocomplete-suggestions:hover").length}catch(t){over_sb=0}over_sb?s.is(":focus")||setTimeout(function(){s.focus()},20):(s.last_val=s.val(),s.sc.hide(),setTimeout(function(){s.sc.hide()},350))}),o.minChars||s.on("focus.autocomplete",function(){s.last_val="\n",s.trigger("keyup.autocomplete")}),s.on("keydown.autocomplete",function(t){if((40==t.which||38==t.which)&&s.sc.html()){var a,c=e(".autocomplete-suggestion.selected",s.sc);return c.length?(a=40==t.which?c.next(".autocomplete-suggestion"):c.prev(".autocomplete-suggestion"),a.length?(c.removeClass("selected"),s.val(a.addClass("selected").data("val"))):(c.removeClass("selected"),s.val(s.last_val),a=0)):(a=40==t.which?e(".autocomplete-suggestion",s.sc).first():e(".autocomplete-suggestion",s.sc).last(),s.val(a.addClass("selected").data("val"))),s.updateSC(0,a),!1}if(27==t.which)s.val(s.last_val).sc.hide();else if(13==t.which||9==t.which){var c=e(".autocomplete-suggestion.selected",s.sc);c.length&&s.sc.is(":visible")&&(o.onSelect(t,c.data("val"),c),setTimeout(function(){s.sc.hide()},20))}}),s.on("keyup.autocomplete",function(a){if(!~e.inArray(a.which,[13,27,35,36,37,38,39,40])){var c=s.val();if(c.length>=o.minChars){if(c!=s.last_val){if(s.last_val=c,clearTimeout(s.timer),o.cache){if(c in s.cache)return void t(s.cache[c]);for(var l=1;l'+e.replace(o,"$1")+""},onSelect:function(e,t,o){}}}(jQuery); \ No newline at end of file diff --git a/kernel/admin/views/edit-page.php b/kernel/admin/views/edit-page.php index 62393751..abac66b7 100644 --- a/kernel/admin/views/edit-page.php +++ b/kernel/admin/views/edit-page.php @@ -77,12 +77,13 @@ echo '