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


PHP node_object_prepare函数代码示例

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


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

示例1: nodeCreate

 /**
  * {@inheritdoc}
  */
 public function nodeCreate($node)
 {
     $current_path = getcwd();
     chdir(DRUPAL_ROOT);
     // Set original if not set.
     if (!isset($node->original)) {
         $node->original = clone $node;
     }
     // Assign authorship if none exists and `author` is passed.
     if (!isset($node->uid) && !empty($node->author) && ($user = user_load(array('name' => $node->author)))) {
         $node->uid = $user->uid;
     }
     // Convert properties to expected structure.
     $this->expandEntityProperties($node);
     // Attempt to decipher any fields that may be specified.
     $this->expandEntityFields('node', $node);
     // Set defaults that haven't already been set.
     $defaults = clone $node;
     module_load_include('inc', 'node', 'node.pages');
     node_object_prepare($defaults);
     $node = (object) array_merge((array) $defaults, (array) $node);
     node_save($node);
     chdir($current_path);
     return $node;
 }
开发者ID:acbramley,项目名称:DrupalDriver,代码行数:28,代码来源:Drupal6.php

示例2: new_empty_node

function new_empty_node($title, $bundle_type, $extra = NULL, $lang = LANGUAGE_NONE)
{
    $node = new stdClass();
    $node->type = $bundle_type;
    $node->language = $lang;
    // und
    $node->status = 1;
    // published
    $node->is_new = true;
    $node->title = $title;
    if (!empty($extra)) {
        foreach ($extra as $k => $v) {
            $node->{$k} = $v;
        }
    }
    node_object_prepare($node);
    node_save($node);
    ft_table_insert($node);
    // defined in expsearch.admin.inc
    return $node;
    /*
    $records = db_query("SELECT max(nid) as nid FROM node");
    $nid = 0;
    foreach($records as $record) { $nid = $record->nid; }
    return $nid;
    */
}
开发者ID:318io,项目名称:318-io,代码行数:27,代码来源:easier.drupal.php

示例3: insert_door_to_drupal

 function insert_door_to_drupal($door_id)
 {
     // set HTTP_HOST or drupal will refuse to bootstrap
     $_SERVER['HTTP_HOST'] = 'zl-apps';
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
     drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
     $door = new Door();
     $door_detail = $door->read(null, $door_id);
     $door_nid = null;
     $query = new EntityFieldQuery();
     $entities = $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'doors')->propertyCondition('status', 1)->fieldCondition('field_door_id', 'value', $door_detail['Door']['id'], '=')->execute();
     foreach ($entities['node'] as $nid => $value) {
         $door_nid = $nid;
         break;
         // no need to loop more even if there is multiple (it is supposed to be unique
     }
     $node = null;
     if (is_null($door_nid)) {
         $node = new stdClass();
         $node->language = LANGUAGE_NONE;
     } else {
         $node = node_load($door_nid);
     }
     $node->type = 'doors';
     node_object_prepare($node);
     $node->title = $door_detail['Door']['door_style'];
     $node->field_door_id[$node->language][0]['value'] = $door_detail['Door']['id'];
     $node->sell_price = 0;
     $node->model = $door_detail['Door']['door_style'];
     $node->shippable = 1;
     $path = 'door/' . $node->title;
     $node->path = array('alias' => $path);
     node_save($node);
 }
开发者ID:khaled-saiful-islam,项目名称:zen_v1.0,代码行数:35,代码来源:Door.php

示例4: __construct

 /**
  * Default constructor for the node object. Do not call this class directly.
  * Create a separate class for each content type and use its constructor.
  *
  * @param int $nid
  *   Nid if an existing node is to be loaded.
  */
 public function __construct($nid = NULL)
 {
     $class = new \ReflectionClass(get_called_class());
     $type = Utils::makeSnakeCase($class->getShortName());
     if (!is_null($nid) && is_numeric($nid)) {
         $node = node_load($nid);
         if (!$node) {
             $this->setErrors("Node with nid {$nid} does not exist.");
             $this->setInitialized(FALSE);
             return;
         }
         if ($node->type != $type) {
             $this->setErrors("Node's type doesn't match the class.");
             $this->setInitialized(FALSE);
             return;
         }
         parent::__construct($node);
     } else {
         global $user;
         $node = (object) array('title' => NULL, 'type' => $type, 'language' => LANGUAGE_NONE, 'is_new' => TRUE, 'name' => $user->name);
         node_object_prepare($node);
         parent::__construct($node);
     }
     $this->setInitialized(TRUE);
 }
