public function test_ns_sort()
 {
     $this->assertEquals($this->pages, $this->extract_ids($this->helper->getTopic('', null, 'mytag')));
 }
Example #2
0
 /**
  * Gives a list of pages for a given include statement
  *
  * @author Michael Hamann <*****@*****.**>
  */
 function _get_included_pages($mode, $page, $sect, $parent_id, $flags)
 {
     global $conf;
     $pages = array();
     switch ($mode) {
         case 'namespace':
             $page = cleanID($page);
             $ns = utf8_encodeFN(str_replace(':', '/', $page));
             // depth is absolute depth, not relative depth, but 0 has a special meaning.
             $depth = $flags['depth'] ? $flags['depth'] + substr_count($page, ':') + ($page ? 1 : 0) : 0;
             search($pagearrays, $conf['datadir'], 'search_allpages', array('depth' => $depth), $ns);
             if (is_array($pagearrays)) {
                 foreach ($pagearrays as $pagearray) {
                     if (!isHiddenPage($pagearray['id'])) {
                         // skip hidden pages
                         $pages[] = $pagearray['id'];
                     }
                 }
             }
             break;
         case 'tagtopic':
             if (!$this->taghelper) {
                 $this->taghelper =& plugin_load('helper', 'tag');
             }
             if (!$this->taghelper) {
                 msg('You have to install the tag plugin to use this functionality!', -1);
                 return array();
             }
             $tag = $page;
             $sect = '';
             $pagearrays = $this->taghelper->getTopic('', null, $tag);
             foreach ($pagearrays as $pagearray) {
                 $pages[] = $pagearray['id'];
             }
             break;
         default:
             $page = $this->_apply_macro($page);
             resolve_pageid(getNS($parent_id), $page, $exists);
             // resolve shortcuts and clean ID
             if (auth_quickaclcheck($page) >= AUTH_READ) {
                 $pages[] = $page;
             }
     }
     if (count($pages) > 1) {
         if ($flags['order'] === 'id') {
             if ($flags['rsort']) {
                 usort($pages, array($this, '_r_strnatcasecmp'));
             } else {
                 natcasesort($pages);
             }
         } else {
             $ordered_pages = array();
             foreach ($pages as $page) {
                 $key = '';
                 switch ($flags['order']) {
                     case 'title':
                         $key = p_get_first_heading($page);
                         break;
                     case 'created':
                         $key = p_get_metadata($page, 'date created', METADATA_DONT_RENDER);
                         break;
                     case 'modified':
                         $key = p_get_metadata($page, 'date modified', METADATA_DONT_RENDER);
                         break;
                     case 'indexmenu':
                         $key = p_get_metadata($page, 'indexmenu_n', METADATA_RENDER_USING_SIMPLE_CACHE);
                         if ($key === null) {
                             $key = '';
                         }
                         break;
                     case 'custom':
                         $key = p_get_metadata($page, 'include_n', METADATA_RENDER_USING_SIMPLE_CACHE);
                         if ($key === null) {
                             $key = '';
                         }
                         break;
                 }
                 $key .= '_' . $page;
                 $ordered_pages[$key] = $page;
             }
             if ($flags['rsort']) {
                 uksort($ordered_pages, array($this, '_r_strnatcasecmp'));
             } else {
                 uksort($ordered_pages, 'strnatcasecmp');
             }
             $pages = $ordered_pages;
         }
     }
     $result = array();
     foreach ($pages as $page) {
         $exists = page_exists($page);
         $result[] = array('id' => $page, 'exists' => $exists, 'parent_id' => $parent_id);
     }
     return $result;
 }
Example #3
0
 /**
  * Returns the sorted tag cloud array
  */
 function _getTagCloud($num, &$min, &$max, $namespaces = NULL, helper_plugin_tag &$tag)
 {
     $cloud = $tag->tagOccurrences(NULL, $namespaces, true, $this->getConf('list_tags_of_subns'));
     $this->_removeFromCloud($cloud, 'tag_blacklist');
     return $this->_sortCloud($cloud, $num, $min, $max);
 }