本文整理汇总了PHP中Story::loadFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Story::loadFromArray方法的具体用法?PHP Story::loadFromArray怎么用?PHP Story::loadFromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Story
的用法示例。
在下文中一共展示了Story::loadFromArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: service_get_story
/**
* Get an existing story
*
* @param array args Contains all the data provided by the client
* @param string &output OUTPUT parameter containing the returned text
* @return int Response code as defined in lib-plugins.php
*/
function service_get_story($args, &$output, &$svc_msg)
{
global $_CONF, $_TABLES, $_USER;
$output = array();
$retval = '';
if (!isset($_CONF['atom_max_stories'])) {
$_CONF['atom_max_stories'] = 10;
// set a resonable default
}
$svc_msg['output_fields'] = array('draft_flag', 'hits', 'numemails', 'comments', 'trackbacks', 'featured', 'commentcode', 'statuscode', 'expire_date', 'postmode', 'advanced_editor_mode', 'frontpage', 'owner_id', 'group_id', 'perm_owner', 'perm_group', 'perm_members', 'perm_anon');
if (empty($args['sid']) && !empty($args['id'])) {
$args['sid'] = $args['id'];
}
if ($args['gl_svc']) {
if (isset($args['mode'])) {
$args['mode'] = COM_applyBasicFilter($args['mode']);
}
if (isset($args['sid'])) {
$args['sid'] = COM_applyBasicFilter($args['sid']);
}
if (empty($args['sid'])) {
$svc_msg['gl_feed'] = true;
} else {
$svc_msg['gl_feed'] = false;
}
} else {
$svc_msg['gl_feed'] = false;
}
if (empty($args['mode'])) {
$args['mode'] = 'view';
}
if (!$svc_msg['gl_feed']) {
$sid = $args['sid'];
$mode = $args['mode'];
$story = new Story();
$retval = $story->loadFromDatabase($sid, $mode);
if ($retval != STORY_LOADED_OK) {
$output = $retval;
return PLG_RET_ERROR;
}
reset($story->_dbFields);
while (list($fieldname, $save) = each($story->_dbFields)) {
$varname = '_' . $fieldname;
$output[$fieldname] = $story->{$varname};
}
$output['username'] = $story->_username;
$output['fullname'] = $story->_fullname;
if ($args['gl_svc']) {
if ($output['statuscode'] == STORY_ARCHIVE_ON_EXPIRE || $output['statuscode'] == STORY_DELETE_ON_EXPIRE) {
// This date format is PHP 5 only,
// but only the web-service uses the value
$output['expire_date'] = date('c', $output['expire']);
}
$output['id'] = $output['sid'];
$output['category'] = array($output['tid']);
$output['published'] = date('c', $output['date']);
$output['updated'] = date('c', $output['date']);
if (empty($output['bodytext'])) {
$output['content'] = $output['introtext'];
} else {
$output['content'] = $output['introtext'] . LB . '[page_break]' . LB . $output['bodytext'];
}
$output['content_type'] = $output['postmode'] == 'html' ? 'html' : 'text';
$owner_data = SESS_getUserDataFromId($output['owner_id']);
$output['author_name'] = $owner_data['username'];
$output['link_edit'] = $sid;
}
} else {
$output = array();
$mode = $args['mode'];
$sql = array();
if (isset($args['offset'])) {
$offset = COM_applyBasicFilter($args['offset'], true);
} else {
$offset = 0;
}
$max_items = $_CONF['atom_max_stories'] + 1;
$limit = " LIMIT {$offset}, {$max_items}";
$limit_pgsql = " LIMIT {$max_items} OFFSET {$offset}";
$order = " ORDER BY unixdate DESC";
$sql['mysql'] = "SELECT s.*, UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) as expireunix, " . "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid)" . COM_getPermSQL('AND', $_USER['uid'], 2, 's') . $order . $limit;
$sql['pgsql'] = "SELECT s.*, UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) as expireunix, u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl FROM stories s, users u, topics t WHERE (s.uid = u.uid) AND (s.tid = t.tid) FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t WHERE (s.uid = u.uid) AND (s.tid = t.tid)" . COM_getPermSQL('AND', $_USER['uid'], 2, 's') . $order . $limit_pgsql;
$result = DB_query($sql);
$count = 0;
while (($story_array = DB_fetchArray($result, false)) !== false) {
$count += 1;
if ($count == $max_items) {
$svc_msg['offset'] = $offset + $_CONF['atom_max_stories'];
break;
}
$story = new Story();
$story->loadFromArray($story_array);
// This access check is not strictly necessary
//.........这里部分代码省略.........
示例2: Story
if ($A = DB_fetchArray($result)) {
$story = new Story();
$story->loadFromArray($A);
if ($_CONF['showfirstasfeatured'] == 1) {
$story->_featured = 1;
}
// display first article
$display .= STORY_renderArticle($story, 'y');
// get plugin center blocks after featured article
if ($story->DisplayElements('featured') == 1) {
$display .= PLG_showCenterblock(2, $page, $topic);
}
// get remaining stories
while ($A = DB_fetchArray($result)) {
$story = new Story();
$story->loadFromArray($A);
$display .= STORY_renderArticle($story, 'y');
}
// get plugin center blocks that follow articles
$display .= PLG_showCenterblock(3, $page, $topic);
// bottom blocks
// Print Google-like paging navigation
if (!isset($_CONF['hide_main_page_navigation']) || $_CONF['hide_main_page_navigation'] == 0) {
if (empty($topic)) {
$base_url = $_CONF['site_url'] . '/index.php';
if ($newstories) {
$base_url .= '?display=new';
}
} else {
$base_url = $_CONF['site_url'] . '/index.php?topic=' . $topic;
}
示例3: PLG_replaceTags
//.........这里部分代码省略.........
$filelink = COM_createLink($linktext, $url);
$content = str_replace($autotag['tagstr'], $filelink, $content);
}
if ($autotag['tag'] == 'story_introtext') {
$url = '';
$linktext = '';
USES_lib_story();
if (isset($_USER['uid']) && $_USER['uid'] > 1) {
$result = DB_query("SELECT maxstories,tids,aids FROM {$_TABLES['userindex']} WHERE uid = {$_USER['uid']}");
$U = DB_fetchArray($result);
} else {
$U['maxstories'] = 0;
$U['aids'] = '';
$U['tids'] = '';
}
$sql = " (date <= NOW()) AND (draft_flag = 0)";
if (empty($topic)) {
$sql .= COM_getLangSQL('tid', 'AND', 's');
}
$sql .= COM_getPermSQL('AND', 0, 2, 's');
if (!empty($U['aids'])) {
$sql .= " AND s.uid NOT IN (" . str_replace(' ', ",", $U['aids']) . ") ";
}
if (!empty($U['tids'])) {
$sql .= " AND s.tid NOT IN ('" . str_replace(' ', "','", $U['tids']) . "') ";
}
$sql .= COM_getTopicSQL('AND', 0, 's') . ' ';
$userfields = 'u.uid, u.username, u.fullname';
$msql = "SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, " . 'UNIX_TIMESTAMP(s.expire) as expireunix, ' . $userfields . ", t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, " . "{$_TABLES['topics']} AS t WHERE s.sid = '" . $autotag['parm1'] . "' AND (s.uid = u.uid) AND (s.tid = t.tid) AND" . $sql;
$result = DB_query($msql);
$nrows = DB_numRows($result);
if ($A = DB_fetchArray($result)) {
$story = new Story();
$story->loadFromArray($A);
$linktext = STORY_renderArticle($story, 'y');
}
$content = str_replace($autotag['tagstr'], $linktext, $content);
}
if ($autotag['tag'] == 'showblock') {
$blockName = COM_applyBasicFilter($autotag['parm1']);
$result = DB_query("SELECT * FROM {$_TABLES['blocks']} WHERE name = '" . DB_escapeString($blockName) . "'" . COM_getPermSQL('AND'));
if (DB_numRows($result) > 0) {
$skip = 0;
$B = DB_fetchArray($result);
$template = '';
$side = '';
$px = explode(' ', trim($autotag['parm2']));
if (is_array($px)) {
foreach ($px as $part) {
if (substr($part, 0, 9) == 'template:') {
$a = explode(':', $part);
$template = $a[1];
$skip++;
} elseif (substr($part, 0, 5) == 'side:') {
$a = explode(':', $part);
$side = $a[1];
$skip++;
break;
}
}
if ($skip != 0) {
if (count($px) > $skip) {
for ($i = 0; $i < $skip; $i++) {
array_shift($px);
}
$caption = trim(implode(' ', $px));
示例4: MYCALJP_showStoriesIntro
function MYCALJP_showStoriesIntro()
{
global $_CONF, $_TABLES, $_MYCALJP2_CONF;
if (!$_MYCALJP2_CONF['showstoriesintro']) {
return '';
}
$retval = '';
$_dateStart = COM_applyFilter($_GET['datestart']);
$_dateEnd = COM_applyFilter($_GET['dateend']);
if (!empty($_dateStart) && !empty($_dateEnd)) {
$ds = explode("-", $_dateStart);
$de = explode("-", $_dateEnd);
$startdate = mktime(0, 0, 0, $ds[1], $ds[2], $ds[0]);
$enddate = mktime(23, 59, 59, $de[1], $de[2], $de[0]);
$sql = "AND (UNIX_TIMESTAMP(date) BETWEEN '{$startdate}' AND '{$enddate}') ";
}
$sql .= "AND (draft_flag = 0) ";
$sql .= COM_getPermSQL('AND', 0, 2, 's') . ' ';
$sql .= COM_getTopicSQL('AND', 0, 'ta') . ' ';
$sql .= COM_getLangSQL('sid', 'AND', 's') . ' ';
$userfields = 'u.username, u.fullname';
if ($_CONF['allow_user_photo'] == 1) {
$userfields .= ', u.photo';
if ($_CONF['use_gravatar']) {
$userfields .= ', u.email';
}
}
$msql = array();
$msql['mysql'] = "SELECT DISTINCT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, " . "UNIX_TIMESTAMP(s.expire) AS expireunix, " . $userfields . ", t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, " . "{$_TABLES['topics']} AS t, {$_TABLES['topic_assignments']} AS ta " . "WHERE (ta.type = 'article') AND (ta.tdefault = 1) AND (s.uid = u.uid) AND (ta.tid = t.tid) AND (s.sid = ta.id) " . $sql . "ORDER BY featured DESC, date DESC";
/*
$msql['mssql']="SELECT STRAIGHT_JOIN s.sid, s.uid, s.draft_flag, s.tid, s.date, s.title, cast(s.introtext as text) as introtext, cast(s.bodytext as text) as bodytext, s.hits, s.numemails, s.comments, s.trackbacks, s.related, s.featured, s.show_topic_icon, s.commentcode, s.trackbackcode, s.statuscode, s.expire, s.postmode, s.frontpage, s.in_transit, s.owner_id, s.group_id, s.perm_owner, s.perm_group, s.perm_members, s.perm_anon, s.advanced_editor_mode, "
. " UNIX_TIMESTAMP(s.date) AS unixdate, "
. 'UNIX_TIMESTAMP(s.expire) as expireunix, '
. $userfields . ", t.topic, t.imageurl "
. "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, "
. "{$_TABLES['topics']} AS t, {$_TABLES['topic_assignments']} AS ta "
. "WHERE (ta.type = 'article') AND (ta.tdefault = 1) AND (s.uid = u.uid) AND (ta.tid = t.tid) AND (s.sid = ta.id) "
. $sql . "ORDER BY featured DESC, date DESC";
*/
$result = DB_query($msql);
require_once $_CONF['path_system'] . 'lib-story.php';
$story = new Story();
while ($A = DB_fetchArray($result)) {
$story->loadFromArray($A);
$retval .= STORY_renderArticle($story, 'y');
}
return $retval;
}
示例5: MG_continueSession
//.........这里部分代码省略.........
DB_query("INSERT INTO {$_TABLES['mg_session_log']} (session_id,session_log) VALUES ('" . DB_escapeString($session_id) . "','{$statusMsg}')");
continue;
}
//This will set the Content-Type to the appropriate setting for the file
switch ($file_extension) {
case "exe":
$filetype = "application/octet-stream";
break;
case "zip":
$filetype = "application/zip";
break;
case "mp3":
$filetype = "audio/mpeg";
break;
case "mpg":
$filetype = "video/mpeg";
break;
case "avi":
$filetype = "video/x-msvideo";
break;
default:
$filetype = "application/force-download";
}
list($rc, $msg) = MG_getFile($srcFile, $baseSrcFile, $album_id, $caption, '', 0, $purgefiles, $filetype, 0, '', $mid, 0, 0, 0);
$mid = $new_media_id;
$statusMsg = DB_escapeString($baseSrcFile . " " . $msg);
DB_query("INSERT INTO {$_TABLES['mg_session_log']} (session_id,session_log) VALUES ('" . DB_escapeString($session_id) . "','{$statusMsg}')");
MG_SortMedia($album_id);
// now update the tag in the article...
$sResult = DB_query("SELECT * FROM {$_TABLES['stories']} WHERE sid='" . DB_escapeString($sid) . "'");
$howmany = DB_numRows($sResult);
$S = DB_fetchArray($sResult);
$story = new Story();
$story->loadFromArray($S);
$intro = $story->replaceImages($S['introtext']);
$body = $story->replaceImages($S['bodytext']);
$atag = $session['session_var0'];
$align = $session['session_var1'];
$delete = $session['session_var2'];
$norm = '[image' . $imageNumber . ']';
$left = '[image' . $imageNumber . '_left]';
$right = '[image' . $imageNumber . '_right]';
$mg_norm = '[' . $atag . ':' . $mid . ' align:' . $align . ']';
$mg_left = '[' . $atag . ':' . $mid . ' align:left]';
$mg_right = '[' . $atag . ':' . $mid . ' align:right]';
$intro = str_replace($norm, $mg_norm, $intro);
$body = str_replace($norm, $mg_norm, $body);
$intro = str_replace($left, $mg_left, $intro);
$body = str_replace($left, $mg_left, $body);
$intro = str_replace($right, $mg_right, $intro);
$body = str_replace($right, $mg_right, $body);
$norm = '[unscaled' . $imageNumber . ']';
$left = '[unscaled' . $imageNumber . '_left]';
$right = '[unscaled' . $imageNumber . '_right]';
$mg_norm = '[oimage:' . $mid . ' align:' . $align . ']';
$mg_left = '[oimage:' . $mid . ' align:left]';
$mg_right = '[oimage:' . $mid . ' align:right]';
$intro = str_replace($norm, $mg_norm, $intro);
$body = str_replace($norm, $mg_norm, $body);
$intro = str_replace($left, $mg_left, $intro);
$body = str_replace($left, $mg_left, $body);
$intro = str_replace($right, $mg_right, $intro);
$body = str_replace($right, $mg_right, $body);
DB_query("UPDATE {$_TABLES['stories']} SET introtext='" . DB_escapeString($intro) . "', bodytext='" . DB_escapeString($body) . "' WHERE sid='" . $sid . "'");
if ($delete == 1) {
$sql = "DELETE FROM {$_TABLES['article_images']} WHERE ai_sid='" . DB_escapeString($sid) . "'";
示例6: MG_buildImportAlbums
function MG_buildImportAlbums()
{
global $mgAlbums, $_TABLES, $_CONF, $_MG_CONF, $_USER;
$mgalbum = new mgAlbumg();
$mgalbum->id = 0;
$mgalbum->title = 'root';
$mgAlbums[0] = $mgalbum;
$counter = 1;
$sql = "SELECT * FROM {$_TABLES['stories']}";
$result = DB_query($sql);
$numRows = DB_numRows($result);
for ($i = 0; $i < $numRows; $i++) {
$I = DB_fetchArray($result);
$story = new Story();
$story->loadFromArray($I);
$tmpsid = $I['sid'];
$icount = DB_count($_TABLES['article_images'], 'ai_sid', $tmpsid);
if ($icount == 0) {
continue;
}
$mgalbum = new mgAlbumg();
$mgalbum->id = $counter;
$mgalbum->sid = $I['sid'];
$mgalbum->title = $I['title'];
$mgalbum->parent = 0;
$intro = $story->replaceImages($I['introtext']);
$body = $story->replaceImages($I['bodytext']);
// list($intro,$body) = STORY_replace_images($I['sid'],$I['introtext'],$I['bodytext']);
list($errors, $intro_notags, $body_notags) = _MG_remove_images($I['sid'], $intro, $body, 'html');
$mgalbum->description = '';
//$intro_notags;
$mgalbum->views = 0;
$mgalbum->media_count = $icount;
$mgalbum->owner_id = $I['owner_id'];
$mgalbum->perm_owner = $I['perm_owner'];
$mgalbum->perm_group = $I['perm_group'];
$mgalbum->perm_members = $I['perm_members'];
$mgalbum->perm_anon = $I['perm_anon'];
$mgAlbums[$counter] = $mgalbum;
$counter++;
}
foreach ($mgAlbums as $id => $mgalbum) {
if ($id != 0 && isset($mgAlbums[$mgalbum->parent]->id)) {
$mgAlbums[$mgalbum->parent]->setChild($id);
}
}
return;
}
示例7: plugin_displaycomment_article
/**
* article: display comment(s)
*
* @param string $id Unique idenifier for item comment belongs to
* @param int $cid Comment id to display (possibly including sub-comments)
* @param string $title Page/comment title
* @param string $order 'ASC' or 'DESC' or blank
* @param string $format 'threaded', 'nested', or 'flat'
* @param int $page Page number of comments to display
* @param boolean $view True to view comment (by cid), false to display (by $pid)
* @return mixed results of calling the plugin_displaycomment_ function
*/
function plugin_displaycomment_article($id, $cid, $title, $order, $format, $page, $view)
{
global $_CONF, $_TABLES, $LANG_ACCESS;
USES_lib_story();
USES_class_story();
$retval = '';
// display story
$sql = "SELECT s.*, UNIX_TIMESTAMP(s.date) AS unixdate, " . 'UNIX_TIMESTAMP(s.expire) as expireunix, ' . "u.uid, u.username, u.fullname, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s LEFT JOIN {$_TABLES['users']} AS u ON s.uid=u.uid " . "LEFT JOIN {$_TABLES['topics']} AS t on s.tid=t.tid " . "WHERE (sid = '" . DB_escapeString($id) . "') " . 'AND (draft_flag = 0) AND (commentcode >= 0) AND (date <= NOW())' . COM_getPermSQL('AND', 0, 2, 's') . COM_getTopicSQL('AND', 0, 't') . ' GROUP BY sid,owner_id, group_id, perm_owner, s.perm_group,s.perm_members, s.perm_anon ';
$result = DB_query($sql);
$nrows = DB_numRows($result);
if ($A = DB_fetchArray($result)) {
$story = new Story();
$story->loadFromArray($A);
$retval .= STORY_renderArticle($story, 'n');
}
// end
$sql = 'SELECT COUNT(*) AS count, commentcode, uid, owner_id, group_id, perm_owner, perm_group, ' . "perm_members, perm_anon FROM {$_TABLES['stories']} " . "WHERE (sid = '" . DB_escapeString($id) . "') " . 'AND (draft_flag = 0) AND (commentcode >= 0) AND (date <= NOW())' . COM_getPermSQL('AND') . COM_getTopicSQL('AND') . ' GROUP BY sid,owner_id, group_id, perm_owner, perm_group,perm_members, perm_anon ';
$result = DB_query($sql);
$B = DB_fetchArray($result);
$allowed = $B['count'];
if ($allowed == 1) {
$delete_option = SEC_hasRights('story.edit') && SEC_hasAccess($B['owner_id'], $B['group_id'], $B['perm_owner'], $B['perm_group'], $B['perm_members'], $B['perm_anon']) == 3;
$retval .= CMT_userComments($id, $title, 'article', $order, $format, $cid, $page, $view, $delete_option, $B['commentcode'], $B['uid']);
} else {
$retval .= COM_showMessageText($LANG_ACCESS['storydenialmsg'], $LANG_ACCESS['accessdenied'], true);
}
return $retval;
}