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


PHP FilesModel类代码示例

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


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

示例1: transferAction

 public function transferAction()
 {
     $fc = FrontController::getInstance();
     $file = new FilesModel();
     $params = $fc->getParams();
     if (preg_match("/^[a-zA-Z0-9_]+(_[\\d]+s|).txt\$/", $params['filename'])) {
         $file->getDataFromFile($params['filename']);
         $file->connectToDb();
         $file->putDataToDatabase();
         $file->getStatus();
     }
 }
开发者ID:onpavlov,项目名称:Auto_Playlist_v2,代码行数:12,代码来源:FilesController.php

示例2: updateFileTreeFields

 /**
  * Update FileTree fields
  */
 public function updateFileTreeFields()
 {
     $objDatabase = \Database::getInstance();
     $arrFields = array('singleSRC', 'imgSRC');
     // Check the column type
     $objDesc = $objDatabase->query("DESC tl_downloadarchiveitems singleSRC");
     // Change the column type
     if ($objDesc->Type != 'binary(16)') {
         foreach ($arrFields as $field) {
             $objFiles = $objDatabase->execute("SELECT id,{$field} FROM tl_downloadarchiveitems");
             $objDatabase->query("ALTER TABLE tl_downloadarchiveitems CHANGE {$field} {$field} binary(16) NULL");
             #$objDatabase->query("UPDATE tl_downloadarchiveitems SET $field=NULL WHERE $field='' OR $field=0");
             while ($objFiles->next()) {
                 $objHelper = $this->generateHelperObject($this->changePath($objFiles->{$field}));
                 // UUID already
                 if ($objHelper->isUuid) {
                     continue;
                 }
                 // Numeric ID to UUID
                 if ($objHelper->isNumeric) {
                     $objFile = \FilesModel::findByPk($objHelper->value);
                     $objDatabase->prepare("UPDATE tl_downloadarchiveitems SET {$field}=? WHERE id=?")->execute($objFile->uuid, $objFiles->id);
                 } else {
                     $objFile = \FilesModel::findByPath($objHelper->value);
                     $objDatabase->prepare("UPDATE tl_downloadarchiveitems SET {$field}=? WHERE id=?")->execute($objFile->uuid, $objFiles->id);
                 }
             }
         }
     }
 }
开发者ID:felixpfeiffer,项目名称:contao-downloadarchive,代码行数:33,代码来源:runonce.php

示例3: getFiles

 /**
  * Collect all Songs per Playlist and return them as array
  * 
  * @param object $objSongs
  * @return array
  */
 public function getFiles($objSongs)
 {
     $arrFiles = array();
     $i = 0;
     if ($objSongs === null) {
         return;
     }
     while ($objSongs->next()) {
         $arrSong = $objSongs->row();
         $arrFiles[$i]['protected'] = $arrSong['protected'];
         $arrFiles[$i]['groups'] = $arrSong['groups'];
         $arrFiles[$i]['id'] = $arrSong['id'];
         $arrFiles[$i]['interpreter'] = $arrSong['interpreter'];
         $arrFiles[$i]['title'] = $arrSong['title'];
         $arrFiles[$i]['album'] = $arrSong['album'];
         $arrFiles[$i]['track'] = $arrSong['track'];
         $arrFiles[$i]['files'] = array();
         $arrUuids = deserialize($arrSong['file']);
         $objSongFiles = \FilesModel::findMultipleByUuids($arrUuids);
         while ($objSongFiles->next()) {
             $arrSongFile = $objSongFiles->row();
             $objFile = new \Contao\File($arrSongFile['path'], true);
             $arrFiles[$i]['files'][] = array('file' => $arrSongFile['path'], 'type' => $objFile->mime);
         }
         $i++;
     }
     // sort out protected songs
     $arrFiles = $this->sortOutProtected($arrFiles);
     return $arrFiles;
 }
开发者ID:MacGyer,项目名称:audiomax,代码行数:36,代码来源:Audiomax.php

示例4: generateSprite

 /**
  * Generate sprite from given data
  */
 public function generateSprite(\DataContainer $row)
 {
     // Get the theme meta data
     $objTheme = $this->Database->prepare("SELECT * FROM tl_theme WHERE id=?")->execute($row->id);
     if ($objTheme->numRows < 1) {
         return;
     }
     if ($objTheme->spritegen_enable != false) {
         // Replace the numeric folder IDs
         $objInputFolder = FilesModel::findByPk($objTheme->spritegen_source);
         $objOutputFolder = FilesModel::findByPk($objTheme->spritegen_output_folder);
         if ($objInputFolder !== null) {
             // Provide settings for SpriteGen()
             $cssSprites = new \SpriteGen();
             $cssSprites->addImageFolder(TL_ROOT . '/' . $objInputFolder->path);
             $cssSprites->setOutputFolder(TL_ROOT . '/' . $objOutputFolder->path);
             $cssSprites->setCacheTime(0);
             $cssSprites->useDatabase($objTheme->spritegen_modify_selectors, unserialize($objTheme->spritegen_selectors));
             // Generate Sprite
             $cssSprites->generateSprite($objTheme->spritegen_output_file, $objTheme->id, true, $objTheme->spritegen_direction, $objTheme->spritegen_output_width);
             // Display success confirmation
             \Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['spritegen_successful']);
             $this->log('Generated image and style sheet for sprite ' . $objTheme->spritegen_output_file, __METHOD__, CRON);
         }
     }
 }
