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


PHP node_save函数代码示例

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


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

示例1: savePosts

 private function savePosts()
 {
     $counter = 0;
     foreach ($this->dbhWp->query('SELECT p.* FROM wp_posts p WHERE p.post_type = \'post\' ORDER BY p.post_date', PDO::FETCH_ASSOC) as $post) {
         echo $counter++ . PHP_EOL;
         $node = new stdClass();
         $node->type = 'blog';
         $node->uid = 3;
         // hosszu.kalman
         $node->created = strtotime($post['post_date']);
         $node->status = $post['post_status'] == 'publish';
         $node->title = $post['post_title'];
         $node->body = $post['post_content'];
         $node->format = 4;
         // New importer input filter
         $node->comment = 2;
         $this->addGeSHiFilter($node);
         $node->teaser = node_teaser($node->body, 4);
         $this->addTerms($node, $post['ID']);
         $this->addMetaKeywords($node, $post['ID']);
         node_save($node);
         $this->dbhImport->query('INSERT INTO posts VALUES (' . $post['ID'] . ', ' . $node->nid . ')');
         $redirect = array('source' => $post['post_name'], 'redirect' => 'node/' . $node->nid);
         $this->saveRedirect($redirect);
         if ($post['pinged']) {
             $redirect = array('source' => $post['pinged'], 'redirect' => 'node/' . $node->nid);
             $this->saveRedirect($redirect);
         }
     }
 }
开发者ID:hosszukalman,项目名称:wp2drupal,代码行数:30,代码来源:Posts.php

示例2: 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

示例3: 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

示例4: run

 public function run($args)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'ifcheck=:ifcheck';
     $criteria->params = array(':ifcheck' => '已通过');
     $news = Bl::model()->findAll($criteria);
     foreach ($news as $new) {
         $node = new stdClass();
         $node->title = $new->title;
         $node->field_phone['und'][0]['value'] = $new->phone;
         $node->type = "_xiansuo";
         $node->body['und'][0]['value'] = $new->content;
         $node->field_shimin['und'][0]['value'] = $new->name;
         $node->uid = 1;
         $node->language = 'zh-hans';
         $node->status = 1;
         //(1 or 0): published or not
         $node->promote = 0;
         //(1 or 0): promoted to front page
         $node->comment = 2;
         // 0 = comments disabled, 1 = read only, 2 = read/write
         if ($new->img1 != "") {
             $suoluetu = 'e://wamp/www/epaper/assets/bl/b_' . $new->img1;
             $file = (object) array('uid' => 1, 'uri' => $suoluetu, 'filemime' => 'image/jpeg', 'status' => 1);
             $file = file_copy($file, 'public://pictures/');
             $node->field_tux['und'][0] = (array) $file;
             $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://wm12.cn:88/admin/assets/img/" . $new->img1 . " \" style=\"width: 100%;\"/></div>";
             $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
         }
         $node = node_submit($node);
         // Prepare node for saving
         node_save($node);
         unset($node);
     }
 }
开发者ID:dingruoting,项目名称:tydaily,代码行数:35,代码来源:BlCommand.php

