diff --git a/.gitignore b/.gitignore index fa914784..3a373671 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ dbgenerator.php bl-content/* bl-plugins/timemachine bl-plugins/timemachine-x -bl-plugins/remote-content bl-plugins/discovery bl-plugins/updater bl-kernel/bludit.pro.php diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 3826a5c6..0360f2d4 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -265,6 +265,12 @@ function changePluginsPosition($pluginClassList) { return true; } +/* + Create a new page + + The array $args support all the keys from variable $dbFields of the class pages.class.php + If you don't pass all the keys, the default values are used, the default values are from $dbFields in the class pages.class.php +*/ function createPage($args) { global $pages; global $syslog; diff --git a/bl-kernel/pages.class.php b/bl-kernel/pages.class.php index 5bbd3926..17b9d1f5 100644 --- a/bl-kernel/pages.class.php +++ b/bl-kernel/pages.class.php @@ -51,7 +51,7 @@ class Pages extends dbJSON { // Create a new page // This function returns the key of the new page - public function add($args, $climode=false) + public function add($args) { $row = array(); @@ -116,18 +116,16 @@ class Pages extends dbJSON { $row['type'] = 'scheduled'; } - if ($climode===false) { - // Create the directory - if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) { - Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory ['.PATH_PAGES.$key.']',LOG_TYPE_ERROR); - return false; - } + // Create the directory + if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) { + Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory ['.PATH_PAGES.$key.']',LOG_TYPE_ERROR); + return false; + } - // Create the index.txt and save the file - if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $contentRaw) === false ) { - Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the content in the file ['.FILENAME.']',LOG_TYPE_ERROR); - return false; - } + // Create the index.txt and save the file + if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $contentRaw) === false ) { + Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the content in the file ['.FILENAME.']',LOG_TYPE_ERROR); + return false; } // Checksum MD5 @@ -145,7 +143,7 @@ class Pages extends dbJSON { return $key; } - public function edit($args, $climode=false) + public function edit($args) { // Old key // This variable is not belong to the database so is not defined in $row @@ -213,22 +211,20 @@ class Pages extends dbJSON { $row['type'] = 'scheduled'; } - if ($climode===false) { - // Move the directory from old key to new key. - if ($newKey!==$key) { - if( Filesystem::mv(PATH_PAGES.$key, PATH_PAGES.$newKey) === false ) { - Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to move the directory to '.PATH_PAGES.$newKey); - return false; - } - } - - // Make the index.txt and save the file. - if (file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $contentRaw)===false) { - Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME); + // Move the directory from old key to new key. + if ($newKey!==$key) { + if( Filesystem::mv(PATH_PAGES.$key, PATH_PAGES.$newKey) === false ) { + Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to move the directory to '.PATH_PAGES.$newKey); return false; } } + // Make the index.txt and save the file. + if (file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $contentRaw)===false) { + Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME); + return false; + } + // Remove the old key unset( $this->db[$key] ); diff --git a/bl-plugins/remote-content/languages/en.json b/bl-plugins/remote-content/languages/en.json new file mode 100644 index 00000000..06a8ebd4 --- /dev/null +++ b/bl-plugins/remote-content/languages/en.json @@ -0,0 +1,12 @@ +{ + "plugin-data": + { + "name": "Remote Content", + "description": "" + }, + "webhook": "Webhook", + "source": "Source", + "keep-content": "Keep content", + "complete-url-of-the-zip-file": "Complete URL of the zip file.", + "if-you-want-to-keep-the-content-generate-via-the-user-interface-enable-this-field": "If you want to keep the content generate via the user interface enable this field." +} \ No newline at end of file diff --git a/bl-plugins/remote-content/languages/es.json b/bl-plugins/remote-content/languages/es.json new file mode 100644 index 00000000..508446a1 --- /dev/null +++ b/bl-plugins/remote-content/languages/es.json @@ -0,0 +1,12 @@ +{ + "plugin-data": + { + "name": "Contenido remoto", + "description": "" + }, + "webhook": "Webhook", + "source": "Source", + "keep-content": "Keep content", + "complete-url-of-the-zip-file": "Complete URL of the zip file.", + "if-you-want-to-keep-the-content-generate-via-the-user-interface-enable-this-field": "If you want to keep the content generate via the user interface enable this field." +} \ No newline at end of file diff --git a/bl-plugins/remote-content/metadata.json b/bl-plugins/remote-content/metadata.json new file mode 100644 index 00000000..9aa58a43 --- /dev/null +++ b/bl-plugins/remote-content/metadata.json @@ -0,0 +1,10 @@ +{ + "author": "Bludit", + "email": "", + "website": "https://plugins.bludit.com/plugin/remote-content", + "version": "3.0", + "releaseDate": "2018-09-14", + "license": "MIT", + "compatible": "3.0", + "notes": "" +} \ No newline at end of file diff --git a/bl-plugins/remote-content/plugin.php b/bl-plugins/remote-content/plugin.php new file mode 100644 index 00000000..f5f5cabd --- /dev/null +++ b/bl-plugins/remote-content/plugin.php @@ -0,0 +1,176 @@ +dbFields = array( + 'webhook'=>$randomWebhook, + 'source'=>'https://github.com/bludit/remote-content-example/archive/master.zip' + ); + } + + public function form() + { + global $Language; + + if (extension_loaded('zip')===false) { + $this->formButtons = false; + return '