开发者ID:redcrackle,项目名称:redtest-core,代码行数:32,代码来源:Node.php

示例5: entityPreSave

 /**
  * Overrides RestfulEntityBase::entityPreSave().
  *
  * Set the node author and other defaults.
  */
 public function entityPreSave(\EntityMetadataWrapper $wrapper) {
   $node = $wrapper->value();
   if (!empty($node->nid)) {
     // Node is already saved.
     return;
   }
   node_object_prepare($node);
   $node->uid = $this->getAccount()->uid;
 }
开发者ID:humanitarianresponse,项目名称:site,代码行数:14,代码来源:RestfulEntityBaseNode.php

示例6: handleDocumentInfo

 function handleDocumentInfo($DocInfo)
 {
     $this->urls_processed[$DocInfo->http_status_code][] = $DocInfo->url;
     if (200 != $DocInfo->http_status_code) {
         return;
     }
     $nid = db_select('field_data_field_sitecrawler_url', 'fdfsu')->fields('fdfsu', array('entity_id'))->condition('fdfsu.field_sitecrawler_url_url', $DocInfo->url)->execute()->fetchField();
     if (!!$nid) {
         $node = node_load($nid);
         $this->nodes_updated++;
     } else {
         $node = new stdClass();
         $node->type = 'sitecrawler_page';
         node_object_prepare($node);
         $this->nodes_created++;
     }
     $node->title = preg_match('#<head.*?<title>(.*?)</title>.*?</head>#is', $DocInfo->source, $matches) ? $matches[1] : $DocInfo->url;
     $node->language = LANGUAGE_NONE;
     $node->field_sitecrawler_url[$node->language][0]['title'] = $node->title;
     $node->field_sitecrawler_url[$node->language][0]['url'] = $DocInfo->url;
     //     $node->field_sitecrawler_summary[$node->language][0]['value'] =
     // drupal_set_message('<pre style="border: 1px solid red;">body_xpaths: ' . print_r($this->body_xpaths,1) . '</pre>');
     $doc = new DOMDocument();
     $doc->loadHTML($DocInfo->source);
     foreach ($this->body_xpaths as $body_xpath) {
         $xpath = new DOMXpath($doc);
         // $body = $xpath->query('/html/body');
         // $body = $xpath->query('//div[@id="layout"]');
         $body = $xpath->query($body_xpath);
         if (!is_null($body)) {
             foreach ($body as $i => $element) {
                 $node_body = $element->nodeValue;
                 if (!empty($node_body)) {
                     break 2;
                 }
             }
         }
     }
     if (empty($node_body)) {
         $node_body = preg_match('#<body.*?>(.*?)</body>#is', $DocInfo->source, $matches) && !empty($matches[1]) ? $matches[1] : $DocInfo->source;
     }
     $node_body = mb_check_encoding($node_body, 'UTF-8') ? $node_body : utf8_encode($node_body);
     $node->body[$node->language][0]['value'] = $node_body;
     $node->body[$node->language][0]['summary'] = text_summary($node_body);
     $node->body[$node->language][0]['format'] = filter_default_format();
     // store the Drupal crawler ID from the opensanmateo_sitecrawler_sites table
     $node->field_sitecrawler_id[$node->language][0]['value'] = $this->crawler_id;
     // store the PHPCrawler ID for this pull of the site
     $node->field_sitecrawler_instance_id[$node->language][0]['value'] = $this->getCrawlerId();
     node_save($node);
     $this->{'nodes_' . (!!$nid ? 'updated' : 'created')}[$node->nid] = $node->title . ' :: ' . $DocInfo->url;
 }
开发者ID:anselmbradford,项目名称:OpenSanMateo,代码行数:52,代码来源:SiteCrawler.class.php

