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


PHP FilesModel::findMultipleByIds方法代码示例

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


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

示例1: generate

 /**
  * Generate media attribute
  *
  * @param \Isotope\Interfaces\IsotopeProduct $objProduct
  * @param array $arrOptions
  * @return string
  */
 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     $strPoster = null;
     $arrFiles = deserialize($objProduct->{$this->field_name}, true);
     // 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 '';
     }
     // Find poster
     while ($objFiles->next()) {
         if (in_array($objFiles->extension, trimsplit(',', $GLOBALS['TL_CONFIG']['validImageTypes']))) {
             $strPoster = $objFiles->uuid;
             $arrFiles = array_diff($arrFiles, array($objFiles->uuid));
         }
     }
     $objContentModel = new \ContentModel();
     $objContentModel->type = 'media';
     $objContentModel->cssID = serialize(array('', $this->field_name));
     $objContentModel->playerSRC = serialize($arrFiles);
     $objContentModel->posterSRC = $strPoster;
     if ($arrOptions['autoplay']) {
         $objContentModel->autoplay = '1';
     }
     if ($arrOptions['width'] || $arrOptions['height']) {
         $objContentModel->playerSize = serialize(array($arrOptions['width'], $arrOptions['height']));
     }
     $objElement = new \ContentMedia($objContentModel);
     return $objElement->generate();
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:41,代码来源:Media.php

示例2: generate

 /**
  * Return if there are no files
  * @return string
  */
 public function generate()
 {
     // Use the home directory of the current user as file source
     if ($this->useHomeDir && FE_USER_LOGGED_IN) {
         $this->import('FrontendUser', 'User');
         if ($this->User->assignDir && is_dir(TL_ROOT . '/' . $this->User->homeDir)) {
             $this->multiSRC = array($this->User->homeDir);
         }
     } else {
         $this->multiSRC = deserialize($this->multiSRC);
     }
     // Return if there are no files
     if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
         return '';
     }
     // Check for version 3 format
     if (!is_numeric($this->multiSRC[0])) {
         return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
     }
     // Get the file entries from the database
     $this->objFiles = \FilesModel::findMultipleByIds($this->multiSRC);
     if ($this->objFiles === null) {
         return '';
     }
     return parent::generate();
 }
开发者ID:rikaix,项目名称:core,代码行数:30,代码来源:ContentGallery.php

示例3: generate

 /**
  * Return if there are no files
  * @return string
  */
 public function generate()
 {
     // Use the home directory of the current user as file source
     if ($this->useHomeDir && FE_USER_LOGGED_IN) {
         $this->import('FrontendUser', 'User');
         if ($this->User->assignDir && is_dir(TL_ROOT . '/' . $this->User->homeDir)) {
             $this->multiSRC = array($this->User->homeDir);
         }
     } else {
         $this->multiSRC = deserialize($this->multiSRC);
     }
     // Return if there are no files
     if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
         return '';
     }
     // Check for version 3 format
     if (!is_numeric($this->multiSRC[0])) {
         return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
     }
     // Get the file entries from the database
     $this->objFiles = \FilesModel::findMultipleByIds($this->multiSRC);
     if ($this->objFiles === null) {
         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 ($this->objFiles->next()) {
             if ($file == $this->objFiles->path || dirname($file) == $this->objFiles->path) {
                 $this->sendFileToBrowser($file);
             }
         }
     }
     return parent::generate();
 }
开发者ID:rburch,项目名称:core,代码行数:39,代码来源:ContentDownloads.php

示例4: generate

 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     $varValue = $objProduct->{$this->field_name};
     if ($this->fieldType == 'checkbox') {
         $varValue = deserialize($varValue, true);
     }
     $objFiles = \FilesModel::findMultipleByIds((array) $varValue);
     if (null !== $objFiles) {
         return $this->generateList($objFiles->fetchEach('path'));
     }
     return '';
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:12,代码来源:FileTree.php

示例5: generate

 /**
  * Check the source folder
  * @return string
  */
 public function generate()
 {
     $this->multiSRC = deserialize($this->multiSRC);
     if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
         return '';
     }
     // Check for version 3 format
     if (!is_numeric($this->multiSRC[0])) {
         return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
     }
     // Get the file entries from the database
     $this->objFiles = \FilesModel::findMultipleByIds($this->multiSRC);
     if ($this->objFiles === null) {
         return '';
     }
     return parent::generate();
 }
开发者ID:rikaix,项目名称:core,代码行数:21,代码来源:ModuleRandomImage.php

