function display($tpl = null) { // Parameters $app = JFactory::getApplication(); $doc = Document::instance(); $params = $app->getParams(); $feedEmail = Config::get('feed_email', 'author'); $siteEmail = Config::get('mailfrom'); $doc->link = Route::url('index.php?option=com_content&view=featured'); // Get some data from the model Request::setVar('limit', Config::get('feed_limit')); $categories = JCategories::getInstance('Content'); $rows = $this->get('Items'); foreach ($rows as $row) { // strip html from feed item title $title = $this->escape($row->title); $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8'); // Compute the article slug $row->slug = $row->alias ? $row->id . ':' . $row->alias : $row->id; // Url link to article $link = Route::url(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language)); // Get row fulltext $db = App::get('db'); $query = 'SELECT' . $db->quoteName('fulltext') . 'FROM #__content WHERE id =' . $row->id; $db->setQuery($query); $row->fulltext = $db->loadResult(); $description = $params->get('feed_summary', 0) ? $row->introtext . $row->fulltext : $row->introtext; $author = $row->created_by_alias ? $row->created_by_alias : $row->author; // Load individual item creator class $item = new \Hubzero\Document\Type\Feed\Item(); $item->title = $title; $item->link = $link; $item->date = $row->publish_up; $item_category = $categories->get($row->catid); $item->category = array(); $item->category[] = Lang::txt('JFEATURED'); // All featured articles are categorized as "Featured" for ($item_category = $categories->get($row->catid); $item_category !== null; $item_category = $item_category->getParent()) { // Only add non-root categories if ($item_category->id > 1) { $item->category[] = $item_category->title; } } $item->author = $author; if ($feedEmail == 'site') { $item->authorEmail = $siteEmail; } elseif ($feedEmail === 'author') { $item->authorEmail = $row->author_email; } // Add readmore link to description if introtext is shown, show_readmore is true and fulltext exists if (!$params->get('feed_summary', 0) && $params->get('feed_show_readmore', 0) && $row->fulltext) { $description .= '<p class="feed-readmore"><a target="_blank" href ="' . $item->link . '">' . Lang::txt('COM_CONTENT_FEED_READMORE') . '</a></p>'; } // Load item description and add div $item->description = '<div class="feed-description">' . $description . '</div>'; // Loads item info into rss array $doc->addItem($item); } }
/** * Force a login without password, as long as the user exists. * * @returns True on log in, false on failure. **/ public static function force_login($username) { self::init(); $user = Document::instance('user')->findOne(array('username' => $username)); if ($user) { $_SESSION['_xoket_auth_user'] = $user->username; self::$user = $user; return true; } else { self::logout(); return false; } }
/** * Push a script to a specific sport int he scripts list * * @param integer $index * @param string $url * @param string $type * @param boolean $defer * @param boolean $async * @return void */ private static function _pushScriptTo($index, $url, $type = 'text/javascript', $defer = false, $async = false) { if (class_exists('\\Document')) { $document = \Document::instance(); } else { $document = JFactory::getDocument(); } if ($document instanceof JDocumentHTML || $document instanceof \Hubzero\Document\Type\Html) { $pushed = false; // Get the old data $data = $document->getHeadData(); $scripts = $data['scripts']; // Reset the scripts data // We need a fresh array to reorganize things $data['scripts'] = array(); // We can't reset the script data with $document->setHeadData($data); and then // use $document->addScript() because JDocument will ignore the empty array we // just set $data['scripts'] to and keep the old data. So, all we'd end up // doing is appending items. SO, we populate a new array and set the head data // to that. // Loop through old data and look for the // spot to insert the new data $i = 0; foreach ($scripts as $key => $foo) { // Found the spot? if ($i == $index) { $data['scripts'][$url] = array('mime' => $type, 'defer' => $defer, 'async' => $async); $pushed = true; } $data['scripts'][$key] = $foo; $i++; } // We didn't find out spot? // Append to the end if (!$pushed) { $data['scripts'][$url] = array('mime' => $type, 'defer' => $defer, 'async' => $async); } $document->setHeadData($data); } }
/** * Display a feed of comments * * @return void */ protected function _feed() { if (!$this->params->get('comments_feeds')) { $this->action = 'view'; $this->_view(); return; } // Set the mime encoding for the document Document::setType('feed'); // Load the comments $comment = new \Plugins\Hubzero\Comments\Models\Comment(); $filters = array('parent' => 0, 'item_type' => $this->obj_type, 'item_id' => $this->obj_id); if ($this->obj instanceof \Hubzero\Base\Model) { $title = $this->obj->get('title'); } else { $title = $this->obj->title; } // Start a new feed object $doc = Document::instance(); $doc->link = Route::url($this->url); $doc->title = Config::get('sitename') . ' - ' . Lang::txt(strtoupper($this->_option)); $doc->title .= $title ? ': ' . stripslashes($title) : ''; $doc->title .= ': ' . Lang::txt('PLG_HUBZERO_COMMENTS'); $doc->description = Lang::txt('PLG_HUBZERO_COMMENTS_RSS_DESCRIPTION', Config::get('sitename'), stripslashes($title)); $doc->copyright = Lang::txt('PLG_HUBZERO_COMMENTS_RSS_COPYRIGHT', date("Y"), Config::get('sitename')); // Start outputing results if any found if ($comment->replies('list', $filters)->total() > 0) { foreach ($comment->replies() as $row) { // URL link to article $link = Route::url('index.php?option=' . $this->_option . '§ion=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $row->id); $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS'); if (!$row->get('anonymous')) { $author = $row->creator('name'); } // Prepare the title $title = Lang::txt('PLG_HUBZERO_COMMENTS_COMMENT_BY', $author) . ' @ ' . $row->created('time') . ' on ' . $row->created('date'); // Strip html from feed item description text if ($row->isReported()) { $description = Lang::txt('PLG_HUBZERO_COMMENTS_REPORTED_AS_ABUSIVE'); } else { $description = $row->content('clean'); } @($date = $row->created() ? date('r', strtotime($row->created())) : ''); // Load individual item creator class $item = new \Hubzero\Document\Type\Feed\Item(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $date; $item->category = ''; $item->author = $author; // Loads item info into rss array $doc->addItem($item); // Check for any replies if ($row->replies()->total()) { foreach ($row->replies() as $reply) { // URL link to article $link = Route::url('index.php?option=' . $this->_option . '§ion=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $reply->id); $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS'); if (!$reply->anonymous) { $cuser = User::getInstance($reply->created_by); $author = $cuser->get('name'); } // Prepare the title $title = Lang::txt('PLG_HUBZERO_COMMENTS_REPLY_TO_COMMENT', $row->id, $author) . ' @ ' . Date::of($reply->created)->toLocal(Lang::txt('TIME_FORMAT_HZ1')) . ' ' . Lang::txt('PLG_HUBZERO_COMMENTS_ON') . ' ' . Date::of($reply->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); // Strip html from feed item description text if ($reply->reports) { $description = Lang::txt('PLG_HUBZERO_COMMENTS_REPORTED_AS_ABUSIVE'); } else { $description = is_object($p) ? $p->parse(stripslashes($reply->content)) : nl2br(stripslashes($reply->content)); } $description = html_entity_decode(\Hubzero\Utility\Sanitize::clean($description)); @($date = $reply->created ? gmdate('r', strtotime($reply->created)) : ''); // Load individual item creator class $item = new \Hubzero\Document\Type\Feed\Item(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $date; $item->category = ''; $item->author = $author; // Loads item info into rss array $doc->addItem($item); if ($reply->replies) { foreach ($reply->replies as $response) { // URL link to article $link = Route::url('index.php?option=' . $this->_option . '§ion=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $response->id); $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS'); if (!$response->anonymous) { $cuser = User::getInstance($response->created_by); $author = $cuser->get('name'); } // Prepare the title $title = Lang::txt('PLG_HUBZERO_COMMENTS_REPLY_TO_COMMENT', $reply->id, $author) . ' @ ' . Date::of($response->created)->toLocal(Lang::txt('TIME_FORMAT_HZ1')) . ' ' . Lang::txt('PLG_HUBZERO_COMMENTS_ON') . ' ' . Date::of($response->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); // Strip html from feed item description text if ($response->reports) { $description = Lang::txt('PLG_HUBZERO_COMMENTS_REPORTED_AS_ABUSIVE'); } else { $description = is_object($p) ? $p->parse(stripslashes($response->content)) : nl2br(stripslashes($response->content)); } $description = html_entity_decode(\Hubzero\Utility\Sanitize::clean($description)); @($date = $response->created ? gmdate('r', strtotime($response->created)) : ''); // Load individual item creator class $item = new \Hubzero\Document\Type\Feed\Item(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $date; $item->category = ''; $item->author = $author; // Loads item info into rss array $doc->addItem($item); } } } } } } // Output the feed echo $doc->render(); }
/** * Display an RSS feed of latest entries * * @return string */ private function _feed() { if (!$this->params->get('feeds_enabled', 1)) { return $this->_browse(); } include_once PATH_CORE . DS . 'libraries' . DS . 'joomla' . DS . 'document' . DS . 'feed' . DS . 'feed.php'; // Filters for returning results $filters = array('limit' => Request::getInt('limit', Config::get('list_limit')), 'start' => Request::getInt('limitstart', 0), 'year' => Request::getInt('year', 0), 'month' => Request::getInt('month', 0), 'scope' => 'group', 'scope_id' => $this->group->get('gidNumber'), 'search' => Request::getVar('search', ''), 'created_by' => Request::getInt('author', 0), 'state' => 'public'); $path = Request::path(); if (strstr($path, '/')) { $bits = $this->_parseUrl(); $filters['year'] = isset($bits[0]) && is_numeric($bits[0]) ? $bits[0] : $filters['year']; $filters['month'] = isset($bits[1]) && is_numeric($bits[1]) ? $bits[1] : $filters['month']; } if ($filters['year'] > date("Y")) { $filters['year'] = 0; } if ($filters['month'] > 12) { $filters['month'] = 0; } // Set the mime encoding for the document Document::setType('feed'); // Start a new feed object $doc = Document::instance(); $doc->link = Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=' . $this->_name); // Build some basic RSS document information $doc->title = Config::get('sitename') . ': ' . Lang::txt('Groups') . ': ' . stripslashes($this->group->get('description')) . ': ' . Lang::txt('Blog'); $doc->description = Lang::txt('PLG_GROUPS_BLOG_RSS_DESCRIPTION', $this->group->get('cn'), Config::get('sitename')); $doc->copyright = Lang::txt('PLG_GROUPS_BLOG_RSS_COPYRIGHT', date("Y"), Config::get('sitename')); $doc->category = Lang::txt('PLG_GROUPS_BLOG_RSS_CATEGORY'); $rows = $this->model->entries($filters)->ordered()->paginated()->rows(); // Start outputing results if any found if ($rows->count() > 0) { foreach ($rows as $row) { $item = new \Hubzero\Document\Type\Feed\Item(); // Strip html from feed item description text $item->description = $row->content; $item->description = \Hubzero\Utility\Sanitize::stripAll(strip_tags(html_entity_decode($item->description))); if ($this->params->get('feed_entries') == 'partial') { $item->description = \Hubzero\Utility\String::truncate($item->description, 300); } $item->description = '<![CDATA[' . $item->description . ']]>'; // Load individual item creator class $item->title = html_entity_decode(strip_tags($row->get('title'))); $item->link = Route::url($row->link()); $item->date = date('r', strtotime($row->published())); $item->category = ''; $item->author = $row->creator()->get('name'); // Loads item info into rss array $doc->addItem($item); } } // Output the feed echo $doc->render(); exit; }
/** * This is always going to get the first instance of the module type unless * there is a title. * * @param string $module The module name * @param string $title Module title * @param string $style Display style * @return string */ protected function byName($module, $title, $style = 'none') { $moduleinstance = $module . JStringNormalise::toCamelCase($title); if (!isset(self::$mods[$moduleinstance])) { self::$mods[$moduleinstance] = ''; $document = \Document::instance(); $renderer = $document->loadRenderer('module'); $params = array('style' => $style); $mod = \Module::byName($module, $title); // If the module without the mod_ isn't found, try it with mod_. // This allows people to enter it either way in the content if (!isset($mod)) { $name = 'mod_' . $module; $mod = \Module::byName($name, $title); } ob_start(); echo $renderer->render($mod, $params); self::$mods[$moduleinstance] = ob_get_clean(); } return self::$mods[$moduleinstance]; }
public static function addInstance(Document $document) { self::$instance = $document; }
/** * Shortcut to wrap a Mongo document in our Document object. * * @param document The document object from Mongo * @param name The name of the class to wrap it in. Defaults to 'Document' * @param database_name The name of the database configuration to use. * * @returns A Document based object with the provided data members. */ public static function wrap($document, $name = 'Document', $database_name = 'default') { $item = Document::instance($name, $database_name); $item->load($document); return $item; }
public function index() { $this->document->title = "Dashboard"; $this->document->user = Auth::get_user(); $this->document->domains = Document::instance('hit')->distinct('host', array('user' => Auth::get_user()->_id)); }
/** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { // Get the document object. $document = Document::instance(); // Set the default view name and format from the Request. $vName = Request::getCmd('view', 'login'); $vFormat = Document::getType(); $lName = Request::getCmd('layout', 'default'); if ($view = $this->getView($vName, $vFormat)) { // Do any specific processing by view. switch ($vName) { case 'registration': App::abort(403, Lang::txt('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN')); return; // If the user is already logged in, redirect to the profile page. if (User::get('guest') != 1) { // Redirect to profile page. $this->setRedirect(Route::url('index.php?option=com_users&view=profile', false)); return; } // Check if user registration is enabled if (Component::params('com_users')->get('allowUserRegistration') == 0) { // Registration is disabled - Redirect to login page. $this->setRedirect(Route::url('index.php?option=com_users&view=login', false)); return; } // The user is a guest, load the registration model and show the registration page. $model = $this->getModel('Registration'); break; // Handle view specific models. // Handle view specific models. case 'profile': App::abort(403, Lang::txt('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN')); return; // If the user is a guest, redirect to the login page. if (User::get('guest') == 1) { // Redirect to login page. $this->setRedirect(Route::url('index.php?option=com_users&view=login', false)); return; } $model = $this->getModel($vName); break; // Handle the default views. // Handle the default views. case 'login': $model = $this->getModel($vName); break; case 'reset': // If the user is already logged in, redirect to the profile page. if (User::get('guest') != 1) { // Redirect to profile page. $this->setRedirect(Route::url('index.php?option=com_members&task=myaccount', false)); return; } $model = $this->getModel($vName); break; case 'remind': // If the user is already logged in, redirect to the profile page. if (User::get('guest') != 1) { // Redirect to profile page. $this->setRedirect(Route::url('index.php?option=com_members&task=myaccount', false)); return; } $model = $this->getModel($vName); break; default: $model = $this->getModel('Login'); break; } // Push the model into the view (as default). $view->setModel($model, true); $view->setLayout($lName); // Push document object into the view. $view->assignRef('document', $document); $view->display(); } }