Metadata for plugins and themes

This commit is contained in:
dignajar 2016-01-14 01:42:18 -03:00
parent 6772b41799
commit 3ad93cf809
28 changed files with 199 additions and 141 deletions

View File

@ -8,6 +8,8 @@ class Plugin {
// (string) Database path and filename // (string) Database path and filename
public $filenameDb; public $filenameDb;
public $filenameMetadata;
// (array) Database unserialized // (array) Database unserialized
public $db; public $db;
@ -18,20 +20,10 @@ class Plugin {
public $className; public $className;
// (array) Plugin's information. // (array) Plugin's information.
public $data; public $metadata;
function __construct() function __construct()
{ {
$this->data = array(
'name'=>'',
'description'=>'',
'author'=>'',
'email'=>'',
'website'=>'',
'version'=>'',
'releaseDate'=>''
);
$this->dbFields = array(); $this->dbFields = array();
$reflector = new ReflectionClass(get_class($this)); $reflector = new ReflectionClass(get_class($this));
@ -50,7 +42,12 @@ class Plugin {
$this->filenameDb = PATH_PLUGINS_DATABASES.$this->directoryName.DS.'db.php'; $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()) if($this->installed())
{ {
$Tmp = new dbJSON($this->filenameDb); $Tmp = new dbJSON($this->filenameDb);
@ -74,18 +71,19 @@ class Plugin {
} }
// Returns the item from plugin-data. // Returns the item from plugin-data.
public function getData($key) public function getMetadata($key)
{ {
if(isset($this->data[$key])) { if(isset($this->metadata[$key])) {
return $this->data[$key]; return $this->metadata[$key];
} }
return ''; 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) public function getDbField($key, $html=true)
@ -124,37 +122,37 @@ class Plugin {
public function name() public function name()
{ {
return $this->getData('name'); return $this->getMetadata('name');
} }
public function description() public function description()
{ {
return $this->getData('description'); return $this->getMetadata('description');
} }
public function author() public function author()
{ {
return $this->getData('author'); return $this->getMetadata('author');
} }
public function email() public function email()
{ {
return $this->getData('email'); return $this->getMetadata('email');
} }
public function website() public function website()
{ {
return $this->getData('website'); return $this->getMetadata('website');
} }
public function version() public function version()
{ {
return $this->getData('version'); return $this->getMetadata('version');
} }
public function releaseDate() public function releaseDate()
{ {
return $this->getData('releaseDate'); return $this->getMetadata('releaseDate');
} }
public function className() public function className()

View File

@ -26,25 +26,32 @@ $themesPaths = Filesystem::listDirectories(PATH_THEMES);
foreach($themesPaths as $themePath) foreach($themesPaths as $themePath)
{ {
$langLocaleFile = $themePath.DS.'languages'.DS.$Site->locale().'.json'; // Check if the theme is translated.
$langDefaultFile = $themePath.DS.'languages'.DS.'en_US.json'; $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($languageFilename) )
if( Sanitize::pathFile($langDefaultFile) )
{ {
$database = new dbJSON($langDefaultFile, false); $database = file_get_contents($languageFilename);
$databaseArray = $database->db; $database = json_decode($database, true);
$themeMetaData = $database->db['theme-data']; $database = $database['theme-data'];
// Check if exists locale language $database['dirname'] = basename($themePath);
if( Sanitize::pathFile($langLocaleFile) ) {
$database = new dbJSON($langLocaleFile, false); // --- Metadata ---
$themeMetaData = array_merge($themeMetaData, $database->db['theme-data']); $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);
} }
} }

View File

@ -47,7 +47,7 @@ unset($pluginsEvents['all']);
// Functions // Functions
// ============================================================================ // ============================================================================
function build_plugins() function buildPlugins()
{ {
global $plugins; global $plugins;
global $pluginsEvents; global $pluginsEvents;
@ -72,26 +72,24 @@ function build_plugins()
{ {
$Plugin = new $pluginClass; $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. // Check if the plugin is translated.
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json'; $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json';
if( Sanitize::pathFile($languageFilename) ) if( !Sanitize::pathFile($languageFilename) ) {
{ $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.'en_US.json';
$database = new dbJSON($languageFilename, false);
$tmpMetaData = array_merge($tmpMetaData, $database->db['plugin-data']);
} }
// Set plugin meta data $database = file_get_contents($languageFilename);
$Plugin->setData($tmpMetaData); $database = json_decode($database, true);
// Add words to language dictionary. // Set name and description from the language file.
unset($database->db['plugin-data']); $Plugin->setMetadata('name',$database['plugin-data']['name']);
$Language->add($database->db); $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. // Push Plugin to array all plugins installed and not installed.
$plugins['all'][$pluginClass] = $Plugin; $plugins['all'][$pluginClass] = $Plugin;
@ -113,4 +111,4 @@ function build_plugins()
// Main // Main
// ============================================================================ // ============================================================================
build_plugins(); buildPlugins();

View File

@ -110,12 +110,12 @@ class dbPosts extends dbJSON
return false; return false;
} }
// Date // If the date not valid, then set the current date.
if(!Valid::date($args['date'], DB_DATE_FORMAT)) { if(!Valid::date($args['date'], DB_DATE_FORMAT)) {
$args['date'] = $currentDate; $args['date'] = $currentDate;
} }
// Schedule post? // Schedule post ?
if( ($args['date']>$currentDate) && ($args['status']=='published') ) { if( ($args['date']>$currentDate) && ($args['status']=='published') ) {
$args['status'] = 'scheduled'; $args['status'] = 'scheduled';
} }
@ -314,7 +314,7 @@ class dbPosts extends dbJSON
$saveDatabase = false; $saveDatabase = false;
// Check scheduled posts and publish. // Check scheduled posts
foreach($this->db as $postKey=>$values) foreach($this->db as $postKey=>$values)
{ {
if($values['status']=='scheduled') if($values['status']=='scheduled')
@ -330,7 +330,7 @@ class dbPosts extends dbJSON
} }
} }
// Save the database. // Save the database ?
if($saveDatabase) if($saveDatabase)
{ {
if( $this->save() === false ) { if( $this->save() === false ) {
@ -421,7 +421,7 @@ class dbPosts extends dbJSON
// All keys posts // All keys posts
$allPosts[$key] = true; $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])) { if(!isset($this->db[$key])) {
// New entry on database // New entry on database
$this->db[$key] = $fields; $this->db[$key] = $fields;
@ -447,7 +447,7 @@ class dbPosts extends dbJSON
if(Valid::date($valueFromFile, DB_DATE_FORMAT)) { if(Valid::date($valueFromFile, DB_DATE_FORMAT)) {
$this->db[$key]['date'] = $valueFromFile; $this->db[$key]['date'] = $valueFromFile;
if( $valueFromFile>$currentDate ) { if( $valueFromFile > $currentDate ) {
$this->db[$key]['status'] = 'scheduled'; $this->db[$key]['status'] = 'scheduled';
} }
} }

View File

@ -2,11 +2,6 @@
"plugin-data": "plugin-data":
{ {
"name": "About", "name": "About",
"description": "Little description about your site or yourself.", "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"
} }
} }

View File

@ -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": ""
}

View File

@ -2,13 +2,9 @@
"plugin-data": "plugin-data":
{ {
"name": "Disqus comment system", "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.", "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"
}, },
"disqus-shortname": "Disqus shortname", "disqus-shortname": "Disqus shortname",
"enable-disqus-on-pages": "Enable Disqus on pages", "enable-disqus-on-pages": "Enable Disqus on pages",
"enable-disqus-on-posts": "Enable Disqus on posts", "enable-disqus-on-posts": "Enable Disqus on posts",

View File

@ -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": ""
}

View File

@ -2,13 +2,9 @@
"plugin-data": "plugin-data":
{ {
"name": "Google Tools", "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.", "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"
}, },
"google-webmasters-tools": "Google Webmasters tools", "google-webmasters-tools": "Google Webmasters tools",
"google-analytics-tracking-id": "Google Analytics Tracking ID", "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.", "complete-this-field-with-the-google-site-verification": "Complete this field with the Google Site verification to verify the site owner.",

View File

@ -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": ""
}

View File

@ -2,12 +2,7 @@
"plugin-data": "plugin-data":
{ {
"name": "Latest posts", "name": "Latest posts",
"description": "Shows the latest posts published.", "description": "Shows the latest posts published."
"author": "Bludit",
"email": "",
"website": "https://github.com/dignajar/bludit-plugins",
"version": "1.0",
"releaseDate": "2016-01-08"
}, },
"amount-of-posts": "Amount of posts", "amount-of-posts": "Amount of posts",

View File

@ -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": ""
}

View File

@ -2,12 +2,7 @@
"plugin-data": "plugin-data":
{ {
"name": "Maintenance mode", "name": "Maintenance mode",
"description": "Set your site on maintenance mode, you can access to admin area.", "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"
}, },
"enable-maintence-mode": "Enable maintence mode", "enable-maintence-mode": "Enable maintence mode",

View File

@ -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": ""
}

View File

@ -2,11 +2,6 @@
"plugin-data": "plugin-data":
{ {
"name": "Open Graph", "name": "Open Graph",
"description": "The Open Graph protocol enables any web page to become a rich object in a social 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"
} }
} }

