Пример #1
0
 /**
  * Test JPathway::getInstance().
  *
  * @return  void
  */
 public function testGetInstance()
 {
     $current = TestReflection::getValue('JApplicationHelper', '_clients');
     // Test Client
     $obj = new stdClass();
     $obj->id = 0;
     $obj->name = 'inspector';
     $obj->path = JPATH_TESTS;
     $obj2 = new stdClass();
     $obj2->id = 1;
     $obj2->name = 'inspector2';
     $obj2->path = __DIR__ . '/stubs';
     TestReflection::setValue('JApplicationHelper', '_clients', array($obj, $obj2));
     $pathway = JPathway::getInstance('Inspector');
     $this->assertThat(get_class($pathway), $this->equalTo('JPathwayInspector'));
     $this->assertThat(JPathway::getInstance('Inspector'), $this->equalTo($pathway));
     $pathway = JPathway::getInstance('Inspector2');
     $this->assertThat(get_class($pathway), $this->equalTo('JPathwayInspector2'));
     $ret = true;
     try {
         JPathway::getInstance('Error');
     } catch (Exception $e) {
         $ret = false;
     }
     if ($ret) {
         $this->fail('JPathway did not throw proper exception upon false client.');
     }
     TestReflection::setValue('JApplicationHelper', '_clients', $current);
 }
 /**
  * Test JPathway::setItemName().
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testSetItemName()
 {
     $pathway = array();
     $object1 = new stdClass();
     $object1->name = 'Item1';
     $object1->link = 'index.php?key=item1';
     $pathway[] = $object1;
     $object2 = new stdClass();
     $object2->name = 'Item2';
     $object2->link = 'index.php?key=item2';
     $pathway[] = $object2;
     TestReflection::setValue($this->fixture, '_pathway', $pathway);
     $this->assertTrue($this->fixture->setItemName(1, 'Item3'));
     $pathway[1]->name = 'Item3';
     $this->assertThat(TestReflection::getValue($this->fixture, '_pathway'), $this->equalTo($pathway));
     $this->assertFalse($this->fixture->setItemName(3, 'False'));
     $this->assertThat(TestReflection::getValue($this->fixture, '_pathway'), $this->equalTo($pathway));
 }
 /**
  * Test JPathway::setItemName().
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testSetItemName()
 {
     $pathway = array();
     $object1 = new stdClass();
     $object1->name = 'Item1';
     $object1->link = 'index.php?key=item1';
     $pathway[] = $object1;
     $object2 = new stdClass();
     $object2->name = 'Item2';
     $object2->link = 'index.php?key=item2';
     $pathway[] = $object2;
     $this->fixture->setPathway($pathway);
     $this->assertTrue($this->fixture->setItemName(1, 'Item3'));
     $pathway[1]->name = 'Item3';
     $this->assertAttributeEquals($pathway, '_pathway', $this->fixture);
     $this->assertFalse($this->fixture->setItemName(3, 'False'));
     $this->assertAttributeEquals($pathway, '_pathway', $this->fixture);
 }
 /**
  * Returns the application JPathway object.
  *
  * @param   string  $name     The name of the application.
  * @param   array   $options  An optional associative array of configuration settings.
  *
  * @return  JPathway  A JPathway object
  *
  * @since   11.1
  */
 public function getPathway($name = null, $options = array())
 {
     if (!isset($name)) {
         $name = $this->_name;
     }
     jimport('joomla.application.pathway');
     $pathway = JPathway::getInstance($name, $options);
     if ($pathway instanceof Exception) {
         return null;
     }
     return $pathway;
 }
Пример #5
0
 /**
  * Return a reference to the application JPathway object.
  *
  * @access public
  * @param  array	$options 	An optional associative array of configuration settings.
  * @return object JPathway.
  * @since 1.5
  */
 public function &getPathway($name = null, $options = array())
 {
     if (!isset($name)) {
         $name = $this->_name;
     }
     jimport('joomla.application.pathway');
     $pathway =& JPathway::getInstance($name, $options);
     if (JError::isError($pathway)) {
         $null = null;
         return $null;
     }
     return $pathway;
 }
Пример #6
0
 /**
  * Returns the application JPathway object.
  *
  * @param   string  $name     The name of the application.
  * @param   array   $options  An optional associative array of configuration settings.
  *
  * @return  JPathway
  *
  * @since   3.2
  */
 public function getPathway($name = null, $options = array())
 {
     if (!isset($name)) {
         $name = $this->getName();
     }
     try {
         $pathway = JPathway::getInstance($name, $options);
     } catch (Exception $e) {
         return null;
     }
     return $pathway;
 }
