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


PHP FilesModel::findBy方法代码示例

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


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

示例1: generateAddActions

 public function generateAddActions($arrData, $id, Watchlist $objWatchlist)
 {
     global $objPage;
     if ($objPage === null) {
         return;
     }
     if (\Validator::isUuid($id)) {
         $objFile = \FilesModel::findByUuid($id);
     } else {
         $objFile = \FilesModel::findBy('path', $id);
     }
     $objItem = new WatchlistItemModel();
     $objItem->pid = Watchlist::getInstance()->getId();
     $objItem->uuid = $objFile->uuid;
     $objItem->pageID = $objPage->id;
     $objItem->cid = $arrData['id'];
     $objItem->type = $arrData['type'];
     $objT = new \FrontendTemplate('watchlist_add_actions');
     $objT->addHref = ampersand(\Controller::generateFrontendUrl($objPage->row()) . '?act=' . WATCHLIST_ACT_ADD . '&cid=' . $objItem->cid . '&type=' . $objItem->type . '&id=' . $strUuid . '&title=' . urlencode($objItem->getTitle()));
     $objT->addTitle = $GLOBALS['TL_LANG']['WATCHLIST']['addTitle'];
     $objT->addLink = $GLOBALS['TL_LANG']['WATCHLIST']['addLink'];
     $objT->active = $objWatchlist->isInList($strUuid);
     $objT->id = $strUuid;
     return $objT->parse();
 }
开发者ID:heimrichhannot,项目名称:contao-watchlist,代码行数:25,代码来源:WatchlistItemEnclosure.php

示例2: getFileCredits

 public function getFileCredits()
 {
     $arrOptions = array();
     $objFiles = \FilesModel::findBy(array('copyright != ""'), "");
     if ($objFiles === null) {
         return $arrOptions;
     }
     $maxLength = 45;
     while ($objFiles->next()) {
         $strPath = $objFiles->path;
         $strLength = strlen($strPath);
         if ($strLength > $maxLength) {
             $strPathLeft = substr($strPath, 0, ceil($maxLength / 7));
             $strPathRight = substr($strPath, ceil($strLength - $maxLength / (7 / 5)), $strLength);
             $strPath = $strPathLeft . '…' . $strPathRight;
         }
         $arrOptions[$objFiles->id] = $strPath;
     }
     return $arrOptions;
 }
开发者ID:pandroid,项目名称:contao-filecredits,代码行数:20,代码来源:tl_module.php

