Plugin configuration
This commit is contained in:
parent
13a5386265
commit
3339d4ec01
@ -1,5 +1,14 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// ============================================================================
|
||||
// Check role
|
||||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set('You do not have sufficient permissions to access this page, contact the administrator.');
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
@ -21,14 +30,19 @@ if($_Plugin===false) {
|
||||
Redirect::page('admin', 'plugins');
|
||||
}
|
||||
|
||||
// Check if the plugin has the method form.
|
||||
if($_Plugin->form()===false) {
|
||||
Redirect::page('admin', 'plugins');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
Alert::set('Configuration saved successfuly');
|
||||
$_Plugin->setDb($_POST);
|
||||
Alert::set('Configuration has been saved successfully');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -22,7 +22,6 @@ function editUser($args)
|
||||
{
|
||||
return $dbUsers->set($args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
@ -11,6 +11,6 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert::set('Login failed');
|
||||
Alert::set('Username or password incorrect');
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,9 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function addPage($args)
|
||||
{
|
||||
global $dbPages;
|
||||
@ -24,6 +28,10 @@ function addPage($args)
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
addPage($_POST);
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function addPost($args)
|
||||
{
|
||||
global $dbPosts;
|
||||
@ -24,6 +28,10 @@ function addPost($args)
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
addPost($_POST);
|
||||
|
@ -9,7 +9,7 @@
|
||||
?>
|
||||
|
||||
<div>
|
||||
<button class="btn btn-blue" name="publish"><i class="fa fa-sun-o fa-right"></i><?php echo $Language->p('Save') ?></button>
|
||||
<button class="btn btn-blue" name="publish"><?php echo $Language->p('Save') ?></button>
|
||||
</div>
|
||||
|
||||
</form>
|
@ -78,11 +78,11 @@
|
||||
|
||||
</div>
|
||||
|
||||
<button class="btn btn-blue" name="publish"><i class="fa fa-sun-o fa-right"></i><?php echo ($_Page->published()?$Language->p('Save'):$Language->p('Publish now')) ?></button>
|
||||
<button class="btn btn-blue" name="publish"><?php echo ($_Page->published()?$Language->p('Save'):$Language->p('Publish now')) ?></button>
|
||||
|
||||
<?php if(count($_Page->children())===0) { ?>
|
||||
<button class="btn" name="draft"><i class="fa fa-circle-o fa-right"></i><?php $Language->p('Draft') ?></button>
|
||||
<button id="jsdelete" class="btn" name="delete"><i class="fa fa-remove fa-right"></i><?php $Language->p('Delete') ?></button>
|
||||
<button class="btn" name="draft"><?php $Language->p('Draft') ?></button>
|
||||
<button id="jsdelete" class="btn" name="delete"><?php $Language->p('Delete') ?></button>
|
||||
<?php } ?>
|
||||
|
||||
</form>
|
||||
|
@ -49,9 +49,9 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-blue" name="publish"><i class="fa fa-sun-o fa-right"></i><?php echo ($_Post->published()?$Language->p('Save'):$Language->p('Publish now')) ?></button>
|
||||
<button class="btn" name="draft"><i class="fa fa-circle-o fa-right"></i><?php $Language->p('Draft') ?></button>
|
||||
<button id="jsdelete" class="btn" name="delete"><i class="fa fa-remove fa-right"></i><?php $Language->p('Delete') ?></button>
|
||||
<button class="btn btn-blue" name="publish"><?php echo ($_Post->published()?$Language->p('Save'):$Language->p('Publish now')) ?></button>
|
||||
<button class="btn" name="draft"><?php $Language->p('Draft') ?></button>
|
||||
<button id="jsdelete" class="btn" name="delete"><?php $Language->p('Delete') ?></button>
|
||||
|
||||
</form>
|
||||
|
||||
|
@ -67,8 +67,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
<button class="btn btn-blue" name="publish"><i class="fa fa-sun-o fa-right"></i><?php $Language->p('Publish now') ?></button>
|
||||
<button class="btn" name="draft"><i class="fa fa-circle-o fa-right"></i><?php $Language->p('Draft') ?></button>
|
||||
<button class="btn btn-blue" name="publish"><?php $Language->p('Publish now') ?></button>
|
||||
<button class="btn" name="draft"><?php $Language->p('Draft') ?></button>
|
||||
|
||||
</form>
|
||||
|
||||
|
@ -48,8 +48,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
<button class="btn btn-blue" name="publish"><i class="fa fa-sun-o fa-right"></i><?php $Language->p('Publish now') ?></button>
|
||||
<button class="btn" name="draft"><i class="fa fa-circle-o fa-right"></i><?php $Language->p('Draft') ?></button>
|
||||
<button class="btn btn-blue" name="publish"><?php $Language->p('Publish now') ?></button>
|
||||
<button class="btn" name="draft"><?php $Language->p('Draft') ?></button>
|
||||
|
||||
</form>
|
||||
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
if($Plugin->installed()) {
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'uninstall-plugin/'.$Plugin->className().'" class="btn btn-red btn-small">'.$Language->g('Uninstall plugin').'</a>';
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$Plugin->className().'" class="btn btn-small">'.$Language->g('Configure plugin').'</a>';
|
||||
if($Plugin->form()) {
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$Plugin->className().'" class="btn btn-small">'.$Language->g('Configure plugin').'</a>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'install-plugin/'.$Plugin->className().'" class="btn btn-blue btn-small">'.$Language->g('Install plugin').'</a>';
|
||||
|
@ -39,7 +39,7 @@
|
||||
<div class="forms-desc"><?php $Language->p('you-can-add-a-small-text-on-the-bottom') ?></div>
|
||||
</label>
|
||||
|
||||
<input type="submit" class="btn" value="<?php $Language->p('Save') ?>" name="form-general">
|
||||
<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="form-general">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -99,7 +99,7 @@
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<input type="submit" class="btn" value="<?php $Language->p('Save') ?>" name="form-advanced">
|
||||
<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="form-advanced">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -142,7 +142,7 @@
|
||||
<div class="forms-desc"><?php $Language->p('you-can-use-this-field-to-define-a-set-of') ?></div>
|
||||
</label>
|
||||
|
||||
<input type="submit" class="btn" value="<?php $Language->p('Save') ?>" name="form-regional">
|
||||
<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="form-regional">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
@ -30,6 +30,8 @@ class Plugin {
|
||||
'website'=>''
|
||||
);
|
||||
|
||||
$this->dbFields = array();
|
||||
|
||||
$reflector = new ReflectionClass(get_class($this));
|
||||
|
||||
// Directory name
|
||||
@ -140,12 +142,9 @@ class Plugin {
|
||||
// Create plugin directory for databases and others files.
|
||||
mkdir(PATH_PLUGINS_DATABASES.$this->directoryName, 0755, true);
|
||||
|
||||
if( !empty($this->dbFields) )
|
||||
{
|
||||
// DEBUG: NO ME GUSTA LLAMAR A UNA CLASE
|
||||
$Tmp = new dbJSON($this->filenameDb);
|
||||
$Tmp->set($this->dbFields);
|
||||
}
|
||||
// Create database
|
||||
$Tmp = new dbJSON($this->filenameDb);
|
||||
$Tmp->set($this->dbFields);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2,32 +2,75 @@
|
||||
|
||||
class dbLanguage extends dbJSON
|
||||
{
|
||||
public $en_US;
|
||||
private $data;
|
||||
public $data;
|
||||
public $db;
|
||||
|
||||
function __construct($language)
|
||||
{
|
||||
$this->data = array();
|
||||
$this->db = array();
|
||||
|
||||
// Default language en_US
|
||||
$filename = PATH_LANGUAGES.'en_US.json';
|
||||
if(file_exists($filename))
|
||||
{
|
||||
parent::__construct($filename, false);
|
||||
$this->en_US = $this->db;
|
||||
$Tmp = new dbJSON($filename, false);
|
||||
$this->db += $Tmp->db;
|
||||
}
|
||||
|
||||
// User language
|
||||
$filename = PATH_LANGUAGES.$language.'.json';
|
||||
if(file_exists($filename))
|
||||
{
|
||||
parent::__construct($filename, false);
|
||||
$this->data = $this->db['language-data'];
|
||||
$Tmp = new dbJSON($filename, false);
|
||||
$this->db += $Tmp->db;
|
||||
}
|
||||
|
||||
$this->data = $this->db['language-data'];
|
||||
unset($this->db['language-data']);
|
||||
}
|
||||
|
||||
// Return the translation, if the translation does'n exist then return the English translation.
|
||||
public function get($string)
|
||||
{
|
||||
$key = Text::lowercase($string);
|
||||
$key = Text::replace(' ', '-', $key);
|
||||
|
||||
if(isset($this->db[$key])) {
|
||||
return $this->db[$key];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
// Returns translation.
|
||||
public function g($string)
|
||||
{
|
||||
return $this->get($string);
|
||||
}
|
||||
|
||||
// Print translation.
|
||||
public function p($string)
|
||||
{
|
||||
echo $this->get($string);
|
||||
}
|
||||
|
||||
public function add($array)
|
||||
{
|
||||
$this->db += $array;
|
||||
}
|
||||
|
||||
// Returns the item from plugin-data.
|
||||
public function getData($key)
|
||||
{
|
||||
if(isset($this->data[$key])) {
|
||||
return $this->data[$key];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
// Returns an array with all dictionaries.
|
||||
public function getLanguageList()
|
||||
{
|
||||
$files = glob(PATH_LANGUAGES.'*.json');
|
||||
@ -45,33 +88,4 @@ class dbLanguage extends dbJSON
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// Return the translation, if the translation does'n exist then return the English translation.
|
||||
public function get($string)
|
||||
{
|
||||
$key = Text::lowercase($string);
|
||||
$key = Text::replace(' ', '-', $key);
|
||||
|
||||
if(isset($this->db[$key]))
|
||||
return $this->db[$key];
|
||||
|
||||
// If the key is not translated then return the English translation.
|
||||
return $this->en_US[$key];
|
||||
}
|
||||
|
||||
public function g($string)
|
||||
{
|
||||
return $this->get($string);
|
||||
}
|
||||
|
||||
// Print the translation.
|
||||
public function p($string)
|
||||
{
|
||||
echo $this->get($string);
|
||||
}
|
||||
|
||||
public function add($array)
|
||||
{
|
||||
$this->db += $array;
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"language-data":
|
||||
{
|
||||
"native": "Español (España)",
|
||||
"native": "Español (Argentina)",
|
||||
"english-name": "Spanish",
|
||||
"last-update": "2015-06-28",
|
||||
"author": "Diego",
|
@ -2,13 +2,6 @@
|
||||
|
||||
class pluginOpenGraph extends Plugin {
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->dbFields = array(
|
||||
'test'=>''
|
||||
);
|
||||
}
|
||||
|
||||
public function onSiteHead()
|
||||
{
|
||||
global $Url, $Site;
|
||||
|
Loading…
Reference in New Issue
Block a user