开发者ID:richardhj,项目名称:contao_cssspritegen,代码行数:29,代码来源:tl_theme.php

示例5: generate

 /**
  * Generate the widget and return it as string
  *
  * @return string
  */
 public function generate()
 {
     global $objPage;
     if ($objPage->outputFormat == 'html5') {
         $blnIsHtml5 = true;
     }
     $blnSwitchOrder = (bool) $this->efgSwitchButtonOrder;
     $strButtonBack = '';
     $strButtonSubmit = '';
     if ($this->efgAddBackButton && ($this->formTotalPages > 1 && $this->formActivePage > 1 || TL_MODE == 'BE')) {
         if ($this->efgBackImageSubmit && $this->efgBackSingleSRC != '') {
             $objFileModel = \FilesModel::findById($this->efgBackSingleSRC);
             $strButtonBack .= sprintf('<input type="image"%s src="%s" id="ctrl_%s_back" class="submit back%s" alt="%s" title="%s" value="%s"%s%s', $this->formActivePage ? ' name="FORM_BACK"' : '', $objFileModel->path, $this->strId, strlen($this->strClass) ? ' ' . $this->strClass : '', specialchars($this->efgBackSlabel), specialchars($this->efgBackSlabel), specialchars('submit_back'), $this->getAttributes(), $this->strTagEnding);
         } else {
             $strButtonBack .= sprintf('<input type="submit"%s id="ctrl_%s_back" class="submit back%s" value="%s"%s%s', $this->formActivePage ? ' name="FORM_BACK"' : '', $this->strId, strlen($this->strClass) ? ' ' . $this->strClass : '', specialchars($this->efgBackSlabel), $this->getAttributes(), $this->strTagEnding);
         }
     }
     if ($this->imageSubmit && $this->singleSRC != '') {
         $objFileModel = \FilesModel::findById($this->singleSRC);
         $strButtonSubmit .= sprintf('<input type="image"%s src="%s" id="ctrl_%s" class="submit next%s" alt="%s" title="%s" value="%s"%s%s', $this->formActivePage ? ' name="FORM_NEXT"' : '', $objFileModel->path, $this->strId, strlen($this->strClass) ? ' ' . $this->strClass : '', specialchars($this->slabel), specialchars($this->slabel), specialchars('submit_next'), $this->getAttributes(), $this->strTagEnding);
     } else {
         $strButtonSubmit .= sprintf('<input type="submit"%s id="ctrl_%s" class="submit next%s" value="%s"%s%s', $this->formActivePage ? ' name="FORM_NEXT"' : '', $this->strId, strlen($this->strClass) ? ' ' . $this->strClass : '', specialchars($this->slabel), $this->getAttributes(), $this->strTagEnding);
     }
     return $blnSwitchOrder ? $strButtonSubmit . $strButtonBack : $strButtonBack . $strButtonSubmit;
 }
开发者ID:Jobu,项目名称:core,代码行数:30,代码来源:EfgFormPaginator.php

示例6: compile

 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     // Clean RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->text = \StringUtil::toXhtml($this->text);
     } else {
         $this->text = \StringUtil::toHtml5($this->text);
     }
     $this->Template->text = \StringUtil::encodeEmail($this->text);
     $this->Template->addImage = false;
     // Add an image
     if ($this->addImage && $this->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($this->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($this->singleSRC)) {
                 $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             $this->singleSRC = $objModel->path;
             $this->addImageToTemplate($this->Template, $this->arrData);
         }
     }
     $classes = deserialize($this->mooClasses);
     $this->Template->toggler = $classes[0] ?: 'toggler';
     $this->Template->accordion = $classes[1] ?: 'accordion';
     $this->Template->headlineStyle = $this->mooStyle;
     $this->Template->headline = $this->mooHeadline;
 }
开发者ID:bytehead,项目名称:contao-core,代码行数:33,代码来源:ContentAccordion.php

