Ejemplo n.º 1
0
	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();
	}
Ejemplo n.º 2
0
 /**
  * @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;
 }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
    /**
     * Template initialization.
     *
     * @return void
     */
    public function initialize()
    {
        // Template requires Bootstrap javascript
        // Template also requires jQuery framework.
        // Load JavaScript.
        // Compile CSS from LESS files.
        if (jimport('jproofless.jproofless')) {
            $jproofLess = JProofLess::getInstance();
            $cssFile = KPATH_MEDIA . "/cache/{$this->name}/css/" . $this->name . '.css';
            $lessFile = KPATH_COMPONENT_RELATIVE . "/template/{$this->name}/less/{$this->name}.less";
            $extraStyle = JPATH_SITE . '/components/com_kunena/template/crypsis/css/custom.css';
            $jproofLess->setCssFile($cssFile)->setLessFile($lessFile)->setVariables($this->style_variables)->useStrategy('missingcss')->setExtraContent($extraStyle);
            $class = $this;
            $jproofLess->getLess()->registerFunction('url', function ($arg) use($class) {
                list($type, $q, $values) = $arg;
                $value = reset($values);
                return "url({$q}{$class->getFile($value, true, 'media', 'media/kunena')}{$q})";
            });
            // Load template colors settings
            $this->ktemplate = KunenaFactory::getTemplate();
            $styles = <<<EOF
\t\t/* Kunena Custom CSS */
EOF;
            $iconcolor = $this->ktemplate->params->get('IconColor');
            if ($iconcolor) {
                $styles .= <<<EOF
\t\t.layout#kunena [class*="category"] i,
\t\t.layout#kunena #kwho i.icon-users,
\t\t.layout#kunena#kstats i.icon-bars { color: {$iconcolor}; }
EOF;
            }
            $iconcolornew = $this->ktemplate->params->get('IconColorNew');
            if ($iconcolornew) {
                $styles .= <<<EOF
\t\t.layout#kunena [class*="category"] .icon-knewchar { color: {$iconcolornew} !important; }
\t\t.layout#kunena sup.knewchar { color: {$iconcolornew} !important; }
\t\t.layout#kunena .topic-item-unread { border-left-color: {$iconcolornew} !important; }
EOF;
            }
            $jproofLess->setExtraContent($styles);
            $jproofLess->autoCompile();
        } else {
            // adding an Log message if it is an good choice to install the JProofLess
            JLog::add('JProofLess is missing: ' . __FILE__ . ' @see <a target="_blank" href="http://wiki.jproof.de/projects/joomla-library-jproof-less/wiki"><b>Wiki</b></a>', JLog::NOTICE);
            // Adding each time the regular already rendered css into the template if the LessCompiler not found
            //JFactory::getDocument()->addStyleSheet($this->baseurl . '/templates/' . $this->template . '/css/template.css');
        }
        parent::initialize();
    }
