Exemplo n.º 1
0
 protected function _commandNew(Library\ControllerToolbarCommand $command)
 {
     $option = $this->getController()->getIdentifier()->package;
     $view = Library\StringInflector::singularize($this->getIdentifier()->name);
     $table = $this->getController()->getModel()->getState()->table;
     $command->href = 'option=com_' . $option . '&view=' . $view . '&table=' . $table;
 }
Exemplo n.º 2
0
 public function createRow(array $options = array())
 {
     $identifier = clone $this->getIdentifier();
     $identifier->path = array('database', 'row');
     $identifier->name = Library\StringInflector::singularize($this->getIdentifier()->name);
     return $this->getObject($identifier, $options);
 }
Exemplo n.º 3
0
 public function _inline()
 {
     $url = $this->getObject('lib:http.url', array('url' => $this->module->params->get('url')));
     $parts = $url->getQuery(true);
     $package = substr($parts['option'], 4);
     $view = Library\StringInflector::singularize($parts['view']);
     $identifier = 'com:' . $package . '.controller.' . $view;
     //Render the component
     $html = $this->getObject($identifier, array('request' => $parts))->render();
     return $html;
 }
Exemplo n.º 4
0
 /**
  * Get the list of commands
  *
  * Will attempt to use information from the xml manifest if possible
  *
  * @return  array
  */
 public function getCommands()
 {
     $menu = $this->getObject('com:pages.model.menus')->application('admin')->getRowset()->find(array('slug' => 'menubar'));
     if (count($menu)) {
         $package = $this->getObject('component')->getIdentifier()->package;
         $view = $this->getObject('component')->getController()->getIdentifier()->name;
         $extension = $this->getObject('application.extensions')->getExtension($package);
         $groups = $this->getObject('user')->getGroups();
         // Make sure that pages without an assigned group are also included.
         $groups[] = 0;
         $pages = $this->getObject('application.pages')->find(array('pages_menu_id' => $menu->top()->id, 'extensions_extension_id' => $extension->id, 'hidden' => 0, 'users_group_id' => $groups));
         foreach ($pages as $page) {
             if ($page->level > 2) {
                 $this->addCommand(JText::_((string) $page->title), array('href' => (string) $page->link_url, 'active' => (string) $view == Library\StringInflector::singularize($page->getLink()->query['view'])));
             }
         }
     }
     return parent::getCommands();
 }
Exemplo n.º 5
0
 public function humanize($config = array())
 {
     $config = new Library\ObjectConfig($config);
     $config->append(array('sizes' => array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB')));
     $bytes = $config->size;
     $result = '';
     $format = ($bytes > 1024 * 1024 && $bytes % 1024 !== 0 ? '%.2f' : '%d') . ' %s';
     foreach ($config->sizes as $s) {
         $size = $s;
         if ($bytes < 1024) {
             $result = $bytes;
             break;
         }
         $bytes /= 1024;
     }
     if ($result == 1) {
         $size = Library\StringInflector::singularize($size);
     }
     return sprintf($format, $result, $this->translate($size));
 }
 /**
  * Create a new entity for the data source
  * Overridden to ensure identifier is set correctly
  *
  * @param Library\ModelContext $context A model context object
  * @return  Library\ModelEntityInterface The entity
  */
 protected function _actionCreate(Library\ModelContext $context)
 {
     //Get the data
     $data = Library\ModelContext::unbox($context->entity);
     //Create the entity identifier
     $identifier = $this->getIdentifier()->toArray();
     $identifier['path'] = array('model', 'entity');
     $identifier['name'] = 'venues';
     if (!is_numeric(key($data))) {
         $identifier['name'] = Library\StringInflector::singularize($identifier['name']);
     } else {
         $identifier['name'] = Library\StringInflector::pluralize($identifier['name']);
     }
     $options = array('data' => $data, 'identity_key' => $context->getIdentityKey());
     return $this->getObject($identifier, $options);
 }