示例6: addEnclosuresToTemplate

 /**
  * Add enclosures to a template
  * 
  * @param object $objTemplate The template object to add the enclosures to
  * @param array  $arrItem     The element or module as array
  */
 public static function addEnclosuresToTemplate($objTemplate, $arrItem)
 {
     $arrEnclosures = deserialize($arrItem['enclosure']);
     if (!is_array($arrEnclosures) || empty($arrEnclosures)) {
         return;
     }
     // Check for version 3 format
     if (!is_numeric($arrEnclosures[0])) {
         foreach (array('details', 'answer', 'text') as $key) {
             if (isset($objTemplate->{$key})) {
                 $objTemplate->{$key} = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         }
         return;
     }
     $objFiles = \FilesModel::findMultipleByIds($arrEnclosures);
     if ($objFiles === null) {
         return;
     }
     $file = \Input::get('file', true);
     // Send the file to the browser
     if ($file != '') {
         while ($objFiles->next()) {
             if ($file == $objFiles->path) {
                 static::sendFileToBrowser($file);
             }
         }
         // Do not index or cache the page
         global $objPage;
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         foreach (array('details', 'answer', 'text') as $key) {
             if (isset($objTemplate->{$key})) {
                 $objTemplate->{$key} = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['ERR']['download'], $file) . '</p>';
             }
         }
     }
     $arrEnclosures = array();
     $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
     // Add download links
     while ($objFiles->next()) {
         if ($objFiles->type == 'file') {
             if (!in_array($objFiles->extension, $allowedDownload)) {
                 continue;
             }
             $objFile = new \File($objFiles->path);
             $arrEnclosures[] = array('link' => $objFiles->name, 'filesize' => static::getReadableSize($objFile->filesize), 'title' => ucfirst(str_replace('_', ' ', $objFile->filename)), 'href' => \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&amp;' : '?') . 'file=' . static::urlEncode($objFiles->path), 'enclosure' => $objFiles->path, 'icon' => TL_FILES_URL . 'system/themes/' . static::getTheme() . '/images/' . $objFile->icon, 'mime' => $objFile->mime);
         }
     }
     $objTemplate->enclosure = $arrEnclosures;
 }
开发者ID:rikaix,项目名称:core,代码行数:59,代码来源:Controller.php

示例7: convertValuesToPaths

 /**
  * Translate the file IDs to file paths
  */
 protected function convertValuesToPaths()
 {
     if (empty($this->varValue)) {
         return;
     }
     if (!is_array($this->varValue)) {
         $this->varValue = array($this->varValue);
     } elseif (empty($this->varValue[0])) {
         $this->varValue = array();
     }
     $objFiles = \FilesModel::findMultipleByIds($this->varValue);
     if ($objFiles !== null) {
         $this->varValue = array_values($objFiles->fetchEach('path'));
     }
 }
开发者ID:iCodr8,项目名称:core,代码行数:18,代码来源:FileSelector.php

示例8: parsePage

 /**
  * Parse the given page and return the image information
  * @param    \PageModel
  * @return   array
  */
 protected static function parsePage(\PageModel $objPage)
 {
     if ($objPage->pageImage == '') {
         return array();
     }
     $arrImages = array();
     $objImages = \FilesModel::findMultipleByIds(deserialize($objPage->pageImage, true));
     if (null !== $objImages) {
         while ($objImages->next()) {
             $objFile = new \File($objImages->path, true);
             if (!$objFile->isGdImage) {
                 continue;
             }
             $arrImage = $objImages->row();
             $arrMeta = static::getMetaData($objImages->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)));
             }
             $arrImage['alt'] = $objPage->pageImageAlt;
             $arrImage['imageUrl'] = $arrMeta['link'];
             $arrImage['caption'] = $arrMeta['caption'];
             if (null !== $objPage->getRelated('pageImageJumpTo')) {
                 $arrImage['hasLink'] = true;
                 $arrImage['title'] = $objPage->pageImageTitle ?: ($arrMeta['title'] ?: ($objJumpTo->pageTitle ?: $objJumpTo->title));
                 $arrImage['href'] = \Controller::generateFrontendUrl($objPage->getRelated('pageImageJumpTo')->row());
             }
             $arrImages[] = $arrImage;
         }
         $arrOrder = deserialize($objPage->pageImageOrder);
         if (!empty($arrOrder) && is_array($arrOrder)) {
             // Remove all values
             $arrOrder = array_map(function () {
             }, array_flip($arrOrder));
             // Move the matching elements to their position in $arrOrder
             foreach ($arrImages as $k => $v) {
                 if (array_key_exists($v['uuid'], $arrOrder)) {
                     $arrOrder[$v['uuid']] = $v;
                     unset($arrImages[$k]);
                 }
             }
             // Append the left-over images at the end
             if (!empty($arrImages)) {
                 $arrOrder = array_merge($arrOrder, array_values($arrImages));
             }
             // Remove empty (unreplaced) entries
             $arrImages = array_values(array_filter($arrOrder));
             unset($arrOrder);
         }
     }
     return $arrImages;
 }
开发者ID:delirius,项目名称:contao-pageimage,代码行数:57,代码来源:PageImage.php

