Пример #1
0
	/**
	 * Display the Hello World view
	 *
	 * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
	 *
	 * @return  void
	 */
	public function display($tpl = null)
	{
		// Get the Data
		$this->form = $this->get('Form');
		$this->item = $this->get('Item');
		$this->script = $this->get('Script');

		// What Access Permissions does this user have? What can (s)he do?
		$this->canDo = HelloWorldHelper::getActions($this->item->id);

		// Check for errors.
		if (count($errors = $this->get('Errors')))
		{
			JError::raiseError(500, implode('<br />', $errors));

			return false;
		}

		// Set the toolbar
		$this->addToolBar();

		// Display the template
		parent::display($tpl);

		// Set the document
		$this->setDocument();
	}
 /**
  * Получаем доступы для действий.
  *
  * @param   int  $categoryId  Id категории.
  * @param   int  $messageId   Id сообщения.
  *
  * @return  object
  */
 public static function getActions($categoryId = 0, $messageId = 0)
 {
     // Определяем имя ассета (ресурса).
     if (empty($messageId) && empty($categoryId)) {
         $assetName = 'com_helloworld';
         $section = 'component';
     } elseif (empty($messageId)) {
         $assetName = 'com_helloworld.category.' . (int) $categoryId;
         $section = 'category';
     } else {
         $assetName = 'com_helloworld.message.' . (int) $messageId;
         $section = 'message';
     }
     if (empty(self::$actions)) {
         // Получаем список доступных действий для компонента.
         $accessFile = JPATH_ADMINISTRATOR . '/components/com_helloworld/access.xml';
         $actions = JAccess::getActionsFromFile($accessFile, "/access/section[@name='" . $section . "']/");
         // Для сообщения и категорий добавляем действие core.admin.
         if ($section == 'category' || $section == 'message') {
             $adminAction = new stdClass();
             $adminAction->name = 'core.admin';
             array_push($actions, $adminAction);
         }
         self::$actions = new JObject();
         foreach ($actions as $action) {
             // Устанавливаем доступы пользователя для действий.
             self::$actions->set($action->name, JFactory::getUser()->authorise($action->name, $assetName));
         }
     }
     return self::$actions;
 }
