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


PHP Folder::get方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:26,代码来源:UploadFieldTest.php

示例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;
 }
开发者ID:Neumes,项目名称:silverstripe-editableuserforms,代码行数:27,代码来源:EditableMultiFileField.php

示例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));
 }
开发者ID:helpfulrobot,项目名称:cwsoft-silverstripe-shortcode,代码行数:36,代码来源:cwsShortCodeRandomImage.php

示例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);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:7,代码来源:testPermissions.php

示例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;
 }
开发者ID:prostart,项目名称:erics-homes,代码行数:11,代码来源:EditableFileField.php

示例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;
 }
开发者ID:helpfulrobot,项目名称:purplespider-file-listing,代码行数:14,代码来源:FilePage.php

示例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;
 }
开发者ID:8secs,项目名称:cocina,代码行数:18,代码来源:EditableFileField.php

示例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();
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-imagegallery-basic,代码行数:44,代码来源:ImageGalleryPage.php

示例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);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:43,代码来源:documentaction.inc.php

示例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);
     }
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:20,代码来源:FolderTest.php

示例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;
 }
开发者ID:sekjal,项目名称:silverstripe-userforms,代码行数:20,代码来源:EditableFileField.php

示例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;
     }
 }
开发者ID:helpfulrobot,项目名称:vikas-srivastava-extensionmanager,代码行数:47,代码来源:ExtensionSnapshot.php

示例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();
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:21,代码来源:foldertransaction.inc.php

示例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);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:38,代码来源:archivedDocuments.php

示例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');
     }
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:23,代码来源:ProtectedFileControllerTest.php


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