Ejemplo n.º 5
0
 /**
  * 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);
 }
Ejemplo n.º 6
0
	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// ]]>");
	}
Ejemplo n.º 7
0
 protected function before()
 {
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
     if (!$this->exists()) {
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
         throw new RuntimeException("Layout '{$this->input->getWord('view')}/{$this->input->getWord('layout', 'default')}' does not exist!", 404);
     }
     // Load language files.
     KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
     KunenaFactory::loadLanguage('com_kunena.templates');
     KunenaFactory::loadLanguage('com_kunena.models');
     KunenaFactory::loadLanguage('com_kunena.views');
     $this->me = KunenaUserHelper::getMyself();
     $this->config = KunenaConfig::getInstance();
     $this->document = JFactory::getDocument();
     $this->template = KunenaFactory::getTemplate();
     $this->template->initialize();
     if ($this->me->isAdmin()) {
         // Display warnings to the administrator if forum is either offline or debug has been turned on.
         if ($this->config->board_offline) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_FORUM_IS_OFFLINE'), 'notice');
         }
         if ($this->config->debug) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_WARNING_DEBUG'), 'notice');
         }
     }
     if ($this->me->isBanned()) {
         // Display warnings to the banned users.
         $banned = KunenaUserBan::getInstanceByUserid($this->me->userid, true);
         if (!$banned->isLifetime()) {
             $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS_EXPIRY', KunenaDate::getInstance($banned->expiration)->toKunena('date_today')), 'notice');
         } else {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS'), 'notice');
         }
     }
     // Remove base and add canonical link.
     $this->document->setBase('');
     $this->document->addHeadLink(KunenaRoute::_(), 'canonical', 'rel', '');
     // Initialize breadcrumb.
     $this->breadcrumb = $this->app->getPathway();
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
 }
Ejemplo n.º 8
0
	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);
		}
	}
Ejemplo n.º 9
0
    public function initialize()
    {
        // Template requires Mootools 1.4+ framework
        $this->loadMootools();
        JHtml::_('behavior.tooltip');
        // New Kunena JS for default template
        $this->addScript('js/plugins.js');
        $this->compileLess('main.less', 'kunena.css');
        $this->addStyleSheet('css/kunena.css');
        if (KunenaFactory::getConfig()->lightbox == 1) {
            // Load mediaxboxadvanced library if enabled in configuration
            // TODO: replace with bootstrap compatible version
            $this->addScript('js/mediaboxAdv.js');
            //$this->addStyleSheet ( 'css/mediaboxAdv.css');
        }
        // Toggler language strings
        JFactory::getDocument()->addScriptDeclaration('// <![CDATA[
var kunena_toggler_close = "' . JText::_('COM_KUNENA_TOGGLER_COLLAPSE') . '";
var kunena_toggler_open = "' . JText::_('COM_KUNENA_TOGGLER_EXPAND') . '";
// ]]>');
        parent::initialize();
    }
Ejemplo n.º 10
0
 /**
  * @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;
         }
     }
     if ($special === true && !$rank->rank_special) {
         return null;
     }
     if ($type == 'title') {
         return $rank->rank_title;
     }
     if (!$config->rankimages) {
         $rank->rank_image = null;
     }
     if ($type == 'image') {
         if (!$rank->rank_image) {
             return null;
         }
         $url = KunenaTemplate::getInstance()->getRankPath($rank->rank_image, true);
         return '<img src="' . $url . '" alt="" />';
     }
     return $rank;
 }
Ejemplo n.º 11
0
	/**
	 * 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);
	}
Ejemplo n.º 12
0
    /**
     * Template initialization.
     *
     * @return void
     */
    public function initialize()
    {
        // Template requires Bootstrap javascript
        JHtml::_('bootstrap.framework');
        JHtml::_('bootstrap.tooltip', '[data-toggle="tooltip"]');
        // Template also requires jQuery framework.
        JHtml::_('jquery.framework');
        JHtml::_('bootstrap.modal');
        // Load JavaScript.
        $this->addScript('main.js');
        // Compile CSS from LESS files.
        $this->compileLess('crypsis.less', 'kunena.css');
        $this->addStyleSheet('kunena.css');
        $filename = JPATH_SITE . '/components/com_kunena/template/crypsis/css/custom.css';
        if (file_exists($filename)) {
            $this->addStyleSheet('custom.css');
        }
        // Load template colors settings
        $this->ktemplate = KunenaFactory::getTemplate();
        $styles = <<<EOF
\t\t/* Kunena Custom CSS */
EOF;
        $iconcolor = $this->ktemplate->params->get('IconColor');
        if ($iconcolor) {
            $styles .= <<<EOF
\t\t.layout#kunena [class*="category"] i,
\t\t.layout#kunena #kwho i.icon-users,
\t\t.layout#kunena#kstats i.icon-bars { color: {$iconcolor}; }
EOF;
        }
        $iconcolornew = $this->ktemplate->params->get('IconColorNew');
        if ($iconcolornew) {
            $styles .= <<<EOF
\t\t.layout#kunena [class*="category"] .icon-knewchar { color: {$iconcolornew} !important; }
\t\t.layout#kunena sup.knewchar { color: {$iconcolornew} !important; }
\t\t.layout#kunena .topic-item-unread { border-left-color: {$iconcolornew} !important; }
EOF;
        }
        $document = JFactory::getDocument();
        $document->addStyleDeclaration($styles);
        parent::initialize();
    }
Ejemplo n.º 13
0
 /**
  * @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;
 }
Ejemplo n.º 14
0
	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();
	}
Ejemplo n.º 15
0
    /**
     * Template initialization.
     *
     * @return void
     */
    public function initialize()
    {
        JHtml::_('bootstrap.framework');
        JHtml::_('bootstrap.tooltip', '[data-toggle="tooltip"]');
        JHtml::_('jquery.framework');
        JHtml::_('bootstrap.modal');
        $this->addScript('main.js');
        // Compile CSS from LESS files.
        $this->compileLess('crypsisb3.less', 'kunena.css');
        $this->addStyleSheet('kunena.css');
        $filename = JPATH_SITE . '/components/com_kunena/template/crypsisb3/css/custom.css';
        if (file_exists($filename)) {
            $this->addStyleSheet('custom.css');
        }
        $this->ktemplate = KunenaFactory::getTemplate();
        $fontawesome = $this->ktemplate->params->get('fontawesome');
        if ($fontawesome) {
            ?>
			<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
		<?php 
        }
        // Load template colors settings
        $styles = <<<EOF
\t\t/* Kunena Custom CSS */
EOF;
        $iconcolor = $this->ktemplate->params->get('IconColor');
        if ($iconcolor) {
            $styles .= <<<EOF
\t\t.layout#kunena [class*="category"] i,
\t\t.layout#kunena .glyphicon-topic,
\t\t.layout#kunena #kwho i.icon-users,
\t\t.layout#kunena#kstats i.icon-bars { color: {$iconcolor}; }
EOF;
        }
        $iconcolornew = $this->ktemplate->params->get('IconColorNew');
        if ($iconcolornew) {
            $styles .= <<<EOF
\t\t.layout#kunena [class*="category"] .icon-knewchar { color: {$iconcolornew} !important; }
\t\t.layout#kunena sup.knewchar { color: {$iconcolornew} !important; }
\t\t.layout#kunena .topic-item-unread { border-left-color: {$iconcolornew} !important;}
\t\t.layout#kunena .topic-item-unread .glyphicon { color: {$iconcolornew} !important;}
\t\t.layout#kunena .topic-item-unread i.fa { color: {$iconcolornew} !important;}
EOF;
        }
        $document = JFactory::getDocument();
        $document->addStyleDeclaration($styles);
        parent::initialize();
    }