示例9: parseSlides

    /**
     * Parse slides
     *
     * @param  \Model\Collection $objSlides slides retrieved from the database
     * @return array                        parsed slides
     */
    protected function parseSlides($objSlides)
    {
        global $objPage;
        $slides = array();
        $pids = array();
        $idIndexes = array();
        if (!$objSlides) {
            return $slides;
        }
        while ($objSlides->next()) {
            $slide = $objSlides->row();
            $slide['text'] = '';
            $pids[] = $slide['id'];
            $idIndexes[(int) $slide['id']] = count($slides);
            if (trim($slide['singleSRC']) && ($file = version_compare(VERSION, '3.2', '<') ? \FilesModel::findByPk($slide['singleSRC']) : \FilesModel::findByUuid($slide['singleSRC'])) && ($fileObject = new \File($file->path, true)) && ($fileObject->isGdImage || $fileObject->isImage)) {
                $meta = $this->getMetaData($file->meta, $objPage->language);
                $slide['image'] = new \stdClass();
                $this->addImageToTemplate($slide['image'], array('id' => $file->id, 'name' => $fileObject->basename, 'singleSRC' => $file->path, 'alt' => $meta['title'], 'imageUrl' => $meta['link'], 'caption' => $meta['caption'], 'size' => isset($this->imgSize) ? $this->imgSize : $this->size));
            }
            if ($slide['videoURL'] && empty($slide['image'])) {
                $slide['image'] = new \stdClass();
                if (preg_match('(^
						https?://  # http or https
						(?:
							www\\.youtube\\.com/(?:watch\\?v=|v/|embed/)  # Different URL formats
							| youtu\\.be/  # Short YouTube domain
						)
						([0-9a-z_\\-]{11})  # YouTube ID
						(?:$|&|/)  # End or separator
					)ix', html_entity_decode($slide['videoURL']), $matches)) {
                    $video = $matches[1];
                    $slide['image']->src = '//img.youtube.com/vi/' . $video . '/0.jpg';
                } else {
                    // Grey dummy image
                    $slide['image']->src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAJCAMAAAAM9FwAAAAAA1BMVEXGxsbd/8BlAAAAFUlEQVR42s3BAQEAAACAkP6vdiO6AgCZAAG/wrlvAAAAAElFTkSuQmCC';
                }
                $slide['image']->imgSize = '';
                $slide['image']->alt = '';
                if (version_compare(VERSION, '3.4', '>=')) {
                    $slide['image']->picture = array('img' => array('src' => $slide['image']->src, 'srcset' => $slide['image']->src), 'sources' => array());
                }
            }
            if ($slide['videos']) {
                $videoFiles = deserialize($slide['videos'], true);
                if (version_compare(VERSION, '3.2', '<')) {
                    $videoFiles = \FilesModel::findMultipleByIds($videoFiles);
                } else {
                    $videoFiles = \FilesModel::findMultipleByUuids($videoFiles);
                }
                $videos = array();
                foreach ($videoFiles as $file) {
                    $videos[] = $file;
                }
                $slide['videos'] = $videos;
            }
            if (trim($slide['backgroundImage']) && ($file = version_compare(VERSION, '3.2', '<') ? \FilesModel::findByPk($slide['backgroundImage']) : \FilesModel::findByUuid($slide['backgroundImage'])) && ($fileObject = new \File($file->path, true)) && ($fileObject->isGdImage || $fileObject->isImage)) {
                $meta = $this->getMetaData($file->meta, $objPage->language);
                $slide['backgroundImage'] = new \stdClass();
                $this->addImageToTemplate($slide['backgroundImage'], array('id' => $file->id, 'name' => $fileObject->basename, 'singleSRC' => $file->path, 'alt' => $meta['title'], 'imageUrl' => $meta['link'], 'caption' => $meta['caption'], 'size' => $slide['backgroundImageSize']));
            } else {
                $slide['backgroundImage'] = null;
            }
            if ($slide['backgroundVideos']) {
                $videoFiles = deserialize($slide['backgroundVideos'], true);
                if (version_compare(VERSION, '3.2', '<')) {
                    $videoFiles = \FilesModel::findMultipleByIds($videoFiles);
                } else {
                    $videoFiles = \FilesModel::findMultipleByUuids($videoFiles);
                }
                $videos = array();
                foreach ($videoFiles as $file) {
                    $videos[] = $file;
                }
                $slide['backgroundVideos'] = $videos;
            }
            if ($this->rsts_navType === 'thumbs') {
                $slide['thumb'] = new \stdClass();
                if (trim($slide['thumbImage']) && ($file = version_compare(VERSION, '3.2', '<') ? \FilesModel::findByPk($slide['thumbImage']) : \FilesModel::findByUuid($slide['thumbImage'])) && ($fileObject = new \File($file->path, true)) && ($fileObject->isGdImage || $fileObject->isImage)) {
                    $this->addImageToTemplate($slide['thumb'], array('id' => $file->id, 'name' => $fileObject->basename, 'singleSRC' => $file->path, 'size' => $this->rsts_thumbs_imgSize));
                } elseif (trim($slide['singleSRC']) && ($file = version_compare(VERSION, '3.2', '<') ? \FilesModel::findByPk($slide['singleSRC']) : \FilesModel::findByUuid($slide['singleSRC'])) && ($fileObject = new \File($file->path, true)) && ($fileObject->isGdImage || $fileObject->isImage)) {
                    $this->addImageToTemplate($slide['thumb'], array('id' => $file->id, 'name' => $fileObject->basename, 'singleSRC' => $file->path, 'size' => $this->rsts_thumbs_imgSize));
                } elseif (!empty($slide['image']->src)) {
                    $slide['thumb'] = clone $slide['image'];
                } elseif (!empty($slide['backgroundImage']->src)) {
                    $slide['thumb'] = clone $slide['backgroundImage'];
                }
            }
            $slides[] = $slide;
        }
        $slideContents = ContentModel::findPublishedByPidsAndTable($pids, SlideModel::getTable());
        if ($slideContents) {
            while ($slideContents->next()) {
                $slides[$idIndexes[(int) $slideContents->pid]]['text'] .= $this->getContentElement($slideContents->current());
            }
//.........这里部分代码省略.........
开发者ID:GerqEV,项目名称:cdemo2,代码行数:101,代码来源:Slider.php

示例10: exportTheme

 /**
  * Export a theme
  * @param \DataContainer
  */
 public function exportTheme(\DataContainer $dc)
 {
     // Get the theme meta data
     $objTheme = $this->Database->prepare("SELECT * FROM tl_theme WHERE id=?")->limit(1)->execute($dc->id);
     if ($objTheme->numRows < 1) {
         return;
     }
     // Romanize the name
     $strName = utf8_romanize($objTheme->name);
     $strName = strtolower(str_replace(' ', '_', $strName));
     $strName = preg_replace('/[^A-Za-z0-9\\._-]/', '', $strName);
     $strName = basename($strName);
     // Replace the numeric folder IDs
     $arrFolders = deserialize($objTheme->folders);
     if (is_array($arrFolders) && !empty($arrFolders)) {
         $objFolders = \FilesModel::findMultipleByIds($arrFolders);
         if ($objFolders !== null) {
             $objTheme->folders = serialize($objFolders->fetchEach('path'));
         }
     }
     // Replace the numeric screenshot ID
     if ($objTheme->screenshot != '') {
         $objFile = \FilesModel::findByPk($objTheme->screenshot);
         if ($objFile !== null) {
             $objTheme->screenshot = $objFile->path;
         }
     }
     // Create a new XML document
     $xml = new \DOMDocument('1.0', 'UTF-8');
     $xml->formatOutput = true;
     // Root element
     $tables = $xml->createElement('tables');
     $tables = $xml->appendChild($tables);
     // Add the tables
     $this->addTableTlTheme($xml, $tables, $objTheme);
     $this->addTableTlStyleSheet($xml, $tables, $objTheme);
     $this->addTableTlModule($xml, $tables, $objTheme);
     $this->addTableTlLayout($xml, $tables, $objTheme);
     // Generate the archive
     $strTmp = md5(uniqid(mt_rand(), true));
     $objArchive = new \ZipWriter('system/tmp/' . $strTmp);
     // Add the XML document
     $objArchive->addString($xml->saveXML(), 'theme.xml');
     // Add the folders
     $arrFolders = deserialize($objTheme->folders);
     if (is_array($arrFolders) && !empty($arrFolders)) {
         foreach ($this->eliminateNestedPaths($arrFolders) as $strFolder) {
             $this->addFolderToArchive($objArchive, $strFolder);
         }
     }
     // Add the template files
     $this->addTemplatesToArchive($objArchive, $objTheme->templates);
     // Close the archive
     $objArchive->close();
     // Open the "save as …" dialogue
     $objFile = new \File('system/tmp/' . $strTmp);
     header('Content-Type: application/octet-stream');
     header('Content-Transfer-Encoding: binary');
     header('Content-Disposition: attachment; filename="' . $strName . '.cto"');
     header('Content-Length: ' . $objFile->filesize);
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     header('Expires: 0');
     $resFile = fopen(TL_ROOT . '/system/tmp/' . $strTmp, 'rb');
     fpassthru($resFile);
     fclose($resFile);
     exit;
 }
开发者ID:rikaix,项目名称:core,代码行数:72,代码来源:Theme.php

示例11: addEvent

 /**
  * Add an event to the array of active events
  * @param object
  * @param integer
  * @param integer
  * @param string
  * @param string
  */
 protected function addEvent($objEvent, $intStart, $intEnd, $strUrl, $strBase)
 {
     if ($intEnd < time()) {
         return;
     }
     global $objPage;
     // Called in the back end (see #4026)
     if ($objPage === null) {
         $objPage = new \stdClass();
         $objPage->dateFormat = $GLOBALS['TL_CONFIG']['dateFormat'];
         $objPage->datimFormat = $GLOBALS['TL_CONFIG']['datimFormat'];
         $objPage->timeFormat = $GLOBALS['TL_CONFIG']['timeFormat'];
     }
     $intKey = date('Ymd', $intStart);
     $span = self::calculateSpan($intStart, $intEnd);
     $format = $objEvent->addTime ? 'datimFormat' : 'dateFormat';
     // Add date
     if ($span > 0) {
         $title = $this->parseDate($objPage->{$format}, $intStart) . ' - ' . $this->parseDate($objPage->{$format}, $intEnd);
     } else {
         $title = $this->parseDate($objPage->dateFormat, $intStart) . ($objEvent->addTime ? ' (' . $this->parseDate($objPage->timeFormat, $intStart) . ($intStart < $intEnd ? ' - ' . $this->parseDate($objPage->timeFormat, $intEnd) : '') . ')' : '');
     }
     // Add title and link
     $title .= ' ' . $objEvent->title;
     $link = '';
     switch ($objEvent->source) {
         case 'external':
             $link = $objEvent->url;
             break;
         case 'internal':
             if (($objTarget = $objEvent->getRelated('jumpTo')) !== null) {
                 $link = $strBase . $this->generateFrontendUrl($objTarget->row());
             }
             break;
         case 'article':
             if (($objArticle = \ArticleModel::findByPk($objEvent->articleId, array('eager' => true))) !== null) {
                 $link = $strBase . ampersand($this->generateFrontendUrl($objArticle->getRelated('pid')->row(), '/articles/' . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id)));
             }
             break;
     }
     // Link to the default page
     if ($link == '') {
         $link = $strBase . sprintf($strUrl, $objEvent->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objEvent->alias : $objEvent->id);
     }
     // Clean the RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $objEvent->teaser = \String::toXhtml($objEvent->teaser);
     } else {
         $objEvent->teaser = \String::toHtml5($objEvent->teaser);
     }
     $arrEvent = array('title' => $title, 'description' => $objEvent->details, 'teaser' => $objEvent->teaser, 'link' => $link, 'published' => $objEvent->tstamp, 'authorName' => $objEvent->authorName);
     // Add the article image as enclosure
     if ($objEvent->addImage) {
         $objFile = \FilesModel::findByPk($objEvent->singleSRC);
         if ($objFile !== null) {
             $arrEvent['enclosure'][] = $objFile->path;
         }
     }
     // Enclosures
     if ($objEvent->addEnclosure) {
         $arrEnclosure = deserialize($objEvent->enclosure, true);
         if (is_array($arrEnclosure)) {
             $objFile = \FilesModel::findMultipleByIds($arrEnclosure);
             while ($objFile->next()) {
                 $arrEvent['enclosure'][] = $objFile->path;
             }
         }
     }
     $this->arrEvents[$intKey][$intStart][] = $arrEvent;
 }
