コード例 #1
0
function igalleryBuildRoute(&$query)
{
    $segments = array();
    $catIdOfActive = 0;
    if (isset($query['view']) && isset($query['igid'])) {
        if ($query['view'] == 'category') {
            if (isset($query['Itemid'])) {
                $app = JFactory::getApplication();
                $menu = $app->getMenu();
                $activeMenu = $menu->getItem($query['Itemid']);
                if (isset($activeMenu->query['igid'])) {
                    $catIdOfActive = $activeMenu->query['igid'];
                }
            }
            $categories = igStaticHelper::getCategories();
            $parents = igTreeHelper::getParentPath($categories, $query['igid'], true);
            foreach ($parents as $parent) {
                if ($parent->id != $catIdOfActive) {
                    array_unshift($segments, $parent->alias);
                } else {
                    break;
                }
            }
            unset($query['view']);
            unset($query['igid']);
        }
    }
    return $segments;
}
コード例 #2
0
 protected function getInput()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_igallery/helpers/tree.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_igallery/helpers/static.php';
     $option = JRequest::getVar('option');
     $hideCurrent = false;
     if ($option == 'com_config') {
         $params = JComponentHelper::getParams('com_igallery');
         $selected = $params->get('default_parent', 0);
     } else {
         if ($option == 'com_menus') {
             $selected = $this->value;
         } else {
             if (strpos($option, 'module')) {
                 $igparams = $this->form->getValue('params');
                 $selected = isset($igparams->category_id) ? $igparams->category_id : 0;
             } else {
                 $selected = $this->form->getValue('parent');
                 $hideCurrent = true;
             }
         }
     }
     $categories = igStaticHelper::getCategories();
     $categoriesbyTree = igTreeHelper::makeCategoryTree($categories);
     if ($hideCurrent) {
         $current = JRequest::getInt('id', 0);
         $categoriesbyTree = igTreeHelper::removeFromTree($categoriesbyTree, 'id', $current, 'numeric-exist');
     }
     if ($option == 'com_igallery' && JRequest::getVar('view') == 'icategory' && JRequest::getInt('id', 0) > 0) {
         $children = igTreeHelper::getChildIds($categories, JRequest::getInt('id', 0));
         if (count($children) > 0) {
             foreach ($children as $child) {
                 $categoriesbyTree = igTreeHelper::removeFromTree($categoriesbyTree, 'id', $child, 'numeric-exist');
             }
         }
     }
     $selectItems = array();
     if ($option != 'com_menus' && !strpos($option, 'module') && JRequest::getVar('view') != 'editorbutton') {
         $selectItems[] = JHTML::_('select.option', '0', JText::_('JGLOBAL_TOP'));
     }
     foreach ($categoriesbyTree as $category) {
         $displayName = $category->name;
         for ($k = 0; $k < $category->level; $k++) {
             $displayName = ' - ' . $displayName;
         }
         $selectItems[] = JHTML::_('select.option', $category->id, $displayName);
     }
     $selectHTML = JHTML::_("select.genericlist", $selectItems, $this->name, 'class="inputbox" size="14"', 'value', 'text', $selected);
     return $selectHTML;
 }
コード例 #3
0
 function getItems()
 {
     $db = $this->getDbo();
     $query = $this->getListQuery();
     $user = JFactory::getUser();
     $db->setQuery($query);
     $categories = $db->loadObjectList();
     $categoriesbyTree = igTreeHelper::makeCategoryTree($categories);
     $search = JString::strtolower($this->getState('filter.search'));
     if ($search) {
         $categoriesbyTree = igTreeHelper::removeFromTree($categoriesbyTree, 'name', $search, 'string-not-exist');
     }
     $filter_state = $this->getState('filter.published');
     if (is_numeric($filter_state)) {
         $categoriesbyTree = igTreeHelper::removeFromTree($categoriesbyTree, 'published', $filter_state, 'numeric-not-exist');
     }
     if (JFactory::getApplication()->isSite()) {
         foreach ($categoriesbyTree as $key => $category) {
             $catStateUsed = false;
             $catDeleteUsed = false;
             $editOk = igGeneralHelper::authorise('core.igalleryfront.edit', $category->id, null, $category->profile, $category->user);
             $editStateOk = igGeneralHelper::authorise('core.igalleryfront.edit.state', $category->id, null, $category->profile, $category->user);
             $deleteOk = igGeneralHelper::authorise('core.igalleryfront.delete', $category->id, null, $category->profile, $category->user);
             $uploadOk = igGeneralHelper::authorise('core.igalleryfront.upload', $category->id, null, $category->profile, $category->user);
             $editImageOk = igGeneralHelper::authorise('core.igalleryfront.editimage', $category->id, null, $category->profile, $category->user);
             $deleteImageOk = igGeneralHelper::authorise('core.igalleryfront.deleteimage', $category->id, null, $category->profile, $category->user);
             $editImageStateOk = igGeneralHelper::authorise('core.igalleryfront.editimage.state', $category->id, null, $category->profile, $category->user);
             $category->manage = false;
             if ($uploadOk || $editImageOk || $deleteImageOk || $editImageStateOk) {
                 $category->manage = true;
             }
             if ($editStateOk && $catStateUsed == false) {
                 JRequest::setVar('igCatStateUsed', 1);
                 $catStateUsed = true;
             }
             if ($deleteOk && $catDeleteUsed == false) {
                 JRequest::setVar('igCatDeleteUsed', 1);
                 $catDeleteUsed = true;
             }
             if (!$editOk && !$editStateOk && !$deleteOk && !$uploadOk && !$editImageOk && !$deleteImageOk && !$editImageStateOk) {
                 unset($categoriesbyTree[$key]);
             }
         }
     }
     $orderedCategories = array_values($categoriesbyTree);
     $limit = $this->getState('list.limit') == 0 ? 1000 : $this->getState('list.limit');
     $slicedCategories = array_slice($orderedCategories, $this->getState('list.start'), $limit);
     return $slicedCategories;
 }
