本文整理汇总了PHP中file_uri_target函数的典型用法代码示例。如果您正苦于以下问题:PHP file_uri_target函数的具体用法?PHP file_uri_target怎么用?PHP file_uri_target使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_uri_target函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testExport
/**
* Tests export of configuration.
*/
function testExport()
{
// Verify the export page with export submit button is available.
$this->drupalGet('admin/config/development/configuration/full/export');
$this->assertFieldById('edit-submit', t('Export'));
// Submit the export form and verify response.
$this->drupalPostForm('admin/config/development/configuration/full/export', array(), t('Export'));
$this->assertResponse(200, 'User can access the download callback.');
// Get the archived binary file provided to user for download.
$archive_data = $this->drupalGetContent();
// Temporarily save the archive file.
$uri = file_unmanaged_save_data($archive_data, 'temporary://config.tar.gz');
// Extract the archive and verify it's not empty.
$file_path = file_directory_temp() . '/' . file_uri_target($uri);
$archiver = new Tar($file_path);
$archive_contents = $archiver->listContents();
$this->assert(!empty($archive_contents), 'Downloaded archive file is not empty.');
// Prepare the list of config files from active storage, see
// \Drupal\config\Controller\ConfigController::downloadExport().
$storage_active = $this->container->get('config.storage');
$config_files = array();
foreach ($storage_active->listAll() as $config_name) {
$config_files[] = $config_name . '.yml';
}
// Assert that the downloaded archive file contents are the same as the test
// site active store.
$this->assertIdentical($archive_contents, $config_files);
// Ensure the test configuration override is in effect but was not exported.
$this->assertIdentical(\Drupal::config('system.maintenance')->get('message'), 'Foo');
$archiver->extract(file_directory_temp(), array('system.maintenance.yml'));
$file_contents = file_get_contents(file_directory_temp() . '/' . 'system.maintenance.yml');
$exported = Yaml::decode($file_contents);
$this->assertNotIdentical($exported['message'], 'Foo');
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:37,代码来源:ConfigExportUITest.php
示例2: hook_file_url_alter
/**
* Alter the URL to a file.
*
* This hook is called from file_create_url(), and is called fairly
* frequently (10+ times per page), depending on how many files there are in a
* given page.
* If CSS and JS aggregation are disabled, this can become very frequently
* (50+ times per page) so performance is critical.
*
* This function should alter the URI, if it wants to rewrite the file URL.
*
* @param $uri
* The URI to a file for which we need an external URL, or the path to a
* shipped file.
*/
function hook_file_url_alter(&$uri)
{
$user = \Drupal::currentUser();
// User 1 will always see the local file in this example.
if ($user->id() == 1) {
return;
}
$cdn1 = 'http://cdn1.example.com';
$cdn2 = 'http://cdn2.example.com';
$cdn_extensions = array('css', 'js', 'gif', 'jpg', 'jpeg', 'png');
// Most CDNs don't support private file transfers without a lot of hassle,
// so don't support this in the common case.
$schemes = array('public');
$scheme = file_uri_scheme($uri);
// Only serve shipped files and public created files from the CDN.
if (!$scheme || in_array($scheme, $schemes)) {
// Shipped files.
if (!$scheme) {
$path = $uri;
} else {
$wrapper = \Drupal::service('stream_wrapper_manager')->getViaScheme($scheme);
$path = $wrapper->getDirectoryPath() . '/' . file_uri_target($uri);
}
// Clean up Windows paths.
$path = str_replace('\\', '/', $path);
// Serve files with one of the CDN extensions from CDN 1, all others from
// CDN 2.
$pathinfo = pathinfo($path);
if (isset($pathinfo['extension']) && in_array($pathinfo['extension'], $cdn_extensions)) {
$uri = $cdn1 . '/' . $path;
} else {
$uri = $cdn2 . '/' . $path;
}
}
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:50,代码来源:file.api.php
示例3: 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', 'default') . '/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');
// Default path for image.
$hero_path = theme_get_setting('hero_path');
if (file_uri_scheme($hero_path) == 'public') {
$hero_path = file_uri_target($hero_path);
}
// Helpful text showing the file name, non-editable.
$form['hero']['hero_path'] = array('#type' => 'textfield', '#title' => 'Path to front page background image', '#default_value' => $hero_path, '#disabled' => TRUE);
// Upload field.
$form['hero']['hero_upload'] = array('#type' => 'file', '#title' => 'Upload a new photo for the hero unit', '#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>'), '#upload_validators' => array('file_validate_extensions' => array('png jpg jpeg')));
// Attach custom submit handler to the form.
$form['#submit'][] = 'nuboot_radix_settings_submit';
// Return the additional form widgets.
return $form;
}
开发者ID:TwoSixtyNine,项目名称:dkan-drops-7,代码行数:31,代码来源:theme-settings.php
示例4: open_framework_form_system_theme_settings_alter
function open_framework_form_system_theme_settings_alter(&$form, &$form_state)
{
// Responsive Behavior
$form['responsive_container'] = array('#type' => 'fieldset', '#title' => t('Responsive'), '#description' => t('Use these settings to adjust the responsive behavior.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
$form['responsive_container']['content_order_classes'] = array('#type' => 'radios', '#title' => t('Content order in mobile'), '#default_value' => theme_get_setting('content_order_classes'), '#options' => array('' => t('Show first sidebar content before main content - <strong><em>Default</em></strong>'), 'content-first ' => t('Show main content before sidebar content')));
// Page Layout
$form['layout_container'] = array('#type' => 'fieldset', '#title' => t('Layout'), '#description' => t('Use these settings to adjust the page layout.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
$form['layout_container']['front_heading_classes'] = array('#type' => 'radios', '#title' => t('Page heading'), '#default_value' => theme_get_setting('front_heading_classes'), '#options' => array('' => t('Hide heading on front page - <strong><em>Default</em></strong>'), 'show-title ' => t('Show heading on front page')));
$form['layout_container']['breadcrumb_classes'] = array('#type' => 'radios', '#title' => t('Breadcrumbs'), '#default_value' => theme_get_setting('breadcrumb_classes'), '#options' => array('' => t('Hide breadcrumbs - <strong><em>Default</em></strong>'), 'show-breadcrumb ' => t('Show breadcrumbs')));
// Background Section
$form['background_container'] = array('#type' => 'fieldset', '#title' => t('Background Images'), '#description' => t('Use these settings to select different background images.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
// Body Background Image
$form['background_container']['body_bg_type'] = array('#type' => 'radios', '#title' => t('Body background image type'), '#default_value' => theme_get_setting('body_bg_type'), '#options' => array('' => t('Wallpaper pattern - <strong><em>Default</em></strong>'), 'photobg ' => t('Photo image')));
$form['background_container']['body_bg_classes'] = array('#type' => 'radios', '#title' => t('Body background image'), '#default_value' => theme_get_setting('body_bg_classes'), '#options' => array('' => t('None - <strong><em>Default</em></strong>'), 'bodybg ' => t('Use my image (upload below):')));
// Default path for image
$body_bg_path = theme_get_setting('body_bg_path');
if (file_uri_scheme($body_bg_path) == 'public') {
$body_bg_path = file_uri_target($body_bg_path);
}
// Helpful text showing the file name, disabled to avoid the user thinking it can be used for any purpose.
$form['background_container']['body_bg_path'] = array('#type' => 'hidden', '#title' => 'Path to background image', '#default_value' => $body_bg_path);
if (!empty($body_bg_path)) {
$form['background_container']['body_bg_preview'] = array('#markup' => !empty($body_bg_path) ? theme('image', array('path' => theme_get_setting('body_bg_path'))) : '');
}
// Upload field
$form['background_container']['body_bg_upload'] = array('#type' => 'file', '#title' => 'Upload background image', '#description' => 'You can upload the following image file types: *.jpg, *.gif, or *.png');
// Border Style
$form['border_container'] = array('#type' => 'fieldset', '#title' => t('Borders'), '#description' => t('Use these settings to change the border style.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
$form['border_container']['border_classes'] = array('#type' => 'radios', '#title' => t('Border style for content section'), '#default_value' => theme_get_setting('border_classes'), '#options' => array('' => t('No borders - <strong><em>Default</em></strong>'), 'borders' => t('Show borders')));
$form['border_container']['corner_classes'] = array('#type' => 'radios', '#title' => t('Corner style'), '#default_value' => theme_get_setting('corner_classes'), '#options' => array('' => t('Straight corners - <strong><em>Default</em></strong>'), 'roundedcorners' => t('Rounded corners (not supported in Internet Explorer 8 or below)')));
// Attach custom submit handler to the form
$form['#submit'][] = 'open_framework_settings_submit';
$form['#validate'][] = 'open_framework_settings_validate';
}
开发者ID:Arabidopsis-Information-Portal,项目名称:araport-portal,代码行数:34,代码来源:theme-settings.php
示例5: testUriFunctions
/**
* Test the getViaUri() and getViaScheme() methods and target functions.
*/
function testUriFunctions()
{
$config = $this->config('system.file');
$instance = \Drupal::service('stream_wrapper_manager')->getViaUri($this->scheme . '://foo');
$this->assertEqual($this->classname, get_class($instance), 'Got correct class type for dummy URI.');
$instance = \Drupal::service('stream_wrapper_manager')->getViaUri('public://foo');
$this->assertEqual('Drupal\\Core\\StreamWrapper\\PublicStream', get_class($instance), 'Got correct class type for public URI.');
// Test file_uri_target().
$this->assertEqual(file_uri_target('public://foo/bar.txt'), 'foo/bar.txt', 'Got a valid stream target from public://foo/bar.txt.');
$this->assertEqual(file_uri_target('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='), 'image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', t('Got a valid stream target from a data URI.'));
$this->assertFalse(file_uri_target('foo/bar.txt'), 'foo/bar.txt is not a valid stream.');
$this->assertFalse(file_uri_target('public://'), 'public:// has no target.');
$this->assertFalse(file_uri_target('data:'), 'data: has no target.');
// Test file_build_uri() and
// Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath().
$this->assertEqual(file_build_uri('foo/bar.txt'), 'public://foo/bar.txt', 'Expected scheme was added.');
$this->assertEqual(\Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath(), PublicStream::basePath(), 'Expected default directory path was returned.');
$this->assertEqual(\Drupal::service('stream_wrapper_manager')->getViaScheme('temporary')->getDirectoryPath(), $config->get('path.temporary'), 'Expected temporary directory path was returned.');
$config->set('default_scheme', 'private')->save();
$this->assertEqual(file_build_uri('foo/bar.txt'), 'private://foo/bar.txt', 'Got a valid URI from foo/bar.txt.');
// Test file_create_url()
// TemporaryStream::getExternalUrl() uses Url::fromRoute(), which needs
// route information to work.
$this->container->get('router.builder')->rebuild();
$this->assertTrue(strpos(file_create_url('temporary://test.txt'), 'system/temporary?file=test.txt'), 'Temporary external URL correctly built.');
$this->assertTrue(strpos(file_create_url('public://test.txt'), Settings::get('file_public_path') . '/test.txt'), 'Public external URL correctly built.');
$this->assertTrue(strpos(file_create_url('private://test.txt'), 'system/files/test.txt'), 'Private external URL correctly built.');
}
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:31,代码来源:StreamWrapperTest.php
示例6: testThemeSettings
/**
* Test the theme settings form.
*/
function testThemeSettings()
{
// Ensure invalid theme settings form URLs return a proper 404.
$this->drupalGet('admin/appearance/settings/bartik');
$this->assertResponse(404, 'The theme settings form URL for a uninstalled theme could not be found.');
$this->drupalGet('admin/appearance/settings/' . $this->randomMachineName());
$this->assertResponse(404, 'The theme settings form URL for a non-existent theme could not be found.');
// Specify a filesystem path to be used for the logo.
$file = current($this->drupalGetTestFiles('image'));
$file_relative = strtr($file->uri, array('public:/' => PublicStream::basePath()));
$default_theme_path = 'core/themes/classy';
$supported_paths = array($file->uri => array('form' => file_uri_target($file->uri), 'src' => file_create_url($file->uri)), file_uri_target($file->uri) => array('form' => file_uri_target($file->uri), 'src' => file_create_url($file->uri)), $file_relative => array('form' => $file_relative, 'src' => file_create_url($file->uri)), 'core/misc/druplicon.png' => array('form' => 'core/misc/druplicon.png', 'src' => $GLOBALS['base_url'] . '/' . 'core/misc/druplicon.png'), $default_theme_path . '/logo.svg' => array('form' => $default_theme_path . '/logo.svg', 'src' => $GLOBALS['base_url'] . '/' . $default_theme_path . '/logo.svg'));
foreach ($supported_paths as $input => $expected) {
$edit = array('default_logo' => FALSE, 'logo_path' => $input);
$this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration'));
$this->assertNoText('The custom logo path is invalid.');
$this->assertFieldByName('logo_path', $expected['form']);
// Verify logo path examples.
$elements = $this->xpath('//div[contains(@class, :item)]/div[@class=:description]/code', array(':item' => 'form-item-logo-path', ':description' => 'description'));
// Expected default values (if all else fails).
$implicit_public_file = 'logo.svg';
$explicit_file = 'public://logo.svg';
$local_file = $default_theme_path . '/logo.svg';
// Adjust for fully qualified stream wrapper URI in public filesystem.
if (file_uri_scheme($input) == 'public') {
$implicit_public_file = file_uri_target($input);
$explicit_file = $input;
$local_file = strtr($input, array('public:/' => PublicStream::basePath()));
} elseif (file_uri_scheme($input) !== FALSE) {
$explicit_file = $input;
} elseif ($input == file_uri_target($file->uri)) {
$implicit_public_file = $input;
$explicit_file = 'public://' . $input;
$local_file = PublicStream::basePath() . '/' . $input;
}
$this->assertEqual((string) $elements[0], $implicit_public_file);
$this->assertEqual((string) $elements[1], $explicit_file);
$this->assertEqual((string) $elements[2], $local_file);
// Verify the actual 'src' attribute of the logo being output.
$this->drupalGet('');
$elements = $this->xpath('//header/a[@rel=:rel]/img', array(':rel' => 'home'));
$this->assertEqual((string) $elements[0]['src'], $expected['src']);
}
$unsupported_paths = array('public://whatever.png', 'private://whatever.png', 'temporary://whatever.png', 'public:/whatever.png', '://whatever.png', ':whatever.png', 'public://', 'whatever.png', PublicStream::basePath() . '/whatever.png', '/' . PublicStream::basePath() . '/whatever.png', 'core/misc/whatever.png', '/core/misc/whatever.png', drupal_realpath($file->uri));
$this->drupalGet('admin/appearance/settings');
foreach ($unsupported_paths as $path) {
$edit = array('default_logo' => FALSE, 'logo_path' => $path);
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->assertText('The custom logo path is invalid.');
}
// Upload a file to use for the logo.
$edit = array('default_logo' => FALSE, 'logo_path' => '', 'files[logo_upload]' => drupal_realpath($file->uri));
$this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration'));
$fields = $this->xpath($this->constructFieldXpath('name', 'logo_path'));
$uploaded_filename = 'public://' . $fields[0]['value'];
$this->drupalGet('');
$elements = $this->xpath('//header/a[@rel=:rel]/img', array(':rel' => 'home'));
$this->assertEqual($elements[0]['src'], file_create_url($uploaded_filename));
}
开发者ID:nstielau,项目名称:drops-8,代码行数:62,代码来源:ThemeTest.php
示例7: testExport
/**
* Tests export of configuration.
*/
function testExport()
{
// Verify the export page with export submit button is available.
$this->drupalGet('admin/config/development/configuration/full/export');
$this->assertFieldById('edit-submit', t('Export'));
// Submit the export form and verify response.
$this->drupalPostForm('admin/config/development/configuration/full/export', array(), t('Export'));
$this->assertResponse(200, 'User can access the download callback.');
// Test if header contains file name with hostname and timestamp.
$request = \Drupal::request();
$hostname = str_replace('.', '-', $request->getHttpHost());
$header_content_disposition = $this->drupalGetHeader('content-disposition');
$header_match = (bool) preg_match('/attachment; filename="config-' . preg_quote($hostname) . '-\\d{4}-\\d{2}-\\d{2}-\\d{2}-\\d{2}\\.tar\\.gz"/', $header_content_disposition);
$this->assertTrue($header_match, "Header with filename matches the expected format.");
// Get the archived binary file provided to user for download.
$archive_data = $this->getRawContent();
// Temporarily save the archive file.
$uri = file_unmanaged_save_data($archive_data, 'temporary://config.tar.gz');
// Extract the archive and verify it's not empty.
$file_path = file_directory_temp() . '/' . file_uri_target($uri);
$archiver = new Tar($file_path);
$archive_contents = $archiver->listContents();
$this->assert(!empty($archive_contents), 'Downloaded archive file is not empty.');
// Prepare the list of config files from active storage, see
// \Drupal\config\Controller\ConfigController::downloadExport().
$storage_active = $this->container->get('config.storage');
$config_files = array();
foreach ($storage_active->listAll() as $config_name) {
$config_files[] = $config_name . '.yml';
}
// Assert that the downloaded archive file contents are the same as the test
// site active store.
$this->assertIdentical($archive_contents, $config_files);
// Ensure the test configuration override is in effect but was not exported.
$this->assertIdentical(\Drupal::config('system.maintenance')->get('message'), 'Foo');
$archiver->extract(file_directory_temp(), array('system.maintenance.yml'));
$file_contents = file_get_contents(file_directory_temp() . '/' . 'system.maintenance.yml');
$exported = Yaml::decode($file_contents);
$this->assertNotIdentical($exported['message'], 'Foo');
// Check the single export form doesn't have "form-required" elements.
$this->drupalGet('admin/config/development/configuration/single/export');
$this->assertNoRaw('js-form-required form-required', 'No form required fields are found.');
// Ensure the temporary file is not available to users without the
// permission.
$this->drupalLogout();
$this->drupalGet('system/temporary', ['query' => ['file' => 'config.tar.gz']]);
$this->assertResponse(403);
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:51,代码来源:ConfigExportUITest.php
示例8: academy_form_system_theme_settings_alter
function academy_form_system_theme_settings_alter(&$form, &$form_state)
{
// Container fieldset
$form['bg_image'] = array('#type' => 'fieldset', '#title' => t('Background image (must be tileable PNG)'));
// Default path for image
$bg_path = theme_get_setting('bg_path');
if (file_uri_scheme($bg_path) == 'public') {
$bg_path = file_uri_target($bg_path);
}
// Helpful text showing the file name, disabled to avoid the user thinking it can be used for any purpose.
$form['bg_image']['bg_path'] = array('#type' => 'textfield', '#title' => 'Path to background image', '#default_value' => $bg_path, '#disabled' => TRUE);
// Upload field
$form['bg_image']['bg_upload'] = array('#type' => 'file', '#title' => 'Upload background image', '#description' => 'Upload a new image for the background.');
// Attach custom submit handler to the form
$form['#submit'][] = 'academy_settings_submit';
}
开发者ID:EWB,项目名称:grh,代码行数:16,代码来源:theme-settings.php
示例9: nuboot_form_system_theme_settings_alter
/**
* Implements hook_form_system_theme_settings_alter().
*/
function nuboot_form_system_theme_settings_alter(&$form, &$form_state)
{
// Hero fieldset.
$form['hero'] = array('#type' => 'fieldset', '#title' => t('Hero Unit'), '#group' => 'general');
// Default path for image.
$hero_path = theme_get_setting('hero_path');
if (file_uri_scheme($hero_path) == 'public') {
$hero_path = file_uri_target($hero_path);
}
// Helpful text showing the file name, non-editable.
$form['hero']['hero_path'] = array('#type' => 'textfield', '#title' => 'Path to front page hero unit background image', '#default_value' => $hero_path, '#disabled' => TRUE);
// Upload field.
$form['hero']['hero_upload'] = array('#type' => 'file', '#title' => 'Upload a photo for the hero unit background image', '#description' => 'Upload a new image for the hero region background.', '#upload_validators' => array('file_validate_extensions' => array('png jpg jpeg')));
// Attach custom submit handler to the form.
$form['#submit'][] = 'nuboot_settings_submit';
}
开发者ID:rhabbachi,项目名称:data_starter,代码行数:19,代码来源:theme-settings.php
示例10: agency_1_form_system_theme_settings_alter
function agency_1_form_system_theme_settings_alter(&$form, &$form_state)
{
//Add the css to fix the color module's goofy form
drupal_add_css(drupal_get_path('theme', 'agency_1') . '/css/colors-admin.css');
//Fix color module rendering of new colors added to .inc file
agency_1_theme_settings_add_new_colors();
/*
* Sliver show/hide
*/
$show_sliver = isset($theme_settings['show_sliver']) ? $theme_settings['show_sliver'] : NULL;
//Add the checkbox to the form
$form['sliver'] = array('#type' => 'fieldset', '#title' => t('Sliver banner settings'), '#description' => t('If toggled on, the sliver banner will be displayed.'), '#attributes' => array('class' => array('theme-settings-bottom')));
$form['sliver']['show_sliver'] = array('#type' => 'checkbox', '#title' => t('Display the sliver banner'), '#default_value' => theme_get_setting('show_sliver'), '#tree' => FALSE, '#description' => t('Check here if you want the theme to display the sliver banner.'));
/*
* Background Image
*/
$background_path = isset($theme_settings['background_path']) ? $theme_settings['background_path'] : NULL;
// If $background_path is a public:// URI, display the path relative to the files directory. (Stream wrappers are not end-user friendly)
if (file_uri_scheme($background_path) == 'public') {
$background_path = file_uri_target($background_path);
}
//Add the background image fields to the form
$form['background_image'] = array('#type' => 'fieldset', '#title' => t('Background image settings'), '#description' => t('If toggled on, the following background will be displayed.'), '#attributes' => array('class' => array('theme-settings-bottom')));
$form['background_image']['default_background'] = array('#type' => 'checkbox', '#title' => t('Use the default background'), '#default_value' => theme_get_setting('default_background'), '#tree' => FALSE, '#description' => t('Check here if you want the theme to use the background supplied with it.'));
$form['background_image']['settings'] = array('#type' => 'container', '#states' => array('invisible' => array('input[name="default_background"]' => array('checked' => TRUE))));
$form['background_image']['settings']['background_path'] = array('#type' => 'textfield', '#title' => t('Path to custom background'), '#description' => t('The path to the file you would like to use as your background file instead of the default background.'), '#default_value' => theme_get_setting('background_path'));
$form['background_image']['settings']['background_file'] = array('#type' => 'file', '#title' => t('Upload background image'), '#maxlength' => 40, '#description' => t("If you don't have direct file access to the server, use this field to upload your background image."), '#element_validate' => array('_agency_1_theme_settings_validate'));
//Toggle display of the branding block in the footer
$form['footer_branding'] = array('#type' => 'fieldset', '#title' => t('Footer Branding settings'), '#description' => t('If toggled on, the branding block will be displayed.'), '#attributes' => array('class' => array('theme-settings-bottom')));
$form['footer_branding']['display_footer_branding'] = array('#type' => 'checkbox', '#title' => t('Display the branding block in the footer'), '#default_value' => theme_get_setting('display_footer_branding'), '#tree' => FALSE, '#description' => t('Check here if you want to display the branding block in the footer.'));
//Capture the information for the Contact Us section in the footer
$form['footer_contact_us'] = array('#type' => 'fieldset', '#title' => t('Footer "Contact Us" settings'), '#description' => t('If toggled on, the Contact Us block will be displayed.'), '#attributes' => array('class' => array('theme-settings-bottom')));
$form['footer_contact_us']['display_footer_contact'] = array('#type' => 'checkbox', '#title' => t('Display the Contact Us block in the footer'), '#default_value' => theme_get_setting('display_footer_contact'), '#tree' => FALSE, '#description' => t('Check here if you want to display the Contact Us block in the footer.'));
$form['footer_contact_us']['settings'] = array('#type' => 'container', '#states' => array('invisible' => array('input[name="display_footer_contact"]' => array('checked' => FALSE))));
$form['footer_contact_us']['settings']['footer_contact_us_title'] = array('#type' => 'textfield', '#title' => t('Title'), '#description' => t('Title for the Contact Us block.'), '#default_value' => theme_get_setting('footer_contact_us_title'));
$form['footer_contact_us']['settings']['footer_contact_us_title_link'] = array('#type' => 'textfield', '#title' => t('Title Link'), '#description' => t('Link for the title in the Contact Us block. (Recommend linking to the contact form.)'), '#default_value' => theme_get_setting('footer_contact_us_title_link'));
$form['footer_contact_us']['settings']['footer_contact_us_agency_title'] = array('#type' => 'textfield', '#title' => t('Agency Title'), '#description' => t('Agency title for the Contact Us block.'), '#default_value' => theme_get_setting('footer_contact_us_agency_title'));
$form['footer_contact_us']['settings']['footer_contact_us_address_1'] = array('#type' => 'textfield', '#title' => t('Address Line 1'), '#description' => t('Address line 1 for the Contact Us block.'), '#default_value' => theme_get_setting('footer_contact_us_address_1'));
$form['footer_contact_us']['settings']['footer_contact_us_address_2'] = array('#type' => 'textfield', '#title' => t('Address Line 2'), '#description' => t('Address line 2 for the Contact Us block.'), '#default_value' => theme_get_setting('footer_contact_us_address_2'));
$form['footer_contact_us']['settings']['footer_contact_us_phone'] = array('#type' => 'textfield', '#title' => t('Phone Number'), '#description' => t('Phone number for the Contact Us block.'), '#default_value' => theme_get_setting('footer_contact_us_phone'));
$form['footer_contact_us']['settings']['footer_contact_us_fax'] = array('#type' => 'textfield', '#title' => t('Fax Number'), '#description' => t('Fax number for the Contact Us block.'), '#default_value' => theme_get_setting('footer_contact_us_fax'));
$form['footer_contact_us']['settings']['footer_contact_us_map_link'] = array('#type' => 'textfield', '#title' => t('Map Link'), '#description' => t('Link for the map in the Contact Us block.'), '#default_value' => theme_get_setting('footer_contact_us_map_link'));
$form['footer_contact_us']['settings']['footer_contact_us_map_path'] = array('#type' => 'textfield', '#title' => t('Path to map image'), '#description' => t('The path to the file you would like to use as your map image. (150px x 150px)'), '#default_value' => theme_get_setting('footer_contact_us_map_path'));
$form['footer_contact_us']['settings']['footer_contact_us_map_image'] = array('#type' => 'file', '#title' => t('Upload map image'), '#maxlength' => 40, '#description' => t("Use this field to upload your map image. (150px x 150px. Will be resized if necessary.)"), '#element_validate' => array('_agency_1_theme_settings_map'));
//End Contact Us
return $form;
}
开发者ID:ehazell,项目名称:AZDWR,代码行数:47,代码来源:theme-settings.php
示例11: locke_form_system_theme_settings_alter
/**
* Implementation of hook_form_system_theme_settings_alter()
*/
function locke_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', 'locke') . '/theme-settings.php';
// Add theme settings here.
$form['locke_theme_settings'] = array('#title' => t('Theme Settings'), '#type' => 'fieldset');
// Copyright.
$copyright = theme_get_setting('copyright');
$form['locke_theme_settings']['copyright'] = array('#title' => t('Copyright'), '#type' => 'text_format', '#format' => $copyright['format'], '#default_value' => $copyright['value'] ? $copyright['value'] : t('Drupal is a registered trademark of Dries Buytaert.'));
// Update the "Toogle Display" to something clearer
$form['theme_settings']['#title'] = t('Theme Display Settings');
// Change Weighting of Default Setting Fields
$form['theme_settings']['#weight'] = 20;
$form['logo']['#weight'] = 30;
$form['favicon']['#weight'] = 40;
// Define the contact information fieldset
$form['contact_information'] = array('#type' => 'fieldset', '#title' => t('Contact Information in Footer'));
// Define the phone number
$form['contact_information']['phone'] = array('#type' => 'textfield', '#title' => t('Phone Number'), '#default_value' => theme_get_setting('phone'));
// Define your fax number
$form['contact_information']['fax'] = array('#type' => 'textfield', '#title' => t('Fax Number'), '#default_value' => theme_get_setting('fax'));
// Define your address
$form['contact_information']['address'] = array('#type' => 'textarea', '#title' => t('Address'), '#rows' => 3, '#default_value' => theme_get_setting('address'));
// Define the social media links
$form['social_media'] = array('#type' => 'fieldset', '#title' => t('Social Media Links in Footer'));
// Define the twitter link
$form['social_media']['twitter_link'] = array('#type' => 'textfield', '#title' => 'Twitter', '#default_value' => theme_get_setting('twitter_link'));
// Define the facebook link
$form['social_media']['facebook_link'] = array('#type' => 'textfield', '#title' => 'Facebook', '#default_value' => theme_get_setting('facebook_link'));
// Define the youtube link
$form['social_media']['youtube_link'] = array('#type' => 'textfield', '#title' => 'YouTube', '#default_value' => theme_get_setting('youtube_link'));
// Update the image settings to include seal
$form['logo']['#title'] = 'Image settings';
$default_seal = theme_get_setting('default_seal');
$form['logo']['default_seal'] = array('#type' => 'checkbox', '#title' => t('Use the default seal'), '#tree' => FALSE, '#description' => t('Check here if you want the theme to use the seal supplied with it'), '#default_value' => empty($default_seal) ? 0 : 1);
$seal_path = theme_get_setting('seal_path');
// If $seal_path is a public:// URI, display the path relative to the files
// directory; stream wrappers are not end-user friendly.
if (file_uri_scheme($seal_path) == 'public') {
$seal_path = file_uri_target($seal_path);
}
$form['logo']['seal_settings'] = array('#type' => 'container', '#states' => array('invisible' => array('input[name="default_seal"]' => array('checked' => TRUE))), 'seal_path' => array('#type' => 'textfield', '#title' => 'Path to custom seal', '#description' => 'The path to the file you would like to use as your seal file instead of the default seal.', '#default_value' => $seal_path), 'seal_upload' => array('#type' => 'file', '#title' => 'Upload logo image', '#maxlength' => 40, '#description' => 'If you don\'t have direct file access to the server, use this field to upload your seal.'));
$form['#submit'][] = 'locke_theme_settings_submit';
$form['#validate'][] = 'locke_theme_settings_validate';
}
开发者ID:TommyTran1,项目名称:excelpoint,代码行数:48,代码来源:theme-settings.php
示例12: testUriFunctions
/**
* Test the URI and target functions.
*/
function testUriFunctions()
{
$config = \Drupal::config('system.file');
$instance = file_stream_wrapper_get_instance_by_uri($this->scheme . '://foo');
$this->assertEqual($this->classname, get_class($instance), 'Got correct class type for dummy URI.');
$instance = file_stream_wrapper_get_instance_by_uri('public://foo');
$this->assertEqual('Drupal\\Core\\StreamWrapper\\PublicStream', get_class($instance), 'Got correct class type for public URI.');
// Test file_uri_target().
$this->assertEqual(file_uri_target('public://foo/bar.txt'), 'foo/bar.txt', 'Got a valid stream target from public://foo/bar.txt.');
$this->assertFalse(file_uri_target('foo/bar.txt'), 'foo/bar.txt is not a valid stream.');
// Test file_build_uri() and
// Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath().
$this->assertEqual(file_build_uri('foo/bar.txt'), 'public://foo/bar.txt', 'Expected scheme was added.');
$this->assertEqual(file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(), PublicStream::basePath(), 'Expected default directory path was returned.');
$this->assertEqual(file_stream_wrapper_get_instance_by_scheme('temporary')->getDirectoryPath(), $config->get('path.temporary'), 'Expected temporary directory path was returned.');
$config->set('default_scheme', 'private')->save();
$this->assertEqual(file_build_uri('foo/bar.txt'), 'private://foo/bar.txt', 'Got a valid URI from foo/bar.txt.');
}
开发者ID:anatalsceo,项目名称:en-classe,代码行数:21,代码来源:StreamWrapperTest.php
示例13: testUriFunctions
/**
* Test the URI and target functions.
*/
function testUriFunctions()
{
$config = \Drupal::config('system.file');
$instance = file_stream_wrapper_get_instance_by_uri($this->scheme . '://foo');
$this->assertEqual($this->classname, get_class($instance), 'Got correct class type for dummy URI.');
$instance = file_stream_wrapper_get_instance_by_uri('public://foo');
$this->assertEqual('Drupal\\Core\\StreamWrapper\\PublicStream', get_class($instance), 'Got correct class type for public URI.');
// Test file_uri_target().
$this->assertEqual(file_uri_target('public://foo/bar.txt'), 'foo/bar.txt', 'Got a valid stream target from public://foo/bar.txt.');
$this->assertEqual(file_uri_target('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='), 'image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', t('Got a valid stream target from a data URI.'));
$this->assertFalse(file_uri_target('foo/bar.txt'), 'foo/bar.txt is not a valid stream.');
$this->assertFalse(file_uri_target('public://'), 'public:// has no target.');
$this->assertFalse(file_uri_target('data:'), 'data: has no target.');
// Test file_build_uri() and
// Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath().
$this->assertEqual(file_build_uri('foo/bar.txt'), 'public://foo/bar.txt', 'Expected scheme was added.');
$this->assertEqual(file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(), PublicStream::basePath(), 'Expected default directory path was returned.');
$this->assertEqual(file_stream_wrapper_get_instance_by_scheme('temporary')->getDirectoryPath(), $config->get('path.temporary'), 'Expected temporary directory path was returned.');
$config->set('default_scheme', 'private')->save();
$this->assertEqual(file_build_uri('foo/bar.txt'), 'private://foo/bar.txt', 'Got a valid URI from foo/bar.txt.');
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:24,代码来源:StreamWrapperTest.php
示例14: testPictureOnNodeComment
/**
* Tests embedded users on node pages.
*/
function testPictureOnNodeComment()
{
$this->drupalLogin($this->web_user);
// Save a new picture.
$image = current($this->drupalGetTestFiles('image'));
$file = $this->saveUserPicture($image);
$node = $this->drupalCreateNode(array('type' => 'article'));
// Enable user pictures on nodes.
$this->container->get('config.factory')->get('system.theme.global')->set('features.node_user_picture', TRUE)->save();
// Verify that the image is displayed on the user account page.
$this->drupalGet('node/' . $node->id());
$this->assertRaw(file_uri_target($file->getFileUri()), 'User picture found on node page.');
// Enable user pictures on comments, instead of nodes.
$this->container->get('config.factory')->get('system.theme.global')->set('features.node_user_picture', FALSE)->set('features.comment_user_picture', TRUE)->save();
$edit = array('comment_body[0][value]' => $this->randomString());
$this->drupalPostForm('comment/reply/node/' . $node->id() . '/comment', $edit, t('Save'));
$this->assertRaw(file_uri_target($file->getFileUri()), 'User picture found on comment.');
// Disable user pictures on comments and nodes.
$this->container->get('config.factory')->get('system.theme.global')->set('features.node_user_picture', FALSE)->set('features.comment_user_picture', FALSE)->save();
\Drupal::entityManager()->getViewBuilder('comment')->resetCache();
$this->drupalGet('node/' . $node->id());
$this->assertNoRaw(file_uri_target($file->getFileUri()), 'User picture not found on node and comment.');
}
开发者ID:anatalsceo,项目名称:en-classe,代码行数:26,代码来源:UserPictureTest.php
示例15: hosting_form_system_theme_settings_alter
function hosting_form_system_theme_settings_alter(&$form, &$form_state)
{
$contact_icon = theme_get_setting('contact_icon');
if (file_uri_scheme($contact_icon) == 'public') {
$contact_icon = file_uri_target($contact_icon);
}
drupal_add_css(drupal_get_path('theme', 'hosting') . '/css/theme-settings.css');
// Contact
$form['contact'] = array('#type' => 'fieldset', '#title' => 'Contact Setting', '#group' => 'drupaloss_settings', '#weight' => 100);
// Contact MAP
/*
$form['contact']['contactmap'] = array(
'#type' => 'fieldset',
'#title' => '<div class="plus"></div><h3 class="options_heading">Contact Map</h3>',
);
*/
// Contact MAP Address
$contact_address = theme_get_setting('contact_address');
$form['contact']['contact_address'] = array('#type' => 'text_format', '#title' => t('Company Address'), '#default_value' => isset($contact_address['value']) ? $contact_address['value'] : '', '#format' => isset($contact_address['format']) ? $contact_address['format'] : 'filtered_html');
// Contact MAP Phone
$form['contact']['contact_phone'] = array('#type' => 'textfield', '#title' => t('Company Telephone'), '#default_value' => theme_get_setting('contact_phone'));
// Company Name
$form['contact']['contact_mail'] = array('#type' => 'textfield', '#title' => t('Company Email'), '#default_value' => theme_get_setting('contact_mail'));
// Website
$form['contact']['contact_website'] = array('#type' => 'textfield', '#title' => 'Website', '#default_value' => theme_get_setting('contact_website'));
// Contact MAP Lat
$form['contact']['contactmap_lat'] = array('#type' => 'textfield', '#title' => 'Lat', '#description' => t('Lat google map'), '#default_value' => theme_get_setting('contactmap_lat'));
// Contact MAP Long
$form['contact']['contactmap_long'] = array('#type' => 'textfield', '#title' => 'Long', '#description'
|
请发表评论