Comments on code and improves on API plugins

This commit is contained in:
dignajar 2016-05-30 00:36:13 -03:00
parent 13a1838d9c
commit 100dce4c49
4 changed files with 39 additions and 2 deletions

View File

@ -43,6 +43,9 @@ if(!method_exists($_Plugin, 'form')) {
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{ {
$_Plugin->setDb($_POST); $_Plugin->setDb($_POST);
Theme::plugins('afterFormSave');
Alert::set($Language->g('the-changes-have-been-saved')); Alert::set($Language->g('the-changes-have-been-saved'));
} }

View File

@ -25,6 +25,7 @@ $plugins = array(
'afterAdminLoad'=>array(), 'afterAdminLoad'=>array(),
'beforeRulesLoad'=>array(), 'beforeRulesLoad'=>array(),
'afterFormSave'=>array(),
'afterPostCreate'=>array(), 'afterPostCreate'=>array(),
'afterPostModify'=>array(), 'afterPostModify'=>array(),

View File

@ -55,6 +55,7 @@ class Page extends Content {
return false; return false;
} }
// Returns an array with all children's key
public function children() public function children()
{ {
$tmp = array(); $tmp = array();

View File

@ -2,7 +2,37 @@
class pluginAPI extends Plugin { class pluginAPI extends Plugin {
public function getPost($key) public function init()
{
$this->dbFields = array(
'ping'=>false
);
}
public function form()
{
$html = '<div>';
$html .= '<input name="ping" id="jsping" type="checkbox" value="true" '.($this->getDbField('ping')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsping">Ping Bludit.com</label>';
$html .= '</div>';
return $html;
}
public function afterFormSave()
{
$this->ping();
}
private function ping()
{
if($this->getDbField('ping')) {
// Just a request HTTP with the website URL
Log::set( file_get_contents('https://www.bludit.com/api.php') );
}
}
private function getPost($key)
{ {
// Generate the object Post // Generate the object Post
$Post = buildPost($key); $Post = buildPost($key);
@ -18,7 +48,7 @@ class pluginAPI extends Plugin {
return $Post->json(); return $Post->json();
} }
public function getPage($key) private function getPage($key)
{ {
// Generate the object Page // Generate the object Page
$Page = buildPage($key); $Page = buildPage($key);
@ -53,6 +83,8 @@ class pluginAPI extends Plugin {
// ------------------------------------------------------------ // ------------------------------------------------------------
// show post {post slug} // show post {post slug}
// show page {page slug} // show page {page slug}
// show all posts
// show all pages
// Get parameters // Get parameters
$parameters = explode('/', $URI); $parameters = explode('/', $URI);