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


PHP node_load函数代码示例

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


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

示例1: getReferencableEntities

 /**
  * Implements EntityReferenceHandler::getReferencableEntities().
  */
 public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0)
 {
     $settings = $this->field['settings']['handler_settings'];
     $include_space = $settings['include_space'];
     $all_groups = oa_core_get_all_groups($match, $match_operator, $limit);
     $groups = array_map(create_function('$group', 'return $group->title;'), $all_groups);
     $group_options = array();
     foreach ($groups as $nid => $group_name) {
         $group_options[$nid] = $group_name;
     }
     if ($space_id = oa_core_get_space_context()) {
         // Bring current group to front.
         if (!empty($group_options[$space_id])) {
             $group_options = array($space_id => t('!name (current)', array('!name' => $group_options[$space_id]))) + $group_options;
         } elseif ($include_space) {
             // NOTE: This title text is ignored and overwritten by select2widget
             // in select2widget_render_modes().  All that matters is the $space_id.
             // Current space should be cached.
             $space = node_load($space_id);
             if (empty($match) || stripos($space->title, $match) !== FALSE) {
                 $group_options = array($space_id => t('- All space members -')) + $group_options;
             }
         }
     }
     return array(OA_GROUP_TYPE => $group_options);
 }
开发者ID:redponey,项目名称:openatrium-7.x-2.51,代码行数:29,代码来源:OaGroupsSelectionHandler.class.php

示例2: odsherredweb_preprocess_page

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

示例3: libya_cron_subscription_mail

function libya_cron_subscription_mail($data)
{
    // subscription node
    $mail = $data[0];
    $nids = $data[1];
    // watchdog('actions', 'Cron subscription vars', func_get_args());
    global $siteName, $isMail, $base_url;
    $isMail = TRUE;
    $body = '<h1 style="font-size:1.25em;">Your alert subscription results from ' . $siteName . '</h1>
	<p class="no-margin">The following results match your subscription alert.</p>';
    foreach ($nids as $nid) {
        $N = node_load($nid);
        $content = strip_tags($N->body['und'][0]['value']);
        if (strlen($content) > 200) {
            $content = substr($content, 0, 200);
        }
        $CL = strrpos($content, ' ');
        $content = substr($content, 0, $CL) . '...';
        $body .= '<h2 style="font-size:1.25em;">' . l($N->title, 'node/' . $N->nid, array('attributes' => array('style' => array('text-decoration' => 'none')))) . '</h2><p>' . $content . '</p>
		<p>' . t('read more: ') . l($base_url . '/' . drupal_lookup_path('alias', 'node/' . $N->nid), 'node/' . $N->nid, array('absolute' => TRUE)) . '</p>
		<hr/>';
    }
    $data['message'] = 'Mail sent';
    $to = $mail['mail'];
    $from = variable_get('site_mail', 'mail@libyanwarthetruth.com');
    $params = array('body' => $body, 'rand' => $mail['rand'], 'to' => $to);
    $sent = drupal_mail('libya', 'subscription_alert_mail', $to, language_default(), $params, $from, TRUE);
}
开发者ID:vishacc,项目名称:libyanwarthetruth,代码行数:28,代码来源:cron.php

