Exemple #1
0
 protected static function _findItem($needles = null)
 {
     $app = JFactory::getApplication('site');
     $menus = $app->getMenu('site');
     // Prepare the reverse lookup array.
     if (self::$lookup === null) {
         self::$lookup = array();
         $component = JComponentHelper::getComponent('com_smfaq');
         $items = $menus->getItems('component_id', $component->id);
         foreach ($items as $item) {
             if (isset($item->query) && isset($item->query['view'])) {
                 $view = $item->query['view'];
                 if (!isset(self::$lookup[$view])) {
                     self::$lookup[$view] = array();
                 }
                 if (isset($item->query['id'])) {
                     self::$lookup[$view][$item->query['id']] = $item->id;
                 }
             }
         }
     }
     if ($needles) {
         foreach ($needles as $view => $ids) {
             if (isset(self::$lookup[$view])) {
                 foreach ($ids as $id) {
                     if (isset(self::$lookup[$view][(int) $id])) {
                         return self::$lookup[$view][(int) $id];
                     }
                 }
             }
         }
     } else {
         $active = $menus->getActive();
         if ($active) {
             return $active->id;
         }
     }
     return null;
 }
Exemple #2
0
    echo JText::_('COM_SMFAQ_YES');
    ?>
            <input type="radio" name="vote_question" onclick="SmFaq.Vote(this.form, value, true)" value="0" /> <?php 
    echo JText::_('COM_SMFAQ_NO');
    ?>
            <input type="hidden" name="id" value="<?php 
    echo $this->item->id;
    ?>
" />
            <input type="hidden" name="token" value="<?php 
    echo JSession::getFormToken();
    ?>
" />
     </form>
<?php 
}
?>
 
</div>
<div class="back-link">
	<a href="<?php 
echo JRoute::_(SmfaqHelperRoute::getCategoryRoute($this->item->catid));
?>
"><?php 
echo JText::_('COM_SMFAQ_RETURN_TO_CATEGORY');
?>
</a>
</div>
</div>

Exemple #3
0
	<div class="smfaq-print"><?php 
    echo JHtml::_('link', $print_link, JText::_('COM_SMFAQ_PRINT_VIEW'), array('rel' => 'nofollow', 'target' => '_blank'));
    ?>
</div>
	<div style="clear: both"></div>
<?php 
}
?>

<?php 
// Вывод вопросов
foreach ($this->items as $item) {
    ?>
			<?php 
    if (isset($as_link)) {
        $link = JRoute::_(SmfaqHelperRoute::getQuestionRoute($this->category->id, $item->id));
        ?>
				<div class="question-link">
				<a href="<?php 
        echo $link;
        ?>
"><?php 
        echo $this->escape($item->question);
        ?>
</a>
				</div>
			<?php 
        continue;
        ?>
			<?php 
    }
Exemple #4
0
 public function cancel($key = null)
 {
     if (parent::cancel($key)) {
         $catid = JRequest::getInt('catid');
         $this->setRedirect(JRoute::_(SmfaqHelperRoute::getCategoryRoute($catid), false));
     }
 }
Exemple #5
0
 /**
  * метод для отправки уведомления
  */
 protected function sendUser(&$data)
 {
     $config = JFactory::getConfig();
     $mailfrom = $config->get('mailfrom');
     $fromname = $config->get('fromname');
     jimport('joomla.application.categories');
     $categories = JCategories::getInstance('SmFaq');
     $category = $categories->get((int) $data['catid']);
     require_once JPATH_SITE . DS . 'components' . DS . 'com_smfaq' . DS . 'helpers' . DS . 'route.php';
     $link = JURI::root() . SmfaqHelperRoute::getCategoryRoute($category->id) . '&limit=0#p' . $data['id'];
     $subject = JText::sprintf('COM_SMFAQ_MAIL_SUBJECT_ANSWER', $category->title);
     $date = JHtml::date($data['created'], 'd.m.Y');
     $message = JText::sprintf('COM_SMFAQ_MAIL_MESSAGE_ANSWER', $date, $data['question'], $link);
     $mail = JFactory::getMailer();
     $send = $mail->sendMail($mailfrom, $fromname, $data['created_by_email'], $subject, $message);
     return;
 }
Exemple #6
0
 /**
  * Подготовка документа
  */
 protected function _prepareDocument()
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu();
     $pathway = $app->getPathway();
     $title = null;
     // Подключение js и стилей
     $catid = $this->category->id;
     $jscript = 'SmFaq.url = \'index.php?option=com_smfaq&amp;catid=' . $catid . '&amp;format=raw&amp;task=\';';
     $this->document->addScriptDeclaration($jscript);
     $baseurl = $this->document->baseurl;
     $this->document->addStyleSheet($baseurl . "components/com_smfaq/css/smfaq.css");
     $this->document->addScript($baseurl . "components/com_smfaq/js/smfaq.js");
     $menu = $menus->getActive();
     if (!$menu) {
         $menus->setActive(JRequest::getInt('Itemid', null));
     }
     if ($menu) {
         $id = (int) $menu->query['id'];
     }
     if ($menu && ($menu->query['option'] != 'com_smfaq' || $id != $this->category->id)) {
         $path = array(array('title' => $this->category->title, 'link' => ''));
         $category = $this->category->getParent();
         while (($menu->query['option'] != 'com_smfaq' || $id != $category->id) && $category->id > 1) {
             $path[] = array('title' => $category->title, 'link' => SmfaqHelperRoute::getCategoryRoute($category->id));
             $category = $category->getParent();
         }
         $path = array_reverse($path);
         foreach ($path as $item) {
             $pathway->addItem($item['title'], $item['link']);
         }
     }
     $title = $this->params->def('page_title', $title = $this->category->title);
     if (empty($title)) {
         $title = $app->getCfg('sitename');
     } elseif ($app->getCfg('sitename_pagetitles', 0)) {
         $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
     }
     $this->document->setTitle($title);
     if ($this->category->metadesc) {
         $this->document->setDescription($this->category->metadesc);
     }
     if ($this->category->metakey) {
         $this->document->setMetadata('keywords', $this->category->metakey);
     }
     if ($app->getCfg('MetaTitle') == '1') {
         $this->document->setMetaData('title', $title);
     }
     if ($app->getCfg('MetaAuthor') == '1') {
         $this->document->setMetaData('author', $this->category->getMetadata()->get('author'));
     }
     $mdata = $this->category->getMetadata()->toArray();
     foreach ($mdata as $k => $v) {
         if ($v) {
             $this->document->setMetadata($k, $v);
         }
     }
     // Add alternative feed link
     if ($this->params->get('show_feed_link', 1) == 1) {
         $link = '&format=feed&limitstart=';
         $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
         $this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
         $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
         $this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
     }
 }
