Ejemplo n.º 1
0
    public function getPagesModel()
    {
        if (!self::$_pages_model) {
            self::$_pages_model = $this->getObject('com://admin/docman.model.pages');

            $view = $this->getObject('request')->query->view;
            if (JFactory::getApplication()->isAdmin() || $view === 'doclink' || $view === 'documents') {
                self::$_pages_model->language('all');
            }
        }

        return self::$_pages_model;
    }
Ejemplo n.º 2
0
 /**
  * Get a list of categories that are reachable by a list view page
  *
  * @return array
  */
 protected function _getCategories()
 {
     if (self::$_categories === null) {
         $table = $this->getObject('com://admin/docman.database.table.categories');
         $query = $this->getObject('lib:database.query.select');
         // Gather the category slugs of active pages
         $category_slugs = array();
         $pages = $this->_getPages();
         foreach ($pages as $page) {
             if (isset($page->query['view']) && $page->query['view'] === 'list' && isset($page->query['slug'])) {
                 $category_slugs[] = $page->query['slug'];
             }
         }
         // Get a list of categories and their children
         if ($category_slugs) {
             $query->columns('tbl.slug, r.ancestor_id, r.descendant_id')->table(array('r' => $table->getBehavior('nestable')->getRelationTable()))->join(array('tbl' => $table->getName()), 'tbl.docman_category_id = r.ancestor_id')->where('tbl.slug IN :slug')->bind(array('slug' => (array) $category_slugs));
             self::$_categories = $table->getAdapter()->select($query, KDatabase::FETCH_OBJECT_LIST);
         } else {
             self::$_categories = array();
         }
     }
     return self::$_categories;
 }
Ejemplo n.º 3
0
    /**
     * Finds the first available page for a row
     *
     * If the $row is a document, it will look for a document page first
     * before looking at list view pages.
     *
     * @param KDatabaseRowInterface $row
     *
     * @return int
     */
    protected function _findPage(KDatabaseRowInterface $row)
    {
        $itemid = 0;
        $key = $row->docman_category_id ? $row->docman_category_id : $row->id;

        if ($row instanceof ComDocmanDatabaseRowDocument)
        {
            $document_pages = self::$_pages_model->reset()->view('document')->getList();
            foreach ($document_pages as $page)
            {
                if (!empty($this->_state->page) && !in_array($page->id, (array) $this->_state->page)) {
                    continue;
                }

                if (isset($page->query['slug']) && $row->slug === $page->query['slug']) {
                    $itemid = $page->id;
                    break;
                }
            }
        }

        if (!$itemid)
        {
            $category_pages = $this->_getCategoryPages();
            foreach ($category_pages as $page)
            {
                if (!empty($this->_state->page) && !in_array($page->id, (array) $this->_state->page)) {
                    continue;
                }

                if (in_array($key, $page->children)) {
                    $itemid = $page->id;
                    break;
                }
            }
        }

        if (!$itemid && $row instanceof ComDocmanDatabaseRowDocument)
        {
            $documents_pages = self::$_pages_model->reset()->view('filteredlist')->getList();
            foreach ($documents_pages as $page)
            {
                if (!empty($this->_state->page) && !in_array($page->id, (array) $this->_state->page)) {
                    continue;
                }

                $categories = (array) $page->params->get('category');
                $created_by = (array) $page->params->get('created_by');

                if ((empty($categories) || in_array($key, $categories))
                    && (empty($created_by) || in_array($row->created_by, $created_by))
                ) {
                    $itemid = $page->id;
                    break;
                }
            }
        }

        if (!$itemid)
        {
            foreach ($this->_getCategoriesPages() as $page)
            {
                $itemid = $page->id;
                break;
            }
        }

        return $itemid;
    }
Ejemplo n.º 4
0
    /**
     * Get a list of categories that are reachable by a list view page
     *
     * @return array
     */
    protected function _getCategories()
    {
        if (self::$_categories === null)
        {
            $table = clone $this->getService('com://admin/docman.database.table.categories');
            $query = $table->getDatabase()->getQuery();

            // Gather the category slugs of active pages
            $category_slugs = array();
            $pages          = $this->_getPages();
            foreach ($pages as $page)
            {
                if ($page->query['view'] === 'list') {
                    $category_slugs[] = $page->query['slug'];
                }
            }

            // Get a list of categories and their children
            if ($category_slugs)
            {
                $query->select('tbl.slug, r.ancestor_id, r.descendant_id')
                    ->from($table->getRelationTable().' AS r')
                    ->join('left', $table->getName().' AS tbl', 'tbl.docman_category_id = r.ancestor_id')
                    ->where('tbl.slug', 'IN', $category_slugs);

                self::$_categories = $table->getDatabase()->select($query, KDatabase::FETCH_OBJECT_LIST);
            }
            else self::$_categories = array();
        }

        return self::$_categories;
    }