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


PHP node_type_get_type函数代码示例

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


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

示例1: hook_entity_diff

/**
 * Allow modules to provide a comparison about entities.
 *
 * @param object $old_entity
 *   The older entity revision.
 * @param object $new_entity
 *   The newer entity revision.
 * @param array $context
 *   An associative array containing:
 *   - entity_type: The entity type; e.g., 'node' or 'user'.
 *   - view_mode: The view mode to use. Defaults to FALSE.
 *
 * @return array
 *   An associative array of values keyed by the entity property.
 *
 * @todo
 *   Investiagate options and document these.
 */
function hook_entity_diff($old_entity, $new_entity, $context)
{
    if ($context['entity_type'] == 'node') {
        $type = node_type_get_type($new_entity);
        $result['title'] = array('#name' => $type->title_label, '#old' => array($old_entity->title), '#new' => array($new_entity->title), '#weight' => -5, '#settings' => array('show_header' => FALSE));
    }
}
开发者ID:ehazell,项目名称:AWBA,代码行数:25,代码来源:diff.api.php

示例2: hook_skinr_ui_element_title

/**
 * Returns the human readable title for a given element.
 *
 * @param $module
 *   The module implementing given element.
 * @param $element
 *   An element.
 * @param $theme_name
 *   The name of the theme.
 *
 * @return
 *   A string containing the element's title in human readable form.
 *
 * @see skinr_ui_admin_skins()
 * @see skinr_context_ui_skin_list_subform()
 */
function hook_skinr_ui_element_title($module, $element, $theme_name)
{
    if ($module == 'node') {
        $type = node_type_get_type($element);
        return $type->name;
    }
}
开发者ID:ph3l1x,项目名称:mydea,代码行数:23,代码来源:skinr_ui.api.php

示例3: hook_field_extra_fields

/**
 * Expose "pseudo-field" components on fieldable objects.
 *
 * Field UI's 'Manage fields' page lets users re-order fields, but also
 * non-field components. For nodes, that would be title, menu settings, or
 * other elements exposed by contributed modules through hook_form() or
 * hook_form_alter().
 *
 * Fieldable entities or contributed modules that want to have their components
 * supported should expose them using this hook, and use
 * field_attach_extra_weight() to retrieve the user-defined weight when
 * inserting the component.
 *
 * @param $bundle
 *   The name of the bundle being considered.
 * @return
 *   An array of 'pseudo-field' components. The keys are the name of the element
 *   as it appears in the form structure. The values are arrays with the
 *   following key/value pairs:
 *   - label: The human readable name of the component.
 *   - description: A short description of the component contents.
 *   - weight: The default weight of the element.
 *   - view: (optional) The name of the element as it appears in the rendered
 *     structure, if different from the name in the form.
 */
function hook_field_extra_fields($bundle)
{
    $extra = array();
    if ($type = node_type_get_type($bundle)) {
        if ($type->has_title) {
            $extra['title'] = array('label' => $type->title_label, 'description' => t('Node module element.'), 'weight' => -5);
        }
        if ($bundle == 'poll' && module_exists('poll')) {
            $extra['title'] = array('label' => t('Poll title'), 'description' => t('Poll module title.'), 'weight' => -5);
            $extra['choice_wrapper'] = array('label' => t('Poll choices'), 'description' => t('Poll module choices.'), 'weight' => -4);
            $extra['settings'] = array('label' => t('Poll settings'), 'description' => t('Poll module settings.'), 'weight' => -3);
        }
    }
    return $extra;
}
开发者ID:nicklewisatx,项目名称:drupal,代码行数:40,代码来源:field.api.php

示例4: merciCreateContentType

 function merciCreateContentType($settings, $merci_type, $merci_settings = NULL)
 {
     // Create resource content type
     // Disable the rating for this content type: 0 for Disabled, 1 for Enabled.
     if (node_type_get_type($settings['type'])) {
         return $settings['type'];
     }
     $content_type = $this->drupalCreateContentType($settings);
     $this->verbose('settings ' . var_export($content_type, TRUE));
     $type = $content_type->type;
     $settings = array('merci_type_setting' => $merci_type, 'merci_max_hours_per_reservation' => 5);
     if ($merci_settings) {
         $settings = $settings + $merci_settings;
     }
     $this->drupalPost('admin/structure/types/manage/' . $type, $settings, t('Save content type'));
     $this->assertResponse(200);
     $this->assertRaw(' has been updated.', t('Settings modified successfully for content type.'));
     return $type;
 }