示例7: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     $this->Template->size = '';
     // Set the size
     if ($this->playerSize != '') {
         $size = deserialize($this->playerSize);
         if (is_array($size)) {
             $this->Template->size = ' width="' . $size[0] . 'px" height="' . $size[1] . 'px"';
         }
     }
     $this->Template->poster = false;
     // Optional poster
     if ($this->posterSRC != '') {
         if (($objFile = \FilesModel::findByPk($this->posterSRC)) !== null) {
             $this->Template->poster = $objFile->path;
         }
     }
     // Pre-sort the array by preference
     if (in_array($this->objFiles->extension, array('mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv'))) {
         $this->Template->isVideo = true;
         $arrFiles = array('mp4' => null, 'm4v' => null, 'mov' => null, 'wmv' => null, 'webm' => null, 'ogv' => null);
     } else {
         $this->Template->isVideo = false;
         $arrFiles = array('m4a' => null, 'mp3' => null, 'wma' => null, 'mpeg' => null, 'wav' => null);
     }
     $this->objFiles->reset();
     // Pass File objects to the template
     while ($this->objFiles->next()) {
         $objFile = new \File($this->objFiles->path);
         $arrFiles[$objFile->extension] = $objFile;
     }
     $this->Template->files = array_values(array_filter($arrFiles));
     $this->Template->autoplay = $this->autoplay;
 }
开发者ID:rikaix,项目名称:core,代码行数:37,代码来源:ContentMedia.php

示例8: cb_parseTemplate

 public function cb_parseTemplate(\Template &$objTemplate)
 {
     global $objPage;
     if (strpos($objTemplate->getName(), 'news_') === 0) {
         if ($objTemplate->source == 'singlefile') {
             $modelFile = \FilesModel::findByUuid($objTemplate->singlefileSRC);
             try {
                 if ($modelFile === null) {
                     throw new \Exception("no file");
                 }
                 $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
                 if (!in_array($modelFile->extension, $allowedDownload)) {
                     throw new Exception("download not allowed by extension");
                 }
                 $objFile = new \File($modelFile->path, true);
                 $strHref = \System::urlEncode($objFile->value);
             } catch (\Exception $e) {
                 $strHref = "";
             }
             $target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
             $objTemplate->more = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $GLOBALS['TL_LANG']['MSC']['more']);
             $objTemplate->linkHeadline = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $objTemplate->headline);
         }
     }
 }
开发者ID:kikmedia,项目名称:contao,代码行数:25,代码来源:NewsSingleFile.php

示例9: prepareLabel

 /**
  * Get the label for a form value to store in lead table.
  *
  * @param mixed $varValue
  * @param \Database\Result $objField
  *
  * @return mixed
  */
 public static function prepareLabel($varValue, $objField)
 {
     // Run for all values in an array
     if (is_array($varValue)) {
         foreach ($varValue as $k => $v) {
             $varValue[$k] = self::prepareLabel($v, $objField);
         }
         return $varValue;
     }
     // File upload
     if ($objField->type == 'upload') {
         $objFile = \FilesModel::findByUuid($varValue);
         if ($objFile !== null) {
             return $objFile->path;
         }
     }
     // Convert timestamps into date format
     if ($varValue != '' && in_array($objField->rgxp, array('date', 'time', 'datim'))) {
         $varValue = \Date::parse($GLOBALS['TL_CONFIG'][$objField->rgxp . 'Format'], $varValue);
     }
     if ($objField->options != '') {
         $arrOptions = deserialize($objField->options, true);
         foreach ($arrOptions as $arrOption) {
             if ($arrOption['value'] == $varValue && $arrOption['label'] != '') {
                 $varValue = $arrOption['label'];
             }
         }
     }
     return $varValue;
 }
开发者ID:terminal42,项目名称:contao-leads,代码行数:38,代码来源:Leads.php

示例10: getPictureFromDB

 public function getPictureFromDB($strTable, $strColumn, $strWhereParam, $strObjID)
 {
     $query = "SELECT " . $strColumn . " FROM " . $strTable . "WHERE " . $strWhereParam . "=?";
     $objPicture = $this->Database->prepare($query)->execute($strObjID);
     $objFile = \FilesModel::findByUuid($objPicture->{$strColumn});
     return $objFile->path;
 }
开发者ID:blioxxx,项目名称:contao-universal-library,代码行数:7,代码来源:images.php

示例11: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     $this->Template->size = '';
     // Set the size
     if ($this->playerSize != '') {
         $size = deserialize($this->playerSize);
         if (is_array($size)) {
             $this->Template->size = ' width="' . $size[0] . '" height="' . $size[1] . '"';
         }
     }
     $this->Template->poster = false;
     // Optional poster
     if ($this->posterSRC != '') {
         if (($objFile = \FilesModel::findByUuid($this->posterSRC)) !== null) {
             $this->Template->poster = $objFile->path;
         }
     }
     // Check for SSL (see #6900)
     $protocol = \Environment::get('ssl') ? 'https://' : 'http://';
     $objFile = new \stdClass();
     $objFile->mime = 'video/x-youtube';
     $objFile->path = $protocol . 'www.youtube.com/watch?v=' . $this->youtube;
     $this->Template->isVideo = true;
     $this->Template->files = array($objFile);
     $this->Template->autoplay = $this->autoplay;
 }
