Exemple #1
0
 /**
  * get the list of files and folders under this current fold
  *	@return array
  */
 function getFileList()
 {
     $outputs = array();
     $files = array();
     $folders = array();
     $tem = array();
     $dirHandler = @opendir($this->currentFolderPath);
     if ($dirHandler) {
         while (false !== ($file = readdir($dirHandler))) {
             if ($file != '.' && $file != '..') {
                 $flag = $this->flags['no'];
                 if ($this->sessionAction->getFolder() == $this->currentFolderPath) {
                     //check if any flag associated with this folder or file
                     $folder = addTrailingSlash(backslashToSlash($this->currentFolderPath));
                     if (in_array($folder . $file, $this->sessionAction->get())) {
                         if ($this->sessionAction->getAction() == "copy") {
                             $flag = $this->flags['copy'];
                         } else {
                             $flag = $this->flags['cut'];
                         }
                     }
                 }
                 $path = $this->currentFolderPath . $file;
                 if (is_dir($path) && isListingDocument($path)) {
                     $this->currentFolderInfo['subdir']++;
                     if (!$this->calculateSubdir) {
                     } else {
                         $folder = $this->getFolderInfo($path);
                         $folder['flag'] = $flag;
                         $folders[$file] = $folder;
                         $outputs[$file] = $folders[$file];
                     }
                 } elseif (is_file($path) && isListingDocument($path)) {
                     $obj = new file($path);
                     $tem = $obj->getFileInfo();
                     if (sizeof($tem)) {
                         $fileType = $this->getFileType($file);
                         foreach ($fileType as $k => $v) {
                             $tem[$k] = $v;
                         }
                         $this->currentFolderInfo['size'] += $tem['size'];
                         $this->currentFolderInfo['file']++;
                         $tem['path'] = backslashToSlash($path);
                         $tem['type'] = "file";
                         $tem['flag'] = $flag;
                         $files[$file] = $tem;
                         $outputs[$file] = $tem;
                         $tem = array();
                         $obj->close();
                     }
                 }
             }
         }
         if ($this->forceFolderOnTop) {
             uksort($folders, "strnatcasecmp");
             uksort($files, "strnatcasecmp");
             $outputs = array();
             foreach ($folders as $v) {
                 $outputs[] = $v;
             }
             foreach ($files as $v) {
                 $outputs[] = $v;
             }
         } else {
             uksort($outputs, "strnatcasecmp");
         }
         @closedir($dirHandler);
     } else {
         trigger_error('Unable to locate the folder ' . $this->currentFolderPath, E_NOTICE);
     }
     return $outputs;
 }
 /**
  * get the list of files and folders under this current fold
  * 	@return array
  */
 function getFileList()
 {
     $outputs = array();
     $files = array();
     $folders = array();
     $tem = array();
     $to_group_id = api_get_group_id();
     global $is_user_in_group;
     $dirHandler = @opendir($this->getCurrentFolderPath());
     if ($dirHandler) {
         while (false !== ($file = readdir($dirHandler))) {
             if ($file != '.' && $file != '..') {
                 $flag = $this->flags['no'];
                 if ($this->sessionAction->getFolder() == $this->getCurrentFolderPath()) {
                     //check if any flag associated with this folder or file
                     $folder = addTrailingSlash(backslashToSlash($this->getCurrentFolderPath()));
                     if (in_array($folder . $file, $this->sessionAction->get())) {
                         if ($this->sessionAction->getAction() == "copy") {
                             $flag = $this->flags['copy'];
                         } else {
                             $flag = $this->flags['cut'];
                         }
                     }
                 }
                 $path = $this->getCurrentFolderPath() . $file;
                 if (is_dir($path) && isListingDocument($path)) {
                     $this->currentFolderInfo['subdir']++;
                     //fix count left folders for Chamilo
                     $deleted_by_Chamilo_folder = '_DELETED_';
                     $css_folder_Chamilo = 'css';
                     $hotpotatoes_folder_Chamilo = 'HotPotatoes_files';
                     $chat_files_Chamilo = 'chat_files';
                     $certificates_Chamilo = 'certificates';
                     //show group's directory only if I'm member. Or if I'm a teacher.
                     //@todo: check groups not necessary because the student dont have access to main folder documents (only to document/group or document/shared_folder).
                     //Teachers can access to all groups ?
                     $group_folder = '_groupdocs';
                     $hide_doc_group = false;
                     if (preg_match("/{$group_folder}/", $path)) {
                         $hide_doc_group = true;
                         if ($is_user_in_group || $to_group_id != 0 && api_is_allowed_to_edit()) {
                             $hide_doc_group = false;
                         }
                     }
                     if (preg_match("/{$deleted_by_Chamilo_folder}/", $path) || preg_match("/{$css_folder_Chamilo}/", $path) || preg_match("/{$hotpotatoes_folder_Chamilo}/", $path) || preg_match("/{$chat_files_Chamilo}/", $path) || preg_match("/{$certificates_Chamilo}/", $path) || $hide_doc_group || $file[0] == '.') {
                         $this->currentFolderInfo['subdir'] = $this->currentFolderInfo['subdir'] - 1;
                     }
                     //end fix for Chamilo
                     if (!$this->calculateSubdir) {
                     } else {
                         $folder = $this->getFolderInfo($path);
                         $folder['flag'] = $flag;
                         $folders[$file] = $folder;
                         $outputs[$file] = $folders[$file];
                     }
                 } elseif (is_file($path) && isListingDocument($path)) {
                     $obj = new file($path);
                     $tem = $obj->getFileInfo();
                     if (sizeof($tem)) {
                         $fileType = $this->getFileType($file);
                         foreach ($fileType as $k => $v) {
                             $tem[$k] = $v;
                         }
                         $this->currentFolderInfo['size'] += $tem['size'];
                         $this->currentFolderInfo['file']++;
                         //fix count left files for Chamilo
                         $deleted_by_Chamilo_file = ' DELETED ';
                         // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
                         if (preg_match("/{$deleted_by_Chamilo_file}/", $tem['name']) || $tem['name'][0] == '.') {
                             $this->currentFolderInfo['file'] = $this->currentFolderInfo['file'] - 1;
                         }
                         ///end fix for Chamilo
                         //Try a course file
                         $tem['path'] = backslashToSlash($path);
                         $pos = strpos($this->getCurrentFolderPath(), 'courses/');
                         if ($pos === false) {
                             //try my_files
                             $pos = strpos($this->getCurrentFolderPath(), 'main/');
                             $tem['public_path'] = api_get_path(WEB_PATH) . substr($this->getCurrentFolderPath(), $pos, strlen($this->getCurrentFolderPath())) . $file;
                         } else {
                             $tem['public_path'] = api_get_path(WEB_PATH) . substr($this->getCurrentFolderPath(), $pos, strlen($this->getCurrentFolderPath())) . $file;
                         }
                         $tem['type'] = "file";
                         $tem['flag'] = $flag;
                         $files[$file] = $tem;
                         $outputs[$file] = $tem;
                         $tem = array();
                         $obj->close();
                     }
                 }
             }
         }
         if ($this->forceFolderOnTop) {
             uksort($folders, "strnatcasecmp");
             uksort($files, "strnatcasecmp");
             $outputs = array();
             foreach ($folders as $v) {
                 $outputs[] = $v;
             }
             foreach ($files as $v) {
                 $outputs[] = $v;
             }
         } else {
             uksort($outputs, "strnatcasecmp");
         }
         @closedir($dirHandler);
     } else {
         trigger_error('Unable to locate the folder ' . $this->getCurrentFolderPath(), E_NOTICE);
     }
     return $outputs;
 }
Exemple #3
0
															
								$fileType = $manager->getFileType($upload->getFileName());

								foreach($fileType as $k=>$v)
								{
									$tem[$k] = $v;
								}
								
								$tem['path'] = backslashToSlash($path);		
								$tem['type'] = "file";
								$tem['size'] = transformFileSize($tem['size']);
								$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
								$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);
								$tem['short_name'] = shortenFileName($tem['name']);						
								$tem['flag'] = 'noFlag';
								$obj->close();
								foreach($tem as $k=>$v)
								{
										$info .= sprintf(", %s:'%s'", $k, $v);									
								}

								$info .= sprintf(", url:'%s'",  getFileUrl($path));
								$info .= sprintf(", tipedit:'%s'",  TIP_DOC_RENAME);		

																				
							}else 
							{
								$error = ERR_FILE_NOT_AVAILABLE;
							}

Exemple #4
0
 /**
  * Generate an XML files and save them to the root directory
  * @param array
  */
 protected function generateFiles($arrArchive)
 {
     $this->import('Database');
     $time = time();
     $strType = $arrArchive['format'] == 'atom' ? 'generateAtom' : 'generateRss';
     $strLink = $arrArchive['feedBase'] != '' ? $arrArchive['feedBase'] : $this->Environment->base;
     $strFile = $arrArchive['feedName'];
     $objFeed = new \Feed($strFile);
     $objFeed->link = $strLink;
     $objFeed->title = $arrArchive['title'];
     $objFeed->description = $arrArchive['description'];
     $objFeed->language = $arrArchive['language'];
     $objFeed->published = $arrArchive['tstamp'];
     // Get items
     $objArticleStmt = $this->Database->prepare("SELECT *, (SELECT name FROM tl_user u WHERE u.id=p.author) AS authorName FROM tl_photoalbums2_album p WHERE pid=? AND (start='' OR start<{$time}) AND (stop='' OR stop>{$time}) AND published=1 ORDER BY sorting ASC");
     if ($arrArchive['maxItems'] > 0) {
         $objArticleStmt->limit($arrArchive['maxItems']);
     }
     $objArticle = $objArticleStmt->execute($arrArchive['id']);
     // Get the default URL
     $objParent = \PageModel::findByPk($arrArchive['modulePage']);
     if ($objParent == null) {
         return;
     }
     $objParent = $this->getPageDetails($objParent->id);
     $strUrl = $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/album/%s', $objParent->language);
     // Parse items
     if ($objArticle !== null) {
         while ($objArticle->next()) {
             // Deserialize image arrays
             $objArticle->images = deserialize($objArticle->images);
             $objArticle->imageSort = deserialize($objArticle->imageSort);
             // Sort images
             $objPa2ImageSorter = new \Pa2ImageSorter($objArticle->imageSortType, $objArticle->images, $objArticle->imageSort);
             $this->arrImages = $objPa2ImageSorter->getSortedUuids();
             $objItem = new \FeedItem();
             $objItem->title = $objArticle->title;
             $objItem->link = sprintf($strLink . $strUrl, $objArticle->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objArticle->alias : $objArticle->id);
             $objItem->published = $objArticle->startdate;
             $objItem->author = $objArticle->authorName;
             if (is_array($objArticle->arrImages) && count($objArticle->arrImages) > 0) {
                 foreach ($objArticle->arrImages as $image) {
                     if (is_file(TL_ROOT . '/' . $image)) {
                         $objItem->addEnclosure($image);
                     }
                 }
             }
             $objItem->description = $this->replaceInsertTags($objArticle->description);
             $objFeed->addItem($objItem);
         }
     }
     // Create file
     $objRss = new \file($strFile . '.xml');
     $objRss->write($this->replaceInsertTags($objFeed->{$strType}()));
     $objRss->close();
 }