示例3: getFiles

 /**
  * Get array of files for this download (could be multiple for folder selection)
  * @return  array
  */
 public function getFiles()
 {
     $objFile = $this->getRelated('singleSRC');
     if (null === $objFile) {
         return array();
     }
     if ($objFile->type == 'folder') {
         $arrFiles = array();
         $objFiles = \FilesModel::findBy(array("pid=?", "type='file'"), array($objFile->id));
         if (null !== $objFiles) {
             while ($objFiles->next()) {
                 $arrFiles[] = $objFiles->current();
             }
         }
         return $arrFiles;
     } elseif (is_file(TL_ROOT . '/' . $objFile->path)) {
         return array($objFile);
     }
     return array();
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:24,代码来源:Download.php

示例4: syncFiles

 /**
  * Synchronize the file system with the database
  *
  * @return string The path to the synchronization log file
  *
  * @throws \Exception If a parent ID entry is missing
  */
 public static function syncFiles()
 {
     // Try to raise the limits (see #7035)
     @ini_set('memory_limit', -1);
     @ini_set('max_execution_time', 0);
     $objDatabase = \Database::getInstance();
     // Lock the files table
     $objDatabase->lockTables(array('tl_files'));
     // Reset the "found" flag
     $objDatabase->query("UPDATE tl_files SET found=''");
     // Get a filtered list of all files
     $objFiles = new \RecursiveIteratorIterator(new \Dbafs\Filter(new \RecursiveDirectoryIterator(TL_ROOT . '/' . \Config::get('uploadPath'), \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::FOLLOW_SYMLINKS | \FilesystemIterator::SKIP_DOTS)), \RecursiveIteratorIterator::SELF_FIRST);
     $strLog = 'system/tmp/' . md5(uniqid(mt_rand(), true));
     // Open the log file
     $objLog = new \File($strLog, true);
     $objLog->truncate();
     $arrModels = array();
     // Create or update the database entries
     foreach ($objFiles as $objFile) {
         $strRelpath = str_replace(TL_ROOT . '/', '', $objFile->getPathname());
         // Get all subfiles in a single query
         if ($objFile->isDir()) {
             $objSubfiles = \FilesModel::findMultipleFilesByFolder($strRelpath);
             if ($objSubfiles !== null) {
                 while ($objSubfiles->next()) {
                     $arrModels[$objSubfiles->path] = $objSubfiles->current();
                 }
             }
         }
         // Get the model
         if (isset($arrModels[$strRelpath])) {
             $objModel = $arrModels[$strRelpath];
         } else {
             $objModel = \FilesModel::findByPath($strRelpath);
         }
         if ($objModel === null) {
             // Add a log entry
             $objLog->append("[Added] {$strRelpath}");
             // Get the parent folder
             $strParent = dirname($strRelpath);
             // Get the parent ID
             if ($strParent == \Config::get('uploadPath')) {
                 $strPid = null;
             } else {
                 $objParent = \FilesModel::findByPath($strParent);
                 if ($objParent === null) {
                     throw new \Exception("No parent entry for {$strParent}");
                 }
                 $strPid = $objParent->uuid;
             }
             // Create the file or folder
             if (is_file(TL_ROOT . '/' . $strRelpath)) {
                 $objFile = new \File($strRelpath, true);
                 $objModel = new \FilesModel();
                 $objModel->pid = $strPid;
                 $objModel->tstamp = time();
                 $objModel->name = $objFile->name;
                 $objModel->type = 'file';
                 $objModel->path = $objFile->path;
                 $objModel->extension = $objFile->extension;
                 $objModel->found = 2;
                 $objModel->hash = $objFile->hash;
                 $objModel->uuid = $objDatabase->getUuid();
                 $objModel->save();
             } else {
                 $objFolder = new \Folder($strRelpath);
                 $objModel = new \FilesModel();
                 $objModel->pid = $strPid;
                 $objModel->tstamp = time();
                 $objModel->name = $objFolder->name;
                 $objModel->type = 'folder';
                 $objModel->path = $objFolder->path;
                 $objModel->extension = '';
                 $objModel->found = 2;
                 $objModel->hash = $objFolder->hash;
                 $objModel->uuid = $objDatabase->getUuid();
                 $objModel->save();
             }
         } else {
             // Check whether the MD5 hash has changed
             $objResource = $objFile->isDir() ? new \Folder($strRelpath) : new \File($strRelpath);
             $strType = $objModel->hash != $objResource->hash ? 'Changed' : 'Unchanged';
             // Add a log entry
             $objLog->append("[{$strType}] {$strRelpath}");
             // Update the record
             $objModel->found = 1;
             $objModel->hash = $objResource->hash;
             $objModel->save();
         }
     }
     // Check for left-over entries in the DB
     $objFiles = \FilesModel::findByFound('');
     if ($objFiles !== null) {
//.........这里部分代码省略.........
开发者ID:iCodr8,项目名称:core,代码行数:101,代码来源:Dbafs.php

示例5: removeCssFileFromGroup

 protected static function removeCssFileFromGroup($path, $groupId)
 {
     $objFileModel = \FilesModel::findBy('path', $path);
     if ($objFileModel === null) {
         return false;
     }
     $objExtCssFileModel = ExtCssFileModel::findBy('src', $objFileModel->uuid);
     if ($objExtCssFileModel === null) {
         return false;
     }
     $objExtCssFileModel->delete();
     return true;
 }
开发者ID:heimrichhannot,项目名称:contao-extassets,代码行数:13,代码来源:ExtCss.php

示例6: sync

    /**
     * Synchronize the file system with the database
     * @return string
     */
    public function sync()
    {
        if (!$this->blnIsDbAssisted) {
            return '';
        }
        $this->arrMessages = array();
        // Reset the "found" flag
        $this->Database->query("UPDATE tl_files SET found=''");
        // Traverse the file system
        $this->execSync($GLOBALS['TL_CONFIG']['uploadPath']);
        // Check for left-over entries in the DB
        $objFiles = \FilesModel::findByFound('');
        if ($objFiles !== null) {
            $arrFiles = array();
            $arrFolders = array();
            while ($objFiles->next()) {
                if ($objFiles->type == 'file') {
                    $arrFiles[] = $objFiles->current();
                } else {
                    $arrFolders[] = $objFiles->current();
                }
            }
            // Check whether a folder has moved
            foreach ($arrFolders as $objFolder) {
                $objFound = \FilesModel::findBy(array('hash=?', 'found=1'), $objFolder->hash);
                if ($objFound !== null) {
                    $this->arrMessages[] = '<p class="tl_info">' . sprintf($GLOBALS['TL_LANG']['tl_files']['syncFound'], $objFolder->path, $objFound->path) . '</p>';
                    // Update the original entry
                    $objFolder->pid = $objFound->pid;
                    $objFolder->tstamp = $objFound->tstamp;
                    $objFolder->name = $objFound->name;
                    $objFolder->type = $objFound->type;
                    $objFolder->path = $objFound->path;
                    $objFolder->save();
                    // Update the PID of the child records
                    $objChildren = \FilesModel::findByPid($objFound->id);
                    if ($objChildren !== null) {
                        while ($objChildren->next()) {
                            $objChildren->pid = $objFolder->id;
                            $objChildren->save();
                        }
                    }
                    // Delete the newer (duplicate) entry
                    $objFound->delete();
                } else {
                    // Delete the entry if the folder has gone
                    $objFolder->delete();
                    $this->arrMessages[] = '<p class="tl_error">' . sprintf($GLOBALS['TL_LANG']['tl_files']['syncRemoved'], $objFolder->path) . '</p>';
                }
            }
            // Check whether a file has moved
            foreach ($arrFiles as $objFile) {
                $objFound = \FilesModel::findBy(array('hash=?', 'found=1'), $objFile->hash);
                if ($objFound !== null) {
                    $this->arrMessages[] = '<p class="tl_info">' . sprintf($GLOBALS['TL_LANG']['tl_files']['syncFound'], $objFile->path, $objFound->path) . '</p>';
                    // Update the original entry
                    $objFile->pid = $objFound->pid;
                    $objFile->tstamp = $objFound->tstamp;
                    $objFile->name = $objFound->name;
                    $objFile->type = $objFound->type;
                    $objFile->path = $objFound->path;
                    $objFile->save();
                    // Delete the newer (duplicate) entry
                    $objFound->delete();
                } else {
                    // Delete the entry if the file has gone
                    $objFile->delete();
                    $this->arrMessages[] = '<p class="tl_error">' . sprintf($GLOBALS['TL_LANG']['tl_files']['syncRemoved'], $objFile->path) . '</p>';
                }
            }
        }
        $return = '
<div id="tl_buttons">
<a href="' . $this->getReferer(true) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b" onclick="Backend.getScrollOffset()">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>

<h2 class="sub_headline">' . $GLOBALS['TL_LANG']['tl_files']['sync'][1] . '</h2>
' . \Message::generate() . '
<div class="tl_message nobg" style="margin-bottom:2em">';
        // Add the messages
        foreach ($this->arrMessages as $strMessage) {
            $return .= "\n  " . $strMessage;
        }
        $return .= '
</div>

<div class="tl_submit_container">
  <a href="' . $this->getReferer(true) . '" class="tl_submit" style="display:inline-block">' . $GLOBALS['TL_LANG']['MSC']['continue'] . '</a>
</div>
';
        return $return;
    }
开发者ID:rikaix,项目名称:core,代码行数:96,代码来源:DC_Folder.php

示例7: 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

示例8: collectFiles

 /**
  * Walks the list of pending folders via ToolboxFile::addPath().
  *
  * @return void
  */
 protected function collectFiles()
 {
     $table = \FilesModel::getTable();
     $conditions = array();
     $parameters = array();
     if (count($this->pendingIds)) {
         $conditions[] = $table . '.uuid IN(' . implode(',', array_fill(0, count($this->pendingIds), 'UNHEX(?)')) . ')';
         $parameters = array_map('bin2hex', $this->pendingIds);
         $this->pendingIds = array();
     }
     if (count($this->pendingPaths)) {
         $slug = $table . '.path LIKE ?';
         foreach ($this->pendingPaths as $pendingPath) {
             $conditions[] = $slug;
             $parameters[] = $pendingPath . '%';
         }
         $this->pendingPaths = array();
     }
     if (!count($conditions)) {
         return;
     }
     if ($files = \FilesModel::findBy(array(implode(' OR ', $conditions)), $parameters)) {
         $this->addFileModels($files);
     }
     if (count($this->pendingPaths)) {
         // Run again.
         $this->collectFiles();
     }
 }
开发者ID:metamodels,项目名称:core,代码行数:34,代码来源:ToolboxFile.php


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