本文整理汇总了PHP中Director::fileExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::fileExists方法的具体用法?PHP Director::fileExists怎么用?PHP Director::fileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::fileExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param Controller $controller The parent controller, necessary to
* create the appropriate form action tag.
* @param string $name The method on the controller that will return this
* form object.
* @param FieldSet|FormField $fields All of the fields in the form - a
* {@link FieldSet} of {@link FormField}
* objects.
* @param FieldSet|FormAction $actions All of the action buttons in the
* form - a {@link FieldSet} of
* {@link FormAction} objects
* @param bool $checkCurrentUser If set to TRUE, it will be checked if a
* the user is currently logged in, and if
* so, only a logout button will be rendered
*/
function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
{
$this->authenticator_class = 'MemberAuthenticator';
$customCSS = project() . '/css/member_login.css';
if (Director::fileExists($customCSS)) {
Requirements::css($customCSS);
}
if (isset($_REQUEST['BackURL'])) {
$backURL = $_REQUEST['BackURL'];
} else {
$backURL = Session::get('BackURL');
}
if ($checkCurrentUser && Member::currentUserID()) {
$fields = new FieldSet();
$actions = new FieldSet(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
} else {
if (!$fields) {
$fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("Email", _t('Member.EMAIL'), Session::get('SessionForms.MemberLoginForm.Email'), null, $this), new EncryptField("Password", _t('Member.PASSWORD'), null, $this), new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me next time?"), Session::get('SessionForms.MemberLoginForm.Remember'), $this));
}
if (!$actions) {
$actions = new FieldSet(new FormAction("dologin", _t('Member.BUTTONLOGIN', "Log in")), new FormAction("forgotPassword", _t('Member.BUTTONLOSTPASSWORD', "I've lost my password")));
}
}
if (isset($backURL)) {
$fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
}
parent::__construct($controller, $name, $fields, $actions);
}
示例2: path_for_file
/**
* Finds the path for specified file.
*
* @param string $fileOrUrl
* @return string|boolean
*/
protected static function path_for_file($fileOrUrl)
{
if (preg_match('{^//|http[s]?}', $fileOrUrl)) {
return $fileOrUrl;
} elseif (Director::fileExists($fileOrUrl)) {
$filePath = preg_replace('/\\?.*/', '', Director::baseFolder() . '/' . $fileOrUrl);
$prefix = Director::baseURL();
$mtimesuffix = "";
$suffix = '';
if (Requirements::get_suffix_requirements()) {
$mtimesuffix = "?m=" . filemtime($filePath);
$suffix = '&';
}
if (strpos($fileOrUrl, '?') !== false) {
if (strlen($suffix) == 0) {
$suffix = '?';
}
$suffix .= substr($fileOrUrl, strpos($fileOrUrl, '?') + 1);
$fileOrUrl = substr($fileOrUrl, 0, strpos($fileOrUrl, '?'));
} else {
$suffix = '';
}
return "{$prefix}{$fileOrUrl}{$mtimesuffix}{$suffix}";
} else {
return false;
}
}
示例3: init
public function init()
{
parent::init();
Requirements::javascript(MCE_ROOT . "tiny_mce_src.js");
Requirements::javascript("jsparty/tiny_mce_improvements.js");
Requirements::javascript("jsparty/hover.js");
Requirements::javascript("jsparty/scriptaculous/controls.js");
Requirements::javascript("cms/javascript/SecurityAdmin.js");
Requirements::javascript("cms/javascript/LeftAndMain_left.js");
Requirements::javascript("cms/javascript/LeftAndMain_right.js");
Requirements::javascript("cms/javascript/CMSMain_left.js");
Requirements::javascript("cms/javascript/ReportAdmin_left.js");
Requirements::javascript("cms/javascript/ReportAdmin_right.js");
Requirements::css("cms/css/ReportAdmin.css");
// TODO Find a better solution to integrate optional Requirements in a specific order
if (Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
Requirements::css("ecommerce/css/DataReportCMSMain.css");
}
if (Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
Requirements::javascript("ecommerce/javascript/DataReport.js");
}
if (Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
Requirements::css(project() . "/css/DataReportCMSMain.css");
}
if (Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
Requirements::javascript(project() . "/javascript/DataReport.js");
}
// We don't want this showing up in every ajax-response, it should always be present in a CMS-environment
if (!Director::is_ajax()) {
Requirements::javascriptTemplate("cms/javascript/tinymce.template.js", array("ContentCSS" => project() . "/css/editor.css", "BaseURL" => Director::absoluteBaseURL(), "Lang" => i18n::get_tinymce_lang()));
}
}
示例4: cwsShortCodeRandomQuoteHandler
/**
* Displays random quote from a CSV file located in a assets subfolder
* Uses template "cwsoft-shortcode/templates/Includes/RandomQuote.ss" for output
*
* @param $arguments (csv_file = 'subfolder_in_assets/csv_file.csv')
* @param $content = null
* @param $parser = null
* @return processed template RandomQuote.ss
*/
public static function cwsShortCodeRandomQuoteHandler($arguments, $content = null, $parser = null)
{
// only proceed if a CSV file was specified
if (!isset($arguments['csv_file'])) {
return;
}
$data = array();
// check if CSV file exists in assets folder
$csvFile = ASSETS_DIR . '/' . Convert::raw2sql($arguments['csv_file']);
if (Director::fileExists($csvFile)) {
$csv = new CSVParser($filename = $csvFile, $delimiter = '|', $enclosure = '"');
// iterate through imported Quotes|Author entries and store results in array
$citations = array();
foreach ($csv as $row) {
// only store entries with two data fields (quotation and author)
if (count($row) !== 2) {
continue;
}
$citations[] = $row;
}
// prepare data for output (randomize array and fetch first citation for output)
shuffle($citations);
$data = $citations[0];
}
// use default citation if CSV file does not exist or is invalid
if (!(isset($data['Quote']) && isset($data['Author']))) {
$data['Quote'] = _t('cwsShortCodeRandomQuote.DEFAULT_QUOTE', 'Only who puts his heart and soul in it, can ignite the fire in others.');
$data['Author'] = _t('cwsShortCodeRandomQuote.DEFAULT_AUTHOR', 'Augustinus');
}
// load template and process data
$template = new SSViewer('RandomQuote');
return $template->process(new ArrayData($data));
}
示例5: __construct
/**
* Constructor
*
* @param Controller $controller The parent controller, necessary to
* create the appropriate form action tag.
* @param string $name The method on the controller that will return this
* form object.
* @param FieldSet|FormField $fields All of the fields in the form - a
* {@link FieldSet} of {@link FormField}
* objects.
* @param FieldSet|FormAction $actions All of the action buttons in the
* form - a {@link FieldSet} of
* {@link FormAction} objects
* @param bool $checkCurrentUser If set to TRUE, it will be checked if a
* the user is currently logged in, and if
* so, only a logout button will be rendered
* @param string $authenticatorClassName Name of the authenticator class that this form uses.
*/
function __construct($controller, $name, $fields = null, $actions = null,
$checkCurrentUser = true) {
// This is now set on the class directly to make it easier to create subclasses
// $this->authenticator_class = $authenticatorClassName;
$customCSS = project() . '/css/member_login.css';
if(Director::fileExists($customCSS)) {
Requirements::css($customCSS);
}
// Focus on the email input when the page is loaded
Requirements::customScript("
(function($){
$(document).ready(function() {
$('#Email input').focus();
});
})(jQuery);
");
if(isset($_REQUEST['BackURL'])) {
$backURL = $_REQUEST['BackURL'];
} else {
$backURL = Session::get('BackURL');
}
if($checkCurrentUser && Member::currentUserID()) {
$fields = new FieldSet();
$actions = new FieldSet(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
} else {
if(!$fields) {
$fields = new FieldSet(
new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this),
new TextField("Email", _t('Member.EMAIL', 'Email'), Session::get('SessionForms.MemberLoginForm.Email'), null, $this),
new PasswordField("Password", _t('Member.PASSWORD', 'Password'))
);
if(Security::$autologin_enabled) {
$fields->push(new CheckboxField(
"Remember",
_t('Member.REMEMBERME', "Remember me next time?")
));
}
}
if(!$actions) {
$actions = new FieldSet(
new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")),
new LiteralField(
'forgotPassword',
'<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'
)
);
}
}
if(isset($backURL)) {
$fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
}
parent::__construct($controller, $name, $fields, $actions);
}
示例6: init
function init()
{
if (Director::fileExists(project() . "/css/VimeoGallery.css")) {
Requirements::css(project() . "/css/VimeoGallery.css");
} elseif (Director::fileExists('themes/' . project() . "/css/VimeoGallery.css")) {
Requirements::css('themes/' . project() . "/css/VimeoGallery.css");
} else {
Requirements::css("vimeoservice/css/VimeoGallery.css");
}
// only include if necessary
if ($this->ShowVideoInPopup) {
Requirements::javascript("vimeoservice/javascript/jquery-1.4.4.min.js");
Requirements::javascript("vimeoservice/javascript/jquery.prettyPhoto.js");
Requirements::css('vimeoservice/css/prettyPhoto.css');
$theme = $this->PopupTheme ? $this->PopupTheme : 'default';
$width = $this->PopupWidth < 1 ? 400 : $this->PopupWidth;
$height = $this->PopupHeight < 1 ? 225 : $this->PopupHeight;
Requirements::customScript(<<<JS
\$(document).ready(function(){
\$("a[rel^='prettyPhoto']").prettyPhoto({
theme:'{$theme}',
default_width: {$width},
default_height: {$height},
});
});
JS
);
}
parent::init();
}
示例7: __construct
/**
* Taken from MemberLoginForm::__construct with minor changes
*/
public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
{
$customCSS = project() . '/css/member_login.css';
if (Director::fileExists($customCSS)) {
Requirements::css($customCSS);
}
if (isset($_REQUEST['BackURL'])) {
$backURL = $_REQUEST['BackURL'];
} else {
$backURL = Session::get('BackURL');
}
if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
$fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this));
$actions = new FieldList(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
} else {
if (!$fields) {
$fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this));
}
if (!$actions) {
$actions = new FieldList(new FormAction('dologin', _t('GoogleAuthenticator.BUTTONLOGIN', "Log in with Google")));
}
}
if (isset($backURL)) {
$fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
}
// Allow GET method for callback
$this->setFormMethod('GET', true);
parent::__construct($controller, $name, $fields, $actions);
}
开发者ID:helpfulrobot,项目名称:xpointo-silverstripe-google-authenticator,代码行数:32,代码来源:GoogleAuthenticatorLoginForm.php
示例8: getPreviewThumbnail
/**
* Gets a thumbnail for this file given a size. If it's an Image,
* it will render the actual file. If not, it will provide an icon based
* on the extension.
* @param int $w The width of the image
* @param int $h The height of the image
* @return Image_Cached
*/
public function getPreviewThumbnail($w = null, $h = null)
{
if (!$w) {
$w = $this->owner->config()->grid_thumbnail_width;
}
if (!$h) {
$h = $this->owner->config()->grid_thumbnail_height;
}
if ($this->IsImage() && Director::fileExists($this->owner->Filename)) {
return $this->owner->CroppedImage($w, $h);
}
$sizes = Config::inst()->forClass('FileAttachmentField')->icon_sizes;
sort($sizes);
foreach ($sizes as $size) {
if ($w <= $size) {
if ($this->owner instanceof Folder) {
$file = $this->getFilenameForType('_folder', $size);
} else {
$file = $this->getFilenameForType($this->owner->getExtension(), $size);
}
if (!file_exists(BASE_PATH . '/' . $file)) {
$file = $this->getFilenameForType('_blank', $size);
}
return new Image_Cached(Director::makeRelative($file));
}
}
}
示例9: 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;
}
}
示例10: generatePageIconsCss
/**
* Include CSS for page icons. We're not using the JSTree 'types' option
* because it causes too much performance overhead just to add some icons.
*
* @return String CSS
*/
public function generatePageIconsCss()
{
$css = '';
$classes = ClassInfo::subclassesFor('SiteTree');
foreach ($classes as $class) {
$obj = singleton($class);
$iconSpec = $obj->stat('icon');
if (!$iconSpec) {
continue;
}
// Legacy support: We no longer need separate icon definitions for folders etc.
$iconFile = is_array($iconSpec) ? $iconSpec[0] : $iconSpec;
// Legacy support: Add file extension if none exists
if (!pathinfo($iconFile, PATHINFO_EXTENSION)) {
$iconFile .= '-file.gif';
}
$iconPathInfo = pathinfo($iconFile);
// Base filename
$baseFilename = $iconPathInfo['dirname'] . '/' . $iconPathInfo['filename'];
$fileExtension = $iconPathInfo['extension'];
$selector = ".page-icon.class-{$class}, li.class-{$class} > a .jstree-pageicon";
if (Director::fileExists($iconFile)) {
$css .= "{$selector} { background: transparent url('{$iconFile}') 0 0 no-repeat; }\n";
} else {
// Support for more sophisticated rules, e.g. sprited icons
$css .= "{$selector} { {$iconFile} }\n";
}
}
return $css;
}
示例11: Icon
public function Icon()
{
$ext = strtolower($this->getExtension());
if (Director::fileExists(POSTMARK_PATH . "/images/icons/files/{$ext}_32.gif")) {
return POSTMARK_RELATIVE_PATH . "/images/icons/files/{$ext}_32.gif";
}
return POSTMARK_RELATIVE_PATH . "/images/icons/files/generic_32.gif";
}
示例12: init
public function init()
{
if (Director::fileExists(project() . "/css/gallery.css")) {
Requirements::css(project() . "/css/gallery.css");
} else {
Requirements::css("basic-galleries/css/gallery.css");
}
parent::init();
}
示例13: init
function init()
{
RSSFeed::linkToFeed($this->Link() . "rss");
if (Director::fileExists(project() . "/css/news.css")) {
Requirements::css(project() . "/css/news.css");
} else {
Requirements::css("basic-news/css/news.css");
}
parent::init();
}
示例14: testFileExists
public function testFileExists()
{
$tempFileName = 'DirectorTest_testFileExists.tmp';
$tempFilePath = TEMP_FOLDER . '/' . $tempFileName;
// create temp file
file_put_contents($tempFilePath, '');
$this->assertTrue(Director::fileExists($tempFilePath), 'File exist check with absolute path');
$this->assertTrue(Director::fileExists($tempFilePath . '?queryparams=1&foo[bar]=bar'), 'File exist check with query params ignored');
unlink($tempFilePath);
}
示例15: onAfterInit
public function onAfterInit()
{
if (Config::inst()->get("Blog", 'include_default_css')) {
if (Director::fileExists(project() . "/css/blog.css")) {
Requirements::css(project() . "/css/blog.css");
} else {
Requirements::css("mypswd-blog-tweaks/css/blog.css");
}
}
}