本文整理汇总了PHP中JFactory::getapplication方法的典型用法代码示例。如果您正苦于以下问题:PHP JFactory::getapplication方法的具体用法?PHP JFactory::getapplication怎么用?PHP JFactory::getapplication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFactory
的用法示例。
在下文中一共展示了JFactory::getapplication方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayDefault
function displayDefault($tpl = null) {
$this->me = KunenaUserHelper::getMyself();
$this->layout = $this->state->get('layout');
if ($this->layout == 'flat') $this->layout = 'default';
$this->setLayout($this->layout);
$this->assignRef ( 'category', $this->get ( 'Category' ) );
$this->assignRef ( 'topic', $this->get ( 'Topic' ) );
$channels = $this->category->getChannels();
if ($this->category->id && ! $this->category->authorise('read')) {
// User is not allowed to see the category
$this->setError($this->category->getError());
} elseif (! $this->topic) {
// Moved topic loop detected (1 -> 2 -> 3 -> 2)
$this->setError(JText::_('COM_KUNENA_VIEW_TOPIC_ERROR_LOOP'));
} elseif (! $this->topic->authorise('read')) {
// User is not allowed to see the topic
$this->setError($this->topic->getError());
} elseif ($this->state->get('item.id') != $this->topic->id || ($this->category->id != $this->topic->category_id && !isset($channels[$this->topic->category_id])) || ($this->state->get('layout') != 'threaded' && $this->state->get('item.mesid'))) {
// Topic has been moved or it doesn't belong to the current category
$db = JFactory::getDBO();
$mesid = $this->state->get('item.mesid');
if (!$mesid) {
$mesid = $this->topic->first_post_id;
}
$message = KunenaForumMessageHelper::get($mesid);
if ($message->exists()) JFactory::getApplication()->redirect($message->getUrl(null, false));
}
$errors = $this->getErrors();
if ($errors) {
return $this->displayNoAccess($errors);
}
$this->assignRef ( 'messages', $this->get ( 'Messages' ) );
$this->assignRef ( 'total', $this->get ( 'Total' ) );
// If page does not exist, redirect to the last page
if ($this->total <= $this->state->get('list.start')) {
JFactory::getApplication()->redirect($this->topic->getUrl(null, false, (int)($this->total / $this->state->get('list.limit'))));
}
$this->assignRef ( 'moderators', $this->get ( 'Moderators' ) );
$this->assignRef ( 'usertopic',$this->topic->getUserTopic());
$this->headerText = JText::_('COM_KUNENA_MENU_LATEST_DESC');
$this->title = JText::_('COM_KUNENA_ALL_DISCUSSIONS');
$this->pagination = $this->getPagination ( 5 );
$this->me = KunenaUserHelper::getMyself();
$this->config = KunenaFactory::getConfig();
// Mark topic read
$this->topic->markRead ();
$this->topic->hits++;
$this->topic->save();
// Check is subscriptions were sent and reset the value
if ($this->topic->authorise('subscribe')) {
$usertopic = $this->topic->getUserTopic();
if ($usertopic->subscribed == 2) {
$usertopic->subscribed = 1;
$usertopic->save();
}
}
$this->keywords = $this->topic->getKeywords(false, ', ');
$this->buttons();
// Get captcha & quick reply
$this->captcha = KunenaSpamRecaptcha::getInstance();
$this->quickreply = ($this->topic->authorise('reply',null, false) && $this->me->exists() && !$this->captcha->enabled());
//meta description and keywords
// TODO: use real keywords, too
$metaKeys = $this->escape ( "{$this->topic->subject}, {$this->category->getParent()->name}, {$this->config->board_title}, " . JText::_('COM_KUNENA_GEN_FORUM') . ', ' . JFactory::getapplication()->getCfg ( 'sitename' ) );
// Create Meta Description form the content of the first message
// better for search results display but NOT for search ranking!
$metaDesc = KunenaHtmlParser::stripBBCode($this->topic->first_post_message);
$metaDesc = preg_replace('/\s+/', ' ', $metaDesc); // remove newlines
$metaDesc = preg_replace('/^[^\w0-9]+/', '', $metaDesc); // remove characters at the beginning that are not letters or numbers
$metaDesc = trim($metaDesc); // Remove trailing spaces and beginning
// remove multiple spaces
while (strpos($metaDesc, ' ') !== false){
$metaDesc = str_replace(' ', ' ', $metaDesc);
}
// limit to 185 characters - google will cut off at ~150
if (strlen($metaDesc) > 185){
$metaDesc = rtrim(JString::substr($metaDesc, 0, 182)).'...';
}
$this->document->setMetadata ( 'keywords', $metaKeys );
$this->document->setDescription ( $this->escape($metaDesc) );
$this->setTitle(JText::sprintf('COM_KUNENA_VIEW_TOPICS_DEFAULT', $this->topic->subject));
$this->display($tpl);
}
示例2: displayDefault
function displayDefault($tpl = null) {
$this->me = KunenaFactory::getUser();
$this->layout = $this->state->get('layout');
if ($this->layout == 'flat') $this->layout = 'default';
$this->setLayout($this->layout);
$this->assignRef ( 'category', $this->get ( 'Category' ) );
$this->assignRef ( 'topic', $this->get ( 'Topic' ) );
$channels = $this->category->getChannels();
if ($this->category->id && ! $this->category->authorise('read')) {
// User is not allowed to see the category
$this->setError($this->category->getError());
} elseif (! $this->topic) {
// Moved topic loop detected (1 -> 2 -> 3 -> 2)
$this->setError(JText::_('COM_KUNENA_VIEW_TOPIC_ERROR_LOOP'));
} elseif (! $this->topic->authorise('read')) {
// User is not allowed to see the topic
$this->setError($this->topic->getError());
} elseif ($this->state->get('item.id') != $this->topic->id || ($this->category->id != $this->topic->category_id && !isset($channels[$this->topic->category_id]))) {
// Topic has been moved or it doesn't belong to the current category
$db = JFactory::getDBO();
$query = "SELECT COUNT(*) FROM #__kunena_messages WHERE thread={$db->Quote($this->topic->id)} AND hold IN ({$this->state->get('hold')}) AND id<={$db->Quote($this->state->get('item.id'))}";
$db->setQuery ( $query );
$replyCount = $db->loadResult ();
if (KunenaError::checkDatabaseError()) return;
$app = JFactory::getApplication();
$app->redirect(CKunenaLink::GetThreadPageURL ( 'view', $this->topic->category_id, $this->topic->id, $replyCount, $this->state->get('list.limit'), $this->state->get('item.id'), false ));
}
$errors = $this->getErrors();
if ($errors) {
return $this->displayNoAccess($errors);
}
$this->assignRef ( 'messages', $this->get ( 'Messages' ) );
$this->assignRef ( 'total', $this->get ( 'Total' ) );
// If page does not exist, redirect to the last page
/* if ($this->total <= $this->state->get('list.start')) {
$app = JFactory::getApplication();
$app->redirect(CKunenaLink::GetThreadPageURL('view', $this->topic->category_id, $this->topic->id, $this->total, $this->state->get('list.start'), '', false));
}
*/
$this->assignRef ( 'moderators', $this->get ( 'Moderators' ) );
$this->assignRef ( 'usertopic',$this->topic->getUserTopic());
$this->headerText = JText::_('COM_KUNENA_MENU_LATEST_DESC');
$this->title = JText::_('COM_KUNENA_ALL_DISCUSSIONS');
$this->pagination = $this->getPagination ( 5 );
$this->me = KunenaFactory::getUser();
$this->config = KunenaFactory::getConfig();
// Mark topic read
$this->topic->markRead ();
$this->topic->hits++;
$this->topic->save();
// Check is subscriptions were sent and reset the value
if ($this->topic->authorise('subscribe')) {
$usertopic = $this->topic->getUserTopic();
if ($usertopic->subscribed == 2) {
$usertopic->subscribed = 1;
$usertopic->save();
}
}
$this->keywords = $this->topic->getKeywords(false, ', ');
$this->buttons();
//meta description and keywords
// TODO: use real keywords, too
$metaKeys = $this->escape ( "{$this->topic->subject}, {$this->category->getParent()->name}, {$this->config->board_title}, " . JText::_('COM_KUNENA_GEN_FORUM') . ', ' . JFactory::getapplication()->getCfg ( 'sitename' ) );
// Create Meta Description form the content of the first message
// better for search results display but NOT for search ranking!
$metaDesc = KunenaHtmlParser::stripBBCode($this->topic->first_post_message);
$metaDesc = preg_replace('/\s+/', ' ', $metaDesc); // remove newlines
$metaDesc = preg_replace('/^[^\w0-9]+/', '', $metaDesc); // remove characters at the beginning that are not letters or numbers
$metaDesc = trim($metaDesc); // Remove trailing spaces and beginning
// remove multiple spaces
while (strpos($metaDesc, ' ') !== false){
$metaDesc = str_replace(' ', ' ', $metaDesc);
}
// limit to 185 characters - google will cut off at ~150
if (strlen($metaDesc) > 185){
$metaDesc = rtrim(JString::substr($metaDesc, 0, 182)).'...';
}
$this->document->setMetadata ( 'keywords', $metaKeys );
$this->document->setDescription ( $this->escape($metaDesc) );
$this->setTitle(JText::sprintf('COM_KUNENA_VIEW_TOPICS_DEFAULT', $this->topic->subject));
$this->display($tpl);
}