Ejemplo n.º 1
0
 /**
  * Installer constructor.
  *
  * @param   string             $dataDirectory The data directory
  * @param   ContainerInterface $container     The container
  */
 public function __construct($dataDirectory, ContainerInterface $container)
 {
     $this->container = $container;
     $this->dataDirectory = $dataDirectory;
     $this->repositoryFactory = $this->container->get('Repository');
     $this->builder = $this->repositoryFactory->getEntityBuilder();
     $this->inflector = Inflector::getInstance();
     $this->loadInstalledExtensions();
     $this->loadExistingEntities();
 }
 /**
  * Instantiate the controller.
  *
  * @param   \JInput          $input  The input object.
  * @param   \JApplicationCms $app    The application object.
  * @param   array            $config The config object.
  */
 public function __construct(\JInput $input = null, \JApplicationCms $app = null, $config = array())
 {
     parent::__construct($input, $app, $config);
     // Guess the item view as the context.
     $this->viewItem = $this->viewItem ?: ArrayHelper::getValue($config, 'view_item', $this->getName());
     // Guess the list view as the plural of the item view.
     $this->viewList = $this->viewList ?: ArrayHelper::getValue($config, 'view_list');
     if (empty($this->viewList)) {
         $inflector = Inflector::getInstance();
         $this->viewList = $inflector->toPlural($this->viewItem);
     }
 }
 /**
  * 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 = Inflector::getInstance();
         $this->viewItem = $inflector->toSingular($this->viewList);
     }
 }
Ejemplo n.º 4
0
 /**
  * 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 = ArrayHelper::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 = Inflector::getInstance();
         $this->viewList = $inflector->toPlural($this->viewItem);
     }
 }
Ejemplo n.º 5
0
 /**
  * Get the path of extension.
  *
  * @param   string   $element   The extension element name, example: com_content or plg_group_name
  * @param   string   $client    Site or administrator.
  * @param   boolean  $absolute  True to return whole path.
  *
  * @return  string  The found path.
  */
 public static function get($element, $client = null, $absolute = true)
 {
     $element = strtolower($element);
     $extracted = ExtensionHelper::extractElement($element);
     $extension = $extracted['type'];
     $name = $extracted['name'];
     $group = $extracted['group'];
     // Assign name path.
     switch ($extension) {
         case 'component':
         case 'module':
             $folder = $element;
             break;
         case 'plugin':
             $folder = $group . '/' . $name;
             $client = 'site';
             break;
         case 'library':
             $client = 'site';
         default:
             $folder = $name;
             break;
     }
     // Build path
     $extension = Inflector::getInstance()->toPlural($extension);
     $path = $extension . '/' . $folder;
     if (!$absolute) {
         return $path;
     }
     // Add absolute path.
     switch ($client) {
         case 'site':
             $path = JPATH_SITE . '/' . $path;
             break;
         case 'admin':
         case 'administrator':
             $path = JPATH_ADMINISTRATOR . '/' . $path;
             break;
         default:
             $path = JPATH_BASE . '/' . $path;
             break;
     }
     return $path;
 }
