本文整理汇总了PHP中Folder::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::get方法的具体用法?PHP Folder::get怎么用?PHP Folder::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
$this->loginWithPermission('ADMIN');
// Save versioned state
$this->oldReadingMode = Versioned::get_reading_mode();
Versioned::set_stage(Versioned::DRAFT);
// Set backend root to /UploadFieldTest
AssetStoreTest_SpyStore::activate('UploadFieldTest');
// Set the File Name Filter replacements so files have the expected names
Config::inst()->update('FileNameFilter', 'default_replacements', array('/\\s/' => '-', '/_/' => '-', '/[^A-Za-z0-9+.\\-]+/' => '', '/[\\-]{2,}/' => '-', '/^[\\.\\-_]+/' => ''));
// Create a test folders for each of the fixture references
foreach (Folder::get() as $folder) {
$path = AssetStoreTest_SpyStore::getLocalPath($folder);
Filesystem::makeFolder($path);
}
// Create a test files for each of the fixture references
$files = File::get()->exclude('ClassName', 'Folder');
foreach ($files as $file) {
$path = AssetStoreTest_SpyStore::getLocalPath($file);
Filesystem::makeFolder(dirname($path));
$fh = fopen($path, "w+");
fwrite($fh, str_repeat('x', 1000000));
fclose($fh);
}
}
示例2: getFormField
public function getFormField()
{
$field = FileAttachmentField::create($this->Name, $this->Title);
// $field = FileField::create($this->Name, $this->Title);
if ($this->getSetting('Folder')) {
$folder = Folder::get()->byId($this->getSetting('Folder'));
if ($folder) {
$field->setFolderName(preg_replace("/^assets\\//", "", $folder->Filename));
}
}
if ($this->getSetting('Obfuscate')) {
$folder = rtrim($field->getFolderName(), '/');
$folder .= '/' . md5(time() + mt_rand());
$field->setFolderName($folder);
}
if ($this->getSetting('MultipleUploads')) {
$field->setMultiple(true);
}
if ($this->Required) {
// Required validation can conflict so add the Required validation messages
// as input attributes
$errorMessage = $this->getErrorMessage()->HTML();
$field->setAttribute('data-rule-required', 'true');
$field->setAttribute('data-msg-required', $errorMessage);
}
return $field;
}
示例3: cwsShortCodeRandomImageHandler
/**
* Displays a random image with colorbox effect from a given assets subfolder
* Uses template "csoft-shortcode/templates/Includes/RandomImage.ss" for output
*
* @param mixed $arguments (folder='subfolder_in_assets' align='left|right')
* @param $content = null
* @param $parser = null
* @return processed template RandomImage.ss
*/
public static function cwsShortCodeRandomImageHandler($arguments, $content = null, $parser = null)
{
// only proceed if subfolder was defined
if (!isset($arguments['folder'])) {
return;
}
// sanitize user inputs
$folder = Convert::raw2sql($arguments['folder']);
$align = isset($arguments['align']) ? strtolower(Convert::raw2xml($arguments['align'])) : '';
// fetch all images in random order from the user defined folder
$folder = Folder::get()->filter('Filename', "assets/{$folder}/")->First();
$randomImage = $folder ? Image::get()->filter('ParentID', $folder->ID)->sort('RAND()') : false;
// exit if user defined folder does not contain any image
if (!$randomImage) {
return;
}
// extract image caption from image filename
$caption = $randomImage->Title;
if (preg_match('#(\\d*-)?(.+)\\.(jpg|gif|png)#i', $caption, $matches)) {
$caption = ucfirst(str_replace('-', ' ', $matches[2]));
}
// prepare data for output
$data = array('RandomImage' => $randomImage->First(), 'Alignment' => $align, 'Caption' => $caption);
// load template and process data
$template = new SSViewer('RandomImage');
return $template->process(new ArrayData($data));
}
示例4: setup
function setup()
{
$oRootFolder =& Folder::get(1);
$this->oUser = User::get(1);
$sName = 'PermissionsTrest' . strftime('%Y%m%d%H%M%S');
$this->oFolder =& KTFolderUtil::add($oRootFolder, $sName, $this->oUser);
}
示例5: getFormField
public function getFormField()
{
$field = new FileField($this->Name, $this->Title);
if ($this->getSetting('Folder')) {
$folder = Folder::get()->byId($this->getSetting('Folder'));
if ($folder) {
$field->setFolderName(preg_replace("/^assets\\//", "", $folder->Filename));
}
}
return $field;
}
示例6: getCMSFields
function getCMSFields()
{
$fields = parent::getCMSFields();
if ($this->FolderID) {
$filescount = File::get()->filter(array("ParentID" => $this->FolderID))->count();
$fields->addFieldToTab('Root.Main', new LiteralField("addnew", "<p><a href='/admin/assets/show/" . $this->FolderID . "' class='ss-ui-button ss-ui-action-constructive ui-button' style='font-size:130%' data-icon=add''>Manage Files (" . $filescount . ")</span></a></p>"), 'Title');
}
$fields->insertAfter(new TextField("FilesHeading", "Files Heading"), 'Content');
$folders = class_exists('FileVersion') ? Folder::get()->exclude("Filename:PartialMatch", "_versions")->map("ID", "Title") : Folder::get()->map("ID", "Title");
$dropdown = new DropdownField("FolderID", "Folder", $folders);
$this->FolderID ? $dropdown->setEmptyString("Clear list") : $dropdown->setEmptyString(" ");
$fields->insertAfter($dropdown, 'FilesHeading');
return $fields;
}
示例7: getFormField
public function getFormField()
{
$field = FileField::create($this->Name, $this->Title);
if ($this->getSetting('Folder')) {
$folder = Folder::get()->byId($this->getSetting('Folder'));
if ($folder) {
$field->setFolderName(preg_replace("/^assets\\//", "", $folder->Filename));
}
}
if ($this->Required) {
// Required validation can conflict so add the Required validation messages
// as input attributes
$errorMessage = $this->getErrorMessage()->HTML();
$field->setAttribute('data-rule-required', 'true');
$field->setAttribute('data-msg-required', $errorMessage);
}
return $field;
}
示例8: onBeforeWrite
public function onBeforeWrite()
{
parent::onBeforeWrite();
$imageAdded = false;
if ($this->AutomaticallyIncludedFolderID) {
debug::log("A");
if ($folder = Folder::get()->byID($this->AutomaticallyIncludedFolderID)) {
if ($files = Image::get()->filter("ParentID", $folder->ID)) {
foreach ($files as $file) {
if (ImageGalleryEntry::get()->filter(array("ImageID" => $file->ID, "ParentID" => $this->ID))->count()) {
//do nothing
//debug::log("already exists");
} else {
$ImageGalleryEntry = new ImageGalleryEntry();
$ImageGalleryEntry->Title = $file->Title;
$ImageGalleryEntry->ImageID = $file->ID;
$ImageGalleryEntry->ParentID = $this->ID;
$ImageGalleryEntry->write();
$imageAdded = true;
//debug::log("writing");
}
}
} else {
//debug::log("D");
}
} else {
//debug::log("C");
}
} else {
//debug::log("B");
}
if ($ImageGalleryEntries = ImageGalleryEntry::get()->filter(array("ParentID" => $this->ID))) {
foreach ($ImageGalleryEntries as $ImageGalleryEntry) {
$image = Image::get()->filter(array("ID" => $ImageGalleryEntry->ImageID))->exclude(array("Title" => $ImageGalleryEntry->Title))->First();
if ($image) {
$image->Title = $image->Name = $ImageGalleryEntry->Title;
$image->write();
}
}
}
if ($imageAdded) {
//LeftAndMain::force_reload();
}
}
示例9: _show
function _show()
{
if (is_null($this->_sShowPermission)) {
return true;
}
$oFolder = Folder::get($this->oDocument->getFolderId());
if ($this->_bMutator && $this->oDocument->getImmutable()) {
if ($this->_bMutationAllowedByAdmin === true) {
if (!KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) {
return false;
}
} else {
return false;
}
}
if ($this->_bAdminAlwaysAvailable) {
if (Permission::userIsSystemAdministrator($this->oUser->getId())) {
return true;
}
if (Permission::isUnitAdministratorForFolder($this->oUser, $this->oDocument->getFolderId())) {
return true;
}
}
$oPermission =& KTPermission::getByName($this->_sShowPermission);
if (PEAR::isError($oPermission)) {
return true;
}
if (!KTWorkflowUtil::actionEnabledForDocument($this->oDocument, $this->sName)) {
return false;
}
// be nasty in archive/delete status.
$status = $this->oDocument->getStatusID();
if ($status == DELETED || $status == ARCHIVED) {
return false;
}
if ($this->bAllowInAdminMode) {
// check if this user is in admin mode
if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) {
return true;
}
}
return KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument);
}
示例10: setUp
public function setUp()
{
parent::setUp();
// Set backend root to /FolderTest
AssetStoreTest_SpyStore::activate('FolderTest');
// Create a test folders for each of the fixture references
foreach (Folder::get() as $folder) {
$path = AssetStoreTest_SpyStore::getLocalPath($folder);
SS_Filesystem::makeFolder($path);
}
// Create a test files for each of the fixture references
$files = File::get()->exclude('ClassName', 'Folder');
foreach ($files as $file) {
$path = AssetStoreTest_SpyStore::getLocalPath($file);
SS_Filesystem::makeFolder(dirname($path));
$fh = fopen($path, "w+");
fwrite($fh, str_repeat('x', 1000000));
fclose($fh);
}
}
示例11: getFormField
public function getFormField()
{
$field = FileField::create($this->Name, $this->Title);
// filter out '' since this would be a regex problem on JS end
$field->getValidator()->setAllowedExtensions(array_filter(Config::inst()->get('File', 'allowed_extensions')));
if ($this->getSetting('Folder')) {
$folder = Folder::get()->byId($this->getSetting('Folder'));
if ($folder) {
$field->setFolderName(preg_replace("/^assets\\//", "", $folder->Filename));
}
}
if ($this->Required) {
// Required validation can conflict so add the Required validation messages
// as input attributes
$errorMessage = $this->getErrorMessage()->HTML();
$field->setAttribute('data-rule-required', 'true');
$field->setAttribute('data-msg-required', $errorMessage);
}
return $field;
}
示例12: save_snapshot
/**
* Save Snapshots of extension in assets folder
*
* @param string $thumbnailUrl, $extensionName
* @return int
*/
public static function save_snapshot($thumbnailUrl, $extensionName)
{
$folderToSave = 'assets/Uploads/Snapshots/';
$folderObject = Folder::get()->filter("Filename", $folderToSave)->first();
if (!$folderObject) {
$folderObject = Folder::find_or_make('Uploads/Snapshots/');
$folderObject->write();
}
$fileExtension = preg_replace('/^.*\\.([^.]+)$/D', '$1', $thumbnailUrl);
$thumbnailBaseName = str_replace('/', '-', $extensionName);
$thumbnailName = $thumbnailBaseName . '-thumbnail.' . $fileExtension;
$ch = curl_init();
$timeout = 30;
curl_setopt($ch, CURLOPT_URL, $thumbnailUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
$response = curl_getinfo($ch);
curl_close($ch);
if ($response['http_code'] == '404') {
throw new InvalidArgumentException("Image not found on given Url Please check 'Snapshot' field in composer.json file");
}
$imageContent = $data;
if ($folderObject) {
$thumbnailFile = fopen(BASE_PATH . DIRECTORY_SEPARATOR . $folderToSave . $thumbnailName, 'w');
fwrite($thumbnailFile, $imageContent);
fclose($thumbnailFile);
} else {
throw new InvalidArgumentException("Could not create {$folderToSave} , Please create it mannually ");
}
if ($thumbnailObject = Image::get()->filter("Name", $thumbnailName)->first()) {
return $thumbnailObject->ID;
} else {
$thumbnailObject = new Image();
$thumbnailObject->ParentID = $folderObject->ID;
$thumbnailObject->Name = $thumbnailName;
$thumbnailObject->OwnerID = Member::currentUser() ? Member::currentUser()->ID : 0;
$thumbnailObject->write();
return $thumbnailObject->ID;
}
}
示例13: _fieldValues
function _fieldValues()
{
if (empty($this->dDateTime)) {
$this->dDateTime = getCurrentDateTime();
}
if (empty($this->iSessionId)) {
$this->iSessionId = $_SESSION['sessionID'];
}
$oFolder = Folder::get($this->iFolderId);
// head off the certain breakage down the line.
if (PEAR::isError($oFolder) || $oFolder === false) {
$this->bAdminMode = 0;
} else {
if (KTBrowseUtil::inAdminMode($oUser, $oFolder)) {
$this->bAdminMode = 1;
} else {
$this->bAdminMode = 0;
}
}
return parent::_fieldValues();
}
示例14: do_main
function do_main()
{
$this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Archived Documents'));
$this->oPage->setBreadcrumbDetails(_kt('browse'));
$oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', 1));
if (PEAR::isError($oFolder)) {
$this->errorRedirectToMain(_kt('Invalid folder selected.'));
exit(0);
}
// Setup the collection for restore display.
$aBaseParams = array();
$collection = new AdvancedCollection();
$oCR =& KTColumnRegistry::getSingleton();
$col = $oCR->getColumn('ktcore.columns.selection');
$aColOptions = array();
//$aColOptions['qs_params'] = kt_array_merge($aBaseParams, array('fFolderId'=>$oFolder->getId()));
$aColOptions['show_folders'] = false;
$aColOptions['show_documents'] = true;
$aColOptions['rangename'] = '_d[]';
$col->setOptions($aColOptions);
$collection->addColumn($col);
$col = $oCR->getColumn('ktcore.columns.title');
//$col->setOptions(array('qs_params'=>kt_array_merge($aBaseParams, array('action' => 'new', 'fFolderId'=>$oFolder->getId()))));
$col->setOptions(array('link_documents' => false));
$collection->addColumn($col);
//$qObj = new BrowseQuery($iFolderId);
$qObj = new ArchivedBrowseQuery($oFolder->getId());
$collection->setQueryObject($qObj);
$aOptions = $collection->getEnvironOptions();
$aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], array(kt_array_merge($aBaseParams, array('fFolderId' => $oFolder->getId()))));
$collection->setOptions($aOptions);
$aURLParams = $aBaseParams;
$aURLParams['action'] = 'restore';
$aBreadcrumbs = KTUtil::generate_breadcrumbs($oFolder, $iFolderId, $aURLParams);
$aTemplateData = array('context' => $this, 'folder' => $oFolder, 'breadcrumbs' => $aBreadcrumbs, 'collection' => $collection);
$oTemplate =& $this->oValidator->validateTemplate('ktcore/document/admin/archivebrowse');
return $oTemplate->render($aTemplateData);
}
示例15: setUp
public function setUp()
{
parent::setUp();
// Set backend root to /ImageTest
AssetStoreTest_SpyStore::activate('ProtectedFileControllerTest');
// Create a test folders for each of the fixture references
foreach (Folder::get() as $folder) {
/** @var Folder $folder */
$filePath = AssetStoreTest_SpyStore::getLocalPath($folder);
\Filesystem::makeFolder($filePath);
}
// Create a test files for each of the fixture references
foreach (File::get()->exclude('ClassName', 'Folder') as $file) {
/** @var File $file */
$path = AssetStoreTest_SpyStore::getLocalPath($file);
\Filesystem::makeFolder(dirname($path));
$fh = fopen($path, "w+");
fwrite($fh, str_repeat('x', 1000000));
fclose($fh);
// Create variant for each file
$this->getAssetStore()->setFromString(str_repeat('y', 100), $file->Filename, $file->Hash, 'variant');
}
}