本文整理汇总了PHP中ObjectCache::getByType方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectCache::getByType方法的具体用法?PHP ObjectCache::getByType怎么用?PHP ObjectCache::getByType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectCache
的用法示例。
在下文中一共展示了ObjectCache::getByType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public static function show($objectId, $jsonLast = null)
{
$db = Core::getDb();
$user = Core::getUser();
$comments = array();
$qLast = $jsonLast ? "and c.id>" . $db->escape($jsonLast) : "";
$q = $db->buildQuery("SELECT c.id, c.body, o.ctime, u.id as local_user_id, o.user_id, c.user_connection_id, con.service, con.external_id\n FROM comments c\n LEFT JOIN objects o ON o.object_id=c.object_id\n LEFT JOIN connections con ON c.user_connection_id=con.id\n\t\t\tLEFT JOIN users u ON u.id=o.user_id\n WHERE c.in_reply_to_id=%d {$qLast}\n ORDER BY o.ctime ASC", $objectId);
$rs = $db->query($q);
if ($rs && $db->numrows($rs)) {
while ($o = $db->fetchObject($rs)) {
$commentAuthor = ObjectCache::getByType('\\Kiki\\User', $o->user_id ? $o->user_id : $o->local_user_id);
if ($commentAuthor) {
if ($o->external_id) {
// HACK: should not always have to load this, but this is quicker than getStoredConnections for User 0
$connection = User\Factory::getInstance($o->service, $o->external_id, 0);
// $connection = $commentAuthor->getConnection($o->service. "_". $o->external_id, true);
if ($connection) {
$serviceName = $connection->serviceName();
$name = $connection->name();
$pic = $connection->picture();
} else {
$serviceName = 'None';
// SNH
$name = $commentAuthor->name();
$pic = $commentAuthor->picture();
}
} else {
$serviceName = 'None';
// Kiki
$name = $commentAuthor->name();
$pic = $commentAuthor->picture();
}
} else {
$serviceName = 'None';
$name = "Anonymous";
$pic = null;
}
if ($jsonLast !== null) {
$comments[] = Comments::showSingle($objectId, $o->id, $name, $pic, $serviceName, $o->body, $o->ctime);
} else {
$comment = array('objectId' => $objectId, 'id' => $o->id, 'name' => $name, 'pic' => $pic, 'type' => $serviceName, 'body' => $o->body, 'ctime' => $o->ctime, 'dateTime' => date("c", strtotime($o->ctime)), 'relTime' => Misc::relativeTime($o->ctime));
$comments[] = $comment;
}
}
} else {
if ($jsonLast === null) {
$comments[] = Comments::showDummy($objectId);
}
}
if ($jsonLast !== null) {
return $comments;
}
$template = new Template('parts/comments');
$template->assign('objectId', $objectId);
$template->assign('comments', $comments);
return $template->fetch();
}
示例2: templateData
public function templateData()
{
$uAuthor = ObjectCache::getByType('\\Kiki\\User', $this->userId);
$data = array('id' => $this->id, 'url' => $this->url(), 'ctime' => strtotime($this->ctime), 'relTime' => Misc::relativeTime($this->ctime), 'title' => $this->title(), 'body' => $this->body, 'author' => $uAuthor->name(), 'publications' => array(), 'likes' => $this->likes(), 'comments' => Comments::count($this->objectId), 'html' => array('comments' => Comments::show($this->objectId)));
$publications = $this->publications();
foreach ($publications as $publication) {
$data['publications'][] = $publication->templateData();
}
return $data;
}
示例3: templateData
public function templateData()
{
$uAuthor = ObjectCache::getByType('\\Kiki\\User', $this->userId);
$prevArticle = $this->getPrev();
$nextArticle = $this->getNext();
$data = array('id' => $this->id, 'url' => $this->url(), 'ctime' => strtotime($this->ctime), 'relTime' => Misc::relativeTime($this->ctime), 'title' => $this->title, 'body' => $this->body, 'author' => $uAuthor->name(), 'images' => array(), 'publications' => array(), 'likes' => $this->likes(), 'comments' => Comments::count($this->objectId), 'html' => array('comments' => Comments::show($this->objectId), 'editform' => $this->form(true, 'articles')));
if ($nextArticle = $this->getNext()) {
$data['next'] = array('id' => $nextArticle->id(), 'url' => $nextArticle->url(), 'title' => $nextArticle->title());
}
if ($prevArticle = $this->getPrev()) {
$data['prev'] = array('id' => $prevArticle->id(), 'url' => $prevArticle->url(), 'title' => $prevArticle->title());
}
$publications = $this->publications();
foreach ($publications as $publication) {
$data['publications'][] = $publication->templateData();
}
$images = $this->images();
foreach ($images as $image) {
$data['images'][] = Storage::url($image);
}
// print_r( $data['images'] );
return $data;
}