Cosmetic changes

skala
Julio Montoya 13 years ago
parent c1facce646
commit 522e551ad1
  1. 87
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.search.php

@ -1,7 +1,9 @@
<?php <?php
include_once(CLASS_FILE); include_once(CLASS_FILE);
require_once(CLASS_SESSION_ACTION); require_once(CLASS_SESSION_ACTION);
require_once(CLASS_MANAGER); require_once(CLASS_MANAGER);
class Search class Search
{ {
var $rootFolder = ''; var $rootFolder = '';
@ -17,6 +19,7 @@
); );
var $sessionAction = null; var $sessionAction = null;
/** /**
* constructor * constructor
* *
@ -33,8 +36,7 @@
$selectedDocuments = $this->sessionAction->get(); $selectedDocuments = $this->sessionAction->get();
$fileType = $obj->getFolderInfo($this->rootFolder); $fileType = $obj->getFolderInfo($this->rootFolder);
foreach($fileType as $k=>$v) foreach ($fileType as $k => $v) {
{
$tem[$k] = $v; $tem[$k] = $v;
} }
@ -43,7 +45,10 @@
$tem['size'] = (is_dir($this->rootFolder) ? '' : transformFileSize(@filesize($this->rootFolder))); $tem['size'] = (is_dir($this->rootFolder) ? '' : transformFileSize(@filesize($this->rootFolder)));
//$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']); //$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
//$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']); //$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);
$tem['flag'] = (array_search($tem['path'], $selectedDocuments) !== false?($this->sessionAction->getAction() == "copy"?'copyFlag':'cutFlag'):'noFlag'); $tem['flag'] = (array_search(
$tem['path'],
$selectedDocuments
) !== false ? ($this->sessionAction->getAction() == "copy" ? 'copyFlag' : 'cutFlag') : 'noFlag');
$tem['url'] = getFileUrl($this->rootFolder); $tem['url'] = getFileUrl($this->rootFolder);
$tem['friendly_path'] = transformFilePath($this->rootFolder); $tem['friendly_path'] = transformFilePath($this->rootFolder);
$tem['file'] = 0; $tem['file'] = 0;
@ -54,7 +59,6 @@
} }
/** /**
* constructor * constructor
* *
@ -75,6 +79,7 @@
{ {
$this->searchkeywords[$key] = $value; $this->searchkeywords[$key] = $value;
} }
/** /**
* change the search keywords * change the search keywords
* *
@ -82,14 +87,13 @@
*/ */
function addSearchKeywords($keywords) function addSearchKeywords($keywords)
{ {
foreach($this->searchkeywords as $k=>$v) foreach ($this->searchkeywords as $k => $v) {
{ if (array_key_exists($k, $keywords) !== false) {
if(array_key_exists($k, $keywords) !== false)
{
$this->searchkeywords[$k] = $keywords[$k]; $this->searchkeywords[$k] = $keywords[$k];
} }
} }
} }
/** /**
* get the file according to the search keywords * get the file according to the search keywords
* *
@ -97,44 +101,52 @@
function doSearch($baseFolderPath = null) function doSearch($baseFolderPath = null)
{ {
$baseFolderPath = addTrailingSlash(backslashToSlash((is_null($baseFolderPath)?$this->rootFolder:$baseFolderPath))); $baseFolderPath = addTrailingSlash(
backslashToSlash((is_null($baseFolderPath) ? $this->rootFolder : $baseFolderPath))
);
$dirHandler = @opendir($baseFolderPath); $dirHandler = @opendir($baseFolderPath);
if($dirHandler) if ($dirHandler) {
{ while (false !== ($file = readdir($dirHandler))) {
while(false !== ($file = readdir($dirHandler))) if ($file != '.' && $file != '..') {
{
if($file != '.' && $file != '..')
{
$path = $baseFolderPath.$file; $path = $baseFolderPath.$file;
if(is_file($path)) if (is_file($path)) {
{
$isValid = true; $isValid = true;
$fileTime = @filemtime($path); $fileTime = @filemtime($path);
$fileSize = @filesize($path); $fileSize = @filesize($path);
if($this->searchkeywords['name'] !== '' && @eregi($this->searchkeywords['name'], $file) === false) if ($this->searchkeywords['name'] !== '' && @eregi(
{ $this->searchkeywords['name'],
$file
) === false
) {
$isValid = false; $isValid = false;
} }
if($this->searchkeywords['mtime_from'] != '' && $fileTime < @strtotime($this->searchkeywords['mtime_from'])) if ($this->searchkeywords['mtime_from'] != '' && $fileTime < @strtotime(
{ $this->searchkeywords['mtime_from']
)
) {
$isValid = false; $isValid = false;
} }
if($this->searchkeywords['mtime_to'] != '' && $fileTime > @strtotime($this->searchkeywords['mtime_to'])) if ($this->searchkeywords['mtime_to'] != '' && $fileTime > @strtotime(
{ $this->searchkeywords['mtime_to']
)
) {
$isValid = false; $isValid = false;
} }
if($this->searchkeywords['size_from'] != '' && $fileSize < @strtotime($this->searchkeywords['size_from'])) if ($this->searchkeywords['size_from'] != '' && $fileSize < @strtotime(
{ $this->searchkeywords['size_from']
)
) {
$isValid = false; $isValid = false;
} }
if($this->searchkeywords['size_to'] != '' && $fileSize > @strtotime($this->searchkeywords['size_to'])) if ($this->searchkeywords['size_to'] != '' && $fileSize > @strtotime(
{ $this->searchkeywords['size_to']
)
) {
$isValid = false; $isValid = false;
} }
if($isValid && isListingDocument($path)) if ($isValid && isListingDocument($path)) {
{
$finalPath = $path; $finalPath = $path;
$objFile = new file($finalPath); $objFile = new file($finalPath);
$tem = $objFile->getFileInfo(); $tem = $objFile->getFileInfo();
@ -143,8 +155,7 @@
$selectedDocuments = $this->sessionAction->get(); $selectedDocuments = $this->sessionAction->get();
$fileType = $obj->getFileType($finalPath); $fileType = $obj->getFileType($finalPath);
foreach($fileType as $k=>$v) foreach ($fileType as $k => $v) {
{
$tem[$k] = $v; $tem[$k] = $v;
} }
@ -153,16 +164,21 @@
/*$tem['size'] = transformFileSize($tem['size']); /*$tem['size'] = transformFileSize($tem['size']);
$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']); $tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);*/ $tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);*/
$tem['flag'] = (array_search($tem['path'], $selectedDocuments) !== false?($this->sessionAction->getAction() == "copy"?'copyFlag':'cutFlag'):'noFlag'); $tem['flag'] = (array_search(
$tem['path'],
$selectedDocuments
) !== false ? ($this->sessionAction->getAction(
) == "copy" ? 'copyFlag' : 'cutFlag') : 'noFlag');
$tem['url'] = getFileUrl($tem['path']); $tem['url'] = getFileUrl($tem['path']);
$this->rootFolderInfo['file']++; $this->rootFolderInfo['file']++;
$manager = null; $manager = null;
$this->files[] = $tem; $this->files[] = $tem;
$tem = null; $tem = null;
} }
}elseif(is_dir($path) && $this->searchkeywords['recursive']) } elseif (is_dir($path) && $this->searchkeywords['recursive']) {
{ $this->doSearch(
$this->doSearch($path); // For Chamilo this line replaces $this->Search($baseFolderPath); to run the search recursively from the root directory $path
); // For Chamilo this line replaces $this->Search($baseFolderPath); to run the search recursively from the root directory
} }
} }
} }
@ -181,4 +197,3 @@
return $this->rootFolderInfo; return $this->rootFolderInfo;
} }
} }
?>
Loading…
Cancel
Save