Beispiel #1
0
 public function display()
 {
     jimport('joomla.html.pagination');
     // get application
     $app = Zoo::getApplication();
     // set toolbar items
     $this->joomla->set('JComponentTitle', $app->getToolbarTitle(JText::_('Tags')));
     JToolBarHelper::deleteList();
     ZooHelper::toolbarHelp();
     JHTML::_('behavior.tooltip');
     // get request vars
     $state_prefix = $this->option . '_' . $app->id . '.tags.';
     $filter_order = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_order', 'filter_order', '', 'cmd');
     $filter_order_Dir = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_order_Dir', 'filter_order_Dir', 'desc', 'word');
     $limit = $this->joomla->getUserStateFromRequest('global.list.limit', 'limit', $this->joomla->getCfg('list_limit'), 'int');
     $limitstart = $this->joomla->getUserStateFromRequest($state_prefix . 'limitstart', 'limitstart', 0, 'int');
     $search = $this->joomla->getUserStateFromRequest($state_prefix . 'search', 'search', '', 'string');
     $search = JString::strtolower($search);
     // is filtered ?
     $this->is_filtered = !empty($search);
     // in case limit has been changed, adjust limitstart accordingly
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     // get data
     $filter = $filter_order ? $filter_order . ' ' . $filter_order_Dir : '';
     $this->tags = YTable::getInstance('tag')->getAll($app->id, $search, '', $filter, $limitstart, $limit);
     $count = (int) YTable::getInstance('tag')->count($app->id);
     $this->pagination = new JPagination($count, $limitstart, $limit);
     // table ordering and search filter
     $this->lists['order_Dir'] = $filter_order_Dir;
     $this->lists['order'] = $filter_order;
     $this->lists['search'] = $search;
     // display view
     $this->getView()->display();
 }
Beispiel #2
0
 public function add()
 {
     // disable menu
     YRequest::setVar('hidemainmenu', 1);
     // get application metadata
     $metadata = $this->application->getMetaData();
     // set toolbar items
     $this->joomla->set('JComponentTitle', $this->application->getToolbarTitle(JText::_('New App') . ': ' . $metadata['name']));
     JToolBarHelper::save();
     JToolBarHelper::custom('', 'back', '', 'Back', false);
     ZooHelper::toolbarHelp();
     // get params
     $this->params = $this->application->getParams();
     // set default template
     $this->params->set('template', 'default');
     // template select
     $options = array(JHTML::_('select.option', '', '- ' . JText::_('Select Template') . ' -'));
     foreach ($this->application->getTemplates() as $template) {
         $metadata = $template->getMetaData();
         $options[] = JHTML::_('select.option', $template->name, $metadata['name']);
     }
     $this->lists['select_template'] = JHTML::_('select.genericlist', $options, 'template', '', 'value', 'text', $this->params->get('template'));
     // display view
     $this->getView()->setLayout('application')->display();
 }
Beispiel #3
0
 public function display()
 {
     // set toolbar items
     $this->joomla->set('JComponentTitle', $this->application->getToolbarTitle(JText::_('Frontpage')));
     JToolBarHelper::save();
     ZooHelper::toolbarHelp();
     // get params
     $this->params = $this->application->getParams();
     // display view
     $this->getView()->display();
 }