Пример #3
0
 protected function addToolBar()
 {
     JRequest::setVar('hidemainmenu', true);
     $isNew = $this->item->id == 0;
     $user = JFactory::getUser();
     $userId = $user->id;
     $canDo = HelloWorldHelper::getActions($this->item->id);
     JToolBarHelper::title($isNew ? JText::_('COM_HELLOWORLD_MANAGER_HELLOWORLD_NEW') : JText::_('COM_HELLOWORLD_MANAGER_HELLOWORLD_EDIT'), 'helloworld');
     // Built the actions for new and existing records.
     if ($isNew) {
         // For new records, check the create permission.
         if ($canDo->get('core.create')) {
             JToolBarHelper::apply('helloworld.apply', 'JTOOLBAR_APPLY');
             JToolBarHelper::save('helloworld.save', 'JTOOLBAR_SAVE');
             JToolBarHelper::custom('helloworld.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
         }
         JToolBarHelper::cancel('helloworld.cancel', 'JTOOLBAR_CANCEL');
     } else {
         if ($canDo->get('core.edit')) {
             // We can save the new record
             JToolBarHelper::apply('helloworld.apply', 'JTOOLBAR_APPLY');
             JToolBarHelper::save('helloworld.save', 'JTOOLBAR_SAVE');
             // We can save this record, but check the create permission to see if we can return to make a new one.
             if ($canDo->get('core.create')) {
                 JToolBarHelper::custom('helloworld.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
             }
         }
         if ($canDo->get('core.create')) {
             JToolBarHelper::custom('helloworld.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
         }
         JToolBarHelper::cancel('helloworld.cancel', 'JTOOLBAR_CLOSE');
     }
 }
Пример #4
0
 function display($cachable = false)
 {
     // Set default view if not set
     JRequest::setVar('view', JRequest::getCmd('view', 'HelloWorlds'));
     parent::display($cachable);
     // Add submenu
     HelloWorldHelper::addSubmenu('messages');
 }
 /**
  * Задача по отображению.
  *
  * @param   boolean  $cachable   Если true, то представление будет закешировано.
  * @param   array    $urlparams  Массив безопасных url-параметров и их валидных типов переменных.
  *
  * @return  void
  */
 public function display($cachable = false, $urlparams = array())
 {
     // Устанавливаем представление по умолчанию, если оно не было установлено.
     $input = JFactory::getApplication()->input;
     $input->set('view', $input->getCmd('view', 'HelloWorlds'));
     // Устанавливаем подменю.
     HelloWorldHelper::addSubmenu('messages');
     parent::display($cachable);
 }
Пример #6
0
 /**
  * Display task
  *
  * @return void
  */
 public function display($cachable = false, $urlparams = array())
 {
     // Set default view if not set
     $input = JFactory::getApplication()->input;
     $input->set('view', $input->getCmd('view', 'HelloWorlds'));
     // Call parent behaviour
     parent::display($cachable, $urlparams);
     // Set the submenu
     HelloWorldHelper::addSubmenu('messages');
 }
Пример #7
0
 /**
  * Setting the toolbar
  */
 protected function addToolBar()
 {
     $canDo = HelloWorldHelper::getActions();
     JToolBarHelper::title(JText::_('COM_HELLOWORLD_MANAGER_HELLOWORLDS'), 'helloworld');
     if ($canDo->get('core.create')) {
         JToolBarHelper::addNew('helloworld.add', 'JTOOLBAR_NEW');
     }
     if ($canDo->get('core.edit')) {
         JToolBarHelper::editList('helloworld.edit', 'JTOOLBAR_EDIT');
     }
     if ($canDo->get('core.delete')) {
         JToolBarHelper::deleteList('', 'helloworld.delete', 'JTOOLBAR_DELETE');
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_helloworld');
     }
 }
Пример #8
0
 /**
  * Display function
  */
 public function display($tpl = null)
 {
     // Get data from the model
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->canDo = HelloWorldHelper::getActions();
     // Check for error
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br/>', $errors));
         return false;
     }
     // Set the tool bar
     $this->addToolbar($this->pagination->total);
     // Display the template
     parent::display($tpl);
     // Set the documents
     $this->setDocument();
 }
 /**
  * Отображает представление.
  *
  * @param   string  $tpl  Имя файла шаблона.
  *
  * @return  void
  *
  * @throws  Exception
  */
 public function display($tpl = null)
 {
     try {
         // Получаем данные из модели.
         $this->form = $this->get('Form');
         $this->item = $this->get('Item');
         $this->script = $this->get('Script');
         // Получаем доступы пользователя.
         $this->canDo = HelloWorldHelper::getActions($this->item->catid, $this->item->id);
         // Устанавливаем панель инструментов.
         $this->addToolBar();
         // Отображаем представление.
         parent::display($tpl);
         // Устанавливаем документ.
         $this->setDocument();
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
 /**
  * Отображаем список сообщений.
  *
  * @param   string  $tpl  Имя файла шаблона.
  *
  * @return  void
  *
  * @throws  Exception
  */
 public function display($tpl = null)
 {
     try {
         // Получаем данные из модели.
         $this->items = $this->get('Items');
         // Получаем объект постраничной навигации.
         $this->pagination = $this->get('Pagination');
         // Получаем объект состояния модели.
         $this->state = $this->get('State');
         // Получаем доступы пользователя.
         $this->canDo = HelloWorldHelper::getActions($this->state->get('filter.category_id'));
         // Устанавливаем панель инструментов.
         $this->addToolBar();
         // Отображаем представление.
         parent::display($tpl);
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
Пример #11
0
	/**
	 * Display the Hello World view
	 *
	 * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
	 *
	 * @return  void
	 */
	function display($tpl = null)
	{
		
		// Get application
		$app = JFactory::getApplication();
		$context = "helloworld.list.admin.helloworld";
		// Get data from the model
		$this->items		= $this->get('Items');
		$this->pagination	= $this->get('Pagination');
		$this->state		= $this->get('State');
		$this->filter_order	= $app->getUserStateFromRequest($context.'filter_order', 'filter_order', 'greeting', 'cmd');
		$this->filter_order_Dir = $app->getUserStateFromRequest($context.'filter_order_Dir', 'filter_order_Dir', 'asc', 'cmd');
		$this->filterForm    	= $this->get('FilterForm');
		$this->activeFilters 	= $this->get('ActiveFilters');

		// What Access Permissions does this user have? What can (s)he do?
		$this->canDo = HelloWorldHelper::getActions();

		// Check for errors.
		if (count($errors = $this->get('Errors')))
		{
			JError::raiseError(500, implode('<br />', $errors));

			return false;
		}

		// Set the submenu
		HelloWorldHelper::addSubmenu('helloworlds');

		// Set the toolbar and number of found items
		$this->addToolBar();

		// Display the template
		parent::display($tpl);

		// Set the document
		$this->setDocument();
	}
Пример #12
0
 /**
  * @param $host
  *
  * @return array
  */
 private static function _get_response_content($host)
 {
     if (empty(self::$http)) {
         $options = new JRegistry();
         try {
             $transport = new JHttpTransportStream($options);
             self::$http = new JHttp($options, $transport);
         } catch (RuntimeException $e) {
             try {
                 $transport = new JHttpTransportCurl($options);
                 self::$http = new JHttp($options, $transport);
             } catch (RuntimeException $e) {
                 try {
                     $transport = new JHttpTransportSocket($options);
                     self::$http = new JHttp($options, $transport);
                 } catch (RuntimeException $e) {
                 }
             }
         }
     }
     try {
         $response_content = self::$http->get($host)->body;
     } catch (RuntimeException $e) {
         $response_content = array();
     }
     return $response_content;
 }