开发者ID:rburch,项目名称:core,代码行数:78,代码来源:Calendar.php

示例12: headerCallback

 /**
  * DCA Header callback
  *
  * Adds selected images to the header or redirects to the parent slider if
  * no slides are found
  *
  * @param  array          $headerFields label value pairs of header fields
  * @param  \DataContainer $dc           data container
  * @return array
  */
 public function headerCallback($headerFields, $dc)
 {
     $sliderData = $this->Database->prepare('SELECT * FROM ' . $GLOBALS['TL_DCA'][$dc->table]['config']['ptable'] . ' WHERE id = ?')->limit(1)->execute(CURRENT_ID);
     if ($sliderData->numRows < 1) {
         return $headerFields;
     }
     $files = deserialize($sliderData->multiSRC);
     if (is_array($files) && count($files)) {
         $slidesCount = $this->Database->prepare('SELECT count(*) as count FROM ' . $dc->table . ' WHERE pid = ?')->execute(CURRENT_ID);
         if (!$slidesCount->count) {
             $this->redirect('contao/main.php?do=rocksolid_slider&act=edit&id=' . CURRENT_ID . '&ref=' . \Input::get('ref') . '&rt=' . REQUEST_TOKEN);
         }
         $headerFields[$GLOBALS['TL_LANG']['tl_rocksolid_slide']['headerImagesSelected'][0]] = $GLOBALS['TL_LANG']['tl_rocksolid_slide']['headerImagesSelected'][1];
         $images = array();
         if (version_compare(VERSION, '3.2', '<')) {
             $files = \FilesModel::findMultipleByIds($files);
         } else {
             $files = \FilesModel::findMultipleByUuids($files);
         }
         while ($files->next()) {
             // 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) {
                 continue;
             }
             // Add the image
             $images[$files->path] = array('id' => $files->id, 'uuid' => isset($files->uuid) ? $files->uuid : null, 'name' => $file->basename, 'path' => $files->path);
         }
         if ($sliderData->orderSRC) {
             // Turn the order string into an array and remove all values
             if (version_compare(VERSION, '3.2', '<')) {
                 $order = explode(',', $sliderData->orderSRC);
                 $order = array_map('intval', $order);
             } else {
                 $order = deserialize($sliderData->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);
         $imagesHtml = '';
         foreach ($images as $image) {
             $imagesHtml .= ' ' . $this->generateImage(\Image::get($image['path'], 60, 45, 'center_center'), '', 'class="gimage"');
         }
         $headerFields[$GLOBALS['TL_LANG']['tl_rocksolid_slide']['headerImages']] = '<div style="margin-top: 12px; margin-right: -40px;">' . $imagesHtml . '</div>';
     }
     return $headerFields;
 }
开发者ID:GerqEV,项目名称:cdemo2,代码行数:77,代码来源:Slider.php

示例13: generateFiles

 /**
  * Generate an XML files and save them to the root directory
  * @param array
  */
 protected function generateFiles($arrFeed)
 {
     $arrArchives = deserialize($arrFeed['archives']);
     if (!is_array($arrArchives) || empty($arrArchives)) {
         return;
     }
     $strType = $arrFeed['format'] == 'atom' ? 'generateAtom' : 'generateRss';
     $strLink = $arrFeed['feedBase'] ?: \Environment::get('base');
     $strFile = $arrFeed['feedName'];
     $objFeed = new \Feed($strFile);
     $objFeed->link = $strLink;
     $objFeed->title = $arrFeed['title'];
     $objFeed->description = $arrFeed['description'];
     $objFeed->language = $arrFeed['language'];
     $objFeed->published = $arrFeed['tstamp'];
     // Get the items
     if ($arrFeed['maxItems'] > 0) {
         $objArticle = \NewsModel::findPublishedByPids($arrArchives, null, $arrFeed['maxItems']);
     } else {
         $objArticle = \NewsModel::findPublishedByPids($arrArchives);
     }
     // Parse the items
     if ($objArticle !== null) {
         $arrUrls = array();
         while ($objArticle->next()) {
             $jumpTo = $objArticle->getRelated('pid')->jumpTo;
             // No jumpTo page set (see #4784)
             if (!$jumpTo) {
                 continue;
             }
             // Get the jumpTo URL
             if (!isset($arrUrls[$jumpTo])) {
                 $objParent = $this->getPageDetails($jumpTo);
                 $arrUrls[$jumpTo] = $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrUrls[$jumpTo];
             $objItem = new \FeedItem();
             $objItem->title = $objArticle->headline;
             $objItem->link = $this->getLink($objArticle, $strUrl, $strLink);
             $objItem->published = $objArticle->date;
             $objItem->author = $objArticle->authorName;
             // Prepare the description
             if ($arrFeed['source'] == 'source_text') {
                 $strDescription = '';
                 $objElement = \ContentModel::findPublishedByPidAndTable($objArticle->id, 'tl_news');
                 if ($objElement !== null) {
                     while ($objElement->next()) {
                         $strDescription .= $this->getContentElement($objElement->id);
                     }
                 }
             } else {
                 $strDescription = $objArticle->teaser;
             }
             $strDescription = $this->replaceInsertTags($strDescription);
             $objItem->description = $this->convertRelativeUrls($strDescription, $strLink);
             // Add the article image as enclosure
             if ($objArticle->addImage) {
                 $objFile = \FilesModel::findByPk($objArticle->singleSRC);
                 if ($objFile !== null) {
                     $objItem->addEnclosure($objFile->path);
                 }
             }
             // Enclosures
             if ($objArticle->addEnclosure) {
                 $arrEnclosure = deserialize($objArticle->enclosure, true);
                 if (is_array($arrEnclosure)) {
                     $objFile = \FilesModel::findMultipleByIds($arrEnclosure);
                     while ($objFile->next()) {
                         $objItem->addEnclosure($objFile->path);
                     }
                 }
             }
             $objFeed->addItem($objItem);
         }
     }
     // Create the file
     $objRss = new \File('share/' . $strFile . '.xml');
     $objRss->write($this->replaceInsertTags($objFeed->{$strType}()));
     $objRss->close();
 }
开发者ID:rburch,项目名称:core,代码行数:84,代码来源:News.php

示例14: createHeaderScripts

 /**
  * Create all header scripts
  * @param object
  * @param object
  * @throws \Exception
  */
 protected function createHeaderScripts($objPage, $objLayout)
 {
     $strStyleSheets = '';
     $strCcStyleSheets = '';
     $arrStyleSheets = deserialize($objLayout->stylesheet);
     $blnXhtml = $objPage->outputFormat == 'xhtml';
     $strTagEnding = $blnXhtml ? ' />' : '>';
     $arrFramework = deserialize($objLayout->framework);
     // Google web fonts
     if ($objLayout->webfonts != '') {
         $protocol = \Environment::get('ssl') ? 'https://' : 'http://';
         $strStyleSheets .= '<link' . ($blnXhtml ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . $protocol . 'fonts.googleapis.com/css?family=' . $objLayout->webfonts . '"' . $strTagEnding . "\n";
     }
     // Add the Contao CSS framework style sheets
     if (is_array($arrFramework)) {
         foreach ($arrFramework as $strFile) {
             if ($strFile != 'tinymce.css') {
                 $GLOBALS['TL_FRAMEWORK_CSS'][] = 'assets/contao/css/' . $strFile;
             }
         }
     }
     // Add the TinyMCE style sheet
     if (is_array($arrFramework) && in_array('tinymce.css', $arrFramework) && file_exists(TL_ROOT . '/' . $GLOBALS['TL_CONFIG']['uploadPath'] . '/tinymce.css')) {
         $GLOBALS['TL_FRAMEWORK_CSS'][] = $GLOBALS['TL_CONFIG']['uploadPath'] . '/tinymce.css';
     }
     // User style sheets
     if (is_array($arrStyleSheets) && strlen($arrStyleSheets[0])) {
         $objStylesheets = \StyleSheetModel::findByIds($arrStyleSheets);
         if ($objStylesheets !== null) {
             while ($objStylesheets->next()) {
                 $media = implode(',', deserialize($objStylesheets->media));
                 // Overwrite the media type with a custom media query
                 if ($objStylesheets->mediaQuery != '') {
                     $media = $objStylesheets->mediaQuery;
                 }
                 // Aggregate regular style sheets
                 if (!$objStylesheets->cc && !$objStylesheets->hasFontFace) {
                     $GLOBALS['TL_USER_CSS'][] = 'assets/css/' . $objStylesheets->name . '.css|' . $media . '|static|' . max($objStylesheets->tstamp, $objStylesheets->tstamp2, $objStylesheets->tstamp3);
                 } else {
                     $strStyleSheet = '<link' . ($blnXhtml ? ' type="text/css"' : '') . ' rel="stylesheet" href="' . TL_ASSETS_URL . 'assets/css/' . $objStylesheets->name . '.css"' . ($media != '' && $media != 'all' ? ' media="' . $media . '"' : '') . $strTagEnding;
                     if ($objStylesheets->cc) {
                         $strStyleSheet = '<!--[' . $objStylesheets->cc . ']>' . $strStyleSheet . '<![endif]-->';
                     }
                     $strCcStyleSheets .= $strStyleSheet . "\n";
                 }
             }
         }
     }
     $arrExternal = deserialize($objLayout->external);
     // External style sheets
     if (is_array($arrExternal) && !empty($arrExternal)) {
         // Get the file entries from the database
         $objFiles = \FilesModel::findMultipleByIds($arrExternal);
         if ($objFiles !== null) {
             while ($objFiles->next()) {
                 if (file_exists(TL_ROOT . '/' . $objFiles->path)) {
                     $GLOBALS['TL_USER_CSS'][] = $objFiles->path . '||static';
                 }
             }
         }
     }
     // Add a placeholder for dynamic style sheets (see #4203)
     $strStyleSheets .= '[[TL_CSS]]';
     // Add the debug style sheet
     if ($GLOBALS['TL_CONFIG']['debugMode']) {
         $strStyleSheets .= '<link rel="stylesheet" href="' . $this->addStaticUrlTo('assets/contao/css/debug.css') . '"' . $strTagEnding . "\n";
     }
     // Always add conditional style sheets at the end
     $strStyleSheets .= $strCcStyleSheets;
     $newsfeeds = deserialize($objLayout->newsfeeds);
     $calendarfeeds = deserialize($objLayout->calendarfeeds);
     // Add newsfeeds
     if (is_array($newsfeeds) && !empty($newsfeeds)) {
         $objFeeds = \NewsFeedModel::findByIds($newsfeeds);
         if ($objFeeds !== null) {
             while ($objFeeds->next()) {
                 $base = $objFeeds->feedBase ?: \Environment::get('base');
                 $strStyleSheets .= '<link rel="alternate" href="' . $base . 'share/' . $objFeeds->alias . '.xml" type="application/' . $objFeeds->format . '+xml" title="' . $objFeeds->title . '"' . $strTagEnding . "\n";
             }
         }
     }
     // Add calendarfeeds
     if (is_array($calendarfeeds) && !empty($calendarfeeds)) {
         $objFeeds = \CalendarFeedModel::findByIds($calendarfeeds);
         if ($objFeeds !== null) {
             while ($objFeeds->next()) {
                 $base = $objFeeds->feedBase ?: \Environment::get('base');
                 $strStyleSheets .= '<link rel="alternate" href="' . $base . 'share/' . $objFeeds->alias . '.xml" type="application/' . $objFeeds->format . '+xml" title="' . $objFeeds->title . '"' . $strTagEnding . "\n";
             }
         }
     }
     // Add a placeholder for dynamic <head> tags (see #4203)
     $strHeadTags = '[[TL_HEAD]]';
     // Add the user <head> tags
//.........这里部分代码省略.........
开发者ID:rburch,项目名称:core,代码行数:101,代码来源:PageRegular.php

示例15: showAll

 public function showAll()
 {
     $return = '';
     $query = 'SELECT * FROM tl_theme ORDER BY name ';
     $objRowStmt = $this->Database->prepare($query);
     $objRow = $objRowStmt->execute();
     $themeList = array();
     $result = $objRow->fetchAllAssoc();
     $this->import('FilesModel');
     foreach ($result as $row) {
         $files = array();
         if (version_compare(VERSION, '3.2', '<')) {
             $folders = \FilesModel::findMultipleByIds(deserialize($row['folders']));
         } else {
             $folders = \FilesModel::findMultipleByUuids(deserialize($row['folders']));
         }
         if ($folders !== null) {
             foreach ($folders->fetchEach('path') as $folder) {
                 $filesResult = \FilesModel::findBy(array($this->FilesModel->getTable() . '.path LIKE ? AND extension = \'base\''), $folder . '/%');
                 if ($filesResult === null) {
                     continue;
                 }
                 foreach ($filesResult->fetchEach('path') as $file) {
                     if (!file_exists(TL_ROOT . '/' . substr($file, 0, -5))) {
                         continue;
                     }
                     $extension = explode('.', $file);
                     $extension = $extension[count($extension) - 2];
                     $files[] = array('id' => $file, 'type' => $extension === 'html5' ? 'html' : $extension, 'name' => substr($file, strlen($folder) + 1, -5));
                 }
             }
         }
         $templateFiles = scandir(TL_ROOT . '/' . $row['templates']);
         foreach ($templateFiles as $file) {
             if (substr($file, -5) === '.base' && file_exists(TL_ROOT . '/' . $row['templates'] . '/' . substr($file, 0, -5))) {
                 $extension = explode('.', $file);
                 $extension = $extension[count($extension) - 2];
                 $files[] = array('id' => $row['templates'] . '/' . $file, 'type' => $extension === 'html5' ? 'html' : $extension, 'name' => substr($file, 0, -5));
             }
         }
         if (version_compare(VERSION, '3.2', '<')) {
             $screenshot = \FilesModel::findByPk($row['screenshot']);
         } else {
             $screenshot = \FilesModel::findByUuid($row['screenshot']);
         }
         if ($screenshot) {
             $screenshot = TL_FILES_URL . \Image::get($screenshot->path, 40, 30, 'center_top');
         }
         if (count($files)) {
             $themeList[] = array('name' => $row['name'], 'files' => $files, 'screenshot' => $screenshot);
         }
     }
     if (!count($themeList)) {
         return '<p class="tl_empty">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p>';
     }
     $return .= '<div id="tl_buttons">' . $this->generateGlobalButtons() . '</div>' . \Message::generate(true);
     $return .= '<div class="tl_listing_container list_view">';
     $return .= '<table class="tl_listing' . ($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['showColumns'] ? ' showColumns' : '') . '">';
     foreach ($themeList as $key => $theme) {
         if ($key) {
             $return .= '<tr style="height: 30px;"><td colspan="2">&nbsp;</td></tr>';
         }
         $return .= '<tr><td colspan="2" class="tl_folder_tlist">';
         if ($theme['screenshot']) {
             $return .= '<img src="' . $theme['screenshot'] . '" alt="" class="theme_preview"> ';
         }
         $return .= $theme['name'] . '</td></tr>';
         $eoCount = -1;
         foreach ($theme['files'] as $file) {
             $return .= '<tr class="' . (++$eoCount % 2 == 0 ? 'even' : 'odd') . '" onmouseover="Theme.hoverRow(this,1)" onmouseout="Theme.hoverRow(this,0)">';
             $return .= '<td class="tl_file_list">' . $GLOBALS['TL_LANG']['rocksolid_theme_assistant']['file_types'][$file['type']] . ' (' . $file['name'] . ')</td>';
             $return .= '<td class="tl_file_list tl_right_nowrap">' . $this->generateButtons($file, $this->strTable) . '</td>';
             $return .= '</tr>';
         }
     }
     $return .= '</table>';
     $return .= '</div>';
     return $return;
 }
开发者ID:madeyourday,项目名称:contao-rocksolid-theme-assistant,代码行数:79,代码来源:ThemeAssistantDataContainer.php


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