本文整理汇总了PHP中taxonomy_get_vocabularies函数的典型用法代码示例。如果您正苦于以下问题:PHP taxonomy_get_vocabularies函数的具体用法?PHP taxonomy_get_vocabularies怎么用?PHP taxonomy_get_vocabularies使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了taxonomy_get_vocabularies函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: form
/**
* Builds extra settings for the block edit form.
*/
public function form($bean, $form, &$form_state)
{
// Here we are defining the form.
$form = array();
// Select objects for the vocabularies that will be used.
$vocabulary = taxonomy_get_vocabularies();
$select_vocabulary_array = array();
foreach ($vocabulary as $item) {
$select_vocabulary_array[$item->machine_name] = $item->name;
}
// Building the basic form for individual 'related' bean configuration.
$form['filters'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('Filters'));
// Determine related taxonomy term vocabularies.
$form['filters']['vocabulary'] = array('#type' => 'select', '#title' => t('Vocabulary'), '#options' => $select_vocabulary_array, '#default_value' => $bean->filters['vocabulary'], '#required' => TRUE, '#multiple' => TRUE, '#size' => 5);
// Settings fieldset is used for configuring the 'listing' bean output.
$form['settings'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('Output'));
// Select objects for the taxonomy term view modes that will be used.
$term_view_modes = array();
$entity_info = entity_get_info();
foreach ($entity_info['taxonomy_term']['view modes'] as $key => $value) {
$term_view_modes[$key] = $value['label'];
}
// User select which view mode to use for the term listing inside the bean.
$form['settings']['term_view_mode'] = array('#type' => 'select', '#title' => t('Taxonomy Term View Mode'), '#options' => $term_view_modes, '#default_value' => $bean->settings['term_view_mode'], '#required' => TRUE, '#multiple' => FALSE);
// User define a maximum number of terms to be shown.
$form['settings']['records_shown'] = array('#type' => 'textfield', '#title' => t('Records shown'), '#size' => 5, '#default_value' => $bean->settings['records_shown'], '#element_validate' => array('bean_tax_setting_is_numeric'));
$form['settings']['hide_empty'] = array('#type' => 'checkbox', '#title' => t('Do not display block if there are no results.'), '#default_value' => $bean->settings['hide_empty']);
return $form;
}
示例2: form
/**
* Builds extra settings for the block edit form.
*/
public function form($bean, $form, &$form_state)
{
// Here we are defining the form.
$form = array();
// Settings fieldset is used for configuring the 'related' bean output.
$form['settings'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('Output'), '#prefix' => '<div id="output-wrapper">', '#suffix' => '</div>');
// Instantiate entity info.
$entity_info = entity_get_info();
// Create a list of entity types that have view modes.
$entity_types = array();
foreach ($entity_info as $key => $value) {
if (!empty($value['view modes'])) {
$entity_types[$key] = $value['label'];
}
}
// Set a cache duration for the block.
$form['settings']['cache_duration'] = array('#type' => 'textfield', '#title' => t('Cache duration (in minutes)'), '#size' => 5, '#default_value' => $bean->settings['cache_duration'], '#required' => TRUE);
// User select how entites are related.
$form['settings']['related'] = array('#type' => 'select', '#title' => t('Related To'), '#options' => array('page' => 'Active Page', 'user' => 'Logged-in User'), '#default_value' => $bean->settings['related'], '#required' => TRUE, '#multiple' => FALSE);
// Determine if auth-user caching is appropriate.
$form['settings']['cache_auth_user'] = array('#type' => 'checkbox', '#title' => t('Cache this block for authenticated users.'), '#description' => t('Warning: This will create a cache record for every authenticated user that views this block.'), '#default_value' => $bean->settings['cache_auth_user'], '#states' => array('visible' => array(':input[name="settings[related]"]' => array('value' => 'user'))));
// Determine if anon-user caching is appropriate.
$form['settings']['cache_anon_user'] = array('#type' => 'checkbox', '#title' => t('Cache this block for anonymous users.'), '#description' => t('This will create a cache record for anonymous users that view this block.'), '#default_value' => $bean->settings['cache_anon_user'], '#states' => array('visible' => array(':input[name="settings[related]"]' => array('value' => 'user'))));
// User select which entity type to use for output.
$form['settings']['entity_type'] = array('#type' => 'select', '#title' => t('Entity Type'), '#options' => $entity_types, '#default_value' => $bean->settings['entity_type'], '#required' => TRUE, '#multiple' => FALSE, '#ajax' => array('callback' => 'bean_tax_entity_type_callback', 'wrapper' => 'output-wrapper', 'method' => 'replace'));
// Check for an ajax update and use new entity_type setting.
if (!isset($form_state['values']['settings']['entity_type'])) {
$entity_type = $bean->settings['entity_type'];
} else {
$entity_type = $form_state['values']['settings']['entity_type'];
}
// User select which view mode to use for the results inside the bean.
$form['settings']['entity_view_mode'] = array('#type' => 'select', '#title' => t('Entity View Mode'), '#options' => bean_tax_get_entity_view_modes($entity_info, $entity_type), '#default_value' => $bean->settings['entity_view_mode'], '#required' => TRUE, '#multiple' => FALSE);
// Determine what entity bundle types to display.
$form['settings']['bundle_types'] = array('#type' => 'select', '#title' => t('Entity Bundles'), '#options' => bean_tax_get_entity_bundles($entity_type), '#default_value' => $bean->settings['bundle_types'], '#required' => TRUE, '#multiple' => TRUE, '#size' => 5);
$form['settings']['hide_empty'] = array('#type' => 'checkbox', '#title' => t('Do not display block if there are no results.'), '#default_value' => $bean->settings['hide_empty']);
$form['settings']['unmatch_add'] = array('#type' => 'checkbox', '#title' => t('Append unrelated entities so there are more results.'), '#default_value' => $bean->settings['unmatch_add']);
// Select objects for the vocabularies that will be used.
$vocabulary = taxonomy_get_vocabularies();
$select_vocabulary_array = array();
foreach ($vocabulary as $item) {
$select_vocabulary_array[$item->machine_name] = $item->name;
}
// Define the filters fieldset.
$form['filters'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('Filters'));
// User define a maximum number of entities to be shown.
$form['filters']['records_shown'] = array('#type' => 'textfield', '#title' => t('Records shown'), '#size' => 5, '#default_value' => $bean->filters['records_shown'], '#element_validate' => array('bean_tax_setting_is_numeric'));
// User define a maximum number of entities to be shown.
$form['filters']['offset_results'] = array('#type' => 'textfield', '#title' => t('Offset Results'), '#size' => 5, '#default_value' => $bean->filters['offset_results'], '#element_validate' => array('bean_tax_setting_is_numeric'));
// Determine related taxonomy term vocabularies.
$form['filters']['vocabulary'] = array('#type' => 'select', '#title' => t('Vocabularies'), '#options' => $select_vocabulary_array, '#default_value' => $bean->filters['vocabulary'], '#required' => TRUE, '#multiple' => TRUE, '#size' => 5);
// Define a "read more" style link to be shown at the bottom of the bean.
$form['more_link'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('More link'));
// Link text shown on the 'more link' to be defined by user.
$form['more_link']['text'] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $bean->more_link['text']);
// Actual URL path for the 'more link' defined by user.
$form['more_link']['path'] = array('#type' => 'textfield', '#title' => t('Link path'), '#default_value' => $bean->more_link['path']);
return $form;
}
示例3: hook_fieldable_info
/**
* Expose fieldable object types.
*
* Inform the Field API about object types to which fields can be attached.
* @see hook_fieldable_info_alter().
*
* @return
* An array whose keys are fieldable object type names and whose values are
* arrays with the following key/value pairs:
* - label: The human-readable name of the type.
* - object keys: An array describing how the Field API can extract the
* informations it needs from the objects of the type.
* - id: The name of the property that contains the primary id of the
* object. Every object passed to the Field API must have this property
* and its value must be numeric.
* - revision: The name of the property that contains the revision id of
* the object. The Field API assumes that all revision ids are unique
* across all objects of a type.
* This element can be omitted if the objects of this type are not
* versionable.
* - bundle: The name of the property that contains the bundle name for the
* object. The bundle name defines which set of fields are attached to
* the object (e.g. what nodes call "content type").
* This element can be omitted if this type has no bundles (all objects
* have the same fields).
* - bundle keys: An array describing how the Field API can extract the
* informations it needs from the bundle objects for this type (e.g
* $vocabulary objects for terms; not applicable for nodes).
* This element can be omitted if this type's bundles do not exist as
* standalone objects.
* - bundle: The name of the property that contains the name of the bundle
* object.
* - cacheable: A boolean indicating whether Field API should cache
* loaded fields for each object, reducing the cost of
* field_attach_load().
* - bundles: An array describing all bundles for this object type.
* Keys are bundles machine names, as found in the objects' 'bundle'
* property (defined in the 'object keys' entry above).
* - label: The human-readable name of the bundle.
* - admin: An array of informations that allow Field UI pages (currently
* implemented in a contributed module) to attach themselves to the
* existing administration pages for the bundle.
* - path: the path of the bundle's main administration page, as defined
* in hook_menu(). If the path includes a placeholder for the bundle,
* the 'bundle argument', 'bundle helper' and 'real path' keys below
* are required.
* - bundle argument: The position of the placeholder in 'path', if any.
* - real path: The actual path (no placeholder) of the bundle's main
* administration page. This will be used to generate links.
* - access callback: As in hook_menu(). 'user_access' will be assumed if
* no value is provided.
* - access arguments: As in hook_menu().
*/
function hook_fieldable_info()
{
$return = array('taxonomy_term' => array('label' => t('Taxonomy term'), 'object keys' => array('id' => 'tid', 'bundle' => 'vocabulary_machine_name'), 'bundle keys' => array('bundle' => 'machine_name'), 'bundles' => array()));
foreach (taxonomy_get_vocabularies() as $vocabulary) {
$return['taxonomy_term']['bundles'][$vocabulary->machine_name] = array('label' => $vocabulary->name, 'admin' => array('path' => 'admin/structure/taxonomy/%taxonomy_vocabulary', 'real path' => 'admin/structure/taxonomy/' . $vocabulary->vid, 'bundle argument' => 3, 'access arguments' => array('administer taxonomy')));
}
return $return;
}
示例4: light_print_terms
function light_print_terms($nid)
{
$vocabularies = taxonomy_get_vocabularies();
$output = '';
foreach ($vocabularies as $vocabulary) {
if ($vocabularies) {
$terms = taxonomy_node_get_terms_by_vocabulary($nid, $vocabulary->vid);
if ($terms) {
$links = array();
//$output .= '' . $vocabulary->name . ': ';
foreach ($terms as $term) {
$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
}
$output .= implode(', ', $links);
}
}
}
return $output;
}
示例5: tac_admin
function tac_admin($form, $form_state, $rid = NULL)
{
$vocabularyObjects = taxonomy_get_vocabularies();
$vocabularies = array(-1 => '[Select One]');
foreach ($vocabularyObjects as $vocabularyObject) {
$vocabularies[$vocabularyObject->vid] = $vocabularyObject->name;
}
$vocabulary = variable_get('tac_vocabulary', -1);
$form = array();
$form[] = array('vocabulary' => array('#type' => 'select', '#options' => $vocabularies, '#title' => t('Vocabulary to use for Access Control'), '#default_value' => $vocabulary));
if ($vocabulary > 0) {
$query = db_select('tac_map', 'm');
$query->fields('m');
$data = $query->execute()->fetchAll();
$currentValues = array();
foreach ($data as $row) {
$currentValues[$row->rid][$row->tid] = $row;
}
$user_roles = user_roles();
$role_permissions = user_role_permissions($user_roles);
foreach ($user_roles as $rid => $role) {
if ($rid == DRUPAL_ANONYMOUS_RID) {
continue;
}
if (isset($role_permissions[$rid]['bypass node access']) && $role_permissions[$rid]['bypass node access']) {
continue;
}
$subform = array('#theme' => 'tac_term_list', '#title' => 'Permissions for role "' . $role . '"');
foreach (taxonomy_get_tree($vocabulary) as $term) {
$subform['term_' . $term->tid] = array('#title' => $term->name, 'list' => array('#parents' => array('edit', $rid, $term->tid, 'list'), '#type' => 'checkbox', '#default_value' => isset($currentValues[$rid][$term->tid]->grant_list) ? $currentValues[$rid][$term->tid]->grant_list : 0), 'create' => array('#parents' => array('edit', $rid, $term->tid, 'create'), '#type' => 'checkbox', '#default_value' => isset($currentValues[$rid][$term->tid]->grant_create) ? $currentValues[$rid][$term->tid]->grant_create : 0), 'update' => array('#parents' => array('edit', $rid, $term->tid, 'update'), '#type' => 'checkbox', '#default_value' => isset($currentValues[$rid][$term->tid]->grant_update) ? $currentValues[$rid][$term->tid]->grant_update : 0), 'delete' => array('#parents' => array('edit', $rid, $term->tid, 'delete'), '#type' => 'checkbox', '#default_value' => isset($currentValues[$rid][$term->tid]->grant_delete) ? $currentValues[$rid][$term->tid]->grant_delete : 0));
}
$form['role' . $rid] = $subform;
}
}
$form[] = array('#type' => 'submit', '#value' => t('Submit'));
return $form;
}
示例6: readDrupal6SiteProperties
/**
* Drupal 6
*/
protected function readDrupal6SiteProperties()
{
$node_types = node_get_types();
$fields = content_fields();
foreach ($node_types as $bundle => $entity_info) {
$field_types = content_types($bundle);
$instances = array();
foreach ($field_types['fields'] as $fieldName => $fieldInfo) {
$instance = array('entity_type' => 'node', 'bundle' => $bundle, 'field_name' => $fieldName, 'label' => $fieldInfo['widget']['label'], 'description' => $fieldInfo['widget']['description'], 'widget' => array('type' => $fieldInfo['widget']['type'], 'settings' => array()));
$instances[$fieldName] = $this->processInstance($instance);
}
$this->entityTypes[] = new NodeTypeBuilder($bundle, $entity_info->name, $entity_info->description, $instances);
}
$vocs = taxonomy_get_vocabularies();
foreach ($vocs as $bundle => $entity_info) {
$this->entityTypes[] = new VocabularyBuilder($entity_info->vid, $entity_info->name, $entity_info->description);
}
foreach ($fields as $fieldName => $fieldInfo) {
$this->fields[] = new FieldBuilder($fieldName, $fieldInfo['type']);
}
$this->parseDefinition();
}
示例7: phptemplate_settings
//.........这里部分代码省略.........
// Node Settings
$form['tnt_container']['node_type_specific'] = array('#type' => 'fieldset', '#title' => t('Node settings'), '#description' => t('Here you can make adjustments to which information is shown with your content, and how it is displayed. You can modify these settings so they apply to all content types, or check the "Use content-type specific settings" box to customize them for each content type. For example, you may want to show the date on stories, but not pages.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Author & Date Settings
$form['tnt_container']['node_type_specific']['submitted_by_container'] = array('#type' => 'fieldset', '#title' => t('Author & date'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_author_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display author\'s username'), '#default_value' => $settings["submitted_by_author_{$type}"]);
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_date_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display date posted (you can customize this format on your Date and Time settings page)'), '#default_value' => $settings["submitted_by_date_{$type}"]);
// Options for default settings
if ($type == 'default') {
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#title'] = t('Default');
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#collapsed'] = $settings['submitted_by_enable_content_type'] ? TRUE : FALSE;
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['submitted_by_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['submitted_by_enable_content_type']);
} else {
if ($settings['submitted_by_enable_content_type'] == 0) {
$form['submitted_by'][$type]['#collapsed'] = TRUE;
}
}
}
// Taxonomy Settings
if (module_exists('taxonomy')) {
$form['tnt_container']['node_type_specific']['display_taxonomy_container'] = array('#type' => 'fieldset', '#title' => t('Taxonomy terms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
// taxonomy display per node
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
// display
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_display_{$type}"] = array('#type' => 'select', '#title' => t('When should taxonomy terms be displayed?'), '#default_value' => $settings["taxonomy_display_{$type}"], '#options' => array('never' => t('Never display taxonomy terms'), 'all' => t('Always display taxonomy terms'), 'only' => t('Only display taxonomy terms on full node pages')));
// format
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_format_{$type}"] = array('#type' => 'radios', '#title' => t('Taxonomy display format'), '#default_value' => $settings["taxonomy_format_{$type}"], '#options' => array('vocab' => t('Display each vocabulary on a new line'), 'list' => t('Display all taxonomy terms together in single list')));
// Get taxonomy vocabularies by node type
$vocabs = array();
$vocabs_by_type = $type == 'default' ? taxonomy_get_vocabularies() : taxonomy_get_vocabularies($type);
foreach ($vocabs_by_type as $key => $value) {
$vocabs[$value->vid] = $value->name;
}
// Display taxonomy checkboxes
foreach ($vocabs as $key => $vocab_name) {
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_vocab_display_{$type}_{$key}"] = array('#type' => 'checkbox', '#title' => t('Display vocabulary: ' . $vocab_name), '#default_value' => $settings["taxonomy_vocab_display_{$type}_{$key}"]);
}
// Options for default settings
if ($type == 'default') {
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#title'] = t('Default');
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#collapsed'] = $settings['taxonomy_enable_content_type'] ? TRUE : FALSE;
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['taxonomy_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['taxonomy_enable_content_type']);
} else {
if ($settings['taxonomy_enable_content_type'] == 0) {
$form['display_taxonomy'][$type]['#collapsed'] = TRUE;
}
}
}
}
// Read More & Comment Link Settings
$form['tnt_container']['node_type_specific']['link_settings'] = array('#type' => 'fieldset', '#title' => t('Links'), '#description' => t('Customize the text of node links'), '#collapsible' => TRUE, '#collapsed' => FALSE);
// Read more link settings
$form['tnt_container']['node_type_specific']['link_settings']['readmore'] = array('#type' => 'fieldset', '#title' => t('“Read more”'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
// Read more
$form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["readmore_{$type}"], '#description' => t('HTML is allowed.'));
$form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["readmore_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
$form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["readmore_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
$form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["readmore_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
// Options for default settings
示例8: csa_base_preprocess_node
/**
* Implementation of template_preprocess_node().
*/
function csa_base_preprocess_node(&$variables)
{
// Add meaningfull classes to the node.
$node_classes = array();
$node_classes[] = 'node';
$node_classes[] = 'node-' . $variables['node']->type;
if (empty($variables['status'])) {
$node_classes[] = 'node-unpublished';
}
$variables['node_classes'] = implode(' ', $node_classes);
// Date & author.
$date = t('Posted ') . format_date($variables['node']->created, 'medium');
// Format date as small, medium, or large
$author = theme('username', $variables['node']);
$author_only_separator = t('Posted by ');
$author_date_separator = t(' by ');
$submitted_by_content_type = theme_get_setting('submitted_by_enable_content_type') == 1 ? $variables['node']->type : 'default';
$date_setting = theme_get_setting('submitted_by_date_' . $submitted_by_content_type) == 1;
$author_setting = theme_get_setting('submitted_by_author_' . $submitted_by_content_type) == 1;
$author_separator = $date_setting ? $author_date_separator : $author_only_separator;
$date_author = $date_setting ? $date : '';
$date_author .= $author_setting ? $author_separator . $author : '';
$variables['submitted'] = $date_author;
if (theme_get_setting('hide_front_page_title') && drupal_is_front_page()) {
$variables['submitted'] = NULL;
}
$taxonomy_content_type = theme_get_setting('taxonomy_enable_content_type') == 1 ? $variables['node']->type : 'default';
$taxonomy_display = theme_get_setting('taxonomy_display_' . $taxonomy_content_type);
$taxonomy_format = theme_get_setting('taxonomy_format_' . $taxonomy_content_type);
$taxonomy_format_links = theme_get_setting('taxonomy_format_links');
if (module_exists('taxonomy') && ($taxonomy_display == 'all' || $taxonomy_display == 'only' && $variables['page'])) {
$output = array();
$vocabularies = taxonomy_get_vocabularies($variables['node']->type);
foreach ($vocabularies as $vocabulary) {
if (theme_get_setting('taxonomy_vocab_display_' . $taxonomy_content_type . '_' . $vocabulary->vid)) {
$terms = taxonomy_node_get_terms_by_vocabulary($variables['node'], $vocabulary->vid);
if ($terms) {
$links = array();
foreach ($terms as $term) {
$links[] = array('data' => l($term->name, taxonomy_term_path($term), array('attributes' => array('rel' => 'tag', 'title' => strip_tags($term->description)))), 'class' => 'vocab-term');
}
if ($taxonomy_format == 'vocab') {
$data = theme_get_setting('taxonomy_display_vocab_name') ? '<span class="vocab-name">' . $vocabulary->name . ':</span> ' : '';
$class = array('vocab');
$children = array();
if ($taxonomy_format_links) {
$class[] = 'links';
$children = $links;
} else {
$term_list = array();
foreach ($links as $link) {
$term_list[] = $link['data'];
}
$data .= implode(theme_get_setting('taxonomy_format_delimiter'), $term_list);
}
$output[] = array('data' => $data, 'class' => implode(' ', $class), 'id' => 'vocab-' . $vocabulary->vid, 'children' => $children);
} else {
$output = array_merge($links, $output);
}
}
}
}
$variables['terms'] = theme('item_list', $output, null, 'ul', array('class' => 'taxonomy'));
} else {
$variables['terms'] = '';
}
}
示例9: taxonomy_get_vocabularies
<?php
}
?>
<!-- CONTENT START -->
<div data-role="content">
<?php
$output = "";
$output = $output . "<!-- CONTENT CATEGORY START -->";
$output = $output . "<section class=\"content-category-ny\">";
$output = $output . "<div class=\"container\">";
$output = $output . "<div class=\"row\">";
$vocabularies = taxonomy_get_vocabularies();
if ($vocabularies) {
foreach ($vocabularies as $vocabulary) {
if ($vocabulary->name == "Kategori") {
$terms = taxonomy_get_tree($vocabulary->vid, $parent = 0, $max_depth = 1, $load_entities = FALSE);
if ($terms) {
$output = $output . "<ul class=\"list-unstyled\">";
foreach ($terms as $term) {
switch ($term->tid) {
case "2925":
// DONT SHOW
break;
case "3013":
// DONT SHOW
break;
default:
示例10: acquia_marina_preprocess_node
function acquia_marina_preprocess_node(&$vars)
{
// Build array of handy node classes
$node_classes = array();
$node_classes[] = $vars['zebra'];
// Node is odd or even
$node_classes[] = !$vars['node']->status ? 'node-unpublished' : '';
// Node is unpublished
$node_classes[] = $vars['sticky'] ? 'sticky' : '';
// Node is sticky
$node_classes[] = isset($vars['node']->teaser) ? 'teaser' : 'full-node';
// Node is teaser or full-node
$node_classes[] = 'node-type-' . $vars['node']->type;
// Node is type-x, e.g., node-type-page
$node_classes = array_filter($node_classes);
// Remove empty elements
$vars['node_classes'] = implode(' ', $node_classes);
// Implode class list with spaces
// Add node_bottom region content
$vars['node_bottom'] = theme('blocks', 'node_bottom');
// Node Theme Settings
// Date & author
if (!module_exists('submitted_by')) {
$date = t('Posted ') . format_date($vars['node']->created, 'medium');
// Format date as small, medium, or large
$author = theme('username', $vars['node']);
$author_only_separator = t('Posted by ');
$author_date_separator = t(' by ');
$submitted_by_content_type = theme_get_setting('submitted_by_enable_content_type') == 1 ? $vars['node']->type : 'default';
$date_setting = theme_get_setting('submitted_by_date_' . $submitted_by_content_type) == 1;
$author_setting = theme_get_setting('submitted_by_author_' . $submitted_by_content_type) == 1;
$author_separator = $date_setting ? $author_date_separator : $author_only_separator;
$date_author = $date_setting ? $date : '';
$date_author .= $author_setting ? $author_separator . $author : '';
$vars['submitted'] = $date_author;
}
// Taxonomy
$taxonomy_content_type = theme_get_setting('taxonomy_enable_content_type') == 1 ? $vars['node']->type : 'default';
$taxonomy_display = theme_get_setting('taxonomy_display_' . $taxonomy_content_type);
$taxonomy_format = theme_get_setting('taxonomy_format_' . $taxonomy_content_type);
if (module_exists('taxonomy') && ($taxonomy_display == 'all' || $taxonomy_display == 'only' && $vars['page'])) {
$vocabularies = taxonomy_get_vocabularies($vars['node']->type);
$output = '';
$term_delimiter = ', ';
foreach ($vocabularies as $vocabulary) {
if (theme_get_setting('taxonomy_vocab_hide_' . $taxonomy_content_type . '_' . $vocabulary->vid) != 1) {
$terms = taxonomy_node_get_terms_by_vocabulary($vars['node'], $vocabulary->vid);
if ($terms) {
$term_items = '';
foreach ($terms as $term) {
// Build vocabulary term items
$term_link = l($term->name, taxonomy_term_path($term), array('attributes' => array('rel' => 'tag', 'title' => strip_tags($term->description))));
$term_items .= '<li class="vocab-term">' . $term_link . $term_delimiter . '</li>';
}
if ($taxonomy_format == 'vocab') {
// Add vocabulary labels if separate
$output .= '<li class="vocab vocab-' . $vocabulary->vid . '"><span class="vocab-name">' . $vocabulary->name . ':</span> <ul class="vocab-list">';
$output .= substr_replace($term_items, '</li>', -(strlen($term_delimiter) + 5)) . '</ul></li>';
} else {
$output .= $term_items;
}
}
}
}
if ($output != '') {
$output = $taxonomy_format == 'list' ? substr_replace($output, '</li>', -(strlen($term_delimiter) + 5)) : $output;
$output = '<ul class="taxonomy">' . $output . '</ul>';
}
$vars['terms'] = $output;
} else {
$vars['terms'] = '';
}
// Node Links
if (isset($vars['node']->links['node_read_more'])) {
$node_content_type = theme_get_setting('readmore_enable_content_type') == 1 ? $vars['node']->type : 'default';
$vars['node']->links['node_read_more'] = array('title' => acquia_marina_themesettings_link(theme_get_setting('readmore_prefix_' . $node_content_type), theme_get_setting('readmore_suffix_' . $node_content_type), t(theme_get_setting('readmore_' . $node_content_type)), 'node/' . $vars['node']->nid, array('attributes' => array('title' => t(theme_get_setting('readmore_title_' . $node_content_type))), 'query' => NULL, 'fragment' => NULL, 'absolute' => FALSE, 'html' => TRUE)), 'attributes' => array('class' => 'readmore-item'), 'html' => TRUE);
}
if (isset($vars['node']->links['comment_add'])) {
$node_content_type = theme_get_setting('comment_enable_content_type') == 1 ? $vars['node']->type : 'default';
if ($vars['teaser']) {
$vars['node']->links['comment_add'] = array('title' => acquia_marina_themesettings_link(theme_get_setting('comment_add_prefix_' . $node_content_type), theme_get_setting('comment_add_suffix_' . $node_content_type), t(theme_get_setting('comment_add_' . $node_content_type)), "comment/reply/" . $vars['node']->nid, array('attributes' => array('title' => t(theme_get_setting('comment_add_title_' . $node_content_type))), 'query' => NULL, 'fragment' => 'comment-form', 'absolute' => FALSE, 'html' => TRUE)), 'attributes' => array('class' => 'comment-add-item'), 'html' => TRUE);
} else {
$vars['node']->links['comment_add'] = array('title' => acquia_marina_themesettings_link(theme_get_setting('comment_node_prefix_' . $node_content_type), theme_get_setting('comment_node_suffix_' . $node_content_type), t(theme_get_setting('comment_node_' . $node_content_type)), "comment/reply/" . $vars['node']->nid, array('attributes' => array('title' => t(theme_get_setting('comment_node_title_' . $node_content_type))), 'query' => NULL, 'fragment' => 'comment-form', 'absolute' => FALSE, 'html' => TRUE)), 'attributes' => array('class' => 'comment-node-item'), 'html' => TRUE);
}
}
if (isset($vars['node']->links['comment_new_comments'])) {
$node_content_type = theme_get_setting('comment_enable_content_type') == 1 ? $vars['node']->type : 'default';
$vars['node']->links['comment_new_comments'] = array('title' => acquia_marina_themesettings_link(theme_get_setting('comment_new_prefix_' . $node_content_type), theme_get_setting('comment_new_suffix_' . $node_content_type), format_plural(comment_num_new($vars['node']->nid), t(theme_get_setting('comment_new_singular_' . $node_content_type)), t(theme_get_setting('comment_new_plural_' . $node_content_type))), "node/" . $vars['node']->nid, array('attributes' => array('title' => t(theme_get_setting('comment_new_title_' . $node_content_type))), 'query' => NULL, 'fragment' => 'new', 'absolute' => FALSE, 'html' => TRUE)), 'attributes' => array('class' => 'comment-new-item'), 'html' => TRUE);
}
if (isset($vars['node']->links['comment_comments'])) {
$node_content_type = theme_get_setting('comment_enable_content_type') == 1 ? $vars['node']->type : 'default';
$vars['node']->links['comment_comments'] = array('title' => acquia_marina_themesettings_link(theme_get_setting('comment_prefix_' . $node_content_type), theme_get_setting('comment_suffix_' . $node_content_type), format_plural(comment_num_all($vars['node']->nid), t(theme_get_setting('comment_singular_' . $node_content_type)), t(theme_get_setting('comment_plural_' . $node_content_type))), "node/" . $vars['node']->nid, array('attributes' => array('title' => t(theme_get_setting('comment_title_' . $node_content_type))), 'query' => NULL, 'fragment' => 'comments', 'absolute' => FALSE, 'html' => TRUE)), 'attributes' => array('class' => 'comment-item'), 'html' => TRUE);
}
$vars['links'] = theme('links', $vars['node']->links, array('class' => 'links inline'));
}
示例11: zeropoint_preprocess_node
function zeropoint_preprocess_node(&$vars)
{
$vars['template_files'][] = 'node-' . $vars['nid'];
//print_r($vars);
if ($vars['user']->uid) {
$vars['content'] = preg_replace('~<foranonym>.*</foranonym>~s', '', $vars['content']);
}
$vars['content'] = preg_replace('~"http://baza-voprosov.ru/~', '"/', $vars['content']);
// Build array of handy node classes
$node_classes = array();
$node_classes[] = $vars['zebra'];
// Node is odd or even
$node_classes[] = !$vars['node']->status ? 'node-unpublished' : '';
// Node is unpublished
$node_classes[] = $vars['sticky'] ? 'sticky' : '';
// Node is sticky
$node_classes[] = isset($vars['node']->teaser) ? 'teaser' : 'full-node';
// Node is teaser or full-node
$node_classes[] = 'node-type-' . $vars['node']->type;
// Node is type-x, e.g., node-type-page
// Add any taxonomy terms for node teasers
if ($vars['teaser'] && isset($vars['taxonomy'])) {
foreach ($vars['taxonomy'] as $taxonomy_id_string => $term_info) {
$taxonomy_id = array_pop(explode('_', $taxonomy_id_string));
$node_classes[] = 'tag-' . $taxonomy_id;
// Node teaser has terms (tag-x)
// $taxonomy_name = id_safe($term_info['title']);
// if ($taxonomy_name) {
// $node_classes[] = 'tag-'. $taxonomy_name; // Node teaser has terms (tag-name)
// }
}
}
$node_classes = array_filter($node_classes);
// Remove empty elements
$vars['node_classes'] = implode(' ', $node_classes);
// Implode class list with spaces
// Add node regions
$vars['node_middle'] = theme('blocks', 'node_middle');
$vars['node_bottom'] = theme('blocks', 'node_bottom');
// Render Ubercart fields into separate variables for node-product.tpl.php
if (module_exists('uc_product') && uc_product_is_product($vars) && $vars['template_files'][0] == 'node-product') {
$node = node_build_content(node_load($vars['nid']));
$vars['uc_image'] = drupal_render($node->content['image']);
$vars['uc_body'] = drupal_render($node->content['body']);
$vars['uc_display_price'] = drupal_render($node->content['display_price']);
$vars['uc_add_to_cart'] = drupal_render($node->content['add_to_cart']);
$vars['uc_weight'] = drupal_render($node->content['weight']);
$vars['uc_dimensions'] = drupal_render($node->content['dimensions']);
$vars['uc_model'] = drupal_render($node->content['model']);
$vars['uc_list_price'] = drupal_render($node->content['list_price']);
$vars['uc_sell_price'] = drupal_render($node->content['sell_price']);
$vars['uc_cost'] = drupal_render($node->content['cost']);
$vars['uc_additional'] = drupal_render($node->content);
}
// Node Theme Settings
// Date & author
if (!module_exists('submitted_by')) {
$date = t('') . format_date($vars['node']->created, 'medium');
// Format date as small, medium, or large
$author = theme('username', $vars['node']);
$author_only_separator = t('');
$author_date_separator = t(' — ');
$submitted_by_content_type = theme_get_setting('submitted_by_enable_content_type') == 1 ? $vars['node']->type : 'default';
$date_setting = theme_get_setting('submitted_by_date_' . $submitted_by_content_type) == 1;
$author_setting = theme_get_setting('submitted_by_author_' . $submitted_by_content_type) == 1;
$author_separator = $date_setting ? $author_date_separator : $author_only_separator;
$date_author = $date_setting ? $date : '';
$date_author .= $author_setting ? $author_separator . $author : '';
$vars['submitted'] = $date_author;
}
// Taxonomy
$taxonomy_content_type = theme_get_setting('taxonomy_enable_content_type') == 1 ? $vars['node']->type : 'default';
$taxonomy_display = theme_get_setting('taxonomy_display_' . $taxonomy_content_type);
$taxonomy_format = theme_get_setting('taxonomy_format_' . $taxonomy_content_type);
if (module_exists('taxonomy') && ($taxonomy_display == 'all' || $taxonomy_display == 'only' && $vars['page'])) {
$vocabularies = taxonomy_get_vocabularies($vars['node']->type);
$output = '';
$term_delimiter = ' | ';
foreach ($vocabularies as $vocabulary) {
if (theme_get_setting('taxonomy_vocab_hide_' . $taxonomy_content_type . '_' . $vocabulary->vid) != 1) {
$terms = taxonomy_node_get_terms_by_vocabulary($vars['node'], $vocabulary->vid);
if ($terms) {
$term_items = '';
foreach ($terms as $term) {
// Build vocabulary term items
$term_link = l($term->name, taxonomy_term_path($term), array('attributes' => array('rel' => 'tag', 'title' => strip_tags($term->description))));
$term_items .= '<li class="vocab-term">' . $term_link . $term_delimiter . '</li>';
}
if ($taxonomy_format == 'vocab') {
// Add vocabulary labels if separate
$output .= '<li class="vocab vocab-' . $vocabulary->vid . '"><span class="vocab-name">' . check_plain($vocabulary->name) . ':</span> <ul class="vocab-list">';
//$output .= '<li class="vocab vocab-'. $vocabulary->vid .'"> <ul class="vocab-list">';
$output .= substr_replace($term_items, '</li>', -(strlen($term_delimiter) + 5)) . '</ul></li>';
} else {
$output .= $term_items;
}
}
}
}
if ($output != '') {
//.........这里部分代码省略.........
示例12: phptemplate_settings
//.........这里部分代码省略.........
// Node Settings
$form['tnt_container']['node_type_specific'] = array('#type' => 'fieldset', '#title' => t('Node settings'), '#description' => t('Here you can make adjustments to which information is shown with your content, and how it is displayed. You can modify these settings so they apply to all content types, or check the "Use content-type specific settings" box to customize them for each content type. For example, you may want to show the date on stories, but not pages.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
// Author & Date Settings
$form['tnt_container']['node_type_specific']['submitted_by_container'] = array('#type' => 'fieldset', '#title' => t('Author & date'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_author_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display author\'s username'), '#default_value' => $settings["submitted_by_author_{$type}"]);
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_date_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display date posted (you can customize this format on your Date and Time settings page)'), '#default_value' => $settings["submitted_by_date_{$type}"]);
// Options for default settings
if ($type == 'default') {
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#title'] = t('Default');
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#collapsed'] = $settings['submitted_by_enable_content_type'] ? TRUE : FALSE;
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['submitted_by_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['submitted_by_enable_content_type']);
} else {
if ($settings['submitted_by_enable_content_type'] == 0) {
$form['submitted_by'][$type]['#collapsed'] = TRUE;
}
}
}
// Taxonomy Settings
if (module_exists('taxonomy')) {
$form['tnt_container']['node_type_specific']['display_taxonomy_container'] = array('#type' => 'fieldset', '#title' => t('Taxonomy terms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
// taxonomy display per node
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
// display
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_display_{$type}"] = array('#type' => 'select', '#title' => t('When should taxonomy terms be displayed?'), '#default_value' => $settings["taxonomy_display_{$type}"], '#options' => array('' => '', 'never' => t('Never display taxonomy terms'), 'all' => t('Always display taxonomy terms'), 'only' => t('Only display taxonomy terms on full node pages')));
// format
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_format_{$type}"] = array('#type' => 'radios', '#title' => t('Taxonomy display format'), '#default_value' => $settings["taxonomy_format_{$type}"], '#options' => array('vocab' => t('Display each vocabulary on a new line'), 'list' => t('Display all taxonomy terms together in single list')));
// Get taxonomy vocabularies by node type
$vocabs = array();
$vocabs_by_type = $type == 'default' ? taxonomy_get_vocabularies() : taxonomy_get_vocabularies($type);
foreach ($vocabs_by_type as $key => $value) {
$vocabs[$value->vid] = $value->name;
}
// Display taxonomy checkboxes
foreach ($vocabs as $key => $vocab_name) {
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_vocab_display_{$type}_{$key}"] = array('#type' => 'checkbox', '#title' => t('Display vocabulary: ' . $vocab_name), '#default_value' => $settings["taxonomy_vocab_display_{$type}_{$key}"]);
}
// Options for default settings
if ($type == 'default') {
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#title'] = t('Default');
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#collapsed'] = $settings['taxonomy_enable_content_type'] ? TRUE : FALSE;
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['taxonomy_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['taxonomy_enable_content_type']);
} else {
if ($settings['taxonomy_enable_content_type'] == 0) {
$form['display_taxonomy'][$type]['#collapsed'] = TRUE;
}
}
}
}
// Read More & Comment Link Settings
$form['tnt_container']['node_type_specific']['link_settings'] = array('#type' => 'fieldset', '#title' => t('Links'), '#description' => t('Customize the text of node links'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Read more link settings
$form['tnt_container']['node_type_specific']['link_settings']['readmore'] = array('#type' => 'fieldset', '#title' => t('“Read more”'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
// Read more
$form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["readmore_{$type}"], '#description' => t('HTML is allowed.'));
$form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["readmore_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
$form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["readmore_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
$form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["readmore_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
// Options for default settings
示例13: acquia_marina_settings
/**
* Implementation of THEMEHOOK_settings() function.
*
* @param $saved_settings
* array An array of saved settings for this theme.
* @return
* array A form array.
*/
function acquia_marina_settings($saved_settings)
{
global $base_url;
// Retrieve & combine default and saved theme settings
$defaults = acquia_marina_default_theme_settings();
$settings = array_merge($defaults, $saved_settings);
// Create theme settings form widgets using Forms API
// TNT Fieldset
$form['tnt_container'] = array('#type' => 'fieldset', '#title' => t('Acquia Marina settings'), '#description' => t('Use these settings to change what and how information is displayed in your theme.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
// General Settings
$form['tnt_container']['general_settings'] = array('#type' => 'fieldset', '#title' => t('General settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
// Mission Statement
$form['tnt_container']['general_settings']['mission_statement'] = array('#type' => 'fieldset', '#title' => t('Mission statement'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['tnt_container']['general_settings']['mission_statement']['mission_statement_pages'] = array('#type' => 'radios', '#title' => t('Where should your mission statement be displayed?'), '#default_value' => $settings['mission_statement_pages'], '#options' => array('home' => t('Display mission statement only on front page'), 'all' => t('Display mission statement on all pages')));
// Breadcrumb
$form['tnt_container']['general_settings']['breadcrumb'] = array('#type' => 'fieldset', '#title' => t('Breadcrumb'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['tnt_container']['general_settings']['breadcrumb']['breadcrumb_display'] = array('#type' => 'checkbox', '#title' => t('Display breadcrumb'), '#default_value' => $settings['breadcrumb_display']);
// Username
$form['tnt_container']['general_settings']['username'] = array('#type' => 'fieldset', '#title' => t('Username'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['tnt_container']['general_settings']['username']['user_notverified_display'] = array('#type' => 'checkbox', '#title' => t('Display "not verified" for unregistered usernames'), '#default_value' => $settings['user_notverified_display']);
// Search Settings
if (module_exists('search')) {
$form['tnt_container']['general_settings']['search_container'] = array('#type' => 'fieldset', '#title' => t('Search results'), '#description' => t('What additional information should be displayed on your search results page?'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['tnt_container']['general_settings']['search_container']['search_results']['search_snippet'] = array('#type' => 'checkbox', '#title' => t('Display text snippet'), '#default_value' => $settings['search_snippet']);
$form['tnt_container']['general_settings']['search_container']['search_results']['search_info_type'] = array('#type' => 'checkbox', '#title' => t('Display content type'), '#default_value' => $settings['search_info_type']);
$form['tnt_container']['general_settings']['search_container']['search_results']['search_info_user'] = array('#type' => 'checkbox', '#title' => t('Display author name'), '#default_value' => $settings['search_info_user']);
$form['tnt_container']['general_settings']['search_container']['search_results']['search_info_date'] = array('#type' => 'checkbox', '#title' => t('Display posted date'), '#default_value' => $settings['search_info_date']);
$form['tnt_container']['general_settings']['search_container']['search_results']['search_info_comment'] = array('#type' => 'checkbox', '#title' => t('Display comment count'), '#default_value' => $settings['search_info_comment']);
$form['tnt_container']['general_settings']['search_container']['search_results']['search_info_upload'] = array('#type' => 'checkbox', '#title' => t('Display attachment count'), '#default_value' => $settings['search_info_upload']);
}
// Node Settings
$form['tnt_container']['node_type_specific'] = array('#type' => 'fieldset', '#title' => t('Node settings'), '#description' => t('Here you can make adjustments to which information is shown with your content, and how it is displayed. You can modify these settings so they apply to all content types, or check the "Use content-type specific settings" box to customize them for each content type. For example, you may want to show the date on stories, but not pages.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
// Author & Date Settings
$form['tnt_container']['node_type_specific']['submitted_by_container'] = array('#type' => 'fieldset', '#title' => t('Author and date'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
if (module_exists('submitted_by') == FALSE) {
foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_author_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display author\'s username'), '#default_value' => $settings["submitted_by_author_{$type}"]);
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_date_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display date posted (you can customize this format on your Date and Time settings page)'), '#default_value' => $settings["submitted_by_date_{$type}"]);
// Options for default settings
if ($type == 'default') {
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#title'] = t('Default');
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#collapsed'] = $settings['submitted_by_enable_content_type'] ? TRUE : FALSE;
$form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['submitted_by_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['submitted_by_enable_content_type']);
} else {
if ($settings['submitted_by_enable_content_type'] == 0) {
$form['submitted_by'][$type]['#collapsed'] = TRUE;
}
}
}
} else {
$form['tnt_container']['node_type_specific']['submitted_by_container']['#description'] = 'NOTICE: You currently have the "Submitted By" module installed and enabled, so the Author & Date theme settings have been disabled to prevent conflicts. If you wish to re-enable the Author & Date theme settings, you must first disable the "Submitted By" module.';
}
// Taxonomy Settings
if (module_exists('taxonomy')) {
$form['tnt_container']['node_type_specific']['display_taxonomy_container'] = array('#type' => 'fieldset', '#title' => t('Taxonomy terms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
// taxonomy display per node
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
// display
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_display_{$type}"] = array('#type' => 'select', '#title' => t('When should taxonomy terms be displayed?'), '#default_value' => $settings["taxonomy_display_{$type}"], '#options' => array('' => '', 'never' => t('Never display taxonomy terms'), 'all' => t('Always display taxonomy terms'), 'only' => t('Only display taxonomy terms on full node pages')));
// format
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_format_{$type}"] = array('#type' => 'radios', '#title' => t('Taxonomy display format'), '#default_value' => $settings["taxonomy_format_{$type}"], '#options' => array('vocab' => t('Display each vocabulary on a new line'), 'list' => t('Display all taxonomy terms together in single list')));
// Get taxonomy vocabularies by node type
$vocabs = array();
$vocabs_by_type = $type == 'default' ? taxonomy_get_vocabularies() : taxonomy_get_vocabularies($type);
foreach ($vocabs_by_type as $key => $value) {
$vocabs[$value->vid] = $value->name;
}
// Display taxonomy checkboxes
foreach ($vocabs as $key => $vocab_name) {
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_vocab_hide_{$type}_{$key}"] = array('#type' => 'checkbox', '#title' => t('Hide vocabulary: ' . $vocab_name), '#default_value' => $settings["taxonomy_vocab_hide_{$type}_{$key}"]);
}
// Options for default settings
if ($type == 'default') {
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#title'] = t('Default');
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#collapsed'] = $settings['taxonomy_enable_content_type'] ? TRUE : FALSE;
$form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['taxonomy_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['taxonomy_enable_content_type']);
} else {
if ($settings['taxonomy_enable_content_type'] == 0) {
$form['display_taxonomy'][$type]['#collapsed'] = TRUE;
}
}
}
}
// Read More & Comment Link Settings
$form['tnt_container']['node_type_specific']['link_settings'] = array('#type' => 'fieldset', '#title' => t('Links'), '#description' => t('Customize the text of node links'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Read more link settings
$form['tnt_container']['node_type_specific']['link_settings']['readmore'] = array('#type' => 'fieldset', '#title' => t('"Read more"'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
//.........这里部分代码省略.........
示例14: saveToActiveStore
/**
* Implements Drupal\configuration\Config\Configuration::saveToActiveStore().
*/
public function saveToActiveStore(ConfigIteratorSettings &$settings)
{
$vocabulary = (object) $this->getData();
if (!empty($vocabulary->vid)) {
unset($vocabulary->vid);
}
$existing = taxonomy_get_vocabularies();
foreach ($existing as $existing_vocab) {
if ($existing_vocab->machine_name === $vocabulary->machine_name) {
$vocabulary->vid = $existing_vocab->vid;
break;
}
}
taxonomy_vocabulary_save($vocabulary);
$settings->addInfo('imported', $this->getUniqueId());
}
示例15: csa_base_settings
function csa_base_settings($saved_settings, $subtheme_defaults = array())
{
// Get the node types
$node_types = node_get_types('names');
// Get the default values from the .info file.
$defaults = csa_base_get_default_settings('csa_base');
// Allow a subtheme to override the default values.
$defaults = array_merge($defaults, $subtheme_defaults);
// 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'];
}
// Merge the saved variables and their default values
$settings = array_merge($defaults, $saved_settings);
// Admin settings
$form['admin_settings'] = array('#type' => 'fieldset', '#title' => t('Admin'), '#description' => t('Control how csa_base\'s admin features behave'), '#collapsible' => TRUE, '#collapsed' => FALSE);
$form['admin_settings']['csa_base_move_sidebar'] = array('#type' => 'checkbox', '#title' => t('Append second sidebar to first when displaying admin pages'), '#default_value' => $settings['csa_base_move_sidebar']);
$form['admin_settings']['breadcrumb_display_admin'] = array('#type' => 'checkbox', '#title' => t('Always show breadcrumb on admin pages'), '#default_value' => $settings['breadcrumb_display_admin'], '#description' => t('This overwrites the general breadcrumb setting for all admin pages'));
// General Settings
$form['general_settings'] = array('#type' => 'fieldset', '#title' => t('General settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
// Primary Links
$form['general_settings']['primary_links'] = array('#type' => 'fieldset', '#title' => t('Primary links'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['general_settings']['primary_links']['primary_links_display_style'] = array('#type' => 'radios', '#title' => t('How should your Primary links be displayed?'), '#default_value' => $settings['primary_links_display_style'], '#options' => array('menu' => t('As a custom menu defined in style.css'), 'superfish sf-horizontal' => t('Superfish: horizontal menu with dropdowns'), 'superfish sf-vertical' => t('Superfish: vertical menu (for sidebar blocks)'), 'tabbed-menu' => t('Tabs: render menu as tabs')));
$form['general_settings']['primary_links']['primary_links_allow_tree'] = array('#type' => 'checkbox', '#title' => t('Allow nested menu tree for Primary links (required for both Superfish and Tabs)'), '#default_value' => $settings['primary_links_allow_tree']);
// Secondary Links
$form['general_settings']['secondary_links'] = array('#type' => 'fieldset', '#title' => t('Secondary links'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['general_settings']['secondary_links']['secondary_links_display_style'] = array('#type' => 'radios', '#title' => t('How should your Secondary links be displayed?'), '#default_value' => $settings['secondary_links_display_style'], '#options' => array('menu' => t('As a custom menu defined in style.css'), 'superfish sf-horizontal' => t('Superfish: horizontal menu with dropdowns'), 'superfish sf-vertical' => t('Superfish: vertical menu (for sidebar blocks)'), 'tabbed-menu' => t('Tabs: render menu as tabs')));
$form['general_settings']['secondary_links']['secondary_links_allow_tree'] = array('#type' => 'checkbox', '#title' => t('Allow nested menu tree for Secondary links (required for both Superfish and Tabs)'), '#default_value' => $settings['secondary_links_allow_tree']);
// Mission Statement
$form['general_settings']['mission_statement'] = array('#type' => 'fieldset', '#title' => t('Mission statement'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['general_settings']['mission_statement']['mission_statement_pages'] = array('#type' => 'radios', '#title' => t('Where should your mission statement be displayed?'), '#default_value' => $settings['mission_statement_pages'], '#options' => array('home' => t('Display mission statement only on front page'), 'all' => t('Display mission statement on all pages')));
// Breadcrumb
$form['general_settings']['breadcrumb'] = array('#type' => 'fieldset', '#title' => t('Breadcrumb'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['general_settings']['breadcrumb']['breadcrumb_display'] = array('#type' => 'checkbox', '#title' => t('Display breadcrumb'), '#default_value' => $settings['breadcrumb_display']);
$form['general_settings']['breadcrumb']['breadcrumb_with_title'] = array('#type' => 'checkbox', '#title' => t('Display page title in the breadcrumb'), '#default_value' => $settings['breadcrumb_with_title']);
// Search Settings
$form['general_settings']['search_container'] = array('#type' => 'fieldset', '#title' => t('Search results'), '#description' => t('What additional information should be displayed on your search results page?'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['general_settings']['search_container']['search_results']['search_snippet'] = array('#type' => 'checkbox', '#title' => t('Display text snippet'), '#default_value' => $settings['search_snippet']);
$form['general_settings']['search_container']['search_results']['search_info_type'] = array('#type' => 'checkbox', '#title' => t('Display content type'), '#default_value' => $settings['search_info_type']);
$form['general_settings']['search_container']['search_results']['search_info_user'] = array('#type' => 'checkbox', '#title' => t('Display author name'), '#default_value' => $settings['search_info_user']);
$form['general_settings']['search_container']['search_results']['search_info_date'] = array('#type' => 'checkbox', '#title' => t('Display posted date'), '#default_value' => $settings['search_info_date']);
$form['general_settings']['search_container']['search_results']['search_info_comment'] = array('#type' => 'checkbox', '#title' => t('Display comment count'), '#default_value' => $settings['search_info_comment']);
$form['general_settings']['search_container']['search_results']['search_info_upload'] = array('#type' => 'checkbox', '#title' => t('Display attachment count'), '#default_value' => $settings['search_info_upload']);
// Node Settings
$form['node_type_specific'] = array('#type' => 'fieldset', '#title' => t('Node settings'), '#description' => t('Here you can make adjustments to which information is shown with your content, and how it is displayed. You can modify these settings so they apply to all content types, or check the "Use content-type specific settings" box to customize them for each content type. For example, you may want to show the date on stories, but not pages.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
// Author & Date Settings
$form['node_type_specific']['submitted_by_container'] = array('#type' => 'fieldset', '#title' => t('Author & date'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
$form['node_type_specific']['submitted_by_container']['submitted_by'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_author_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display author\'s username'), '#default_value' => $settings["submitted_by_author_{$type}"]);
$form['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_date_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display date posted (you can customize this format on your <a href="@date-time-url">Date and Time</a> settings page)', array('@date-time-url' => url('admin/settings/date-time'))), '#default_value' => $settings["submitted_by_date_{$type}"]);
// Options for default settings
if ($type == 'default') {
$form['node_type_specific']['submitted_by_container']['submitted_by']['default']['#title'] = t('Default');
$form['node_type_specific']['submitted_by_container']['submitted_by']['default']['#collapsed'] = $settings['submitted_by_enable_content_type'] ? TRUE : FALSE;
$form['node_type_specific']['submitted_by_container']['submitted_by']['submitted_by_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['submitted_by_enable_content_type']);
} else {
if ($settings['submitted_by_enable_content_type'] == 0) {
$form['submitted_by'][$type]['#collapsed'] = TRUE;
}
}
}
// Taxonomy Settings
if (module_exists('taxonomy')) {
$form['node_type_specific']['display_taxonomy_container'] = array('#type' => 'fieldset', '#title' => t('Taxonomy terms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['node_type_specific']['display_taxonomy_container']['display'] = array('#type' => 'fieldset', '#title' => t('Display'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['node_type_specific']['display_taxonomy_container']['display']['taxonomy_format_delimiter'] = array('#type' => 'textfield', '#title' => t('Delimter'), '#size' => 60, '#default_value' => $settings['taxonomy_format_delimiter'], '#description' => t('Enter a custom delimiter for taxonomy terms'));
$form['node_type_specific']['display_taxonomy_container']['display']["taxonomy_format_links"] = array('#type' => 'checkbox', '#title' => t('Display taxonomy terms in a links list (omitting delimiters)'), '#default_value' => $settings["taxonomy_format_links"]);
$form['node_type_specific']['display_taxonomy_container']['display']["taxonomy_display_vocab_name"] = array('#type' => 'checkbox', '#title' => t('Display vocabulary names'), '#default_value' => $settings["taxonomy_display_vocab_name"]);
// Default & content-type specific settings
foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
// taxonomy display per node
$form['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
// display
$form['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_display_{$type}"] = array('#type' => 'select', '#title' => t('When should taxonomy terms be displayed?'), '#default_value' => $settings["taxonomy_display_{$type}"], '#options' => array('' => '', 'never' => t('Never display taxonomy terms'), 'all' => t('Always display taxonomy terms'), 'only' => t('Only display taxonomy terms on full node pages')));
// format
$form['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_format_{$type}"] = array('#type' => 'radios', '#title' => t('Taxonomy display format'), '#default_value' => $settings["taxonomy_format_{$type}"], '#options' => array('vocab' => t('Display each vocabulary on a new line'), 'list' => t('Display all taxonomy terms on a single line')));
// Get taxonomy vocabularies by node type
$vocabs = array();
$vocabs_by_type = $type == 'default' ? taxonomy_get_vocabularies() : taxonomy_get_vocabularies($type);
foreach ($vocabs_by_type as $key => $value) {
$vocabs[$value->vid] = $value->name;
}
// Display taxonomy checkboxes
foreach ($vocabs as $key => $vocab_name) {
$form['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_vocab_display_{$type}_{$key}"] = array('#type' => 'checkbox', '#title' => t('Display vocabulary: ' . $vocab_name), '#default_value' => $settings["taxonomy_vocab_display_{$type}_{$key}"]);
}
// Options for default settings
if ($type == 'default') {
$form['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#title'] = t('Default');
$form['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#collapsed'] = $settings['taxonomy_enable_content_type'] ? TRUE : FALSE;
$form['node_type_specific']['display_taxonomy_container']['display_taxonomy']['taxonomy_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['taxonomy_enable_content_type']);
} else {
if ($settings['taxonomy_enable_content_type'] == 0) {
$form['display_taxonomy'][$type]['#collapsed'] = TRUE;
}
//.........这里部分代码省略.........