Example #1
0
 /**
  * Handler manager
  *
  * @return     string
  */
 public function handler()
 {
     // Incoming
     $props = Request::getVar('p', '');
     $ajax = Request::getInt('ajax', 0);
     $pid = Request::getInt('pid', 0);
     $vid = Request::getInt('vid', 0);
     $handler = trim(Request::getVar('h', ''));
     $action = trim(Request::getVar('do', ''));
     // Parse props for curation
     $parts = explode('-', $props);
     $block = isset($parts[0]) ? $parts[0] : 'content';
     $blockId = isset($parts[1]) && is_numeric($parts[1]) && $parts[1] > 0 ? $parts[1] : 1;
     $element = isset($parts[2]) && is_numeric($parts[2]) && $parts[2] > 0 ? $parts[2] : 0;
     // Output HTML
     $view = new \Hubzero\Component\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'site', 'name' => 'handlers', 'layout' => 'editor'));
     $view->publication = new \Components\Publications\Models\Publication($pid, NULL, $vid);
     if (!$view->publication->exists()) {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_SELECTOR_ERROR_NO_PUBID'));
         // Output error
         $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'files', 'name' => 'error'));
         $view->title = '';
         $view->option = $this->_option;
         $view->setError($this->getError());
         return $view->loadTemplate();
     }
     // Set curation
     $view->publication->setCuration();
     // Set block
     if (!$view->publication->_curationModel->setBlock($block, $blockId)) {
         $view->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_SELECTOR_ERROR_LOADING_CONTENT'));
     }
     // Load handler
     $modelHandler = new \Components\Publications\Models\Handlers($this->_database);
     $view->handler = $modelHandler->ini($handler);
     if (!$view->handler) {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_ERROR_LOADING_HANDLER'));
     } else {
         // Perform request
         if ($action) {
             $modelHandler->update($view->handler, $view->publication, $element, $action);
         }
         // Load editor
         $view->editor = $modelHandler->loadEditor($view->handler, $view->publication, $element);
     }
     $view->option = $this->_option;
     $view->database = $this->_database;
     $view->uid = $this->_uid;
     $view->ajax = $ajax;
     $view->task = $this->_task;
     $view->element = $element;
     $view->block = $block;
     $view->blockId = $blockId;
     $view->props = $props;
     $view->config = $this->_pubconfig;
     // Get messages	and errors
     $view->msg = $this->_msg;
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     return $view->loadTemplate();
 }