开发者ID:MakeRnCoders,项目名称:FabDrupal,代码行数:19,代码来源:merci_testcase.php

示例5: hook_form

/**
 * Display a node editing form.
 *
 * This hook, implemented by node modules, is called to retrieve the form
 * that is displayed when one attempts to "create/edit" an item. This form is
 * displayed at the URI http://www.example.com/?q=node/<add|edit>/nodetype.
 *
 * @param $node
 *   The node being added or edited.
 * @param $form_state
 *   The form state array. Changes made to this variable will have no effect.
 * @return
 *   An array containing the form elements to be displayed in the node
 *   edit form.
 *
 * The submit and preview buttons, taxonomy controls, and administrative
 * accoutrements are displayed automatically by node.module. This hook
 * needs to return the node title, the body text area, and fields
 * specific to the node type.
 *
 * For a detailed usage example, see node_example.module.
 */
function hook_form($node, $form_state)
{
    $type = node_type_get_type($node);
    $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE);
    $form['body'] = array('#type' => 'textarea', '#title' => check_plain($type->body_label), '#rows' => 20, '#required' => TRUE);
    $form['field1'] = array('#type' => 'textfield', '#title' => t('Custom field'), '#default_value' => $node->field1, '#maxlength' => 127);
    $form['selectbox'] = array('#type' => 'select', '#title' => t('Select box'), '#default_value' => $node->selectbox, '#options' => array(1 => 'Option A', 2 => 'Option B', 3 => 'Option C'), '#description' => t('Please choose an option.'));
    return $form;
}
开发者ID:nicklewisatx,项目名称:drupal,代码行数:31,代码来源:node.api.php

示例6: hook_form

/**
 * Display a node editing form.
 *
 * This hook, implemented by node modules, is called to retrieve the form
 * that is displayed when one attempts to "create/edit" an item. This form is
 * displayed at the URI http://www.example.com/?q=node/<add|edit>/nodetype.
 *
 * @param $node
 *   The node being added or edited.
 * @param $form_state
 *   The form state array. Changes made to this variable will have no effect.
 * @return
 *   An array containing the form elements to be displayed in the node
 *   edit form.
 *
 * The submit and preview buttons, taxonomy controls, and administrative
 * accoutrements are displayed automatically by node.module. This hook
 * needs to return the node title, the body text area, and fields
 * specific to the node type.
 *
 * For a detailed usage example, see node_example.module.
 *
 * @ingroup node_api_hooks
 */
function hook_form($node, $form_state)
{
    $type = node_type_get_type($node);
    $form['field1'] = array('#type' => 'textfield', '#title' => t('Custom field'), '#default_value' => $node->field1, '#maxlength' => 127);
    $form['selectbox'] = array('#type' => 'select', '#title' => t('Select box'), '#default_value' => $node->selectbox, '#options' => array(1 => 'Option A', 2 => 'Option B', 3 => 'Option C'), '#description' => t('Choose an option.'));
    return $form;
}
开发者ID:scor,项目名称:d7stt,代码行数:31,代码来源:node.api.php

示例7: backdropCreateContentType

 /**
  * 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 backdropCreateContentType($settings = array())
 {
     // Find a non-existent random type name.
     do {
         $name = strtolower($this->randomName(8));
     } while (node_type_get_type($name));
     // Populate defaults array.
     $defaults = array('type' => $name, 'name' => $name, 'base' => 'node_content', 'description' => '', 'help' => '', 'title_label' => 'Title', 'body_label' => 'Body', 'has_title' => 1, 'has_body' => 1, 'is_new' => TRUE);
     // 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);
     menu_rebuild();
     node_add_body_field($type);
     $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;
 }
开发者ID:thejimbirch,项目名称:backdropcms.org,代码行数:29,代码来源:backdrop_web_test_case.php

示例8: commons_beehive_process_node

/**
 * Implements hook_process_node().
 */
