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


PHP variable_set函数代码示例

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


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

示例1: asu_webspark_bootstrap_settings_submit

function asu_webspark_bootstrap_settings_submit($form, &$form_state)
{
    // Set the variables, need to use this instead of theme_get_settings
    // because the scop of the vars is more global.
    if ($form_state['values']['asu_brand_header_selector'] != 'custom') {
        variable_set('asu_brand_header_template', $form_state['values']['asu_brand_header_selector']);
    } else {
        variable_set('asu_brand_header_template', $form_state['values']['asu_brand_header_template']);
    }
    variable_set('asu_brand_is_student', $form_state['values']['asu_brand_is_student']);
    variable_set('asu_brand_student_color', $form_state['values']['asu_brand_student_color']);
    variable_set('asu_brand_header_selector', $form_state['values']['asu_brand_header_selector']);
    if ($file = $form_state['values']['picture_upload']) {
        unset($form_state['values']['picture_upload']);
        $filename = file_unmanaged_copy($file->uri);
        $form_state['values']['default_picture'] = 1;
        $form_state['values']['picture_path'] = $filename;
    }
    // If the user entered a path relative to the system files directory for
    // a logo or favicon, store a public:// URI so the theme system can handle it.
    if (!empty($form_state['values']['picture_path'])) {
        $form_state['values']['picture_path'] = _system_theme_settings_validate_path($form_state['values']['picture_path']);
    }
    // ASU header needs a cache_clear
    if (module_exists('asu_brand')) {
        asu_brand_cache_clear();
    }
}
开发者ID:niner9,项目名称:webspark-drops-drupal7,代码行数:28,代码来源:theme-settings.php

示例2: fusion_core_initialize_theme_settings

/**
 * Initialize theme settings if needed
 */
function fusion_core_initialize_theme_settings($theme_name)
{
    $theme_settings = theme_get_settings($theme_name);
    if (is_null($theme_settings['theme_font_size']) || $theme_settings['rebuild_registry'] == 1) {
        // Rebuild theme registry & notify user
        if ($theme_settings['rebuild_registry'] == 1) {
            drupal_rebuild_theme_registry();
            drupal_set_message(t('Theme registry rebuild completed. <a href="!link">Turn off</a> this feature for production websites.', array('!link' => url('admin/build/themes/settings/' . $GLOBALS['theme']))), 'warning');
        }
        // Retrieve saved or site-wide theme settings
        $theme_setting_name = str_replace('/', '_', 'theme_' . $theme_name . '_settings');
        $settings = variable_get($theme_setting_name, FALSE) ? theme_get_settings($theme_name) : theme_get_settings();
        // Skip toggle_node_info_ settings
        if (module_exists('node')) {
            foreach (node_get_types() as $type => $name) {
                unset($settings['toggle_node_info_' . $type]);
            }
        }
        // Retrieve default theme settings
        $defaults = fusion_core_default_theme_settings();
        // Set combined default & saved theme settings
        variable_set($theme_setting_name, array_merge($defaults, $settings));
        // Force theme settings refresh
        theme_get_setting('', TRUE);
    }
}
开发者ID:edchacon,项目名称:scratchpads,代码行数:29,代码来源:theme-settings.php

示例3: submit

 public function submit($form, &$form_state)
 {
     variable_set('publisher_enabled', $form_state['values']['enabled']);
     variable_set('publisher_api_key', $form_state['values']['api_key']);
     variable_set('publisher_debug_mode', $form_state['values']['debug']);
     drupal_set_message('Publisher settings saved successfully!');
 }
开发者ID:sammarks,项目名称:publisher,代码行数:7,代码来源:SettingsForm.php

示例4: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     static::$cacheDir = DRUPONY_TEST_DIR . DIRECTORY_SEPARATOR . 'cacheDir';
     variable_set('drupony_cachedir', static::$cacheDir);
     require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'drupony.module';
     require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'drupony.hooks.inc';
 }
开发者ID:frizinak,项目名称:drupony,代码行数:7,代码来源:DruponyModuleTest.php

