本文整理汇总了PHP中Stream::buildStream方法的典型用法代码示例。如果您正苦于以下问题:PHP Stream::buildStream方法的具体用法?PHP Stream::buildStream怎么用?PHP Stream::buildStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::buildStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateStream
private function generateStream($offset = 0)
{
require_once FRAMEWORK_PATH . 'models/stream.php';
$stream = new Stream($this->registry);
$stream->buildStream($this->registry->getObject('authenticate')->getUser()->getUserID(), $offset);
if (!$stream->isEmpty()) {
$this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'stream/main.tpl.php', 'footer.tpl.php');
$streamdata = $stream->getStream();
$IDs = $stream->getIDs();
$cacheableIDs = array();
foreach ($IDs as $id) {
$i = array();
$i['status_id'] = $id;
$cacheableIDs[] = $i;
}
$cache = $this->registry->getObject('db')->cacheData($cacheableIDs);
$this->registry->getObject('template')->getPage()->addTag('stream', array('DATA', $cache));
foreach ($streamdata as $data) {
$datatags = array();
foreach ($data as $tag => $value) {
$datatags['status' . $tag] = $value;
}
// your own status updates
if ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID() && $data['poster'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
// it was a present...from me to me!
// http://www.imdb.com/title/tt0285403/quotes?qt0473119
$this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '-Spongebob-Squarepants-Costume-gift.tpl.php', $datatags);
} elseif ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
// updates to you
$this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '-toself.tpl.php', $datatags);
} elseif ($data['poster'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
// updates by you
$this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '-fromself.tpl.php', $datatags);
} elseif ($data['poster'] == $data['profile']) {
$this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '-user.tpl.php', $datatags);
} else {
// network updates
$this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '.tpl.php', $datatags);
}
}
// stream comments, likes and dislikes
$status_ids = implode(',', $IDs);
$start = array();
foreach ($IDs as $id) {
$start[$id] = array();
}
// comments
$comments = $start;
$sql = "SELECT p.name as commenter, c.profile_post, c.comment FROM profile p, comments c WHERE p.user_id=c.creator AND c.approved=1 AND c.profile_post IN ({$status_ids})";
$this->registry->getObject('db')->executeQuery($sql);
if ($this->registry->getObject('db')->numRows() > 0) {
while ($comment = $this->registry->getObject('db')->getRows()) {
$comments[$comment['profile_post']][] = $comment;
}
}
foreach ($comments as $status => $comments) {
$cache = $this->registry->getObject('db')->cacheData($comments);
$this->registry->getObject('template')->getPage()->addTag('comments-' . $status, array('DATA', $cache));
}
// likes + dislikes
$likes = $start;
$dislikes = $start;
$sql = "SELECT i.status, p.name as iker, i.iker as iker_id, i.type as type FROM profile p, ikes i WHERE p.user_id=i.iker AND i.status IN ({$status_ids}) ";
$this->registry->getObject('db')->executeQuery($sql);
if ($this->registry->getObject('db')->numRows() > 0) {
while ($ike = $this->registry->getObject('db')->getRows()) {
if ($ike['type'] == 'likes') {
$likes[$ike['status']][] = $ike;
} else {
$dislikes[$ike['status']][] = $ike;
}
}
}
foreach ($likes as $status => $likeslist) {
$cache = $this->registry->getObject('db')->cacheData($likeslist);
$this->registry->getObject('template')->getPage()->addTag('likes-' . $status, array('DATA', $cache));
}
foreach ($dislikes as $status => $dislikeslist) {
$cache = $this->registry->getObject('db')->cacheData($dislikeslist);
$this->registry->getObject('template')->getPage()->addTag('dislikes-' . $status, array('DATA', $cache));
}
} else {
$this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'stream/none.tpl.php', 'footer.tpl.php');
}
}
示例2: generateStream
public function generateStream($offset = 0)
{
if ($offset == 0) {
$this->registry->getObject('template')->getPage()->addTag('referer', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
require_once 'stream.php';
$stream = new Stream($this->registry);
$stream->buildStream($this->registry->getObject('authenticate')->getUser()->getUserID(), $offset);
$statusTypes = $stream->getStatusType();
if (!$stream->isEmpty()) {
$this->registry->getObject('template')->buildFromTemplate('header.php', 'stream_main.php', 'footer.php');
$streamdata = $stream->getStream();
$IDs = $stream->getIDs();
$cacheableIDs = array();
foreach ($IDs as $id) {
$i = array();
$i['status_id'] = $id;
$cacheableIDs[] = $i;
}
$cache = $this->registry->getObject('db')->cacheData($cacheableIDs);
$this->registry->getObject('template')->getPage()->addTag('stream', array('DATA', $cache));
//var_dump($cacheableIDs);
foreach ($streamdata as $data) {
$datatags = array();
foreach ($data as $tag => $value) {
$datatags['status' . $tag] = $value;
}
//var_dump($datatags);
// your own status updates
if ($data['profile'] == 0) {
// network updates
$this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-general.php', $datatags);
} elseif ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID() && $data['poster'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
$this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-self.php', $datatags);
} elseif ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
// updates to you
$this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-toSelf.php', $datatags);
} elseif ($data['poster'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
// updates by you
$this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-fromSelf.php', $datatags);
} elseif ($data['poster'] == $data['profile']) {
$this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-user.php', $datatags);
} else {
// network updates
$this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '.php', $datatags);
}
}
// stream comments, likes and dislikes
$status_ids = implode(',', $IDs);
$start = array();
foreach ($IDs as $id) {
$start[$id] = array();
}
// comments
$this->generateComments($start, $status_ids);
//rates
$this->getRates('status', $IDs);
//$this->getRates('comments', $IDs);
$this->registry->getObject('template')->getPage()->addTag('offset', $offset + 20);
//var_dump($this->registry->getObject('template')->getPage()->getBits());
if ($stream->noMoreStreams) {
$this->registry->ajaxReply(array('content' => '', 'status' => 'stream404'));
}
} else {
$this->registry->getObject('template')->buildFromTemplate('header.php', 'stream_none.php', 'footer.php');
}
} else {
//"View More" of Stream
$this->registry->getObject('template')->getPage()->addTag('referer', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
require_once 'stream.php';
$stream = new Stream($this->registry);
$stream->buildStream($this->registry->getObject('authenticate')->getUser()->getUserID(), $offset);
$statusTypes = $stream->getStatusType();
if (!$stream->isEmpty()) {
$this->registry->getObject('template')->buildFromTemplate('stream_more.php');
$streamdata = $stream->getStream();
$IDs = $stream->getIDs();
$cacheableIDs = array();
foreach ($IDs as $id) {
$i = array();
$i['status_id'] = $id;
$cacheableIDs[] = $i;
}
$cache = $this->registry->getObject('db')->cacheData($cacheableIDs);
$this->registry->getObject('template')->getPage()->addTag('stream', array('DATA', $cache));
//var_dump($cacheableIDs);
foreach ($streamdata as $data) {
$datatags = array();
foreach ($data as $tag => $value) {
$datatags['status' . $tag] = $value;
}
//var_dump($datatags);
// your own status updates
if ($data['profile'] == 0) {
// network updates
$this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-general.php', $datatags);
} elseif ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID() && $data['poster'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
$this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-self.php', $datatags);
} elseif ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
// updates to you
$this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-toSelf.php', $datatags);
//.........这里部分代码省略.........