本文整理汇总了PHP中Sections::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Sections::put方法的具体用法?PHP Sections::put怎么用?PHP Sections::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sections
的用法示例。
在下文中一共展示了Sections::put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$fields = array();
// submit
$context['text'] .= Skin::build_block(i18n::s('Start'), 'title');
// the submit button
$context['text'] .= '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Add content'), i18n::s('Press [s] to submit data'), 's') . '</p>' . "\n";
// end of the form
$context['text'] .= '</div></form>';
// append the script used for data checking on the browser
Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . ' if(!container.title.value) {' . "\n" . ' alert("' . i18n::s('Please provide a meaningful title.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' return true;' . "\n" . '}' . "\n" . "\n" . '$("#main_title").focus();' . "\n");
// create the stuff
} else {
// update the main section
$item['title'] = $_REQUEST['main_title'];
$item['introduction'] = $_REQUEST['main_introduction'];
$item['description'] = $_REQUEST['main_description'];
Sections::put($item);
// create new sections
for ($index = 0; $index < count($_REQUEST['titles']); $index++) {
$fields = array();
$fields['anchor'] = 'section:' . $item['id'];
$fields['title'] = $_REQUEST['titles'][$index];
$fields['introduction'] = $_REQUEST['introductions'][$index];
$fields['articles_layout'] = 'none';
// no articles here
$fields['options'] = 'with_links';
if ($fields['title']) {
Sections::post($fields, FALSE);
}
}
// increment the post counter of the surfer
Users::increment_posts(Surfer::get_id());
示例2: array
return;
}
// update an existing page
if (isset($_REQUEST['id'])) {
// remember the previous version
if ($item['id']) {
Versions::save($item, 'section:' . $item['id']);
}
// overlay has been inserted or updated
if (isset($_REQUEST['overlay_type']) && $_REQUEST['overlay_type']) {
$action = 'insert';
} else {
$action = 'update';
}
// stop on error
if (!Sections::put($_REQUEST) || is_object($overlay) && !$overlay->remember($action, $_REQUEST, 'section:' . $_REQUEST['id'])) {
$item = $_REQUEST;
$with_form = TRUE;
// else display the updated page
} else {
// cascade changes on access rights
if ($_REQUEST['active'] != $item['active']) {
Anchors::cascade('section:' . $item['id'], $_REQUEST['active']);
}
// notification to send by e-mail
$mail = array();
$mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Contribution'), strip_tags($_REQUEST['title']));
$mail['notification'] = Sections::build_notification('update', $_REQUEST);
$mail['headers'] = Mailer::set_thread('section:' . $_REQUEST['id']);
// notify watchers of the updated section and of its parent
if ($handle = new Section()) {
示例3: restore
/**
* restore a previous version of this section
*
* @see versions/restore.php
*
* @param array set of attributes to restore
* @return TRUE on success, FALSE otherwise
*/
function restore($item)
{
global $context;
// restore this instance
$this->item = $item;
// save updated state
return Sections::put($item);
}
示例4: parse_tag_close
function parse_tag_close($parser, $tag)
{
global $context;
global $in_overlay, $overlay_class, $overlay_parameters;
global $parsed_cdata, $parsed_item, $parsed_overlay, $parsing_report;
// save gathered data if necessary
switch ($tag) {
case 'article':
// end of article
// transcode owner id
$parsed_item['owner_id'] = Surfer::get_id();
if (isset($parsed_item['owner_nick_name']) && ($user = Users::get($parsed_item['owner_nick_name']))) {
$parsed_item['owner_id'] = $user['id'];
}
// transcode creator id
$parsed_item['create_id'] = Surfer::get_id();
if (isset($parsed_item['create_nick_name']) && ($user = Users::get($parsed_item['create_nick_name']))) {
$parsed_item['create_id'] = $user['id'];
}
// transcode editor id
$parsed_item['edit_id'] = Surfer::get_id();
if (isset($parsed_item['edit_nick_name']) && ($user = Users::get($parsed_item['edit_nick_name']))) {
$parsed_item['edit_id'] = $user['id'];
}
// transcode publisher id
$parsed_item['publish_id'] = Surfer::get_id();
if (isset($parsed_item['publish_nick_name']) && ($user = Users::get($parsed_item['publish_nick_name']))) {
$parsed_item['publish_id'] = $user['id'];
}
// bind to given overlay
$overlay = NULL;
if ($overlay_class) {
$overlay = Overlay::bind($overlay_class . ' ' . $overlay_parameters);
}
// when the page has been overlaid
if (is_object($overlay)) {
// update the overlay from content
foreach ($parsed_overlay as $label => $value) {
$overlay->attributes[$label] = $value;
}
// save content of the overlay in this item
$parsed_item['overlay'] = $overlay->save();
$parsed_item['overlay_id'] = $overlay->get_id();
}
// find anchor from handle
if (isset($parsed_item['anchor_handle']) && ($reference = Sections::lookup($parsed_item['anchor_handle']))) {
$parsed_item['anchor'] = $reference;
}
// update an existing page
if (isset($parsed_item['handle']) && ($item = Articles::get($parsed_item['handle']))) {
// transcode page id
$parsed_item['id'] = $item['id'];
// stop on error
if (!Articles::put($parsed_item) || is_object($overlay) && !$overlay->remember('update', $parsed_item, 'article:' . $item['id'])) {
Logger::error(sprintf('Unable to save article %s', $parsed_item['title'] . ' (' . $parsed_item['id'] . ')'));
}
// create a new page
} else {
unset($parsed_item['id']);
// stop on error
if (!($parsed_item['id'] = Articles::post($parsed_item))) {
Logger::error(sprintf('Unable to save article %s', $parsed_item['title']));
} else {
// save overlay content
if (is_object($overlay)) {
$overlay->remember('insert', $parsed_item, 'article:' . $parsed_item['id']);
}
}
}
// report to surfer
$parsing_report .= '<li>' . Skin::build_link(Articles::get_permalink($parsed_item), $parsed_item['title']) . "</li>\n";
// ready for next item
$overlay_class = NULL;
$overlay_parameters = '';
$parsed_overlay = array();
$parsed_item = array();
Safe::set_time_limit(30);
break;
case 'overlay':
// end of overlay data
$in_overlay = FALSE;
break;
case 'section':
// end of section
// transcode owner id
$parsed_item['owner_id'] = Surfer::get_id();
if (isset($parsed_item['owner_nick_name']) && ($user = Users::get($parsed_item['owner_nick_name']))) {
$parsed_item['owner_id'] = $user['id'];
}
// transcode creator id
$parsed_item['create_id'] = Surfer::get_id();
if (isset($parsed_item['create_nick_name']) && ($user = Users::get($parsed_item['create_nick_name']))) {
$parsed_item['create_id'] = $user['id'];
}
// transcode editor id
$parsed_item['edit_id'] = Surfer::get_id();
if (isset($parsed_item['edit_nick_name']) && ($user = Users::get($parsed_item['edit_nick_name']))) {
$parsed_item['edit_id'] = $user['id'];
}
// bind to given overlay
//.........这里部分代码省略.........