コード例 #1
0
	/**
	 * Method to test JStringInflector::toPlural().
	 *
	 * @param   string  $singular  The singular form of a word.
	 * @param   string  $plural    The plural form of a word.
	 *
	 * @return  void
	 *
	 * @dataProvider  seedSinglePlural
	 * @since   12.1
	 * @covers  JStringInflector::toSingular
	 */
	public function testToSingular($singular, $plural)
	{
		$this->assertThat(
			$this->inflector->toSingular($plural),
			$this->equalTo($singular)
		);
	}
コード例 #2
0
ファイル: helper.php プロジェクト: ForAEdesWeb/AEW25
 /**
  * Configure the Link bar.
  *
  * @param   string  $vName  The name of the active view.
  *
  * @return  void
  */
 public static function addSubmenu($vName)
 {
     $app = \JFactory::getApplication();
     $inflector = \JStringInflector::getInstance(true);
     foreach (new \DirectoryIterator(JPATH_ADMINISTRATOR . '/components/com_copymodules/view') as $folder) {
         if ($folder->isDir() && $inflector->isPlural($view = $folder->getBasename())) {
             JHtmlSidebar::addEntry(JText::sprintf(sprintf('COM_COPYMODULES_%s_TITLE_LIST', strtoupper($folder))), 'index.php?option=com_copymodules&view=' . $view, $vName == $view);
         }
     }
     $dispatcher = \JEventDispatcher::getInstance();
     $dispatcher->trigger('onAfterAddSubmenu', array('com_copymodules', $vName));
 }
コード例 #3
0
 /**
  * Instantiate the controller.
  *
  * @param \JInput          $input   The input object.
  * @param \JApplicationCms $app     The application object.
  * @param array            $config  Alternative config.
  */
 public function __construct(\JInput $input = null, \JApplicationCms $app = null, $config = array())
 {
     parent::__construct($input, $app, $config);
     // Guess the item view as the context.
     $this->viewList = $this->viewList ?: \JArrayHelper::getValue($config, 'view_list', $this->getName());
     // Guess the list view as the plural of the item view.
     $this->viewItem = $this->viewItem ?: \JArrayHelper::getValue($config, 'view_item');
     if (empty($this->viewItem)) {
         $inflector = \JStringInflector::getInstance();
         $this->viewItem = $inflector->toSingular($this->viewList);
     }
 }
コード例 #4
0
 /**
  * Method to test __construct().
  *
  * @return void
  *
  * @covers Windwalker\Model\ListModel::__construct
  */
 public function test__construct()
 {
     $listModel = new ListModel();
     $option = TestHelper::getValue($listModel, 'option');
     $viewList = TestHelper::getValue($listModel, 'viewList');
     $viewItem = TestHelper::getValue($listModel, 'viewItem');
     $expectedViewItem = \JStringInflector::getInstance()->toSingular($viewList);
     $this->assertNull(TestHelper::getValue($listModel, 'orderCol'));
     $this->assertEquals(array('*'), TestHelper::getValue($listModel, 'filterFields'));
     $this->assertSame(Container::getInstance($option), TestHelper::getValue($listModel, 'container'));
     $this->assertEquals($listModel->getName(), $viewList);
     $this->assertEquals($expectedViewItem, $viewItem);
 }
コード例 #5
0
 /**
  * Method to instantiate the view.
  *
  * @param Model             $model     The model object.
  * @param Container         $container DI Container.
  * @param array             $config    View config.
  * @param \SplPriorityQueue $paths     Paths queue.
  */
 public function __construct(Model $model = null, Container $container = null, $config = array(), \SplPriorityQueue $paths = null)
 {
     parent::__construct($model, $container, $config, $paths);
     // Guess the item view as the context.
     if (empty($this->viewList)) {
         $this->viewList = $this->getName();
     }
     // Guess the list view as the plural of the item view.
     if (empty($this->viewItem)) {
         $inflector = \JStringInflector::getInstance();
         $this->viewItem = $inflector->toSingular($this->viewList);
     }
 }