Ejemplo n.º 6
0
 /**
  * Load model class
  *
  * @param   string $class Class name
  */
 private function model($class)
 {
     if (!strstr(strtolower($class), 'model')) {
         return;
     }
     $kls = explode('\\', $class);
     $class = array_pop($kls);
     $scope = Factory::getApplication()->scope;
     $isFabble = strtolower(substr($class, 0, 11)) === 'fabblemodel';
     if ($this->appName($class) === $scope || $isFabble) {
         $path = JPATH_SITE . '/libraries/fabble/';
         $defaultPath = JPATH_SITE . '/libraries/fabble/';
         $plural = Inflector::getInstance();
         $parts = Normalise::fromCamelCase($class, true);
         unset($parts[0]);
         $parts = array_values($parts);
         foreach ($parts as &$part) {
             $part = strtolower($part);
             if ($plural->isPlural($part)) {
                 $part = $plural->toSingular($part);
             }
             $part = JString::ucfirst(strtolower($part));
         }
         $path .= implode('/', $parts) . '.php';
         if (file_exists($path)) {
             require_once $path;
             $type = array_pop($parts);
             if (!$isFabble) {
                 class_alias('\\Fabble\\Model\\FabbleModel' . JString::ucfirst($type), $class);
             }
             return;
         }
         // IF no actual model name found try loading default model
         $parts[count($parts) - 1] = 'Default';
         $defaultPath .= implode('/', $parts) . '.php';
         if (file_exists($defaultPath)) {
             require_once $defaultPath;
             $type = array_pop($parts);
             class_alias("\\Fabble\\Model\\FabbleModel" . JString::ucfirst($type), $class);
             return;
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * 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 ?: ArrayHelper::getValue($config, 'order_column', null);
     // This block should be remove after 3.0, use allowFields instead
     if (!$this->filterFields) {
         $this->filterFields = ArrayHelper::getValue($config, 'filter_fields', array());
         $this->filterFields[] = '*';
     }
     if (!$this->allowFields) {
         $this->allowFields = ArrayHelper::getValue($config, 'allow_fields', array());
         $this->allowFields[] = '*';
     }
     $this->prefix = $this->getPrefix($config);
     $this->option = 'com_' . $this->prefix;
     // Guess name for container
     $this->name = $this->name ?: ArrayHelper::getValue($config, 'name', $this->getName());
     $this->container = $container ?: $this->getContainer();
     $this->container->registerServiceProvider(new GridProvider($this->name, $this));
     $this->configureTables();
     parent::__construct($config, $container, $state, $db);
     // Guess the item view as the context.
     $this->viewList = $this->viewList ?: ArrayHelper::getValue($config, 'view_list', $this->getName());
     // Guess the list view as the plural of the item view.
     $this->viewItem = $this->viewItem ?: ArrayHelper::getValue($config, 'view_item');
     if (empty($this->viewItem)) {
         $inflector = Inflector::getInstance();
         $this->viewItem = $inflector->toSingular($this->viewList);
     }
 }
Ejemplo n.º 8
0
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
$app = JFactory::getApplication();
$user = JFactory::getUser();
$userId = $user->get('id');
$extension = $this->escape($this->state->get('filter.extension'));
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$saveOrder = $listOrder == 'a.lft' && strtolower($listDirn) == 'asc';
$parts = explode('.', $extension);
$component = $parts[0];
$section = null;
$columns = 7;
if (count($parts) > 1) {
    $section = $parts[1];
    $inflector = Inflector::getInstance();
    if (!$inflector->isPlural($section)) {
        $section = $inflector->toPlural($section);
    }
}
if ($saveOrder) {
    $saveOrderingUrl = 'index.php?option=com_categories&task=categories.saveOrderAjax&tmpl=component';
    JHtml::_('sortablelist.sortable', 'categoryList', 'adminForm', strtolower($listDirn), $saveOrderingUrl, false, true);
}
?>
<form action="<?php 
echo JRoute::_('index.php?option=com_categories&view=categories');
?>
" method="post" name="adminForm" id="adminForm">
	<div id="j-sidebar-container" class="span2">
		<?php 
Ejemplo n.º 9
0
 /**
  * Method to test Inflector::getInstance().
  *
  * @return  void
  *
  * @covers  Joomla\String\Inflector::getInstance
  * @since   1.0
  */
 public function testGetInstance()
 {
     $this->assertInstanceOf('Joomla\\String\\Inflector', Inflector::getInstance(), 'Check getInstance returns the right class.');
     // Inject an instance an test.
     TestHelper::setValue($this->inflector, 'instance', new \stdClass());
     $this->assertThat(Inflector::getInstance(), $this->equalTo(new \stdClass()), 'Checks singleton instance is returned.');
     $this->assertInstanceOf('Joomla\\String\\Inflector', Inflector::getInstance(true), 'Check getInstance a fresh object with true argument even though the instance is set to something else.');
 }
Ejemplo n.º 10
0
 /**
  * Normalises the entity name.
  *
  * @param   string $entity The entity name (singular or plural)
  *
  * @return  string The singular entity name
  */
 protected function normaliseEntityName($entity)
 {
     $inflector = Inflector::getInstance();
     if ($inflector->isPlural($entity)) {
         $entity = $inflector->toSingular($entity);
     }
     return ucfirst($entity);
 }