示例7: testConfigurationForm

 function testConfigurationForm()
 {
     // We need a real node because webform_component_edit_form() uses it.
     $node = (object) array('type' => 'webform');
     node_object_prepare($node);
     $node->webform['components'] = $this->components;
     node_save($node);
     $form = FormBuilderWebformForm::loadFromStorage('webform', $node->nid, 'the-sid', array());
     $form_state = array();
     $element = $form->getElement('cid_2');
     $a = $element->configurationForm(array(), $form_state);
     $this->assertEqual(array('#_edit_element' => array('#webform_component' => array('nid' => $node->nid, 'cid' => '2', 'pid' => '0', 'form_key' => 'textfield1', 'name' => 'textfield1', 'type' => 'textfield', 'value' => 'textfield1', 'extra' => array('title_display' => 'before', 'private' => 0, 'disabled' => 1, 'unique' => 0, 'conditional_operator' => '=', 'width' => '4', 'maxlength' => '', 'field_prefix' => 'testprefix', 'field_suffix' => 'testpostfix', 'description' => '', 'attributes' => array(), 'conditional_component' => '', 'conditional_values' => ''), 'mandatory' => '0', 'weight' => '1', 'page_num' => 1), '#weight' => '1', '#key' => 'textfield1', '#form_builder' => array('element_id' => 'cid_2', 'parent_id' => 0, 'element_type' => 'textfield', 'form_type' => 'webform', 'form_id' => $node->nid, 'configurable' => TRUE, 'removable' => TRUE)), 'size' => array('#form_builder' => array('property_group' => 'display'), '#type' => 'textfield', '#size' => 6, '#title' => 'Size', '#default_value' => '4', '#weight' => 2, '#maxlength' => 5, '#element_validate' => array(0 => 'form_validate_integer')), 'maxlength' => array('#form_builder' => array('property_group' => 'validation'), '#type' => 'textfield', '#size' => 6, '#title' => 'Max length', '#default_value' => '', '#field_suffix' => ' characters', '#weight' => 3, '#maxlength' => 7, '#element_validate' => array(0 => 'form_validate_integer')), 'field_prefix' => array('#form_builder' => array('property_group' => 'display'), '#type' => 'textfield', '#title' => 'Prefix', '#default_value' => 'testprefix', '#weight' => -2), 'field_suffix' => array('#form_builder' => array('property_group' => 'display'), '#type' => 'textfield', '#title' => 'Suffix', '#default_value' => 'testpostfix', '#weight' => -1), 'disabled' => array('#form_builder' => array('property_group' => 'display'), '#title' => 'Disabled (read-only)', '#type' => 'checkbox', '#default_value' => TRUE, '#weight' => 12), 'unique' => array('#form_builder' => array('property_group' => 'validation'), '#title' => 'Unique', '#description' => 'Check that all entered values for this field are unique. The same value is not allowed to be used twice.', '#type' => 'checkbox', '#default_value' => 0), 'title' => array('#title' => 'Title', '#type' => 'textfield', '#default_value' => 'textfield1', '#maxlength' => 255, '#required' => TRUE, '#weight' => -10), 'title_display' => array('#type' => 'select', '#title' => 'Label display', '#default_value' => 'before', '#options' => array('before' => 'Above', 'inline' => 'Inline', 'none' => 'None'), '#description' => 'Determines the placement of the component\'s label.', '#weight' => 8, '#tree' => TRUE, '#form_builder' => array('property_group' => 'display')), 'default_value' => array('#type' => 'textfield', '#title' => 'Default value', '#default_value' => 'textfield1', '#weight' => 1), 'description' => array('#title' => 'Description', '#type' => 'textarea', '#default_value' => '', '#weight' => 5), 'webform_private' => array('#type' => 'checkbox', '#title' => 'Private', '#default_value' => FALSE, '#description' => 'Private fields are shown only to users with results access.', '#weight' => 45, '#disabled' => TRUE, '#tree' => TRUE, '#form_builder' => array('property_group' => 'display')), 'required' => array('#form_builder' => array('property_group' => 'validation'), '#title' => 'Required', '#type' => 'checkbox', '#default_value' => '0', '#weight' => -1), 'key' => array('#title' => 'Form key', '#type' => 'machine_name', '#default_value' => 'textfield1', '#maxlength' => 128, '#description' => 'The form key is used in the field "name" attribute. Must be alphanumeric and underscore characters.', '#machine_name' => array('source' => array(0 => 'title'), 'label' => 'Form key'), '#weight' => -9, '#element_validate' => array(0 => 'form_builder_property_key_form_validate')), 'weight' => array('#form_builder' => array('property_group' => 'hidden'), '#type' => 'textfield', '#size' => 6, '#title' => 'Weight', '#default_value' => '1')), $a);
 }
