示例#1
0
 public function display($tpl = null)
 {
     // Automatically fetch the item and assign it to the layout
     $this->fetchItem();
     // Common lists
     $parent_id_params = array('nullvalue' => 1, 'nulltitle' => JText::_('No parent'), 'current' => $this->item->parent_id, 'self' => $this->item->id);
     $this->lists['parent_id'] = SimplelistsHTML::selectCategories('parent_id', $parent_id_params);
     // Construct the modal boxes
     $modal = array();
     //$modal['image'] = 'index.php?option=com_simplelists&view=files&tmpl=component&type=picture' ;
     //$modal['image'] .= ($this->item->image) ? '&folder=/'.dirname($this->item->image).'&current='.$this->item->image : '&current=';
     $this->assignRef('modal', $modal);
     // Construct the slider-panel
     jimport('joomla.html.pane');
     $pane =& JPane::getInstance('sliders');
     $this->assignRef('pane', $pane);
     // Add jQuery
     if (JFactory::getApplication()->get('jquery') == false) {
         $this->addJs('jquery.js');
         JFactory::getApplication()->set('jquery', true);
     }
     // Add extra JavaScript
     JHTML::_('behavior.formvalidation');
     $this->addJs('form-validation.js');
     parent::display($tpl);
 }
示例#2
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     if (!empty($control_name)) {
         $fieldName = $control_name . '[' . $name . ']';
     } else {
         $fieldName = $name;
     }
     $categories_params = array('current' => $value, 'nullvalue' => 1);
     return SimplelistsHTML::selectCategories($fieldName, $categories_params);
 }
示例#3
0
 public function display($tpl = null)
 {
     // Give a warning if no categories are configured
     SimplelistsHelper::checkCategories();
     // Fetch the item automatically
     $this->fetchItem(true);
     // Modify the item a bit
     $this->item->image_default_folder = COM_SIMPLELISTS_DIR;
     $this->item->image_default_uri = COM_SIMPLELISTS_BASEURL;
     $this->item->picture_folder = $this->item->image_default_folder;
     $this->item->picture_uri = $this->item->image_default_uri;
     $this->item->picture_path = null;
     if (!empty($this->item->picture)) {
         $this->item->picture_path = JPATH_SITE . DS . $this->item->picture;
         $this->item->picture_uri = str_replace(DS, '/', $this->item->picture);
         $this->item->picture_folder = dirname($this->item->picture_uri);
     }
     // Add extra filtering lists
     $defaultCategory = $this->item->id == 0 ? (int) $this->getFilter('category_id', null, null, 'com_simplelists_items_') : null;
     $categories_params = array('item_id' => $this->item->id, 'multiple' => 1, 'current' => $defaultCategory);
     $this->lists['categories'] = SimplelistsHTML::selectCategories('categories[]', $categories_params);
     // Construct the modal boxes
     $modal = array();
     $modal['picture'] = 'index.php?option=com_simplelists&view=files&tmpl=component&type=picture&current=' . $this->item->picture;
     if ($this->item->picture) {
         $modal['picture'] .= '&folder=' . $this->item->picture_folder;
     }
     $this->assignRef('modal', $modal);
     // Construct the slider-panel
     jimport('joomla.html.pane');
     $pane =& JPane::getInstance('sliders');
     $this->assignRef('pane', $pane);
     // Include extra JavaScript
     $this->addJs('mootools-cookie.js');
     $this->addJs('view-browser.js');
     // Load the plugins
     $link_plugins = SimplelistsPluginHelper::getPlugins('simplelistslink');
     $this->assignRef('link_plugins', $link_plugins);
     // Add extra stuff
     JHTML::_('behavior.tooltip');
     JHTML::_('behavior.modal', 'a.modal-button');
     parent::display($tpl);
 }
示例#4
0
 public function display($tpl = null)
 {
     // Set extra toolbar items for the page
     JToolBarHelper::preferences('com_simplelists', '480');
     //JToolBarHelper::help( 'screen.simplelist' );
     // Preliminary check to see if any categories have been configured yet
     SimplelistsHelper::checkCategories();
     // Automatically fetch items, total and pagination - and assign them to the template
     $this->fetchItems();
     // Prepare data for each simplelists item
     foreach ($this->items as $index => $item) {
         $item->categories = SimplelistsHelper::getCategories($item->id);
         $item->edit_link = JRoute::_('index.php?option=com_simplelists&view=item&task=edit&cid[]=' . $item->id);
         $this->items[$index] = $item;
     }
     // build list of categories
     $category_id_params = array('current' => $this->getFilter('category_id'), 'javascript' => 1, 'nullvalue' => 1);
     $this->lists['category_id'] = SimplelistsHTML::selectCategories('filter_category_id', $category_id_params);
     $this->lists['link_type'] = SimplelistsHTML::selectLinkType($this->getFilter('link_type'));
     parent::display($tpl);
 }
