示例#1
0
 /**
  * Prepare an xml file content holding
  * a standard record for returning result
  * of an ajax request
  *
  * @param JView $view the view handling the request
  */
 public static function prepareAjaxResponse($view)
 {
     // use Joomla wml object
     jimport('joomla.utilities.simplexml');
     // create a root node
     $xml = new JSimpleXMLElement('item', array('id' => 'shajax-response'));
     // add children : status, message, message code, task
     $status =& $xml->addChild('status');
     $message =& $xml->addChild('message');
     $messagecode =& $xml->addChild('messagecode');
     $taskexecuted =& $xml->addChild('taskexecuted');
     // set default values
     $status->setData('_');
     $message->setData('_');
     $messagecode->setData('_');
     $taskexecuted->setData('_');
     // set their respective values
     $vErrors = $view->getErrors();
     if (empty($vErrors)) {
         // retrieve messagecode and task
         if (empty($view->messagecode)) {
             $view->assign('messagecode', 'COM_SH404SEF_OPERATION_COMPLETED');
         }
         if (empty($view->taskexecuted)) {
             $view->assign('taskexecuted', '');
         }
         // either a success or a redirect
         if (empty($view->redirectTo)) {
             // no error
             $status->setData('success');
             $msg = empty($view->message) ? JText16::_('COM_SH404SEF_OPERATION_COMPLETED') : $view->message;
             $message->setData('<ul>' . $msg . '</ul>');
             $messagecode->setData($view->messagecode);
         } else {
             $status->setData('redirect');
             $glue = strpos($view->redirectTo, '?') === false ? '?' : '&';
             $message->setData($view->redirectTo . $glue . 'sh404sefMsg=' . $view->messagecode);
         }
         $taskexecuted->setData($view->taskexecuted);
     } else {
         $status->setData('failure');
         $messageTxt = '';
         foreach ($vErrors as $error) {
             $messageTxt .= '<li>' . $error . '</li>';
         }
         $message->setData('<ul>' . $messageTxt . '</ul>');
     }
     // output resulting text, no need for a layout file I think
     $output = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
     $output .= $xml->toString();
     return $output;
 }
 /**
  * Load Browser view
  */
 function loadBrowser()
 {
     jimport('joomla.application.component.view');
     $browser = new JView($config = array('base_path' => JCE_LIBRARIES, 'layout' => 'browser'));
     $browser->assign('action', $this->getFormAction());
     $browser->display();
 }
示例#3
0
 /**
  * Method called to display elements of ElasticSearch result
  * The view must be in the file elasticsearch/plg_name/view/type_name/default.php
  * 
  * @param Array $data
  * 
  * @return string html display of the element
  * */
 public function onElasticSearchDisplay($type, $data)
 {
     // Check the type
     if ($type != $this->type) {
         return false;
     }
     $highlight = $this->smartHighLight($data);
     $path = JPATH_SITE . '/plugins/elasticsearch/' . $type;
     $view = new JView(array('name' => 'plg_' . $type, 'base_path' => $path));
     // Pass data to the view
     $view->assign('data', $data->getData());
     $view->assign('highlight', $highlight);
     // Pass type to the view
     $view->assign('type', $type);
     return $view->loadTemplate();
 }