本文整理汇总了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();
}
示例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']);
}
示例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();
}
示例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');
}
示例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']);
}
示例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;
}
示例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;
}