本文整理汇总了PHP中node_get_types函数的典型用法代码示例。如果您正苦于以下问题:PHP node_get_types函数的具体用法?PHP node_get_types怎么用?PHP node_get_types使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了node_get_types函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addLocationContentType
function addLocationContentType(&$settings, $add = array())
{
// find a non-existent random type name.
do {
$name = strtolower($this->randomName(3, 'type_'));
} while (node_get_types('type', $name));
// Get the (settable) defaults.
$defaults = array();
$d = location_invoke_locationapi($location, 'defaults');
$fields = location_field_names();
foreach ($fields as $k => $v) {
if (!isset($v['nodiff'])) {
$defaults[$k] = $d[$k];
}
}
foreach ($defaults as $k => $v) {
// Change collection to allow.
$defaults[$k]['collect'] = 1;
}
$settings = array('name' => $name, 'type' => $name, 'location_settings' => array('multiple' => array('max' => 1, 'add' => 1), 'form' => array('fields' => $defaults)));
//$settings['location_settings'] = array_merge_recursive($settings['location_settings'], $add);
$this->flattenPostData($settings);
$add = array('location_settings' => $add);
$this->flattenPostData($add);
$settings = array_merge($settings, $add);
$this->drupalPost('admin/content/types/add', $settings, 'Save content type');
$this->refreshVariables();
$settings = variable_get('location_settings_node_' . $name, array());
return $name;
}
示例2: 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;
}
示例3: 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);
}
}
示例4: 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 (!isset($theme_settings['primary_menu_dropdown']) || $theme_settings['rebuild_registry'] == 1) {
static $registry_rebuilt = false;
// avoid multiple rebuilds per page
// Rebuild theme registry & notify user
if (isset($theme_settings['rebuild_registry']) && $theme_settings['rebuild_registry'] == 1 && !$registry_rebuilt) {
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');
$registry_rebuilt = true;
}
// 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]);
}
}
// Combine default theme settings from .info file & theme-settings.php
$theme_data = list_themes();
// get theme data for all themes
$info_theme_settings = $theme_name ? $theme_data[$theme_name]->info['settings'] : array();
$defaults = array_merge(fusion_core_default_theme_settings(), $info_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);
}
}
示例5: seotools_page_title_nodes_reset
function seotools_page_title_nodes_reset()
{
$types = node_get_types();
foreach ($types as $type) {
// Define the node-type key
$key = 'page_title_type_' . $type->type . '_showfield';
variable_set($key, 1);
}
}
示例6: drupalCreateContentType
/**
* Creates a custom content type based on default settings.
*
* @param settings
* An array of settings to change from the defaults.
* Example: 'type' => 'foo'.
* @return object Created content type.
*/
function drupalCreateContentType($settings = array())
{
// find a non-existent random type name.
do {
$name = strtolower($this->randomName(3, 'type_'));
} while (node_get_types('type', $name));
// Populate defaults array
$defaults = array('type' => $name, 'name' => $name, 'description' => '', 'help' => '', 'min_word_count' => 0, 'title_label' => 'Title', 'body_label' => 'Body', 'has_title' => 1, 'has_body' => 1);
// imposed values for a custom type
$forced = array('orig_type' => '', 'old_type' => '', 'module' => 'node', 'custom' => 1, 'modified' => 1, 'locked' => 0);
$type = $forced + $settings + $defaults;
$type = (object) $type;
node_type_save($type);
node_types_rebuild();
return $type;
}
示例7: node_delete
/**
* Override node_delete() core Drupal function.
* Skip user access function during the importing.
*
* @param int $nid The nodeID
*/
protected function node_delete($nid)
{
// Clear the cache before the load, so if multiple nodes are deleted, the
// memory will not fill up with nodes (possibly) already removed.
$node = node_load($nid, NULL, TRUE);
db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
// Call the node-specific callback (if any):
node_invoke($node, 'delete');
node_invoke_nodeapi($node, 'delete');
// Clear the page and block caches.
cache_clear_all();
// Remove this node from the search index if needed.
if (function_exists('search_wipe')) {
search_wipe($node->nid, 'node');
}
watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title)));
}
示例8: layoutstudio_theme_get_default_settings
/**
* Return the theme settings' default values from the .info and save them into the database.
*
* @param $theme
* The name of theme.
*/
function layoutstudio_theme_get_default_settings($theme)
{
$themes = list_themes();
// Get the default values from the .info file.
$defaults = !empty($themes[$theme]->info['settings']) ? $themes[$theme]->info['settings'] : array();
if (!empty($defaults)) {
// Get the theme settings saved in the database.
$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));
// If the active theme has been loaded, force refresh of Drupal internals.
if (!empty($GLOBALS['theme_key'])) {
theme_get_setting('', TRUE);
}
}
// Return the default settings.
return $defaults;
}
示例9: rules_action_callback_form
/**
* The configuration form callback for an action.
*
* It should be placed into the file MODULENAME.rules_forms.inc or into
* MODULENAME.rules.inc.
*
* This callback can be used to alter the automatically generated
* configuration form. New form elements should be put in $form['settings']
* as its form values are used to populate $settings automatically. If some
* postprocessing of the values is necessary the action may implement
* rules_action_callback_submit().
*
* @param $settings
* The array of configuration settings to edit. This array is going to be
* passed to the action implementation once executed.
* @param $form
* The configuration form as generated by rules. The modify it, has to be
* taken by reference. Additional form elements should go into
* $form['settings']. To let rules know about additional textual form
* elements use the 'eval input' attribute of hook_rules_action_info() so
* rules adds input evaluation support to them.
* @param $form_state
* The form's form state.
*
*
* @see rules_action_callback_validate(), rules_action_callback_submit()
*
*/
function rules_action_callback_form($settings, &$form)
{
$settings += array('type' => array());
$form['settings']['type'] = array('#type' => 'select', '#title' => t('Content types'), '#options' => node_get_types('names'), '#multiple' => TRUE, '#default_value' => $settings['type'], '#required' => TRUE);
}
示例10: testCreateType
public function testCreateType()
{
$type = new StdClass();
$type->iso = 'test';
$type->name = 'Test type';
$created_type = _kentry_create_type($type);
$node_types = array_keys(node_get_types());
$this->assertTrue(in_array($created_type, $node_types), sprintf('%s not created', $created_type));
}
示例11: drupalCreateContentType
/**
* Creates a custom content type based on default settings.
*
* @param $settings
* An array of settings to change from the defaults.
* Example: 'type' => 'foo'.
* @return
* Created content type.
*/
protected function drupalCreateContentType($settings = array())
{
// find a non-existent random type name.
do {
$name = strtolower($this->randomName(3, 'type_'));
} while (node_get_types('type', $name));
// Populate defaults array
$defaults = array('type' => $name, 'name' => $name, 'description' => '', 'help' => '', 'min_word_count' => 0, 'title_label' => 'Title', 'body_label' => 'Body', 'has_title' => 1, 'has_body' => 1);
// imposed values for a custom type
$forced = array('orig_type' => '', 'old_type' => '', 'module' => 'node', 'custom' => 1, 'modified' => 1, 'locked' => 0);
$type = $forced + $settings + $defaults;
$type = (object) $type;
$saved_type = node_type_save($type);
node_types_rebuild();
$this->assertEqual($saved_type, SAVED_NEW, t('Created content type %type.', array('%type' => $type->type)));
// Reset permissions so that permissions for this content type are available.
$this->checkPermissions(array(), TRUE);
return $type;
}
示例12: t
field-<?php
print $field_name_css;
?>
">
<?php
if ($label_display == 'above') {
?>
<div class="field-label"><?php
print t($label);
?>
: </div>
<?php
if ($field_type == 'flexifield') {
?>
<div class="field-value"> <?php
print node_get_types('name', $items[0]['type']);
?>
</div>
<?php
}
?>
<?php
}
?>
<div class="field-items">
<?php
$count = 1;
foreach ($items as $delta => $item) {
if (!$item['empty']) {
?>
<div class="field-item <?php
示例13: guifi_node_form
function guifi_node_form(&$node, $form_state)
{
global $user;
$form_weight = 0;
$type = node_get_types('type', $node);
if (!empty($node->zone_id)) {
drupal_set_breadcrumb(guifi_node_ariadna($node));
} else {
drupal_set_breadcrumb(NULL);
}
// ----
// El títol el primer de tot
// ------------------------------------------------
if ($type->has_title) {
$form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title);
}
$form_weight = 2;
/*
* maintainers fieldset
*/
$form_weight = -3;
$form['maintainers'] = guifi_maintainers_form($node, $form_weight);
/*
* funders fieldset
*/
$form_weight = -4;
$form['funders'] = guifi_funders_form($node, $form_weight);
$form_weight = 0;
$form['nick'] = array('#type' => 'textfield', '#title' => t('Nick'), '#required' => FALSE, '#size' => 20, '#maxlength' => 20, '#element_validate' => array('guifi_node_nick_validate'), '#default_value' => $node->nick, '#description' => t("Unique identifier for this node. Avoid generic names such 'MyNode', use something that really identifies your node.<br />Short name, single word with no spaces, 7-bit chars only, will be used for hostname, reports, etc."), '#weight' => $form_weight++);
$form['notification'] = array('#type' => 'textfield', '#title' => t('Contact'), '#required' => FALSE, '#size' => 60, '#maxlength' => 1024, '#element_validate' => array('guifi_emails_validate'), '#default_value' => $node->notification, '#description' => t("Who did possible this node or who to contact with regarding this node if it is distinct of the owner of this page. Use valid emails, if you like to have more than one, separated by commas.'"), '#weight' => $form_weight++);
$form['settings'] = array('#type' => 'fieldset', '#title' => t('Node settings'), '#weight' => $form_weight++, '#collapsible' => TRUE, '#collapsed' => TRUE);
// Si ets administrador pots definir el servidor de dades
if (user_access('administer guifi zones')) {
$graphstr = guifi_service_str($node->graph_server);
$form['settings']['graph_serverstr'] = array('#type' => 'textfield', '#title' => t('default graphs server'), '#maxlength' => 60, '#required' => FALSE, '#default_value' => $graphstr, '#autocomplete_path' => 'guifi/js/select-service/SNPgraphs', '#element_validate' => array('guifi_service_name_validate', 'guifi_zone_service_validate'), '#description' => t('Select the <em>graph server</em> to be used at this node.<br />You can find the <em>graph server</em> by introducing part of the id number, zone name or graph server name. A list with all matching values with a maximum of 50 values will be created.<br />You can refine the text to find your choice.'));
$form['settings']['graph_server'] = array('#type' => 'hidden', '#value' => $node->graph_server);
}
$form['settings']['stable'] = array('#type' => 'select', '#title' => t("It's supposed to be a stable online node?"), '#required' => FALSE, '#default_value' => $node->stable ? $node->stable : 'Yes', '#options' => array('Yes' => t('Yes, is intended to be kept always on, avalable for extending the mesh'), 'No' => t("I'm sorry. Will be connected just when I'm online")), '#description' => t("That helps while planning a mesh network. We should know which locations are likely available to provide stable links."), '#weight' => 1);
// Ask for a license agreement if is a new node
if (empty($node->nid)) {
$form['license'] = array('#type' => 'item', '#title' => t('License and usage agreement'), '#value' => t(variable_get('guifi_license', NULL)), '#description' => t('You must accept this agreement to be authorized to create new nodes.'), '#weight' => 1);
if (empty($node->agreement)) {
$agreement = 'No';
} else {
$agreement = $node->agreement;
}
$form['agreement'] = array('#type' => 'radios', '#default_value' => $agreement, '#options' => array('Yes' => t('Yes, I have read this and accepted')), '#element_validate' => array('guifi_node_agreement_validate'), '#weight' => 2);
} else {
$form['agreement'] = array('#type' => 'hidden', '#default_value' => 'Yes');
}
if (empty($node->nid)) {
if (empty($node->ndfzone)) {
if (empty($node->zone_id)) {
if (!empty($user->guifi_default_zone)) {
$zone_id = $user->guifi_default_zone;
}
} else {
$zone_id = $node->zone_id;
}
} else {
$zone_id = $node->ndfzone;
}
} else {
$zone_id = $node->zone_id;
}
$form['zone_id'] = guifi_zone_autocomplete_field($zone_id, 'zone_id');
// $form['zone_id'] = guifi_zone_select_field($zone_id,'zone_id');
$form['zone_id']['#weight'] = 3;
// ----
// position
// ------------------------------------------------
$form['position'] = array('#type' => 'fieldset', '#title' => t('Node position settings'), '#weight' => 4, '#collapsible' => FALSE);
if (guifi_gmap_key()) {
drupal_add_js(drupal_get_path('module', 'guifi') . '/js/guifi_gmap_node.js', 'module');
$form['position']['GMAP'] = array('#type' => 'item', '#title' => t('Map'), '#description' => t('Select the point where the node has to be placed.'), '#suffix' => '<input style="width: 240px;" id="mapSearch" type="text" /><div id="map" style="width: 100%; height: 437px; margin:5px;"></div>', '#weight' => 0);
$form['guifi_wms'] = array('#type' => 'hidden', '#value' => variable_get('guifi_wms_service', ''));
$form['lat'] = array('#type' => 'hidden', '#value' => $node->lat);
$form['lon'] = array('#type' => 'hidden', '#value' => $node->lon);
}
$form['position']['longitude'] = array('#type' => 'item', '#title' => t('Longitude'), '#prefix' => '<table><tr><th> </th><th>' . t('degrees (decimal values allowed)') . '</th><th>' . t('minutes') . '</th><th>' . t('seconds') . '</th></tr><tr><td>', '#suffix' => '</td>', '#weight' => 1);
$form['position']['londeg'] = array('#type' => 'textfield', '#default_value' => $node->londeg, '#size' => 12, '#maxlength' => 24, '#element_validate' => array('guifi_lon_validate'), '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 2);
$form['position']['lonmin'] = array('#type' => 'textfield', '#default_value' => $node->lonmin, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 3);
$form['position']['lonseg'] = array('#type' => 'textfield', '#default_value' => $node->lonseg, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td></tr>', '#weight' => 4);
$form['position']['latitude'] = array('#type' => 'item', '#title' => t('Latitude'), '#prefix' => '<tr><td>', '#suffix' => '</td>', '#weight' => 5);
$form['position']['latdeg'] = array('#type' => 'textfield', '#default_value' => $node->latdeg, '#size' => 12, '#maxlength' => 24, '#element_validate' => array('guifi_lat_validate'), '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 6);
$form['position']['latmin'] = array('#type' => 'textfield', '#default_value' => $node->latmin, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 7);
$form['position']['latseg'] = array('#type' => 'textfield', '#default_value' => $node->latseg, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td></tr></table>', '#weight' => 8);
$form['position']['zone_description'] = array('#type' => 'textfield', '#title' => t('Zone description'), '#required' => FALSE, '#size' => 60, '#maxlength' => 128, '#default_value' => $node->zone_description, '#description' => t("Zone, address, neighborhood. Something that describes your area within your location.<br />If you don't know your lat/lon, please provide street and number or crossing street."), '#weight' => 9);
$form['position']['elevation'] = array('#type' => 'textfield', '#title' => t('Antenna elevation'), '#required' => FALSE, '#size' => 5, '#length' => 20, '#maxlength' => 20, '#default_value' => $node->elevation, '#element_validate' => array('guifi_elevation_validate'), '#description' => t("Antenna height over the floor level."), '#weight' => 10);
if ($type->has_body) {
$form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
}
$radios = array();
$query = db_query("SELECT * FROM {guifi_radios} WHERE nid=%d", $node->id);
while ($radio = db_fetch_array($query)) {
$radios[] = $radio;
}
if (count($radios) < 1) {
$form['status_flag'] = array('#type' => 'select', '#title' => t("Node status"), '#default_value' => $node->status_flag ? $node->status_flag : 'Planned', '#required' => FALSE, '#options' => array('Reserved' => t('Reserved'), 'Inactive' => t('Inactive'), 'Planned' => t('Planned')));
} else {
//.........这里部分代码省略.........
示例14: hook_search
//.........这里部分代码省略.........
* capabilities. To do this, node module also implements hook_update_index()
* which is used to create and maintain the index.
*
* We call do_search() with the keys, the module name and extra SQL fragments
* to use when searching. See hook_update_index() for more information.
*
* @ingroup search
*/
function hook_search($op = 'search', $keys = null)
{
switch ($op) {
case 'name':
return t('Content');
case 'reset':
db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = 'node'", REQUEST_TIME);
return;
case 'status':
$total = db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1'));
$remaining = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.sid IS NULL OR d.reindex <> 0"));
return array('remaining' => $remaining, 'total' => $total);
case 'admin':
$form = array();
// Output form for defining rank factor weights.
$form['content_ranking'] = array('#type' => 'fieldset', '#title' => t('Content ranking'));
$form['content_ranking']['#theme'] = 'node_search_admin';
$form['content_ranking']['info'] = array('#value' => '<em>' . t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em>');
// Note: reversed to reflect that higher number = higher ranking.
$options = drupal_map_assoc(range(0, 10));
foreach (module_invoke_all('ranking') as $var => $values) {
$form['content_ranking']['factors']['node_rank_' . $var] = array('#title' => $values['title'], '#type' => 'select', '#options' => $options, '#default_value' => variable_get('node_rank_' . $var, 0));
}
return $form;
case 'search':
// Build matching conditions
list($join1, $where1) = _db_rewrite_sql();
$arguments1 = array();
$conditions1 = 'n.status = 1';
if ($type = search_query_extract($keys, 'type')) {
$types = array();
foreach (explode(',', $type) as $t) {
$types[] = "n.type = '%s'";
$arguments1[] = $t;
}
$conditions1 .= ' AND (' . implode(' OR ', $types) . ')';
$keys = search_query_insert($keys, 'type');
}
if ($category = search_query_extract($keys, 'category')) {
$categories = array();
foreach (explode(',', $category) as $c) {
$categories[] = "tn.tid = %d";
$arguments1[] = $c;
}
$conditions1 .= ' AND (' . implode(' OR ', $categories) . ')';
$join1 .= ' INNER JOIN {taxonomy_term_node} tn ON n.vid = tn.vid';
$keys = search_query_insert($keys, 'category');
}
if ($languages = search_query_extract($keys, 'language')) {
$categories = array();
foreach (explode(',', $languages) as $l) {
$categories[] = "n.language = '%s'";
$arguments1[] = $l;
}
$conditions1 .= ' AND (' . implode(' OR ', $categories) . ')';
$keys = search_query_insert($keys, 'language');
}
// Get the ranking expressions.
$rankings = _node_rankings();
// When all search factors are disabled (ie they have a weight of zero),
// The default score is based only on keyword relevance.
if ($rankings['total'] == 0) {
$total = 1;
$arguments2 = array();
$join2 = '';
$select2 = 'i.relevance AS score';
} else {
$total = $rankings['total'];
$arguments2 = $rankings['arguments'];
$join2 = implode(' ', $rankings['join']);
$select2 = '(' . implode(' + ', $rankings['score']) . ') AS score';
}
// Do search.
$find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid ' . $join1, $conditions1 . (empty($where1) ? '' : ' AND ' . $where1), $arguments1, $select2, $join2, $arguments2);
// Load results.
$results = array();
foreach ($find as $item) {
// Build the node body.
$node = node_load($item->sid);
$node->build_mode = NODE_BUILD_SEARCH_RESULT;
$node = node_build_content($node, FALSE, FALSE);
$node->body = drupal_render($node->content);
// Fetch comments for snippet.
$node->body .= module_invoke('comment', 'node', $node, 'update_index');
// Fetch terms for snippet.
$node->body .= module_invoke('taxonomy', 'node', $node, 'update_index');
$extra = module_invoke_all('node_search_result', $node);
$results[] = array('link' => url('node/' . $item->sid, array('absolute' => TRUE)), 'type' => check_plain(node_get_types('name', $node)), 'title' => $node->title, 'user' => theme('username', $node), 'date' => $node->changed, 'node' => $node, 'extra' => $extra, 'score' => $total ? $item->score / $total : 0, 'snippet' => search_excerpt($keys, $node->body));
}
return $results;
}
}
示例15: cms_base_settings
/**
* Implementation of THEMEHOOK_settings() function.
*
* @param $saved_settings
* An array of saved settings for this theme.
* @param $subtheme_defaults
* Allows a subtheme to override the default values.
* @return
* An array of form.
*/
function cms_base_settings($saved_settings, $subtheme_defaults = array())
{
$defaults = cms_base_default_settings('cms_base');
// Allows a subtheme to override the default values.
$defaults = array_merge($defaults, $subtheme_defaults);
// Merges the saved variables and their default values.
$settings = array_merge($defaults, $saved_settings);
// Creates the form for theme settings page.
$form = array();
// Extra variable settings for this theme
// layout settings
$form['layout'] = array('#type' => 'fieldset', '#title' => t('Layout settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['layout']['sidebar_left_width'] = array('#type' => 'textfield', '#title' => t('Left sidebar width'), '#size' => 10, '#default_value' => $settings['sidebar_left_width'], '#field_suffix' => t('px'));
$form['layout']['width_sidebar_right'] = array('#type' => 'textfield', '#title' => t('Right sidebar width'), '#size' => 10, '#default_value' => $settings['width_sidebar_right'], '#field_suffix' => t('px'));
$form['layout']['width_sidebar_right2'] = array('#type' => 'textfield', '#title' => t('Right sidebar 2 width'), '#size' => 10, '#default_value' => $settings['width_sidebar_right2'], '#field_suffix' => t('px'), '#description' => l(t('View instructions for using the sidebar settings'), 'http://www.cmsquickstart.com/drupal-theme-guides/sidebar-settings', array('attributes' => array('target' => "_blank"), 'absolute' => TRUE)));
$form['layout']['show_tooltip'] = array('#type' => 'checkbox', '#title' => t('Check to show tool tip when hovering over the primary links menu.'), '#default_value' => $settings['show_tooltip'], '#weight' => 11);
//font settings
$form['font_settings'] = array('#type' => 'fieldset', '#title' => t('Font settings'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t(''));
$form['font_settings']['use_css_for_fonts'] = array('#type' => 'checkbox', '#title' => t('Use CSS for fonts'), '#default_value' => $settings['use_css_for_fonts']);
$form['font_settings']['body_text'] = array('#type' => 'fieldset', '#title' => t('Body text font'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('Font used for the body text of content types, comments, and blocks.'));
$form['font_settings']['body_text']['body_text_font'] = array('#type' => 'select', '#title' => t('Font family'), '#default_value' => $settings['body_text_font'], '#options' => array("Georgia, 'Times New Roman', Times, serif" => t("Georgia, 'Times New Roman', Times, serif"), "'Times New Roman', Times, Georgia, serif" => t("'Times New Roman', Times, Georgia, serif"), "Verdana, Arial, Helvetica, sans-serif" => t("Verdana, Arial, Helvetica, sans-serif"), "Helvetica, Arial, Verdana, sans-serif" => t("Helvetica, Arial, Verdana, sans-serif'"), "Tahoma, Verdana, Arial, sans-serif" => t("Tahoma, Verdana, Arial, sans-serif"), 'Custom' => t('Custom (specify below)')), '#description' => t("Default font family - Georgia, 'Times New Roman', Times, serif"));
$form['font_settings']['body_text']['body_text_font_custom'] = array('#type' => 'textfield', '#title' => t('Custom font-family setting'), '#default_value' => $settings['body_text_font_custom'], '#size' => 40, '#maxlength' => 200, '#description' => t("Enter fonts in order of priority separated by commas. If the user's computer does not have the font it will use the next font listed in order of priority. For example: Verdana, Arial, 'Times New Roman' - in this example if the user does not have Verdana then their computer will look for Arial and then for Times Roman.<br /><b>Note:</b> Put ' before and after any fonts that have a space such as 'Times New Roman'."));
$form['font_settings']['headings_text_font'] = array('#type' => 'fieldset', '#title' => t('Headings text font'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('Font used for h1-h6 headings, navigation links, site name and slogan.'));
$form['font_settings']['headings_text_font']['heading_text_font'] = array('#type' => 'select', '#title' => t('Font family'), '#default_value' => $settings['heading_text_font'], '#options' => array("Georgia, 'Times New Roman', Times, serif" => t("Georgia, 'Times New Roman', Times, serif"), "'Times New Roman', Times, Georgia, serif" => t("'Times New Roman', Times, Georgia, serif"), "Verdana, Arial, Helvetica, sans-serif" => t("Verdana, Arial, Helvetica, sans-serif"), "Helvetica, Arial, Verdana, sans-serif" => t("Helvetica, Arial, Verdana, sans-serif'"), "Tahoma, Verdana, Arial, sans-serif" => t("Tahoma, Verdana, Arial, sans-serif"), 'Custom' => t('Custom (specify below)')), '#description' => t("Default font family - Georgia, 'Times New Roman', Times"));
$form['font_settings']['headings_text_font']['heading_text_font_custom'] = array('#type' => 'textfield', '#title' => t('Custom font-family setting'), '#default_value' => $settings['heading_text_font_custom'], '#size' => 40, '#maxlength' => 200, '#description' => t("Enter fonts in order of priority separated by commas. If the user's computer does not have the font it will use the next font listed in order of priority. For example: Verdana, Arial, 'Times New Roman' - in this example if the user does not have Verdana then their computer will look for Arial and then for Times Roman.<br /><b>Note:</b> Put ' before and after any fonts that have a space such as 'Times New Roman'."));
// Search Settings
if (module_exists('search')) {
$form['search_settings'] = array('#type' => 'fieldset', '#title' => t('Search results'), '#description' => t('Select additional information you would like to be displayed with search results.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['search_settings']['search_author_name'] = array('#type' => 'checkbox', '#title' => t('Author name'), '#default_value' => $settings['search_author_name']);
$form['search_settings']['search_posted_date'] = array('#type' => 'checkbox', '#title' => t('Node posted date'), '#default_value' => $settings['search_posted_date']);
$form['search_settings']['search_text_snippet'] = array('#type' => 'checkbox', '#title' => t('Text snippet'), '#default_value' => $settings['search_text_snippet']);
$form['search_settings']['search_node_type'] = array('#type' => 'checkbox', '#title' => t('Content type name'), '#default_value' => $settings['search_node_type']);
$form['search_settings']['search_node_comments'] = array('#type' => 'checkbox', '#title' => t('Comment count'), '#default_value' => $settings['search_node_comments']);
$form['search_settings']['search_attachment_count'] = array('#type' => 'checkbox', '#title' => t('Number of attachments'), '#default_value' => $settings['search_attachment_count']);
}
// Node Settings
$form['node_specific_settings'] = array('#type' => 'fieldset', '#title' => t('Node display settings'), '#description' => t("Options for displaying or hiding post information for your site's content. For example you may wish to show the author and date for Blog posts and hide these options for info pages."), '#collapsible' => TRUE, '#collapsed' => TRUE, '#attributes' => array('class' => 'node_settings'));
// Author & Date Settings
$form['node_specific_settings']['post_info_container'] = array('#type' => 'fieldset', '#title' => t('Author & date'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
if (!module_exists('submitted_by')) {
foreach (array_merge(array('default' => 'Default'), node_get_types('names')) as $type => $name) {
$form['node_specific_settings']['post_info_container']['submitted_by'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['node_specific_settings']['post_info_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_specific_settings']['post_info_container']['submitted_by'][$type]["submitted_by_date_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display date posted'), '#default_value' => $settings["submitted_by_date_{$type}"]);
// Options for default settings
if ($type == 'default') {
$form['node_specific_settings']['post_info_container']['submitted_by']['default']['#title'] = t('Default');
$form['node_specific_settings']['post_info_container']['submitted_by']['default']['#collapsed'] = $settings['submitted_by_content_type'] ? TRUE : FALSE;
$form['node_specific_settings']['post_info_container']['submitted_by']['submitted_by_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['submitted_by_content_type']);
} else {
if ($settings['submitted_by_content_type'] == 0) {
$form['submitted_by'][$type]['#collapsed'] = TRUE;
}
}
}
} else {
$form['node_specific_settings']['post_info_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.';
}
// Read More & Comment Link Settings
$form['node_specific_settings']['link_settings_container'] = array('#type' => 'fieldset', '#title' => t('Links'), '#description' => t('Define custom text for node links'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Read more link settings
$form['node_specific_settings']['link_settings_container']['readmore'] = array('#type' => 'fieldset', '#title' => t('Read more link'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
foreach (array_merge(array('default' => 'Default'), node_get_types('names')) as $type => $name) {
// Read more
$form['node_specific_settings']['link_settings_container']['readmore'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['node_specific_settings']['link_settings_container']['readmore'][$type]["readmore_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["readmore_{$type}"], '#description' => t('HTML is allowed.'));
$form['node_specific_settings']['link_settings_container']['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['node_specific_settings']['link_settings_container']['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['node_specific_settings']['link_settings_container']['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
if ($type == 'default') {
$form['node_specific_settings']['link_settings_container']['readmore']['default']['#title'] = t('Default');
$form['node_specific_settings']['link_settings_container']['readmore']['default']['#collapsed'] = $settings['readmore_content_type'] ? TRUE : FALSE;
$form['node_specific_settings']['link_settings_container']['readmore']['readmore_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['readmore_content_type']);
} else {
if ($settings['readmore_content_type'] == 0) {
$form['readmore'][$type]['#collapsed'] = TRUE;
}
}
}
// Comments link settings
$form['node_specific_settings']['link_settings_container']['comment'] = array('#type' => 'fieldset', '#title' => t('Comment links setting'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Default & content-type specific settings
foreach (array_merge(array('default' => 'Default'), node_get_types('names')) as $type => $name) {
$form['node_specific_settings']['link_settings_container']['comment'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Full nodes
$form['node_specific_settings']['link_settings_container']['comment'][$type]['node'] = array('#type' => 'fieldset', '#title' => t('Full node view settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['node_specific_settings']['link_settings_container']['comment'][$type]['node']['add'] = array('#type' => 'fieldset', '#title' => t('"Add new comment" link'), '#description' => t('The link when the full content is being displayed.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
//.........这里部分代码省略.........