Ejemplo n.º 1
0
 function getContent()
 {
     $offset = (int) $this->getInput('offset');
     $types = $this->getInput('types');
     if (!empty($this->arguments[0])) {
         // If we're on the friendly content-specific URL
         if ($friendly_types = explode('/', $this->arguments[0])) {
             $types = [];
             // Run through the URL parameters and set content types appropriately
             foreach ($friendly_types as $friendly_type) {
                 if ($content_type_class = \Idno\Common\ContentType::categoryTitleToClass($friendly_type)) {
                     $types[] = $content_type_class;
                 }
             }
         }
     }
     if (empty($types)) {
         $types = 'Idno\\Entities\\ActivityStreamPost';
         $search = ['verb' => 'post'];
     } else {
         if (!is_array($types)) {
             $types = [$types];
         }
         $types[] = '!Idno\\Entities\\ActivityStreamPost';
         $search = [];
     }
     $count = \Idno\Entities\ActivityStreamPost::countFromX($types, []);
     $feed = \Idno\Entities\ActivityStreamPost::getFromX($types, $search, [], \Idno\Core\site()->config()->items_per_page, $offset);
     if (\Idno\Core\site()->session()->isLoggedIn()) {
         $create = \Idno\Common\ContentType::getRegistered();
     } else {
         $create = false;
     }
     if (!empty(\Idno\Core\site()->config()->description)) {
         $description = \Idno\Core\site()->description;
     } else {
         $description = 'An independent social website, powered by idno.';
     }
     $t = \Idno\Core\site()->template();
     $t->__(array('title' => \Idno\Core\site()->config()->title, 'description' => $description, 'body' => $t->__(array('items' => $feed, 'contentTypes' => $create, 'offset' => $offset, 'count' => $count))->draw('pages/home')))->drawPage();
 }
Ejemplo n.º 2
0
 /**
  * Get a user's settings for default content types on their homepage (or all the content types registered
  * if none have been listed).
  *
  * THIS IS A LEGACY FUNCTION AND DUE FOR REMOVAL.
  * @deprecated
  *
  * @return array
  */
 function getDefaultContentTypes()
 {
     $friendly_types = array();
     if ($temp_types = $this->settings['default_feed_content']) {
         if (is_array($temp_types)) {
             foreach ($temp_types as $temp_type) {
                 if ($content_type_class = \Idno\Common\ContentType::categoryTitleToClass($temp_type)) {
                     $friendly_types[] = $content_type_class;
                 }
             }
         }
     }
     return $friendly_types;
 }
Ejemplo n.º 3
0
 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/');
     }
     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 {
         if (!is_array($types)) {
             $types = array($types);
         }
         $types[] = '!Idno\\Entities\\ActivityStreamPost';
     }
     $count = \Idno\Entities\ActivityStreamPost::countFromX($types, array());
     $feed = \Idno\Entities\ActivityStreamPost::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();
 }