Skip to content

Commit

Permalink
[add] automatically reading of plugin configuration
Browse files Browse the repository at this point in the history
[rem] manually reading of LanguageChecker configuration

--HG--
extra : convert_revision : svn%3A3e3b3d7d-fd53-0410-b969-2d950244e6dc/trunk%4059
  • Loading branch information
haschek committed May 9, 2010
1 parent 2d3072f commit 9aca525
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
16 changes: 2 additions & 14 deletions plugins/i18n/LanguageChecker.php
@@ -1,23 +1,13 @@
<?php

// TODO: Description, class + methods
class LanguageChecker extends SandboxPlugin
{

private $config = array();
private $languages = array();
protected $languages = array();

protected function init()
{
// load user configuration
$config = $this->sandbox->getConfig();
if (isset($config['LanguageChecker']))
{
// user configuration
$this->config = $config['LanguageChecker'];
}

// Foafpress event handlers for SPCMS
//$this->pm->subscribe('sandbox_parse_failed', $this, 'LoadResource'); // parameters: event name, class name or instance, event handler method

$this->languages = $this->createUserPreferences();

Expand Down Expand Up @@ -99,5 +89,3 @@ private function getLanguageRequests()
}

}

?>
20 changes: 20 additions & 0 deletions spcms/sandbox.inc.php
Expand Up @@ -1218,6 +1218,13 @@ class SandboxPlugin
**/
protected $path = null;

/**
* @var Array $config Plugin configuration as key-value pairs
* @access protected
* @since 0.1
**/
protected $config = null;

/**
* Sandbox Plugin constructor
*
Expand All @@ -1233,12 +1240,25 @@ class SandboxPlugin
**/
final public function __construct(Sandbox $sandbox, $pluginpath)
{
// interfaces to API

$this->path = rtrim($pluginpath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
$this->sandbox = $sandbox;
$this->content = $sandbox->content;
$this->pm = $sandbox->pm;
$this->cache = $sandbox->cache;

// plugin config from user configuration (done in bootstrap)

$config = $this->sandbox->getConfig();
$classname = get_class($this);
if (isset($config[$classname]))
{
$this->config = $config[$classname];
}
unset($config);
unset($classname);

$this->init();
}

Expand Down

0 comments on commit 9aca525

Please sign in to comment.