本文整理汇总了PHP中Articles::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::get方法的具体用法?PHP Articles::get怎么用?PHP Articles::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_by_id
/**
* load the related item
*
* @see shared/anchor.php
*
* @param int the id of the record to load
* @param boolean TRUE to always fetch a fresh instance, FALSE to enable cache
*/
function load_by_id($id, $mutable = FALSE)
{
$this->item = Articles::get($id, $mutable);
}
示例2: load_skin
load_skin('home');
}
// the menu bar may be made of sections
if (isset($context['root_sections_at_home']) && $context['root_sections_at_home'] != 'none' && isset($context['root_sections_layout']) && $context['root_sections_layout'] == 'menu') {
// default number of sections to list
if (!isset($context['root_sections_count_at_home']) || $context['root_sections_count_at_home'] < 1) {
$context['root_sections_count_at_home'] = 5;
}
if ($items = Sections::list_by_title_for_anchor(NULL, 0, $context['root_sections_count_at_home'], 'menu')) {
$context['page_menu'] = $items;
}
}
// load the cover page
if ((!isset($context['root_cover_at_home']) || $context['root_cover_at_home'] != 'none') && $context['master_host'] == $context['main_host']) {
// look for a named page
if ($cover_page = Articles::get('cover')) {
} elseif ($anchor = Sections::lookup('covers')) {
$cover_page =& Articles::get_newest_for_anchor($anchor);
}
// compute page title -- $context['page_title']
if (isset($cover_page['title']) && (!isset($context['root_cover_at_home']) || $context['root_cover_at_home'] == 'full')) {
$context['page_title'] = $cover_page['title'];
}
// layout content of cover page -- may be changed in skin.php if necessary
if (isset($cover_page['id'])) {
$context['text'] .= Skin::layout_cover_article($cover_page);
}
}
// the prefix hook
if (is_callable(array('Hooks', 'include_scripts'))) {
$context['text'] .= Hooks::include_scripts('index.php#prefix');
示例3: submit_page
/**
* create a page out of a textual entity
*
* If a target is provided, it is extended with the text of this entity.
* Else if the anchor is an article, a comment is created. Otherwise an article is created.
*
* @param array of entity attributes
* @param string the textual entity to process
* @param array poster attributes
* @param string an optional anchor (e.g., 'article:123')
* @param string reference of the object to be extended, if any
* @return string reference to the created or updated object, or NULL
*/
public static function submit_page($entity_headers, $text, $user, $anchor = NULL, $target = NULL)
{
global $context;
// retrieve queue parameters
list($server, $account, $password, $allowed, $match, $section, $options, $hooks, $prefix, $suffix) = $context['mail_queue'];
// preserve breaks
$text = preg_replace('/\\s*<(br|div|h|p)/is', "\n\n<\$1", $text);
// suppress dangerous html tags
$text = strip_tags($text, $context['users_allowed_tags']);
// trim white spaces
while (TRUE) {
$text = trim($text, " \t\r\n");
if (!strncmp($text, '<br>', 4)) {
$text = substr($text, 4);
} elseif (!strncmp($text, '<br/>', 5)) {
$text = substr($text, 5);
} elseif (!strncmp($text, '<br />', 6)) {
$text = substr($text, 6);
} else {
break;
}
}
// parse article content
include_once $context['path_to_root'] . 'articles/article.php';
$article = new Article();
$entry_fields = array();
$entry_fields = $article->parse($text, $entry_fields);
// trim the header
if ($prefix) {
$tokens = explode($prefix, $entry_fields['description']);
if (isset($tokens[1])) {
$entry_fields['description'] = $tokens[1];
} else {
$entry_fields['description'] = $tokens[0];
}
}
// trim the signature
if ($suffix) {
list($entry_fields['description'], $dropped) = explode($suffix, $entry_fields['description']);
}
// strip extra text
$entry_fields['description'] = trim(preg_replace('/\\(See attached file: [^\\)]+?\\)/', '', $entry_fields['description']));
// anchor this item to something
$entry_fields['anchor'] = $anchor;
// make a title
if (!isset($entry_fields['title'])) {
$entry_fields['title'] = $context['mail_subject'];
}
// message creation stamp
$entry_fields['create_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', strtotime($context['mail_date']));
if (!isset($entry_fields['create_name'])) {
$entry_fields['create_name'] = $user['nick_name'];
}
if (!isset($entry_fields['create_id'])) {
$entry_fields['create_id'] = $user['id'];
}
if (!isset($entry_fields['create_address'])) {
$entry_fields['create_address'] = $user['email'];
}
// message edition stamp
$entry_fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time());
if (!isset($entry_fields['edit_name'])) {
$entry_fields['edit_name'] = $user['nick_name'];
}
if (!isset($entry_fields['edit_id'])) {
$entry_fields['edit_id'] = $user['id'];
}
if (!isset($entry_fields['edit_address'])) {
$entry_fields['edit_address'] = $user['email'];
}
// we have to extend an existing article --this entity is mutable
if ($target && !strncmp($target, 'article:', 8) && ($article = Articles::get(substr($target, 8), TRUE))) {
// append the text to article description field
$fields = array();
$fields['id'] = $article['id'];
$fields['description'] = $article['description'] . $entry_fields['description'];
$fields['silent'] = TRUE;
Articles::put_attributes($fields);
return $target;
// we have to extend an existing comment --this entity is mutable
} elseif ($target && !strncmp($target, 'comment:', 8) && ($comment = Comments::get(substr($target, 8), TRUE))) {
// append the text to comment description field
$comment['description'] .= $entry_fields['description'];
Comments::post($comment);
return $target;
// we have to comment an existing page
} elseif (!strncmp($anchor, 'article:', 8)) {
//.........这里部分代码省略.........
示例4: echo_menu
/**
* echo the site menu
*
* You can override this function into your skin
*/
public static function echo_menu()
{
global $context;
// ensure normal conditions
if (file_exists($context['path_to_root'] . 'parameters/switch.on') && is_callable(array('Articles', 'get')) && is_callable(array('Codes', 'beautify'))) {
// use content of a named global page
if ($item = Articles::get('menu')) {
echo Skin::build_box(Codes::beautify_title($item['title']), Codes::beautify($item['description']), 'navigation', 'main_menu');
}
}
}
示例5: gmstrftime
$fields['title'] = i18n::c('USTREAM broadcast');
$fields['introduction'] = i18n::c('Drive your audience to a USTREAM show. At the given date and time participants are invited to join the channel.');
$fields['options'] = 'edit_as_thread';
$fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
$fields['thumbnail_url'] = $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/thumbnails/conference.gif';
$overlay = Overlay::bind('ustream_meeting');
$fields['overlay'] = $overlay->save();
$fields['overlay_id'] = $overlay->get_id();
if (Articles::post($fields)) {
$text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['title']) . BR . "\n";
} else {
$text .= Logger::error_pop() . BR . "\n";
}
}
// 'wiki_template' article
if (!Articles::get('wiki_template') && ($anchor = Sections::lookup('templates'))) {
$fields = array();
$fields['anchor'] = $anchor;
$fields['nick_name'] = 'wiki_template';
$fields['title'] = i18n::c('Wiki page');
$fields['introduction'] = i18n::c('Create an initial page and invite participants to follow-up. Modifications are saved, to allow for fall-back.');
$fields['options'] = 'edit_as_simple members_edit view_as_wiki';
$fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
$fields['thumbnail_url'] = $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/thumbnails/page.gif';
if (Articles::post($fields)) {
$text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['title']) . BR . "\n";
} else {
$text .= Logger::error_pop() . BR . "\n";
}
}
// nothing added
示例6: elseif
// the title of the page
$context['page_title'] = i18n::s('Change named overlays');
// this is reserved to associates
if (!Surfer::is_associate()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// update targeted overlays
} elseif (isset($_REQUEST['id']) && $_REQUEST['id']) {
// change all named overlays
$count = 0;
if ($ids = Articles::get_ids_for_overlay($_REQUEST['id'])) {
$context['text'] .= sprintf(i18n::s('Changing all overlays with name %s'), $_REQUEST['id']) . BR;
// one page at a time
foreach ($ids as $id) {
// load the page and bind the related overlay
if (($item = Articles::get($id)) && ($overlay = Overlay::load($item, 'article:' . $item['id'])) && is_callable(array($overlay, 'update'))) {
$count++;
// update provided attributes
$overlay->update($_REQUEST);
// save content of the overlay in the page
$item['overlay'] = $overlay->save();
$item['overlay_id'] = $overlay->get_id();
// store in the database
if (Articles::put($item)) {
$context['text'] .= sprintf(i18n::s('%s has been changed'), Skin::build_link(Articles::get_permalink($item), $item['title']));
}
}
}
// no page has been found
} else {
$context['text'] .= '<p>' . i18n::s('No item has the provided id.') . '</p>';
示例7: post_default
/**
* create a default named page
*
* @param string the nick name of the item to create
* @return string text to be displayed in the resulting page
*/
public static function post_default($nick_name)
{
global $context;
// the page already exists
if ($item = Articles::get($nick_name)) {
return '';
}
// use the provided model for this item
if (is_readable($context['path_to_root'] . 'articles/defaults/' . $nick_name . '.php')) {
include_once $context['path_to_root'] . 'articles/defaults/' . $nick_name . '.php';
// do the job
if (is_callable(array($nick_name, 'initialize'))) {
return call_user_func(array($nick_name, 'initialize'));
}
}
// tough luck
return '';
}
示例8: elseif
* @tester Timster
* @reference
* @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
*/
// common definitions and initial processing
include_once '../../shared/global.php';
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
$id = $context['arguments'][0];
}
$id = strip_tags($id);
// get the item from the database
$item = Articles::get($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
$anchor = Anchors::get($item['anchor']);
}
// get poll data
include_once '../overlay.php';
$overlay = NULL;
if (isset($item['overlay'])) {
$overlay = Overlay::load($item, 'article:' . $item['id']);
}
// look for the vote
$vote = '';
if (isset($_REQUEST['vote'])) {
$vote = $_REQUEST['vote'];
示例9: sprintf
$context['text'] .= '<p>' . sprintf(i18n::ns('%d page has been updated.', '%d pages have been updated.', $count), $count) . '</p>';
// follow-up commands
$follow_up = i18n::s('What do you want to do now?');
$menu = array();
$menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the section'), 'span');
$menu[] = Skin::build_link(Sections::get_url($item['id'], 'manage'), i18n::s('Manage it'), 'span');
$follow_up .= Skin::finalize_list($menu, 'menu_bar');
$context['text'] .= Skin::build_block($follow_up, 'bottom');
// unlock pages
} elseif ($action == 'unlock_articles') {
// articles
if (isset($_REQUEST['selected_articles'])) {
$count = 0;
foreach ($_REQUEST['selected_articles'] as $dummy => $id) {
// an article to lock
if (($article = Articles::get($id)) && $article['locked'] == 'Y') {
$attributes = array();
$attributes['id'] = $article['id'];
$attributes['locked'] = 'N';
$attributes['silent'] = 'Y';
// too minor to be noted
if (Articles::put_attributes($attributes)) {
$count++;
}
}
}
// clear cache for containing section
Sections::clear($item);
// report on results
$context['text'] .= '<p>' . sprintf(i18n::ns('%d page has been unlocked.', '%d pages have been unlocked.', $count), $count) . '</p>';
// follow-up commands
示例10: gmstrftime
// this is private
$article['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
// no review is required
$article['options'] = 'view_as_zic_pm';
// include some overlay
$overlay = Overlay::bind('thread');
$article['overlay'] = $overlay->save();
$article['overlay_id'] = $overlay->get_id();
// ensure everything is positioned as expected
Surfer::empower();
// post the new thread
if (!($article['id'] = Articles::post($article))) {
Logger::error(i18n::s('Impossible to add a page.'));
} else {
//get full article
$article = Articles::get($article['id']);
// attach some file
if (isset($_FILES['upload']) && ($file = Files::upload($_FILES['upload'], 'files/article/' . $article['id'], 'article:' . $article['id']))) {
$_REQUEST['message'] .= $file;
}
// make a new comment out of received message, if any
if (isset($_REQUEST['message']) && trim($_REQUEST['message'])) {
$comment = array();
$comment['anchor'] = 'article:' . $article['id'];
$comment['description'] = strip_tags($_REQUEST['message']);
Comments::post($comment);
}
// page title
$context['page_title'] = i18n::s('Message sent !');
// feed-back to surfer
// $context['text'] .= '<p>'.i18n::s('A new thread has been created, and it will be listed in profiles of the persons that you have involved. You can invite additional people later on if you wish.').'</p>';
示例11: 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
//.........这里部分代码省略.........
示例12: array
}
$follow_up .= Skin::build_list($menu, 'menu_bar');
$menu = array();
if (Surfer::may_upload()) {
$menu = array_merge($menu, array('images/edit.php?anchor=' . urlencode('article:' . $_REQUEST['id']) => i18n::s('Add an image')));
$menu = array_merge($menu, array('files/edit.php?anchor=' . urlencode('article:' . $_REQUEST['id']) => i18n::s('Add a file')));
$menu = array_merge($menu, array('images/edit.php?anchor=' . urlencode('article:' . $_REQUEST['id']) . '&action=thumbnail' => i18n::s('Add a thumbnail')));
}
if (is_object($anchor) && Surfer::is_empowered()) {
$menu = array_merge($menu, array('articles/edit.php?anchor=' . urlencode($anchor->get_reference()) => i18n::s('Add another page')));
}
$follow_up .= Skin::build_list($menu, 'menu_bar');
$context['text'] .= Skin::build_block($follow_up, 'bottom');
}
// we have to duplicate some template page
} elseif (!isset($item['id']) && !is_object($overlay) && is_object($anchor) && isset($_REQUEST['template']) && ($item = Articles::get($_REQUEST['template']))) {
// ensure we are not duplicating outside regular templates
if (!($templates = Anchors::get($item['anchor'])) || $templates->get_nick_name() != 'templates') {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
die(i18n::s('You are not allowed to perform this operation.'));
}
// we will get a new id, a new title and a new handle
unset($item['title']);
unset($item['id']);
unset($item['handle']);
// set the anchor
$item['anchor'] = $anchor->get_reference();
// the duplicator becomes the author
unset($item['create_address']);
unset($item['create_date']);
unset($item['create_id']);
示例13: elseif
$id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
$id = $context['arguments'][0];
}
$id = strip_tags($id);
// load localized strings
i18n::bind('root');
// load the skin
load_skin('go');
// the title of the page
$context['page_title'] = i18n::s('Page locator');
// ensure we have a non-empty string
if (!($id = trim($id)) || !preg_match('/\\w/', $id)) {
$context['text'] .= '<p>' . i18n::s('Please indicate a nick name to look for.') . "</p>\n";
// short link to some article
} elseif (!strncmp($id, 'a~', 2) && ($item = Articles::get(restore_number(substr($id, 2))))) {
Safe::redirect(Articles::get_permalink($item));
// short link to some section
} elseif (!strncmp($id, 's~', 2) && ($item = Sections::get(restore_number(substr($id, 2))))) {
Safe::redirect(Sections::get_permalink($item));
// look in sections
} elseif ($items =& Sections::list_for_name($id, NULL, 'full')) {
// only one section has this name
if (count($items) == 1) {
list($url, $attributes) = each($items);
Safe::redirect($url);
}
// splash
$context['text'] .= '<p>' . i18n::s('Select below among available sections.') . '</p>';
// several pages
$context['text'] .= Skin::build_list($items, 'decorated');
示例14: elseif
if (Surfer::may_be_a_robot()) {
Logger::error(i18n::s('Please prove you are not a robot.'));
$with_form = TRUE;
// display the form on error
} elseif (!($_REQUEST['id'] = Articles::post($_REQUEST))) {
$with_form = TRUE;
// post-processing
} else {
// do whatever is necessary on page publication
Articles::finalize_publication($anchor, $_REQUEST);
// message to the query poster
$context['page_title'] = i18n::s('Your query has been registered');
// use the secret handle to access the query
$link = '';
$status = '';
if ($item = Articles::get($_REQUEST['id'])) {
// ensure the article has a private handle
if (!isset($item['handle']) || !$item['handle']) {
$item['handle'] = md5(mt_rand());
// save in the database
$fields = array();
$fields['id'] = $item['id'];
$fields['handle'] = $item['handle'];
$fields['silent'] = 'Y';
Articles::put_attributes($fields);
}
// the secret link --see users/login.php
$link = $context['url_to_home'] . $context['url_to_root'] . Users::get_login_url('edit', 'article:' . $item['id'], $item['create_name'], $item['handle']);
$status = i18n::s('<p>You can check the status of your query at the following address:</p>') . '<p>' . Skin::build_link($link, $link, 'basic', i18n::s('The permanent address for your query')) . '</p>';
}
$context['text'] .= i18n::s('<p>Your query will now be reviewed by one of the associates of this community. It is likely that this will be done within the next 24 hours at the latest.</p>');
示例15:
<?php
if (isset($_GET['article_id'])) {
$id = $_GET['article_id'];
$article = Articles::get($id);
$_SESSION['articles'] = $article;
//var_dump($_SESSION['article']);
}
?>
<a href="home.php?page=2"<button class="btn-primary form-control" type="submit" name="insert">Back</button></a>
<h1>Edit Article</h1><br>
<a href='../index.php?controller=News&method=index&id=<?php
echo $article->article_id;
?>
' target='_blank' >View article on site</a><br><br>
<img src='../view/images/<?php
echo $_SESSION['articles']->article_picture_small;
?>
'><br><br>
<a href='home.php?page=5&article_id=<?php
echo $_SESSION['articles']->article_id;
?>
'><button type="button" class="form-control btn-success">Change Picture</button></a><br>
<form action="home.php?page=4" method="POST" enctype="multipart/form-data">
<input type="hidden" name="article_id" value="<?php
echo $_SESSION['articles']->article_id;
?>
">
<input type="hidden" name="article_picture_small" value="<?php
echo $_SESSION['articles']->article_picture_small;
?>