示例4: testFileFieldRSSContent

 /**
  * Tests RSS enclosure formatter display for RSS feeds.
  */
 function testFileFieldRSSContent()
 {
     $field_name = strtolower($this->randomMachineName());
     $type_name = 'article';
     $field_settings = array('display_field' => '1', 'display_default' => '1');
     $instance_settings = array('description_field' => '1');
     $widget_settings = array();
     $this->createFileField($field_name, 'node', $type_name, $field_settings, $instance_settings, $widget_settings);
     // RSS display must be added manually.
     $this->drupalGet("admin/structure/types/manage/{$type_name}/display");
     $edit = array("display_modes_custom[rss]" => '1');
     $this->drupalPostForm(NULL, $edit, t('Save'));
     // Change the format to 'RSS enclosure'.
     $this->drupalGet("admin/structure/types/manage/{$type_name}/display/rss");
     $edit = array("fields[{$field_name}][type]" => 'file_rss_enclosure');
     $this->drupalPostForm(NULL, $edit, t('Save'));
     // Create a new node with a file field set. Promote to frontpage
     // needs to be set so this node will appear in the RSS feed.
     $node = $this->drupalCreateNode(array('type' => $type_name, 'promote' => 1));
     $test_file = $this->getTestFile('text');
     // Create a new node with the uploaded file.
     $nid = $this->uploadNodeFile($test_file, $field_name, $node->id());
     // Get the uploaded file from the node.
     $node = node_load($nid, TRUE);
     $node_file = file_load($node->{$field_name}->target_id);
     // Check that the RSS enclosure appears in the RSS feed.
     $this->drupalGet('rss.xml');
     $uploaded_filename = str_replace('public://', '', $node_file->getFileUri());
     $test_element = array('key' => 'enclosure', 'value' => "", 'attributes' => array('url' => url("{$this->public_files_directory}/{$uploaded_filename}", array('absolute' => TRUE)), 'length' => $node_file->getSize(), 'type' => $node_file->getMimeType()));
     $this->assertRaw(format_xml_elements(array($test_element)), 'File field RSS enclosure is displayed when viewing the RSS feed.');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:34,代码来源:FileFieldRSSContentTest.php

示例5: callback_batch_operation

/**
 * Perform a single batch operation.
 *
 * Callback for batch_set().
 *
 * @param $MULTIPLE_PARAMS
 *   Additional parameters specific to the batch. These are specified in the
 *   array passed to batch_set().
 * @param $context
 *   The batch context array, passed by reference. This contains the following
 *   properties:
 *   - 'finished': A float number between 0 and 1 informing the processing
 *     engine of the completion level for the operation. 1 (or no value
 *     explicitly set) means the operation is finished: the operation will not
 *     be called again, and execution passes to the next operation or the
 *     callback_batch_finished() implementation. Any other value causes this
 *     operation to be called again; however it should be noted that the value
 *     set here does not persist between executions of this callback: each time
 *     it is set to 1 by default by the batch system.
 *   - 'sandbox': This may be used by operations to persist data between
 *     successive calls to the current operation. Any values set in
 *     $context['sandbox'] will be there the next time this function is called
 *     for the current operation. For example, an operation may wish to store a
 *     pointer in a file or an offset for a large query. The 'sandbox' array key
 *     is not initially set when this callback is first called, which makes it
 *     useful for determining whether it is the first call of the callback or
 *     not:
 *     @code
 *       if (empty($context['sandbox'])) {
 *         // Perform set-up steps here.
 *       }
 *     @endcode
 *     The values in the sandbox are stored and updated in the database between
 *     http requests until the batch finishes processing. This avoids problems
 *     if the user navigates away from the page before the batch finishes.
 *   - 'message': A text message displayed in the progress page.
 *   - 'results': The array of results gathered so far by the batch processing.
 *     This array is highly useful for passing data between operations. After
 *     all operations have finished, this is passed to callback_batch_finished()
 *     where results may be referenced to display information to the end-user,
 *     such as how many total items were processed.
 */
function callback_batch_operation($MULTIPLE_PARAMS, &$context)
{
    if (!isset($context['sandbox']['progress'])) {
        $context['sandbox']['progress'] = 0;
        $context['sandbox']['current_node'] = 0;
        $context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField();
    }
    // For this example, we decide that we can safely process
    // 5 nodes at a time without a timeout.
    $limit = 5;
    // With each pass through the callback, retrieve the next group of nids.
    $result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit);
    while ($row = db_fetch_array($result)) {
        // Here we actually perform our processing on the current node.
        $node = node_load($row['nid'], NULL, TRUE);
        $node->value1 = $options1;
        $node->value2 = $options2;
        node_save($node);
        // Store some result for post-processing in the finished callback.
        $context['results'][] = check_plain($node->title);
        // Update our progress information.
        $context['sandbox']['progress']++;
        $context['sandbox']['current_node'] = $node->nid;
        $context['message'] = t('Now processing %node', array('%node' => $node->title));
    }
    // Inform the batch engine that we are not finished,
    // and provide an estimation of the completion level we reached.
    if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
        $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
    }
}
开发者ID:CuBoulder,项目名称:cu-express-drops-7,代码行数:73,代码来源:form.api.php

