Changeset 1144
- Timestamp:
- 06/12/2008 07:45:58 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
actions/wantedpages/wantedpages.php (modified) (2 diffs)
-
libs/Wakka.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/actions/wantedpages/wantedpages.php
r1132 r1144 28 28 * @uses Wakka::Link() 29 29 * @uses Wakka::LoadWantedPages() 30 * @uses Wakka::LoadWantedPages2()31 30 * @uses Wakka::FormOpen() 32 31 * @uses Wakka::FormClose() … … 36 35 37 36 $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 = ''; 38 for ($i = 1; $i <= 3; $i ++) 39 39 { 40 $sort = ''; 41 for ($i = 1; $i <= 3; $i ++) 40 if (isset($_GET['ob'.$i])) 42 41 { 43 if (i sset($_GET['ob'.$i]))42 if (in_array($_GET['ob'.$i], $sorting_fields)) 44 43 { 45 if ( in_array($_GET['ob'.$i], $sorting_fields))44 if ($sort) 46 45 { 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 .= ','; 56 47 } 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])) 67 50 { 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'; 75 52 } 76 53 } 77 54 } 78 55 } 79 elseif ($pages = $this->LoadWantedPages()) 56 if ($pages = $this->LoadWantedPages($sort)) // @@@ array -> list 80 57 { 81 // @@@ use array -> list82 58 foreach ($pages as $page) 83 59 { 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 } 85 71 } 86 } 87 if ($pages) 88 { 72 89 73 // adding form to control sorting 90 74 $options = '<option value=""> </option>'; -
trunk/libs/Wakka.class.php
r1130 r1144 1691 1691 * @uses Wakka::LoadAll() 1692 1692 * 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. 1694 1694 * @return array 1695 1695 * @todo it would be useful to set a LIMIT ($max) here as well 1696 1696 */ 1697 function LoadWantedPages 2($sort='')1697 function LoadWantedPages($sort='') 1698 1698 { 1699 1699 #echo 'sort: '.$sort."<br/>\n"; … … 1717 1717 GROUP BY page_tag 1718 1718 ORDER BY ".$sort 1719 );1720 return $pages;1721 }1722 /**1723 * Load pages that need to be created.1724 *1725 * @access public1726 * @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 array1731 * @todo it would be useful to set a LIMIT ($max) here as well1732 */1733 function LoadWantedPages() // #4101734 {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 count1740 FROM ".$pre."links1741 LEFT JOIN ".$pre."pages1742 ON ".$pre."links.to_tag = ".$pre."pages.tag1743 WHERE ".$pre."pages.tag IS NULL1744 GROUP BY page_tag1745 ORDER BY count DESC"1746 1719 ); 1747 1720 return $pages;