本文整理汇总了PHP中Story类的典型用法代码示例。如果您正苦于以下问题:PHP Story类的具体用法?PHP Story怎么用?PHP Story使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Story类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Renderize the view.
*
* @return null
*/
public function render(Story $story)
{
?>
<p>
<?php
echo REQUIRED_FIELDS_TEXT;
?>
</p>
<form action="<?php
echo $this->generateURL('story', 'edit', $story->getIdStory());
?>
" method="post">
<fieldset>
<div class="row">
<div class="col-md-6">
<div>
<label for="title">
Título <small>(*)</small>
</label>
<input name="title" type="text" required value="<?php
echo $story->getTitle();
?>
" />
</div>
</div>
<div class="col-md-6">
<div>
<label for="body">
Cuerpo <small>(*)</small>
</label>
<textarea name="body" required><?php
echo $story->getBody();
?>
</textarea>
</div>
<div>
<input type="submit" value="Modificar" />
</div>
</div>
</div>
</fieldset>
</form>
<?php
}
示例2: story_plugin_action
function story_plugin_action()
{
global $_, $myUser;
switch ($_['action']) {
case 'DELETE_STORY':
$storyManager = new Story();
$causeManager = new Cause();
$effectManager = new Effect();
$storyManager->delete(array('id' => $_['id']));
$causeManager->delete(array('story' => $_['id']));
$effectManager->delete(array('story' => $_['id']));
break;
case 'plugin_story_check':
require_once 'Cause.class.php';
$vocal = new Cause();
$vocal = $vocal->getById($_['event']);
Story::check($vocal);
break;
case 'SAVE_STORY':
$causeManager = new Cause();
$effectManager = new Effect();
$story = new Story();
if (isset($_['story']['id']) && $_['story']['id'] != '0') {
$story = $story->getById($_['story']['id']);
$causeManager->delete(array('story' => $story->id));
$effectManager->delete(array('story' => $story->id));
}
$story->label = $_['story']['label'];
$story->date = time();
$story->state = 1;
$story->save();
$i = 0;
foreach ($_['story']['cause'] as $cause) {
$current = new Cause();
$current->type = $cause['type'];
$current->target = is_array(@$cause['target']) ? implode('|', @$cause['target']) : @$cause['target'];
$current->operator = @$cause['operator'];
$current->value = $cause['value'];
$current->sort = $i;
$current->union = $cause['union'];
$current->story = $story->id;
$current->save();
$i++;
}
$i = 0;
foreach ($_['story']['effect'] as $effect) {
$current = new Effect();
$current->type = $effect['type'];
$current->target = is_array(@$effect['target']) ? implode('|', @$effect['target']) : @$effect['target'];
$current->value = $effect['value'];
$current->sort = $i;
$current->union = $cause['union'];
$current->story = $story->id;
$current->save();
$i++;
}
break;
}
}
示例3: __construct
public function __construct(Story $story)
{
// initialise our parent first
parent::__construct($story->getCategory() . ' > ' . $story->getGroupAsString() . ' > ' . $story->getName());
// remember the story we are reporting on
$this->story = $story;
// we want success to say 'PASS' rather than 'OKAY'
$this->resultStrings[self::OKAY] = 'PASS';
}
示例4: executeCreate
public function executeCreate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod('post'));
$iteration = Doctrine::getTable('Iteration')->find($request->getParameter('iteration_id'));
$story = new Story();
$story->setIteration($iteration);
$this->form = new StoryForm($story);
$this->processForm($request, $this->form);
$this->setTemplate('new');
}
示例5: dashboard
function dashboard()
{
$this->User->recursive = 0;
$this->set('users', $this->paginate());
$sprints = $this->Sprint->getCurrentSprint();
$this->set('sprints', $sprints);
$tasks = $this->Task->getUserTask($this->Auth->user('id'), false);
$this->set('tasks', $tasks);
$this->set('project', $this->Project->read(null, 1));
$this->set('information', $this->Information->getLatestInformation());
$this->set('show_link', true);
$all_sprints = $this->Sprint->getAllSprints();
$this->Sprint->makeSprintZero($all_sprints);
$stories = $this->Story->getActiveStory();
$all_sprints = $this->PmsCommon->getEachStoryPoints($all_sprints, $stories);
$this->set("all_sprints", $all_sprints);
}
示例6: action
function action()
{
$album = new Album();
$story = new Story();
$kdgs = new Kdgs();
$story_url = new StoryUrl();
$album_list = $album->get_list("id>0", 10);
foreach ($album_list as $k => $v) {
$story_list = $kdgs->get_album_story_list($v['link_url']);
foreach ($story_list as $k2 => $v2) {
$exists = $story->check_exists("`source_audio_url`='{$v2['source_audio_url']}'");
if ($exists) {
continue;
}
$story_id = $story->insert(array('album_id' => $v['id'], 'title' => $v2['title'], 'intro' => $v2['intro'], 's_cover' => $v2['cover'], 'source_audio_url' => $v2['source_audio_url'], 'add_time' => date('Y-m-d H:i:s')));
$story_url->insert(array('res_name' => 'story', 'res_id' => $story_id, 'field_name' => 'cover', 'source_url' => $v2['cover'], 'source_file_name' => ltrim(strrchr($v2['cover'], '/'), '/'), 'add_time' => date('Y-m-d H:i:s')));
echo $story_id;
echo "<br />";
exit;
}
}
}
示例7: getBeastData
public function getBeastData($id)
{
$retArray = array();
if (Beast::where('TaxonID', '=', $id)->count() > 0) {
$beast = Beast::where('TaxonID', '=', $id)->first();
if (isset($beast->AcceptedCommonName)) {
$beastName = '%' . $beast->AcceptedCommonName . '%';
$stories = Story::where(function ($query) use($beastName) {
$query->where('Subjects', 'like', $beastName)->orWhere('Keywords', 'like', $beastName);
})->get();
$retArray['stories'] = $stories;
}
$sightings = Sighting::where('TaxonID', '=', $id)->orderBy('Date', 'DESC');
if ($sightings->count() > 0) {
$sighting = $sightings->first();
if (isset($beast->ScientificName)) {
$apiSighting = $this->getLatestAPISighting($beast->ScientificName);
if (count($apiSighting > 0) && $apiSighting[0] > $sighting->Date) {
$retArray['sighting'] = array('longitude' => $apiSighting[1][0], 'latitude' => $apiSighting[1][1], 'date' => $apiSighting[0], 'name' => $apiSighting[2]);
} else {
$retArray['sighting'] = array('longitude' => $sighting->Longitude, 'latitude' => $sighting->Latitude, 'date' => $sighting->Date, 'name' => $sighting->Username);
}
} else {
$retArray['sighting'] = array('longitude' => $sighting->Longitude, 'latitude' => $sighting->Latitude, 'date' => $sighting->Date, 'name' => $sighting->Username);
}
} else {
if (isset($beast->ScientificName)) {
$apiSighting = $this->getLatestAPISighting($beast->ScientificName);
if (count($apiSighting) > 0) {
$retArray['sighting'] = array('longitude' => $apiSighting[1][0], 'latitude' => $apiSighting[1][1], 'date' => $apiSighting[0], 'name' => $apiSighting[2]);
} else {
$retArray['sighting'] = array();
}
} else {
$retArray['sighting'] = array();
}
}
$retArray['info'] = $beast;
}
return $retArray;
}
示例8: array_keys
$t->is($post->getUniqueId(), $identifier);
// @Test: getFieldsArray() generates an array with all the required fields
$keys = array_keys($post->getFieldsArray());
$t->is_deeply($keys, array('sf_unique_id', 'sf_meta_class', 'sf_meta_id', 'title_t', 'body_t'));
// @Test: getFieldsArray() generates an array with correct values
$array = $post->getFieldsArray();
$t->is($array['sf_meta_class']['value'], 'Post');
$t->is($array['sf_meta_id']['value'], $post->getId());
$t->is($array['title_t']['value'], 'title');
$t->is($array['body_t']['value'], 'body');
// @Test: deleteIndex() calls the deleteAllFromClass handler function
$handler->deleteAllFromClass('Post')->once();
$handler->commit()->once();
$handler->replay();
Doctrine::getTable('Post')->deleteIndex();
$handler->verify();
// @Test: createSearchQuery returns a Doctrine_Query object
$results = array('response' => array('docs' => array(0 => array('sf_meta_id' => 1), 3 => array('sf_meta_id' => 2), 2 => array('sf_meta_id' => 3))));
$handler->any('search')->returns($results);
$handler->replay();
$q = Doctrine::getTable('Post')->createSearchQuery('azerty');
$t->ok($q instanceof Doctrine_Query);
// @Test: I18n integration
$story = new Story();
$story->slug = 'toto';
$story->Translation['fr']->body = 'Mon histoire';
$story->Translation['en']->body = 'My story';
$story->save();
$fields = $story->getFieldsArray();
$t->ok(array_key_exists('body_fr', $fields));
$t->ok(array_key_exists('body_en', $fields));
示例9: 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
//.........这里部分代码省略.........
示例10: blockStory
public static function blockStory($type, $stories = [], $extra = NULL)
{
$blocks = ["recommended", "featured", "random", "new"];
if (in_array($type, $blocks)) {
while (list($key, ) = each($stories)) {
Story::dataProcess($stories[$key]);
}
\Base::instance()->set('renderData', $stories);
\Base::instance()->set('extra', $extra);
return parent::render("story/block.{$type}.html");
} else {
return NULL;
}
}
示例11: PLG_replaceTags
//.........这里部分代码省略.........
if (!empty($url)) {
$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);
}
示例12: Database
<?php
include 'includes/header.php';
// create DB object
$db = new Database();
$st = new Story();
$ca = new Category();
// check url for category
if (isset($_GET['category'])) {
$category = $_GET['category'];
$stories = $db->select($st->getStoryByCategory($category));
$cat = $db->select($ca->getCategoryById($category))->fetch_assoc();
} else {
$stories = $db->select($st->getAllStories());
}
$categories = $db->select($st->getStoryCategories());
?>
<div class="container">
<div class="header">
<h1 class="title">Stories</h1>
<?php
if (isset($category)) {
?>
<p class="lead description">Stories in the <?php
echo $cat['Name'];
?>
category</p>
<?php
} else {
?>
示例13: mailstoryform
/**
* Display form to email a story to someone.
*
* @param string $sid ID of article to email
* @return string HTML for email story form
*
*/
function mailstoryform($sid, $to = '', $toemail = '', $from = '', $fromemail = '', $shortmsg = '', $msg = 0)
{
global $_CONF, $_TABLES, $_USER, $LANG08, $LANG_LOGIN;
require_once $_CONF['path_system'] . 'lib-story.php';
$retval = '';
if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) {
$retval = COM_startBlock($LANG_LOGIN[1], '', COM_getBlockTemplate('_msg_block', 'header'));
$login = new Template($_CONF['path_layout'] . 'submit');
$login->set_file(array('login' => 'submitloginrequired.thtml'));
$login->set_var('xhtml', XHTML);
$login->set_var('site_url', $_CONF['site_url']);
$login->set_var('site_admin_url', $_CONF['site_admin_url']);
$login->set_var('layout_url', $_CONF['layout_url']);
$login->set_var('login_message', $LANG_LOGIN[2]);
$login->set_var('lang_login', $LANG_LOGIN[3]);
$login->set_var('lang_newuser', $LANG_LOGIN[4]);
$login->parse('output', 'login');
$retval .= $login->finish($login->get_var('output'));
$retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
return $retval;
}
$story = new Story();
$result = $story->loadFromDatabase($sid, 'view');
if ($result != STORY_LOADED_OK) {
return COM_refresh($_CONF['site_url'] . '/index.php');
}
if ($msg > 0) {
$retval .= COM_showMessage($msg);
}
if (empty($from) && empty($fromemail)) {
if (!COM_isAnonUser()) {
$from = COM_getDisplayName($_USER['uid'], $_USER['username'], $_USER['fullname']);
$fromemail = DB_getItem($_TABLES['users'], 'email', "uid = {$_USER['uid']}");
}
}
$mail_template = new Template($_CONF['path_layout'] . 'profiles');
$mail_template->set_file('form', 'contactauthorform.thtml');
$mail_template->set_var('xhtml', XHTML);
$mail_template->set_var('site_url', $_CONF['site_url']);
$mail_template->set_var('site_admin_url', $_CONF['site_admin_url']);
$mail_template->set_var('layout_url', $_CONF['layout_url']);
$mail_template->set_var('start_block_mailstory2friend', COM_startBlock($LANG08[17]));
$mail_template->set_var('lang_title', $LANG08[31]);
$mail_template->set_var('story_title', $story->displayElements('title'));
$url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid);
$mail_template->set_var('story_url', $url);
$link = COM_createLink($story->displayElements('title'), $url);
$mail_template->set_var('story_link', $link);
$mail_template->set_var('lang_fromname', $LANG08[20]);
$mail_template->set_var('name', $from);
$mail_template->set_var('lang_fromemailaddress', $LANG08[21]);
$mail_template->set_var('email', $fromemail);
$mail_template->set_var('lang_toname', $LANG08[18]);
$mail_template->set_var('toname', $to);
$mail_template->set_var('lang_toemailaddress', $LANG08[19]);
$mail_template->set_var('toemail', $toemail);
$mail_template->set_var('lang_cc', $LANG08[36]);
$mail_template->set_var('lang_cc_description', $LANG08[37]);
$mail_template->set_var('lang_shortmessage', $LANG08[27]);
$mail_template->set_var('shortmsg', htmlspecialchars($shortmsg));
$mail_template->set_var('lang_warning', $LANG08[22]);
$mail_template->set_var('lang_sendmessage', $LANG08[16]);
$mail_template->set_var('story_id', $sid);
$mail_template->set_var('end_block', COM_endBlock());
PLG_templateSetVars('emailstory', $mail_template);
$mail_template->parse('output', 'form');
$retval .= $mail_template->finish($mail_template->get_var('output'));
return $retval;
}
示例14: STORY_renderArticle
if ($_CONF['showfirstasfeatured'] == 1) {
$story->_featured = 1;
}
// display first article
if ($story->DisplayElements('featured') == 1) {
$pageBody .= STORY_renderArticle($story, 'y');
$pageBody .= PLG_showCenterblock(CENTERBLOCK_AFTER_FEATURED, $page, $topic);
} else {
$pageBody .= PLG_showCenterblock(CENTERBLOCK_AFTER_FEATURED, $page, $topic);
$pageBody .= STORY_renderArticle($story, 'y');
}
$articleCounter++;
// get remaining stories
while ($A = DB_fetchArray($result)) {
$pageBody .= PLG_displayAdBlock('story', $articleCounter);
$story = new Story();
$story->loadFromArray($A);
$pageBody .= STORY_renderArticle($story, 'y');
$articleCounter++;
}
// get plugin center blocks that follow articles
$pageBody .= PLG_showCenterblock(CENTERBLOCK_BOTTOM, $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 {
示例15: enqueue_issue_story_scripts
function enqueue_issue_story_scripts()
{
global $post;
if ($post->post_type == 'issue' && ($javascript_url = Issue::get_javascript_url($post)) !== False) {
Config::add_script($javascript_url);
} else {
if ($post->post_type == 'story' && ($javascript_url = Story::get_javascript_url($post)) !== False) {
if (($issue = get_story_issue($post)) !== False && ($issue_javascript_url = Issue::get_javascript_url($issue)) !== False) {
Config::add_script($issue_javascript_url);
}
Config::add_script($javascript_url);
}
}
}