Changeset 1144

Show
Ignore:
Timestamp:
06/12/2008 07:45:58 AM (2 years ago)
Author:
DotMG
Message:

refs #776

Renaming LoadWantedPages2 to LoadWantedPages

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/actions/wantedpages/wantedpages.php

    r1132 r1144  
    2828 * @uses        Wakka::Link() 
    2929 * @uses        Wakka::LoadWantedPages() 
    30  * @uses        Wakka::LoadWantedPages2() 
    3130 * @uses        Wakka::FormOpen() 
    3231 * @uses        Wakka::FormClose() 
     
    3635 
    3736$sorting_fields = array('count', 'time', 'page_tag'); 
    38 if ((isset($vars) && is_array($vars) && isset($vars['option']) && $vars['option'] == 'v2') || (isset($_GET['ob1']))) 
     37$sort = ''; 
     38for ($i = 1; $i <= 3; $i ++) 
    3939{ 
    40         $sort = ''; 
    41         for ($i = 1; $i <= 3; $i ++) 
     40        if (isset($_GET['ob'.$i])) 
    4241        { 
    43                 if (isset($_GET['ob'.$i])) 
     42                if (in_array($_GET['ob'.$i], $sorting_fields)) 
    4443                { 
    45                         if (in_array($_GET['ob'.$i], $sorting_fields)) 
     44                        if ($sort) 
    4645                        { 
    47                                 if ($sort) 
    48                                 { 
    49                                         $sort .= ','; 
    50                                 } 
    51                                 $sort .= $_GET['ob'.$i].' '; 
    52                                 if (isset($_GET['de'.$i])) 
    53                                 { 
    54                                         $sort .= 'desc'; 
    55                                 } 
     46                                $sort .= ','; 
    5647                        } 
    57                 } 
    58         } 
    59         // @@@ really use this if all sort params are empty? You get 
    60         // different output that way than from the first time without sorting, which is confusing 
    61         if ($pages = $this->LoadWantedPages2($sort))    // @@@ array -> list 
    62         { 
    63                 foreach ($pages as $page) 
    64                 { 
    65                         print($this->Link($page['page_tag'])); 
    66                         if ($page['count'] > 1) 
     48                        $sort .= $_GET['ob'.$i].' '; 
     49                        if (isset($_GET['de'.$i])) 
    6750                        { 
    68                                 print(' (<a href="'.$this->Href('backlinks', $page['page_tag']).'" title="'.sprintf(WIKKA_BACKLINKS_LINK_TITLE, $page['page_tag']).'">'.$page['count']."</a>)<br />\n"); 
    69                         } 
    70                         else 
    71                         { 
    72                                 preg_match('#/(.*)$#', $page['time'], $match); 
    73                                 $pagetime = $match[1]; 
    74                                 print(' (1 : '.$this->Link($pagetime).' <small>['.$this->Link($pagetime, 'edit', WIKKA_PAGE_EDIT_LINK_DESC, FALSE, TRUE, sprintf(WIKKA_PAGE_EDIT_LINK_TITLE, $pagetime))."]</small>)<br />\n"); 
     51                                $sort .= 'desc'; 
    7552                        } 
    7653                } 
    7754        } 
    7855} 
    79 elseif ($pages = $this->LoadWantedPages()) 
     56if ($pages = $this->LoadWantedPages($sort))     // @@@ array -> list 
    8057{ 
    81         // @@@ use array -> list 
    8258        foreach ($pages as $page) 
    8359        { 
    84                 print($this->Link($page['page_tag']).' (<a href="'.$this->Href('backlinks', $page['page_tag']).'" title="'.sprintf(WIKKA_BACKLINKS_LINK_TITLE, $page['page_tag']).'">'.$page['count']."</a>)<br />\n"); 
     60                print($this->Link($page['page_tag'])); 
     61                if ($page['count'] > 1) 
     62                { 
     63                        print(' (<a href="'.$this->Href('backlinks', $page['page_tag']).'" title="'.sprintf(WIKKA_BACKLINKS_LINK_TITLE, $page['page_tag']).'">'.$page['count']."</a>)<br />\n"); 
     64                } 
     65                else 
     66                { 
     67                        preg_match('#/(.*)$#', $page['time'], $match); 
     68                        $pagetime = $match[1]; 
     69                        print(' (1 : '.$this->Link($pagetime).' <small>['.$this->Link($pagetime, 'edit', WIKKA_PAGE_EDIT_LINK_DESC, FALSE, TRUE, sprintf(WIKKA_PAGE_EDIT_LINK_TITLE, $pagetime))."]</small>)<br />\n"); 
     70                } 
    8571        } 
    86 } 
    87 if ($pages) 
    88 { 
     72 
    8973        // adding form to control sorting 
    9074        $options = '<option value="">&nbsp;</option>'; 
  • trunk/libs/Wakka.class.php

    r1130 r1144  
    16911691         * @uses        Wakka::LoadAll() 
    16921692         * 
    1693          * @param       string  $sort   Sorting needed: Legal SQL expression after ORDER BY clause. Field names are count, time and tag. 
     1693         * @param       string  $sort   Sorting needed: Legal SQL expression after ORDER BY clause. Field names are count, time and page_tag. 
    16941694         * @return      array 
    16951695         * @todo        it would be useful to set a LIMIT ($max) here as well 
    16961696         */ 
    1697         function LoadWantedPages2($sort='') 
     1697        function LoadWantedPages($sort='') 
    16981698        { 
    16991699#echo 'sort: '.$sort."<br/>\n"; 
     
    17171717                        GROUP BY page_tag 
    17181718                        ORDER BY ".$sort 
    1719                         ); 
    1720                 return $pages; 
    1721         } 
    1722         /** 
    1723          * Load pages that need to be created. 
    1724          * 
    1725          * @access      public 
    1726          * @uses        Wakka::GetConfigValue() 
    1727          * @uses        Wakka::LoadAll() 
    1728          * 
    1729          * @param       string $sort Sorting needed: Legal SQL expression after ORDER BY clause. Field names are count, time and tag. 
    1730          * @return      array 
    1731          * @todo        it would be useful to set a LIMIT ($max) here as well 
    1732          */ 
    1733         function LoadWantedPages()              // #410 
    1734         { 
    1735                 $pre = $this->GetConfigValue('table_prefix'); 
    1736                 $pages = $this->LoadAll(" 
    1737                         SELECT DISTINCT ". 
    1738                                 $pre."links.to_tag AS page_tag, 
    1739                                 COUNT(".$pre."links.from_tag) AS count 
    1740                         FROM ".$pre."links 
    1741                         LEFT JOIN ".$pre."pages 
    1742                                 ON ".$pre."links.to_tag = ".$pre."pages.tag 
    1743                         WHERE ".$pre."pages.tag IS NULL 
    1744                         GROUP BY page_tag 
    1745                         ORDER BY count DESC" 
    17461719                        ); 
    17471720                return $pages;