当前位置: 首页>>代码示例>>PHP>>正文


PHP FilesModel::findByPid方法代码示例

本文整理汇总了PHP中FilesModel::findByPid方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesModel::findByPid方法的具体用法?PHP FilesModel::findByPid怎么用?PHP FilesModel::findByPid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FilesModel的用法示例。


在下文中一共展示了FilesModel::findByPid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compile

 /**
  * Generate the content element
  */
 public function compile()
 {
     $newMultiSRC = array();
     if (strlen(\Input::get('tag')) && !$this->tag_ignore || strlen($this->tag_filter)) {
         $tagids = array();
         $relatedlist = strlen(\Input::get('related')) ? preg_split("/,/", \Input::get('related')) : array();
         $alltags = array_merge(array(\Input::get('tag')), $relatedlist);
         $first = true;
         if (strlen($this->tag_filter)) {
             $headlinetags = preg_split("/,/", $this->tag_filter);
             $tagids = $this->getFilterTags();
             $first = false;
         } else {
             $headlinetags = array();
         }
         foreach ($alltags as $tag) {
             if (strlen(trim($tag))) {
                 if (count($tagids)) {
                     $tagids = $this->Database->prepare("SELECT tid FROM tl_tag WHERE from_table = ? AND tag = ? AND tid IN (" . join($tagids, ",") . ")")->execute('tl_files', $tag)->fetchEach('tid');
                 } else {
                     if ($first) {
                         $tagids = $this->Database->prepare("SELECT tid FROM tl_tag WHERE from_table = ? AND tag = ?")->execute('tl_files', $tag)->fetchEach('tid');
                         $first = false;
                     }
                 }
             }
         }
         while ($this->objFiles->next()) {
             if ($this->objFiles->type == 'file') {
                 if (in_array($this->objFiles->id, $tagids)) {
                     array_push($newMultiSRC, $this->objFiles->uuid);
                 }
             } else {
                 $objSubfiles = \FilesModel::findByPid($this->objFiles->uuid);
                 if ($objSubfiles === null) {
                     continue;
                 }
                 while ($objSubfiles->next()) {
                     if (in_array($objSubfiles->id, $tagids)) {
                         array_push($newMultiSRC, $objSubfiles->uuid);
                     }
                 }
             }
         }
         $this->multiSRC = $newMultiSRC;
         $this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
         if ($this->objFiles === null) {
             return '';
         }
     }
     parent::compile();
 }
开发者ID:AgentCT,项目名称:tags,代码行数:55,代码来源:ContentGalleryTags.php

