2021-08-18 19:42:30 +00:00
|
|
|
<?php
|
2021-09-02 21:44:01 +00:00
|
|
|
/**
|
|
|
|
* @brief translater, a plugin for Dotclear 2
|
2021-11-01 21:32:32 +00:00
|
|
|
*
|
2021-09-02 21:44:01 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-01 21:32:32 +00:00
|
|
|
*
|
2021-09-02 21:44:01 +00:00
|
|
|
* @author Jean-Christian Denis & contributors
|
2021-11-01 21:32:32 +00:00
|
|
|
*
|
2021-09-02 21:44:01 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-08-18 19:42:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Translater proposal tools container.
|
|
|
|
*/
|
|
|
|
class translaterProposals
|
|
|
|
{
|
2021-08-18 22:48:47 +00:00
|
|
|
public $core;
|
|
|
|
|
2021-11-01 21:32:32 +00:00
|
|
|
private $stack = [];
|
2021-08-18 22:48:47 +00:00
|
|
|
|
|
|
|
public function __construct($core)
|
|
|
|
{
|
|
|
|
$this->core = $core;
|
|
|
|
|
|
|
|
# --BEHAVIOR-- addTranslaterProposalTool
|
|
|
|
$core->callBehavior('addTranslaterProposalTool', $this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addTool($id)
|
|
|
|
{
|
|
|
|
if (!class_exists($id)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$r = new ReflectionClass($id);
|
|
|
|
$p = $r->getParentClass();
|
|
|
|
|
|
|
|
if (!$p || $p->name != 'translaterProposalTool') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->stack[$id] = new $id($this->core);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTools()
|
|
|
|
{
|
|
|
|
return $this->stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTool($id)
|
|
|
|
{
|
|
|
|
return array_key_exists($id, $this->stack) ? $this->stack[$id] : null;
|
|
|
|
}
|
2021-08-18 19:42:30 +00:00
|
|
|
|
2021-08-18 22:48:47 +00:00
|
|
|
public function hasTool($id)
|
|
|
|
{
|
|
|
|
return array_key_exists($id, $this->stack);
|
|
|
|
}
|
2021-11-01 21:32:32 +00:00
|
|
|
}
|