开发者ID:TeamTriplo,项目名称:triplo-build,代码行数:13,代码来源:FormBuilderWebformFormTest.php

示例8: addNode

function addNode($title, $content, $date)
{
    $node = new stdClass();
    $node->type = 'test_perf_1';
    node_object_prepare($node);
    $node->language = LANGUAGE_NONE;
    $node->uid = 1;
    $node->changed_by = 1;
    $node->status = 1;
    $node->created = time() - mt_rand(1000, 1451610061);
    $node->title = $title;
    $node->body[LANGUAGE_NONE][0] = array('value' => $content, 'format' => 'full_html');
    $node->field_test_date[LANGUAGE_NONE][0] = array('value' => $date, 'timezone' => 'UTC', 'timezone_db' => 'UTC');
    node_save($node);
}
开发者ID:cherouvim,项目名称:test-drupal-perf-1,代码行数:15,代码来源:add-dummy-content.php

示例9: __construct

 /**
  * Constructor that wraps the entity.
  */
 public function __construct($entity = NULL)
 {
     if ($entity) {
         $this->entity = $entity;
     } else {
         if ($this->getEntityType() == 'node') {
             // Node specific preparation.
             $this->entity = new stdClass();
             $this->entity->type = $this->getBundle();
             node_object_prepare($this->entity);
         } else {
             $this->entity = entity_create($this->getEntityType(), array('type' => $this->getBundle()));
         }
     }
 }
开发者ID:alnutile,项目名称:entity_decorator,代码行数:18,代码来源:EntityDecorator.php

示例10: hook_instagram_media_save

/**
 * Notifies of a newly saved instagram media item.
 *
 * @param $type  string
 *    The type of the instagram media (image, video)
 * @param $item
 *    The instagram media item object
 *   stdClass containing the instagram media item.
 * @see https://www.instagram.com/developer/endpoints/media/ for details about the contents of $item.
 */
function hook_instagram_media_save($type, $item)
{
    //
    // add a node for all new items
    $node = new stdClass();
    $node->type = 'instagram';
    $node->language = LANGUAGE_NONE;
    $node->uid = 1;
    $node->status = 1;
    node_object_prepare($node);
    // assign all fields
    $node->body[LANGUAGE_NONE][0]['value'] = $item->caption;
    // save node
    $node = node_submit($node);
    node_save($node);
}
开发者ID:PixelGarage,项目名称:hso2,代码行数:26,代码来源:instagram_social_feed.api.php

示例11: __construct

 /**
  * Default constructor for the node object. Do not call this class directly.
  * Create a separate class for each content type and use its constructor.
  *
  * @param int $nid
  *   Nid if an existing node is to be loaded.
  */
 public function __construct($nid = NULL)
 {
     $class = new \ReflectionClass(get_called_class());
     $type = Utils::makeSnakeCase($class->getShortName());
     if (!is_null($nid) && is_numeric($nid)) {
         $node = node_load($nid);
         if ($node->type == $type) {
             parent::__construct($node);
         }
     } else {
         global $user;
         $node = (object) array('title' => NULL, 'type' => $type, 'language' => LANGUAGE_NONE, 'is_new' => TRUE, 'name' => $user->name);
         node_object_prepare($node);
         parent::__construct($node);
     }
     $this->setInitialized(TRUE);
 }
开发者ID:vishalred,项目名称:redtest-core-pw,代码行数:24,代码来源:Node.php

示例12: _save_node

/**
 * node save
 */
function _save_node($param_array = NULL)
{
    global $user;
    $node = new stdClass();
    $node->type = $param_array['type'];
    $node->title = $param_array['title'];
    $node->language = LANGUAGE_NONE;
    // Or any language code if Locale module is enabled. More on this below *
    node_object_prepare($node);
    // Set some default values.
    $node->uid = $user->uid;
    $node->field_chassis_dspl_chassis['und'][0]['product_id'] = $param_array['product_pid'];
    // $node->field_card_dspl_card['und'][0]['product_id'] = $param_array['product_pid'];
    $node = node_submit($node);
    // Prepare node for a submit
    node_save($node);
    // After this call we'll get a nid
    $node_nid = $node->nid;
    drupal_set_message(t('Save node as ') . $node_nid);
    return $node->nid;
}
开发者ID:temptemp5678,项目名称:onequote2,代码行数:24,代码来源:batch_save_node.php