コード例 #6
0
ファイル: sidebar.php プロジェクト: prox91/joomla-dev
    /**
     * Display the side navigation bar, ACL aware
     *
     * @return  string the html representation of side navigation
     */
    public static function getSideNavigation()
    {
        JHtml::_('behavior.framework', true);
        jimport('joomla.string.inflector');
        $inflector = JStringInflector::getInstance();
        $input = JFactory::getApplication()->input;
        $viewName = $input->get('view', '', 'cmd');
        $disabled = $input->get('disablesidebar', '0', 'int');
        $link = 'index.php?option=com_openhrm';
        if ($disabled) {
            return;
        }
        $menuStructure['OPENHRM_SUBMENU_DASHBOARD'] = array(0 => array('OPENHRM_SUBMENU_DASHBOARD', '&view=dashboard'));
        $menuStructure['OPENHRM_SUBMENU_PIM'] = array(0 => array('OPENHRM_SUBMENU_EMPLOYEE_LIST', '&view=employees'));
        $menuStructure['OPENHRM_SUBMENU_LEAVE'] = array(0 => array('OPENHRM_SUBMENU_LEAVE_TYPE_LIST', '&view=leavetypes'), 1 => array('OPENHRM_SUBMENU_LEAVE_REQUEST_LIST', '&view=leaverequests'));
        $menuStructure['OPENHRM_SUBMENU_TIME'] = array(0 => array('OPENHRM_SUBMENU_TIMESHEET_LIST', '&view=timesheets'));
        $menuStructure['OPENHRM_SUBMENU_RECRUITMENT'] = array(0 => array('OPENHRM_SUBMENU_CANDIDATE_LIST', '&view=candidates'), 1 => array('OPENHRM_SUBMENU_VACANCY_LIST', '&view=vacancies'));
        $menuStructure['OPENHRM_SUBMENU_PERFORMANCE'] = array(0 => array('OPENHRM_SUBMENU_KPI_LIST', '&view=kpis'), 1 => array('OPENHRM_SUBMENU_REVIEW_LIST', '&view=reviews'));
        $menuStructure['OPENHRM_SUBMENU_REPORT'] = array(0 => array('OPENHRM_SUBMENU_EMPLOYEES_REPORT_LIST', '&view=employeereports'), 1 => array('OPENHRM_SUBMENU_PROJECT_REPORT_LIST', '&view=projectreports'));
        $menuStructure['OPENHRM_SUBMENU_ADMIN'] = array(0 => array('OPENHRM_SUBMENU_USER_LIST', '&view=users'), 1 => array('OPENHRM_SUBMENU_JOB_CATEGORY_LIST', '&view=jobcategories'), 2 => array('OPENHRM_SUBMENU_JOB_TITLE_LIST', '&view=jobtitles'), 3 => array('OPENHRM_SUBMENU_QUALIFICATION_LIST', '&view=qualifications'));
        $menuStructure['OPENHRM_SUBMENU_SYSTEM'] = array(0 => array('OPENHRM_SUBMENU_COUNTRY_LIST', '&view=countries'), 1 => array('OPENHRM_SUBMENU_STATE_LIST', '&view=states'), 2 => array('OPENHRM_SUBMENU_ORGANIZATIONINFO_LIST', '&view=organizationinfo'), 4 => array('OPENHRM_SUBMENU_MARITALSTATE_LIST', '&view=maritalstates'));
        $html = '';
        $html .= '<div id="ec-panel-left" class="span2">';
        $html .= '<ul id="ec-sidebar-navigation">';
        $html .= '<li class="ec-tools">
					<a id="ec-dashboard" title="' . JText::_('OPENHRM_SUBMENU_DASHBOARD') . '"
					   href="' . JRoute::_('index.php?option=com_openhrm') . '">
					</a>
				  </li>';
        $iconMap = array('dashboard' => 'icon-home', 'pim' => 'icon-user', 'leave' => 'icon-share', 'time' => 'icon-time', 'recruitment' => 'icon-comments-2', 'performance' => 'icon-adjust', 'report' => 'icon-bookmark', 'admin' => 'icon-key', 'system' => 'icon-wrench');
        foreach ($menuStructure as $menuName => $menuDetails) {
            $html .= '<li class="ec-toggle" id="ec-sn_' . strtolower(substr($menuName, 16)) . '">
			            <a class="ec-indicator">Open</a>
			            <a class="ec-title"><i class="' . $iconMap[strtolower(substr($menuName, 16))] . '"></i> ' . JText::_($menuName) . '</a>';
            $html .= '<ul>';
            foreach ($menuDetails as $menu) {
                if (substr($menu[1], 1, 4) == 'view') {
                    $html .= '<li class="' . (substr($menu[1], 6) == $viewName || $inflector->toSingular(substr($menu[1], 6)) == $viewName ? 'active' : '') . '">';
                } else {
                    $html .= '<li class="">';
                }
                $html .= '<a id="' . strtolower($menu[0]) . '" href="' . JRoute::_($link . $menu[1]) . '">' . JText::_($menu[0]) . '</a></li>';
            }
            $html .= '</ul>';
            $html .= '</li>';
        }
        $html .= '</ul>';
        $html .= '</div>';
        $html .= '</div>';
        return $html;
    }