function commons_beehive_process_node(&$variables, $hook)
{
    $node = $variables['node'];
    $wrapper = entity_metadata_wrapper('node', $node);
    // Use timeago module for formatting node submission date
    // if it is enabled and also configured to be used on nodes.
    if (module_exists('timeago') && variable_get('timeago_node', 1)) {
        $variables['date'] = timeago_format_date($node->created, $variables['date']);
        $use_timeago_date_format = TRUE;
    } else {
        $use_timeago_date_format = FALSE;
    }
    // Replace the submitted text on nodes with something a bit more pertinent to
    // the content type.
    if (variable_get('node_submitted_' . $node->type, TRUE)) {
        $node_type_info = node_type_get_type($variables['node']);
        $type_attributes = array('class' => array('node-content-type', drupal_html_class('node-content-type-' . $node->type)));
        $placeholders = array('!type' => '<span' . drupal_attributes($type_attributes) . '>' . check_plain($node_type_info->name) . '</span>', '!user' => $variables['name'], '!date' => $variables['date'], '@interval' => format_interval(REQUEST_TIME - $node->created));
        // Show what group the content belongs to if applicable.
        if (!empty($node->{OG_AUDIENCE_FIELD}) && $wrapper->{OG_AUDIENCE_FIELD}->count() == 1) {
            $placeholders['!group'] = l($wrapper->{OG_AUDIENCE_FIELD}->get(0)->label(), 'node/' . $wrapper->{OG_AUDIENCE_FIELD}->get(0)->getIdentifier());
            if ($use_timeago_date_format == TRUE) {
                $variables['submitted'] = t('!type created !date in the !group group by !user', $placeholders);
            } else {
                $variables['submitted'] = t('!type created @interval ago in the !group group by !user', $placeholders);
            }
        } else {
            if ($use_timeago_date_format == TRUE) {
                $variables['submitted'] = t('!type created !date by !user', $placeholders);
            } else {
                $variables['submitted'] = t('!type created @interval ago by !user', $placeholders);
            }
        }
    }
    // Append a feature label to featured node teasers.
    if ($variables['teaser'] && $variables['promote']) {
        $variables['submitted'] .= ' <span class="featured-node-tooltip">' . t('Featured') . ' ' . $variables['type'] . '</span>';
    }
}
开发者ID:jayelless,项目名称:beehive,代码行数:42,代码来源:template.php

示例9: hook_form

/**
 * Display a node editing form.
 *
 * This hook, implemented by node modules, is called to retrieve the form
 * that is displayed to create or edit a node. This form is displayed at path
 * node/add/[node type] or node/[node ID]/edit.
 *
 * The submit and preview buttons, administrative and display controls, and
 * sections added by other modules (such as path settings, menu settings,
 * comment settings, and fields managed by the Field UI module) are
 * displayed automatically by the node module. This hook just needs to
 * return the node title and form editing fields specific to the node type.
 *
 * @param $node
 *   The node being added or edited.
 * @param $form_state
 *   The form state array.
 *
 * @return
 *   An array containing the title and any custom form elements to be displayed
 *   in the node editing form.
 *
 * @ingroup node_api_hooks
 */
function hook_form($node, &$form_state) {
  $type = node_type_get_type($node);

  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => check_plain($type->title_label),
    '#default_value' => !empty($node->title) ? $node->title : '',
    '#required' => TRUE, '#weight' => -5
  );

  $form['field1'] = array(
    '#type' => 'textfield',
    '#title' => t('Custom field'),
    '#default_value' => $node->field1,
    '#maxlength' => 127,
  );
  $form['selectbox'] = array(
    '#type' => 'select',
    '#title' => t('Select box'),
    '#default_value' => $node->selectbox,
    '#options' => array(
      1 => 'Option A',
      2 => 'Option B',
      3 => 'Option C',
    ),
    '#description' => t('Choose an option.'),
  );

  return $form;
}
开发者ID:richielokay,项目名称:drupal7,代码行数:54,代码来源:node.api.php