Exemple #7
0
 /**
  * Smfaq Search method
  *
  * The sql must return the following fields that are used in a common display
  * routine: href, title, section, created, text, browsernav
  * @param string 	Target search string
  * @param string 	mathcing option, exact|any|all
  * @param string 	ordering option, newest|oldest|popular|alpha|category
  * @param mixed 	An array if the search it to be restricted to areas, null if search all
  */
 public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     require_once JPATH_SITE . '/components/com_smfaq/helpers/route.php';
     require_once JPATH_SITE . '/components/com_smfaq/router.php';
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $db = JFactory::getDbo();
     $limit = $this->params->get('search_limit', 50);
     $result_link = $this->params->get('result_link', 1);
     switch ($phrase) {
         case 'exact':
             $text = $db->quote('%' . $text . '%', true);
             $wheres2 = array();
             $wheres2[] = 'a.question LIKE ' . $text;
             $wheres2[] = 'a.answer LIKE ' . $text;
             $wheres2[] = 'a.metakey LIKE ' . $text;
             $wheres2[] = 'a.metadesc LIKE ' . $text;
             $where = '(' . implode(') OR (', $wheres2) . ')';
             break;
         case 'all':
         case 'any':
         default:
             $words = explode(' ', $text);
             $wheres = array();
             foreach ($words as $word) {
                 $word = $db->quote('%' . $text . '%', true);
                 $wheres2 = array();
                 $wheres2[] = 'a.question LIKE ' . $word;
                 $wheres2[] = 'a.answer LIKE ' . $word;
                 $wheres2[] = 'a.metakey LIKE ' . $word;
                 $wheres2[] = 'a.metadesc LIKE ' . $word;
                 $wheres[] = implode(' OR ', $wheres2);
             }
             $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
             break;
     }
     switch ($ordering) {
         case 'oldest':
             $order = 'a.created ASC';
             break;
         case 'alpha':
             $order = 'a.question ASC';
             break;
         case 'category':
             $order = 'c.title ASC, a.question ASC';
             break;
         case 'popular':
         case 'newest':
         default:
             $order = 'a.created DESC';
             break;
     }
     $query = $db->getQuery(true);
     $case_when = ' CASE WHEN ';
     $case_when .= $query->charLength('c.alias');
     $case_when .= ' THEN ';
     $c_id = $query->castAsChar('c.id');
     $case_when .= $query->concatenate(array($c_id, 'c.alias'), ':');
     $case_when .= ' ELSE ';
     $case_when .= $c_id . ' END as catslug';
     $query->select('a.id, a.question AS title, a.answer AS text, a.created, a.metakey, a.metadesc, c.title AS section, ' . $case_when);
     $query->where('(' . $where . ' AND a.published = 1 AND c.published = 1 )');
     $query->from('#__smfaq AS a');
     $query->join('INNER', '#__categories AS c ON c.id=a.catid AND extension=' . $db->quote('com_smfaq'));
     $query->group('a.id,  a.question, a.answer, a.metadesc, a.metakey, a.created, c.title, c.alias, c.id');
     $query->order($order);
     $db->setQuery($query, 0, $limit);
     $list = $db->loadObjectList();
     if ($list) {
         foreach ($list as $key => $item) {
             if ($result_link) {
                 $list[$key]->href = JRoute::_(SmfaqHelperRoute::getQuestionRoute($item->catslug, $item->id));
             } else {
                 $list[$key]->href = JRoute::_(SmfaqHelperRoute::getCategoryRoute($item->catslug) . '&limit=0#p' . $item->id);
             }
             $list[$key]->browsernav = true;
         }
     }
     return $list;
 }