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.html.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' ); class HTML_easyfaq{ /** * Show all faqs from a certain categorie * * @param array $rows * @param <var>mosCategorie</var> $cat * @param <var>mosParameters</var> $params */ function showFaqByCat($rows, $cat, $subcats, $params){ global $option, $mainframe, $Itemid, $my; if($cat->parent_id > 0){ HTML_easyfaq::constructPathway($cat); } if($cat->name){ $mainframe->setPageTitle($cat->name . EASYFAQ_CAT_TITLE_PREPEND); $mainframe->appendPathWay($cat->name); } else { $mainframe->setPageTitle(EASYFAQ_FAQ_CATEGORIES); } $mainframe->addCustomHeadTag('<script type="text/javascript" src="'. $mainframe->getCfg('live_site') . '/components/com_easyfaq/easyfaq.js"></script>'); $mainframe->addCustomHeadTag('<link href="'.$mainframe->getCfg('live_site') . '/components/com_easyfaq/easyfaq.css" rel="stylesheet" type="text/css"/>'); ?> <div class="componentheading"><?php echo $cat->name . EASYFAQ_CAT_TITLE_PREPEND; ?></div> <?php echo EASYFAQ_GENERAL; //show subcategories if(sizeof($subcats) > 0){ HTML_easyfaq::showSubCat($subcats, $params); } if($my->id && ($my->gid == 2)){ ?> <div style="float: right;"> <a href="<?php echo 'index.php?option=' . $option . '&task=new&Itemid=' .$Itemid; ?>"> <img src="<?php echo $mainframe->getCfg('live_site');?>/images/M_images/new.png" width="13" height="14" align="middle" border="0" alt="<?php echo _CMN_NEW;?>" /> <?php echo _CMN_NEW;?>...</a> </div> <?php } if($params->get('cat_description')){ echo $cat->description; } if(sizeof($rows) > 0){ $showanchors = false; echo '<ul class="faq">'; for($i=0,$n=count($rows);$i<$n;$i++){ $row = $rows[$i]; $row->fulltext = trim($row->fulltext); $link = ''; switch ($params->get('show_intro')){ case 'javascript': $content = '<div id="faq'. $row->id . '" style="display: none;">'; $content .= HTML_easyfaq::printEdit($row, $params); $content .= HTML_easyfaq::printButton($row, $params); $content .= HTML_easyfaq::pdfButton($row, $params); $content .= ($params->get('show_author') ? '<span class="small">'. _WRITTEN_BY . ' '. ($row->author_alias ? $row->author_alias : $row->author) . '</span><br />' : '') . $row->introtext . (!empty($row->fulltext) ? '<br /><a href="' . sefRelToAbs('index.php?option=' . $option . '&task=view&id=' . $row->id . '&Itemid=' . $Itemid) . '">' . _READ_MORE . '</a>' : ''); $content .= HTML_easyfaq::printUseful($row, $params); $content .= '</div>'; $link = 'javascript:void(0);" onclick="toggleFaq('. $row->id . ');'; break; case 'ajax': $link = 'javascript:void(0);" onclick="toggleFaqWithAjax('. $row->id . ');'; $content = '<div id="faq'. $row->id . '" style="display: none;"></div>'; break; case 'none': $content = ''; break; } echo '<li class="faq" id="li'. $row->id . '">'; switch ($params->get('display')){ case 'list': if(empty($link)){ $link = sefRelToAbs('index.php?option=' . $option . '&task=view&id=' . $row->id . '&Itemid=' . $Itemid); } echo '<a href="' . $link . '">'. $row->title . '</a>'; break; case 'anchors': default: $showanchors = true; echo '<a href="' . sefRelToAbs('index.php?option=' . $option . ($params->get('catid') == 0 ? '&task=cat&catid=' . $cat->id : '') . '&Itemid=' . $Itemid) . '#faq'. $row->id . '">'. $row->title . '</a>'; } echo $content; echo '</li>'; } echo '</ul>'; if($showanchors){ //display full items.. echo '<div class="faqs">'; for($i=0,$n=count($rows);$i<$n;$i++){ $row = $rows[$i]; echo '<br /><br /><a name="faq' . $row->id . '"></a><h3>'. $row->title . '</h3>'; echo HTML_easyfaq::printEdit($row, $params); echo HTML_easyfaq::printButton($row, $params); echo HTML_easyfaq::pdfButton($row, $params); if($params->get('show_author')){ ?> <span class="small"> <?php echo _WRITTEN_BY . ' '. ($row->author_alias ? $row->author_alias : $row->author); ?> </span><br /> <?php } echo $row->introtext . (!empty($row->fulltext) ? '<br /><a href="' . sefRelToAbs('index.php?option=' . $option . '&task=view&id=' . $row->id . '&Itemid=' . $Itemid) . '">' . _READ_MORE . '</a>' : ''); echo HTML_easyfaq::printUseful($row, $params); } echo '</div>'; } } if($params->get('catid') == 0){ echo '<br />'; mosHTML::BackButton ( $params ); } echo '<br />'; } /** * Show a FAQ item * * @param <var>dbFaq</var> $row * @param <var>mosCategorie</var> $cat * @param <var>mosParameters</var> $params */ function showFaqItem($row, $cat, $params){ global $option, $mainframe, $Itemid, $my; if($params->get('catid') == 0){ //clicked through, add categorie to pathway $mainframe->appendPathWay('<a href="' . sefRelToAbs('index.php?option=' . $option . '&task=cat&catid=' . $cat->id . '&Itemid=' . $Itemid) . '">' .$cat->name . '</a>'); } $mainframe->setPageTitle($row->title); $mainframe->appendPathWay($row->title); $mainframe->addCustomHeadTag('<link href="'.$mainframe->getCfg('live_site') . '/components/com_easyfaq/easyfaq.css" rel="stylesheet" type="text/css"/>'); ?> <div class="componentheading"><?php echo $row->title; ?></div> <?php echo HTML_easyfaq::printEdit($row, $params); echo HTML_easyfaq::printButton($row, $params); echo HTML_easyfaq::pdfButton($row, $params); if($params->get('show_author')){ ?> <span class="small"> <?php echo _WRITTEN_BY . ' '. $row->author; ?> </span><br /> <?php } echo $row->introtext . $row->fulltext; echo HTML_easyfaq::printUseful($row, $params); if( $params->get( 'item_navigation' ) ){ HTML_easyfaq::printNavigation($row, $params); } if (!$params->get( 'print_view' ) ) { mosHTML::BackButton ( $params ); } } /** * Show categories * * @param array categories */ function showCat($rows, $params){ global $mainframe, $option, $Itemid; $mainframe->setPageTitle('Êàòåãîðèè FAQ'); $mainframe->addCustomHeadTag('<link href="'.$mainframe->getCfg('live_site') . '/components/com_easyfaq/easyfaq.css" rel="stylesheet" type="text/css"/>'); ?> <div class="componentheading"><?php echo EASYFAQ_FAQ_CATEGORIES; ?></div> <?php echo EASYFAQ_GENERAL; echo EASYFAQ_CAT_GENERAL_DESCRIPTION; ?> <ul class="faq"> <?php for($i=0,$n=count($rows);$i<$n;$i++){ $row = $rows[$i]; if($params->get('show_empty_cat') == 0){ if($row->faq_count == 0){ continue; } } echo '<li class="faq" id="li'. $row->id . '"><a href="' . sefRelToAbs('index.php?option=' . $option . '&task=cat&catid=' . $row->id . '&Itemid=' . $Itemid) . '">' . $row->name . '</a></li>'; } ?> </ul> <?php } /** * Show sub categories * * @param array categories */ function showSubCat($rows, $params){ global $mainframe, $option, $Itemid; ?> <?php echo EASYFAQ_SUBCAT_GENERAL_DESCRIPTION; ?> <ul class="faq"> <?php for($i=0,$n=count($rows);$i<$n;$i++){ $row = $rows[$i]; if($params->get('show_empty_cat') == 0){ if($row->faq_count == 0){ continue; } } echo '<li class="cat" id="li'. $row->id . '"><a href="' . sefRelToAbs('index.php?option=' . $option . '&task=cat&catid=' . $row->id . '&Itemid=' . $Itemid) . '">' . $row->name . '</a></li>'; } ?> </ul> <?php } /** * Construct pathway * * @param <var>mosCategory</var> current */ function constructPathway($cat){ global $mainframe, $database, $option, $Itemid; $query = "SELECT * FROM #__categories WHERE section = 'com_easyfaq' AND published = 1"; $database->setQuery($query); $rows = $database->loadObjectlist('id'); $pid = $cat->parent_id; $pathway = array(); while($pid != 0){ $cat = $rows[$pid]; $pathway[] = '<a href="'. sefRelToAbs('index.php?option=' . $option . '&task=cat&catid=' . $cat->id . '&Itemid=' . $Itemid) . '">'. $cat->name . '</a>'; $pid = $cat->parent_id; } $pathway = array_reverse($pathway); for($i=0,$n=count($pathway);$i<$n;$i++){ $mainframe->appendPathWay($pathway[$i]); } } /** * Show categories and FAQ * * @param array categories * @param array FAQ */ function showCatAndFaq($cats, $rows, $params){ global $mainframe, $option, $Itemid; $mainframe->setPageTitle(EASYFAQ_FAQ_CATEGORIES); $mainframe->addCustomHeadTag('<script type="text/javascript" src="'. $mainframe->getCfg('live_site') . '/components/com_easyfaq/easyfaq.js"></script>'); $mainframe->addCustomHeadTag('<link href="'.$mainframe->getCfg('live_site') . '/components/com_easyfaq/easyfaq.css" rel="stylesheet" type="text/css"/>'); ?> <div class="componentheading"><?php echo EASYFAQ_FAQ_CATEGORIES; ?></div> <?php echo EASYFAQ_GENERAL; if($my->id && ($my->gid == 2)){ ?> <div style="float: right;"> <a href="<?php echo 'index.php?option=' . $option . '&task=new&Itemid=' .$Itemid; ?>"> <img src="<?php echo $mainframe->getCfg('live_site');?>/images/M_images/new.png" width="13" height="14" align="middle" border="0" alt="<?php echo _CMN_NEW;?>" /> <?php echo _CMN_NEW;?>...</a> </div> <?php } echo EASYFAQ_CAT_GENERAL_DESCRIPTION . '<br />'; for($i=0,$n=count($cats);$i<$n;$i++){ $cat = $cats[$i]; if($params->get('show_empty_cat') == 0){ if($cat->faq_count == 0){ continue; } } echo '<h3 class="sectiontableheader">' . $cat->name . '</h3>'; if($params->get('cat_description')){ echo $cat->description; } echo '<ul class="faq">'; for($j=0,$k=count($rows);$j<$k;$j++){ $row = $rows[$j]; if($row->catid == $cat->id){ $link = ''; switch ($params->get('show_intro')){ case 'javascript': $content = '<div id="faq'. $row->id . '" style="display: none;">'; $content .= HTML_easyfaq::printEdit($row, $params); $content .= HTML_easyfaq::printButton($row, $params); $content .= HTML_easyfaq::pdfButton($row, $params); $content .= ($params->get('show_author') ? '<span class="small">'. _WRITTEN_BY . ' '. ($row->author_alias ? $row->author_alias : $row->author) . '</span><br />' : '') . $row->introtext . (!empty($row->fulltext) ? '<br /><a href="' . sefRelToAbs('index.php?option=' . $option . '&task=view&id=' . $row->id . '&Itemid=' . $Itemid) . '">' . _READ_MORE . '</a>' : ''); $content .= HTML_easyfaq::printUseful($row, $params); $content .= '</div>'; $link = 'javascript:void(0);" onclick="toggleFaq('. $row->id . ');'; break; case 'ajax': $link = 'javascript:void(0);" onclick="toggleFaqWithAjax('. $row->id . ');'; $content = '<div id="faq'. $row->id . '" style="display: none;"></div>'; break; case 'none': $content = ''; break; } if(empty($link)){ $link = sefRelToAbs('index.php?option=' . $option . '&task=view&id=' . $row->id . '&Itemid=' . $Itemid); } echo '<li class="faq" id="li'. $row->id . '">'; echo '<a href="' . $link . '">'. $row->title . '</a>'; echo $content; echo '</li>'; // echo '<li class="faq"><a href="' . sefRelToAbs('index.php?option=' . $option . '&task=view&id=' . $row->id . '&Itemid=' . $Itemid) . '">'. $row->title . '</a></li>'; } } echo '</ul>'; } } /** * Edit or add a FAQ item * * @param dbFaq $row * @param array $lists */ function editFaq($row, $lists){ global $option, $Itemid, $my, $mainframe; if((!$my->id) || ($my->gid != 2)){ mosNotAuth(); return; } require_once( $mainframe->getCfg('absolute_path') . '/includes/HTML_toolbar.php' ); ?> <script type="text/javascript"> <!-- function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'cancel') { submitform( pressbutton ); return; } if (form.title.value == ""){ alert( <?php echo EASYFAQ_MUST_HAVE_TITLE; ?> ); return; } <?php getEditorContents( 'editor1', 'introtext' ) ; ?> <?php getEditorContents( 'editor2', 'fulltext' ) ; ?> submitform( pressbutton ); } //--> </script> <form action="index.php" method="post" name="adminForm"> <div class="componentheading"><?php echo ($row->id ? EASYFAQ_EDIT : EASYFAQ_ADD); ?></div> <div style="float: right;"> <?php // Toolbar Top mosToolBar::startTable(); mosToolBar::save(); mosToolBar::cancel(); mosToolBar::endtable(); ?> </div> <table class="adminform" width="100%" cellpadding="0" cellspacing="0"> <tr> <td class="sectiontableheader" colspan="2"><?php echo EASYFAQ_EDIT_FAQ; ?></td> </tr> <tr> <td width="50"><?php echo EASYFAQ_TITLE; ?></td> <td><input type="text" name="title" value="<?php echo $row->title; ?>" size="50" /></td> </tr> <tr> <td width="50"><?php echo EASYFAQ_CATEGORIE; ?></td> <td><?php echo $lists['catid']; ?></td> </tr> <tr> <td colspan="2" width="100%"> <?php echo EASYFAQ_INTROTEXT; ?> <br /><?php // parameters : areaname, content, hidden field, width, height, rows, cols editorArea( 'editor1', $row->introtext , 'introtext', '520', '350', '75', '20' ) ; ?> </td> </tr> <tr> <td colspan="2" width="100%"> <?php echo EASYFAQ_MAINTEXT; ?> <br /><?php // parameters : areaname, content, hidden field, width, height, rows, cols editorArea( 'editor2', $row->fulltext , 'fulltext', '520', '400', '75', '30' ) ; ?> </td> </tr> </table> <br /> <table class="adminform" width="100%" cellpadding="0" cellspacing="0"> <tr> <td class="sectiontableheader" colspan="2"><?php echo EASYFAQ_PARAMETERS; ?></td> </tr> <tr> <td><?php echo EASYFAQ_PUBLISHED; ?>:</td> <td><input type="checkbox" name="published" value="1" <?php echo ($row->published ? 'checked="checked"' : ''); ?>/></td> </tr> <tr> <td><?php echo EASYFAQ_CREATED_BY; ?>:</td> <td><?php echo $lists['created_by']; ?></td> </tr> <tr> <td><?php echo EASYFAQ_AUTHOR_ALIAS; ?></td> <td><input type="text" name="author_alias" size="30" maxlength="100" value="<?php echo $row->author_alias; ?>" class="text_area" /></td> </tr> </table> <input type="hidden" name="id" value="<?php echo $row->id; ?>" /> <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" /> <input type="hidden" name="option" value="<?php echo $option; ?>" /> <input type="hidden" name="act" value="faq" /> <input type="hidden" name="task" value="" /> <input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="hidemainmenu" value="0" /> </form> <?php } /** * print print button * * @param <var>dbEasyFaq</var> $row * @param <var>mosParameters</var> $params */ function printButton($row, $params){ global $mainframe, $Itemid; if ( $params->get( 'print' ) ) { if ( $params->get( 'icons' ) ) { $image = mosAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, _CMN_PRINT, _CMN_PRINT ); } else { $image = _ICON_SEP .' '. _CMN_PRINT. ' '. _ICON_SEP; } $text = ''; $text .= '<div style="float: right;">'; if($params->get('print_view')){ $text .= '<a href="#" onclick="javascript:window.print(); return false;" title="'. _CMN_PRINT . '">'. $image . '</a>'; } else { $link = $mainframe->getCfg('live_site'). '/index2.php?option=com_easyfaq&task=view&id=' . $row->id .'&pop=1&Itemid=' . $Itemid; $text .= '<a href="' . $link . '" target="_blank" onclick="window.open(\'' . $link . '\',\'win2\',\'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no\'); return false;" title="'. _CMN_PRINT . '">'. $image . '</a>'; } $text .= ' </div>'; } return $text; } /** * print pdf button * * @param <var>dbEasyFaq</var> $row * @param <var>mosParameters</var> $params */ function pdfButton($row, $params){ global $mainframe, $Itemid; if ( $params->get( 'pdf' ) && !$params->get('print_view') ) { if ( $params->get( 'icons' ) ) { $image = mosAdminMenus::ImageCheck( 'pdf_button.png', '/images/M_images/', NULL, NULL, _CMN_PDF, _CMN_PDF ); } else { $image = _ICON_SEP .' '. _CMN_PDF. ' '. _ICON_SEP; } $text = ''; $text .= '<div style="float: right;">'; $link = $mainframe->getCfg('live_site'). '/index2.php?option=com_easyfaq&task=pdf&id=' . $row->id .'&pop=1&no_html=1&Itemid=' . $Itemid; $text .= '<a href="' . $link . '" title="'. _CMN_PDF . '">'. $image . '</a>'; $text .= ' </div>'; } return $text; } /** * Print usefull/unusefull things * * @param <var>dbEasyFaq</var> $row * @param <var>mosParameters</var> $params */ function printUseful($row, $params){ global $option, $Itemid, $mainframe; $text = ''; if( $params->get( 'helpful' ) && !$params->get('print_view') ){ if($row->usefull > 0){ $total = $row->usefull + $row->unusefull; $f_u = number_format($row->usefull / $total * 100, 2, ',', '.'); } else { $f_u = 0; $total = 0; } $text .= '<div style="clear: both" class="easfaq_useful">'; $text .= sprintf(EASYFAQ_FOUND_USEFULL, $f_u . '%', $total); $text .= ' ' . EASYFAQ_I_FOUND; $text .= ' <a href="javascript:void(0);" onclick="xajax_setHelpful(' . $row->id . ', 1);"><img src="' . $mainframe->getCfg('live_site') . '/components/com_easyfaq/icons/ledlightgreen.png" border="0" alt="' . EASYFAQ_USEFUL . '" /></a> '. EASYFAQ_USEFUL . ''; $text .= ' <a href="javascript:void(0);" onclick="xajax_setHelpful(' . $row->id . ', 0);"><img src="' . $mainframe->getCfg('live_site') . '/components/com_easyfaq/icons/ledred.png" border="0" alt="' . EASYFAQ_UNUSEFUL . '" /></a> '. EASYFAQ_UNUSEFUL . ''; $text .= '</div>'; } return $text; } /** * Print edit button * * @param <var>dbEasyFaq</var> $row * @param <var>mosParameters</var> $params * @return string */ function printEdit($row, $params){ global $option, $Itemid, $mainframe, $my; $text = ''; if($my->id && ($my->gid == 2)){ $image = mosAdminMenus::ImageCheck( 'edit.png', '/images/M_images/', NULL, NULL, _E_EDIT, _E_EDIT ); $text = '<a href="' . sefRelToAbs( 'index.php?option=' . $option . '&task=edit&id=' . $row->id . '&Itemid=' . $Itemid ) . '">'. $image . '</a>'; } return $text; } /** * print previous and next buttons * * @param <var>dbEasyFaq</var> $row * @param <var>mosParameters</var> $params */ function printNavigation($row, $params){ global $option, $Itemid; $link_part = 'index.php?option=' . $option . '&task=view&id='; if ( $row->prev ) { $row->prev = sefRelToAbs( $link_part . $row->prev . '&Itemid=' . $Itemid ); } else { $row->prev = 0; } if ( $row->next ) { $row->next = sefRelToAbs( $link_part . $row->next . '&Itemid=' . $Itemid ); } else { $row->next = 0; } if ( $params->get( 'item_navigation' ) && !$params->get( 'print_view' ) && ( $row->prev || $row->next ) ) { ?> <table align="center" style="margin-top: 25px;"> <tr> <?php if ( $row->prev ) { ?> <th class="pagenav_prev"> <a href="<?php echo $row->prev; ?>"> <?php echo _ITEM_PREVIOUS; ?></a> </th> <?php } if ( $row->prev && $row->next ) { ?> <td width="50"> </td> <?php } if ( $row->next ) { ?> <th class="pagenav_next"> <a href="<?php echo $row->next; ?>"> <?php echo _ITEM_NEXT; ?></a> </th> <?php } ?> </tr> </table> <?php } } /** * Show copyright notices */ function showCopyright(){ global $mainframe; /** * Visible copyright notices, you can remove it if you like */ echo '<div class="small" style="clear: both;"><br />'. EASYFAQ_POWERED_BY . ' <a href="http://www.joomla-addons.org/easyfaq-component.html" target="_blank">EasyFAQ</a> © 2006 <a href="http://www.joomla-addons.org" target="_blank" title="Joomla êîìïîíåíòû, ìîäóëè, ïëàãèíû è õîñòèíã">Joomla-addons.org</a></div>'; /** * I would appreciate it very much if you could leave this present, * this is something your users will never see */ $mainframe->addMetaTag('Àâòîð', 'EasyFAQ îò www.joomla-addons.org'); } } ?>