Пример #1
0
function DocmanBuildRoute(&$query)
{
    jimport('joomla.filter.output');
    $segments = array();
    // check for task=...
    if (!isset($query['task'])) {
        return $segments;
    }
    $segments[] = $query['task'];
    // check for gid=...
    $gid = isset($query['gid']) ? $query['gid'] : 0;
    if (in_array($query['task'], array('cat_view', 'upload'))) {
        // create the category slugs
        $cats =& DOCMAN_Cats::getCategoryList();
        $cat_slugs = array();
        while ($gid and isset($cats[$gid])) {
            $cat_slugs[] = $gid . ':' . JFilterOutput::stringURLSafe($cats[$gid]->name);
            $gid = $cats[$gid]->parent_id;
        }
        $segments = array_merge($segments, array_reverse($cat_slugs));
    } else {
        // create the document slug
        $doc = DocmanRouterHelper::getDoc($gid);
        if ($doc->id) {
            $segments[] = $gid . ':' . JFilterOutput::stringURLSafe($doc->dmname);
        }
    }
    unset($query['gid']);
    unset($query['task']);
    return $segments;
}
Пример #2
0
 function &getInstance($id = 0)
 {
     global $database;
     static $instances = array();
     if (!$id) {
         $new = new mosDMCategory($database);
         return $new;
     }
     if (!isset($instances[$id])) {
         $instances[$id] = new mosDMCategory($database);
         //$instances[$id]->load( $id );
         // instead of loading, we'll use the the following method to improve performance
         $list =& DOCMAN_Cats::getCategoryList();
         // get a list of categories, $list[$id] is our current category
         $instances[$id]->bind((array) $list[$id]);
         // assign each property of the category to the category object
     }
     return $instances[$id];
 }