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


PHP Entity::countFromX方法代码示例

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


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

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

示例2: getContent

 function getContent()
 {
     if (!empty($this->arguments[0])) {
         $user = \Idno\Entities\User::getByHandle($this->arguments[0]);
     }
     if (empty($user)) {
         $this->noContent();
     }
     // Users own their own profiles
     $this->setOwner($user);
     $types = \Idno\Common\ContentType::getRegisteredClasses();
     $offset = (int) $this->getInput('offset');
     $count = \Idno\Common\Entity::countFromX($types, array('owner' => $user->getUUID()));
     $feed = \Idno\Common\Entity::getFromX($types, array('owner' => $user->getUUID()), array(), \Idno\Core\Idno::site()->config()->items_per_page, $offset);
     $last_modified = $user->updated;
     if (!empty($feed) && is_array($feed)) {
         if ($feed[0]->updated > $last_modified) {
             $last_modified = $feed[0]->updated;
         }
     }
     $this->setLastModifiedHeader($last_modified);
     $t = \Idno\Core\Idno::site()->template();
     $t->__(array('title' => $user->getTitle(), 'body' => $t->__(array('user' => $user, 'items' => $feed, 'count' => $count, 'offset' => $offset))->draw('entity/User/profile'), 'description' => 'The ' . \Idno\Core\Idno::site()->config()->title . ' profile for ' . $user->getTitle()))->drawPage();
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:24,代码来源:View.php

示例3: countPosts

 /**
  * Count the number of posts this user has made
  * @return int
  */
 function countPosts()
 {
     $types = \Idno\Common\ContentType::getRegisteredClasses();
     return \Idno\Common\Entity::countFromX($types, array('owner' => $this->getUUID()));
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:9,代码来源:User.php

示例4: getContent

 function getContent()
 {
     $query = $this->getInput('q');
     $offset = (int) $this->getInput('offset');
     $types = $this->getInput('types');
     $friendly_types = array();
     // Check for an empty site
     if (!\Idno\Entities\User::get()) {
         $this->forward(\Idno\Core\Idno::site()->config()->getURL() . 'begin/');
     }
     // Set the homepage owner for single-user sites
     if (!$this->getOwner() && \Idno\Core\Idno::site()->config()->single_user) {
         $owners = \Idno\Entities\User::get(['admin' => true]);
         if (count($owners) === 1) {
             $this->setOwner($owners[0]);
         } else {
             \Idno\Core\Idno::site()->logging()->warning('Expected exactly 1 admin user for single-user site; got ' . count($owners));
         }
     }
     if (!empty($this->arguments[0])) {
         // If we're on the friendly content-specific URL
         if ($friendly_types = explode('/', $this->arguments[0])) {
             $friendly_types = array_filter($friendly_types);
             if (empty($friendly_types) && !empty($query)) {
                 $friendly_types = array('all');
             }
             $types = array();
             // Run through the URL parameters and set content types appropriately
             foreach ($friendly_types as $friendly_type) {
                 if ($friendly_type == 'all') {
                     $types = \Idno\Common\ContentType::getRegisteredClasses();
                     break;
                 }
                 if ($content_type_class = \Idno\Common\ContentType::categoryTitleToClass($friendly_type)) {
                     $types[] = $content_type_class;
                 }
             }
         }
     } else {
         // If user has content-specific preferences, do something with $friendly_types
         if (empty($query)) {
             $types = \Idno\Core\Idno::site()->config()->getHomepageContentTypes();
         }
     }
     $search = array();
     if (!empty($query)) {
         $search = \Idno\Core\Idno::site()->db()->createSearchArray($query);
     }
     if (empty($types)) {
         $types = \Idno\Common\ContentType::getRegisteredClasses();
     } else {
         $types = (array) $types;
     }
     $count = \Idno\Common\Entity::countFromX($types, array());
     $feed = \Idno\Common\Entity::getFromX($types, $search, array(), \Idno\Core\Idno::site()->config()->items_per_page, $offset);
     if (\Idno\Core\Idno::site()->session()->isLoggedIn()) {
         $create = \Idno\Common\ContentType::getRegistered();
         // If we can't create an object of this type, hide from the button bar
         foreach ($create as $key => $obj) {
             if (!$obj->createable) {
                 unset($create[$key]);
             }
         }
     } else {
         $create = false;
     }
     if (!empty(\Idno\Core\Idno::site()->config()->description)) {
         $description = \Idno\Core\Idno::site()->config()->description;
     } else {
         $description = 'An independent social website, powered by Known.';
     }
     // If we have a feed, set our last modified flag to the time of the latest returned entry
     if (!empty($feed)) {
         if (is_array($feed)) {
             $feed = array_filter($feed);
             $this->setLastModifiedHeader(reset($feed)->updated);
         }
     }
     if (!empty(\Idno\Core\Idno::site()->config()->homepagetitle)) {
         $title = \Idno\Core\Idno::site()->config()->homepagetitle;
     } else {
         $title = \Idno\Core\Idno::site()->config()->title;
     }
     $t = \Idno\Core\Idno::site()->template();
     $t->__(array('title' => $title, 'description' => $description, 'content' => $friendly_types, 'body' => $t->__(array('items' => $feed, 'contentTypes' => $create, 'offset' => $offset, 'count' => $count, 'subject' => $query, 'content' => $friendly_types))->draw('pages/home')))->drawPage();
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:86,代码来源:Homepage.php


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