Пример #7
0
 /**
  * ECR_COM_NAMEECR_LIST_POSTFIX view display method.
  *
  * @param string $tpl The name of the template file to parse;
  *
  * @return void
  */
 public function display($tpl = null)
 {
     jimport('joomla.application.pathway');
     //-- Initialize some variables
     $document = JFactory::getDocument();
     $pathway = JPathway::getInstance('site');
     //-- Get the parameters of the active menu item
     $menus = JSite::getMenu();
     $menu = $menus->getActive();
     //-- Get some data from the model
     $items = $this->get('data');
     $category = $this->get('category');
     $state = $this->get('state');
     //-- Get the page/component configuration
     $params = JComponentHelper::getParams('ECR_COM_COM_NAME');
     if (!$category) {
         $this->params = $params;
         parent::display($tpl);
         return;
     }
     if ($items) {
         $total = $this->get('total');
         $pagination = $this->get('pagination');
         $category->total = $total;
     }
     $model = JModelLegacy::getInstance('categories', 'ECR_COM_NAMEmodel');
     $categories = $model->getData();
     //-- Add alternate feed link
     if ($params->get('show_feed_link', 1) == 1) {
         $link = '&view=category&id=' . $category->slug . '&format=feed&limitstart=';
         $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
         $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
         $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
         $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
     }
     $menus = JSite::getMenu();
     $menu = $menus->getActive();
     //-- Because the application sets a default page title, we need to get it
     //-- right from the menu item itself
     if (is_object($menu)) {
         if (!$menu->params->get('page_title')) {
             $params->set('page_title', $category->title);
         }
     } else {
         $params->set('page_title', $category->title);
     }
     $document->setTitle($params->get('page_title'));
     //-- Set breadcrumbs
     if (is_object($menu) && $menu->query['view'] != 'category') {
         $pathway->addItem($category->title, '');
     }
     //-- Prepare category description
     $category->description = JHTML::_('content.prepare', $category->description);
     //-- Table ordering
     $lists['order_Dir'] = $state->get('filter_order_dir');
     $lists['order'] = $state->get('filter_order');
     //-- Set some defaults if not set for params
     $params->def('comp_description', JText::_('ECR_COM_NAME_DESC'));
     //-- Define image tag attributes
     if (isset($category->image) && $category->image != '') {
         $attribs['align'] = $category->image_position;
         $attribs['hspace'] = 6;
         //-- Use the static HTML library to build the image tag
         $category->image = JHTML::_('image', 'images/stories/' . $category->image, JText::_('Web Links'), $attribs);
     }
     $k = 0;
     $count = count($items);
     for ($i = 0; $i < $count; $i++) {
         $item =& $items[$i];
         $link = JRoute::_('index.php?view=ECR_COM_NAME&catid=' . $category->slug . '&id=' . $item->slug);
         $menuclass = 'category' . $this->escape($params->get('pageclass_sfx'));
         /*
          * @todo set edit link to custom field
          */
         $item->link = '<a href="' . $link . '" class="' . $menuclass . '">' . $this->escape($item->id) . '</a>';
         $item->odd = $k;
         $item->count = $i;
         $k = 1 - $k;
     }
     $count = count($categories);
     for ($i = 0; $i < $count; $i++) {
         $cat =& $categories[$i];
         $cat->link = JRoute::_('index.php?option=ECR_COM_COM_NAME&view=category&id=' . $cat->slug);
     }
     $this->lists = $lists;
     $this->params = $params;
     $this->category = $category;
     $this->categories = $categories;
     $this->items = $items;
     $this->pagination = $this->get('pagination');
     parent::display($tpl);
 }
Пример #8
0
 /**
  * Returns the application JPathway object.
  *
  * @param   string  $name     The name of the application.
  * @param   array   $options  An optional associative array of configuration settings.
  *
  * @return  JPathway  A JPathway object
  *
  * @since   11.1
  */
 public function getPathway($name = null, $options = array())
 {
     if (!isset($name)) {
         $name = $this->_name;
     }
     $pathway = JPathway::getInstance($name, $options);
     if ($pathway instanceof Exception) {
         return null;
     }
     return $pathway;
 }
Пример #9
0
 /**
  * Returns the application JPathway object.
  *
  * @param   string  $name     The name of the application.
  * @param   array   $options  An optional associative array of configuration settings.
  *
  * @return  JPathway
  *
  * @since   3.2
  */
 public function getPathway($name = null, $options = array())
 {
     if (!isset($name)) {
         $name = $this->getName();
     }
     return JPathway::getInstance($name, $options);
 }
Пример #10
0
 /**
  * Sets the pathway for the current controller
  * TuiyoControllerCore::setPathway()
  * @return void
  */
 public function setPathway($pathway)
 {
     JPathway::setPathway($pathway);
 }