plugins/generic/translator/TranslatorPlugin.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 import('classes.plugins.GenericPlugin');
00018 
00019 class TranslatorPlugin extends GenericPlugin {
00020    function register($category, $path) {
00021       if (parent::register($category, $path)) {
00022          $this->addLocaleData();
00023          if ($this->getSetting(0, 0, 'enabled')) {
00024             $this->addHelpData();
00025             HookRegistry::register ('LoadHandler', array(&$this, 'handleRequest'));
00026          }
00027          return true;
00028       }
00029       return false;
00030    }
00031 
00032    function handleRequest($hookName, $args) {
00033       $page =& $args[0];
00034       $op =& $args[1];
00035       $sourceFile =& $args[2];
00036 
00037       if ($page === 'translate') {
00038          $this->import('TranslatorHandler');
00039          Registry::set('plugin', $this);
00040          define('HANDLER_CLASS', 'TranslatorHandler');
00041          return true;
00042       }
00043 
00044       return false;
00045    }
00046 
00047    function getName() {
00048       return 'TranslatorPlugin';
00049    }
00050 
00051    function getDisplayName() {
00052       return __('plugins.generic.translator.name');
00053    }
00054 
00055    function getDescription() {
00056       return __('plugins.generic.translator.description');
00057    }
00058 
00059    function getManagementVerbs() {
00060       $isEnabled = $this->getSetting(0, 0, 'enabled');
00061 
00062       $verbs[] = array(
00063          ($isEnabled?'disable':'enable'),
00064          __($isEnabled?'manager.plugins.disable':'manager.plugins.enable')
00065       );
00066 
00067       if ($isEnabled) $verbs[] = array(
00068          'translate',
00069          __('plugins.generic.translator.translate')
00070       );
00071 
00072       return $verbs;
00073    }
00074 
00075    /*
00076     * Execute a management verb on this plugin
00077     * @param $verb string
00078     * @param $args array
00079     * @param $message string Location for the plugin to put a result msg
00080     * @return boolean
00081     */
00082    function manage($verb, $args, &$message) {
00083       if (!Validation::isSiteAdmin()) return false;
00084 
00085       switch ($verb) {
00086          case 'enable':
00087             $this->updateSetting(0, 0, 'enabled', true);
00088             $message = __('plugins.generic.translator.enabled');
00089             break;
00090          case 'disable':
00091             $this->updateSetting(0, 0, 'enabled', false);
00092             $message = __('plugins.generic.translator.disabled');
00093             break;
00094          case 'translate':
00095             Request::redirect('index', 'index', 'translate');
00096             break;
00097       }
00098       return false;
00099    }
00100 
00101    function isSitePlugin() {
00102       return true;
00103    }
00104 }
00105 
00106 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7