本文整理汇总了PHP中file_default_scheme函数的典型用法代码示例。如果您正苦于以下问题:PHP file_default_scheme函数的具体用法?PHP file_default_scheme怎么用?PHP file_default_scheme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_default_scheme函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testFileCheckDirectoryHandling
/**
* Test directory handling functions.
*/
function testFileCheckDirectoryHandling()
{
// A directory to operate on.
$directory = file_default_scheme() . '://' . $this->randomMachineName() . '/' . $this->randomMachineName();
$this->assertFalse(is_dir($directory), 'Directory does not exist prior to testing.');
// Non-existent directory.
$this->assertFalse(file_prepare_directory($directory, 0), 'Error reported for non-existing directory.', 'File');
// Make a directory.
$this->assertTrue(file_prepare_directory($directory, FILE_CREATE_DIRECTORY), 'No error reported when creating a new directory.', 'File');
// Make sure directory actually exists.
$this->assertTrue(is_dir($directory), 'Directory actually exists.', 'File');
if (substr(PHP_OS, 0, 3) != 'WIN') {
// PHP on Windows doesn't support any kind of useful read-only mode for
// directories. When executing a chmod() on a directory, PHP only sets the
// read-only flag, which doesn't prevent files to actually be written
// in the directory on any recent version of Windows.
// Make directory read only.
@drupal_chmod($directory, 0444);
$this->assertFalse(file_prepare_directory($directory, 0), 'Error reported for a non-writeable directory.', 'File');
// Test directory permission modification.
$this->setSetting('file_chmod_directory', 0777);
$this->assertTrue(file_prepare_directory($directory, FILE_MODIFY_PERMISSIONS), 'No error reported when making directory writeable.', 'File');
}
// Test that the directory has the correct permissions.
$this->assertDirectoryPermissions($directory, 0777, 'file_chmod_directory setting is respected.');
// Remove .htaccess file to then test that it gets re-created.
@drupal_unlink(file_default_scheme() . '://.htaccess');
$this->assertFalse(is_file(file_default_scheme() . '://.htaccess'), 'Successfully removed the .htaccess file in the files directory.', 'File');
file_ensure_htaccess();
$this->assertTrue(is_file(file_default_scheme() . '://.htaccess'), 'Successfully re-created the .htaccess file in the files directory.', 'File');
// Verify contents of .htaccess file.
$file = file_get_contents(file_default_scheme() . '://.htaccess');
$this->assertEqual($file, FileStorage::htaccessLines(FALSE), 'The .htaccess file contains the proper content.', 'File');
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:37,代码来源:DirectoryTest.php
示例2: __construct
/**
* Constructs a DataProviderFile object.
*/
public function __construct(RequestInterface $request, ResourceFieldCollectionInterface $field_definitions, $account, $plugin_id, $resource_path, array $options, $langcode = NULL)
{
parent::__construct($request, $field_definitions, $account, $plugin_id, $resource_path, $options, $langcode);
$file_options = empty($this->options['options']) ? array() : $this->options['options'];
$default_values = array('validators' => array('file_validate_extensions' => array(), 'file_validate_size' => array()), 'scheme' => file_default_scheme(), 'replace' => FILE_EXISTS_RENAME);
$this->options['options'] = drupal_array_merge_deep($default_values, $file_options);
}
开发者ID:jhoffman-tm,项目名称:waldorf-deployment,代码行数:10,代码来源:DataProviderFile.php
示例3: puzzle_form_system_theme_settings_alter
function puzzle_form_system_theme_settings_alter(&$form, $form_state)
{
$form['layout_style'] = array('#type' => 'select', '#title' => t('Layout Style'), '#default_value' => theme_get_setting('layout_style'), '#options' => array('wide' => t('Wide'), 'boxed' => t('Boxed')));
$form['main_color'] = array('#type' => 'select', '#title' => t('Main Color'), '#default_value' => theme_get_setting('main_color'), '#options' => array('corporate' => 'corporate', 'cyan' => 'cyan', 'medical' => 'medical', 'restaurant' => 'restaurant', 'portfolio' => 'portfolio', 'orange' => 'orange', 'tangerine' => 'tangerine', 'gold' => 'gold'));
$form['background_color'] = array('#type' => 'select', '#title' => t('Background'), '#default_value' => theme_get_setting('background_color'), '#options' => background_color());
$form['background_image'] = array('#type' => 'managed_file', '#title' => t('Background Image'), '#default_value' => theme_get_setting('background_image'), '#upload_location' => file_default_scheme() . '://theme_background', '#upload_validators' => array('file_validate_extensions' => array('gif png jpg jpeg')));
$form['header_top_padding'] = array('#type' => 'textfield', '#title' => t('HEader Top Padding'), '#default_value' => theme_get_setting('header_top_padding'));
}
开发者ID:Koreychenko,项目名称:puzzle,代码行数:8,代码来源:theme-settings.php
示例4: languageCssPath
/**
* Get the path for css file.
*
* @param bool $dironly
* TRUE if wants only the dir, FALSE for the full path + file.
*
* @return string
* Full path to css file.
*/
public static function languageCssPath($dironly = FALSE)
{
$directory = file_default_scheme() . '://geshi';
if (!$dironly) {
$directory .= '/geshifilter-languages.css';
}
return $directory;
}
开发者ID:hugronaphor,项目名称:cornel,代码行数:17,代码来源:GeshiFilterCss.php
示例5: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$id = $this->entity->id;
$file_name = file_default_scheme() . "://js_injector/{$id}.js";
file_unmanaged_delete_recursive($file_name);
$this->entity->delete();
drupal_set_message($this->t('Js Injector deleted @label.', ['@label' => $this->entity->label()]));
$form_state->setRedirectUrl($this->getCancelUrl());
}
开发者ID:pookmish,项目名称:js_injector,代码行数:12,代码来源:JsInjectorDeleteForm.php
示例6: testSingleFile
/**
* Delete a normal file.
*/
function testSingleFile()
{
// Create a file for testing
$filepath = file_default_scheme() . '://' . $this->randomMachineName();
file_put_contents($filepath, '');
// Delete the file.
$this->assertTrue(file_unmanaged_delete_recursive($filepath), 'Function reported success.');
$this->assertFalse(file_exists($filepath), 'Test file has been deleted.');
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:12,代码来源:UnmanagedDeleteRecursiveTest.php
示例7: testPathologic
function testPathologic()
{
global $script_path;
// Start by testing our function to build protocol-relative URLs
$this->assertEqual(_pathologic_url_to_protocol_relative('http://example.com/foo/bar'), '//example.com/foo/bar', t('Protocol-relative URL creation with http:// URL'));
$this->assertEqual(_pathologic_url_to_protocol_relative('https://example.org/baz'), '//example.org/baz', t('Protocol-relative URL creation with https:// URL'));
// Build some paths to check against
$test_paths = array('foo' => array('path' => 'foo', 'opts' => array()), 'foo/bar' => array('path' => 'foo/bar', 'opts' => array()), 'foo/bar?baz' => array('path' => 'foo/bar', 'opts' => array('query' => array('baz' => NULL))), 'foo/bar?baz=qux' => array('path' => 'foo/bar', 'opts' => array('query' => array('baz' => 'qux'))), 'foo/bar#baz' => array('path' => 'foo/bar', 'opts' => array('fragment' => 'baz')), 'foo/bar?baz=qux&quux=quuux#quuuux' => array('path' => 'foo/bar', 'opts' => array('query' => array('baz' => 'qux', 'quux' => 'quuux'), 'fragment' => 'quuuux')), 'foo%20bar?baz=qux%26quux' => array('path' => 'foo bar', 'opts' => array('query' => array('baz' => 'qux&quux'))), '/' => array('path' => '<front>', 'opts' => array()));
foreach (array('full', 'proto-rel', 'path') as $protocol_style) {
$format_id = _pathologic_build_format(['settings_source' => 'local', 'local_settings' => ['protocol_style' => $protocol_style]]);
$paths = array();
foreach ($test_paths as $path => $args) {
$args['opts']['absolute'] = $protocol_style !== 'path';
$paths[$path] = _pathologic_content_url($args['path'], $args['opts']);
if ($protocol_style === 'proto-rel') {
$paths[$path] = _pathologic_url_to_protocol_relative($paths[$path]);
}
}
$t10ns = array('@clean' => empty($script_path) ? t('Yes') : t('No'), '@ps' => $protocol_style);
$this->assertEqual(check_markup('<a href="foo"><img src="foo/bar" /></a>', $format_id), '<a href="' . $paths['foo'] . '"><img src="' . $paths['foo/bar'] . '" /></a>', t('Simple paths. Clean URLs: @clean; protocol style: @ps.', $t10ns));
$this->assertEqual(check_markup('<a href="index.php?q=foo"></a><a href="index.php?q=foo/bar&baz=qux"></a>', $format_id), '<a href="' . $paths['foo'] . '"></a><a href="' . $paths['foo/bar?baz=qux'] . '"></a>', t('D7 and earlier-style non-clean URLs. Clean URLs: @clean; protocol style: @ps.', $t10ns));
$this->assertEqual(check_markup('<a href="index.php/foo"></a><a href="index.php/foo/bar?baz=qux"></a>', $format_id), '<a href="' . $paths['foo'] . '"></a><a href="' . $paths['foo/bar?baz=qux'] . '"></a>', t('D8-style non-clean URLs. Clean URLs: @clean; protocol style: @ps.', $t10ns));
$this->assertEqual(check_markup('<form action="foo/bar?baz"><IMG LONGDESC="foo/bar?baz=qux" /></a>', $format_id), '<form action="' . $paths['foo/bar?baz'] . '"><IMG LONGDESC="' . $paths['foo/bar?baz=qux'] . '" /></a>', t('Paths with query string. Clean URLs: @clean; protocol style: @ps.', $t10ns));
$this->assertEqual(check_markup('<a href="foo/bar#baz">', $format_id), '<a href="' . $paths['foo/bar#baz'] . '">', t('Path with fragment. Clean URLs: @clean; protocol style: @ps.', $t10ns));
$this->assertEqual(check_markup('<a href="#foo">', $format_id), '<a href="#foo">', t('Fragment-only href. Clean URLs: @clean; protocol style: @ps.', $t10ns));
// @see https://drupal.org/node/2208223
$this->assertEqual(check_markup('<a href="#">', $format_id), '<a href="#">', t('Hash-only href. Clean URLs: @clean; protocol style: @ps.', $t10ns));
$this->assertEqual(check_markup('<a href="foo/bar?baz=qux&quux=quuux#quuuux">', $format_id), '<a href="' . $paths['foo/bar?baz=qux&quux=quuux#quuuux'] . '">', t('Path with query string and fragment. Clean URLs: @clean; protocol style: @ps.', $t10ns));
$this->assertEqual(check_markup('<a href="foo%20bar?baz=qux%26quux">', $format_id), '<a href="' . $paths['foo%20bar?baz=qux%26quux'] . '">', t('Path with URL encoded parts. Clean URLs: @clean; protocol style: @ps.', $t10ns));
$this->assertEqual(check_markup('<a href="/"></a>', $format_id), '<a href="' . $paths['/'] . '"></a>', t('Path with just slash. Clean URLs: @clean; protocol style: @ps', $t10ns));
}
global $base_path;
$this->assertEqual(check_markup('<a href="' . $base_path . 'foo">bar</a>', $format_id), '<a href="' . _pathologic_content_url('foo', array('absolute' => FALSE)) . '">bar</a>', t('Paths beginning with $base_path (like WYSIWYG editors like to make)'));
global $base_url;
$this->assertEqual(check_markup('<a href="' . $base_url . '/foo">bar</a>', $format_id), '<a href="' . _pathologic_content_url('foo', array('absolute' => FALSE)) . '">bar</a>', t('Paths beginning with $base_url'));
// @see http://drupal.org/node/1617944
$this->assertEqual(check_markup('<a href="//example.com/foo">bar</a>', $format_id), '<a href="//example.com/foo">bar</a>', t('Off-site schemeless URLs (//example.com/foo) ignored'));
// Test internal: and all base paths
$format_id = _pathologic_build_format(['settings_source' => 'local', 'local_settings' => ['local_paths' => "http://example.com/qux\nhttp://example.org\n/bananas", 'protocol_style' => 'full']]);
// @see https://drupal.org/node/2030789
$this->assertEqual(check_markup('<a href="//example.org/foo">bar</a>', $format_id), '<a href="' . _pathologic_content_url('foo', array('absolute' => TRUE)) . '">bar</a>', t('On-site schemeless URLs processed'));
$this->assertEqual(check_markup('<a href="internal:foo">', $format_id), '<a href="' . _pathologic_content_url('foo', array('absolute' => TRUE)) . '">', t('Path Filter compatibility (internal:)'));
$this->assertEqual(check_markup('<a href="files:image.jpeg">look</a>', $format_id), '<a href="' . _pathologic_content_url(file_create_url(file_default_scheme() . '://image.jpeg'), array('absolute' => TRUE)) . '">look</a>', t('Path Filter compatibility (files:)'));
$this->assertEqual(check_markup('<a href="http://example.com/qux/foo"><img src="http://example.org/bar.jpeg" longdesc="/bananas/baz" /></a>', $format_id), '<a href="' . _pathologic_content_url('foo', array('absolute' => TRUE)) . '"><img src="' . _pathologic_content_url('bar.jpeg', array('absolute' => TRUE)) . '" longdesc="' . _pathologic_content_url('baz', array('absolute' => TRUE)) . '" /></a>', t('"All base paths for this site" functionality'));
$this->assertEqual(check_markup('<a href="webcal:foo">bar</a>', $format_id), '<a href="webcal:foo">bar</a>', t('URLs with likely protocols are ignored'));
// Test hook_pathologic_alter() implementation.
$this->assertEqual(check_markup('<a href="foo?test=add_foo_qpart">', $format_id), '<a href="' . _pathologic_content_url('foo', array('absolute' => TRUE, 'query' => array('test' => 'add_foo_qpart', 'foo' => 'bar'))) . '">', t('hook_pathologic_alter(): Alter $url_params'));
$this->assertEqual(check_markup('<a href="bar?test=use_original">', $format_id), '<a href="bar?test=use_original">', t('hook_pathologic_alter(): Passthrough with use_original option'));
// Test paths to existing files when clean URLs are disabled.
// @see http://drupal.org/node/1672430
$script_path = '';
$filtered_tag = check_markup('<img src="misc/druplicon.png" />', $format_id);
$this->assertTrue(strpos($filtered_tag, 'q=') === FALSE, t('Paths to files don\'t have ?q= when clean URLs are off'));
$format_id = _pathologic_build_format(['settings_source' => 'global', 'local_settings' => ['protocol_style' => 'rel']]);
$this->config('pathologic.settings')->set('protocol_style', 'proto-rel')->set('local_paths', 'http://example.com/')->save();
$this->assertEqual(check_markup('<img src="http://example.com/foo.jpeg" />', $format_id), '<img src="' . _pathologic_url_to_protocol_relative(_pathologic_content_url('foo.jpeg', array('absolute' => TRUE))) . '" />', t('Use global settings when so configured on the format'));
}
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:57,代码来源:PathologicTest.php
示例8: plain_response_preprocess_html
/**
* Preprocessor for html.tpl.php
* Adds meta tag to control viewport, and path to theme in JS.
*/
function plain_response_preprocess_html(&$vars)
{
$meta = array('#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, minimum-scale=1'));
drupal_add_html_head($meta, 'plain-response-viewport');
$settings = array('base_url' => url('<front>', array('absolute' => 'true')), 'theme_path' => path_to_theme(), 'default_scheme' => file_default_scheme());
foreach (file_get_stream_wrappers() as $name => $wrapper) {
$settings[$name . '_files'] = file_create_url($name . '://');
}
$path = drupal_get_path('theme', 'plain_response');
drupal_add_js(array('plain_response' => $settings), array('type' => 'setting'));
}
开发者ID:rtrvrtg,项目名称:Plain-Response,代码行数:15,代码来源:template.php
示例9: userConf
/**
* Returns processed profile configuration for a user.
*/
public static function userConf(AccountProxyInterface $user = NULL, $scheme = NULL)
{
$user = $user ?: \Drupal::currentUser();
$scheme = isset($scheme) ? $scheme : file_default_scheme();
if ($profile = static::userProfile($user, $scheme)) {
$conf = $profile->getConf();
$conf['pid'] = $profile->id();
$conf['scheme'] = $scheme;
return static::processUserConf($conf, $user);
}
}
开发者ID:aakb,项目名称:cfia,代码行数:14,代码来源:Imce.php
示例10: setUp
/**
* Sets up for multiple values test case.
*/
protected function setUp()
{
parent::setUp();
// Create test files.
$this->permanent_file_entity = $this->createPermanentFileEntity();
$this->temporary_file_entity_1 = $this->createTemporaryFileEntity();
$this->temporary_file_entity_2 = $this->createTemporaryFileEntity();
$path = file_default_scheme() . '://' . FILEFIELD_SOURCE_ATTACH_DEFAULT_PATH;
$this->temporary_file = $this->createTemporaryFile($path);
// Change allowed number of values.
$this->drupalPostForm('admin/structure/types/manage/' . $this->typeName . '/fields/node.' . $this->typeName . '.' . $this->fieldName . '/storage', array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings'));
$this->enableSources(array('upload' => TRUE, 'remote' => TRUE, 'clipboard' => TRUE, 'reference' => TRUE, 'attach' => TRUE));
}
开发者ID:shrimala,项目名称:filefield_sources,代码行数:16,代码来源:MultipleValuesTest.php
示例11: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
parent::setUp();
// Enable user pictures.
\Drupal::state()->set('user_pictures', 1);
\Drupal::state()->set('user_picture_file_size', '');
// Set up the pictures directory.
$picture_path = file_default_scheme() . '://' . \Drupal::state()->get('user_picture_path', 'pictures');
if (!file_prepare_directory($picture_path, FILE_CREATE_DIRECTORY)) {
$this->fail('Could not create directory ' . $picture_path . '.');
}
$this->account = $this->drupalCreateUser(array('administer users'));
$this->drupalLogin($this->account);
}
开发者ID:dev981,项目名称:gaptest,代码行数:17,代码来源:TokenUserTest.php
示例12: testWithoutFilename
/**
* Test the file_save_data() function when no filename is provided.
*/
function testWithoutFilename()
{
$contents = $this->randomName(8);
$result = file_save_data($contents);
$this->assertTrue($result, 'Unnamed file saved correctly.');
$this->assertEqual(file_default_scheme(), file_uri_scheme($result->getFileUri()), "File was placed in Drupal's files directory.");
$this->assertEqual($result->getFilename(), drupal_basename($result->getFileUri()), "Filename was set to the file's basename.");
$this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of the file are correct.');
$this->assertEqual($result->getMimeType(), 'application/octet-stream', 'A MIME type was set.');
$this->assertTrue($result->isPermanent(), "The file's status was set to permanent.");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(array('insert'));
// Verify that what was returned is what's in the database.
$this->assertFileUnchanged($result, file_load($result->id(), TRUE));
}
开发者ID:alnutile,项目名称:drunatra,代码行数:18,代码来源:SaveDataTest.php
示例13: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
$js_injector = $this->entity;
$status = $js_injector->save();
switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Created the %label Js Injector.', ['%label' => $js_injector->label()]));
break;
default:
drupal_set_message($this->t('Saved the %label Js Injector.', ['%label' => $js_injector->label()]));
$file_name = file_default_scheme() . '://js_injector/' . $js_injector->id . '.js';
file_unmanaged_delete_recursive($file_name);
}
drupal_flush_all_caches();
$form_state->setRedirectUrl($js_injector->urlInfo('collection'));
}
开发者ID:pookmish,项目名称:js_injector,代码行数:19,代码来源:JsInjectorForm.php
示例14: testFileSaveData
/**
* Test the file_unmanaged_save_data() function.
*/
function testFileSaveData()
{
$contents = $this->randomMachineName(8);
$this->settingsSet('file_chmod_file', 0777);
// No filename.
$filepath = file_unmanaged_save_data($contents);
$this->assertTrue($filepath, 'Unnamed file saved correctly.');
$this->assertEqual(file_uri_scheme($filepath), file_default_scheme(), "File was placed in Drupal's files directory.");
$this->assertEqual($contents, file_get_contents($filepath), 'Contents of the file are correct.');
// Provide a filename.
$filepath = file_unmanaged_save_data($contents, 'public://asdf.txt', FILE_EXISTS_REPLACE);
$this->assertTrue($filepath, 'Unnamed file saved correctly.');
$this->assertEqual('asdf.txt', drupal_basename($filepath), 'File was named correctly.');
$this->assertEqual($contents, file_get_contents($filepath), 'Contents of the file are correct.');
$this->assertFilePermissions($filepath, 0777);
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:19,代码来源:UnmanagedSaveDataTest.php
示例15: __construct
/**
* Overrides \RestfulEntityBase::__construct()
*
* Set the "options" key from the plugin info, specific for file upload, with
* the following keys:
* - "validators": By default no validation is done on the file extensions or
* file size.
* - "scheme": By default the default scheme (e.g. public, private) is used.
*/
public function __construct(array $plugin, \RestfulAuthenticationManager $auth_manager = NULL, \DrupalCacheInterface $cache_controller = NULL, $language = NULL) {
parent::__construct($plugin, $auth_manager, $cache_controller, $language);
if (!$options = $this->getPluginKey('options')) {
$options = array();
}
$default_values = array(
'validators' => array(
'file_validate_extensions' => array(),
'file_validate_size' => array(),
),
'scheme' => file_default_scheme(),
'replace' => FILE_EXISTS_RENAME,
);
$this->setPluginKey('options', drupal_array_merge_deep($default_values, $options));
}
开发者ID:humanitarianresponse,项目名称:site,代码行数:27,代码来源:RestfulFilesUpload.php
示例16: testUserTokens
public function testUserTokens()
{
// Enable user pictures.
\Drupal::state()->set('user_pictures', 1);
\Drupal::state()->set('user_picture_file_size', '');
// Set up the pictures directory.
$picture_path = file_default_scheme() . '://' . \Drupal::state()->get('user_picture_path', 'pictures');
if (!file_prepare_directory($picture_path, FILE_CREATE_DIRECTORY)) {
$this->fail('Could not create directory ' . $picture_path . '.');
}
// Add a user picture to the account.
$image = current($this->drupalGetTestFiles('image'));
$edit = array('files[user_picture_0]' => drupal_realpath($image->uri));
$this->drupalPostForm('user/' . $this->account->id() . '/edit', $edit, t('Save'));
$storage = \Drupal::entityTypeManager()->getStorage('user');
// Load actual user data from database.
$storage->resetCache();
$this->account = $storage->load($this->account->id());
$this->assertTrue(!empty($this->account->user_picture->target_id), 'User picture uploaded.');
$picture = ['#theme' => 'user_picture', '#account' => $this->account];
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$user_tokens = array('picture' => $renderer->renderPlain($picture), 'picture:fid' => $this->account->user_picture->target_id, 'picture:size-raw' => 125, 'ip-address' => NULL, 'roles' => implode(', ', $this->account->getRoles()));
$this->assertTokens('user', array('user' => $this->account), $user_tokens);
// Remove the simpletest-created user role.
$roles = $this->account->getRoles();
$this->account->removeRole(end($roles));
$this->account->save();
// Remove the user picture field and reload the user.
FieldStorageConfig::loadByName('user', 'user_picture')->delete();
$storage->resetCache();
$this->account = $storage->load($this->account->id());
$user_tokens = array('picture' => NULL, 'picture:fid' => NULL, 'ip-address' => NULL, 'roles' => 'authenticated', 'roles:keys' => (string) DRUPAL_AUTHENTICATED_RID);
$this->assertTokens('user', array('user' => $this->account), $user_tokens);
// The ip address token should work for the current user token type.
$tokens = array('ip-address' => \Drupal::request()->getClientIp());
$this->assertTokens('current-user', array(), $tokens);
$anonymous = new AnonymousUserSession();
$tokens = array('roles' => 'anonymous', 'roles:keys' => (string) DRUPAL_ANONYMOUS_RID);
$this->assertTokens('user', array('user' => $anonymous), $tokens);
}
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:41,代码来源:TokenUserTest.php
示例17: nuboot_radix_form_system_theme_settings_alter
/**
* Implements theme_settings().
*/
function nuboot_radix_form_system_theme_settings_alter(&$form, &$form_state)
{
// Ensure this include file is loaded when the form is rebuilt from the cache.
$form_state['build_info']['files']['form'] = drupal_get_path('theme', 'nuboot_radix') . '/theme-settings.php';
// Add theme settings here.
$form['nuboot_radix_theme_settings'] = array('#title' => t('Theme Settings'), '#type' => 'fieldset');
// Copyright.
$copyright = theme_get_setting('copyright');
$form['nuboot_radix_theme_settings']['copyright'] = array('#title' => t('Copyright'), '#type' => 'text_format', '#format' => 'html', '#default_value' => isset($copyright['value']) ? $copyright['value'] : t('Powered by Drupal, not for clinical or production use!!'));
// Hero fieldset.
$form['hero'] = array('#type' => 'fieldset', '#title' => t('Hero Unit'), '#group' => 'general');
// Upload field.
$form['hero']['hero_file'] = array('#type' => 'managed_file', '#title' => t('Upload a new photo for the hero section background'), '#description' => t('<p>The hero unit is the large featured area located on the front page.
This theme supplies a default background image for this area. You may upload a different
photo here and it will replace the default background image.</p><p>Max. file size: 2 MB
<br>Recommended pixel size: 1920 x 400<br>Allowed extensions: .png .jpg .jpeg</p>'), '#required' => FALSE, '#upload_location' => file_default_scheme() . '://theme/backgrounds/', '#default_value' => theme_get_setting('hero_file'), '#upload_validators' => array('file_validate_extensions' => array('gif png jpg jpeg')));
// Solid color background.
$form['hero']['background_option'] = array('#type' => 'textfield', '#title' => t('Solid color option'), '#description' => t('<p>Enter a hex value here to use a solid background color rather than an image in the hero unit. Make sure the image field above is empty.'), '#required' => FALSE, '#default_value' => theme_get_setting('background_option'), '#element_validate' => array('_background_option_setting'));
// Return the additional form widgets.
return $form;
}
开发者ID:KFGisIT,项目名称:gsa-bpa-drupal,代码行数:24,代码来源:theme-settings.php
示例18: nuboot_radix_form_system_theme_settings_alter
/**
* Implements theme_settings().
*/
function nuboot_radix_form_system_theme_settings_alter(&$form, &$form_state)
{
//drupal_set_message('<pre>' . print_r($form, TRUE) . '</pre>');
// Ensure this include file is loaded when the form is rebuilt from the cache.
$form_state['build_info']['files']['form'] = drupal_get_path('theme', 'nuboot_radix') . '/theme-settings.php';
// Add theme settings here.
$form['nuboot_radix_theme_settings'] = array('#title' => t('Theme Settings'), '#type' => 'fieldset');
// Copyright.
$copyright = theme_get_setting('copyright');
$form['nuboot_radix_theme_settings']['copyright'] = array('#title' => t('Copyright'), '#type' => 'text_format', '#format' => 'html', '#default_value' => isset($copyright['value']) ? $copyright['value'] : t('Powered by <a href="http://nucivic.com/dkan">DKAN</a>, a project of <a href="http://nucivic.com">NuCivic</a>'));
// Hero fieldset.
$form['hero'] = array('#type' => 'fieldset', '#title' => t('Hero Unit'), '#group' => 'general');
// Upload field.
$form['hero']['hero_file'] = array('#type' => 'managed_file', '#title' => t('Upload a new photo for the hero section background'), '#description' => t('<p>The hero unit is the large featured area located on the front page.
This theme supplies a default background image for this area. You may upload a different
photo here and it will replace the default background image.</p><p>Max. file size: 2 MB
<br>Recommended pixel size: 1920 x 400<br>Allowed extensions: .png .jpg .jpeg</p>'), '#required' => FALSE, '#upload_location' => file_default_scheme() . '://theme/backgrounds/', '#default_value' => theme_get_setting('hero_file'), '#upload_validators' => array('file_validate_extensions' => array('gif png jpg jpeg')));
// Solid color background.
$form['hero']['background_option'] = array('#type' => 'textfield', '#title' => t('Solid color option'), '#description' => t('<p>Enter a hex value here to use a solid background color rather than an image in the hero unit. Make sure the image field above is empty.'), '#required' => FALSE, '#default_value' => theme_get_setting('background_option'), '#element_validate' => array('_background_option_setting'));
// Add svg logo option.
$form['logo']['settings']['svg_logo'] = array('#type' => 'managed_file', '#title' => t('Upload an .svg version of your logo'), '#description' => t('<p>Be sure to also add a .png version of your logo with the <em>Upload logo image</em> field above for older browsers that do not support .svg files. Both files should have the same name, only the suffix should change (i.e. logo.png & logo.svg).</p>'), '#required' => FALSE, '#upload_location' => file_default_scheme() . '://', '#default_value' => theme_get_setting('svg_logo'), '#upload_validators' => array('file_validate_extensions' => array('svg')));
// Return the additional form widgets.
return $form;
}
开发者ID:newswim,项目名称:dkan-drops-7,代码行数:27,代码来源:theme-settings.php
示例19: settings
/**
* Implements hook_filefield_source_settings().
*/
public static function settings(WidgetInterface $plugin)
{
$settings = $plugin->getThirdPartySetting('filefield_sources', 'filefield_sources', array('source_attach' => array('path' => FILEFIELD_SOURCE_ATTACH_DEFAULT_PATH, 'absolute' => FILEFIELD_SOURCE_ATTACH_RELATIVE, 'attach_mode' => FILEFIELD_SOURCE_ATTACH_MODE_MOVE)));
$return['source_attach'] = array('#title' => t('File attach settings'), '#type' => 'details', '#description' => t('File attach allows for selecting a file from a directory on the server, commonly used in combination with FTP.') . ' <strong>' . t('This file source will ignore file size checking when used.') . '</strong>', '#element_validate' => array(array(get_called_class(), 'filePathValidate')), '#weight' => 3);
$return['source_attach']['path'] = array('#type' => 'textfield', '#title' => t('File attach path'), '#default_value' => $settings['source_attach']['path'], '#size' => 60, '#maxlength' => 128, '#description' => t('The directory within the <em>File attach location</em> that will contain attachable files.'));
if (\Drupal::moduleHandler()->moduleExists('token')) {
$return['source_attach']['tokens'] = array('#theme' => 'token_tree', '#token_types' => array('user'));
}
$return['source_attach']['absolute'] = array('#type' => 'radios', '#title' => t('File attach location'), '#options' => array(FILEFIELD_SOURCE_ATTACH_RELATIVE => t('Within the files directory'), FILEFIELD_SOURCE_ATTACH_ABSOLUTE => t('Absolute server path')), '#default_value' => $settings['source_attach']['absolute'], '#description' => t('The <em>File attach path</em> may be with the files directory (%file_directory) or from the root of your server. If an absolute path is used and it does not start with a "/" your path will be relative to your site directory: %realpath.', array('%file_directory' => drupal_realpath(file_default_scheme() . '://'), '%realpath' => realpath('./'))));
$return['source_attach']['attach_mode'] = array('#type' => 'radios', '#title' => t('Attach method'), '#options' => array(FILEFIELD_SOURCE_ATTACH_MODE_MOVE => t('Move the file directly to the final location'), FILEFIELD_SOURCE_ATTACH_MODE_COPY => t('Leave a copy of the file in the attach directory')), '#default_value' => isset($settings['source_attach']['attach_mode']) ? $settings['source_attach']['attach_mode'] : 'move');
return $return;
}
开发者ID:shrimala,项目名称:filefield_sources,代码行数:15,代码来源:Attach.php
示例20: testFolderSetup
function testFolderSetup()
{
$directory = file_default_scheme() . '://styles';
$this->assertTrue(file_prepare_directory($directory, FALSE), 'Directory created.');
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:5,代码来源:FolderTest.php
注:本文中的file_default_scheme函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论