コード例 #7
0
 /**
  * Configure the Link bar.
  *
  * @param   string  $vName  The name of the active view.
  *
  * @return  void
  */
 public static function addSubmenu($vName)
 {
     $app = \JFactory::getApplication();
     $inflector = \JStringInflector::getInstance(true);
     // Add Category Menu Item
     if ($app->isAdmin()) {
         JHtmlSidebar::addEntry(JText::_('JCATEGORY'), 'index.php?option=com_categories&extension=com_remoteimage', $vName == 'categories');
     }
     foreach (new \DirectoryIterator(JPATH_ADMINISTRATOR . '/components/com_remoteimage/view') as $folder) {
         if ($folder->isDir() && $inflector->isPlural($view = $folder->getBasename())) {
             JHtmlSidebar::addEntry(JText::sprintf(sprintf('COM_REMOTEIMAGE_%s_TITLE_LIST', strtoupper($folder))), 'index.php?option=com_remoteimage&view=' . $view, $vName == $view);
         }
     }
     $dispatcher = \JEventDispatcher::getInstance();
     $dispatcher->trigger('onAfterAddSubmenu', array('com_remoteimage', $vName));
 }
コード例 #8
0
ファイル: AdminModel.php プロジェクト: beingsane/quickcontent
 /**
  * Constructor
  *
  * @param   array              $config    An array of configuration options (name, state, dbo, table_path, ignore_request).
  * @param   JoomlaContainer    $container Service container.
  * @param   \JRegistry         $state     The model state.
  * @param   \JDatabaseDriver   $db        The database adapter.
  */
 public function __construct($config = array(), JoomlaContainer $container = null, \JRegistry $state = null, \JDatabaseDriver $db = null)
 {
     parent::__construct($config, $container, $state, $db);
     if (!$this->reorderConditions) {
         $this->reorderConditions = \JArrayHelper::getValue($config, 'reorder_conditions', array('catid'));
     }
     // Guess the item view as the context.
     if (empty($this->viewItem)) {
         $this->viewItem = $this->getName();
     }
     // Guess the list view as the plural of the item view.
     if (empty($this->viewList)) {
         $inflector = \JStringInflector::getInstance();
         $this->viewList = $inflector->toPlural($this->viewItem);
     }
 }