Beispiel #4
0
 public function edit()
 {
     // disable menu
     YRequest::setVar('hidemainmenu', 1);
     // get request vars
     $cid = YRequest::getArray('cid.0', '', 'int');
     $edit = $cid > 0;
     // get category
     if ($edit) {
         $this->category = YTable::getInstance('category')->get($cid);
     } else {
         $this->category = new Category();
         $this->category->parent = 0;
     }
     // get category params
     $this->params = $this->category->getParams();
     // set toolbar items
     $text = $edit ? JText::_('Edit') : JText::_('New');
     $this->joomla->set('JComponentTitle', $this->application->getToolbarTitle(JText::_('Category') . ': ' . $this->category->name . ' <small><small>[ ' . $text . ' ]</small></small>'));
     JToolBarHelper::save();
     JToolBarHelper::custom('saveandnew', 'saveandnew', 'saveandnew', 'Save & New', false);
     JToolBarHelper::apply();
     JToolBarHelper::cancel('cancel', $edit ? 'Close' : 'Cancel');
     ZooHelper::toolbarHelp();
     // select published state
     $this->lists['select_published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $this->category->published);
     // get categories and exclude the current category
     $categories = $this->application->getCategories();
     unset($categories[$this->category->id]);
     // build category tree
     $list = CategoryHelper::buildTreeList(0, CategoryHelper::buildTree($this->application->id, $categories));
     $options = array(JHTML::_('select.option', '0', JText::_('Root')));
     foreach ($list as $item) {
         $options[] = JHTML::_('select.option', $item->id, '&nbsp;&nbsp;&nbsp;' . $item->treename);
     }
     // select parent category
     $this->lists['select_parent'] = JHTML::_('select.genericlist', $options, 'parent', 'class="inputbox" size="10"', 'value', 'text', $this->category->parent);
     // display view
     $this->getView()->setLayout('edit')->display();
 }
Beispiel #5
0
 public function assignSubmission()
 {
     // disable menu
     YRequest::setVar('hidemainmenu', 1);
     // init vars
     $type = YRequest::getString('type');
     $this->template = YRequest::getString('template');
     $this->layout = YRequest::getString('layout');
     // get type
     $this->type = $this->application->getType($type);
     // set toolbar items
     $this->joomla->set('JComponentTitle', $this->application->getToolbarTitle(JText::_('Type') . ': ' . $this->type->name . ' <small><small>[ ' . JText::_('Assign Submittable elements') . ': ' . $this->layout . ' ]</small></small>'));
     JToolBarHelper::save('savesubmission');
     JToolBarHelper::apply('applysubmission');
     JToolBarHelper::cancel('types');
     ZooHelper::toolbarHelp();
     // for template, module, plugin
     if ($this->template) {
         $this->path = $this->application->getPath() . '/templates/' . $this->template;
     }
     // get renderer
     $renderer = new ItemRenderer();
     $renderer->addPath($this->path);
     // get positions and config
     $this->config = $renderer->getConfig('item')->get($this->group . '.' . $type . '.' . $this->layout);
     $prefix = 'item.';
     if ($renderer->pathExists('item' . DIRECTORY_SEPARATOR . $type)) {
         $prefix .= $type . '.';
     }
     $this->positions = $renderer->getPositions($prefix . $this->layout);
     // display view
     $this->getView()->setLayout('assignsubmission')->display();
 }
Beispiel #6
0
 public function edit($tpl = null)
 {
     // disable menu
     YRequest::setVar('hidemainmenu', 1);
     // get database
     $this->db = JFactory::getDBO();
     // get request vars
     $cid = YRequest::getArray('cid.0', '', 'int');
     $edit = $cid > 0;
     // get item
     if ($edit) {
         $this->submission = YTable::getInstance('submission')->get($cid);
     } else {
         $this->submission = new Submission();
         $this->submission->application_id = $this->application->id;
         $this->submission->access = 1;
     }
     // set toolbar items
     $this->joomla->set('JComponentTitle', $this->application->getToolbarTitle(JText::_('Submission') . ': ' . $this->submission->name . ' <small><small>[ ' . ($edit ? JText::_('Edit') : JText::_('New')) . ' ]</small></small>'));
     JToolBarHelper::save();
     JToolBarHelper::custom('saveandnew', 'saveandnew', 'saveandnew', 'Save & New', false);
     JToolBarHelper::apply();
     JToolBarHelper::cancel('cancel', $edit ? 'Close' : 'Cancel');
     ZooHelper::toolbarHelp();
     // published select
     $this->lists['select_published'] = JHTML::_('select.booleanlist', 'state', null, $this->submission->state);
     // tooltip select
     $this->lists['select_tooltip'] = JHTML::_('select.booleanlist', 'params[show_tooltip]', null, $this->submission->showTooltip());
     // type select
     $this->types = array();
     foreach ($this->application->getTypes() as $type) {
         // list types with submission layouts only
         if (count(ZooHelper::getLayouts($this->application, $type->id, 'submission')) > 0) {
             $form = $this->submission->getForm($type->id);
             $this->types[$type->id]['name'] = $type->name;
             $options = array(JHTML::_('select.option', '', '- ' . JText::_('not submittable') . ' -'));
             $this->types[$type->id]['select_layouts'] = JHTML::_('zoo.layoutList', $this->application, $type->id, 'submission', $options, 'params[form][' . $type->id . '][layout]', '', 'value', 'text', $form->get('layout'));
             $options = array(JHTML::_('select.option', '', '- ' . JText::_('uncategorized') . ' -'));
             $this->types[$type->id]['select_categories'] = JHTML::_('zoo.categorylist', $this->application, $options, 'params[form][' . $type->id . '][category]', 'size="1"', 'value', 'text', $form->get('category'));
         }
     }
     // display view
     $this->getView()->setLayout('edit')->display();
 }
Beispiel #7
0
 public function render($params = array())
 {
     $jplugins = $this->_config->get('jplugins');
     $display = isset($params['display']) ? $params['display'] : 'all';
     $result = array();
     switch ($display) {
         case 'all':
             foreach ($this as $self) {
                 if (($text = $this->_data->get('value', '')) && !empty($text)) {
                     $result[] = $text;
                 }
             }
             break;
         case 'first':
             $this->rewind();
             if (($text = $this->_data->get('value', '')) && !empty($text)) {
                 $result[] = $text;
             }
             break;
         case 'all_without_first':
             $this->rewind();
             while ($this->next()) {
                 if (($text = $this->_data->get('value', '')) && !empty($text)) {
                     $result[] = $text;
                 }
             }
             break;
     }
     // trigger joomla content plugins
     if ($jplugins) {
         for ($i = 0; $i < count($result); $i++) {
             $result[$i] = ZooHelper::triggerContentPlugins($result[$i]);
         }
     }
     return ElementHelper::applySeparators($params['separated_by'], $result);
 }
Beispiel #8
0
 public function getText($text)
 {
     return ZooHelper::triggerContentPlugins($text);
 }
Beispiel #9
0
 public function renderSubmission($params = array())
 {
     // load js
     JHTML::script('image.js', 'administrator/components/com_zoo/elements/image/assets/js/');
     // init vars
     $image = $this->_data->get('file');
     // is uploaded file
     $image = is_array($image) ? '' : $image;
     // get params
     $params = new YArray($params);
     $trusted_mode = $params->get('trusted_mode');
     // build image select
     $lists = array();
     if ($trusted_mode) {
         $options = array(JHTML::_('select.option', '', '- ' . JText::_('Select Image') . ' -'));
         if (!empty($image) && !$this->_inUploadPath($image)) {
             $options[] = JHTML::_('select.option', $image, '- ' . JText::_('No Change') . ' -');
         }
         $img_ext = str_replace(',', '|', trim(JComponentHelper::getParams('com_media')->get('image_extensions'), ','));
         foreach (YFile::readDirectoryFiles(JPATH_ROOT . '/' . $this->_getUploadImagePath() . '/', $this->_getUploadImagePath() . '/', '/\\.(' . $img_ext . ')$/i', false) as $file) {
             $options[] = JHTML::_('select.option', $file, basename($file));
         }
         $lists['image_select'] = JHTML::_('select.genericlist', $options, 'elements[' . $this->identifier . '][image]', 'class="image"', 'value', 'text', $image);
     } else {
         if (!empty($image)) {
             $image = ZooHelper::resizeImage(JPATH_ROOT . DS . $image, 0, 0);
             $image = trim(str_replace('\\', '/', preg_replace('/^' . preg_quote(JPATH_ROOT, '/') . '/i', '', $image)), '/');
         }
     }
     if (!empty($image)) {
         $image = JURI::root() . $image;
     }
     if ($layout = $this->getLayout('submission.php')) {
         return self::renderLayout($layout, array('element' => $this->identifier, 'lists' => $lists, 'image' => $image));
     }
 }
Beispiel #10
0
 public function element()
 {
     $this->_loadGeneralCSS();
     jimport('joomla.html.pagination');
     // get database
     $this->db = JFactory::getDBO();
     // get request vars
     $this->filter_item = YRequest::getInt('item_filter', 0);
     $this->type_filter = YRequest::getArray('type_filter', array());
     $state_prefix = $this->option . '_' . $this->application->id . '.' . ($this->getTask() == 'element' ? 'element' : 'item') . '.';
     $filter_order = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_order', 'filter_order', 'a.created', 'cmd');
     $filter_order_Dir = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_order_Dir', 'filter_order_Dir', 'desc', 'word');
     $filter_category_id = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_category_id', 'filter_category_id', '0', 'string');
     $limit = $this->joomla->getUserStateFromRequest('global.list.limit', 'limit', $this->joomla->getCfg('list_limit'), 'int');
     $limitstart = $this->joomla->getUserStateFromRequest($state_prefix . 'limitstart', 'limitstart', 0, 'int');
     $filter_type = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_type', 'filter_type', '', 'string');
     $filter_author_id = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_author_id', 'filter_author_id', 0, 'int');
     $search = $this->joomla->getUserStateFromRequest($state_prefix . 'search', 'search', '', 'string');
     $search = JString::strtolower($search);
     // is filtered ?
     $this->is_filtered = $filter_category_id != '0' || !empty($filter_type) || !empty($filter_author_id) || !empty($search);
     // in case limit has been changed, adjust limitstart accordingly
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $table = YTable::getInstance('item');
     $this->users = $table->getUsers($this->application->id);
     $this->groups = ZooHelper::getGroups();
     // get data from the table
     $where = array();
     // application filter
     $where[] = 'a.application_id = ' . (int) $this->application->id;
     // category filter
     if ($filter_category_id > 0) {
         $where[] = 'ci.category_id = ' . (int) $filter_category_id;
     } else {
         if ($filter_category_id === '') {
             $where[] = 'ci.item_id IS NULL';
         }
     }
     // type filter
     if (!empty($this->type_filter)) {
         $where[] = 'a.type IN ("' . implode('", "', $this->type_filter) . '")';
     } else {
         if (!empty($filter_type)) {
             $where[] = 'a.type = "' . (string) $filter_type . '"';
         }
     }
     // item filter
     if ($this->filter_item > 0) {
         $where[] = 'a.id != ' . (int) $this->filter_item;
     }
     // author filter
     if ($filter_author_id > 0) {
         $where[] = 'a.created_by = ' . (int) $filter_author_id;
     }
     if ($search) {
         $where[] = 'LOWER(a.name) LIKE ' . $this->db->Quote('%' . $this->db->getEscaped($search, true) . '%', false);
     }
     // access filter
     $where[] = 'a.access <= ' . (int) $this->user->get('aid', 0);
     // state filter
     $where[] = 'a.state = 1';
     $options = array('select' => 'DISTINCT a.*', 'from' => $table->getTableName() . ' AS a LEFT JOIN ' . ZOO_TABLE_CATEGORY_ITEM . ' AS ci ON a.id = ci.item_id', 'conditions' => array(implode(' AND ', $where)), 'order' => $filter_order . ' ' . $filter_order_Dir);
     $this->items = $table->all($limit > 0 ? array_merge($options, array('offset' => $limitstart, 'limit' => $limit)) : $options);
     $this->items = array_merge($this->items);
     $this->pagination = new JPagination($table->count($options), $limitstart, $limit);
     // category select
     $options = array();
     $options[] = JHTML::_('select.option', '0:0', '- ' . JText::_('Select Category') . ' -');
     $options[] = JHTML::_('select.option', '', '- ' . JText::_('uncategorized') . ' -');
     $this->lists['select_category'] = JHTML::_('zoo.categorylist', $this->application, $options, 'filter_category_id', 'class="inputbox auto-submit"', 'value', 'text', $filter_category_id);
     // type select
     $options = array(JHTML::_('select.option', '0', '- ' . JText::_('Select Type') . ' -'));
     $this->lists['select_type'] = JHTML::_('zoo.typelist', $options, 'filter_type', 'class="inputbox auto-submit"', 'value', 'text', $filter_type, false, false, $this->type_filter);
     // author select
     $options = array(JHTML::_('select.option', '0', '- ' . JText::_('Select Author') . ' -'));
     $this->lists['select_author'] = JHTML::_('zoo.itemauthorlist', $options, 'filter_author_id', 'class="inputbox auto-submit"', 'value', 'text', $filter_author_id);
     // table ordering and search filter
     $this->lists['order_Dir'] = $filter_order_Dir;
     $this->lists['order'] = $filter_order;
     $this->lists['search'] = $search;
     $this->addViewPath(ZOO_ADMIN_PATH . '/views/item/');
     $view = $this->getView('', '', '', array('base_path' => ZOO_ADMIN_PATH));
     $view->setLayout('element')->display();
 }
Beispiel #11
0
 public function edit($tpl = null)
 {
     // disable menu
     YRequest::setVar('hidemainmenu', 1);
     // get database
     $this->db = JFactory::getDBO();
     // get request vars
     $cid = YRequest::getArray('cid.0', '', 'int');
     $edit = $cid > 0;
     // get item
     if ($edit) {
         $this->item = YTable::getInstance('item')->get($cid);
     } else {
         $this->item = new Item();
         $this->item->application_id = $this->application->id;
         $this->item->type = JRequest::getVar('type');
         $this->item->publish_down = $this->db->getNullDate();
     }
     // get item params
     $this->params = $this->item->getParams();
     // set toolbar items
     $this->joomla->set('JComponentTitle', $this->application->getToolbarTitle(JText::_('Item') . ': ' . $this->item->name . ' <small><small>[ ' . ($edit ? JText::_('Edit') : JText::_('New')) . ' ]</small></small>'));
     JToolBarHelper::save();
     JToolBarHelper::custom('saveandnew', 'saveandnew', 'saveandnew', 'Save & New', false);
     JToolBarHelper::apply();
     JToolBarHelper::cancel('cancel', $edit ? 'Close' : 'Cancel');
     ZooHelper::toolbarHelp();
     // published select
     $this->lists['select_published'] = JHTML::_('select.booleanlist', 'state', null, $this->item->state);
     // published searchable
     $this->lists['select_searchable'] = JHTML::_('select.booleanlist', 'searchable', null, $this->item->searchable);
     // categories select
     $related_categories = $this->item->getRelatedCategoryIds();
     $this->lists['select_frontpage'] = JHTML::_('select.booleanlist', 'frontpage', null, in_array(0, $related_categories));
     $this->lists['select_categories'] = JHTML::_('zoo.categorylist', $this->application, array(), 'categories[]', 'size="15" multiple="multiple"', 'value', 'text', $related_categories);
     $this->lists['select_primary_category'] = JHTML::_('zoo.categorylist', $this->application, array(JHTML::_('select.option', '', JText::_('none'))), 'params[primary_category]', '', 'value', 'text', $this->params->get('config.primary_category'));
     // most used tags
     $this->lists['most_used_tags'] = YTable::getInstance('tag')->getAll($this->application->id, null, null, 'items DESC, a.name ASC', null, self::MAX_MOST_USED_TAGS);
     // comments enabled select
     $this->lists['select_enable_comments'] = JHTML::_('select.booleanlist', 'params[enable_comments]', null, $this->params->get('config.enable_comments', 1));
     // display view
     $this->getView()->setLayout('edit')->display();
 }
Beispiel #12
0
 public static function layoutList($application, $type_id, $layout_type, $options, $name, $attribs = null, $key = 'value', $text = 'text', $selected = NULL, $idtag = false, $translate = false)
 {
     // set options
     if (is_array($options)) {
         reset($options);
     } else {
         $options = array($options);
     }
     $layouts = ZooHelper::getLayouts($application, $type_id, $layout_type);
     foreach ($layouts as $layout => $metadata) {
         $options[] = JHTML::_('select.option', $layout, $metadata->get('name'));
     }
     return JHTML::_('select.genericlist', $options, $name, $attribs, $key, $text, $selected, $idtag, $translate);
     // create options
     foreach ($application->getTemplates() as $template) {
         $metadata = $template->getMetadata();
         $options[] = JHTML::_('select.option', $template->name, $metadata['name']);
     }
     return JHTML::_('select.genericlist', $options, $name, $attribs, $key, $text, $selected, $idtag, $translate);
 }
Beispiel #13
0
 protected function _getThumbnails($params)
 {
     $thumbs = array();
     $width = $params->get('width');
     $height = $params->get('height');
     $resize = $params->get('resize', 1);
     $title = $this->_data->get('title', '');
     $files = JFolder::files($this->_path, '.', false, true, array('.svn', 'CVS', '.DS_Store'));
     $files = array_filter($files, create_function('$file', 'return preg_match("#(\\.bmp|\\.gif|\\.jpg|\\.jpeg|\\.png)$#i", $file);'));
     // set default thumbnail size, if incorrect sizes defined
     $width = intval($width);
     $height = intval($height);
     if ($width < 1 && $height < 1) {
         $width = 100;
         $height = null;
     }
     foreach ($files as $file) {
         $filename = basename($file);
         $thumb = ZooHelper::resizeImage($file, $width, $height);
         // if thumbnail exists, add it to return value
         if (is_file($thumb)) {
             // set image name or title if exsist
             if ($title != '') {
                 $name = $title;
             } else {
                 $name = JFile::stripExt($filename);
                 $name = JString::str_ireplace('_', ' ', $name);
                 $name = JString::ucwords($name);
             }
             // get image info
             list($thumb_width, $thumb_height) = @getimagesize($thumb);
             $thumbs[] = array('name' => $name, 'filename' => $filename, 'img' => $this->_uri . $this->_getRelativePath($file), 'img_file' => $file, 'thumb' => $this->_uri . $this->_getRelativePath($thumb), 'thumb_width' => $thumb_width, 'thumb_height' => $thumb_height);
         }
     }
     return $thumbs;
 }