示例#5
0
 /**
  * Method to parse a list of categories into a HTML selectbox
  *
  * @access    public
  * @param    int ID of current item 
  * @param    int ID of parent category
  * @return    string HTML output
  */
 public function selectCategories($name = '', $params = array())
 {
     // Fetch all categories
     $parent_id = isset($params['parent_id']) ? $params['parent_id'] : null;
     $categories = SimplelistsHTML::getCategories($parent_id);
     // Remove the current category
     if (isset($params['self'])) {
         foreach ($categories as $index => $category) {
             if ($category->id == $params['self']) {
                 unset($categories[$index]);
                 break;
             }
         }
     }
     // If the $item_id is set, find all the current categories for a SimpleLists item
     $current = isset($params['item_id']) ? SimplelistsHTML::getCurrentCategory($categories, $params['item_id']) : null;
     $current = isset($params['current']) ? $params['current'] : $current;
     // If no current is set, and if the count of categories is 1, select the first category list
     if (empty($current) && count($categories) == 1) {
         $current = $categories[0]->id;
     }
     // Define extra HTML-arguments
     $extra = '';
     // If $multiple is true, we assume we're in the Item Edit form
     if (isset($params['multiple']) && $params['multiple'] == 1) {
         $size = count($categories) < 10 ? count($categories) : 10;
         $extra .= 'size="' . $size . '" multiple';
     }
     // If $none is true, we include an extra option
     if (isset($params['nullvalue']) && $params['nullvalue'] == 1) {
         $nulltitle = isset($params['nulltitle']) ? $params['nulltitle'] : JText::_('COM_SIMPLELISTS_SELECT_CATEGORY');
         array_unshift($categories, JHTML::_('select.option', 0, '- ' . $nulltitle . ' -', 'id', 'title'));
     }
     // If $javascript is true, we submit the form as soon as an option has been selected
     if (isset($params['javascript']) && $params['javascript'] == 1) {
         $extra .= 'onchange="document.adminForm.submit();"';
     }
     return JHTML::_('select.genericlist', $categories, $name, $extra, 'id', 'title', $current);
 }
示例#6
0
 protected function getInput()
 {
     $categories_params = array('current' => $this->value, 'nullvalue' => 1);
     return SimplelistsHTML::selectCategories($this->name, $categories_params);
 }
示例#7
0
 public function _prepareItem($item, $layout)
 {
     // Get system variables
     $user =& JFactory::getUser();
     $dispatcher =& JDispatcher::getInstance();
     $params = $this->params;
     // Run the content through Content Plugins
     if ($item->params->get('enable_content_plugins', 1) == 1) {
         JPluginHelper::importPlugin('content');
         $iparams = array();
         $results = $dispatcher->trigger('onPrepareContent', array(&$item, &$iparams, 0));
     }
     // Disable the text when needed
     if ($item->params->get('show_item_text', 1) == 0) {
         $item->text = null;
     }
     // Prepare the URL
     $item->url = JRoute::_(SimplelistsPluginHelper::getPluginLinkUrl($item));
     if ($item->alias) {
         $item->href = $item->alias;
     } else {
         $item->href = 'item' . $item->id;
     }
     // Create a simple target-string
     switch ($item->params->get('target')) {
         case 1:
             $item->target = ' target="_blank"';
             break;
         case 2:
             $item->target = ' onclick="javascript: window.open(\'' . $item->url . '\', \'\', \'toolbar=no,location=no,status=no,' . 'menubar=no,scrollbars=yes,resizable=yes,width=780,height=550\'); return false"';
             break;
         default:
             $item->target = false;
             break;
     }
     // Set the readmore link for this item
     if ($item->params->get('readmore') == 1 && $item->url) {
         $readmore_text = $item->params->get('readmore_text', JText::sprintf('Read more', $item->title));
         $readmore_css = trim('readon ' . $item->params->get('readmore_class', ''));
         $item->readmore = JHTML::link($item->url, $readmore_text, 'title="' . $item->title . '" class="' . $readmore_css . '"' . $item->target);
     } else {
         $item->readmore = null;
     }
     // Set the image-alignment for this item
     if ($item->params->get('picture_alignment') != '' && $layout != 'picture') {
         $item->picture_alignment = ' align="' . $item->params->get('picture_alignment') . '"';
     } else {
         $item->picture_alignment = null;
     }
     // Prepare the image
     if ($item->params->get('show_item_image', 1) && !empty($item->picture)) {
         $attributes = 'title="' . $item->title . '" class="simplelists"' . $item->picture_alignment;
         $item->picture = SimplelistsHTML::image($item->picture, $item->title, $attributes);
     } else {
         $item->picture = null;
     }
     // Prepare the title
     if ($item->params->get('show_item_title', 1)) {
         if ($item->params->get('title_link') && !empty($item->url)) {
             $item->title = JHTML::link($item->url, $item->title, $item->target);
         }
     } else {
         $item->title = null;
     }
     // Set specific layout settings
     $item->style = '';
     if ($layout == 'select' || $layout == 'hover') {
         if (empty($firstflag)) {
             static $firstflag = 1;
             $item->style = 'display:block; visibility:visible;';
         }
     }
     // Enable parsing the content
     JPluginHelper::importPlugin('content');
     $results = $dispatcher->trigger('onBeforeDisplayContent', array(&$item, &$item->params, 0));
     foreach ($results as $result) {
         if (!empty($result)) {
             $item->text .= $result;
         }
     }
     return $item;
 }