示例5: apply

    public function apply ( $patients ) {

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

        foreach ( $patients as $patient ) {
            \LogHelper::log_info('Applying ReportConfigRemoveFilter 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->model->filters)) {
                $preservedFilters = array();
                foreach ($reportConfig->model->filters as $key => $filter) {
                    if ( $patient->filter != $filter ) {
                        $preservedFilters[] = $filter;
                    }
                }
                $reportConfig->model->filters = $preservedFilters;

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

示例6: 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

示例7: 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

示例8: 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

示例9: 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 array|\ArrayAccess $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.
 *   It is discouraged to typehint this parameter as an array, to allow an
 *   object implement \ArrayAccess to be passed.
 */
function callback_batch_operation($MULTIPLE_PARAMS, &$context)
{
    $node_storage = \Drupal::entityTypeManager()->getStorage('node');
    $database = \Drupal::database();
    if (!isset($context['sandbox']['progress'])) {
        $context['sandbox']['progress'] = 0;
        $context['sandbox']['current_node'] = 0;
        $context['sandbox']['max'] = $database->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 = $database->queryRange("SELECT nid FROM {node} WHERE nid > :nid ORDER BY nid ASC", 0, $limit, [':nid' => $context['sandbox']['current_node']]);
    foreach ($result as $row) {
        // Here we actually perform our processing on the current node.
        $node_storage->resetCache(array($row['nid']));
        $node = $node_storage->load($row['nid']);
        $node->value1 = $options1;
        $node->value2 = $options2;
        node_save($node);
        // Store some result for post-processing in the finished callback.
        $context['results'][] = $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:sgtsaughter,项目名称:d8portfolio,代码行数:78,代码来源:form.api.php

示例10: apply

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

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

            $reportNode = node_load($patient->reportNodeId);
            $reportConfigText = get_node_field_value($reportNode, 'field_report_conf', 0, 'value', FALSE);

            $reportConfig = isset($reportConfigText) ? json_decode($reportConfigText) : NULL;
            if (!isset($reportConfig)) {
                \LogHelper::log_info('Report configuration is EMPTY');
                continue;
            }

            // check columns
            if (!empty($reportConfig->model->datasets)) {
                $reportNode->field_report_dataset_sysnames[$reportNode->language] = array();
                foreach ($reportConfig->model->datasets as $datasetName) {
                    $reportNode->field_report_dataset_sysnames[$reportNode->language][] = array('value' => $datasetName);
                }
                node_save($reportNode);
            }

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

示例11: 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

示例12: actionCreate

 public function actionCreate()
 {
     $basic = new basic();
     if (isset($_POST['title']) & isset($_POST['content']) & isset($_POST['phone'])) {
         $node = new stdClass();
         $node->title = $_POST['title'];
         $node->body['und'][0]['value'] = $_POST['content'];
         $node->field_phone['und'][0]['value'] = $_POST['phone'];
         $node->uid = 1;
         $node->type = 'yijianfank';
         $node->language = 'zh-hans';
         $node->status = 1;
         //(1 or 0): published or not
         $node->promote = 0;
         //(1 or 0): promoted to front page
         $node->comment = 0;
         // 0 = comments disabled, 1 = read only, 2 = read/write
         $node = node_submit($node);
         // Prepare node for saving
         //print_r($node);
         node_save($node);
         $basic->error_code = 0;
         //$basic->error_msg="no input parameters";
     } else {
         $basic->error_code = 1;
         $basic->error_msg = "no input parameters";
     }
     $jsonObj = CJSON::encode($basic);
     echo $jsonObj;
 }
开发者ID:dingruoting,项目名称:tydaily,代码行数:30,代码来源:FeedbackController.php

示例13: unpromoteNode

 /**
  * Removes node from front page by $nid.
  */
 public static function unpromoteNode($nid)
 {
     // Load the node object.
     $node = node_load($nid);
     // Set promote property to 0.
     $node->promote = 0;
     // Save the node.
     node_save($node);
 }
开发者ID:kastowo,项目名称:idbigdata,代码行数:12,代码来源:NodeHelper.php

示例14: insertar_contenido

function insertar_contenido($content_type, $archivo_datos)
{
    $handle = fopen($archivo_datos, "r");
    $theHeaders = fgetcsv($handle, 4096, "\t");
    $lineno = 0;
    while ($line = fgetcsv($handle, 4096, "\t")) {
        $output .= '';
        $valueno = 0;
        $lineno++;
        $output .= '<ul>L’nea: ' . $lineno;
        $observaciones = '';
        foreach ($line as $value) {
            if ($value) {
                $output .= '<li>' . $theHeaders[$valueno] . ': ' . $value . '</li>';
                $observaciones .= '<li>' . $theHeaders[$valueno] . ': ' . $value . '</li>';
            }
            $valueno++;
        }
        $output .= '</ul>';
        $node = array();
        $node['title'] = $line[3];
        $node['body'] = $observaciones;
        $node['type'] = $content_type;
        $node['format'] = 3;
        //$node['taxonomy'] = $_REQUEST['taxonomy'];
        $node['name'] = $content_name;
        //$node['date'] = $_REQUEST['date'];
        $node['status'] = 1;
        $node['promote'] = 0;
        $node['sticky'] = 0;
        $log = 'Importado por importar-contactos el ' . date('g:i:s a');
        $node['log'] = $log;
        $node['field_empresa'] = array(0 => array('nid' => db_result(db_query("SELECT nid FROM {node} WHERE title = '%s'", $line[2]))));
        $node['field_cargo'] = array(0 => array('value' => $line[22]));
        $node['field_saludo'] = array(0 => array('value' => $line[17]));
        $node['field_nombres'] = array(0 => array('value' => $line[54]));
        $node['field_apellidos'] = array(0 => array('value' => $line[55]));
        $node['field_mvil'] = array(0 => array('value' => $line[15]));
        $node['field_telfono_particular'] = array(0 => array('value' => $line[14]));
        $node['field_buscapersonas'] = array(0 => array('value' => $line[16]));
        $node['field_e_mail'] = array(0 => array('value' => $line[89]));
        /*
          // this code, from the autosave module, is unnecessary, since node_save will do it for us :)
          $node['nid'] = db_result(db_query("SELECT id FROM {sequences} WHERE name = '%s'", 'node_nid')) + 1;
          $node['vid'] = db_result(db_query("SELECT id FROM {sequences} WHERE name = '%s'", 'node_revisions_vid')) + 1;
        */
        if ($node['title']) {
            $node = (object) $node;
            $node = node_submit($node);
            node_save($node);
            print $output;
            $nid = $node->nid;
            $tid = 6;
            db_query("INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)", $nid, $tid);
        }
    }
}
开发者ID:msshin0313,项目名称:daniel-code-snippet,代码行数:57,代码来源:from_gdo.php

示例15: importo_save_node

function importo_save_node($node)
{
    $node = node_submit($node);
    if (!$node) {
        _die("FATAL [" . __FILE__ . " (" . __LINE__ . ")]: node_submit failed");
    }
    node_save($node);
    return $node;
}
开发者ID:bartcornelis,项目名称:comfortenergy,代码行数:9,代码来源:import.php


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