本文整理汇总了PHP中file_uri_scheme函数的典型用法代码示例。如果您正苦于以下问题:PHP file_uri_scheme函数的具体用法?PHP file_uri_scheme怎么用?PHP file_uri_scheme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_uri_scheme函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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';
}
示例2: 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;
}
示例3: 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;
}
}
}
示例4: 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));
}
示例5: createGroup
/**
* Overrides LinkitSearchPluginEntity::createGroup().
*/
function createGroup($entity)
{
// The the standard group name.
$group = parent::createGroup($entity);
// Add the scheme.
if ($this->conf['group_by_scheme']) {
// Get all stream wrappers.
$stream_wrapper = file_get_stream_wrappers();
$group .= ' - ' . $stream_wrapper[file_uri_scheme($entity->uri)]['name'];
}
return $group;
}
示例6: viewElements
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode)
{
$element = [];
$settings = $this->getSettings();
foreach ($items as $delta => $item) {
$file = File::load($item->target_id);
$metadata = isset($item->data) ? unserialize($item->data) : array();
$scheme = file_uri_scheme($file->getFileUri());
$provider = $this->providerManager->loadProviderFromStream($scheme, $file, $metadata);
$element[$delta] = $provider->renderEmbedCode($settings);
}
return $element;
}
示例7: 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);
}
示例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';
}
示例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';
}
示例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;
}
示例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';
}
示例12: testExistingReplace
/**
* Test file_save_data() when replacing an existing file.
*/
function testExistingReplace()
{
// Setup a file to overwrite.
$existing = $this->createFile();
$contents = $this->randomMachineName(8);
$result = file_save_data($contents, $existing->getFileUri(), FILE_EXISTS_REPLACE);
$this->assertTrue($result, 'File saved successfully.');
$this->assertEqual('public', file_uri_scheme($result->getFileUri()), "File was placed in Drupal's files directory.");
$this->assertEqual($result->getFilename(), $existing->getFilename(), 'Filename was set to the basename of the existing file, rather than preserving the original name.');
$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('load', 'update'));
// Verify that the existing file was re-used.
$this->assertSameFile($existing, $result);
// Verify that what was returned is what's in the database.
$this->assertFileUnchanged($result, File::load($result->id()));
}
示例13: save
/**
* {@inheritdoc}
*/
public function save($destination)
{
$scheme = file_uri_scheme($destination);
// Work around lack of stream wrapper support in imagejpeg() and imagepng().
if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
// If destination is not local, save image to temporary local file.
$local_wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_LOCAL);
if (!isset($local_wrappers[$scheme])) {
$permanent_destination = $destination;
$destination = drupal_tempnam('temporary://', 'gd_');
}
// Convert stream wrapper URI to normal path.
$destination = drupal_realpath($destination);
}
switch ($this->getType()) {
case GDToolkitWebP::IMAGETYPE_WEBP:
$function = 'imagewebp';
break;
default:
$function = 'image' . image_type_to_extension($this->getType(), FALSE);
break;
}
if (!function_exists($function)) {
return FALSE;
}
if ($this->getType() == IMAGETYPE_JPEG) {
$success = $function($this->getResource(), $destination, $this->configFactory->get('system.image.gd')->get('jpeg_quality'));
} else {
// Always save PNG images with full transparency.
if ($this->getType() == IMAGETYPE_PNG) {
imagealphablending($this->getResource(), FALSE);
imagesavealpha($this->getResource(), TRUE);
}
$success = $function($this->getResource(), $destination);
}
// Move temporary local file to remote destination.
if (isset($permanent_destination) && $success) {
return (bool) file_unmanaged_move($destination, $permanent_destination, FILE_EXISTS_REPLACE);
}
return $success;
}
示例14: SFT_preprocess_html
function SFT_preprocess_html(&$vars)
{
// theme option variables
$vars['content_order_classes'] = !empty($vars['content_order_classes']) ? $vars['content_order_classes'] : theme_get_setting('content_order_classes');
$vars['front_heading_classes'] = !empty($vars['front_heading_classes']) ? $vars['front_heading_classes'] : theme_get_setting('front_heading_classes');
$vars['breadcrumb_classes'] = !empty($vars['breadcrumb_classes']) ? $vars['breadcrumb_classes'] : theme_get_setting('breadcrumb_classes');
$vars['border_classes'] = !empty($vars['border_classes']) ? $vars['border_classes'] : theme_get_setting('border_classes');
$vars['corner_classes'] = !empty($vars['corner_classes']) ? $vars['corner_classes'] : theme_get_setting('corner_classes');
$vars['body_bg_type'] = !empty($vars['body_bg_type']) ? $vars['body_bg_type'] : theme_get_setting('body_bg_type');
$vars['body_bg_classes'] = !empty($vars['body_bg_classes']) ? $vars['body_bg_classes'] : theme_get_setting('body_bg_classes');
$vars['body_bg_path'] = !empty($vars['body_bg_path']) ? $vars['body_bg_path'] : theme_get_setting('body_bg_path');
$vars['font_awesome_version'] = !empty($vars['font_awesome_version']) ? $vars['font_awesome_version'] : theme_get_setting('font_awesome_version');
// Variables
$content_order_classes = $vars['content_order_classes'];
$front_heading_classes = $vars['front_heading_classes'];
$breadcrumb_classes = $vars['breadcrumb_classes'];
$border_classes = $vars['border_classes'];
$corner_classes = $vars['corner_classes'];
$body_bg_type = $vars['body_bg_type'];
$body_bg_classes = $vars['body_bg_classes'];
$body_bg_path = $vars['body_bg_path'];
// Default path for body background image
if (file_uri_scheme($body_bg_path) == 'public') {
$body_bg_path = file_create_url($body_bg_path);
}
// If body background image is enabled, add following style to body
if (!empty($body_bg_classes)) {
drupal_add_css('body {background: url(' . $body_bg_path . ') repeat top left;}', array('group' => CSS_THEME, 'type' => 'inline', 'media' => 'screen', 'preprocess' => FALSE, 'weight' => '9999'));
}
// Add body class based on style selected
$vars['classes_array'][] = $vars['body_bg_type'];
$vars['classes_array'][] = $vars['body_bg_classes'];
$vars['classes_array'][] = $vars['content_order_classes'];
$vars['classes_array'][] = $vars['front_heading_classes'];
$vars['classes_array'][] = $vars['breadcrumb_classes'];
$vars['classes_array'][] = $vars['border_classes'];
$vars['classes_array'][] = $vars['corner_classes'];
}
示例15: viewElements
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode)
{
// load widget settings
$field_definition = $this->fieldDefinition;
$entity_form_display = entity_get_form_display($field_definition->getTargetEntityTypeId(), $field_definition->getTargetBundle(), 'default');
$widget = $entity_form_display->getRenderer($field_definition->getName());
$widget_settings = $widget->getSettings();
$element = [];
foreach ($items as $delta => $item) {
$file = File::load($item->target_id);
$metadata = isset($item->data) ? unserialize($item->data) : array();
$scheme = file_uri_scheme($file->getFileUri());
$provider = $this->providerManager->loadProviderFromStream($scheme, $file, $metadata, $widget_settings);
$url = FALSE;
if ($this->getSetting('link_image_to') == static::LINK_CONTENT) {
$url = $items->getEntity()->urlInfo();
} elseif ($this->getSetting('link_image_to') == static::LINK_PROVIDER) {
$url = Url::fromUri(file_create_url($file->getFileUri()));
}
$element[$delta] = $provider->renderThumbnail($this->getSetting('image_style'), $url);
}
return $element;
}