本文整理汇总了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));
}
示例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);
}
}
示例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));
//.........这里部分代码省略.........
示例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;
}