示例6: viewEntities

 /**
  * {@inheritdoc}
  *
  * Pipe the 'meters' entry point to the relevant meter handler.
  */
 public function viewEntities($ids_string)
 {
     $ids = array_unique(array_filter(explode(',', $ids_string)));
     $output = array();
     $account = $this->getAccount();
     foreach ($ids as $id) {
         $node = node_load($id);
         if ($node->type == 'iec_meter') {
             $resource = 'iec_meters';
         } elseif ($node->type == 'modbus_meter') {
             $resource = 'modbus_meters';
         }
         // The resource, by convention, is the plural form of the content-type
         // (for 'modbus_meter', it'll be 'modbus_meters').
         $resource = $node->type . 's';
         $handler = restful_get_restful_handler($resource);
         // Pipe the account.
         $handler->setAccount($account);
         // Get the meter.
         $output[] = $handler->viewEntity($id);
     }
     // Prepare summary data for the formatter.
     $this->prepareSummary($this);
     return $output;
 }
开发者ID:Gizra,项目名称:negawatt-server,代码行数:30,代码来源:NegawattMeterResource.class.php

示例7: hook_og_access

/**
 * Determine if a user has access to a certain operation within a group context.
 *
 * For content access @see hook_og_node_access().
 *
 * @param $op
 *   The operation name.
 * @param $node
 *   The group or group content node object.
 * @param $acting_user
 *   The user object of the acting user.
 * @param $account
 *   Optional; The account related to the operation.
 * @return
 *   OG_ACCESS_ALLOW  - if operation is allowed;
 *   OG_ACCESS_DENY   - if it should be denied;
 *   OG_ACCESS_IGNORE - if you don't care about this operation.
 */
function hook_og_access($op, $node, $acting_user, $account = NULL)
{
    if ($op == 'view') {
        // Show group content only if they are in a certain day, defined in the
        // group's data. This data is fictional, and it's up to an implementing
        // module to implement it.
        if (og_is_group_content_type($node->type)) {
            // Get the first node group this group content belongs to.
            $gids = og_get_object_groups('node', $node);
            $group = node_load($gids[0]);
            if (!empty($group->data['show day'])) {
                $today = date('N');
                if ($group->data['show day'] == $today) {
                    return OG_ACCESS_ALLOW;
                } else {
                    return OG_ACCESS_DENY;
                }
            } else {
                // The group doesn't have a day definition, so we don't care about this
                // operation.
                return OG_ACCESS_IGNORE;
            }
        }
    }
}
开发者ID:Br3nda,项目名称:drupal-module-og,代码行数:43,代码来源:og.api.php

示例8: guifi_funders_validate

function guifi_funders_validate($node)
{
    /*
     * Validate funder(s)
     */
    foreach ($node->funders as $k => $f) {
        guifi_log(GUIFILOG_TRACE, 'function guifi_funders_validate(m)', $f);
        if (!empty($f['supplier'])) {
            $mtemp = explode('-', $f['supplier']);
            if (is_numeric($mtemp[0])) {
                $supplier = node_load($mtemp[0]);
            } else {
                form_set_error('funders][' . $k . '][supplier', t('%supplier has to be registered as supplier/provider', array('%supplier' => $f['supplier'])));
            }
        }
        if (!empty($f['user'])) {
            $mtemp = explode('-', $f['user']);
            if (is_numeric($mtemp[0])) {
                $user = user_load($mtemp[0]);
            } else {
                form_set_error('funders][' . $k . '][user', t('%user has to be a valid user', array('%user' => $f['user'])));
            }
        }
    }
    guifi_log(GUIFILOG_TRACE, 'function guifi_funders_validate(funder)', $funder);
}
开发者ID:itorres,项目名称:drupal-guifi,代码行数:26,代码来源:guifi_funders.inc.php

示例9: getFieldInstances

 /**
  * Returns field instances attached to the comment.
  *
  * @return array
  *   An array of field instances.
  */
 public function getFieldInstances()
 {
     $nid = $this->getNidValues();
     $node = node_load($nid);
     $bundle = 'comment_node_' . $node->type;
     return field_info_instances('comment', $bundle);
 }
开发者ID:vishalred,项目名称:redtest-core-pw,代码行数:13,代码来源:Comment.php

