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


PHP drupal_get_path函数代码示例

本文整理汇总了PHP中drupal_get_path函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_get_path函数的具体用法?PHP drupal_get_path怎么用?PHP drupal_get_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: omega_kickstart_preprocess_html

/**
 * Preprocess variables for html.tpl.php
 *
 * @see system_elements()
 * @see html.tpl.php
 */
function omega_kickstart_preprocess_html(&$variables)
{
    // Add conditional stylesheets for IE
    $theme_path = drupal_get_path('theme', 'omega_kickstart');
    drupal_add_css($theme_path . '/css/ie-lte-8.css', array('group' => CSS_THEME, 'weight' => 20, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'preprocess' => FALSE));
    drupal_add_css($theme_path . '/css/ie-lte-7.css', array('group' => CSS_THEME, 'weight' => 21, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
}
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:13,代码来源:template.php

示例2: manis_form_system_theme_settings_alter

function manis_form_system_theme_settings_alter(&$form, $form_state)
{
    $theme_path = drupal_get_path('theme', 'manis');
    $form['settings'] = array('#type' => 'vertical_tabs', '#title' => t('Theme settings'), '#weight' => 2, '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['settings']['general_setting'] = array('#type' => 'fieldset', '#title' => t('General Settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['settings']['general_setting']['general_setting_tracking_code'] = array('#type' => 'textarea', '#title' => t('Tracking Code'), '#default_value' => theme_get_setting('general_setting_tracking_code', 'manis'));
    $form['settings']['header'] = array('#type' => 'fieldset', '#title' => t('Header settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['settings']['header']['header_style'] = array('#title' => t('Header style'), '#type' => 'select', '#options' => array('header1' => t('Header 1'), 'header2' => t('Header 2'), 'header3' => t('Header 3')), '#default_value' => theme_get_setting('header_style', 'manis'));
    $form['settings']['header']['phone_contact'] = array('#title' => t('Phone contact'), '#type' => 'textfield', '#default_value' => theme_get_setting('phone_contact', 'manis'));
    $form['settings']['header']['contact_email'] = array('#title' => t('Contact email'), '#type' => 'textfield', '#default_value' => theme_get_setting('contact_email', 'manis'));
    $form['settings']['header']['social_network'] = array('#title' => t('Header social network'), '#type' => 'textarea', '#default_value' => theme_get_setting('social_network', 'manis'));
    $form['settings']['blogs'] = array('#type' => 'fieldset', '#title' => t('Blogs'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['settings']['blogs']['blogs_list'] = array('#type' => 'select', '#title' => t('Blogs list style'), '#options' => array('style1' => t('Style 1'), 'style2' => t('Style 2')), '#default_value' => theme_get_setting('blogs_style', 'manis'));
    $form['settings']['footer'] = array('#type' => 'fieldset', '#title' => t('Footer settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['settings']['footer']['enable_footer_logo'] = array('#type' => 'select', '#title' => t('Enable footer logo'), '#options' => array('on' => t('ON'), 'off' => t('OFF')), '#default_value' => theme_get_setting('enable_footer_logo', 'manis'));
    $form['settings']['footer']['footer_copyright_message'] = array('#type' => 'textarea', '#title' => t('Footer copyright message'), '#default_value' => theme_get_setting('footer_copyright_message', 'manis'));
    $form['settings']['custom_css'] = array('#type' => 'fieldset', '#title' => t('Custom CSS'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['settings']['custom_css']['custom_css'] = array('#type' => 'textarea', '#title' => t('Custom CSS'), '#default_value' => theme_get_setting('custom_css', 'manis'), '#description' => t('<strong>Example:</strong><br/>h1 { font-family: \'Metrophobic\', Arial, serif; font-weight: 400; }'));
    $form['settings']['skin'] = array('#type' => 'fieldset', '#title' => t('Switcher Style'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    //Disable Switcher style;
    $form['settings']['skin']['manis_disable_switch'] = array('#title' => t('Switcher style'), '#type' => 'select', '#options' => array('on' => t('ON'), 'off' => t('OFF')), '#default_value' => theme_get_setting('manis_disable_switch', 'manis'));
    $form['settings']['skin']['manis_layout'] = array('#title' => t('Layout'), '#type' => 'select', '#options' => array('wide' => t('Wide'), 'boxed' => t('Boxed')), '#default_value' => theme_get_setting('manis_layout', 'manis'));
    $form['settings']['skin']['manis_direction'] = array('#title' => t('Direction'), '#type' => 'select', '#options' => array('ltr' => t('LTR'), 'rtl' => t('RTL')), '#default_value' => theme_get_setting('manis_direction', 'manis'));
    $form['settings']['skin']['manis_style'] = array('#title' => t('Style'), '#type' => 'select', '#options' => array('light' => t('LIGHT'), 'dark' => t('DARK')), '#default_value' => theme_get_setting('manis_style', 'manis'));
    $form['settings']['skin']['manis_skin'] = array('#title' => t('Skins'), '#type' => 'select', '#options' => array('default' => t('Default'), 'alimbalmarina' => t('Alimbalmarina'), 'juicy' => t('Juicy'), 'spoonflower_goats' => t('Spoonflower goats'), 'nutricap_keratin_vit' => t('Nutricap keratin vit'), 'courtly_attire' => t('Courtly attire'), 'mondrian' => t('Mondrian'), 'sage' => t('Sage'), 'walking_by' => t('Walking by')), '#default_value' => theme_get_setting('manis_skin', 'manis'));
    $form['settings']['skin']['background'] = array('#type' => 'fieldset', '#title' => t('Background style'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['settings']['skin']['background']['background_style'] = array('#title' => t('Use style'), '#type' => 'select', '#options' => array('pattern' => t('Pattern'), 'image' => t('Image')), '#default_value' => theme_get_setting('background_style', 'manis'));
    $form['settings']['skin']['background']['manis_bg_pattern'] = array('#title' => t('Bg pattern'), '#type' => 'select', '#options' => array('swirl_pattern' => t('Swirl pattern'), 'sativa' => t('Sativa'), 'dimension' => t('Dimension'), 'symphony' => t('Symphony'), 'black_lozenge' => t('Black lozenge'), 'congruent_outline' => t('Congruent outline'), 'dark_exa' => t('Dark exa'), 'office_pattern' => t('Office pattern')), '#default_value' => theme_get_setting('manis_bg_pattern', 'manis'));
    $form['settings']['skin']['background']['manis_bg_image'] = array('#title' => t('Bg image'), '#type' => 'select', '#options' => array('1' => t('1'), '2' => t('2'), '3' => t('3'), '4' => t('4'), '5' => t('5'), '6' => t('6'), '7' => t('7'), '8' => t('8')), '#default_value' => theme_get_setting('manis_bg_image', 'manis'));
}
开发者ID:antoniodltm,项目名称:merxtrod,代码行数:30,代码来源:theme-settings.php

示例3: testFileParsing

 public function testFileParsing()
 {
     $filename = drupal_get_path('module', 'locale') . '/tests/locale_test.js';
     // Parse the file to look for source strings.
     _locale_parse_js_file($filename);
     // Get all of the source strings that were found.
     $strings = $this->container->get('locale.storage')->getStrings(array('type' => 'javascript', 'name' => $filename));
     $source_strings = array();
     foreach ($strings as $string) {
         $source_strings[$string->source] = $string->context;
     }
     $etx = LOCALE_PLURAL_DELIMITER;
     // List of all strings that should be in the file.
     $test_strings = array('Standard Call t' => '', 'Whitespace Call t' => '', 'Single Quote t' => '', "Single Quote \\'Escaped\\' t" => '', 'Single Quote Concat strings t' => '', 'Double Quote t' => '', "Double Quote \\\"Escaped\\\" t" => '', 'Double Quote Concat strings t' => '', 'Context !key Args t' => 'Context string', 'Context Unquoted t' => 'Context string unquoted', 'Context Single Quoted t' => 'Context string single quoted', 'Context Double Quoted t' => 'Context string double quoted', "Standard Call plural{$etx}Standard Call @count plural" => '', "Whitespace Call plural{$etx}Whitespace Call @count plural" => '', "Single Quote plural{$etx}Single Quote @count plural" => '', "Single Quote \\'Escaped\\' plural{$etx}Single Quote \\'Escaped\\' @count plural" => '', "Double Quote plural{$etx}Double Quote @count plural" => '', "Double Quote \\\"Escaped\\\" plural{$etx}Double Quote \\\"Escaped\\\" @count plural" => '', "Context !key Args plural{$etx}Context !key Args @count plural" => 'Context string', "Context Unquoted plural{$etx}Context Unquoted @count plural" => 'Context string unquoted', "Context Single Quoted plural{$etx}Context Single Quoted @count plural" => 'Context string single quoted', "Context Double Quoted plural{$etx}Context Double Quoted @count plural" => 'Context string double quoted');
     // Assert that all strings were found properly.
     foreach ($test_strings as $str => $context) {
         $args = array('%source' => $str, '%context' => $context);
         // Make sure that the string was found in the file.
         $this->assertTrue(isset($source_strings[$str]), String::format('Found source string: %source', $args));
         // Make sure that the proper context was matched.
         $message = $context ? String::format('Context for %source is %context', $args) : String::format('Context for %source is blank', $args);
         $this->assertTrue(isset($source_strings[$str]) && $source_strings[$str] === $context, $message);
     }
     $this->assertEqual(count($source_strings), count($test_strings), 'Found correct number of source strings.');
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:25,代码来源:LocaleJavascriptTranslationTest.php

示例4: testFeed

 /**
  * Generates a test feed and simulates last-modified and etags.
  *
  * @param $use_last_modified
  *   Set TRUE to send a last modified header.
  * @param $use_etag
  *   Set TRUE to send an etag.
  * @param Request $request
  *   Information about the current HTTP request.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  *   A feed that forces cache validation.
  */
 public function testFeed($use_last_modified, $use_etag, Request $request)
 {
     $response = new Response();
     $last_modified = strtotime('Sun, 19 Nov 1978 05:00:00 GMT');
     $etag = Crypt::hashBase64($last_modified);
     $if_modified_since = strtotime($request->server->get('HTTP_IF_MODIFIED_SINCE'));
     $if_none_match = stripslashes($request->server->get('HTTP_IF_NONE_MATCH'));
     // Send appropriate response. We respond with a 304 not modified on either
     // etag or on last modified.
     if ($use_last_modified) {
         $response->headers->set('Last-Modified', gmdate(DateTimePlus::RFC7231, $last_modified));
     }
     if ($use_etag) {
         $response->headers->set('ETag', $etag);
     }
     // Return 304 not modified if either last modified or etag match.
     if ($last_modified == $if_modified_since || $etag == $if_none_match) {
         $response->setStatusCode(304);
         return $response;
     }
     // The following headers force validation of cache.
     $response->headers->set('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT');
     $response->headers->set('Cache-Control', 'must-revalidate');
     $response->headers->set('Content-Type', 'application/rss+xml; charset=utf-8');
     // Read actual feed from file.
     $file_name = drupal_get_path('module', 'aggregator_test') . '/aggregator_test_rss091.xml';
     $handle = fopen($file_name, 'r');
     $feed = fread($handle, filesize($file_name));
     fclose($handle);
     $response->setContent($feed);
     return $response;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:45,代码来源:AggregatorTestRssController.php

示例5: testModuleConfig

 /**
  * Tests if installed config is equal to the exported config.
  *
  * @dataProvider providerTestModuleConfig
  */
 public function testModuleConfig($module)
 {
     /** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
     $module_installer = $this->container->get('module_installer');
     /** @var \Drupal\Core\Config\StorageInterface $active_config_storage */
     $active_config_storage = $this->container->get('config.storage');
     /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
     $config_manager = $this->container->get('config.manager');
     $module_installer->install([$module]);
     // System and user are required in order to be able to install some of the
     // other modules. Therefore they are put into static::$modules, which though
     // doesn't install config files, so import those config files explicitly.
     switch ($module) {
         case 'system':
         case 'user':
             $this->installConfig([$module]);
             break;
     }
     $default_install_path = drupal_get_path('module', $module) . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
     $module_config_storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION);
     // The following config entries are changed on module install, so compare
     // them doesn't make sense.
     $skipped_config = [];
     $skipped_config['locale.settings'][] = 'path: ';
     $skipped_config['syslog.settings'][] = 'facility: ';
     // @todo Figure out why simpletest.settings is not installed.
     $skipped_config['simpletest.settings'] = TRUE;
     // Compare the installed config with the one in the module directory.
     foreach ($module_config_storage->listAll() as $config_name) {
         $result = $config_manager->diff($module_config_storage, $active_config_storage, $config_name);
         $this->assertConfigDiff($result, $config_name, $skipped_config);
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:38,代码来源:DefaultConfigTest.php

示例6: CallAPI

 /**
  * Function is used to render a test harness for the API.
  */
 static function CallAPI()
 {
     global $conf;
     if ($_GET['submit'] == 1) {
         $host = $conf['check_book']['data_feeds']['site_url'];
         $url = $host . '/api?wsdl';
         $xml = $_POST['txtInput'];
         $ch = curl_init($url);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
         $response = curl_exec($ch);
         curl_close($ch);
         $xml = simplexml_load_string($response);
         $json = json_encode($xml);
         $array = json_decode($json, TRUE);
         $html = self::render_xml_data($array);
         echo $html;
     } else {
         $domain = 'spending_oge';
         $xml = file_get_contents(realpath(drupal_get_path('module', 'checkbook_api')) . "/sample/" . strtolower($domain) . ".xml");
         echo '<form action="api-test?submit=1" method="post">';
         echo 'Paste Input Here:<br>';
         echo '<textarea name="txtInput" rows="20" columns="40" style="height: 100%;">' . $xml . '</textarea>';
         echo '<br>';
         echo '<br><br>';
         echo '<input type="submit" value="Submit">';
         echo '</form> ';
     }
 }
开发者ID:ecs-hk,项目名称:Checkbook,代码行数:35,代码来源:CheckbookAPIUtil.php

示例7: odsherredweb_preprocess_page

/**
 * implements hook_preprocess_page()
 *
 **/
function odsherredweb_preprocess_page(&$variables)
{
    $current_theme = variable_get('theme_default', 'none');
    // Search form
    $variables['simple_navigation_search'] = module_invoke('search', 'block_view', 'search');
    // Navigation
    $variables['sidebar_borger'] = _bellcom_generate_menu('menu-indhold', 'sidebar');
    $variables['sidebar_erhverv'] = _bellcom_generate_menu('menu-erhverv', 'sidebar');
    $variables['sidebar_politik'] = _bellcom_generate_menu('menu-politik', 'sidebar');
    // Add the site structure term id to the page div
    $node = node_load(arg(1));
    if (is_object($node) && isset($node->field_os2web_spotbox_sitestruct)) {
        $termParents = taxonomy_get_parents($node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid']);
        $termId = 'tid-' . $node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid'];
        $termIdParent = "";
        if (!empty($termParents)) {
            $termIdParent = 'tid-' . key($termParents);
        }
        $variables['attributes_array']['class'] = $termIdParent . ' ' . $termId;
    }
    // Paths
    $variables['path_js'] = base_path() . drupal_get_path('theme', $current_theme) . '/js';
    $variables['path_img'] = base_path() . drupal_get_path('theme', $current_theme) . '/images';
    $variables['path_css'] = base_path() . drupal_get_path('theme', $current_theme) . '/css';
    $variables['path_font'] = base_path() . drupal_get_path('theme', $current_theme) . '/font';
}
开发者ID:odsherred,项目名称:odsherred.dk,代码行数:30,代码来源:template.php

示例8: process

 /**
  * Callback for $element['#process']
  * Create one textfield element per rule.
  *
  * @param array $element
  * @param array $form_state
  * @return array
  */
 function process($element, $form_state)
 {
     /** @var crumbs_PluginSystem_PluginInfo $info */
     $info = $element['#crumbs_plugin_info'];
     $available_keys_meta = $info->availableKeysMeta;
     // Set up table rows
     /** @var crumbs_Container_MultiWildcardDataOffset $meta */
     foreach ($available_keys_meta as $key => $meta) {
         $element[$key] = array('#type' => 'textfield', '#size' => 10, '#default_value' => 'inherit', '#class' => array('crumbs-weight-element'), '#crumbs_rule_info' => $meta);
         if (isset($element['#value'][$key])) {
             $v = $element['#value'][$key];
             if (FALSE === $v) {
                 $v = 'disabled';
             } elseif (-1 === $v || '-1' === $v) {
                 $v = 'auto';
             }
             $element[$key]['#default_value'] = $v;
         }
     }
     // Calculate md5 hashes for keys, because javascript sucks at it.
     $keys_md5 = array();
     foreach ($available_keys_meta as $key => $meta) {
         $keys_md5[$key] = md5($key);
     }
     $settings['crumbs']['default_weights'] = $element['#crumbs_plugin_info']->defaultWeights;
     $settings['crumbs']['keys_md5'] = $keys_md5;
     $element['#attached']['js'][] = array('data' => $settings, 'type' => 'setting');
     $element['#attached']['js'][] = drupal_get_path('module', 'crumbs') . '/js/crumbs.admin.expansible.js';
     $element['#attached']['css'][] = drupal_get_path('module', 'crumbs') . '/css/crumbs.admin.expansible.css';
     return $element;
 }
开发者ID:haleyhawes,项目名称:foursquare,代码行数:39,代码来源:WeightsExpansible.php

示例9: testUserAgentValidation

 /**
  * Test validation of the User-Agent header we use to perform test requests.
  */
 public function testUserAgentValidation()
 {
     global $base_url;
     // Logout the user which was logged in during test-setup.
     $this->drupalLogout();
     $system_path = $base_url . '/' . drupal_get_path('module', 'system');
     $HTTP_path = $system_path . '/tests/http.php/user/login';
     $https_path = $system_path . '/tests/https.php/user/login';
     // Generate a valid simpletest User-Agent to pass validation.
     $this->assertTrue(preg_match('/simpletest\\d+/', $this->databasePrefix, $matches), 'Database prefix contains simpletest prefix.');
     $test_ua = drupal_generate_test_ua($matches[0]);
     $this->additionalCurlOptions = array(CURLOPT_USERAGENT => $test_ua);
     // Test pages only available for testing.
     $this->drupalGet($HTTP_path);
     $this->assertResponse(200, 'Requesting http.php with a legitimate simpletest User-Agent returns OK.');
     $this->drupalGet($https_path);
     $this->assertResponse(200, 'Requesting https.php with a legitimate simpletest User-Agent returns OK.');
     // Now slightly modify the HMAC on the header, which should not validate.
     $this->additionalCurlOptions = array(CURLOPT_USERAGENT => $test_ua . 'X');
     $this->drupalGet($HTTP_path);
     $this->assertResponse(403, 'Requesting http.php with a bad simpletest User-Agent fails.');
     $this->drupalGet($https_path);
     $this->assertResponse(403, 'Requesting https.php with a bad simpletest User-Agent fails.');
     // Use a real User-Agent and verify that the special files http.php and
     // https.php can't be accessed.
     $this->additionalCurlOptions = array(CURLOPT_USERAGENT => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12');
     $this->drupalGet($HTTP_path);
     $this->assertResponse(403, 'Requesting http.php with a normal User-Agent fails.');
     $this->drupalGet($https_path);
     $this->assertResponse(403, 'Requesting https.php with a normal User-Agent fails.');
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:34,代码来源:SimpleTestBrowserTest.php

示例10: testStatisticsTokenReplacement

 /**
  * Creates a node, then tests the statistics tokens generated from it.
  */
 function testStatisticsTokenReplacement()
 {
     $language_interface = \Drupal::languageManager()->getCurrentLanguage();
     // Create user and node.
     $user = $this->drupalCreateUser(array('create page content'));
     $this->drupalLogin($user);
     $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $user->id()));
     // Hit the node.
     $this->drupalGet('node/' . $node->id());
     // Manually calling statistics.php, simulating ajax behavior.
     $nid = $node->id();
     $post = http_build_query(array('nid' => $nid));
     $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
     global $base_url;
     $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics') . '/statistics.php';
     $client = \Drupal::service('http_client_factory')->fromOptions(['config/curl' => [CURLOPT_TIMEOUT => 10]]);
     $client->post($stats_path, array('headers' => $headers, 'body' => $post));
     $statistics = statistics_get($node->id());
     // Generate and test tokens.
     $tests = array();
     $tests['[node:total-count]'] = 1;
     $tests['[node:day-count]'] = 1;
     $tests['[node:last-view]'] = format_date($statistics['timestamp']);
     $tests['[node:last-view:short]'] = format_date($statistics['timestamp'], 'short');
     // Test to make sure that we generated something for each token.
     $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
     foreach ($tests as $input => $expected) {
         $output = \Drupal::token()->replace($input, array('node' => $node), array('langcode' => $language_interface->getId()));
         $this->assertEqual($output, $expected, format_string('Statistics token %token replaced.', array('%token' => $input)));
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:34,代码来源:StatisticsTokenReplaceTest.php

示例11: testDrupalRenderChildrenAttached

 /**
  * Tests #attached functionality in children elements.
  */
 function testDrupalRenderChildrenAttached()
 {
     // The cache system is turned off for POST requests.
     $request_method = \Drupal::request()->getMethod();
     \Drupal::request()->setMethod('GET');
     // Create an element with a child and subchild. Each element loads a
     // different JavaScript file using #attached.
     $parent_js = drupal_get_path('module', 'user') . '/user.js';
     $child_js = drupal_get_path('module', 'forum') . '/forum.js';
     $subchild_js = drupal_get_path('module', 'book') . '/book.js';
     $element = array('#type' => 'details', '#open' => TRUE, '#cache' => array('keys' => array('simpletest', 'drupal_render', 'children_attached')), '#attached' => array('js' => array($parent_js)), '#title' => 'Parent');
     $element['child'] = array('#type' => 'details', '#open' => TRUE, '#attached' => array('js' => array($child_js)), '#title' => 'Child');
     $element['child']['subchild'] = array('#attached' => array('js' => array($subchild_js)), '#markup' => 'Subchild');
     // Render the element and verify the presence of #attached JavaScript.
     drupal_render($element);
     $scripts = drupal_get_js();
     $this->assertTrue(strpos($scripts, $parent_js), 'The element #attached JavaScript was included.');
     $this->assertTrue(strpos($scripts, $child_js), 'The child #attached JavaScript was included.');
     $this->assertTrue(strpos($scripts, $subchild_js), 'The subchild #attached JavaScript was included.');
     // Load the element from cache and verify the presence of the #attached
     // JavaScript.
     drupal_static_reset('_drupal_add_js');
     $element = array('#cache' => array('keys' => array('simpletest', 'drupal_render', 'children_attached')));
     $this->assertTrue(strlen(drupal_render($element)) > 0, 'The element was retrieved from cache.');
     $scripts = drupal_get_js();
     $this->assertTrue(strpos($scripts, $parent_js), 'The element #attached JavaScript was included when loading from cache.');
     $this->assertTrue(strpos($scripts, $child_js), 'The child #attached JavaScript was included when loading from cache.');
     $this->assertTrue(strpos($scripts, $subchild_js), 'The subchild #attached JavaScript was included when loading from cache.');
     // Restore the previous request method.
     \Drupal::request()->setMethod($request_method);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:34,代码来源:RenderTest.php

示例12: radix_form_system_theme_settings_alter

/**
 * Implements theme_settings().
 */
function radix_form_system_theme_settings_alter(&$form, &$form_state)
{
    $theme_path = drupal_get_path('theme', 'sizzle');
    // Ensure this include file is loaded when the form is rebuilt from the cache.
    $form_state['build_info']['files']['form'] = $theme_path . '/theme-settings.php';
    // Hide all theme settings
    $form['theme_settings']['#access'] = FALSE;
    // Add theme settings here.
    $form['default_theme_settings'] = array('#title' => t('Theme Settings'), '#type' => 'vertical_tabs');
    $form['layout'] = array('#type' => 'fieldset', '#title' => t('Layout'), '#collapsible' => TRUE, '#group' => 'default_theme_settings');
    $form['layout']['site_width'] = array('#title' => t('Width'), '#type' => 'radios', '#options' => array('full' => t('Full width'), 'boxed' => t('Boxed')), '#default_value' => theme_get_setting('site_width'));
    // Site background image.
    $form['layout']['site_background_image'] = array('#title' => t('Background image'), '#type' => 'managed_file', '#description' => t('The background image to use for the site.'), '#upload_location' => 'public://', '#theme' => 'restaurant_admin_thumbnail', '#default_value' => theme_get_setting('site_background_image'));
    // Create a branding group and move logo and favicon to it.
    $form['branding'] = array('#type' => 'fieldset', '#title' => t('Branding'), '#collapsible' => TRUE, '#group' => 'default_theme_settings');
    $form['logo']['#group'] = 'branding';
    $form['favicon']['#group'] = 'branding';
    // Footer.
    $form['footer'] = array('#type' => 'fieldset', '#title' => t('Footer'), '#collapsible' => TRUE, '#group' => 'default_theme_settings');
    // Footer background image.
    $form['footer']['footer_background_image'] = array('#title' => t('Background image'), '#type' => 'managed_file', '#description' => t('The background image to use for the site footer.'), '#upload_location' => 'public://', '#theme' => 'restaurant_admin_thumbnail', '#default_value' => theme_get_setting('footer_background_image'));
    // Footer text.
    $footer_text = theme_get_setting('footer_text');
    $form['footer']['footer_text'] = array('#title' => t('Footer text'), '#type' => 'text_format', '#format' => $footer_text['format'], '#default_value' => $footer_text['value']);
    $form['footer']['show_footer_nav'] = array('#title' => t('Show the footer nav?'), '#type' => 'checkbox', '#default_value' => theme_get_setting('show_footer_nav'));
    // Copyright.
    $copyright = theme_get_setting('copyright');
    $form['footer']['copyright'] = array('#title' => t('Copyright'), '#type' => 'text_format', '#format' => $copyright['format'], '#default_value' => $copyright['value']);
    // Add a custom submit handler.
    $form['#submit'][] = 'sizzle_form_system_theme_settings_submit';
    // Return the additional form widgets.
    return $form;
}
开发者ID:shinjanidhar,项目名称:book-your-show,代码行数:36,代码来源:theme-settings.php

示例13: hook_toolbar

/**
 * Add items to the toolbar menu.
 *
 * The toolbar is a container for administrative and site-global interactive
 * components.
 *
 * The toolbar provides a common styling for items denoted by the
 * .toolbar-tab class.
 *
 * The toolbar provides a construct called a 'tray'. The tray is a container
 * for content. The tray may be associated with a toggle in the administration
 * bar. The toggle shows or hides the tray and is optimized for small and
 * large screens. To create this association, hook_toolbar() returns one or
 * more render elements of type 'toolbar_item', containing the toggle and tray
 * elements in its 'tab' and 'tray' properties.
 *
 * The following properties are available:
 *   - 'tab': A renderable array.
 *   - 'tray': Optional. A renderable array.
 *   - '#weight': Optional. Integer weight used for sorting toolbar items in
 *     administration bar area.
 *
 * This hook is invoked in toolbar_pre_render().
 *
 * @return
 *   An array of toolbar items, keyed by unique identifiers such as 'home' or
 *   'administration', or the short name of the module implementing the hook.
 *   The corresponding value is a render element of type 'toolbar_item'.
 *
 * @see toolbar_pre_render()
 * @ingroup toolbar_tabs
 */
function hook_toolbar()
{
    $items = array();
    // Add a search field to the toolbar. The search field employs no toolbar
    // module theming functions.
    $items['global_search'] = array('#type' => 'toolbar_item', 'tab' => array('#type' => 'search', '#attributes' => array('placeholder' => t('Search the site'), 'class' => array('search-global'))), '#weight' => 200, '#attached' => array('css' => array(drupal_get_path('module', 'search') . '/css/search.base.css')));
    // The 'Home' tab is a simple link, which is wrapped in markup associated
    // with a visual tab styling.
    $items['home'] = array('#type' => 'toolbar_item', 'tab' => array('#type' => 'link', '#title' => t('Home'), '#url' => Url::fromRoute('<front>'), '#options' => array('attributes' => array('title' => t('Home page'), 'class' => array('toolbar-icon', 'toolbar-icon-home')))), '#weight' => -20);
    // A tray may be associated with a tab.
    //
    // When the tab is activated, the tray will become visible, either in a
    // horizontal or vertical orientation on the screen.
    //
    // The tray should contain a renderable array. An optional #heading property
    // can be passed. This text is written to a heading tag in the tray as a
    // landmark for accessibility.
    $items['commerce'] = array('#type' => 'toolbar_item', 'tab' => array('#type' => 'link', '#title' => t('Shopping cart'), '#url' => Url::fromRoute('cart'), '#options' => array('html' => FALSE, 'attributes' => array('title' => t('Shopping cart')))), 'tray' => array('#heading' => t('Shopping cart actions'), 'shopping_cart' => array('#theme' => 'item_list', '#items' => array())), '#weight' => 150);
    // The tray can be used to render arbritrary content.
    //
    // A renderable array passed to the 'tray' property will be rendered outside
    // the administration bar but within the containing toolbar element.
    //
    // If the default behavior and styling of a toolbar tray is not desired, one
    // can render content to the toolbar element and apply custom theming and
    // behaviors.
    $items['user_messages'] = array('#type' => 'toolbar_item', 'tab' => array('#type' => 'link', '#theme' => 'user_message_toolbar_tab', '#theme_wrappers' => array(), '#title' => t('Messages'), '#url' => Url::fromRoute('user.message'), '#options' => array('attributes' => array('title' => t('Messages')))), 'tray' => array('#heading' => t('User messages'), 'messages' => array()), '#weight' => 125);
    return $items;
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:61,代码来源:toolbar.api.php

示例14: whaleocalypse_preprocess_field

/**
 * Add the comic strip name right above the body field.
 */
function whaleocalypse_preprocess_field(&$vars)
{
    if (isset($vars['element']['#bundle']) && $vars['element']['#bundle'] == 'comic' && isset($vars['element']['#field_name']) && $vars['element']['#field_name'] == 'body') {
        $vars['label'] = $vars['element']['#object']->title;
    }
    //Add the transcript expand js if the field is populated
    if ($vars['element']['#field_name'] == 'field_transcript') {
        drupal_add_js(drupal_get_path('theme', 'whaleocalypse') . '/js/expand-transcript.js', array('scope' => 'footer', 'type' => 'file'));
    }
    //Create the custom "story arc" functionality
    if (isset($vars['element']['#field_name']) && $vars['element']['#field_name'] == 'field_story_arc') {
        $tid = $vars['element']['#object']->field_story_arc[LANGUAGE_NONE][0]['tid'];
        $nid = $vars['element']['#object']->nid;
        $story_arc_count = new EntityFieldQuery();
        $vars['story_arc_count'] = $story_arc_count->entityCondition('entity_type', 'node')->entityCondition('bundle', 'comic')->fieldCondition('field_story_arc', 'tid', $tid, '=')->count()->execute();
        $story_arc_position = new EntityFieldQuery();
        $story_arc_position = $story_arc_position->entityCondition('entity_type', 'node')->entityCondition('bundle', 'comic')->fieldCondition('field_story_arc', 'tid', $tid, '=')->propertyOrderBy('created', 'ASC')->execute();
        $vars['story_arc_position'] = array_search($nid, array_keys($story_arc_position['node'])) + 1;
    }
    //Add the author URL if it is set.
    if (isset($vars['element']['#field_name']) && $vars['element']['#field_name'] == 'field_contributing_author') {
        if (isset($vars['element']['#object']->field_contributing_author_url[LANGUAGE_NONE][0])) {
            $vars['items'][0]['#markup'] = l($vars['items'][0]['#markup'], $vars['element']['#object']->field_contributing_author_url[LANGUAGE_NONE][0]['value'], array("attributes" => array("target" => "_blank")));
        }
        $vars['call_to_action'] = 'You can ' . l('write your own whaleocalypse too.', 'node/169', array());
    }
}
开发者ID:ridho7uliansyah,项目名称:0xPc50ff3ns1v3,代码行数:30,代码来源:template.php

示例15: bartik_preprocess_maintenance_page

/**
 * Implements hook_preprocess_maintenance_page().
 */
function bartik_preprocess_maintenance_page(&$variables)
{
    if (!$variables['db_is_active']) {
        unset($variables['site_name']);
    }
    drupal_add_css(drupal_get_path('theme', 'bartik') . '/css/maintenance-page.css');
}
开发者ID:xalgorithm,项目名称:capistrano-stuff,代码行数:10,代码来源:template.php


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