示例13: nodeCreate

 /**
  * {@inheritdoc}
  */
 public function nodeCreate($node)
 {
     // Set original if not set.
     if (!isset($node->original)) {
         $node->original = clone $node;
     }
     // Assign authorship if none exists and `author` is passed.
     if (!isset($node->uid) && !empty($node->author) && ($user = user_load_by_name($node->author))) {
         $node->uid = $user->uid;
     }
     // Convert properties to expected structure.
     $this->expandEntityProperties($node);
     // Attempt to decipher any fields that may be specified.
     $this->expandEntityFields('node', $node);
     // Set defaults that haven't already been set.
     $defaults = clone $node;
     node_object_prepare($defaults);
     $node = (object) array_merge((array) $defaults, (array) $node);
     node_save($node);
     return $node;
 }
开发者ID:acbramley,项目名称:DrupalDriver,代码行数:24,代码来源:Drupal7.php

示例14: createContentFromImage

/**
 * Funzione che consente di creare automaticamente un contenuto drupal con le immagini jpg caricate in temp_img
 * e i dati exif ricavati da esse.
 *
 * @param $lat
 * @param $lng
 * @param $fileName
 *
 */
function createContentFromImage($lat, $lng, $fileName)
{
    $node = new stdClass();
    // Create a new node object Or page, or whatever content type you like
    $node->type = "exif_data";
    // Set some default values
    node_object_prepare($node);
    $node->language = "en";
    $node->uid = 1;
    $coords = (object) array('lat' => $lat, 'lng' => $lng);
    $node->field_posizione['und'][0] = (array) $coords;
    //@ToDo here you have to substitute the path
    $file_path = "/var/www/.." . $fileName;
    $count_photo = count($file_path);
    for ($i = 0; $i < $count_photo; $i++) {
        if (getimagesize($file_path)) {
            $file_gallery = (object) array('uid' => 0, 'uri' => $file_path, 'filemime' => file_get_mimetype($file_path), 'status' => 1);
            //substitute "your_destination_folder" with a folder name
            try {
                file_copy($file_gallery, 'public://your_destination_folder');
                $node->field_image['und'][0] = (array) $file_gallery;
                echo "File correctly copied";
            } catch (Exception $e) {
                echo $e->getMessage();
            }
        }
    }
    //$node = node_submit($node); // Prepare node for saving
    if ($node = node_submit($node)) {
        // Prepare node for saving
        node_save($node);
        //Drupal node saving function call
        $status = "Content created correctly" . "";
    } else {
        $status = "Something went wrong during the node submitting";
    }
    echo $status;
}
开发者ID:marshall86,项目名称:Drupal-content-generator,代码行数:47,代码来源:contentGenerator.php

示例15: create

    private function create ( ReportEntity $entity ) {
        $node = new \stdClass();
        $node->type = self::NODE_TYPE;
        $node->language = LANGUAGE_NONE;
        node_object_prepare($node);

        $node->title = $entity->getName();
        $node->uid = $entity->getAuthor()->getId();

        $node->field_report_uuid[$node->language][0]['value'] = $entity->getUuid(); //Uuid::generate();

        $node->field_report_desc[$node->language][0]['value'] = $entity->getDescription();

        $node->field_report_datasource[$node->language][0]['value'] = $entity->getDatasource();

        $node->field_report_conf[$node->language][0]['value'] = $entity->getConfig()->toJson();

        $node->field_report_dataset_sysnames[$node->language] = array();
        foreach ( $entity->getDatasets() as $dataset ) {
            $node->field_report_dataset_sysnames[$node->language][] = array('value' => $dataset->name);
        }

        $node->field_report_custom_view[$node->language][0]['value'] = $entity->getCustomCode();

        $node->field_report_tags[$node->language] = array();
        foreach ( $entity->getTags() as $tag ) {
            $node->field_report_tags[$node->language][] = array('tid' => $tag->tid);
        }

        node_save($node);

        // update the entity object

        // created, updated, uuid, etc.

    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:36,代码来源:ReportRepository.php


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