示例10: content

 /**
  * {@inheritdoc}
  */
 public function content()
 {
     // Get the list of the reservation node ids.
     $storage = \Drupal::entityManager()->getStorage('node');
     $reserved_list = \Drupal::entityQuery('node')->condition('status', 1)->condition('type', 'balagan_reservation')->condition('field_balagan_reserv_accom', 'NULL', '<>')->condition('field_balagan_reserv_customer', 'NULL', '<>')->execute();
     $reserved_accom = array();
     $build = array();
     foreach ($reserved_list as $nid) {
         $reserved_accom[] = $storage->load($nid)->field_balagan_reserv_accom->getValue()[0]['target_id'];
     }
     if (!empty($reserved_accom)) {
         $accommodations = \Drupal::entityQuery('node')->condition('status', 1)->condition('type', 'balagan_accommodation')->condition('nid', $reserved_accom, 'NOT IN')->execute();
         foreach ($accommodations as $item) {
             $node = node_load($item);
             $locality = $node->field_balagan_accom_address->getValue()[0]['locality'];
             $start = $node->field_balagan_accom_date->getValue()[0]['value'];
             $end = $node->field_balagan_accom_date->getValue()[1]['value'];
             $people = $node->field_balagan_accom_people->getValue()[0]['value'];
             $link = $node->toLink()->toRenderable();
             $build[] = $link;
             $build[] = array('markup' => array('#type' => 'markup', '#markup' => ' ' . $locality . ' ' . $start . ' - ' . $end . ' ' . 'Room for: ' . $people . '<BR>'));
         }
     }
     return $build;
 }
开发者ID:balagan73,项目名称:cheppers_work,代码行数:28,代码来源:BalaganAvailAccomController.php

示例11: getBoxFolderID

 /**
  * Helper function to get the Box id number from the node. Includes
  * a check to see if the node is an organic group or not.
  */
 public static function getBoxFolderID($gid)
 {
     // Is session active
     self::isSessionActive();
     $node = node_load($gid);
     // ->soc_boxgroup_folder
     // if not group
     if (!og_is_group('node', $node)) {
         $msg = t('@node_title is not an Group', ['@node_title' => $node->title]);
         watchdog(self::BOX_OPERATIONS_NAME, $msg);
         drupal_set_message($msg, 'error');
         return FALSE;
     }
     // return URL if we can
     $ent = entity_metadata_wrapper('node', $node);
     $box_id = $ent->soc_boxgroup_folder->value();
     // if field is blank
     if (is_null($box_id)) {
         $msg = t('@node_title does not have a box folder url assigned to it', ['@node_title' => $node->title]);
         watchdog(SOC_BOXGROUP_MODULE_NAME, $msg);
         drupal_set_message($msg, 'error');
         return FALSE;
     }
     // is it not numeric
     if (!is_numeric($box_id)) {
         watchdog(SOC_BOXGROUP_MODULE_NAME, t('@node_title (@nid) does not have a numeric folder id assigned to it', ['@node_title' => $node->title, '@nid' => $node->nid]));
         return FALSE;
     }
     // Lastly, if we get this far, just return the value;
     return $ent->soc_boxgroup_folder->value();
 }
开发者ID:rgoodie,项目名称:soc_boxauth,代码行数:35,代码来源:BoxFolderOperations.class.php