コード例 #9
0
ファイル: sidebar.php プロジェクト: prox91/joomla-dev
    /**
     * Display the side navigation bar, ACL aware
     *
     * @return  string the html representation of side navigation
     */
    public static function getSideNavigation()
    {
        JHtml::_('behavior.framework', true);
        jimport('joomla.string.inflector');
        $inflector = JStringInflector::getInstance();
        $input = JFactory::getApplication()->input;
        $viewName = $input->get('view', '', 'cmd');
        $disabled = $input->get('disablesidebar', '0', 'int');
        $link = 'index.php?option=com_englishconcept';
        if ($disabled) {
            return;
        }
        $menuStructure['EC_SUBMENU_MASTER'] = array(0 => array('EC_SUBMENU_BOOK_LIST', '&view=books'), 1 => array('EC_SUBMENU_CATEGORY_LIST', '&view=categories'), 2 => array('EC_SUBMENU_LEVEL_LIST', '&view=levels'), 3 => array('EC_SUBMENU_LESSON_LIST', '&view=lessons'));
        $menuStructure['EC_SUBMENU_CONTENT'] = array(0 => array('EC_SUBMENU_COMPREHENSION_LIST', '&view=comprehensions'), 1 => array('EC_SUBMENU_PRECIS_LIST', '&view=precises'), 2 => array('EC_SUBMENU_COMPOSITION_LIST', '&view=compositions'), 3 => array('EC_SUBMENU_GRAMMAR_LIST', '&view=grammars'), 4 => array('EC_SUBMENU_USAGE_LIST', '&view=usages'));
        $menuStructure['EC_SUBMENU_SYSTEM'] = array(0 => array('EC_SUBMENU_SETTING_LIST', '&view=setting'));
        $html = '';
        $html .= '<div id="ec-panel-left" class="span2">';
        $html .= '<ul id="ec-sidebar-navigation">';
        $html .= '<li class="ec-tools">
					<a id="ec-dashboard" title="' . JText::_('EC_SUBMENU_DASHBOARD') . '"
					   href="' . JRoute::_('index.php?option=com_englishconcept') . '">
					</a>
				  </li>';
        $iconMap = array('master' => 'icon-home', 'content' => 'icon-key', 'system' => 'icon-wrench');
        foreach ($menuStructure as $menuName => $menuDetails) {
            $html .= '<li class="ec-toggle" id="ec-sn_' . strtolower(substr($menuName, 11)) . '">
			            <a class="ec-indicator">Open</a>
			            <a class="ec-title"><i class="' . $iconMap[strtolower(substr($menuName, 11))] . '"></i> ' . JText::_($menuName) . '</a>';
            $html .= '<ul>';
            foreach ($menuDetails as $menu) {
                if (substr($menu[1], 1, 4) == 'view') {
                    $html .= '<li class="' . (substr($menu[1], 6) == $viewName || $inflector->toSingular(substr($menu[1], 6)) == $viewName ? 'active' : '') . '">';
                } else {
                    $html .= '<li class="">';
                }
                $html .= '<a id="' . strtolower($menu[0]) . '" href="' . JRoute::_($link . $menu[1]) . '">' . JText::_($menu[0]) . '</a></li>';
            }
            $html .= '</ul>';
            $html .= '</li>';
        }
        $html .= '</ul>';
        $html .= '</div>';
        $html .= '</div>';
        return $html;
    }
コード例 #10
0
 /**
  * Constructor.
  *
  * @param   \Windwalker\DI\Container      $container
  * @param   \Muse\IO\IOInterface $io
  * @param   Registry                      $config
  */
 public function __construct(Container $container, IOInterface $io, Registry $config = null)
 {
     // Get item & list name
     $ctrl = $config['ctrl'] ?: $io->getArgument(1);
     $ctrl = explode('.', $ctrl);
     $inflector = \JStringInflector::getInstance();
     if (empty($ctrl[0])) {
         $ctrl[0] = 'item';
     }
     if (empty($ctrl[1])) {
         $ctrl[1] = $inflector->toPlural($ctrl[0]);
     }
     list($itemName, $listName) = $ctrl;
     $replace['extension.element.lower'] = strtolower($config['element']);
     $replace['extension.element.upper'] = strtoupper($config['element']);
     $replace['extension.element.cap'] = ucfirst($config['element']);
     $replace['extension.name.lower'] = strtolower($config['name']);
     $replace['extension.name.upper'] = strtoupper($config['name']);
     $replace['extension.name.cap'] = ucfirst($config['name']);
     $replace['controller.list.name.lower'] = strtolower($listName);
     $replace['controller.list.name.upper'] = strtoupper($listName);
     $replace['controller.list.name.cap'] = ucfirst($listName);
     $replace['controller.item.name.lower'] = strtolower($itemName);
     $replace['controller.item.name.upper'] = strtoupper($itemName);
     $replace['controller.item.name.cap'] = ucfirst($itemName);
     // Set replace to config.
     foreach ($replace as $key => $val) {
         $config->set('replace.' . $key, $val);
     }
     // Set copy dir.
     $config->set('dir.dest', PathHelper::get(strtolower($config['element']), $config['client']));
     $config->set('dir.tmpl', GENERATOR_BUNDLE_PATH . '/Template/' . $config['extension'] . '/' . $config['template']);
     $config->set('dir.src', $config->get('dir.tmpl') . '/' . $config['client']);
     // Replace DS
     $config['dir.dest'] = Path::clean($config['dir.dest']);
     $config['dir.tmpl'] = Path::clean($config['dir.tmpl']);
     $config['dir.src'] = Path::clean($config['dir.src']);
     // Push container
     $this->container = $container;
     parent::__construct($io, $config, $replace);
 }
