| 37 | | $showpagetitle = TRUE; |
| 38 | | } |
| 39 | | |
| 40 | | if ($pages = $this->LoadPageTitles()) |
| 41 | | { |
| 42 | | // filter by letter |
| 43 | | $requested_letter = (isset($_GET['letter'])) ? $this->GetSafeVar('letter', 'get') : ''; # #312 |
| 44 | | if (!$requested_letter && isset($letter)) |
| 45 | | { |
| 46 | | $requested_letter = strtoupper($letter); // TODO action parameter (letter) needs to be validated and sanitized (make sure it's a single character) |
| 47 | | } |
| 48 | | |
| 49 | | // get things started |
| 50 | | $cached_username = $this->GetUserName(); |
| 51 | | $user_owns_pages = FALSE; |
| 52 | | $link = $this->href('', '', 'letter='); |
| 53 | | $alpha_bar = '<a href="'.$link.'">'.PAGEINDEX_ALL_PAGES.'</a> '."\n"; |
| 54 | | $index_caption = PAGEINDEX_CAPTION; |
| 55 | | $index_output = ''; |
| 56 | | $current_character = ''; |
| 57 | | $character_changed = FALSE; |
| 58 | | |
| 59 | | // get page list |
| 60 | | foreach ($pages as $page) |
| 61 | | { |
| 62 | | // check user read privileges |
| 63 | | if (!$this->HasAccess('read', $page['tag'])) |
| 64 | | { |
| 65 | | continue; |
| 66 | | } |
| 67 | | |
| 68 | | $page_owner = $page['owner']; |
| 69 | | // $this->CachePage($page); |
| 70 | | |
| 71 | | $firstChar = strtoupper($page['tag'][0]); |
| 72 | | if (!preg_match('/[A-Za-z]/', $firstChar))//TODO: (#104 #340, #34) Internationalization (allow other starting chars, make consistent with Formatter REs) |
| 73 | | { |
| 74 | | $firstChar = '#'; |
| 75 | | } |
| 76 | | if ($firstChar != $current_character) |
| 77 | | { |
| 78 | | $alpha_bar .= '<a href="'.$link.$firstChar.'">'.$firstChar.'</a> '."\n"; |
| 79 | | $current_character = $firstChar; |
| 80 | | $character_changed = TRUE; |
| 81 | | } |
| 82 | | if ($requested_letter == '' || $firstChar == $requested_letter) |
| 83 | | { |
| 84 | | if ($character_changed) |
| 85 | | { |
| 86 | | $index_output .= "<br />\n<strong>$firstChar</strong><br />\n"; |
| 87 | | $character_changed = FALSE; |
| 88 | | } |
| 89 | | $index_output .= $this->Link($page['tag']); |
| 90 | | // Output page title if $showpagetitle set to 1 |
| 91 | | if (TRUE === $showpagetitle) |
| 92 | | { |
| 93 | | $index_output .= "<span class=\"pagetitle\">[".$this->PageTitle($page['tag'])."]</span>"; |
| 94 | | } |
| 95 | | if ($cached_username == $page_owner) |
| 96 | | { |
| 97 | | $index_output .= '*'; |
| 98 | | $user_owns_pages = TRUE; |
| 99 | | } |
| 100 | | elseif ($page_owner != '(Public)' && $page_owner != '') |
| 101 | | { |
| 102 | | $index_output .= sprintf(' . . . . '.WIKKA_PAGE_OWNER, $this->FormatUser($page_owner)); |
| 103 | | } |
| 104 | | $index_output .= "<br />\n"; |
| 105 | | } |
| 106 | | } |
| 107 | | // generate page |
| 108 | | // @@@ don't use Format() - generate HTML! |
| 109 | | if ($user_owns_pages) |
| 110 | | { |
| 111 | | $index_caption .= '---'.PAGEINDEX_OWNED_PAGES_CAPTION; |
| 112 | | } |
| 113 | | echo $this->Format('===='.PAGEINDEX_HEADING.'==== --- <<'.$index_caption.'<< ::c:: ---'); |
| 114 | | echo "\n<strong>".$alpha_bar."</strong><br />\n"; |
| 115 | | echo $index_output; |
| | 41 | $newpage = $this->htmlspecialchars_ent($vars['showjustletters']); |
| | 42 | $alpha_bar = generateAlphaBar($this, $newpage); |
| | 43 | echo $alpha_bar; |
| | 44 | return; |
| 119 | | echo WIKKA_NO_PAGES_FOUND; |
| | 48 | |
| | 49 | $showpagetitle = FALSE; |
| | 50 | if (isset($vars['showpagetitle']) && 1 == (int) $vars['showpagetitle']) |
| | 51 | { |
| | 52 | $showpagetitle = TRUE; |
| | 53 | } |
| | 54 | |
| | 55 | if ($pages = $this->LoadPageTitles()) |
| | 56 | { |
| | 57 | // filter by letter |
| | 58 | $requested_letter = (isset($_GET['letter'])) ? $this->GetSafeVar('letter', 'get') : ''; # #312 |
| | 59 | if (!$requested_letter && isset($letter)) |
| | 60 | { |
| | 61 | $requested_letter = strtoupper($letter); // TODO action parameter (letter) needs to be validated and sanitized (make sure it's a single character) |
| | 62 | } |
| | 63 | |
| | 64 | // get things started |
| | 65 | $cached_username = $this->GetUserName(); |
| | 66 | $user_owns_pages = FALSE; |
| | 67 | $link = $this->href('', '', 'letter='); |
| | 68 | $alpha_bar = '<a href="'.$link.'">'.PAGEINDEX_ALL_PAGES.'</a> '."\n"; |
| | 69 | $index_caption = PAGEINDEX_CAPTION; |
| | 70 | $index_output = ''; |
| | 71 | $current_character = ''; |
| | 72 | $character_changed = FALSE; |
| | 73 | |
| | 74 | // get page list |
| | 75 | foreach ($pages as $page) |
| | 76 | { |
| | 77 | // check user read privileges |
| | 78 | if (!$this->HasAccess('read', $page['tag'])) |
| | 79 | { |
| | 80 | continue; |
| | 81 | } |
| | 82 | |
| | 83 | $page_owner = $page['owner']; |
| | 84 | // $this->CachePage($page); |
| | 85 | |
| | 86 | $firstChar = strtoupper($page['tag'][0]); |
| | 87 | if (!preg_match('/[A-Za-z]/', $firstChar))//TODO: (#104 #340, #34) Internationalization (allow other starting chars, make consistent with Formatter REs) |
| | 88 | { |
| | 89 | $firstChar = '#'; |
| | 90 | } |
| | 91 | if ($firstChar != $current_character) |
| | 92 | { |
| | 93 | $alpha_bar .= '<a href="'.$link.$firstChar.'">'.$firstChar.'</a> '."\n"; |
| | 94 | $current_character = $firstChar; |
| | 95 | $character_changed = TRUE; |
| | 96 | } |
| | 97 | if ($requested_letter == '' || $firstChar == $requested_letter) |
| | 98 | { |
| | 99 | if ($character_changed) |
| | 100 | { |
| | 101 | $index_output .= "<br />\n<strong>$firstChar</strong><br />\n"; |
| | 102 | $character_changed = FALSE; |
| | 103 | } |
| | 104 | $index_output .= $this->Link($page['tag']); |
| | 105 | // Output page title if $showpagetitle set to 1 |
| | 106 | if (TRUE === $showpagetitle) |
| | 107 | { |
| | 108 | $index_output .= "<span class=\"pagetitle\">[".$this->PageTitle($page['tag'])."]</span>"; |
| | 109 | } |
| | 110 | if ($cached_username == $page_owner) |
| | 111 | { |
| | 112 | $index_output .= '*'; |
| | 113 | $user_owns_pages = TRUE; |
| | 114 | } |
| | 115 | elseif ($page_owner != '(Public)' && $page_owner != '') |
| | 116 | { |
| | 117 | $index_output .= sprintf(' . . . . '.WIKKA_PAGE_OWNER, $this->FormatUser($page_owner)); |
| | 118 | } |
| | 119 | $index_output .= "<br />\n"; |
| | 120 | } |
| | 121 | } |
| | 122 | // generate page |
| | 123 | // @@@ don't use Format() - generate HTML! |
| | 124 | if ($user_owns_pages) |
| | 125 | { |
| | 126 | $index_caption .= '---'.PAGEINDEX_OWNED_PAGES_CAPTION; |
| | 127 | } |
| | 128 | echo $this->Format('===='.PAGEINDEX_HEADING.'==== --- <<'.$index_caption.'<< ::c:: ---'); |
| | 129 | echo "\n<strong>".$alpha_bar."</strong><br />\n"; |
| | 130 | echo $index_output; |
| | 131 | } |
| | 132 | else |
| | 133 | { |
| | 134 | echo WIKKA_NO_PAGES_FOUND; |
| | 135 | } |
| | 136 | } |
| | 137 | |
| | 138 | function generateAlphaBar(&$wakka, $newpage) |
| | 139 | { |
| | 140 | if ($pages = $wakka->LoadPageTitles()) |
| | 141 | { |
| | 142 | // get things started |
| | 143 | $link = $wakka->href('', $newpage, 'letter='); |
| | 144 | $alpha_bar = '<a href="'.$link.'"><strong>'.PAGEINDEX_ALL_PAGES.'</strong></a> '."\n"; |
| | 145 | $current_character = ''; |
| | 146 | $character_changed = FALSE; |
| | 147 | |
| | 148 | // get page list |
| | 149 | foreach ($pages as $page) |
| | 150 | { |
| | 151 | // check user read privileges |
| | 152 | if (!$wakka->HasAccess('read', $page['tag'])) |
| | 153 | { |
| | 154 | continue; |
| | 155 | } |
| | 156 | |
| | 157 | $firstChar = strtoupper($page['tag'][0]); |
| | 158 | if (!preg_match('/[A-Za-z]/', $firstChar))//TODO: (#104 #340, #34) Internationalization (allow other starting chars, make consistent with Formatter REs) |
| | 159 | { |
| | 160 | $firstChar = '#'; |
| | 161 | } |
| | 162 | if ($firstChar != $current_character) |
| | 163 | { |
| | 164 | $alpha_bar .= '<a href="'.$link.$firstChar.'"><strong>'.$firstChar.'</strong></a> '."\n"; |
| | 165 | |
| | 166 | $current_character = $firstChar; |
| | 167 | $character_changed = TRUE; |
| | 168 | } |
| | 169 | } |
| | 170 | } |
| | 171 | return $alpha_bar; |