translater/inc/class.translater.proposals.php

61 lines
1.3 KiB
PHP
Raw Normal View History

2021-08-18 19:42:30 +00:00
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of translater, a plugin for Dotclear 2.
#
2021-08-19 21:11:14 +00:00
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
2021-08-18 19:42:30 +00:00
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* Translater proposal tools container.
*/
class translaterProposals
{
2021-08-18 22:48:47 +00:00
public $core;
private $stack = array();
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);
}
}