当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity::getBySlug方法代码示例

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


在下文中一共展示了Entity::getBySlug方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: deleteContent

 function deleteContent()
 {
     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->forward();
     }
     // TODO: 404
     if ($object->delete()) {
         \Idno\Core\site()->session()->addMessage($object->getTitle() . ' was deleted.');
     }
     $this->forward($_SERVER['HTTP_REFERER']);
 }
开发者ID:avewrigley,项目名称:idno,代码行数:17,代码来源:View.php

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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


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