16 protected $MaxPerPage = 100;
21 private $searchHelperDao;
25 $this->Name =
"search";
26 $this->Title = _(
"Search");
27 $this->MenuList =
"Search";
28 $this->MenuOrder = 90;
29 $this->Dependency = array(
"browse");
32 parent::__construct();
34 $this->uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
35 $this->searchHelperDao = $GLOBALS[
'container']->get(
'dao.searchhelperdao');
40 $this->
State = PLUGIN_STATE_READY;
44 function loadUploads()
46 $allUploadsPre = $this->uploadDao->getActiveUploadsArray();
47 $filteredUploadsList = array();
49 return array_filter($allUploadsPre,
function($uploadObj){
50 if ($this->uploadDao->isAccessible($uploadObj->getId(), Auth::getGroupId())) {
62 menu_insert(
"Main::" . $this->MenuList,$this->MenuOrder,$this->Name,$this->MenuTarget);
71 menu_insert(
"Browse::Search", 1, $URI, $this->MenuList);
86 $Count = count($UploadtreeRecs);
88 $Outbuf .= _(
"No matching files.\n");
91 if (($Page > 0) || ($Count >= $this->MaxPerPage)) {
93 $PageChoices =
MenuEndlessPage($Page, ($Count >= $this->MaxPerPage), $Uri) .
95 $Outbuf .= $PageChoices;
99 $Outbuf .=
UploadtreeFileList($UploadtreeRecs,
"browse",
"view",$Page*$this->MaxPerPage + 1);
102 $Outbuf .= $PageChoices;
114 if ($this->
State != PLUGIN_STATE_READY) {
117 if ($this->OutputType !=
'HTML') {
126 $uploadsArray = $this->loadUploads();
127 $this->vars[
'uploadsArray'] = $uploadsArray;
132 $this->vars[
'pathOfItem'] =
Dir2Browse($this->Name, $Item, NULL, 1, NULL) .
134 $GETvars .=
"&item=$Item";
138 $GETvars .=
"&searchtype=" . urlencode($searchtype);
139 if ($searchtype ==
'containers') {
140 $this->vars[
"ContainersChecked"] =
"checked=\"checked\"";
141 }
else if ($searchtype ==
'directory') {
142 $this->vars[
"DirectoryChecked"] =
"checked=\"checked\"";
144 $this->vars[
"AllFilesChecked"] =
"checked=\"checked\"";
148 if (! empty($Filename)) {
150 $GETvars .=
"&filename=" . urlencode($Filename);
151 $this->vars[
"Filename"] = $Filename;
155 $SelectedUploadName =
"All uploads";
158 $GETvars .=
"&upload=" . urlencode($Upload);
159 $this->vars[
"Upload"] = $Upload;
160 foreach ($uploadsArray as $row) {
161 if ($row->getId() == $Upload) {
162 $SelectedUploadName = $row->getFilename() .
" from " .
Convert2BrowserTime(date(
"Y-m-d H:i:s",$row->getTimestamp()));
166 $this->vars[
"Upload"] = 0;
172 $GETvars .=
"&tag=" . urlencode($tag);
173 $this->vars[
"tag"] = $tag;
177 if (! empty($SizeMin) && is_numeric($SizeMin) && ($SizeMin >= 0)) {
178 $SizeMin = intval($SizeMin);
180 $GETvars .=
"&sizemin=$SizeMin";
181 $this->vars[
"SizeMin"] = $SizeMin;
185 if (! empty($SizeMax) && is_numeric($SizeMax) && ($SizeMax >= 0)) {
186 $SizeMax = intval($SizeMax);
188 $GETvars .=
"&sizemax=$SizeMax";
189 $this->vars[
"SizeMax"] = $SizeMax;
193 if (! empty($License)) {
195 $GETvars .=
"&license=" . urlencode($License);
196 $this->vars[
"License"] = $License;
200 if (! empty($Copyright)) {
202 $GETvars .=
"©right=" . urlencode($Copyright);
203 $this->vars[
"Copyright"] = $Copyright;
211 if ($CriteriaCount) {
215 $UploadtreeRecsResult = $this->searchHelperDao->GetResults($Item, $Filename,$Upload, $tag, $Page, $Limit, $SizeMin,
216 $SizeMax, $searchtype, $License, $Copyright, $this->uploadDao,
220 "The indented search results are same files in different folders");
221 $html .=
"<H4>$message</H4>\n";
222 $text = $UploadtreeRecsResult[1] .
" " . _(
"Files matching");
223 $html .=
"<H2>$text " . htmlentities($Filename) .
" in ". htmlentities($SelectedUploadName) .
"</H2>\n";
224 $html .= $this->
HTMLResults($UploadtreeRecsResult[0], $Page, $GETvars,
225 $License, $Copyright);
226 $this->vars[
"result"] = $html;
230 public function getTemplateName()
232 return "ui-search.html.twig";
237 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
Contains the constants and helpers for authentication of user.
HTMLResults($UploadtreeRecs, $Page, $GETvars)
print search results to stdout
__construct()
base constructor. Most plugins will just use this
Output()
Display the loaded menu and plugins.
PostInitialize()
This function is called before the plugin is used and after all plugins have been initialized....
RegisterMenus()
Customize submenus.
UploadtreeFileList($Listing, $IfDirPlugin, $IfFilePlugin, $Count=-1, $ShowPhrase=0)
Given an array of pfiles/uploadtree, sorted by pfile, list all of the breadcrumbs for each file....
Dir2Browse($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
Get an html linked string of a file browse path.
Traceback_uri()
Get the URI without query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
Convert2BrowserTime($server_time)
Convert the server time to browser time.
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN