Example #1
0
 /**
  * Files listing
  *
  * Creates a list of files
  *
  * Usage:
  *
  * {{ files:listing folder="home-slider" type="i" fetch="subfolder|root" }}
  * 	// your html logic
  * {{ /files:listing }}
  *
  * The tags that are available to use from this method are listed below
  *
  * {id}
  * {folder_id}
  * {user_id}
  * {type}
  * {name}
  * {filename}
  * {description}
  * {extension}
  * {mimetype}
  * {width}
  * {height}
  * {filesize}
  * {date_added}
  *
  * @return	array
  */
 public function listing()
 {
     if (!$this->content()) {
         return '';
     }
     $folder_id = $this->attribute('folder', '');
     // Id or Path
     $limit = $this->attribute('limit', '10');
     $offset = $this->attribute('offset', '');
     $type = $this->attribute('type', '');
     $fetch = $this->attribute('fetch');
     if (!empty($folder_id) && (empty($type) || in_array($type, array('a', 'v', 'd', 'i', 'o')))) {
         if (is_numeric($folder_id)) {
             $folder = $this->file_folders_m->get($folder_id);
         } elseif (is_string($folder_id)) {
             $folder = $this->file_folders_m->get_by_path($folder_id);
         }
     }
     if (empty($folder)) {
         return array();
     }
     if (in_array($fetch, array('root', 'subfolder')) && ($subfolders = $this->file_folders_m->folder_tree($fetch === 'root' ? $folder->root_id : $folder->id))) {
         $ids = array_merge(array((int) $folder->id), array_keys($subfolders));
         $this->file_m->where_in('folder_id', $ids);
     } else {
         $this->file_m->where('folder_id', $folder->id);
     }
     $type and $this->file_m->where('type', $type);
     $limit and $this->file_m->limit($limit);
     $offset and $this->file_m->limit($offset);
     $files = $this->file_m->get_all();
     $files and array_merge($this->_files, assoc_array_prop($files));
     return $files;
 }
Example #2
0
	/**
	 * Files listing
	 *
	 * Creates a list of files
	 *
	 * Usage:
	 *
	 * {pyro:files:listing folder="home-slider" type="i"}
	 * 	// your html logic
	 * {/pyro:files:listing}
	 *
	 * The tags that are available to use from this method are listed below
	 *
	 * {id}
	 * {folder_id}
	 * {user_id}
	 * {type}
	 * {name}
	 * {filename}
	 * {description}
	 * {extension}
	 * {mimetype}
	 * {width}
	 * {height}
	 * {filesize}
	 * {date_added}
	 *
	 * @return	array
	 */
	function listing()
	{
		if ( ! $this->content())
		{
			return '';
		}

		$folder_identity	= $this->attribute('folder', ''); // Id or Path
		$limit				= $this->attribute('limit', '10');
		$offset				= $this->attribute('offset', '');
		$type				= $this->attribute('type', '');

		if ( ! empty($folder_identity) && (empty($type) || in_array($type, array('a','v','d','i','o'))))
		{
			if (is_numeric($folder_identity))
			{
				$folder = $this->file_folders_m->get($folder_identity);
			}
			elseif (is_string($folder_identity))
			{
				$folder = $this->file_folders_m->get_by_path($folder_identity);
			}
		}

		if (empty($folder))
		{
			return array();
		}

		$this->file_m->where('folder_id', $folder->id);

		$type AND $this->file_m->where('type', $type);
		$limit AND $this->file_m->limit($limit);
		$offset AND $this->file_m->limit($offset);

		$files = $this->file_m->get_all();
		$files AND array_merge($this->_files, assoc_array_prop($files));

		return $files;
	}