示例12: apply

    public function apply ( $patients ) {

        if ( !is_array($patients) ) {
            $patients = array($patients);
        }

        foreach ( $patients as $patient ) {
            \LogHelper::log_info('Applying ReportConfigRemoveColumnConfig treatment to: ' . $patient->reportNodeId);

            $node = node_load($patient->reportNodeId);

            $reportConfigText = get_node_field_value($node, 'field_report_conf', 0, 'value', FALSE);
            $reportConfig = isset($reportConfigText) ? json_decode($reportConfigText) : NULL;
            if (!isset($reportConfig)) {
                \LogHelper::log_info('Report configuration is EMPTY');
                return;
            }

            // check column configs
            if (!empty($reportConfig->columnConfigs)) {
                foreach ($reportConfig->columnConfigs as $key => $value) {
                    if (empty($value->columnId)) {
                        unset($reportConfig->columnConfigs[$key]);
                    }
                }

                $node->field_report_conf[$node->language][0]['value'] = json_encode($reportConfig);
                node_save($node);
            }
        }
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:31,代码来源:RemoveColumnConfigTreatment.php

示例13: truncateColumnStorage

    public function truncateColumnStorage(DataControllerCallContext $callcontext, DataSourceStructureHandler $datasourceStructureHandler, DatasetMetaData $dataset, $columnName) {
        $datasetNode = node_load($this->logicalDataset->nid);
        $datasetNode->field_dataset_records[$datasetNode->language][0]['value'] = 0;
        node_save($datasetNode);

        parent::truncateColumnStorage($callcontext, $datasourceStructureHandler, $dataset, $columnName);
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:7,代码来源:GD_TruncateDatasetStorageObserver.php

示例14: hook_nodewords_tags_permission_alter

/**
 * Changes the permission a user has on the meta tags being edited.
 *
 * @param &$permission
 *   TRUE, if the user can edit the current meta tag.
 * @param $object
 *   An array describing the object to which the meta tag are associated.
 * @param $tag_name
 *   The name of the meta tag.
 * @param $tag_info
 *   An array describing the meta tag.
 */
function hook_nodewords_tags_permission_alter(&$permission, $object, $tag_name, $tag_info)
{
    global $user;
    if (user_access('administer meta tags')) {
        $permission = TRUE;
        return;
    }
    if ($object['type'] == 'node' && ($node = node_load($options['id']))) {
        if ($user->uid == $node->uid && user_access("edit one's own node meta tags")) {
            $permission = TRUE;
            return;
        }
        if (user_access('edit any node meta tags')) {
            $permission = TRUE;
        } else {
            $permission = FALSE;
        }
    } elseif ($object['type'] == 'user' && ($account = user_load($object['id']))) {
        if ($user->uid == $account->uid && user_access("edit one's own user profile meta tags")) {
            $permission = TRUE;
            return;
        }
        if (user_access('edit any user profile meta tags')) {
            $permission = TRUE;
        } else {
            $permission = FALSE;
        }
    }
}
开发者ID:robertfoleyjr,项目名称:robertfoleyjr-d6,代码行数:41,代码来源:nodewords.api.php

示例15: dguk_preprocess_node

/**
 *  Implements hook_preprocess_node().
 */
function dguk_preprocess_node(&$variables)
{
    $variables['classes_array'][] = 'boxed';
    $full_node = node_load($variables['node']->nid);
    $variables['title'] = $full_node->title;
    $variables['theme_hook_suggestions'][] = 'node__' . $variables['view_mode'];
    $variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->type . '__' . $variables['view_mode'];
    if ($variables['node']->type == 'resource' || $variables['node']->type == 'book') {
        $variables['submitted'] = 'Submitted on ' . format_date($variables['created']);
    }
    $variables['updated'] = $variables['created'] != $variables['changed'] ? '| Updated on ' . format_date($variables['changed']) : FALSE;
    // We render user picture only on forum and blog nodes.
    if ($variables['node']->type == 'forum' || $variables['node']->type == 'blog') {
        $fields = field_info_instances('user', 'user');
        $field_id = $fields['field_avatar']['field_id'];
        $user = new stdClass();
        $user->uid = $variables['node']->uid;
        field_attach_load('user', array($user->uid => $user), FIELD_LOAD_CURRENT, array('field_id' => $field_id));
        if (!empty($user->field_avatar)) {
            $field = field_get_items('user', $user, 'field_avatar');
            $image = field_view_value('user', $user, 'field_avatar', $field[0], array('settings' => array('image_style' => 'avatar')));
        } else {
            $image_info = dguk_default_field_image('field_avatar');
            $image = field_view_value('user', $user, 'field_avatar', (array) $image_info, array('settings' => array('image_style' => 'avatar')));
        }
        $colour = $variables['node']->uid % 10;
        if ($variables['node']->uid) {
            $variables['avatar'] = l(render($image), 'user/' . $variables['node']->uid, array('html' => true, 'attributes' => array('class' => array('field-avatar', 'bg-colour-' . $colour))));
        } else {
            $variables['avatar'] = '<div class="field-avatar bg-colour-0">' . render($image) . '</div>';
        }
    }
}
开发者ID:davidread,项目名称:dgu_d7,代码行数:36,代码来源:template.php


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