• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Common\Entity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Idno\Common\Entity的典型用法代码示例。如果您正苦于以下问题:PHP Entity类的具体用法?PHP Entity怎么用?PHP Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Entity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
         }
     }
 }
开发者ID:emory,项目名称:Known,代码行数:30,代码来源:Post.php


示例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();
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:35,代码来源:Homepage.php


示例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();
 }
开发者ID:phpsource,项目名称:idno,代码行数:26,代码来源:Search.php


示例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');
     }
 }
开发者ID:hank,项目名称:Known,代码行数:33,代码来源:Post.php


示例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;
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:17,代码来源:Main.php


示例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']);
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:14,代码来源:View.php


示例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;
 }
开发者ID:avewrigley,项目名称:idno,代码行数:14,代码来源:Shortlink.php


示例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();
 }
开发者ID:phpsource,项目名称:idno,代码行数:15,代码来源:Edit.php


示例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();
 }
开发者ID:phpsource,项目名称:idno,代码行数:19,代码来源:View.php


示例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();
 }
开发者ID:kreativmind,项目名称:Known,代码行数:19,代码来源:Edit.php


示例11: postContent

 function postContent()
 {
     if (!empty($this->arguments[0])) {
         $object = \Idno\Common\Entity::getByID($this->arguments[0]);
     }
     if (empty($object)) {
         $this->setResponse(404);
         echo \Idno\Core\Idno::site()->template()->__(array('body' => \Idno\Core\Idno::site()->template()->draw('404'), 'title' => 'Not found'))->drawPage();
         exit;
     }
     if (!$object->canEdit()) {
         $this->setResponse(403);
         echo \Idno\Core\Idno::site()->template()->__(array('body' => \Idno\Core\Idno::site()->template()->draw('403'), 'title' => 'Permission denied'))->drawPage();
         exit;
     }
     $object->unsyndicate();
     \Idno\Core\Idno::site()->session()->addMessage("We removed copies on all the syndicated sites.");
     $this->forward($object->getDisplayURL());
 }
开发者ID:sintoris,项目名称:Known,代码行数:19,代码来源:Withdraw.php


示例12: postContent

 function postContent()
 {
     $this->gatekeeper();
     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];
     if ($object->canEditAnnotation($permalink)) {
         if ($object->removeAnnotation($permalink) && $object->save()) {
             //\Idno\Core\site()->session()->addMessage('The annotation was deleted.');
         }
     }
     $this->forward($object->getURL() . '#comments');
 }
开发者ID:jeffery,项目名称:idno,代码行数:20,代码来源:Delete.php


示例13: postContent

 function postContent()
 {
     $this->gatekeeper();
     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];
     if ($object->canEdit()) {
         if ($object->removeAnnotation($permalink) && $object->save()) {
             \Idno\Core\site()->session()->addMessage('Annotation ' . $permalink . ' was deleted.');
         }
     }
     $this->forward($_SERVER['HTTP_REFERER']);
 }
开发者ID:phpsource,项目名称:idno,代码行数:20,代码来源:Delete.php


示例14: postContent

 function postContent()
 {
     $this->createGatekeeper();
     if (!empty($this->arguments)) {
         $object = Entity::getByID($this->arguments[0]);
     }
     if ($object) {
         if (!$object->canEdit()) {
             $this->setResponse(403);
             Idno::site()->session()->addErrorMessage("You don't have permission to delete this object.");
         } else {
             if ($object->delete()) {
                 Idno::site()->session()->addMessage($object->getTitle() . ' was deleted.');
             } else {
                 Idno::site()->session()->addErrorMessage("We couldn't delete " . $object->getTitle() . ".");
             }
         }
     }
     $this->forward($_SERVER['HTTP_REFERER']);
 }
开发者ID:kylewm,项目名称:KnownReactions,代码行数:20,代码来源:Delete.php