示例2: compile

 /**
  * Generate the content element
  */
 protected function compile()
 {
     global $objPage;
     $images = array();
     $auxDate = array();
     $objFiles = $this->objFiles;
     // Get all images
     while ($objFiles->next()) {
         // Continue if the files has been processed or does not exist
         if (isset($images[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
             continue;
         }
         // Single files
         if ($objFiles->type == 'file') {
             $objFile = new \File($objFiles->path, true);
             if (!$objFile->isGdImage) {
                 continue;
             }
             $arrMeta = $this->getMetaData($objFiles->meta, $objPage->language);
             // Use the file name as title if none is given
             if ($arrMeta['title'] == '') {
                 $arrMeta['title'] = specialchars(str_replace('_', ' ', $objFile->filename));
             }
             // Add the image
             $images[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objFiles->path, 'alt' => $arrMeta['title'], 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']);
             $auxDate[] = $objFile->mtime;
         } else {
             $objSubfiles = \FilesModel::findByPid($objFiles->uuid);
             if ($objSubfiles === null) {
                 continue;
             }
             while ($objSubfiles->next()) {
                 // Skip subfolders
                 if ($objSubfiles->type == 'folder') {
                     continue;
                 }
                 $objFile = new \File($objSubfiles->path, true);
                 if (!$objFile->isGdImage) {
                     continue;
                 }
                 $arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->language);
                 // Use the file name as title if none is given
                 if ($arrMeta['title'] == '') {
                     $arrMeta['title'] = specialchars(str_replace('_', ' ', $objFile->filename));
                 }
                 // Add the image
                 $images[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objSubfiles->path, 'alt' => $arrMeta['title'], 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']);
                 $auxDate[] = $objFile->mtime;
             }
         }
     }
     // Sort array
     switch ($this->dk_msrySortBy) {
         default:
         case 'name_asc':
             uksort($images, 'basename_natcasecmp');
             break;
         case 'name_desc':
             uksort($images, 'basename_natcasercmp');
             break;
         case 'date_asc':
             array_multisort($images, SORT_NUMERIC, $auxDate, SORT_ASC);
             break;
         case 'date_desc':
             array_multisort($images, SORT_NUMERIC, $auxDate, SORT_DESC);
             break;
         case 'meta':
             // Backwards compatibility
         // Backwards compatibility
         case 'custom':
             if ($this->orderSRC != '') {
                 $tmp = deserialize($this->orderSRC);
                 if (!empty($tmp) && is_array($tmp)) {
                     // Remove all values
                     $arrOrder = array_map(function () {
                     }, array_flip($tmp));
                     // Move the matching elements to their position in $arrOrder
                     foreach ($images as $k => $v) {
                         if (array_key_exists($v['uuid'], $arrOrder)) {
                             $arrOrder[$v['uuid']] = $v;
                             unset($images[$k]);
                         }
                     }
                     // Append the left-over images at the end
                     if (!empty($images)) {
                         $arrOrder = array_merge($arrOrder, array_values($images));
                     }
                     // Remove empty (unreplaced) entries
                     $images = array_values(array_filter($arrOrder));
                     unset($arrOrder);
                 }
             }
             break;
         case 'random':
             shuffle($images);
             break;
     }
//.........这里部分代码省略.........
开发者ID:dklemmt,项目名称:contao_dk_masonry,代码行数:101,代码来源:ContentMasonryGallery.php

示例3: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $images = array();
     if ($this->files) {
         $files = $this->files;
         $filesExpaned = array();
         // Get all images
         while ($files->next()) {
             if ($files->type === 'file') {
                 $filesExpaned[] = $files->current();
             } else {
                 $subFiles = \FilesModel::findByPid(version_compare(VERSION, '3.2', '<') ? $files->id : $files->uuid);
                 while ($subFiles && $subFiles->next()) {
                     if ($subFiles->type === 'file') {
                         $filesExpaned[] = $subFiles->current();
                     }
                 }
             }
         }
         foreach ($filesExpaned as $files) {
             // Continue if the files has been processed or does not exist
             if (isset($images[$files->path]) || !file_exists(TL_ROOT . '/' . $files->path)) {
                 continue;
             }
             $file = new \File($files->path, true);
             if (!$file->isGdImage && !$file->isImage) {
                 continue;
             }
             $arrMeta = $this->getMetaData($files->meta, $objPage->language);
             // Add the image
             $images[$files->path] = array('id' => $files->id, 'uuid' => isset($files->uuid) ? $files->uuid : null, 'name' => $file->basename, 'singleSRC' => $files->path, 'alt' => $arrMeta['title'], 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']);
         }
         if ($this->orderSRC) {
             // Turn the order string into an array and remove all values
             if (version_compare(VERSION, '3.2', '<')) {
                 $order = explode(',', $this->orderSRC);
                 $order = array_map('intval', $order);
             } else {
                 $order = deserialize($this->orderSRC);
             }
             if (!$order || !is_array($order)) {
                 $order = array();
             }
             $order = array_flip($order);
             $order = array_map(function () {
             }, $order);
             // Move the matching elements to their position in $order
             $idKey = version_compare(VERSION, '3.2', '<') ? 'id' : 'uuid';
             foreach ($images as $k => $v) {
                 if (array_key_exists($v[$idKey], $order)) {
                     $order[$v[$idKey]] = $v;
                     unset($images[$k]);
                 }
             }
             $order = array_merge($order, array_values($images));
             // Remove empty (unreplaced) entries
             $images = array_filter($order);
             unset($order);
         }
         $images = array_values($images);
         foreach ($images as $key => $image) {
             $newImage = new \stdClass();
             $image['size'] = isset($this->imgSize) ? $this->imgSize : $this->size;
             $this->addImageToTemplate($newImage, $image);
             if ($this->rsts_navType === 'thumbs') {
                 $newImage->thumb = new \stdClass();
                 $image['size'] = $this->rsts_thumbs_imgSize;
                 $this->addImageToTemplate($newImage->thumb, $image);
             }
             $images[$key] = $newImage;
         }
     }
     // use custom skin if specified
     if (trim($this->arrData['rsts_customSkin'])) {
         $this->arrData['rsts_skin'] = trim($this->arrData['rsts_customSkin']);
     }
     $this->Template->images = $images;
     $slides = array();
     if (isset($this->newsArticles)) {
         foreach ($this->newsArticles as $newsArticle) {
             $slides[] = array('text' => $newsArticle);
         }
     } else {
         if (isset($this->eventItems)) {
             foreach ($this->eventItems as $eventItem) {
                 $slides[] = array('text' => $eventItem);
             }
         } else {
             if (isset($this->slider->id) && $this->slider->type === 'content') {
                 $slides = $this->parseSlides(SlideModel::findPublishedByPid($this->slider->id));
             }
         }
     }
     $this->Template->slides = $slides;
     $options = array();
     // strings
//.........这里部分代码省略.........
开发者ID:madeyourday,项目名称:contao-rocksolid-slider,代码行数:101,代码来源:Slider.php

示例4: renderList

 /**
  * Render the file list.
  *
  * @param array           $values        The selected values.
  * @param array           $icons         The generated icons.
  * @param Collection|null $collection    The files collection.
  * @param bool            $followSubDirs If true subfolders get rendered.
  *
  * @return void
  */
 private function renderList(array &$values, array &$icons, Collection $collection = null, $followSubDirs = false)
 {
     if (!$collection) {
         return;
     }
     foreach ($collection as $model) {
         // File system and database seem not in sync
         if (!file_exists(TL_ROOT . '/' . $model->path)) {
             continue;
         }
         $values[$model->id] = $model->uuid;
         if ($this->isGallery && !$this->isDownloads) {
             $icons[$model->uuid] = $this->renderIcon($model);
         } elseif ($model->type === 'folder' && $followSubDirs) {
             $subCollection = \FilesModel::findByPid($model->uuid);
             $this->renderList($values, $icons, $subCollection);
         } else {
             $icon = $this->renderIcon($model, $this->isGallery, $this->isDownloads);
             if ($icon !== false) {
                 $icons[$model->uuid] = $icon;
             }
         }
     }
 }
开发者ID:davidmaack,项目名称:dc-general,代码行数:34,代码来源:FileTree.php

示例5: compile

 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $files = array();
     $auxDate = array();
     $objFiles = $this->objFiles;
     $allowedDownload = trimsplit(',', strtolower(\Config::get('allowedDownload')));
     // Get all files
     while ($objFiles->next()) {
         // Continue if the files has been processed or does not exist
         if (isset($files[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
             continue;
         }
         // Single files
         if ($objFiles->type == 'file') {
             $objFile = new \File($objFiles->path, true);
             if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
                 continue;
             }
             $arrMeta = $this->getMetaData($objFiles->meta, $objPage->language);
             if (empty($arrMeta)) {
                 if ($this->metaIgnore) {
                     continue;
                 } elseif ($objPage->rootFallbackLanguage !== null) {
                     $arrMeta = $this->getMetaData($objFiles->meta, $objPage->rootFallbackLanguage);
                 }
             }
             // Use the file name as title if none is given
             if ($arrMeta['title'] == '') {
                 $arrMeta['title'] = specialchars($objFile->basename);
             }
             $strHref = \Environment::get('request');
             // Remove an existing file parameter (see #5683)
             if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
                 $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
             }
             $strHref .= (\Config::get('disableAlias') || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFiles->path);
             // Add the image
             $files[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'title' => specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename)), 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => $this->getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname);
             $auxDate[] = $objFile->mtime;
         } else {
             $objSubfiles = \FilesModel::findByPid($objFiles->uuid);
             if ($objSubfiles === null) {
                 continue;
             }
             while ($objSubfiles->next()) {
                 // Skip subfolders
                 if ($objSubfiles->type == 'folder') {
                     continue;
                 }
                 $objFile = new \File($objSubfiles->path, true);
                 if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
                     continue;
                 }
                 $arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->language);
                 if (empty($arrMeta)) {
                     if ($this->metaIgnore) {
                         continue;
                     } elseif ($objPage->rootFallbackLanguage !== null) {
                         $arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->rootFallbackLanguage);
                     }
                 }
                 // Use the file name as title if none is given
                 if ($arrMeta['title'] == '') {
                     $arrMeta['title'] = specialchars($objFile->basename);
                 }
                 $strHref = \Environment::get('request');
                 // Remove an existing file parameter (see #5683)
                 if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
                     $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
                 }
                 $strHref .= (\Config::get('disableAlias') || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objSubfiles->path);
                 // Add the image
                 $files[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'title' => specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename)), 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => $this->getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname);
                 $auxDate[] = $objFile->mtime;
             }
         }
     }
     // Sort array
     switch ($this->sortBy) {
         default:
         case 'name_asc':
             uksort($files, 'basename_natcasecmp');
             break;
         case 'name_desc':
             uksort($files, 'basename_natcasercmp');
             break;
         case 'date_asc':
             array_multisort($files, SORT_NUMERIC, $auxDate, SORT_ASC);
             break;
         case 'date_desc':
             array_multisort($files, SORT_NUMERIC, $auxDate, SORT_DESC);
             break;
         case 'meta':
             // Backwards compatibility
         // Backwards compatibility
//.........这里部分代码省略.........
开发者ID:StephenGWills,项目名称:sample-contao-app,代码行数:101,代码来源:ContentDownloads.php

示例6: renderList

 /**
  * Render the file list.
  *
  * @param array           $icons         The generated icons.
  * @param Collection|null $collection    The files collection.
  * @param bool            $followSubDirs If true subfolders get rendered.
  *
  * @return void
  */
 private function renderList(array &$icons, Collection $collection = null, $followSubDirs = false)
 {
     if (!$collection) {
         return;
     }
     foreach ($collection as $model) {
         // File system and database seem not in sync
         if (!file_exists(TL_ROOT . '/' . $model->path)) {
             continue;
         }
         if ('folder' === $model->type && $followSubDirs) {
             $this->renderList($icons, \FilesModel::findByPid($model->uuid));
             continue;
         }
         if (false !== ($icon = $this->renderIcon($model, $this->isGallery, $this->isDownloads))) {
             $icons[$model->uuid] = $icon;
         }
     }
 }
开发者ID:zonky2,项目名称:dc-general,代码行数:28,代码来源:FileTree.php

示例7: getFiles

 public function getFiles($varFolder, $loadSubdir = false)
 {
     $arrFiles = array();
     $objFiles = \FilesModel::findByPid($varFolder);
     if ($objFiles === null) {
         return false;
     }
     while ($objFiles->next()) {
         // Skip subfolders
         if ($objFiles->type == 'folder') {
             #echo $objFiles->path . "<br>";
             $varSubfiles = $this->getFiles($objFiles->uuid, $loadSubdir);
             if ($varSubfiles) {
                 $arrFiles = array_merge($arrFiles, $varSubfiles);
             }
             continue;
         }
         if ($this->extension && !in_array($objFiles->extension, $this->extension)) {
             continue;
         }
         $arrFiles[] = $objFiles;
     }
     if (is_array($arrFiles) && count($arrFiles) > 0) {
         return $arrFiles;
     } else {
         return false;
     }
 }
开发者ID:felixpfeiffer,项目名称:contao-downloadarchive,代码行数:28,代码来源:tl_downloadarchive.php

示例8: scanDirRecursive

 /**
  * scanDirRecursive function.
  *
  * @access protected
  * @param  string $uuid
  * @return array
  */
 protected function scanDirRecursive($uuid)
 {
     $arrUuids = array();
     $objFile = \FilesModel::findByUuid($uuid);
     switch ($objFile->type) {
         case 'folder':
             $objChildren = \FilesModel::findByPid($uuid);
             if ($objChildren !== null) {
                 while ($objChildren->next()) {
                     $arrScan = $this->scanDirRecursive($objChildren->uuid);
                     if (is_array($arrScan) && count($arrScan) > 0) {
                         $arrUuids = array_merge($arrUuids, $arrScan);
                     }
                 }
             }
             break;
         case 'file':
             // Set only the file ids with the correct extension
             if (count($this->arrExtensions) > 0) {
                 if (in_array($objFile->extension, $this->arrExtensions)) {
                     $arrUuids[] = $objFile->uuid;
                 }
             } else {
                 $arrUuids[] = $objFile->uuid;
             }
             break;
     }
     return array_unique($arrUuids);
 }
开发者ID:craffft,项目名称:contao-imagesortwizard,代码行数:36,代码来源:ImageSorter.php

示例9: generate

 /**
  * Generate download attributes
  * @param IsotopeProduct
  * @return string
  */
 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     global $objPage;
     $arrFiles = deserialize($objProduct->{$this->field_name});
     // Return if there are no files
     if (empty($arrFiles) || !is_array($arrFiles)) {
         return '';
     }
     // Get the file entries from the database
     $objFiles = \FilesModel::findMultipleByIds($arrFiles);
     if (null === $objFiles) {
         return '';
     }
     $file = \Input::get('file', true);
     // Send the file to the browser and do not send a 404 header (see #4632)
     if ($file != '' && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) {
         while ($objFiles->next()) {
             if ($file == $objFiles->path || dirname($file) == $objFiles->path) {
                 \Controller::sendFileToBrowser($file);
             }
         }
         $objFiles->reset();
     }
     $files = array();
     $auxDate = array();
     $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
     // Get all files
     while ($objFiles->next()) {
         // Continue if the files has been processed or does not exist
         if (isset($files[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
             continue;
         }
         // Single files
         if ($objFiles->type == 'file') {
             $objFile = new \File($objFiles->path, true);
             if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
                 continue;
             }
             $arrMeta = \Frontend::getMetaData($objFiles->meta, $objPage->language);
             // Use the file name as title if none is given
             if ($arrMeta['title'] == '') {
                 $arrMeta['title'] = specialchars(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objFile->filename)));
             }
             $strHref = \Environment::get('request');
             // Remove an existing file parameter (see #5683)
             if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
                 $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
             }
             $strHref .= ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFiles->path);
             // Add the image
             $files[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'title' => $arrMeta['title'], 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => \System::getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname);
             $auxDate[] = $objFile->mtime;
         } else {
             $objSubfiles = \FilesModel::findByPid($objFiles->id);
             if ($objSubfiles === null) {
                 continue;
             }
             while ($objSubfiles->next()) {
                 // Skip subfolders
                 if ($objSubfiles->type == 'folder') {
                     continue;
                 }
                 $objFile = new \File($objSubfiles->path, true);
                 if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
                     continue;
                 }
                 $arrMeta = \Frontend::getMetaData($objSubfiles->meta, $objPage->language);
                 // Use the file name as title if none is given
                 if ($arrMeta['title'] == '') {
                     $arrMeta['title'] = specialchars(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objFile->filename)));
                 }
                 $strHref = \Environment::get('request');
                 // Remove an existing file parameter (see #5683)
                 if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
                     $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
                 }
                 $strHref .= ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objSubfiles->path);
                 // Add the image
                 $files[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'title' => $arrMeta['title'], 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => \System::getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname);
                 $auxDate[] = $objFile->mtime;
             }
         }
     }
     // Sort array
     $sortBy = $arrOptions['sortBy'] ?: $this->sortBy;
     switch ($sortBy) {
         default:
         case 'name_asc':
             uksort($files, 'basename_natcasecmp');
             break;
         case 'name_desc':
             uksort($files, 'basename_natcasercmp');
             break;
         case 'date_asc':
             array_multisort($files, SORT_NUMERIC, $auxDate, SORT_ASC);
//.........这里部分代码省略.........
开发者ID:Aziz-JH,项目名称:core,代码行数:101,代码来源:Downloads.php

示例10: getMultiMetaData

 private function getMultiMetaData($multiSRC)
 {
     global $objPage;
     $images = array();
     $objFiles = \FilesModel::findMultipleByUuids(unserialize($multiSRC));
     if ($objFiles !== null) {
         while ($objFiles->next()) {
             // Continue if the files has been processed or does not exist
             if (isset($images[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
                 continue;
             }
             // Single files
             if ($objFiles->type == 'file') {
                 $objFile = new \File($objFiles->path, true);
                 if (!$objFile->isGdImage) {
                     continue;
                 }
                 $images[$objFiles->path] = $this->getMetaData($objFiles->meta, $objPage->language);
             } else {
                 $objSubfiles = \FilesModel::findByPid($objFiles->uuid);
                 if ($objSubfiles === null) {
                     continue;
                 }
                 while ($objSubfiles->next()) {
                     // Skip subfolders
                     if ($objSubfiles->type == 'folder') {
                         continue;
                     }
                     $objFile = new \File($objSubfiles->path, true);
                     if (!$objFile->isGdImage) {
                         continue;
                     }
                     $images[$objFile->path] = $this->getMetaData($objSubfiles->meta, $objPage->language);
                 }
             }
         }
     }
     // END if($objFiles !== null)
     return $images;
 }
开发者ID:pandroid,项目名称:contao-metafields,代码行数:40,代码来源:MetafieldsHelper.php

示例11: generate

   /**
    * Generate the widget and return it as string
    * @return string
    */
   public function generate()
   {
       $strValues = '';
       $arrValues = array();
       if ($this->varValue != '') {
           $strValues = implode(',', array_map('intval', (array) $this->varValue));
           $objFiles = $this->Database->execute("SELECT id, path, type FROM tl_files WHERE id IN({$strValues}) ORDER BY " . $this->Database->findInSet('id', $strValues));
           $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
           while ($objFiles->next()) {
               // File system and database seem not in sync
               if (!file_exists(TL_ROOT . '/' . $objFiles->path)) {
                   continue;
               }
               // Show files and folders
               if (!$this->blnIsGallery && !$this->blnIsDownloads) {
                   if ($objFiles->type == 'folder') {
                       $arrValues[$objFiles->id] = $this->generateImage('folderC.gif') . ' ' . $objFiles->path;
                   } else {
                       $objFile = new \File($objFiles->path);
                       $arrValues[$objFiles->id] = $this->generateImage($objFile->icon) . ' ' . $objFiles->path;
                   }
               } else {
                   if ($objFiles->type == 'folder') {
                       $objSubfiles = \FilesModel::findByPid($objFiles->id);
                       if ($objSubfiles === null) {
                           continue;
                       }
                       while ($objSubfiles->next()) {
                           // Skip subfolders
                           if ($objSubfiles->type == 'folder') {
                               continue;
                           }
                           $objFile = new \File($objSubfiles->path);
                           if ($this->blnIsGallery) {
                               // Only show images
                               if ($objFile->isGdImage) {
                                   $arrValues[$objSubfiles->id] = $this->generateImage(\Image::get($objSubfiles->path, 50, 50, 'center_center'), '', 'class="gimage"');
                               }
                           } else {
                               // Only show allowed download types
                               if (in_array($objFile->extension, $allowedDownload) && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
                                   $arrValues[$objSubfiles->id] = $this->generateImage($objFile->icon) . ' ' . $objSubfiles->path;
                               }
                           }
                       }
                   } else {
                       $objFile = new \File($objFiles->path);
                       if ($this->blnIsGallery) {
                           // Only show images
                           if ($objFile->isGdImage) {
                               $arrValues[$objFiles->id] = $this->generateImage(\Image::get($objFiles->path, 50, 50, 'center_center'), '', 'class="gimage"');
                           }
                       } else {
                           // Only show allowed download types
                           if (in_array($objFile->extension, $allowedDownload) && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
                               $arrValues[$objFiles->id] = $this->generateImage($objFile->icon) . ' ' . $objFiles->path;
                           }
                       }
                   }
               }
           }
           // Apply a custom sort order
           if ($this->strOrderField != '' && $this->orderSRC != '') {
               $arrNew = array();
               $arrOrder = array_map('intval', explode(',', $this->orderSRC));
               foreach ($arrOrder as $i) {
                   if (isset($arrValues[$i])) {
                       $arrNew[$i] = $arrValues[$i];
                       unset($arrValues[$i]);
                   }
               }
               if (!empty($arrValues)) {
                   foreach ($arrValues as $k => $v) {
                       $arrNew[$k] = $v;
                   }
               }
               $arrValues = $arrNew;
               unset($arrNew);
           }
       }
       $return = '<input type="hidden" name="' . $this->strName . '" id="ctrl_' . $this->strId . '" value="' . $strValues . '">' . ($this->strOrderField != '' ? '
 <input type="hidden" name="' . $this->strOrderName . '" id="ctrl_' . $this->strOrderId . '" value="' . $this->orderSRC . '">' : '') . '
 <div class="selector_container" id="target_' . $this->strId . '">
   <ul id="sort_' . $this->strId . '" class="' . trim(($this->strOrderField != '' ? 'sortable ' : '') . ($this->blnIsGallery ? 'sgallery' : '')) . '">';
       foreach ($arrValues as $k => $v) {
           $return .= '<li data-id="' . $k . '">' . $v . '</li>';
       }
       $return .= '</ul>
   <p><a href="contao/file.php?table=' . $this->strTable . '&amp;field=' . $this->strField . '&amp;id=' . \Input::get('id') . '&amp;value=' . $strValues . '" class="tl_submit" onclick="Backend.getScrollOffset();Backend.openModalSelector({\'width\':765,\'title\':\'' . $GLOBALS['TL_LANG']['MOD']['files'][0] . '\',\'url\':this.href,\'id\':\'' . $this->strId . '\'});return false">' . $GLOBALS['TL_LANG']['MSC']['changeSelection'] . '</a></p>' . ($this->strOrderField != '' ? '
   <script>Backend.makeMultiSrcSortable("sort_' . $this->strId . '", "ctrl_' . $this->strOrderId . '");</script>' : '') . '
 </div>';
       return $return;
   }
开发者ID:rikaix,项目名称:core,代码行数:97,代码来源:FileTree.php

示例12: getImages

 public function getImages()
 {
     global $objPage;
     $images = array();
     $auxDate = array();
     $objFiles = $this->objFiles;
     if ($objFiles === null) {
         return '';
     }
     // Get all images
     while ($objFiles->next()) {
         // Continue if the files has been processed or does not exist
         if (isset($images[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
             continue;
         }
         // Single files
         if ($objFiles->type == 'file') {
             $objFile = new \File($objFiles->path, true);
             if (!$objFile->isGdImage) {
                 continue;
             }
             $arrMeta = $this->getMetaData($objFiles->meta, $objPage->language);
             // Use the file name as title if none is given
             if ($arrMeta['title'] == '') {
                 $arrMeta['title'] = specialchars($objFile->basename);
             }
             // Add the image
             $images[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objFiles->path, 'alt' => $arrMeta['title'], 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']);
             $auxDate[] = $objFile->mtime;
         } else {
             $objSubfiles = \FilesModel::findByPid($objFiles->uuid);
             if ($objSubfiles === null) {
                 continue;
             }
             while ($objSubfiles->next()) {
                 // Continue if the files has been processed or does not exist
                 if (isset($images[$objSubfiles->path]) || !file_exists(TL_ROOT . '/' . $objSubfiles->path)) {
                     continue;
                 }
                 // Skip subfolders
                 if ($objSubfiles->type == 'folder') {
                     continue;
                 }
                 $objFile = new \File($objSubfiles->path, true);
                 if (!$objFile->isGdImage) {
                     continue;
                 }
                 $arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->language);
                 // Use the file name as title if none is given
                 if ($arrMeta['title'] == '') {
                     $arrMeta['title'] = specialchars($objFile->basename);
                 }
                 // Add the image
                 $images[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objSubfiles->path, 'alt' => $arrMeta['title'], 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']);
                 $auxDate[] = $objFile->mtime;
             }
         }
     }
     // all files do not exist (maybe moved or deleted by FTP or else)
     if (empty($images)) {
         return '';
     }
     // Sort array
     switch ($this->slickSortBy) {
         default:
         case 'name_asc':
             uksort($images, 'basename_natcasecmp');
             break;
         case 'name_desc':
             uksort($images, 'basename_natcasercmp');
             break;
         case 'date_asc':
             array_multisort($images, SORT_NUMERIC, $auxDate, SORT_ASC);
             break;
         case 'date_desc':
             array_multisort($images, SORT_NUMERIC, $auxDate, SORT_DESC);
             break;
         case 'meta':
             // Backwards compatibility
         // Backwards compatibility
         case 'custom':
             if ($this->slickOrderSRC != '') {
                 $tmp = deserialize($this->slickOrderSRC);
                 if (!empty($tmp) && is_array($tmp)) {
                     // Remove all values
                     $arrOrder = array_map(function () {
                     }, array_flip($tmp));
                     // Move the matching elements to their position in $arrOrder
                     foreach ($images as $k => $v) {
                         if (array_key_exists($v['uuid'], $arrOrder)) {
                             $arrOrder[$v['uuid']] = $v;
                             unset($images[$k]);
                         }
                     }
                     // Append the left-over images at the end
                     if (!empty($images)) {
                         $arrOrder = array_merge($arrOrder, array_values($images));
                     }
                     // Remove empty (unreplaced) entries
                     $images = array_values(array_filter($arrOrder));
//.........这里部分代码省略.........
开发者ID:heimrichhannot,项目名称:contao-slick,代码行数:101,代码来源:Slick.php

示例13: compile

 protected function compile(\PageModel $objPage)
 {
     $images = array();
     $auxDate = array();
     $objFiles = $this->objFiles;
     $this->applySettings($objPage);
     while ($objFiles->next()) {
         // Continue if the files has been processed or does not exist
         if (isset($images[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
             continue;
         }
         // Single files
         if ($objFiles->type == 'file') {
             $objFile = new \File($objFiles->path, true);
             if (!$objFile->isGdImage) {
                 continue;
             }
             $arrMeta = $this->getMetaData($objFiles->meta, $objPage->language);
             // Use the file name as title if none is given
             if ($arrMeta['title'] == '') {
                 $arrMeta['title'] = specialchars(str_replace('_', ' ', $objFile->filename));
             }
             // Add the image
             $images[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objFiles->path, 'alt' => $arrMeta['title'], 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']);
             $auxDate[] = $objFile->mtime;
         } else {
             $objSubfiles = \FilesModel::findByPid($objFiles->uuid);
             if ($objSubfiles === null) {
                 continue;
             }
             while ($objSubfiles->next()) {
                 // Skip subfolders
                 if ($objSubfiles->type == 'folder') {
                     continue;
                 }
                 $objFile = new \File($objSubfiles->path, true);
                 if (!$objFile->isGdImage) {
                     continue;
                 }
                 $arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->language);
                 // Use the file name as title if none is given
                 if ($arrMeta['title'] == '') {
                     $arrMeta['title'] = specialchars(str_replace('_', ' ', $objFile->filename));
                 }
                 // Add the image
                 $images[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objSubfiles->path, 'alt' => $arrMeta['title'], 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']);
                 $auxDate[] = $objFile->mtime;
             }
         }
     }
     // Sort array
     switch ($this->sortBy) {
         default:
         case 'name_asc':
             uksort($images, 'basename_natcasecmp');
             break;
         case 'name_desc':
             uksort($images, 'basename_natcasercmp');
             break;
         case 'date_asc':
             array_multisort($images, SORT_NUMERIC, $auxDate, SORT_ASC);
             break;
         case 'date_desc':
             array_multisort($images, SORT_NUMERIC, $auxDate, SORT_DESC);
             break;
         case 'meta':
             // Backwards compatibility
         // Backwards compatibility
         case 'custom':
             if ($this->order != '') {
                 $tmp = deserialize($this->order);
                 if (!empty($tmp) && is_array($tmp)) {
                     // Remove all values
                     $arrOrder = array_map(function () {
                     }, array_flip($tmp));
                     // Move the matching elements to their position in $arrOrder
                     foreach ($images as $k => $v) {
                         if (array_key_exists($v['uuid'], $arrOrder)) {
                             $arrOrder[$v['uuid']] = $v;
                             unset($images[$k]);
                         }
                     }
                     // Append the left-over images at the end
                     if (!empty($images)) {
                         $arrOrder = array_merge($arrOrder, array_values($images));
                     }
                     // Remove empty (unreplaced) entries
                     $images = array_values(array_filter($arrOrder));
                     unset($arrOrder);
                 }
             }
             break;
         case 'random':
             shuffle($images);
             break;
     }
     $images = array_values($images);
     $intMaxWidth = $GLOBALS['TL_CONFIG']['maxImageWidth'];
     $objImages = array();
     $imageIndex = 0;
//.........这里部分代码省略.........
开发者ID:pfitz,项目名称:contao-full-background-images,代码行数:101,代码来源:ContaoFullBgImage.php

示例14: getFileModels

 /**
  * Get the file models
  *
  * @return \Model\Collection|null
  */
 public function getFileModels()
 {
     $albumFolder = $this->getAlbumFolder();
     if ($albumFolder === null) {
         return null;
     }
     return \FilesModel::findByPid($albumFolder->getModel()->uuid);
 }
开发者ID:terminal42,项目名称:contao-facebook-albums,代码行数:13,代码来源:FacebookAlbum.php

示例15: getElements

 private function getElements($objParentFolder, $objPage, $level = 1)
 {
     $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
     $arrElements = array();
     $arrFolders = array();
     $arrFiles = array();
     $objElements = \FilesModel::findByPid($objParentFolder->uuid);
     if ($objElements === null) {
         return $arrElements;
     }
     while ($objElements->next()) {
         if ($objElements->type == 'folder') {
             $elements = $this->getElements($objElements, $objPage, $level + 1);
             if ($this->recursiveDownloadFolderHideEmptyFolders && !empty($elements) || !$this->recursiveDownloadFolderHideEmptyFolders) {
                 $strCssClass = 'folder';
                 if ($this->recursiveDownloadFolderShowAllLevels) {
                     $strCssClass .= ' folder-open';
                 }
                 if (empty($elements)) {
                     $strCssClass .= ' folder-empty';
                 }
                 $arrFolders[$objElements->name] = array('type' => $objElements->type, 'data' => $this->getFolderData($objElements, $objPage), 'elements' => $elements, 'elements_rendered' => $this->getElementsRendered($elements, $level + 1), 'is_empty' => empty($elements), 'css_class' => $strCssClass);
             }
         } else {
             $objFile = new \File($objElements->path, true);
             if (in_array($objFile->extension, $allowedDownload) && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
                 $arrFileData = $this->getFileData($objFile, $objElements, $objPage);
                 $strCssClass = 'file file-' . $arrFileData['extension'];
                 $arrFiles[$objFile->basename] = array('type' => $objElements->type, 'data' => $arrFileData, 'css_class' => $strCssClass);
             }
         }
     }
     // sort the folders and files alphabetically by their name
     ksort($arrFolders);
     ksort($arrFiles);
     // merge folders and files into one array (foders at first, files afterwards)
     $arrElements = array_values($arrFolders);
     $arrElements = array_merge($arrElements, array_values($arrFiles));
     return $arrElements;
 }
开发者ID:hofff,项目名称:contao-recursive-download-folder,代码行数:40,代码来源:ContentRecursiveDownloadFolder.php


注:本文中的FilesModel::findByPid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。