コード例 #4
0
 static function getCategorySelect($name, $key, $value, $exclude, $selectText, $size, $submit, $active)
 {
     $categories = igStaticHelper::getCategories();
     $categoriesbyTree = igTreeHelper::makeCategoryTree($categories);
     if (!empty($exclude)) {
         $categoriesbyTree = igTreeHelper::removeFromTree($categoriesbyTree, 'id', $exclude, 'numeric-exist');
     }
     $selectOptions = array();
     if ($selectText) {
         $selectOptions[] = JHTML::_('select.option', '0', JText::_('JOPTION_SELECT_CATEGORY'), $key, $value);
     }
     foreach ($categoriesbyTree as $category) {
         $displayName = $category->name;
         for ($k = 0; $k < $category->level; $k++) {
             $displayName = ' - ' . $displayName;
         }
         $selectOptions[] = JHTML::_('select.option', $category->id, $displayName, $key, $value);
     }
     $html = 'class="inputbox" size="' . $size . '" ';
     $javascript = $submit == true ? 'onchange="document.adminForm.submit();"' : '';
     $parentSelectList = JHTML::_("select.genericlist", $selectOptions, $name, $html . $javascript, $key, $value, $active);
     return $parentSelectList;
 }
コード例 #5
0
 static function buildParentPath($categoriesById, $childId, $parents)
 {
     foreach ($categoriesById as $category) {
         if ($category->id == $childId) {
             if ($category->parent != 0) {
                 $parents[] = $categoriesById[$category->parent];
                 $parents = igTreeHelper::buildParentPath($categoriesById, $category->parent, $parents);
             }
         }
     }
     return $parents;
 }
コード例 #6
0
 function getChildIds($parentId)
 {
     $categories = igStaticHelper::getCategories();
     $childIds = igTreeHelper::getChildIds($categories, $parentId);
     return $childIds;
 }
コード例 #7
0
                ?>
                <?php 
                if ($row->numimages > 0) {
                    ?>
                    <div class="menu_text_block menu_text_block_num"><?php 
                    echo $row->numimages;
                    ?>
 <?php 
                    echo JText::_('IMAGES');
                    ?>
</div>
                <?php 
                } else {
                    ?>
                    <?php 
                    $childCategories = igTreeHelper::getChildIds($allCategories, $row->id);
                    ?>
                    <?php 
                    if (count($childCategories) > 0) {
                        ?>
                        <?php 
                        $categoryText = count($childCategories) > 1 ? JText::_('COM_IGALLERY_CATEGORIES') : JText::_('JCATEGORY');
                        ?>
                        <div class="menu_text_block menu_text_block_child"><?php 
                        echo count($childCategories);
                        ?>
 <?php 
                        echo $categoryText;
                        ?>
</div>
                    <?php 
コード例 #8
0
 static function getItemid($catId)
 {
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     $menuItems = $menu->getMenu();
     $categories = igStaticHelper::getCategories();
     $parents = igTreeHelper::getParentPath($categories, $catId, false);
     foreach ($menuItems as $menu) {
         if ($menu->component == 'com_igallery' && $menu->query['view'] == 'category' && $menu->query['igid'] == $catId) {
             return $menu->id;
         }
     }
     foreach ($menuItems as $menu) {
         if ($menu->component == 'com_igallery' && $menu->query['view'] == 'category') {
             foreach ($parents as $parent) {
                 if ($parent->id == $menu->query['igid']) {
                     return $menu->id;
                 }
             }
         }
     }
     return JRequest::getVar('Itemid', 1);
 }