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


PHP Director::baseFolder方法代码示例

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


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

示例1: run

 function run()
 {
     try {
         $election_input_path = Director::baseFolder() . '/' . ELECTION_VOTERS_INGEST_PATH;
         $files = scandir($election_input_path);
         $manager = new ElectionManager(new SapphireElectionRepository(), new SapphireFoundationMemberRepository(), new SapphireVoteRepository(), new SapphireVoterFileRepository(), new VoteFactory(), new VoterFileFactory(), new ElectionFactory(), SapphireTransactionManager::getInstance());
         foreach ($files as $file_name) {
             if ($this->isCSV($file_name) && (list($election_id, $open_date, $close_date) = $this->isValidElectionFileName($file_name))) {
                 try {
                     echo printf('processing file %s' . PHP_EOL, $file_name);
                     list($count, $not_processed) = $manager->ingestVotersForElection($election_input_path . '/' . $file_name, $election_id, $open_date, $close_date);
                     echo printf('file %s - processed %d rows - not processed %d rows' . PHP_EOL, $file_name, $count, count($not_processed));
                     if (count($not_processed) > 0) {
                         echo 'not processed details ... ' . PHP_EOL;
                         echo var_dump($not_processed) . PHP_EOL;
                     }
                     echo printf('deleting file %s ...' . PHP_EOL, $file_name);
                     unlink($election_input_path . '/' . $file_name);
                 } catch (Exception $ex) {
                     SS_Log::log($ex, SS_Log::ERR);
                     echo $ex->getMessage();
                 }
             }
         }
         return 'OK';
     } catch (Exception $ex) {
         SS_Log::log($ex, SS_Log::ERR);
         echo $ex->getMessage();
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:30,代码来源:VotersDataIngestionTask.php

示例2: __construct

 /**
  * @param $locale
  */
 public function __construct($locale = null)
 {
     $this->defaultLocale = $locale ? $locale : i18n::get_lang_from_locale(i18n::default_locale());
     $this->basePath = Director::baseFolder();
     $this->baseSavePath = Director::baseFolder();
     parent::__construct();
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:10,代码来源:i18nTextCollector.php

示例3: updateSettingsFields

 public function updateSettingsFields(FieldList $fields)
 {
     $systemThemes = SiteConfig::current_site_config()->getAvailableThemes();
     $partials = $themes = array('' => '', 'none' => '(none)');
     foreach ($systemThemes as $key => $themeName) {
         if (file_exists(Director::baseFolder() . '/themes/' . $themeName . '/templates/Page.ss')) {
             $themes[$key] = $themeName;
         } else {
             $partials[$key] = $themeName;
         }
     }
     $themeDropdownField = new DropdownField("AppliedTheme", 'Applied Theme', $themes);
     $fields->addFieldToTab('Root.Theme', $themeDropdownField);
     $current = $this->appliedTheme();
     if ($current) {
         $themeDropdownField->setRightTitle('Current effective theme: ' . $current);
     } else {
         $themeDropdownField->setRightTitle('Using default site theme');
     }
     $themeDropdownField = new DropdownField("PartialTheme", 'Partial Theme', $partials);
     $fields->addFieldToTab('Root.Theme', $themeDropdownField);
     $current = $this->appliedPartialTheme();
     if ($current) {
         $themeDropdownField->setRightTitle('Current effective partial theme: ' . $current);
     } else {
         $themeDropdownField->setRightTitle('Please only use a specific applied theme OR a partial theme, not both!');
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-silverstripe-partial-themes,代码行数:28,代码来源:PartialThemesExtension.php

示例4: init

 function init()
 {
     parent::init();
     // Special case for dev/build: Defer permission checks to DatabaseAdmin->init() (see #4957)
     $requestedDevBuild = stripos($this->request->getURL(), 'dev/build') === 0;
     // We allow access to this controller regardless of live-status or ADMIN permission only
     // if on CLI.  Access to this controller is always allowed in "dev-mode", or of the user is ADMIN.
     $canAccess = $requestedDevBuild || Director::isDev() || Director::is_cli() || Permission::check("ADMIN");
     if (!$canAccess) {
         return Security::permissionFailure($this);
     }
     // check for valid url mapping
     // lacking this information can cause really nasty bugs,
     // e.g. when running Director::test() from a FunctionalTest instance
     global $_FILE_TO_URL_MAPPING;
     if (Director::is_cli()) {
         if (isset($_FILE_TO_URL_MAPPING)) {
             $fullPath = $testPath = BASE_PATH;
             while ($testPath && $testPath != "/" && !preg_match('/^[A-Z]:\\\\$/', $testPath)) {
                 $matched = false;
                 if (isset($_FILE_TO_URL_MAPPING[$testPath])) {
                     $matched = true;
                     break;
                 }
                 $testPath = dirname($testPath);
             }
             if (!$matched) {
                 echo 'Warning: You probably want to define ' . 'an entry in $_FILE_TO_URL_MAPPING that covers "' . Director::baseFolder() . '"' . "\n";
             }
         } else {
             echo 'Warning: You probably want to define $_FILE_TO_URL_MAPPING in ' . 'your _ss_environment.php as instructed on the "sake" page of the doc.silverstripe.org wiki' . "\n";
         }
     }
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:34,代码来源:DevelopmentAdmin.php

示例5: customise_css

 /**
  *	Apply custom styles to the absolute description element.
  *
  *	@parameter <{DESCRIPTION_CSS}> array(string)
  */
 public static function customise_css($styles)
 {
     if (is_array($styles)) {
         // Determine the path to write against.
         $URL = DESCRIPTIVE_PATH . '/css/custom.css';
         $path = Director::baseFolder() . "/{$URL}";
         // Collate each custom style where appropriate.
         $CSS = '#cms-menu-descriptive {' . PHP_EOL;
         foreach ($styles as $style => $value) {
             if (!is_numeric($style)) {
                 $CSS .= "\t{$style}: {$value} !important;" . PHP_EOL;
                 // Apply any possible background change.
                 if (strtolower($style) === 'background') {
                     $background = '#cms-menu-descriptive:before,' . PHP_EOL . '#cms-menu-descriptive:after {' . PHP_EOL;
                     $background .= "\tborder-top: 10px solid {$value} !important;" . PHP_EOL . '}' . PHP_EOL . PHP_EOL;
                     $background .= '#cms-menu-descriptive:before {' . PHP_EOL;
                     $background .= "\tborder-top: 13px solid !important;" . PHP_EOL;
                     $background .= "\tborder-top-color: inherit !important;" . PHP_EOL . '}' . PHP_EOL;
                 }
             }
         }
         $CSS .= '}' . PHP_EOL . PHP_EOL . $background;
         // Write the custom styles.
         file_put_contents($path, $CSS);
         chmod($path, 0664);
         LeftAndMain::require_css($URL);
     }
 }
开发者ID:nglasl,项目名称:silverstripe-descriptive,代码行数:33,代码来源:DescriptiveService.php

示例6: setTemporaryPath

 /**
  * Setup the environment to point to a temporary location
  *
  * @param type $path
  */
 protected function setTemporaryPath($path)
 {
     $this->envPath = $path;
     Filesystem::makeFolder($this->envPath);
     $this->envPath = realpath($this->envPath);
     Injector::inst()->load(array('DNData' => array('properties' => array('EnvironmentDir' => $this->envPath, 'KeyDir' => TEMP_FOLDER . '/deploynaut_test/gitkeys', 'DataTransferDir' => Director::baseFolder() . '/assets/transfers', 'GitUser' => ''))));
 }
开发者ID:ss23,项目名称:deploynaut,代码行数:12,代码来源:DeploynautTest.php

示例7: Thumbnail

 public function Thumbnail($page = 1)
 {
     // Only thumbnail PDF files
     if (strtolower($this->owner->getExtension()) != 'pdf') {
         return false;
     }
     $file_filename = Director::baseFolder() . '/' . $this->owner->getFilename();
     if (!file_exists($file_filename)) {
         return false;
     }
     $cache_filename = $this->owner->getFilename() . '.page-' . (int) $page . '.jpg';
     // Check for existing cached thumbnail
     if (file_exists(Director::baseFolder() . '/' . $cache_filename) && filemtime(Director::baseFolder() . '/' . $cache_filename) > filemtime($file_filename)) {
         $img = DataObject::get_one('Image', "Filename = '" . $cache_filename . "'");
         if ($img) {
             return $img;
         }
     }
     // Create and cache the thumbnail
     $command = self::$convert_path . ' -density 300x300 ' . escapeshellarg($file_filename . '[' . ((int) $page - 1) . ']') . ' -quality 100 -resize 2000x -units PixelsPerInch ' . escapeshellarg(Director::baseFolder() . '/' . $cache_filename);
     $out = shell_exec($command);
     //var_dump( $command );
     if (!file_exists(Director::baseFolder() . '/' . $cache_filename)) {
         return false;
     }
     $img = new Image();
     $img->setFilename($cache_filename);
     $img->write();
     $img = DataObject::get_one('Image', "Filename = '" . $cache_filename . "'");
     return $img;
 }
开发者ID:NobrainerWeb,项目名称:silverstripe-pdf-thumbnailer,代码行数:31,代码来源:PdfThumbnailerExtension.php

示例8: transform

 /**
  *
  * @param SilverStripeContentItem $item
  * @param type $parentObject
  * @param type $duplicateStrategy
  * @return TransformResult 
  */
 public function transform($item, $parentObject, $duplicateStrategy)
 {
     $newFile = $this->getTypeForFile($item->Name);
     $newFile = new $newFile();
     $folderPath = $parentObject->getRelativePath();
     $parentId = $parentObject ? $parentObject->ID : 0;
     $filter = '"ParentID" = \'' . Convert::raw2sql($parentId) . '\' and "Title" = \'' . Convert::raw2sql($item->Name) . '\'';
     $existing = DataObject::get_one('File', $filter);
     if ($existing && $duplicateStrategy == ExternalContentTransformer::DS_SKIP) {
         // just return the existing children
         return new TransformResult($existing, null);
     } else {
         if ($existing && $duplicateStrategy == ExternalContentTransformer::DS_OVERWRITE) {
             $newFile = $existing;
         }
     }
     $newFile->Name = $item->Name;
     $newFile->RemoteNodeId = $item->getSS_ID();
     $newFile->RemoteSystemId = $item->getSource()->ID;
     $newFile->Title = $item->Title;
     $newFile->ParentID = $parentId;
     $newFile->write();
     $filepath = Director::baseFolder() . '/' . $newFile->Filename;
     Filesystem::makeFolder(dirname($filepath));
     $item->streamContent($filepath);
     return new TransformResult($newFile, null);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-silverstripe-connector,代码行数:34,代码来源:SilverStripeFileImporter.php

示例9: testFileLinkRewritingOnVirtualPages

 function testFileLinkRewritingOnVirtualPages()
 {
     // File setup
     $this->logInWithPermission('ADMIN');
     touch(Director::baseFolder() . '/assets/testscript-test-file.pdf');
     // Publish the source page
     $page = $this->objFromFixture('SiteTree', 'page1');
     $this->assertTrue($page->doPublish());
     // Create a virtual page from it, and publish that
     $svp = new SubsitesVirtualPage();
     $svp->CopyContentFromID = $page->ID;
     $svp->write();
     $svp->doPublish();
     // Rename the file
     $file = $this->objFromFixture('File', 'file1');
     $file->Name = 'renamed-test-file.pdf';
     $file->write();
     // Verify that the draft and publish virtual pages both have the corrected link
     $this->assertContains('<img src="assets/renamed-test-file.pdf"', DB::query("SELECT \"Content\" FROM \"SiteTree\" WHERE \"ID\" = {$svp->ID}")->value());
     $this->assertContains('<img src="assets/renamed-test-file.pdf"', DB::query("SELECT \"Content\" FROM \"SiteTree_Live\" WHERE \"ID\" = {$svp->ID}")->value());
     // File teardown
     $testFiles = array('/assets/testscript-test-file.pdf', '/assets/renamed-test-file.pdf');
     foreach ($testFiles as $file) {
         if (file_exists(Director::baseFolder() . $file)) {
             unlink(Director::baseFolder() . $file);
         }
     }
 }
开发者ID:helpfulrobot,项目名称:mikenz-silverstripe-simplesubsites,代码行数:28,代码来源:SubsitesVirtualPageTest.php

示例10: getFormattedImage

 /**
  * Return an image object representing the image in the given format.
  * This image will be generated using generateFormattedImage().
  * The generated image is cached, to flush the cache append ?flush=1 to your URL.
  *
  * Just pass the correct number of parameters expected by the working function
  *
  * @param string $format The name of the format.
  * @return Image_Cached
  */
 public function getFormattedImage($format)
 {
     $args = func_get_args();
     if ($this->ID && $this->Filename && Director::fileExists($this->Filename)) {
         $cacheFile = call_user_func_array(array($this, "cacheFilename"), $args);
         $fullPath = Director::baseFolder() . "/" . $cacheFile;
         if (!file_exists($fullPath) || self::$flush) {
             call_user_func_array(array($this, "generateFormattedImage"), $args);
             // If this image should be compressed, compress it now
             if ($this->getCompressed()) {
                 $compressor = $this->getCompressor();
                 try {
                     $compressor->compress($fullPath)->writeTo($fullPath);
                 } catch (Exception $e) {
                     // Do nothing, leave the uncompressed image in-place
                 }
             }
         }
         $cached = Injector::inst()->createWithArgs('Image_Cached', array($cacheFile));
         // Pass through the title so the templates can use it
         $cached->Title = $this->Title;
         // Pass through the parent, to store cached images in correct folder.
         $cached->ParentID = $this->ParentID;
         return $cached;
     }
 }
开发者ID:helpfulrobot,项目名称:kinglozzer-silverstripe-tinypng,代码行数:36,代码来源:Image.php

示例11: process

 public function process()
 {
     $post = $this->getObject();
     if ($post) {
         $author = $post->Owner();
         $balance = $author->Balance;
         if (self::$api_key && $post->Content != self::SPAM_CONTENT) {
             require_once Director::baseFolder() . '/microblog/thirdparty/defensio/Defensio.php';
             $defensio = new Defensio(self::$api_key);
             $document = array('type' => 'comment', 'content' => $post->Content, 'platform' => 'silverstripe_microblog', 'client' => 'MicroBlog Defensio-PHP | 0.1 | Marcus Nyeholt | marcus@silverstripe.com.au', 'async' => 'false');
             try {
                 $result = $defensio->postDocument($document);
                 if ($result && isset($result[1])) {
                     if ($result[1]->allow == 'false') {
                         $post->Content = self::SPAM_CONTENT;
                         $post->Down += self::SPAM_DOWN;
                         $post->write();
                         $author->Down += self::SPAM_DOWN;
                         $author->write();
                     }
                 }
             } catch (Exception $e) {
                 SS_Log::log($e, SS_Log::WARN);
             }
         }
         if ($post->Content != self::SPAM_CONTENT) {
             $post->analyseContent();
             $post->write();
         }
     }
     $this->isComplete = true;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-microblog,代码行数:32,代码来源:ProcessPostJob.php

示例12: init

 function init()
 {
     parent::init();
     // We allow access to this controller regardless of live-status or ADMIN permission only
     // if on CLI.  Access to this controller is always allowed in "dev-mode", or of the user is ADMIN.
     $canAccess = Director::isDev() || Director::is_cli() || Permission::check("ADMIN");
     if (!$canAccess) {
         return Security::permissionFailure($this, "This page is secured and you need administrator rights to access it. " . "Enter your credentials below and we will send you right along.");
     }
     // check for valid url mapping
     // lacking this information can cause really nasty bugs,
     // e.g. when running Director::test() from a FunctionalTest instance
     global $_FILE_TO_URL_MAPPING;
     if (Director::is_cli()) {
         if (isset($_FILE_TO_URL_MAPPING)) {
             $fullPath = $testPath = $_SERVER['SCRIPT_FILENAME'];
             while ($testPath && $testPath != "/" && !preg_match('/^[A-Z]:\\\\$/', $testPath)) {
                 $matched = false;
                 if (isset($_FILE_TO_URL_MAPPING[$testPath])) {
                     $matched = true;
                     break;
                 }
                 $testPath = dirname($testPath);
             }
             if (!$matched) {
                 echo 'Warning: You probably want to define ' . 'an entry in $_FILE_TO_URL_MAPPING that covers "' . Director::baseFolder() . '"' . "\n";
             }
         } else {
             echo 'Warning: You probably want to define $_FILE_TO_URL_MAPPING in ' . 'your _ss_environment.php as instructed on the "sake" page of the doc.silverstripe.com wiki' . "\n";
         }
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:32,代码来源:DevelopmentAdmin.php

示例13: createResampledAsset

 /**
  * Creates a content service asset object based on a given resampled file path
  * 
  * @param type $filename
  * @return ContentServiceAsset
  */
 protected function createResampledAsset($filename)
 {
     $fullpath = Director::baseFolder() . '/' . $filename;
     $asset = ContentServiceAsset::get()->filter('Filename', $filename)->first();
     if (!$asset) {
         $asset = new ContentServiceAsset();
     }
     $this->service = singleton('ContentService');
     $asset->Filename = $filename;
     $asset->SourceID = $this->ID;
     $asset->ParentID = $this->ParentID;
     $mtime = time();
     $writer = $this->service->getWriterFor($asset, 'FilePointer', $this->targetStore());
     if ($writer) {
         if (file_exists($fullpath)) {
             // likely that cached image never got built correctly.
             $name = \Controller::join_links(dirname($filename), $mtime, basename($filename));
             $writer->write(fopen($fullpath, 'r'), $name);
             $asset->FilePointer = $writer->getContentId();
             $asset->write();
             $reader = $writer->getReader();
             if ($reader && $reader->exists()) {
                 @unlink($fullpath);
             }
         } else {
             $asset = null;
         }
     } else {
         $asset = null;
     }
     return $asset;
 }
开发者ID:stephenmcm,项目名称:silverstripe-cdncontent,代码行数:38,代码来源:CdnImage.php

示例14: storeThemeFile

 /**
  * Store the contents of a folder on a CDN. 
  * 
  * If processReferences is set, relative URL references are attempted to be 
  * detected and stored remotely as well, with the file to be stored rewritten 
  * to refer to the CDN value. This really is only useful for CSS 
  *
  * @param string $folder
  * @param boolean $processReferences 
  */
 public function storeThemeFile($toCdn, $file, $forceUpdate = false, $processReferences = false)
 {
     $mtime = @filemtime($file);
     $relativeName = self::CDN_THEME_PREFIX . '/' . $mtime . '/' . trim(str_replace(Director::baseFolder(), '', $file), '/');
     if (!$forceUpdate) {
         // see if the file already exists, if not we do NOT do an update
         $reader = $this->contentService->findReaderFor($toCdn, $relativeName);
         if ($reader && $reader->exists()) {
             return $reader->getURL();
         }
     }
     $clear = false;
     if ($processReferences) {
         $clear = true;
         $file = $this->processFileReferences($toCdn, $file, $forceUpdate);
     }
     // otherwise, lets get a content writer
     $writer = $this->contentService->getWriter($toCdn);
     try {
         $writer->write($file, $relativeName);
     } catch (Exception $e) {
         SS_Log::log($e, SS_Log::WARN);
     }
     if ($clear && strpos($file, '.cdn') > 0) {
         @unlink($file);
     }
     $id = $writer->getContentId();
     return $writer->getReader()->getURL();
 }
开发者ID:stephenmcm,项目名称:silverstripe-cdncontent,代码行数:39,代码来源:ContentDeliveryService.php

示例15: generateFormattedImage

 public function generateFormattedImage($format, $arg1 = null, $arg2 = null)
 {
     $cacheFile = $this->cacheFilename($format, $arg1, $arg2);
     $gd = new GDBackend(Director::baseFolder() . "/" . $this->Filename);
     // Skip aktual generation
     return $gd;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:7,代码来源:DataDifferencerTest.php


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