示例5: save

 public function save()
 {
     foreach ($this->saveable as $property) {
         $save[$property] = $this->{$property};
     }
     variable_set('ldap_profile_conf', $save);
 }
开发者ID:mrschleig,项目名称:sensdata,代码行数:7,代码来源:LdapProfileConfAdmin.class.php

示例6: testDateImport

 /**
  * Verify that date fields are imported correctly. When no timezone is
  * explicitly provided with the source data, we want the displayed time on the
  * Drupal site to match that in the source data. To validate that, we make
  * sure we have set a consistent timezone at the PHP and Drupal levels, and
  * that the format used on the page is not locale-dependent (no day or month
  * names). Then, we can just look for the desired date/time strings in the
  * node page.
  */
 function testDateImport()
 {
     date_default_timezone_set('America/Los_Angeles');
     variable_set('date_default_timezone', 'America/Los_Angeles');
     variable_set('date_format_medium', 'Y-m-d H:i');
     $migration = Migration::getInstance('DateExample');
     $result = $migration->processImport();
     $this->assertEqual($result, Migration::RESULT_COMPLETED, t('Variety term import returned RESULT_COMPLETED'));
     $rawnodes = node_load_multiple(FALSE, array('type' => 'date_migrate_example'), TRUE);
     $this->assertEqual(count($rawnodes), 2, t('Two sample nodes created'));
     $node = reset($rawnodes);
     $this->drupalGet('/node/' . $node->nid);
     $this->assertText('2011-05-12 19:43', t('Simple date field found'));
     $this->assertText('2011-06-13 18:32 to 2011-07-23 10:32', t('Date range field found'));
     $this->assertText('2011-07-22 12:13', t('Datestamp field found'));
     $this->assertText('2011-08-01 00:00 to 2011-09-01 00:00', t('Datestamp range field found'));
     $this->assertText('2011-11-18 15:00', t('Datetime field with +9 timezone found'));
     $this->assertText('2011-10-30 14:43 to 2011-12-31 17:59', t('Datetime range field with -5 timezone found'));
     $this->assertText('2011-11-25 09:01', t('First date repeat instance found'));
     $this->assertText('2011-12-09 09:01', t('Second date repeat instance found'));
     $this->assertNoText('2011-12-23 09:01', t('Skipped date repeat instance not found'));
     $this->assertText('2012-05-11 09:01', t('Last date repeat instance found'));
     $node = next($rawnodes);
     $this->drupalGet('/node/' . $node->nid);
     $this->assertText('2012-06-21 15:32', t('First date value found'));
     $this->assertText('2012-12-02 11:08', t('Second date value found'));
     $this->assertText('2004-02-03 01:15', t('Start for first date range found'));
     $this->assertText('2005-03-04 22:11', t('End for first date range found'));
     $this->assertText('2014-09-01 17:21', t('Start for second date range found'));
     $this->assertText('2015-12-23 00:01', t('End for first second range found'));
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:40,代码来源:DateMigrateExampleUnitTest.php

示例7: _scratchpadify_install_configure_form_submit

function _scratchpadify_install_configure_form_submit($form, &$form_state)
{
    global $user;
    variable_set('site_name', $form_state['values']['site_name']);
    variable_set('site_mail', $form_state['values']['site_mail']);
    variable_set('date_default_timezone', $form_state['values']['date_default_timezone']);
    // Enable update.module if this option was selected.
    if ($form_state['values']['update_status_module'][1]) {
        // Stop enabling the update module, it's a right royal pain in the arse.
        //drupal_install_modules(array('update'));
    }
    // Turn this off temporarily so that we can pass a password through.
    variable_set('user_email_verification', FALSE);
    $form_state['old_values'] = $form_state['values'];
    $form_state['values'] = $form_state['values']['account'];
    // We precreated user 1 with placeholder values. Let's save the real values.
    $account = user_load(1);
    $merge_data = array('init' => $form_state['values']['mail'], 'roles' => array(), 'status' => 0);
    user_save($account, array_merge($form_state['values'], $merge_data));
    // Log in the first user.
    user_authenticate($form_state['values']);
    $form_state['values'] = $form_state['old_values'];
    unset($form_state['old_values']);
    variable_set('user_email_verification', TRUE);
    if (isset($form_state['values']['clean_url'])) {
        variable_set('clean_url', $form_state['values']['clean_url']);
    }
    // The user is now logged in, but has no session ID yet, which
    // would be required later in the request, so remember it.
    $user->sid = session_id();
    // Record when this install ran.
    variable_set('install_time', time());
}
开发者ID:edchacon,项目名称:scratchpads,代码行数:33,代码来源:scratchpadify.profile-help.php

示例8: testKeyEnumKeys

 /**
  * Test enumeration of anonymous and authenticated keys.
  */
 public function testKeyEnumKeys()
 {
     global $base_root;
     variable_set('authcache_roles', array());
     $expect = array($base_root);
     $result = authcache_enum_keys();
     $this->assertEqual($expect, $result);
     drupal_static_reset();
     // Test anonymous and authenticated roles.
     variable_set('authcache_roles', array(DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID));
     $result = authcache_enum_keys();
     $anonymous_key = array_pop($result);
     $this->assertEqual($base_root, $anonymous_key);
     // Expect 1 additional key for authenticated users.
     $this->assertEqual(1, count($result));
     drupal_static_reset();
     // Test additional roles.
     $rid1 = $this->drupalCreateRole(array());
     $rid2 = $this->drupalCreateRole(array());
     variable_set('authcache_roles', array(DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID, $rid1 => $rid1, $rid2 => $rid2));
     $result = authcache_enum_keys();
     $anonymous_key = array_pop($result);
     $this->assertEqual($base_root, $anonymous_key);
     // Expect 4 keys for authenticated users:
     // * Only authenticated rid
     // * Only rid1
     // * Only rid2
     // * rid1 and rid2
     $this->assertEqual(4, count($result));
 }
开发者ID:LandPotential,项目名称:LandPKS_Authentication_Admin,代码行数:33,代码来源:AuthcacheEnumKeysTestCase.php

示例9: drupalexp_form_system_theme_settings_submit

function drupalexp_form_system_theme_settings_submit(&$form, &$form_state)
{
    unset($_SESSION['drupalexp_default_preset']);
    unset($_SESSION['drupalexp_default_direction']);
    unset($_SESSION['drupalexp_layout']);
    variable_set('drupalexp_settings_updated', REQUEST_TIME);
}
开发者ID:benelori,项目名称:lori,代码行数:7,代码来源:theme-settings.php

示例10: csa_base_get_default_settings

function csa_base_get_default_settings($theme)
{
    // Get node types
    $node_types = node_get_types('names');
    // The default values for the theme variables. Make sure $defaults exactly
    // matches the $defaults in the theme-settings.php file.
    $defaults = array('csa_base_move_sidebar' => 1, 'breadcrumb_display' => 0, 'breadcrumb_display_admin' => 1, 'breadcrumb_with_title' => 1, 'primary_links_display_style' => 'tabbed-menu', 'primary_links_allow_tree' => 0, 'secondary_links_display_style' => 'menu', 'secondary_links_allow_tree' => 0, 'search_snippet' => 1, 'search_info_type' => 1, 'search_info_user' => 1, 'search_info_date' => 1, 'search_info_comment' => 1, 'search_info_upload' => 1, 'mission_statement_pages' => 'home', 'hide_front_page_title' => 1, 'front_page_title_display' => 'title_slogan', 'page_title_display_custom' => '', 'other_page_title_display' => 'ptitle_slogan', 'other_page_title_display_custom' => '', 'configurable_separator' => ' | ', 'meta_keywords' => '', 'meta_description' => '', 'taxonomy_display_default' => 'only', 'taxonomy_display_vocab_name' => 1, 'taxonomy_format_default' => 'vocab', 'taxonomy_format_links' => 0, 'taxonomy_format_delimiter' => ', ', 'taxonomy_enable_content_type' => 0, 'submitted_by_author_default' => 0, 'submitted_by_date_default' => 0, 'submitted_by_enable_content_type' => 0);
    // Make the default content-type settings the same as the default theme settings,
    // so we can tell if content-type-specific settings have been altered.
    $defaults = array_merge($defaults, theme_get_settings());
    // Set the default values for content-type-specific settings
    foreach ($node_types as $type => $name) {
        $defaults["taxonomy_display_{$type}"] = $defaults['taxonomy_display_default'];
        $defaults["taxonomy_format_{$type}"] = $defaults['taxonomy_format_default'];
        $defaults["submitted_by_author_{$type}"] = $defaults['submitted_by_author_default'];
        $defaults["submitted_by_date_{$type}"] = $defaults['submitted_by_date_default'];
    }
    // Get default theme settings.
    $settings = theme_get_settings($theme);
    // Don't save the toggle_node_info_ variables
    if (module_exists('node')) {
        foreach (node_get_types() as $type => $name) {
            unset($settings['toggle_node_info_' . $type]);
        }
    }
    // Save default theme settings
    variable_set(str_replace('/', '_', 'theme_' . $theme . '_settings'), array_merge($defaults, $settings));
    // Force refresh of Drupal internals
    theme_get_setting('', TRUE);
    return $defaults;
}
开发者ID:rasjones,项目名称:csa,代码行数:31,代码来源:theme-settings-defaults.php

示例11: testNewDefaultThemeBlocks

 /**
  * Check the enabled Garland blocks are correctly copied over.
  */
 function testNewDefaultThemeBlocks()
 {
     // Create administrative user.
     $adminuser = $this->drupalCreateUser(array('administer themes'));
     $this->drupalLogin($adminuser);
     // Ensure no other theme's blocks are in the block table yet.
     $count = db_query_range("SELECT 1 FROM {block} WHERE theme NOT IN ('garland', 'seven')", 0, 1)->fetchField();
     $this->assertFalse($count, t('Only Garland and Seven have blocks.'));
     // Populate list of all blocks for matching against new theme.
     $blocks = array();
     $result = db_query("SELECT * FROM {block} WHERE theme = 'garland'");
     foreach ($result as $block) {
         // $block->theme and $block->bid will not match, so remove them.
         unset($block->theme, $block->bid);
         $blocks[$block->module][$block->delta] = $block;
     }
     // Turn on the Stark theme and ensure that it contains all of the blocks
     // that Garland did.
     theme_enable(array('stark'));
     variable_set('theme_default', 'stark');
     $result = db_query("SELECT * FROM {block} WHERE theme='stark'");
     foreach ($result as $block) {
         unset($block->theme, $block->bid);
         $this->assertEqual($blocks[$block->module][$block->delta], $block, t('Block %name matched', array('%name' => $block->module . '-' . $block->delta)));
     }
 }
开发者ID:pjcdawkins,项目名称:drupal7mongodb,代码行数:29,代码来源:NewDefaultThemeBlocksTest.php

示例12: applyDefaultConfigurationToContentType

 /**
  * Apply default NextEuropa configuration to a specific content type.
  *
  * This method is usually called into hook_install().
  *
  * @param string $type
  *    Content type machine name.
  *
  * @see nexteuropa_pages_install()
  */
 public function applyDefaultConfigurationToContentType($type)
 {
     // Replace title field.
     multisite_config_service('title')->replaceTitleField('node', $type, 'title');
     multisite_config_service('entity_translation')->enableEntityTranslation($type);
     // Add Organic Group fields.
     multisite_config_service('og')->createOgGroupAudienceField('node', $type);
     multisite_config_service('og')->createOgContentAccessField('node', $type);
     // Enable Workbench Moderation.
     multisite_config_service('workbench_moderation')->enableWorkbenchModeration($type);
     // Grant OG permissions if NextEuropa Editorial feature is enabled.
     if (module_exists('nexteuropa_editorial')) {
         $og_permissions = array();
         $og_permissions['contributor'] = array('create ' . $type . ' content', 'update own ' . $type . ' content', 'delete own ' . $type . ' content');
         $og_permissions['validator'] = $og_permissions['publisher'] = $og_permissions['administrator member'] = array('create ' . $type . ' content', 'update own ' . $type . ' content', 'delete own ' . $type . ' content', 'update any ' . $type . ' content', 'delete any ' . $type . ' content');
         foreach ($og_permissions as $role => $permissions) {
             multisite_config_service('og')->grantOgPermissions($role, $permissions, 'node', 'editorial_team', 'og');
         }
     }
     // Enable Linkchecker control for "Page" content type.
     multisite_config_service('linkchecker')->enableLinkcheckerForContentType($type);
     // Enable default scheduling options for a specific content type.
     multisite_config_service('scheduler')->enableSchedulerForContentType($type);
     // Set unpublish moderation state to "expired".
     // This call cannot be included in the API method above since it is
     // a configuration specific to NextEuropa .
     variable_set('scheduler_unpublish_moderation_state_' . $type, 'expired');
 }
开发者ID:janoka,项目名称:platform-dev,代码行数:38,代码来源:Config.php

示例13: hook_taxonomy_vocabulary_update

/**
 * Act on taxonomy vocabularies when updated.
 *
 * Modules implementing this hook can act on the vocabulary object when updated.
 *
 * @param $vocabulary
 *   A taxonomy vocabulary object.
 */
function hook_taxonomy_vocabulary_update($vocabulary)
{
    $status = $vocabulary->synonyms ? TRUE : FALSE;
    if ($vocabulary->synonyms) {
        variable_set('taxonomy_' . $vocabulary->vid . '_synonyms', $status);
    }
}
开发者ID:edos4,项目名称:drupal_test,代码行数:15,代码来源:taxonomy.api.php

示例14: hook_menu_delete

/**
 * Respond to a custom menu deletion.
 *
 * This hook is used to notify modules that a custom menu along with all links
 * contained in it (if any) has been deleted. Contributed modules may use the
 * information to perform actions based on the information entered into the menu
 * system.
 *
 * @param $menu
 *   An array representing a custom menu:
 *   - menu_name: The unique name of the custom menu.
 *   - title: The human readable menu title.
 *   - description: The custom menu description.
 *
 * @see hook_menu_insert()
 * @see hook_menu_update()
 */
function hook_menu_delete($menu)
{
    // Delete the record from our variable.
    $my_menus = variable_get('my_module_menus', array());
    unset($my_menus[$menu['menu_name']]);
    variable_set('my_module_menus', $my_menus);
}
开发者ID:HamzaBendidane,项目名称:prel,代码行数:24,代码来源:menu.api.php

示例15: _validate_page_width

function _validate_page_width($width)
{
    global $theme_key;
    /*
     * The default values for the theme variables. Make sure $defaults exactly
     * matches the $defaults in the theme-settings.php file.
     */
    $defaults = array('pixture_width' => '85%');
    // check if it is liquid (%) or fixed width (px)
    if (preg_match("/(\\d+)\\s*%/", $width, $match)) {
        $liquid = 1;
        $num = intval($match[0]);
        if (50 <= $num && $num <= 100) {
            return $num . "%";
            // OK!
        }
    } else {
        if (preg_match("/(\\d+)\\s*px/", $width, $match)) {
            $fixed = 1;
            $num = intval($match[0]);
            if (800 <= $num && $num < 1600) {
                return $num . "px";
                // OK
            }
        }
    }
    // reset to default value
    variable_set(str_replace('/', '_', 'theme_' . $theme_key . '_settings'), array_merge($defaults, theme_get_settings($theme_key)));
    // Force refresh of Drupal internals
    theme_get_setting('', TRUE);
    return $defaults['pixture_width'];
}
开发者ID:javaperl,项目名称:fcase,代码行数:32,代码来源:theme-settings.php


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