本文整理汇总了PHP中Idno\Common\Entity类的典型用法代码示例。如果您正苦于以下问题:PHP Entity类的具体用法?PHP Entity怎么用?PHP Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postContent
function postContent()
{
$body = strip_tags($this->getInput('body'));
$name = strip_tags($this->getInput('name'));
$url = trim($this->getInput('url'));
$url2 = trim($this->getInput('url-2'));
$validator = $this->getInput('validator');
if (!empty($url2)) {
$this->deniedContent();
}
$this->referrerGatekeeper();
if (!empty($body) && !empty($name) && !empty($validator)) {
if ($object = Entity::getByUUID($validator)) {
if ($url = Webservice::sanitizeURL($url)) {
if ($content = Webservice::get($url)) {
if ($content['response'] == '200') {
$icon = Webmention::getIconFromWebsiteContent($content['content'], $url);
}
}
}
if (empty($icon)) {
$bn = hexdec(substr(md5($url), 0, 15));
$number = 1 + $bn % 5;
$icon = \Idno\Core\site()->config()->url . 'gfx/users/default-' . str_pad($number, 2, '0', STR_PAD_LEFT) . '.png';
}
$object->addAnnotation('reply', $name, $url, $icon, $body);
$this->forward($object->getDisplayURL());
}
}
}
示例2: getContent
function getContent()
{
if ($staticpages = \Idno\Core\Idno::site()->plugins()->get('StaticPages')) {
if (!empty($staticpages->getCurrentHomepageId())) {
$object = \Idno\Common\Entity::getByID($staticpages->getCurrentHomepageId());
if (empty($object)) {
$object = \Idno\Common\Entity::getBySlug($staticpages->getCurrentHomepageId());
}
if (empty($object)) {
$this->goneContent();
}
// From here, we know the object is set
// Ensure we're talking about pages ...
if (!$object instanceof \IdnoPlugins\StaticPages\StaticPage) {
$this->goneContent();
}
// Check that we can see it
if (!$object->canRead()) {
$this->deniedContent();
}
// Forward if necessary
if (!empty($object->forward_url) && !\Idno\Core\Idno::site()->session()->isAdmin()) {
$this->forward($object->forward_url);
}
$this->setOwner($object->getOwner());
$this->setPermalink();
// This is a permalink
$this->setLastModifiedHeader($object->updated);
// Say when this was last modified
$t = \Idno\Core\Idno::site()->template();
$t->__(array('title' => $object->getTitle(), 'body' => $t->__(array('object' => $object))->draw('staticpages/page'), 'description' => $object->getShortDescription()))->drawPage();
}
}
parent::getContent();
}
示例3: getContent
function getContent()
{
$subject = $this->getInput('q');
$types = $this->getInput('types');
$subject = trim($subject);
$offset = (int) $this->getInput('offset');
if (empty($types)) {
$types = '!Idno\\Entities\\ActivityStreamPost';
} else {
if (!is_array($types)) {
$types = [$types];
}
$types[] = '!Idno\\Entities\\ActivityStreamPost';
}
if (!empty($subject)) {
$regexObj = new \MongoRegex("/" . addslashes($subject) . "/i");
$items = \Idno\Common\Entity::getFromX($types, ['$or' => [['body' => $regexObj], ['title' => $regexObj], ['description' => $regexObj]]], [], 10, $offset);
$count = \Idno\Common\Entity::countFromX($types, ['$or' => [['body' => $regexObj], ['title' => $regexObj], ['description' => $regexObj]]]);
} else {
$items = [];
$subject = 'Search';
$count = 0;
}
$t = \Idno\Core\site()->template();
$t->__(array('title' => $subject, 'body' => $t->__(array('subject' => $subject, 'items' => $items, 'count' => $count, 'offset' => $offset))->draw('entity/search')))->drawPage();
}
示例4: postContent
function postContent()
{
$this->createGatekeeper();
// User is logged in and can post content
// Get variables
$body = $this->getInput('body');
$object_uuid = $this->getInput('object');
$type = $this->getInput('type');
$user = \Idno\Core\site()->session()->currentUser();
if ($type != 'like') {
$type = 'reply';
}
if ($object = Entity::getByUUID($object_uuid)) {
$has_liked = false;
if ($type == 'like') {
if ($like_annotations = $object->getAnnotations('like')) {
foreach ($like_annotations as $like) {
if ($like['owner_url'] == \Idno\Core\site()->session()->currentUser()->getURL()) {
$object->removeAnnotation($like['permalink']);
$object->save();
$has_liked = true;
}
}
}
}
if (!$has_liked) {
if ($object->addAnnotation($type, $user->getTitle(), $user->getURL(), $user->getIcon(), $body)) {
$object->save();
}
}
$this->forward($object->getURL() . '#comments');
}
}
示例5: setAsHomepage
/**
* Sets a static page as the homepage, overwriting the current setting if one is set.
* @param $pageId
* @return bool
*/
function setAsHomepage($pageId)
{
if (\Idno\Core\Idno::site()->session()->isLoggedIn()) {
if (\Idno\Core\Idno::site()->session()->currentUser()->isAdmin()) {
if (!empty(\Idno\Common\Entity::getByID($pageId))) {
\Idno\Core\Idno::site()->config->staticPages['homepage'] = $pageId;
return \Idno\Core\Idno::site()->config->save();
}
}
}
return false;
}
示例6: deleteContent
function deleteContent()
{
if (!empty($this->arguments[0])) {
$object = \Idno\Common\Entity::getByID($this->arguments[0]);
}
if (empty($object)) {
$this->forward();
}
// TODO: 404
if ($object->delete()) {
\Idno\Core\Idno::site()->session()->addMessage($object->getTitle() . ' was deleted.');
}
$this->forward($_SERVER['HTTP_REFERER']);
}
示例7: webmentionContent
function webmentionContent($source, $target, $source_content, $source_mf2)
{
if (!empty($this->arguments[0])) {
$object = \Idno\Common\Entity::getByShortURL($this->arguments[0]);
}
if (empty($object)) {
return false;
}
$return = true;
if ($object instanceof \Idno\Common\Entity) {
$return = $object->addWebmentions($source, $target, $source_content, $source_mf2);
}
return $return;
}
示例8: getContent
function getContent()
{
if (!empty($this->arguments[0])) {
$object = \Idno\Common\Entity::getByID($this->arguments[0]);
}
if (empty($object)) {
$this->forward();
}
// TODO: 404
if (!$object->canEdit()) {
$this->forward($object->getURL());
}
$t = \Idno\Core\site()->template();
$t->__(array('title' => $object->getTitle(), 'body' => $object->drawEdit()))->drawPage();
}
示例9: getContent
function getContent()
{
if (!empty($this->arguments[0])) {
$object = \Idno\Common\Entity::getByID($this->arguments[0]);
if (empty($object)) {
$object = \Idno\Common\Entity::getBySlug($this->arguments[0]);
}
}
if (empty($object)) {
$this->goneContent();
}
$permalink = $object->getUrl() . '/annotations/' . $this->arguments[1];
$annotation = $object->getAnnotation($permalink);
$subtype = $object->getAnnotationSubtype($permalink);
$this->setPermalink();
// This is a permalink
$t = \Idno\Core\site()->template();
$t->__(array('title' => $object->getTitle(), 'body' => $t->__(array('annotation' => $annotation, 'subtype' => $subtype, 'permalink' => $permalink, 'object' => $object))->draw('entity/annotations/shell'), 'description' => $object->getShortDescription()))->drawPage();
}
示例10: getContent
function getContent()
{
if (!empty($this->arguments[0])) {
$object = \Idno\Common\Entity::getByID($this->arguments[0]);
}
if (empty($object)) {
$this->forward();
}
// TODO: 404
if (!$object->canEdit()) {
$this->forward($object->getDisplayURL());
}
if ($owner = $object->getOwner()) {
$this->setOwner($owner);
}
session_write_close();
$t = \Idno\Core\Idno::site()->template();
$t->__(array('title' => $object->getTitle(), 'body' => $t->__(['object' => $object])->draw('entity/editwrapper')))->drawPage();
}
示例11: save
function save()
{
// generate our own meaningful, unique(ish) slug
if (!$this->getSlug() && !$this->_id && $this->getTitle() && $this->likeof) {
$this->setSlugResilient($this->getTitle() . '-' . substr(md5($this->likeof), 0, 10));
}
return parent::save();
}
示例12: hash
function __construct()
{
parent::__construct();
$this->code = hash('sha256', mt_rand() . microtime(true));
$this->expires = strtotime('now + 10 minutes');
$this->setTitle($this->code);
// better stub generation, not that it matters
}
示例13: getURL
function getURL()
{
if (!$this->getSlug() && $this->getID()) {
return \Idno\Core\site()->config()->url . 'entry/' . $this->getID() . '/' . $this->getPrettyURLTitle();
} else {
return parent::getURL();
}
}
示例14: getURL
function getURL()
{
if (!$this->getSlug() && $this->getID()) {
return \Idno\Core\site()->config()->url . 'rsvp/' . $this->getID() . '/';
} else {
return parent::getURL();
}
}
示例15: getURL
function getURL()
{
if ($this->getID()) {
return \Idno\Core\site()->config()->url . 'slides/' . $this->getID();
// . '/' . $this->getPrettyURLTitle();
} else {
return parent::getURL();
}
}