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
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()

View File

@ -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 exists default language
if( Sanitize::pathFile($langDefaultFile) )
{
$database = new dbJSON($langDefaultFile, false);
$databaseArray = $database->db;
$themeMetaData = $database->db['theme-data'];
// Check if exists locale language
if( Sanitize::pathFile($langLocaleFile) ) {
$database = new dbJSON($langLocaleFile, false);
$themeMetaData = array_merge($themeMetaData, $database->db['theme-data']);
// 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';
}
$themeMetaData['dirname'] = basename($themePath);
if( Sanitize::pathFile($languageFilename) )
{
$database = file_get_contents($languageFilename);
$database = json_decode($database, true);
$database = $database['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, $themeMetaData);
array_push($themes, $database);
}
}
}

View File

@ -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();

View File

@ -110,7 +110,7 @@ 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;
}
@ -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;

View File

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

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":
{
"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",

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":
{
"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.",

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":
{
"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",

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":
{
"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",

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":
{
"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."
}
}

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":
{
"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",

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":
{
"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."
}
}

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":
{
"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."
}
}

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":
{
"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."
}
}

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":
{
"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."
}
}