diff --git a/kernel/abstract/plugin.class.php b/kernel/abstract/plugin.class.php index 5ca8e245..42a76d4e 100644 --- a/kernel/abstract/plugin.class.php +++ b/kernel/abstract/plugin.class.php @@ -8,6 +8,8 @@ class Plugin { // (string) Database path and filename public $filenameDb; + public $filenameMetadata; + // (array) Database unserialized public $db; @@ -18,20 +20,10 @@ class Plugin { public $className; // (array) Plugin's information. - public $data; + public $metadata; function __construct() { - $this->data = array( - 'name'=>'', - 'description'=>'', - 'author'=>'', - 'email'=>'', - 'website'=>'', - 'version'=>'', - 'releaseDate'=>'' - ); - $this->dbFields = array(); $reflector = new ReflectionClass(get_class($this)); @@ -50,7 +42,12 @@ class Plugin { $this->filenameDb = PATH_PLUGINS_DATABASES.$this->directoryName.DS.'db.php'; - // If the plugin installed then get the database. + // --- Metadata --- + $this->filenameMetadata = PATH_PLUGINS.$this->directoryName().DS.'metadata.json'; + $metadataString = file_get_contents($this->filenameMetadata); + $this->metadata = json_decode($metadataString, true); + + // If the plugin is installed then get the database. if($this->installed()) { $Tmp = new dbJSON($this->filenameDb); @@ -74,18 +71,19 @@ class Plugin { } // Returns the item from plugin-data. - public function getData($key) + public function getMetadata($key) { - if(isset($this->data[$key])) { - return $this->data[$key]; + if(isset($this->metadata[$key])) { + return $this->metadata[$key]; } return ''; } - public function setData($array) + public function setMetadata($key, $value) { - $this->data = $array; + $this->metadata[$key] = $value; + return true; } public function getDbField($key, $html=true) @@ -124,37 +122,37 @@ class Plugin { public function name() { - return $this->getData('name'); + return $this->getMetadata('name'); } public function description() { - return $this->getData('description'); + return $this->getMetadata('description'); } public function author() { - return $this->getData('author'); + return $this->getMetadata('author'); } public function email() { - return $this->getData('email'); + return $this->getMetadata('email'); } public function website() { - return $this->getData('website'); + return $this->getMetadata('website'); } public function version() { - return $this->getData('version'); + return $this->getMetadata('version'); } public function releaseDate() { - return $this->getData('releaseDate'); + return $this->getMetadata('releaseDate'); } public function className() diff --git a/kernel/admin/controllers/themes.php b/kernel/admin/controllers/themes.php index 1181ac73..400a08ba 100644 --- a/kernel/admin/controllers/themes.php +++ b/kernel/admin/controllers/themes.php @@ -26,25 +26,32 @@ $themesPaths = Filesystem::listDirectories(PATH_THEMES); foreach($themesPaths as $themePath) { - $langLocaleFile = $themePath.DS.'languages'.DS.$Site->locale().'.json'; - $langDefaultFile = $themePath.DS.'languages'.DS.'en_US.json'; + // Check if the theme is translated. + $languageFilename = $themePath.DS.'languages'.DS.$Site->locale().'.json'; + if( !Sanitize::pathFile($languageFilename) ) { + $languageFilename = $themePath.DS.'languages'.DS.'en_US.json'; + } - // Check if exists default language - if( Sanitize::pathFile($langDefaultFile) ) + if( Sanitize::pathFile($languageFilename) ) { - $database = new dbJSON($langDefaultFile, false); - $databaseArray = $database->db; - $themeMetaData = $database->db['theme-data']; + $database = file_get_contents($languageFilename); + $database = json_decode($database, true); + $database = $database['theme-data']; - // Check if exists locale language - if( Sanitize::pathFile($langLocaleFile) ) { - $database = new dbJSON($langLocaleFile, false); - $themeMetaData = array_merge($themeMetaData, $database->db['theme-data']); + $database['dirname'] = basename($themePath); + + // --- Metadata --- + $filenameMetadata = $themePath.DS.'metadata.json'; + + if( Sanitize::pathFile($filenameMetadata) ) + { + $metadataString = file_get_contents($filenameMetadata); + $metadata = json_decode($metadataString, true); + + $database = $database + $metadata; + + // Theme data + array_push($themes, $database); } - - $themeMetaData['dirname'] = basename($themePath); - - // Theme data - array_push($themes, $themeMetaData); } } diff --git a/kernel/boot/rules/60.plugins.php b/kernel/boot/rules/60.plugins.php index 25c4d3bc..11faad3f 100644 --- a/kernel/boot/rules/60.plugins.php +++ b/kernel/boot/rules/60.plugins.php @@ -47,7 +47,7 @@ unset($pluginsEvents['all']); // Functions // ============================================================================ -function build_plugins() +function buildPlugins() { global $plugins; global $pluginsEvents; @@ -72,26 +72,24 @@ function build_plugins() { $Plugin = new $pluginClass; - // Default language and meta data for the plugin - $tmpMetaData = array(); - $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.'en_US.json'; - $database = new dbJSON($languageFilename, false); - $tmpMetaData = $database->db['plugin-data']; - // Check if the plugin is translated. $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json'; - if( Sanitize::pathFile($languageFilename) ) - { - $database = new dbJSON($languageFilename, false); - $tmpMetaData = array_merge($tmpMetaData, $database->db['plugin-data']); + if( !Sanitize::pathFile($languageFilename) ) { + $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.'en_US.json'; } - // Set plugin meta data - $Plugin->setData($tmpMetaData); + $database = file_get_contents($languageFilename); + $database = json_decode($database, true); - // Add words to language dictionary. - unset($database->db['plugin-data']); - $Language->add($database->db); + // Set name and description from the language file. + $Plugin->setMetadata('name',$database['plugin-data']['name']); + $Plugin->setMetadata('description',$database['plugin-data']['description']); + + // Remove name and description, and add new words if there are. + unset($database['plugin-data']); + if(!empty($database)) { + $Language->add($database); + } // Push Plugin to array all plugins installed and not installed. $plugins['all'][$pluginClass] = $Plugin; @@ -113,4 +111,4 @@ function build_plugins() // Main // ============================================================================ -build_plugins(); +buildPlugins(); diff --git a/kernel/dbposts.class.php b/kernel/dbposts.class.php index 180a58eb..d395f02c 100644 --- a/kernel/dbposts.class.php +++ b/kernel/dbposts.class.php @@ -110,12 +110,12 @@ class dbPosts extends dbJSON return false; } - // Date + // If the date not valid, then set the current date. if(!Valid::date($args['date'], DB_DATE_FORMAT)) { $args['date'] = $currentDate; } - // Schedule post? + // Schedule post ? if( ($args['date']>$currentDate) && ($args['status']=='published') ) { $args['status'] = 'scheduled'; } @@ -314,7 +314,7 @@ class dbPosts extends dbJSON $saveDatabase = false; - // Check scheduled posts and publish. + // Check scheduled posts foreach($this->db as $postKey=>$values) { if($values['status']=='scheduled') @@ -330,7 +330,7 @@ class dbPosts extends dbJSON } } - // Save the database. + // Save the database ? if($saveDatabase) { if( $this->save() === false ) { @@ -421,7 +421,7 @@ class dbPosts extends dbJSON // All keys posts $allPosts[$key] = true; - // Create the new entry if not exists on DATABASE. + // Create the new entry if not exist on DATABASE. if(!isset($this->db[$key])) { // New entry on database $this->db[$key] = $fields; @@ -447,7 +447,7 @@ class dbPosts extends dbJSON if(Valid::date($valueFromFile, DB_DATE_FORMAT)) { $this->db[$key]['date'] = $valueFromFile; - if( $valueFromFile>$currentDate ) { + if( $valueFromFile > $currentDate ) { $this->db[$key]['status'] = 'scheduled'; } } diff --git a/plugins/about/languages/en_US.json b/plugins/about/languages/en_US.json index 77d59f3d..1bcab5c5 100644 --- a/plugins/about/languages/en_US.json +++ b/plugins/about/languages/en_US.json @@ -2,11 +2,6 @@ "plugin-data": { "name": "About", - "description": "Little description about your site or yourself.", - "author": "Bludit", - "email": "", - "website": "https://github.com/dignajar/bludit-plugins", - "version": "0.7", - "releaseDate": "2015-12-01" + "description": "Little description about your site or yourself." } } \ No newline at end of file diff --git a/plugins/about/metadata.json b/plugins/about/metadata.json new file mode 100644 index 00000000..83f2154e --- /dev/null +++ b/plugins/about/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-15", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/plugins/disqus/languages/en_US.json b/plugins/disqus/languages/en_US.json index d80b0210..fb6f45f9 100644 --- a/plugins/disqus/languages/en_US.json +++ b/plugins/disqus/languages/en_US.json @@ -2,13 +2,9 @@ "plugin-data": { "name": "Disqus comment system", - "description": "Disqus is a blog comment hosting service for web sites. It's necesary to register on Disqus.com before using this plugin.", - "author": "Bludit", - "email": "", - "website": "https://github.com/dignajar/bludit-plugins", - "version": "0.7", - "releaseDate": "2015-12-01" + "description": "Disqus is a blog comment hosting service for web sites. It's necesary to register on Disqus.com before using this plugin." }, + "disqus-shortname": "Disqus shortname", "enable-disqus-on-pages": "Enable Disqus on pages", "enable-disqus-on-posts": "Enable Disqus on posts", diff --git a/plugins/disqus/metadata.json b/plugins/disqus/metadata.json new file mode 100644 index 00000000..83f2154e --- /dev/null +++ b/plugins/disqus/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-15", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/plugins/googletools/languages/en_US.json b/plugins/googletools/languages/en_US.json index 5f74907e..28cd8570 100644 --- a/plugins/googletools/languages/en_US.json +++ b/plugins/googletools/languages/en_US.json @@ -2,13 +2,9 @@ "plugin-data": { "name": "Google Tools", - "description": "This plugin generate the meta tag to validate your site with Google Webmasters Tools and the JavaScript code to track your site with Google Analytics.", - "author": "Bludit", - "email": "", - "website": "https://github.com/dignajar/bludit-plugins", - "version": "0.7", - "releaseDate": "2015-12-01" + "description": "This plugin generate the meta tag to validate your site with Google Webmasters Tools and the JavaScript code to track your site with Google Analytics." }, + "google-webmasters-tools": "Google Webmasters tools", "google-analytics-tracking-id": "Google Analytics Tracking ID", "complete-this-field-with-the-google-site-verification": "Complete this field with the Google Site verification to verify the site owner.", diff --git a/plugins/googletools/metadata.json b/plugins/googletools/metadata.json new file mode 100644 index 00000000..83f2154e --- /dev/null +++ b/plugins/googletools/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-15", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/plugins/latest_posts/languages/en_US.json b/plugins/latest_posts/languages/en_US.json index 9a9d0a0d..493c1967 100644 --- a/plugins/latest_posts/languages/en_US.json +++ b/plugins/latest_posts/languages/en_US.json @@ -2,12 +2,7 @@ "plugin-data": { "name": "Latest posts", - "description": "Shows the latest posts published.", - "author": "Bludit", - "email": "", - "website": "https://github.com/dignajar/bludit-plugins", - "version": "1.0", - "releaseDate": "2016-01-08" + "description": "Shows the latest posts published." }, "amount-of-posts": "Amount of posts", diff --git a/plugins/latest_posts/metadata.json b/plugins/latest_posts/metadata.json new file mode 100644 index 00000000..83f2154e --- /dev/null +++ b/plugins/latest_posts/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-15", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/plugins/maintancemode/languages/en_US.json b/plugins/maintancemode/languages/en_US.json index f16b8b52..8fb1c458 100644 --- a/plugins/maintancemode/languages/en_US.json +++ b/plugins/maintancemode/languages/en_US.json @@ -2,12 +2,7 @@ "plugin-data": { "name": "Maintenance mode", - "description": "Set your site on maintenance mode, you can access to admin area.", - "author": "Bludit", - "email": "", - "website": "https://github.com/dignajar/bludit-plugins", - "version": "0.7", - "releaseDate": "2015-12-01" + "description": "Set your site on maintenance mode, you can access to admin area." }, "enable-maintence-mode": "Enable maintence mode", diff --git a/plugins/maintancemode/metadata.json b/plugins/maintancemode/metadata.json new file mode 100644 index 00000000..83f2154e --- /dev/null +++ b/plugins/maintancemode/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-15", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/plugins/opengraph/languages/en_US.json b/plugins/opengraph/languages/en_US.json index 40364d27..2360859f 100644 --- a/plugins/opengraph/languages/en_US.json +++ b/plugins/opengraph/languages/en_US.json @@ -2,11 +2,6 @@ "plugin-data": { "name": "Open Graph", - "description": "The Open Graph protocol enables any web page to become a rich object in a social graph.", - "author": "Bludit", - "email": "", - "website": "https://github.com/dignajar/bludit-plugins", - "version": "0.7", - "releaseDate": "2015-12-01" + "description": "The Open Graph protocol enables any web page to become a rich object in a social graph." } } \ No newline at end of file diff --git a/plugins/opengraph/metadata.json b/plugins/opengraph/metadata.json new file mode 100644 index 00000000..83f2154e --- /dev/null +++ b/plugins/opengraph/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-15", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/plugins/pages/languages/en_US.json b/plugins/pages/languages/en_US.json index 2b05194c..8158fefa 100644 --- a/plugins/pages/languages/en_US.json +++ b/plugins/pages/languages/en_US.json @@ -2,12 +2,7 @@ "plugin-data": { "name": "Page list", - "description": "Shows the list of pages in order.", - "author": "Bludit", - "email": "", - "website": "https://github.com/dignajar/bludit-plugins", - "version": "0.7", - "releaseDate": "2015-12-01" + "description": "Shows the list of pages in order." }, "home": "Home", diff --git a/plugins/pages/metadata.json b/plugins/pages/metadata.json new file mode 100644 index 00000000..83f2154e --- /dev/null +++ b/plugins/pages/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-15", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/plugins/rss/information.json b/plugins/rss/information.json deleted file mode 100644 index 6f9fde99..00000000 --- a/plugins/rss/information.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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/metadata.json b/plugins/rss/metadata.json new file mode 100644 index 00000000..83f2154e --- /dev/null +++ b/plugins/rss/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-15", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/plugins/simplemde/metadata.json b/plugins/simplemde/metadata.json new file mode 100644 index 00000000..1af5575a --- /dev/null +++ b/plugins/simplemde/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "NextStepWebs", + "email": "", + "website": "https://github.com/NextStepWebs/simplemde-markdown-editor", + "version": "1.8.1", + "releaseDate": "2015-11-13", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/plugins/sitemap/languages/en_US.json b/plugins/sitemap/languages/en_US.json index ef54ccec..8bd661ea 100644 --- a/plugins/sitemap/languages/en_US.json +++ b/plugins/sitemap/languages/en_US.json @@ -2,11 +2,6 @@ "plugin-data": { "name": "Sitemap", - "description": "This plugin generate a file sitemap.xml where you can list the web pages of your site to tell to search engines about the organization of your site content.", - "author": "Bludit", - "email": "", - "website": "https://github.com/dignajar/bludit-plugins", - "version": "1.0", - "releaseDate": "2016-01-07" + "description": "This plugin generate a file sitemap.xml where you can list the web pages of your site to tell to search engines about the organization of your site content." } } \ No newline at end of file diff --git a/plugins/sitemap/metadata.json b/plugins/sitemap/metadata.json new file mode 100644 index 00000000..83f2154e --- /dev/null +++ b/plugins/sitemap/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-15", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/plugins/tags/languages/en_US.json b/plugins/tags/languages/en_US.json index bee02f67..d6a98ca0 100644 --- a/plugins/tags/languages/en_US.json +++ b/plugins/tags/languages/en_US.json @@ -2,11 +2,6 @@ "plugin-data": { "name": "Tags list", - "description": "Shows all tags.", - "author": "Bludit", - "email": "", - "website": "https://github.com/dignajar/bludit-plugins", - "version": "0.7", - "releaseDate": "2015-12-01" + "description": "Shows all tags." } } \ No newline at end of file diff --git a/plugins/tags/metadata.json b/plugins/tags/metadata.json new file mode 100644 index 00000000..83f2154e --- /dev/null +++ b/plugins/tags/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-15", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/plugins/tinymce/languages/en_US.json b/plugins/tinymce/languages/en_US.json index 7f3875cc..b36b0f3a 100644 --- a/plugins/tinymce/languages/en_US.json +++ b/plugins/tinymce/languages/en_US.json @@ -2,11 +2,6 @@ "plugin-data": { "name": "TinyMCE", - "description": "Tinymce is an easy HTML editor, with many plugins and very customizable.", - "author": "TinyMCE", - "email": "", - "website": "http://www.tinymce.com", - "version": "4.3.1", - "releaseDate": "2015-12-08" + "description": "Tinymce is an easy HTML editor, with many plugins and very customizable." } } \ No newline at end of file diff --git a/plugins/tinymce/metadata.json b/plugins/tinymce/metadata.json new file mode 100644 index 00000000..83f2154e --- /dev/null +++ b/plugins/tinymce/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-15", + "license": "MIT", + "requires": "Bludit v1.0", + "notes": "" +} \ No newline at end of file diff --git a/themes/pure/languages/en_US.json b/themes/pure/languages/en_US.json index 788d1b4b..46af0ad5 100644 --- a/themes/pure/languages/en_US.json +++ b/themes/pure/languages/en_US.json @@ -2,11 +2,6 @@ "theme-data": { "name": "Pure", - "description": "Simple and clean, based on the framework Pure.css.", - "author": "Bludit", - "email": "", - "website": "https://github.com/dignajar/bludit-themes", - "version": "0.6", - "releaseDate": "2015-11-13" + "description": "Simple and clean, based on the framework Pure.css." } } \ No newline at end of file