开发者ID:iCodr8,项目名称:core,代码行数:29,代码来源:ContentYouTube.php

示例12: buildFileDir

 protected function buildFileDir($objEntity = null)
 {
     if ($this->fileDir && ($objFolder = \FilesModel::findByUuid($this->fileDir))) {
         $objMember = \FrontendUser::getInstance();
         $strDir = $objFolder->path;
         if ($this->useHomeDir && FE_USER_LOGGED_IN && $objMember->assignDir && $objMember->homeDir) {
             $strDir = Files::getPathFromUuid($objMember->homeDir);
         }
         if (in_array('protected_homedirs', \ModuleLoader::getActive())) {
             if ($this->useProtectedHomeDir && $objMember->assignProtectedDir && $objMember->protectedHomeDir) {
                 $strDir = Files::getPathFromUuid($objMember->protectedHomeDir);
             }
         }
         if ($this->fileSubDirName) {
             $strDir .= '/' . $this->fileSubDirName;
         }
         if (isset($GLOBALS['TL_HOOKS']['exporter_modifyFileDir']) && is_array($GLOBALS['TL_HOOKS']['exporter_modifyFileDir'])) {
             foreach ($GLOBALS['TL_HOOKS']['exporter_modifyFileDir'] as $callback) {
                 $objCallback = \System::importStatic($callback[0]);
                 $strFixedDir = $objCallback->{$callback}[1]($strDir, $this);
                 $strDir = $strFixedDir ?: $strDir;
             }
         }
         return $strDir;
     }
     throw new \Exception('No exporter fileDir defined!');
 }
开发者ID:heimrichhannot,项目名称:contao-exporter,代码行数:27,代码来源:Exporter.php

示例13: actionPreviewPage

 public function actionPreviewPage($id)
 {
     $file = FilesModel::getFile($id);
     if (!$file) {
         throw new BadRequestException("File not found", 404);
     }
     if (!$this->triggerEvent('allowFileDownload', $file)) {
         throw new BadRequestException("File download forbidden", 403);
     }
     $this->template->file = $file;
     $this->setLayout(false);
     //experimental for documentFile
     $xml = substr($file->info, 5);
     $sxml = simplexml_load_string($xml);
     //TODO proč nefunguje vždy?
     $pages = array();
     if ($sxml && $sxml->page) {
         foreach ($sxml->page as $p) {
             $page = array($p, array());
             foreach ($p->block as $b) {
                 foreach ($b->text as $t) {
                     $page[1][] = $t;
                 }
             }
             $pages[] = $page;
         }
     }
     $this->template->pdf2xml = $pages;
 }
开发者ID:osmcz,项目名称:website,代码行数:29,代码来源:FilesPresenter.php

示例14: getInstance

 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new FilesModel();
     }
     return self::$instance;
 }
开发者ID:nokatsur,项目名称:blog,代码行数:7,代码来源:files_model.php

示例15: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     $intList = $this->athletes_group;
     $objMembers = $this->Database->prepare("SELECT * FROM tl_athlete WHERE published=1 AND pid=? ORDER BY sorting")->execute($intList);
     //$objMembers = \MembersModel;
     // Return if no Members were found
     if (!$objMembers->numRows) {
         return;
     }
     $strLink = '';
     // Generate a jumpTo link
     if ($this->jumpTo > 0) {
         $objJump = \PageModel::findByPk($this->jumpTo);
         if ($objJump !== null) {
             $strLink = $this->generateFrontendUrl($objJump->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s');
         }
     }
     $arrMembers = array();
     // Generate Members
     while ($objMembers->next()) {
         $strPhoto = '';
         $objPhoto = \FilesModel::findByPk($objMembers->photo);
         // Add photo image
         if ($objPhoto !== null) {
             $strPhoto = \Image::getHtml(\Image::get($objPhoto->path, '140', '187', 'center_center'));
         }
         $arrMembers[] = array('name' => $objMembers->name, 'family' => $objMembers->family, 'post' => $objMembers->post, 'joined' => $objMembers->joined, 'photo' => $strPhoto, 'link' => strlen($strLink) ? sprintf($strLink, $objMembers->alias) : '');
     }
     $this->Template->members = $arrMembers;
 }
开发者ID:respinar,项目名称:contao-athletes,代码行数:33,代码来源:ModuleAthleteList.php


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