1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8function wikiplugin_showpages_info() 9{ 10 return [ 11 'name' => tra('Show Pages'), 12 'documentation' => 'PluginShowPages', 13 'description' => tra('Find pages by searching within page names'), 14 'prefs' => [ 'wikiplugin_showpages' ], 15 'iconname' => 'search', 16 'introduced' => 1, 17 'params' => [ 18 'find' => [ 19 'required' => true, 20 'name' => tra('Find'), 21 'description' => tra('Search criteria'), 22 'since' => '1', 23 'default' => '', 24 ], 25 'max' => [ 26 'required' => false, 27 'name' => tra('Result Count'), 28 'description' => tra('Maximum amount of results displayed.'), 29 'since' => '1', 30 'filter' => 'int', 31 'default' => '', 32 ], 33 'display' => [ 34 'required' => false, 35 'name' => tra('Display'), 36 'description' => tra('Display page name and/or description. Both displayed by default.'), 37 'since' => '1', 38 'filter' => 'text', 39 'default' => 'name|desc', 40 'options' => [ 41 ['text' => '', 'value' => ''], 42 ['text' => tra('Name'), 'value' => 'name'], 43 ['text' => tra('Description'), 'value' => 'desc'], 44 ['text' => tra('Name & Description'), 'value' => 'name|desc'] 45 ] 46 ] 47 ] 48 ]; 49} 50 51function wikiplugin_showpages($data, $params) 52{ 53 global $tikilib, $prefs; 54 55 extract($params, EXTR_SKIP); 56 if (! isset($find)) { 57 return ("<b>missing find parameter for plugin SHOWPAGES</b><br />"); 58 } 59 60 if (! isset($max)) { 61 $max = -1; 62 } 63 64 if (! isset($display) || (strpos($display, 'name') === false && strpos($display, 'desc') === false)) { 65 $display = 'name|desc'; 66 } 67 68 $data = $tikilib->list_pages(0, $max, 'pageName_asc', $find, null, false); 69 70 $text = ''; 71 72 foreach ($data["data"] as $page) { 73 if (isset($prefs['feature_wiki_description']) && $prefs['feature_wiki_description'] == 'y' && strpos($display, 'desc') !== false) { 74 $desc = $tikilib->page_exists_desc($page["pageName"]); 75 } else { 76 $desc = ''; 77 } 78 $text .= "<a href=\"tiki-index.php?page=" . $page["pageName"] . "\" title=\"" . tra("Last modified by") . " " . $page["user"] . "\" class=\"wiki\">"; 79 $text .= (strpos($display, 'name') !== false || strlen($desc) == 0 ? $page["pageName"] : $desc); 80 $text .= "</a>"; 81 $text .= (strpos($display, 'name') !== false && $desc !== $page["pageName"] && strlen($desc) > 0 ? " - $desc" : ""); 82 $text .= "<br />"; 83 } 84 85 return $text; 86} 87