示例15: post

 function post()
 {
     \Idno\Core\Idno::site()->logging->debug("Pubsub: Ping received");
     // Since we've overloaded post, we need to parse the arguments
     $arguments = func_get_args();
     if (!empty($arguments)) {
         $this->arguments = $arguments;
     }
     // Find users
     if (!empty($this->arguments[0])) {
         $subscriber = \Idno\Common\Entity::getByID($this->arguments[0]);
     }
     if (empty($subscriber) || !$subscriber instanceof \Idno\Entities\User) {
         $this->goneContent();
     }
     if (!empty($this->arguments[1])) {
         $subscription = \Idno\Common\Entity::getByID($this->arguments[1]);
     }
     if (empty($subscription) || !$subscription instanceof \Idno\Entities\User) {
         $this->goneContent();
     }
     \Idno\Core\Idno::site()->logging->debug("Pubsub: Ping received, pinging out...");
     \Idno\Core\Idno::site()->triggerEvent('pubsubhubbub/ping', array('subscriber' => $subscriber, 'subscription' => $subscription, 'data' => trim(file_get_contents("php://input"))));
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:24,代码来源:Callback.php


示例16: post

 function post()
 {
     parse_str(trim(file_get_contents("php://input")), $vars);
     // Check that both source and target are non-empty
     if (!empty($vars['source']) && !empty($vars['target']) && $vars['source'] != $vars['target']) {
         $source = $vars['source'];
         $target = $vars['target'];
         // Remove anchors from target URL, but save them to '#' input so we can still reference them later
         if (strpos($target, '#')) {
             list($target, $fragment) = explode('#', $target, 2);
             if (!empty($fragment)) {
                 $this->setInput('#', $fragment);
             }
         }
         // Get the page handler for target
         if ($page = \Idno\Core\Idno::site()->getPageHandler($target)) {
             // First of all, make sure the target page isn't the source page. Let's not webmention ourselves!
             $webmention_ok = true;
             if (\Idno\Common\Entity::isLocalUUID($source)) {
                 if ($source_page = \Idno\Core\Idno::site()->getPageHandler($source)) {
                     if ($source_page == $page) {
                         $webmention_ok = false;
                     }
                 }
             }
             // Check that source exists, parse it for mf2 content,
             // and ensure that it genuinely mentions this page
             if ($webmention_ok) {
                 if ($source_content = \Idno\Core\Webservice::get($source)) {
                     if (substr_count($source_content['content'], $target) || $source_content['response'] == 410) {
                         $source_mf2 = \Idno\Core\Webmention::parseContent($source_content['content'], $source);
                         // Set source and target information as input variables
                         $page->setPermalink();
                         if ($page->webmentionContent($source, $target, $source_content, $source_mf2)) {
                             $this->setResponse(202);
                             // Webmention received a-ok.
                             exit;
                         } else {
                             $error = 'target_not_supported';
                             $error_text = 'This is not webmentionable.';
                         }
                     } else {
                         $error = 'no_link_found';
                         $error_text = 'The source URI does not contain a link to the target URI.';
                         \Idno\Core\Idno::site()->logging->warning('No link from ' . $source . ' to ' . $target);
                     }
                 } else {
                     $error = 'source_not_found';
                     $error_text = 'The source content for ' . $source . ' could not be obtained.';
                     \Idno\Core\Idno::site()->logging->warning('No content from ' . $source);
                 }
             } else {
                 $error = 'target_not_supported';
                 $error_text = 'A page can\'t webmention itself.';
             }
         } else {
             $error = 'target_not_found';
             $error_text = 'The target page ' . $target . ' does not exist.';
             \Idno\Core\Idno::site()->logging()->error('Could not find handler for ' . $target);
         }
     }
     $this->setResponse(400);
     // Webmention failed.
     if (empty($error)) {
         $error = 'unknown_error';
         $error_text = 'Not all the required webmention variables were set.';
     }
     echo json_encode(array('error' => $error, 'error_text' => $error_text));
 }
开发者ID:knownunknowns,项目名称:Known,代码行数:69,代码来源:Endpoint.php


示例17: setSlug

 /**
  * Sets the URL slug of this entity to the given non-empty string, returning
  * the sanitized slug on success
  * @param string $slug
  * @param int $max_pieces The maximum number of words in the slug (default: 10)
  * @param int $max_chars The maximum number of characters in the slug (default: 255)
  * @return bool
  */
 function setSlug($slug, $max_pieces = 10, $max_chars = 255)
 {
     $plugin_slug = \Idno\Core\Idno::site()->triggerEvent('entity/slug', array('object' => $this));
     if (!empty($plugin_slug) && $plugin_slug !== true) {
         return $plugin_slug;
     }
     $slug = $this->prepare_slug($slug, $max_pieces, $max_chars);
     if (empty($slug)) {
         return false;
     }
     if ($entity = \Idno\Common\Entity::getBySlug($slug)) {
         if ($entity->getUUID() != $this->getUUID()) {
             return false;
         }
     }
     $this->slug = $slug;
     return $slug;
 }
开发者ID:sensiblemn,项目名称:Known,代码行数:26,代码来源:Entity.php


示例18: setSlug

 /**
  * Sets the URL slug of this entity to the given non-empty string, returning
  * the sanitized slug on success
  * @param string $slug
  * @param int $limit The maximum length of the slug
  * @return bool
  */
 function setSlug($slug, $limit = 140)
 {
     $plugin_slug = \Idno\Core\site()->triggerEvent('entity/slug', ['object' => $this]);
     if (!empty($plugin_slug) && $plugin_slug !== true) {
         return $plugin_slug;
     }
     $slug = trim($slug);
     $slug = strtolower($slug);
     $slug = preg_replace('|https?://[a-z\\.0-9]+|i', '', $slug);
     $slug = preg_replace("/[^A-Za-z0-9\\-\\_ ]/", '', $slug);
     $slug = preg_replace("/[ ]+/", ' ', $slug);
     $slug = substr($slug, 0, $limit);
     $slug = str_replace(' ', '-', $slug);
     if (empty($slug)) {
         return false;
     }
     if ($entity = \Idno\Common\Entity::getBySlug($slug)) {
         if ($entity->getUUID() != $this->getUUID()) {
             return false;
         }
     }
     $this->slug = $slug;
     return $slug;
 }
开发者ID:phpsource,项目名称:idno,代码行数:31,代码来源:Entity.php


示例19: getActor

 /**
  * Get the actor associated with this entity
  */
 function getActor()
 {
     return \Idno\Common\Entity::getByUUID($this->actor);
 }
开发者ID:sintoris,项目名称:Known,代码行数:7,代码来源:ActivityStreamPost.php


示例20: 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();
 }
开发者ID:kylewm,项目名称:KnownReactions,代码行数:8,代码来源:Like.php



注:本文中的Idno\Common\Entity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Core\Idno类代码示例发布时间:2022-05-23
下一篇:
PHP Web\Url类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap