本文整理汇总了PHP中KunenaTemplate::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaTemplate::getInstance方法的具体用法?PHP KunenaTemplate::getInstance怎么用?PHP KunenaTemplate::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaTemplate
的用法示例。
在下文中一共展示了KunenaTemplate::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayEdit
function displayEdit()
{
$this->setToolBarEdit();
// FIXME: enable template parameters
$this->form = $this->get('Form');
$this->params = $this->get('editparams');
$this->details = $this->get('templatedetails');
$this->templatename = $this->app->getUserState('kunena.edit.template');
$template = KunenaTemplate::getInstance($this->templatename);
$template->initializeBackend();
$this->templatefile = KPATH_SITE . '/template/' . $this->templatename . '/params.ini';
if (!JFile::exists($this->templatefile))
{
$ourFileHandle = @fopen($this->templatefile, 'w');
if ($ourFileHandle)
{
fclose($ourFileHandle);
}
}
$this->display();
}
示例2: loadFormData
/**
* @see JModelForm::loadFormData()
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_kunena.edit.template.data', array());
if (empty($data)) {
$template = $this->getState('template');
$data = KunenaTemplate::getInstance($template)->params->toArray();
}
return $data;
}
示例3: displayEdit
function displayEdit()
{
$this->setToolBarEdit();
$this->params = $this->get('editparams');
$this->details = $this->get('templatedetails');
$this->templatename = $this->app->getUserState('kunena.edit.template');
$template = KunenaTemplate::getInstance($this->templatename);
$template->initializeBackend();
$this->display();
}
示例4: before
/**
* Prepare topic moderate display.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$catid = $this->input->getInt('catid');
$id = $this->input->getInt('id');
$mesid = $this->input->getInt('mesid');
if (!$mesid) {
$this->topic = KunenaForumTopicHelper::get($id);
$this->topic->tryAuthorise('move');
} else {
$this->message = KunenaForumMessageHelper::get($mesid);
$this->message->tryAuthorise('move');
$this->topic = $this->message->getTopic();
}
$this->category = $this->topic->getCategory();
$this->uri = "index.php?option=com_kunena&view=topic&layout=moderate" . "&catid={$this->category->id}&id={$this->topic->id}" . ($this->message ? "&mesid={$this->message->id}" : '');
$this->title = !$this->message ? JText::_('COM_KUNENA_TITLE_MODERATE_TOPIC') : JText::_('COM_KUNENA_TITLE_MODERATE_MESSAGE');
// Load topic icons if available.
if ($this->config->topicicons) {
$this->template = KunenaTemplate::getInstance();
$this->template->setCategoryIconset();
$this->topicIcons = $this->template->getTopicIcons(false);
}
// Have a link to moderate user as well.
if (isset($this->message)) {
$user = $this->message->getAuthor();
if ($user->exists()) {
$username = $user->getName();
$this->userLink = $this->message->userid ? JHtml::_('kunenaforum.link', 'index.php?option=com_kunena&view=user&layout=moderate&userid=' . $this->message->userid, $username . ' (' . $this->message->userid . ')', $username . ' (' . $this->message->userid . ')') : null;
}
}
if ($this->message) {
$this->banHistory = KunenaUserBan::getUserHistory($this->message->userid);
$this->me = KunenaFactory::getUser();
// Get thread and reply count from current message:
$db = JFactory::getDbo();
$query = "SELECT COUNT(mm.id) AS replies FROM #__kunena_messages AS m\r\n\t\t\t\tINNER JOIN #__kunena_messages AS t ON m.thread=t.id\r\n\t\t\t\tLEFT JOIN #__kunena_messages AS mm ON mm.thread=m.thread AND mm.time > m.time\r\n\t\t\t\tWHERE m.id={$db->Quote($this->message->id)}";
$db->setQuery($query, 0, 1);
$this->replies = $db->loadResult();
if (KunenaError::checkDatabaseError()) {
return;
}
}
$this->banInfo = KunenaUserBan::getInstanceByUserid(JFactory::getUser()->id, true);
}
示例5: initialize
public function initialize($identifier ='class') {
$js = "window.addEvent('domready', function() {
kbbcode = new kbbcode('kbbcode-message', 'kbbcode-toolbar', {
dispatchChangeEvent: true,
changeEventDelay: 1000,
interceptTab: true
});\n";
$editor = simplexml_load_file(dirname(__FILE__).'/editor.xml');
foreach ($editor as $item) {
if ($item['disabled'] == 'disabled') continue;
switch ($item->getName()) {
case 'button':
// <button tag="i" name="italic" title="COM_KUNENA_EDITOR_ITALIC" alt="COM_KUNENA_EDITOR_HELPLINE_ITALIC">
if ($item['config']) {
$cfgVariable = (string) $item['config'];
$cfgValue = intval($cfgVariable[0] != '!');
if (!$cfgValue) $cfgVariable = substr($cfgVariable, 1);
if (KunenaFactory::getConfig()->$cfgVariable != $cfgValue) continue;
}
$name = $item['name'] ? $item['name'] : ($item['tag'] ? $item['tag'] : '#');
$class = $item['class'] ? $item['class'] : "kbbcode-{$name}-button";
$js .= "\nkbbcode.addFunction('{$name}', function() {";
$js .= $this->editorAction($name, $item);
$js .= "\n}, {";
foreach (array('title', 'alt') as $type) {
if (isset($item[$type])) {
$value = JText::_($item[$type], true);
$js .= "\n '{$type}': '{$value}',";
}
}
if ($item['class']) {
$js .= "\n 'class': '{$class}'";
} else {
$js .= "\n '{$identifier}': '{$class}'";
}
$js .= "\n});\n";
break;
}
}
$js .= "});\n";
$template = KunenaTemplate::getInstance();
$template->addScript('js/editor.js');
JFactory::getDocument()->addScriptDeclaration( "// <![CDATA[\n{$js}\n// ]]>");
}
示例6: displayDefault
function displayDefault($tpl = null) {
$this->config = KunenaFactory::getConfig();
if (!$this->config->enablerss) {
JError::raiseError ( 404, JText::_ ( 'COM_KUNENA_RSS_DISABLED' ) );
}
$this->assignRef ( 'category', $this->get ( 'Category' ) );
if (! $this->category->authorise('read')) {
JError::raiseError ( 404, $this->category->getError() );
}
$this->template = KunenaTemplate::getInstance();
$this->assignRef ( 'topics', $this->get ( 'Topics' ) );
$title = JText::_('COM_KUNENA_THREADS_IN_FORUM').': '. $this->category->name;
$this->setTitle ( $title );
$metaDesc = $this->document->get ( 'description' ) . '. ' . $this->escape ( "{$this->category->name} - {$this->config->board_title}" );
$this->document->setDescription ( $metaDesc );
// Create image for feed
$image = new JFeedImage();
$image->title = $this->document->getTitle();
$image->url = $this->template->getImagePath('icons/rss.png');
$image->description = $this->document->getDescription();
$this->document->image = $image;
foreach ( $this->topics as $topic ) {
$id = $topic->last_post_id;
$page = ceil ( $topic->posts / $this->config->messages_per_page );
$description = $topic->last_post_message;
$date = new JDate($topic->last_post_time);
$userid = $topic->last_post_userid;
$username = KunenaFactory::getUser($userid)->getName($topic->last_post_guest_name);
$title = $topic->subject;
$url = CKunenaLink::GetThreadPageURL('view', $topic->category_id, $topic->id, $page, $this->config->messages_per_page, $id, true );
$category = $topic->getCategory()->name;
$this->createItem($title, $url, $description, $category, $date, $userid, $username);
}
}
示例7: getUserRank
/**
* @param UserTable $user
* @param bool $showTitle
* @param bool $showImage
* @return string|null
*/
public static function getUserRank($user, $showTitle = true, $showImage = true)
{
global $_CB_framework;
if (!class_exists('KunenaUser')) {
return null;
}
$value = null;
if ($user->get('id')) {
$forumUser = KunenaUser::getInstance((int) $user->get('id'));
if ($forumUser) {
$userRank = $forumUser->getRank();
if (!$userRank) {
return null;
}
$title = $userRank->rank_title;
if ($showTitle) {
$value .= '<div>' . $title . '</div>';
}
if ($showImage && class_exists('KunenaTemplate')) {
$template = KunenaTemplate::getInstance();
$value .= '<div><img src="' . $_CB_framework->getCfg('live_site') . '/' . $template->getRankPath($userRank->rank_image) . '" alt="' . htmlspecialchars($title) . '" border="0" /></div>';
}
if (!$value) {
$value = $forumUser->rank;
}
}
}
return $value;
}
示例8: defined
<?php
/**
* Kunena Component
* @package Kunena.Template.Blue_Eagle
* @subpackage Statistics
*
* @copyright (C) 2008 - 2013 Kunena Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.kunena.org
**/
defined('_JEXEC') or die;
$template = KunenaTemplate::getInstance();
?>
<!-- BEGIN: GENERAL STATS -->
<?php
if ($this->config->showgenstats) {
?>
<div class="kblock kgenstats">
<div class="kheader clearfix">
<span class="ktoggler"><a class="ktoggler close" title="<?php
echo JText::_('COM_KUNENA_TOGGLER_COLLAPSE');
?>
" rel="kgenstats_tbody"></a></span>
<h2><span><?php
echo $this->escape($this->config->board_title);
?>
<?php
echo JText::_('COM_KUNENA_STAT_FORUMSTATS');
?>
</span></h2>
示例9: initialize
/**
* @param string $identifier
*/
public function initialize($identifier = 'class')
{
$js = "window.addEvent('domready', function() {\n\tkbbcode = new kbbcode('kbbcode-message', 'kbbcode-toolbar', {\n\t\tdispatchChangeEvent: true,\n\t\tchangeEventDelay: 1000,\n\t\tinterceptTab: true\n});\n";
$xml_file = simplexml_load_file(dirname(__FILE__) . '/editor.xml');
$this->editor_elements = self::parseXML($xml_file);
//Hook to manipulate the Editor XML like adding buttons
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('kunena');
$dispatcher->trigger('onKunenaBbcodeEditorInit', array($this));
foreach ($this->editor_elements as $item) {
$js .= $item->generateJs($identifier);
}
$js .= "});\n";
$template = KunenaTemplate::getInstance();
$template->addScript('js/editor.js');
JFactory::getDocument()->addScriptDeclaration("// <![CDATA[\n{$js}\n// ]]>");
}
示例10: getRank
/**
* @param int $catid
* @param bool $type
*
* @return stdClass|string
*/
public function getRank($catid = 0, $type = false)
{
// Default rank
$rank = new stdClass();
$rank->rank_id = false;
$rank->rank_title = null;
$rank->rank_min = 0;
$rank->rank_special = 0;
$rank->rank_image = null;
$config = KunenaFactory::getConfig();
$category = KunenaForumCategoryHelper::get($catid);
if (!$config->showranking) {
return;
}
if (self::$_ranks === null) {
$this->_db->setQuery("SELECT * FROM #__kunena_ranks");
self::$_ranks = $this->_db->loadObjectList('rank_id');
KunenaError::checkDatabaseError();
}
$rank->rank_title = JText::_('COM_KUNENA_RANK_USER');
$rank->rank_image = 'rank0.gif';
if ($this->userid == 0) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_VISITOR');
$rank->rank_special = 1;
} else {
if ($this->isBanned()) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_BANNED');
$rank->rank_special = 1;
$rank->rank_image = 'rankbanned.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankbanned') {
$rank = $cur;
break;
}
}
} else {
if ($this->rank != 0 && isset(self::$_ranks[$this->rank])) {
$rank = self::$_ranks[$this->rank];
} else {
if ($this->rank == 0 && $this->isAdmin($category)) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_ADMINISTRATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankadmin.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankadmin') {
$rank = $cur;
break;
}
}
} else {
if ($this->rank == 0 && $this->isModerator($category)) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_MODERATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankmod.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankmod') {
$rank = $cur;
break;
}
}
}
}
}
}
}
if ($rank->rank_id === false) {
//post count rank
$rank->rank_id = 0;
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 0 && $cur->rank_min <= $this->posts && $cur->rank_min >= $rank->rank_min) {
$rank = $cur;
}
}
}
if ($type == 'title') {
return $rank->rank_title;
}
if ($type == 'image') {
$template = KunenaTemplate::getInstance();
if (!$config->rankimages) {
return;
}
$iconurl = $template->getRankPath($rank->rank_image, true);
return '<img src="' . $iconurl . '" alt="" />';
}
if (!$config->rankimages) {
$rank->rank_image = null;
}
return $rank;
}
示例11: getTemplate
/**
* Get a Kunena template object
*
* Returns the global {@link KunenaTemplate} object, only creating it if it doesn't already exist.
*
* @param string $name
* @return KunenaTemplate
*/
public static function getTemplate($name = null) {
return KunenaTemplate::getInstance($name);
}
示例12: getRank
/**
* @param int $catid Category Id for the rank (user can have different rank in different categories).
* @param string $type Possible values: 'title' | 'image' | false (for object).
* @param bool|null $special True if special only, false if post count, otherwise combined.
*
* @return stdClass|string|null
*/
public function getRank($catid = 0, $type = null, $special = null)
{
$config = KunenaConfig::getInstance();
if (!$config->showranking) {
return null;
}
// Guests do not have post rank, they only have special rank.
if ($special === false && !$this->userid) {
return null;
}
// First run? Initialize ranks.
if (self::$_ranks === null) {
$this->_db->setQuery("SELECT * FROM #__kunena_ranks");
self::$_ranks = $this->_db->loadObjectList('rank_id');
KunenaError::checkDatabaseError();
}
$userType = $special !== false ? $this->getType($catid, true) : 'count';
if (isset(self::$_ranks[$this->rank]) && !in_array($userType, array('guest', 'blocked', 'banned', 'count'))) {
// Use rank specified to the user.
$rank = self::$_ranks[$this->rank];
} else {
// Generate user rank.
$rank = new stdClass();
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_USER');
$rank->rank_min = 0;
$rank->rank_special = 0;
$rank->rank_image = 'rank0.gif';
switch ($userType) {
case 'guest':
$rank->rank_title = JText::_('COM_KUNENA_RANK_VISITOR');
$rank->rank_special = 1;
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'guest')) {
$rank = $cur;
break;
}
}
break;
case 'blocked':
$rank->rank_title = JText::_('COM_KUNENA_RANK_BLOCKED');
$rank->rank_special = 1;
$rank->rank_image = 'rankdisabled.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'disabled')) {
$rank = $cur;
break;
}
}
break;
case 'banned':
$rank->rank_title = JText::_('COM_KUNENA_RANK_BANNED');
$rank->rank_special = 1;
$rank->rank_image = 'rankbanned.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'banned')) {
$rank = $cur;
break;
}
}
break;
case 'admin':
case 'localadmin':
$rank->rank_title = JText::_('COM_KUNENA_RANK_ADMINISTRATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankadmin.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'admin')) {
$rank = $cur;
break;
}
}
break;
case 'globalmod':
case 'moderator':
$rank->rank_title = JText::_('COM_KUNENA_RANK_MODERATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankmod.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && (strstr($cur->rank_image, 'rankmod') || strstr($cur->rank_image, 'moderator'))) {
$rank = $cur;
break;
}
}
break;
case 'user':
case 'count':
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 0 && $cur->rank_min <= $this->posts && $cur->rank_min >= $rank->rank_min) {
$rank = $cur;
}
}
break;
//.........这里部分代码省略.........
示例13: getTemplate
/**
* Get a Kunena template object
*
* Returns the global {@link KunenaTemplate} object, only creating it if it doesn't already exist.
*
* @return object KunenaTemplate
*/
public static function getTemplate($name = null)
{
kimport('kunena.template');
return KunenaTemplate::getInstance($name);
}
示例14: displayPosts
function displayPosts($tpl = null) {
$this->config = KunenaFactory::getConfig();
if (!$this->config->enablerss) {
JError::raiseError ( 404, JText::_ ( 'COM_KUNENA_RSS_DISABLED' ) );
}
$this->layout = 'posts';
$this->assignRef ( 'messages', $this->get ( 'Messages' ) );
$this->assignRef ( 'topics', $this->get ( 'Topics' ) );
$this->assignRef ( 'total', $this->get ( 'Total' ) );
$this->me = KunenaUserHelper::getMyself();
$this->template = KunenaTemplate::getInstance();
// TODO: if start != 0, add information from it into description
$title = JText::_('COM_KUNENA_ALL_DISCUSSIONS');
$this->document->setGenerator('Kunena Forum (Joomla)');
switch ($this->state->get ( 'list.mode' )) {
case 'unapproved':
$title = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_UNAPPROVED');
break;
case 'deleted':
$title = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_DELETED');
break;
case 'mythanks':
$title = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_MYTHANKS');
break;
case 'thankyou':
$title = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_THANKYOU');
break;
case 'recent':
default:
$title = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_DEFAULT');
}
$this->setTitle ( $title );
// Create image for feed
$image = new JFeedImage();
$image->title = $this->document->getTitle();
$image->url = $this->template->getImagePath('icons/rss.png');
$image->description = $this->document->getDescription();
$this->document->image = $image;
$this->displayPostRows();
}
示例15: behavior
static function behavior() {
static $loaded = false;
if (!$loaded)
{
JHTML::_('behavior.tooltip');
KunenaTemplate::getInstance()->addScript ( 'js/grid.js' );
// Build the behavior script.
$js = '
window.addEvent(\'domready\', function(){
actions = $$(\'a.move_up\');
actions.combine($$(\'a.move_down\'));
actions.combine($$(\'a.grid_true\'));
actions.combine($$(\'a.grid_false\'));
actions.combine($$(\'a.grid_trash\'));
actions.combine($$(\'a.grid_action\'));
actions.each(function(a){
a.addEvent(\'click\', function(){
args = JSON.decode(this.rel);
listItemTask(args.id, args.task);
});
});
$$(\'input.check-all-toggle\').each(function(el){
el.addEvent(\'click\', function(){
if (el.checked) {
document.id(this.form).getElements(\'input[type=checkbox]\').each(function(i){
i.checked = true;
})
}
else {
document.id(this.form).getElements(\'input[type=checkbox]\').each(function(i){
i.checked = false;
})
}
});
});
});';
// Add the behavior to the document head.
$document = JFactory::getDocument();
$document->addScriptDeclaration($js);
$loaded = true;
}
}