當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FilesModel::findMultipleByBasepath方法代碼示例

本文整理匯總了PHP中FilesModel::findMultipleByBasepath方法的典型用法代碼示例。如果您正苦於以下問題:PHP FilesModel::findMultipleByBasepath方法的具體用法?PHP FilesModel::findMultipleByBasepath怎麽用?PHP FilesModel::findMultipleByBasepath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FilesModel的用法示例。


在下文中一共展示了FilesModel::findMultipleByBasepath方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: deleteResource

 /**
  * Removes a file or folder
  *
  * @param string $strResource The path to the file or folder
  */
 public static function deleteResource($strResource)
 {
     $objModel = \FilesModel::findByPath($strResource);
     // Remove the resource
     if ($objModel !== null) {
         $objModel->delete();
     }
     // Look for subfolders and files
     $objFiles = \FilesModel::findMultipleByBasepath($strResource . '/');
     // Remove subfolders and files as well
     if ($objFiles !== null) {
         while ($objFiles->next()) {
             $objFiles->delete();
         }
     }
     static::updateFolderHashes(dirname($strResource));
 }
開發者ID:iCodr8,項目名稱:core,代碼行數:22,代碼來源:Dbafs.php

示例2: purge

 /**
  * Purge the folder
  */
 public function purge()
 {
     $this->Files->rrdir($this->strFolder, true);
     // Update the database
     if ($this->blnSyncDb) {
         $objFiles = \FilesModel::findMultipleByBasepath($this->strFolder . '/');
         if ($objFiles !== null) {
             while ($objFiles->next()) {
                 $objFiles->delete();
             }
         }
         \Dbafs::updateFolderHashes($this->strFolder);
     }
 }
開發者ID:jamesdevine,項目名稱:core-bundle,代碼行數:17,代碼來源:Folder.php

示例3: save

 /**
  * Save the current value
  * @param mixed
  * @throws \Exception
  */
 protected function save($varValue)
 {
     if (\Input::post('FORM_SUBMIT') != $this->strTable) {
         return;
     }
     $arrData = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField];
     // File names
     if ($this->strField == 'name') {
         if (!file_exists(TL_ROOT . '/' . $this->strPath . '/' . $this->varValue . $this->strExtension) || !$this->isMounted($this->strPath . '/' . $this->varValue . $this->strExtension) || $this->varValue == $varValue) {
             return;
         }
         $this->import('Files');
         $varValue = utf8_romanize($varValue);
         // Trigger the save_callback
         if (is_array($arrData['save_callback'])) {
             foreach ($arrData['save_callback'] as $callback) {
                 $this->import($callback[0]);
                 $varValue = $this->{$callback}[0]->{$callback}[1]($varValue, $this);
             }
         }
         $this->Files->rename($this->strPath . '/' . $this->varValue . $this->strExtension, $this->strPath . '/' . $varValue . $this->strExtension);
         // Update the database
         if ($this->blnIsDbAssisted) {
             // Get the parent ID
             if ($this->strPath == $GLOBALS['TL_CONFIG']['uploadPath']) {
                 $pid = 0;
             } else {
                 $objFolder = \FilesModel::findByPath($this->strPath);
                 $pid = $objFolder->id;
             }
             // New folders
             if (stristr($this->intId, '__new__') == true) {
                 // Create the DB entry
                 $objFile = new \FilesModel();
                 $objFile->pid = $pid;
                 $objFile->tstamp = time();
                 $objFile->type = 'folder';
                 $objFile->path = $this->strPath . '/' . $varValue;
                 $objFile->name = $varValue;
                 $objFile->hash = md5('');
                 $objFile->save();
                 $this->objActiveRecord = $objFile;
                 // Add a log entry
                 $this->log('Folder "' . $this->strPath . '/' . $varValue . $this->strExtension . '" has been created', 'DC_Folder save()', TL_FILES);
             } else {
                 // Find the corresponding DB entry
                 $objFile = \FilesModel::findByPath($this->strPath . '/' . $this->varValue . $this->strExtension);
                 // Update the data
                 $objFile->pid = $pid;
                 $objFile->path = $this->strPath . '/' . $varValue . $this->strExtension;
                 $objFile->name = $varValue . $this->strExtension;
                 $objFile->save();
                 $this->objActiveRecord = $objFile;
                 // Add a log entry
                 $this->log('File or folder "' . $this->strPath . '/' . $this->varValue . $this->strExtension . '" has been renamed to "' . $this->strPath . '/' . $varValue . $this->strExtension . '"', 'DC_Folder save()', TL_FILES);
             }
             // Also update all child records
             if ($objFile->type == 'folder') {
                 $strPath = $this->strPath . '/' . $this->varValue . '/';
                 $objFiles = \FilesModel::findMultipleByBasepath($strPath);
                 if ($objFiles !== null) {
                     while ($objFiles->next()) {
                         $objFiles->path = preg_replace('@^' . $strPath . '@', $this->strPath . '/' . $varValue . '/', $objFiles->path);
                         $objFiles->save();
                     }
                 }
             }
             // Also update the MD5 hash of the parent folder
             if ($objFile->pid > 0) {
                 $objModel = \FilesModel::findByPk($objFile->pid);
                 $objFolder = new \Folder($objModel->path);
                 $objModel->hash = $objFolder->hash;
                 $objModel->save();
             }
         }
         // Set the new value so the input field can show it
         if (\Input::get('act') == 'editAll') {
             $session = $this->Session->getData();
             if (($index = array_search($this->urlEncode($this->strPath . '/' . $this->varValue) . $this->strExtension, $session['CURRENT']['IDS'])) !== false) {
                 $session['CURRENT']['IDS'][$index] = $this->urlEncode($this->strPath . '/' . $varValue) . $this->strExtension;
                 $this->Session->setData($session);
             }
         }
         $this->varValue = $varValue;
     } elseif ($this->blnIsDbAssisted) {
         // Convert date formats into timestamps
         if ($varValue != '' && in_array($arrData['eval']['rgxp'], array('date', 'time', 'datim'))) {
             $objDate = new \Date($varValue, $GLOBALS['TL_CONFIG'][$arrData['eval']['rgxp'] . 'Format']);
             $varValue = $objDate->tstamp;
         }
         // Make sure unique fields are unique
         if ($varValue != '' && $arrData['eval']['unique']) {
             $objUnique = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE " . $this->strField . "=? AND id!=?")->execute($varValue, $this->objActiveRecord->id);
             if ($objUnique->numRows) {
                 throw new \Exception(sprintf($GLOBALS['TL_LANG']['ERR']['unique'], $arrData['label'][0] ?: $this->strField));
//.........這裏部分代碼省略.........
開發者ID:rikaix,項目名稱:core,代碼行數:101,代碼來源:DC_Folder.php

示例4: getOrnamentItems

 protected function getOrnamentItems($path)
 {
     $elements = array('normal' => array(), 'light' => array());
     $objFiles = \FilesModel::findMultipleByBasepath($path);
     if ($objFiles->count() > 0) {
         while ($objFiles->next()) {
             $objFile = $objFiles->current();
             /* @var $objFile \Contao\FilesModel */
             if (!preg_match('/light/', $objFile->name)) {
                 $elements['normal'][] = $objFile->path;
             } else {
                 $elements['light'][] = $objFile->path;
             }
         }
     }
     return $elements;
 }
開發者ID:pressi,項目名稱:zdps_customize,代碼行數:17,代碼來源:Content.php


注:本文中的FilesModel::findMultipleByBasepath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。