Current Path : /var/www/html/clients/kampol.e-nk.ru/OLD/components/com_easyfaq/ |
Current File : /var/www/html/clients/kampol.e-nk.ru/OLD/components/com_easyfaq/easyfaq.php |
<?php /** * @package Easyfaq * @copyright (C) 2006 Joomla-addons.org * @author Websmurf * * -------------------------------------------------------------------------------- * All rights reserved. Easy FAQ Component for Joomla! * * This program is free software; you can redistribute it and/or * modify it under the terms of the Creative Commons - Attribution-NoDerivs 2.5 * license as published by the Creative Commons Organisation * http://creativecommons.org/licenses/by-nd/2.5/. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * -------------------------------------------------------------------------------- **/ defined( '_VALID_MOS' ) or die( 'Restricted access' ); require_once( $mainframe->getPath( 'front_html') ); require_once( $mainframe->getPath( 'class') ); if(!class_exists('xajax')){ require_once( $mainframe->getCfg('absolute_path') . '/components/com_easyfaq/xajax/xajax.inc.php' ); } /** Load menu parameters **/ $menu = new mosMenu( $database ); $menu->load( $Itemid ); $params = new mosParameters( $menu->params ); $params->def( 'display', 'anchors'); $params->def( 'show_intro', 'none'); $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) ); $params->def( 'cat_order', 'ordering' ); $params->def( 'cat_description', 1 ); $params->def( 'faq_order', 'title' ); $params->def( 'show_author', 1 ); $params->def( 'show_empty_cat', 1 ); $params->def( 'print_view', intval(mosGetParam($_REQUEST, 'pop', 0)) ); $params->def( 'print', !$mainframe->getCfg( 'hidePrint' ) ); $params->def( 'pdf', !$mainframe->getCfg( 'hidePdf' ) ); $params->def( 'icons', $mainframe->getCfg( 'icons' ) ); $params->def( 'item_navigation', $mainframe->getCfg( 'item_navigation' ) ); $params->def( 'helpful', 1 ); if(file_exists($mainframe->getCfg('absolute_path') . '/components/com_easyfaq/language/' . $mainframe->getCfg('lang') . '.php')){ require_once($mainframe->getCfg('absolute_path') . '/components/com_easyfaq/language/' . $mainframe->getCfg('lang') . '.php'); } else { require_once($mainframe->getCfg('absolute_path') . '/components/com_easyfaq/language/russian.php'); } /** get request options **/ $catid = intval(mosGetParam($_REQUEST, 'catid', $params->get('catid', 0))); $id = intval(mosGetParam($_REQUEST, 'id', 0)); $task = mosGetParam($_REQUEST, 'task'); /** initiate ajax stuff **/ if($params->get('display') == 'list_intro_ajax' || $params->get('helpful')){ $xajax = new xajax('index2.php?option=' . $option . '&task=xajax&Itemid=' . $Itemid . '&no_html=1'); $xajax->registerFunction("getFaqItem", XAJAX_POST); $xajax->registerFunction("setHelpful", XAJAX_POST); $xajax->processRequests(); } if($task != 'xajax'){ /** add javascript when ajax method is active **/ if($params->get('display') == 'list_intro_ajax' || $params->get('helpful')){ $mainframe->addCustomHeadTag($xajax->getJavascript($mainframe->getCfg('live_site') . '/components/com_easyfaq/xajax')); } switch ($task){ case 'view': easyFAQ::showFaqItem($id, $params); break; case 'new': faq::editFaq(0); break; case 'edit': faq::editFaq($id); break; case 'save': $id = faq::saveFaq(false); mosRedirect('index.php?option=' . $option . '&task=view&id=' . $id . '&Itemid=' . $Itemid, 'Èçìåíåíèÿ â ñòàòüå ñîõðàíåíû'); break; case 'cancel': mosRedirect('index.php?option=' . $option . '&task=view&id=' . $id . '&Itemid=' . $Itemid); break; case 'pdf': easyFAQ::generatePDF($id); break; case 'cat': easyFAQ::showFaqByCat($catid, $params); break; default: if($params->get('display') == 'cat_and_faq'){ easyFAQ::showCatAndFaq($params); } else { easyFAQ::showFaqByCat($catid, $params); } break; } /** * do not comment this out please, * have a look at the bottom of easyfaq.html.php * for some comments */ if (! $params->get( 'print_view' ) ) { HTML_easyfaq::showCopyright(); } } /** * Get Faq Content By XAJAX * * @param int $id * @return string XML */ function getFaqItem($id){ global $database, $option, $Itemid, $params; $row = new dbFaq($database); $row->load($id); $text = ''; $text .= HTML_easyfaq::printEdit($row, $params); $text .= HTML_easyfaq::printButton($row, $params); $text .= HTML_easyfaq::pdfButton($row, $params); if($params->get('show_author')){ if(empty($row->author_alias)){ $user = new mosUser($database); $user->load($row->created_by); $row->author = $user->name; } else { $row->author = $row->author_alias; } $text .= '<span class="small">'. _WRITTEN_BY . ' '. ($row->author_alias ? $row->author_alias : $row->author) . '</span><br />'; } $text .= $row->introtext . (!empty($row->fulltext) ? '<br /><a href="' . sefRelToAbs('index.php?option=' . $option . '&task=view&id=' . $row->id . '&Itemid=' . $Itemid) . '">' . _READ_MORE . '</a>' : ''); $text .= HTML_easyfaq::printUseful($row, $params); $objResponse = new xajaxResponse(); $objResponse->addAssign("faq" . $id,"innerHTML", $text); $objResponse->addAssign("faq" . $id,"style.display", 'block'); $objResponse->addAssign("li" . $id,"style.backgroundImage", 'url(components/com_easyfaq/icons/1downarrow.png)'); return $objResponse->getXML(); exit; } /** * Set helpful state by XAJAX * * @param int $id * @param boolean $helpful */ function setHelpful($id, $helpful){ global $database; $objResponse = new xajaxResponse(); if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } elseif (isset($_SERVER["HTTP_CLIENT_IP"])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } else { $ip = $_SERVER["REMOTE_ADDR"]; } $query = "SELECT COUNT(1) FROM #__easyfaq_helpful_log WHERE fid = $id AND ip = '$ip'"; $database->setQuery($query); $result = $database->loadResult(); if($result > 0){ //allready voted $objResponse->addAlert(EASYFAQ_ALLREADY_HULPFUL); return $objResponse->getXML(); exit; } $row = new dbFaq($database); $row->load($id); if($helpful){ $row->usefull++; } else { $row->unusefull++; } if (!$row->store()) { $objResponse->addAlert($database->getErrorMsg()); return $objResponse->getXML(); exit; } $query = "INSERT INTO #__easyfaq_helpful_log (fid, ip) VALUES ($row->id, '$ip')"; $database->setQuery($query); $database->query(); $objResponse->addAlert(EASYFAQ_VOTE_ADDED); return $objResponse->getXML(); exit; } ?>