Ejemplo n.º 16
0
 /**
  * @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// ]]>");
 }
Ejemplo n.º 17
0
	/**
	 * 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);
	}
Ejemplo n.º 18
0
	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;
		}
	}
Ejemplo n.º 19
0
 /**
  * @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;
 }
Ejemplo n.º 20
0
 function report()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->setRedirectBack();
         return;
     }
     if (!$this->me->exists() || $this->config->reportmsg == 0) {
         // Deny access if report feature has been disabled or user is guest
         $this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ACCESS'), 'notice');
         $this->setRedirectBack();
         return;
     }
     if (!$this->config->get('send_emails')) {
         // Emails have been disabled
         $this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_DISABLED'), 'notice');
         $this->setRedirectBack();
         return;
     }
     if (!$this->config->getEmail() || !JMailHelper::isEmailAddress($this->config->getEmail())) {
         // Error: email address is invalid
         $this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_INVALID'), 'error');
         $this->setRedirectBack();
         return;
     }
     // Get target object for the report
     if ($this->mesid) {
         $message = $target = KunenaForumMessageHelper::get($this->mesid);
         $topic = $target->getTopic();
     } else {
         $topic = $target = KunenaForumTopicHelper::get($this->id);
         $message = KunenaForumMessageHelper::get($topic->first_post_id);
     }
     $messagetext = $message->message;
     $baduser = KunenaFactory::getUser($message->userid);
     if (!$target->authorise('read')) {
         // Deny access if user cannot read target
         $this->app->enqueueMessage($target->getError(), 'notice');
         $this->setRedirectBack();
         return;
     }
     $reason = JRequest::getString('reason');
     $text = JRequest::getString('text');
     $template = KunenaTemplate::getInstance();
     if (method_exists($template, 'reportMessage')) {
         $template->reportMessage($message, $reason, $text);
     }
     // Load language file from the template.
     KunenaFactory::getTemplate()->loadLanguage();
     if (empty($reason) && empty($text)) {
         // Do nothing: empty subject or reason is empty
         $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_FORG0T_SUB_MES'));
         $this->setRedirectBack();
         return;
     } else {
         $acl = KunenaAccess::getInstance();
         $emailToList = $acl->getSubscribers($topic->category_id, $topic->id, false, true, false);
         if (!empty($emailToList)) {
             $mailsender = JMailHelper::cleanAddress($this->config->board_title . ' ' . JText::_('COM_KUNENA_FORUM') . ': ' . $this->me->getName());
             $mailsubject = "[" . $this->config->board_title . " " . JText::_('COM_KUNENA_FORUM') . "] " . JText::_('COM_KUNENA_REPORT_MSG') . ": ";
             if ($reason) {
                 $mailsubject .= $reason;
             } else {
                 $mailsubject .= $topic->subject;
             }
             jimport('joomla.environment.uri');
             $msglink = JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $target->getPermaUrl(null, false);
             $mail = JFactory::getMailer();
             $mail->setSender(array($this->me->username, $this->me->email));
             $mail->setSubject($mailsubject);
             // Render the email.
             $layout = KunenaLayout::factory('Email/Report')->debug(false)->set('mail', $mail)->set('message', $message)->set('me', $this->me)->set('title', $reason)->set('content', $text)->set('messageLink', $msglink);
             try {
                 $body = trim($layout->render());
                 $mail->setBody($body);
             } catch (Exception $e) {
                 // TODO: Deprecated in K4.0, remove in K5.0
                 $mailmessage = "" . JText::_('COM_KUNENA_REPORT_RSENDER') . " {$this->me->username} ({$this->me->name})";
                 $mailmessage .= "\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RREASON') . " " . $reason;
                 $mailmessage .= "\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RMESSAGE') . " " . $text;
                 $mailmessage .= "\n\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_POSTER') . " {$baduser->username} ({$baduser->name})";
                 $mailmessage .= "\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_SUBJECT') . ": " . $topic->subject;
                 $mailmessage .= "\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_MESSAGE') . "\n-----\n" . KunenaHtmlParser::stripBBCode($messagetext, 0, false);
                 $mailmessage .= "\n-----\n\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_LINK') . " " . $msglink;
                 $mailmessage = JMailHelper::cleanBody(strtr($mailmessage, array('&#32;' => '')));
                 $mail->setBody($mailmessage);
             }
             $receivers = array();
             foreach ($emailToList as $emailTo) {
                 if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) {
                     continue;
                 }
                 $receivers[] = $emailTo->email;
             }
             KunenaEmail::send($mail, $receivers);
             $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_SUCCESS'));
         } else {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_NOT_SEND'));
         }
     }
     $this->setRedirect($target->getUrl($this->return, false));
 }
Ejemplo n.º 21
0
<?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>
 /**
  * Generate users details
  *
  * @param moscomprofilerUser $user
  * @param object             $forum
  * @return object
  */
 function getUserDetails($user, $forum)
 {
     global $_CB_database, $_CB_framework;
     static $usersdetailsCache = array();
     if (!isset($usersdetailsCache[$user->id])) {
         if ((isset($forum->config['showuserstats']) ? $forum->config['showuserstats'] : $forum->config['showstats']) || !$forum->config['showranking'] && !$forum->config['showkarma'] && !(isset($forum->config['poststats']) ? $forum->config['poststats'] : (isset($forum->config['postStats']) ? $forum->config['postStats'] : (isset($forum->config['userlist_posts']) ? $forum->config['userlist_posts'] : $forum->config['showstats'])))) {
             if ($forum->component == 'com_fireboard' && $forum->version >= '1.0.3' || $forum->component == 'com_kunena') {
                 $supportsDbRanks = ', ' . $_CB_database->NameQuote('rank');
             } else {
                 $supportsDbRanks = null;
             }
             $userDetails = $this->getUserSettings($user, $forum, $supportsDbRanks);
             if (isset($userDetails->posts) && $userDetails->posts != 0) {
                 if (class_exists('KunenaTemplate') && class_exists('KunenaForum')) {
                     $kunenaTemplate = KunenaTemplate::getInstance();
                 } else {
                     $kunenaTemplate = null;
                 }
                 if ($forum->config['showranking']) {
                     $uIsAdm = isModerator($user->id);
                     $uIsMod = $userDetails->moderator;
                     $pathImage = $_CB_framework->getCfg('live_site') . '/components/' . $forum->component;
                     if ($forum->prefix != 'kunena' || $forum->prefix == 'kunena' && !class_exists('KunenaForum')) {
                         if ($supportsDbRanks) {
                             if ($userDetails->rank != 0) {
                                 $where = $_CB_database->NameQuote('rank_id') . ' = ' . (int) $userDetails->rank;
                             } else {
                                 $where = $_CB_database->NameQuote('rank_min') . ' <= ' . (int) $userDetails->posts . "\n ORDER BY " . $_CB_database->NameQuote('rank_min') . ' DESC';
                             }
                             $query = 'SELECT ' . $_CB_database->NameQuote('rank_title') . ', ' . $_CB_database->NameQuote('rank_image') . "\n FROM " . $_CB_database->NameQuote('#__' . $forum->prefix . '_ranks') . "\n WHERE " . $where;
                             $_CB_database->setQuery($query, 0, 1);
                             $userRank = null;
                             $_CB_database->loadObject($userRank);
                             $pathImage = $pathImage . $this->params->get('TemplateRank', '/template/default/images');
                             $rText = $userRank->rank_title;
                             $rImg = $pathImage . '/ranks/' . $userRank->rank_image;
                         } else {
                             $userDetails->rank = 1;
                             for ($i = 1; $i <= 5; $i++) {
                                 $rankPrev = $forum->config['rank' . ($i > 1 ? $i - 1 : $i)];
                                 $rank = $forum->config['rank' . $i];
                                 if ($userDetails->posts <= $rank && $userDetails->posts > $rankPrev) {
                                     $userDetails->rank = $i;
                                 } elseif ($i == 5 && $userDetails->posts > $rank) {
                                     $userDetails->rank = 6;
                                 }
                             }
                             $rText = $forum->config['rank' . $userDetails->rank . 'txt'];
                             $rImg = $pathImage . '/ranks/rank' . $userDetails->rank . '.gif';
                         }
                     } elseif ($userDetails instanceof KunenaUser) {
                         $pathImage = $pathImage . $this->params->get('TemplateRank', '/template/default/images');
                         $userRank = $userDetails->getRank();
                         $rText = $userRank->rank_title;
                         if ($kunenaTemplate) {
                             $rImg = $_CB_framework->getCfg('live_site') . '/' . $kunenaTemplate->getRankPath($userRank->rank_image);
                         } else {
                             $rImg = null;
                         }
                     } else {
                         $rText = null;
                         $rImg = null;
                     }
                     if ($userDetails->rank == 0 && $uIsMod) {
                         $rText = CBTxt::T('Moderator');
                         if ($kunenaTemplate) {
                             $rImg = $_CB_framework->getCfg('live_site') . '/' . $kunenaTemplate->getRankPath('rankmod.gif');
                         } else {
                             $rImg = $pathImage . '/ranks/rankmod.gif';
                         }
                     }
                     if ($userDetails->rank == 0 && $uIsAdm) {
                         $rText = CBTxt::T('Administrator');
                         if ($kunenaTemplate) {
                             $rImg = $_CB_framework->getCfg('live_site') . '/' . $kunenaTemplate->getRankPath('rankadmin.gif');
                         } else {
                             $rImg = $pathImage . '/ranks/rankadmin.gif';
                         }
                     }
                     if ($forum->config['rankimages'] && $rImg) {
                         $userDetails->msg_userrankimg = '<img src="' . htmlspecialchars($rImg) . '" alt="' . htmlspecialchars($rText) . '" border="0" />';
                     }
                     $userDetails->msg_userrank = $rText;
                 }
             } else {
                 $userDetails = false;
             }
         } else {
             $userDetails = false;
         }
         $usersdetailsCache[$user->id] = $userDetails;
     }
     return $usersdetailsCache[$user->id];
 }