コード例 #11
0
ファイル: router.php プロジェクト: prox91/joomla-dev
 /**
  * Find and execute the appropriate controller based on a given route.
  *
  * @param   string  $route  The route string for which to find and execute a controller.
  *
  * @return  void
  *
  * @since   1.0
  * @throws  InvalidArgumentException
  * @throws  RuntimeException
  *
  * @codeCoverageIgnore
  */
 public function execute($route)
 {
     // Allow poor clients to make advanced requests
     $this->setMethodInPostRequest(true);
     // Get actions from route
     $route = $this->actionRoute($route);
     // Get version and extention from route
     $route = $this->rewriteRoute($route);
     // Set controller prefix
     $this->setControllerPrefix('WebServiceController' . ucfirst($this->apiVersion) . ucfirst($this->apiType));
     // Get the controller name based on the route patterns and requested route.
     $name = $this->parseRoute($route);
     // Singularize type
     $stringInflector = JStringInflector::getInstance();
     $type = $stringInflector->toSingular($name);
     // Append the HTTP method based suffix.
     $name .= $this->fetchControllerSuffix();
     // Get the controller object by name.
     $controller = $this->fetchController($name, $type);
     // Execute the controller.
     $controller->execute();
 }
コード例 #12
0
 /**
  * Gets an instance of the JStringInflector singleton.
  *
  * @param   boolean  $new  If true (default is false), returns a new instance regardless if one exists.
  *                         This argument is mainly used for testing.
  *
  * @return  JStringInflector
  *
  * @since   12.1
  */
 public static function getInstance($new = false)
 {
     if ($new) {
         return new static();
     } elseif (!is_object(self::$_instance)) {
         self::$_instance = new static();
     }
     return self::$_instance;
 }
コード例 #13
0
 /**
  * Method to create and execute a SELECT WHERE query.
  *
  * @param   array  $options  Array of options
  *
  * @return  string  Results of query
  *
  * @since   3.1
  */
 public function find($options = array())
 {
     $where = array();
     foreach ($options as $col => $val) {
         if (JStringInflector::getInstance()->isPlural($col)) {
             $where[] = $col . ' LIKE ' . $this->_db->quote('%' . $this->_db->escape($val, true) . '%');
         } else {
             $where[] = $col . ' = ' . $this->_db->quote($val);
         }
     }
     $query = $this->_db->getQuery(true)->select($this->_db->quoteName($this->_tbl_key))->from($this->_db->quoteName($this->_tbl))->where(implode(' AND ', $where));
     $this->_db->setQuery($query);
     return $this->_db->loadResult();
 }
コード例 #14
0
ファイル: ListModel.php プロジェクト: beingsane/quickcontent
 /**
  * Constructor
  *
  * @param   array              $config    An array of configuration options (name, state, dbo, table_path, ignore_request).
  * @param   JoomlaContainer    $container Service container.
  * @param   \JRegistry         $state     The model state.
  * @param   \JDatabaseDriver   $db        The database adapter.
  */
 public function __construct($config = array(), JoomlaContainer $container = null, \JRegistry $state = null, \JDatabaseDriver $db = null)
 {
     // These need before parent constructor.
     $this->orderCol = $this->orderCol ?: JArrayHelper::getValue($config, 'order_column', null);
     if (!$this->filterFields) {
         $this->filterFields = JArrayHelper::getValue($config, 'filter_fields', array());
         $this->filterFields[] = '*';
     }
     // Guess name for container
     $this->name = $this->name ?: JArrayHelper::getValue($config, 'name', $this->getName());
     $this->container = $container ?: $this->getContainer();
     $this->container->registerServiceProvider(new GridProvider($this->name));
     $this->configureTables();
     parent::__construct($config, $container, $state, $db);
     // Guess the item view as the context.
     $this->viewList = $this->viewList ?: \JArrayHelper::getValue($config, 'view_list', $this->getName());
     // Guess the list view as the plural of the item view.
     $this->viewItem = $this->viewItem ?: \JArrayHelper::getValue($config, 'view_item');
     if (empty($this->viewItem)) {
         $inflector = \JStringInflector::getInstance();
         $this->viewItem = $inflector->toSingular($this->viewList);
     }
 }