/**
  * Permit requests to the statistics grid handler
  * @param $hookName string The name of the hook being invoked
  * @param $args array The parameters to the invoked hook
  */
 function setupGridHandler($hookName, $params)
 {
     $component =& $params[0];
     if ($component == 'plugins.generic.addThis.controllers.grid.AddThisStatisticsGridHandler') {
         // Allow the static page grid handler to get the plugin object
         import($component);
         AddThisStatisticsGridHandler::setPlugin($this);
         return true;
     }
     return false;
 }
 /**
  * Set the Plugin
  * @param $plugin Plugin
  */
 static function setPlugin($plugin)
 {
     self::$_plugin = $plugin;
 }
Esempio n. 3
0
 /**
  * @copydoc PKPPlugin::manage()
  */
 function manage($verb, $args, &$message, &$messageParams, &$pluginModalContent = null)
 {
     $request = $this->getRequest();
     $press = $request->getPress();
     $templateMgr = TemplateManager::getManager($request);
     switch ($verb) {
         case 'settings':
             $templateMgr->assign('statsConfigured', $this->statsConfigured($press));
             $pluginModalContent = $templateMgr->fetch($this->getTemplatePath() . 'settingsTabs.tpl');
             return true;
         case 'showTab':
             if ($request->getUserVar('tab') == 'settings') {
                 $this->import('AddThisSettingsForm');
                 $form = new AddThisSettingsForm($this, $press);
                 if ($request->getUserVar('save')) {
                     $form->readInputData();
                     if ($form->validate()) {
                         $form->execute();
                         $message = NOTIFICATION_TYPE_SUCCESS;
                         $messageParams = array('contents' => __('plugins.generic.addThis.form.saved'));
                         return false;
                     } else {
                         $pluginModalContent = $form->fetch($request);
                     }
                 } else {
                     $form->initData();
                     $pluginModalContent = $form->fetch($request);
                 }
             } else {
                 $pluginModalContent = $templateMgr->fetch($this->getTemplatePath() . 'statistics.tpl');
             }
             return true;
         case 'showStatistics':
             $this->import('AddThisStatisticsGridHandler');
             $gridHandler = new AddThisStatisticsGridHandler($this);
             $gridHandler->initialize($request);
             $jsonMessage = json_decode($gridHandler->fetchGrid($args, $request));
             $pluginModalContent = $jsonMessage->content;
             return true;
         default:
             // let the parent handle it.
             return parent::manage($verb, $args, $message, $messageParams);
     }
 }