本文整理汇总了PHP中node_save函数的典型用法代码示例。如果您正苦于以下问题:PHP node_save函数的具体用法?PHP node_save怎么用?PHP node_save使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了node_save函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: entity_save
/**
* Implement the save function for the entity.
*/
public function entity_save($entity)
{
if (module_exists('workbench_moderation') && workbench_moderation_node_type_moderated($entity->type)) {
$live_entity = workbench_moderation_node_live_load($entity);
if ($live_entity->vid != $entity->vid) {
$entity->revision = TRUE;
}
}
node_save($entity);
}
开发者ID:stevebresnick,项目名称:iomedia_stp_d7_core,代码行数:13,代码来源:PanelizerEntityNode.class.php
示例17: 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
示例18: 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
示例19: update
/**
* Updates a solution
*
* @param int $nid ["path","0"]
* The nid of the solution to update
* @param object $solution ["data"]
* The solution object
* @return object
*
* @Access(callback='DocuWalkSolutionResource::access', args={'update'}, appendArgs=true)
*/
public static function update($nid, $solution)
{
$attr = array('title', 'body');
$node = node_load($nid);
// Transfer attributes from
foreach ($attr as $name) {
if (isset($solution->{$name})) {
$node->{$name} = $solution->{$name};
}
}
node_save($node);
return (object) array('nid' => $node->nid, 'uri' => services_resource_uri(array('docuwalk-solution', $node->nid)), 'url' => url('node/' . $node->nid, array('absolute' => TRUE)));
}
开发者ID:hugowetterberg,项目名称:docuwalk,代码行数:24,代码来源:DocuWalkSolutionResource.php
示例20: run
public function run($args)
{
//$news=Yw::model()->findAll();
$criteria = new CDbCriteria();
// $criteria->select=array('content','create_time','nick');
// $criteria->condition='article_id=:article_id AND ifcheck=:ifcheck';
$criteria->order = 'id DESC';
//降序 最新的总是在最前面
// $criteria->params=array(':article_id'=>$param['id'],':ifcheck'=>'已通过');
$news = Zt::model()->findAll($criteria);
foreach ($news as $key => $new) {
if ($key < 2) {
$node = new stdClass();
$node->title = $new->title;
$node->body['und'][0]['value'] = $new->content;
$node->field_fubiaoti['und'][0]['value'] = $new->subTitle;
$node->field_src['und'][0]['value'] = $new->src;
$node->field_label['und'][0]['value'] = $new->label;
$node->field_myspecial['und'][0]['tid'] = 98;
$node->uid = 1;
$node->type = 'article';
$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->img3 != "") {
$htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132:88/admin/assets/img/" . $new->img3 . " \" style=\"width: 100%;\"/></div>";
$node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
}
if ($new->img2 != "") {
$htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132:88/admin/assets/img/" . $new->img2 . " \" style=\"width: 100%;\"/></div>";
$node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
}
if ($new->img1 != "") {
$suoluetu = 'http://202.99.222.132:88/admin/assets/img/b_' . $new->img1;
$file = (object) array('uid' => 1, 'uri' => $suoluetu, 'filemime' => 'image/jpeg', 'status' => 1);
$file = file_copy($file, 'public://pictures/');
$node->field_image['und'][0] = (array) $file;
$htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132: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
//print_r($node);
node_save($node);
}
}
}
开发者ID:dingruoting,项目名称:tydaily,代码行数:51,代码来源:NewsCommand.php
注:本文中的node_save函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论