示例10: prepareBuild

 /**
  * Implements Drupal\configuration\Config\Configuration::prepareBuild().
  */
 protected function prepareBuild()
 {
     $data = (object) node_type_get_type($this->identifier);
     $this->data = new \StdClass();
     foreach ($this->getKeysToExport() as $key) {
         $this->data->{$key} = $data->{$key};
     }
     // Force module name to be 'configuration' if set to 'node. If we leave as
     // 'node' the content type will be assumed to be database-stored by
     // the node module.
     $this->data->base = $this->data->base === 'node' ? 'configuration' : $this->data->base;
     return $this;
 }
开发者ID:mrsad,项目名称:Dru.io,代码行数:16,代码来源:ContentTypeConfiguration.php

示例11: hook_sbp_details

/**
 * Return details about an indexed path (required sub-module hook).
 *
 * This hook is invoked after a search, to get full information about
 * what to display.
 *
 * This hook is also invoked during search indexing to get the page title
 * which is added to the indexed text. In this case, $keys will be null, and
 * the module can also return rendered content to be indexed, if desired.
 *
 * @param $id
 *    The ID corresponding to the path. This is the ID number you
 *    returned in hook_sbp_paths(), for this path.
 * @param $environment
 *   ID of environment currently being indexed or searched.
 * @param $keys
 *    The keywords being searched for (useful in extracting a snippet). NULL
 *    indicates this call is for search indexing.
 *
 * @return
 *    - If for some reason this path should not be displayed or indexed,
 *      return NULL or zero.
 *    - If $keys is null, return an associative array for search
 *      indexing, with component 'title' (the page title) and optional
 *      component 'content' (an override of the page content, to avoid
 *      standard Drupal rendering).
 *    - If keywords are not null, return an associative array of fields
 *      suitable for display on search results screen for this path. See
 *      the Drupal documentation for hook_search() for a list of what
 *      the fields are. The 'title' component must be given.  The 'link'
 *      component should be omitted (it is handled by the main
 *      search_by_page module).  The search_by_page_excerpt() function may be
 *      useful in extracting a 'snippet'.
 *
 * @see hook_sbp_paths()
 */
function hook_sbp_details($id, $environment, $keys = NULL)
{
    $node = my_module_get_node($id);
    $type = node_type_get_type($node);
    return array('type' => check_plain($type->name), 'title' => search_by_page_strip_tags($node->title, $environment), 'user' => theme('username', array('account' => $node)), 'date' => $node->changed, 'extra' => $node->extra, 'snippet' => search_by_page_excerpt($keys, search_by_page_strip_tags($node->body[LANGUAGE_NONE][0]['value'], $environment)));
}
开发者ID:owenmj,项目名称:iergo,代码行数:42,代码来源:search_by_page.api.php

示例12: exists

 /**
  * Determines if a content type exists or not.
  *
  * @param string $machine_name The machine name of the content type.
  *
  * @return bool
  */
 public static function exists($machine_name)
 {
     return node_type_get_type($machine_name) !== false;
 }
开发者ID:ryne-andal,项目名称:ablecore,代码行数:11,代码来源:ContentType.php

示例13: getNodeView

 /**
  * Retrieve information relevant for viewing the node.
  *
  * (This data is generally added to the node's extra field.)
  *
  * @return
  *  Content array
  */
 public function getNodeView()
 {
     $type = node_type_get_type($this->node);
     $content['question_type'] = array('#markup' => '<div class="question_type_name">' . $type->name . '</div>', '#weight' => -2);
     /*
     $question_body = field_get_items('node', $this->node, 'body');
     $content['question'] = array(
       '#markup' => '<div class="question-body">' . $question_body[0]['safe_value'] . '</div>',
       '#weight' => -1,
     );
     */
     return $content;
 }
开发者ID:progamr,项目名称:opigno,代码行数:21,代码来源:og_quiz_question.php


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