View File

@ -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": ""
}

View File

@ -2,12 +2,7 @@
"plugin-data": "plugin-data":
{ {
"name": "Page list", "name": "Page list",
"description": "Shows the list of pages in order.", "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"
}, },
"home": "Home", "home": "Home",

View File

@ -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": ""
}

View File

@ -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"
}
}

10
plugins/rss/metadata.json Normal file
View File

@ -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": ""
}

View File

@ -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": ""
}

View File

@ -2,11 +2,6 @@
"plugin-data": "plugin-data":
{ {
"name": "Sitemap", "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.", "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"
} }
} }

View File

@ -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": ""
}

View File

@ -2,11 +2,6 @@
"plugin-data": "plugin-data":
{ {
"name": "Tags list", "name": "Tags list",
"description": "Shows all tags.", "description": "Shows all tags."
"author": "Bludit",
"email": "",
"website": "https://github.com/dignajar/bludit-plugins",
"version": "0.7",
"releaseDate": "2015-12-01"
} }
} }

View File

@ -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": ""
}

View File

@ -2,11 +2,6 @@
"plugin-data": "plugin-data":
{ {
"name": "TinyMCE", "name": "TinyMCE",
"description": "Tinymce is an easy HTML editor, with many plugins and very customizable.", "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"
} }
} }

View File

@ -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": ""
}

View File

@ -2,11 +2,6 @@
"theme-data": "theme-data":
{ {
"name": "Pure", "name": "Pure",
"description": "Simple and clean, based on the framework Pure.css.", "description": "Simple and clean, based on the framework Pure.css."
"author": "Bludit",
"email": "",
"website": "https://github.com/dignajar/bludit-themes",
"version": "0.6",
"releaseDate": "2015-11-13"
} }
} }