function manage_category()
{
    global $hesk_settings, $hesklang;
    $catid = intval(hesk_GET('catid')) or hesk_error($hesklang['kb_cat_inv']);
    $result = hesk_dbQuery('SELECT * FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'kb_categories` ORDER BY `parent` ASC, `cat_order` ASC');
    $kb_cat = array();
    while ($cat = hesk_dbFetchAssoc($result)) {
        $kb_cat[] = $cat;
        if ($cat['id'] == $catid) {
            $this_cat = $cat;
        }
    }
    if (isset($_SESSION['manage_cat'])) {
        $_SESSION['manage_cat'] = hesk_stripArray($_SESSION['manage_cat']);
        $this_cat['type'] = $_SESSION['manage_cat']['type'];
        $this_cat['parent'] = $_SESSION['manage_cat']['parent'];
        $this_cat['name'] = $_SESSION['manage_cat']['title'];
    }
    /* Translate main category "Knowledgebase" if needed */
    $kb_cat[0]['name'] = $hesklang['kb_text'];
    require HESK_PATH . 'inc/treemenu/TreeMenu.php';
    $icon = HESK_PATH . 'img/folder.gif';
    $expandedIcon = HESK_PATH . 'img/folder-expanded.gif';
    $menu = new HTML_TreeMenu();
    $thislevel = array('0');
    $nextlevel = array();
    $i = 1;
    $j = 1;
    while (count($kb_cat) > 0) {
        foreach ($kb_cat as $k => $cat) {
            if (in_array($cat['parent'], $thislevel)) {
                $up = $cat['parent'];
                $my = $cat['id'];
                $type = $cat['type'] ? '*' : '';
                $text_short = $cat['name'] . $type . ' (' . $cat['articles'] . ', ' . $cat['articles_private'] . ', ' . $cat['articles_draft'] . ')';
                if (isset($node[$up])) {
                    $node[$my] =& $node[$up]->addItem(new HTML_TreeNode(array('hesk_parent' => $this_cat['parent'], 'text' => 'Text', 'text_short' => $text_short, 'hesk_catid' => $cat['id'], 'hesk_select' => 'option' . $j, 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true)));
                } else {
                    $node[$my] = new HTML_TreeNode(array('hesk_parent' => $this_cat['parent'], 'text' => 'Text', 'text_short' => $text_short, 'hesk_catid' => $cat['id'], 'hesk_select' => 'option' . $j, 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true));
                }
                $nextlevel[] = $cat['id'];
                $j++;
                unset($kb_cat[$k]);
            }
        }
        $thislevel = $nextlevel;
        $nextlevel = array();
        /* Break after 20 recursions to avoid hang-ups in case of any problems */
        if ($i > 20) {
            break;
        }
        $i++;
    }
    $menu->addItem($node[1]);
    // Create the presentation class
    $listBox =& ref_new(new HTML_TreeMenu_Listbox($menu));
    /* Print header */
    require_once HESK_PATH . 'inc/header.inc.php';
    /* Print main manage users page */
    require_once HESK_PATH . 'inc/show_admin_nav.inc.php';
    ?>

	
     <div class="container manage-kb-category-title"><a href="manage_knowledgebase.php" class="smaller"><b><?php 
    echo $hesklang['kb'];
    ?>
</b></a> &gt; <?php 
    echo $hesklang['kb_cat_man'];
    ?>
</div>

	<!-- SUB NAVIGATION -->
	<?php 
    show_subnav('', $catid);
    ?>
	<!-- SUB NAVIGATION -->

	<?php 
    if (!isset($_SESSION['hide']['article_list'])) {
        ?>

     <div class="container category-kb"><?php 
        echo $hesklang['category'];
        ?>
: <span class="black"><?php 
        echo $this_cat['name'];
        ?>
</span></div>

    &nbsp;<br />

    <?php 
        $result = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `catid`='{$catid}' ORDER BY `sticky` DESC, `art_order` ASC");
        $num = hesk_dbNumRows($result);
        if ($num == 0) {
            echo '<div class="container kb_no_article">' . $hesklang['kb_no_art'] . ' &nbsp;<br/><br/> 
		<a href="manage_knowledgebase.php?a=add_article&amp;catid=' . $catid . '"><img src="../img/add_article.png" width="16" height="16" alt="' . $hesklang['kb_i_art2'] . '" title="' . $hesklang['kb_i_art2'] . '" border="0" style="border:none;vertical-align:text-bottom" /></a>' . '<a href="manage_knowledgebase.php?a=add_article&amp;catid=' . $catid . '"><b>' . $hesklang['kb_i_art2'] . '</b></a></div>';
        } else {
            /* Get number of sticky articles */
            $res2 = hesk_dbQuery("SELECT COUNT(*) FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `catid`='{$catid}' AND `sticky` = '1' ");
            $num_sticky = hesk_dbResult($res2);
            $num_nosticky = $num - $num_sticky;
            ?>
        <div class="container insertArticle">
	        <?php 
            echo '<a href="manage_knowledgebase.php?a=add_article&amp;catid=' . $catid . '"><img src="../img/add_article.png" width="16" height="16" alt="' . $hesklang['kb_i_art2'] . '" title="' . $hesklang['kb_i_art2'] . '" border="0" style="border:none;vertical-align:text-bottom" /></a> <a href="manage_knowledgebase.php?a=add_article&amp;catid=' . $catid . '"><b>' . $hesklang['kb_i_art2'] . '</b></a>';
            ?>
	    </div>

	     <div class="container kb_cat_art_title"><?php 
            echo $hesklang['kb_cat_art'];
            ?>
</div>

		<div class="container">
		<table class="table table-bordered table-responsive kb_cat_art_table">
		<tr>
        <th class="admin_white">&nbsp;</th>
		<th class="admin_white"><b><i><?php 
            echo $hesklang['kb_subject'];
            ?>
</i></b></th>
		<th class="admin_white"><b><i><?php 
            echo $hesklang['kb_type'];
            ?>
</i></b></th>
        <th class="admin_white"><b><i><?php 
            echo $hesklang['views'];
            ?>
</i></b></th>
        <?php 
            if ($hesk_settings['kb_rating']) {
                ?>
	        <th class="admin_white" style="white-space:nowrap" nowrap="nowrap" width="130"><b><i><?php 
                echo $hesklang['rating'] . ' (' . $hesklang['votes'] . ')';
                ?>
</i></b></th>
	        <?php 
            }
            ?>
        <th class="admin_white" style="width:120px"><b><i>&nbsp;<?php 
            echo $hesklang['opt'];
            ?>
&nbsp;</i></b></th>
		</tr>
    	<?php 
            $i = 1;
            $j = 1;
            $k = 1;
            $previous_sticky = 1;
            $num = $num_sticky;
            while ($article = hesk_dbFetchAssoc($result)) {
                if ($previous_sticky != $article['sticky']) {
                    $k = 1;
                    $num = $num_nosticky;
                    $previous_sticky = $article['sticky'];
                }
                if (isset($_SESSION['artord']) && $article['id'] == $_SESSION['artord']) {
                    $color = 'admin_green';
                    unset($_SESSION['artord']);
                } elseif ($article['sticky']) {
                    $color = 'admin_yellow';
                } else {
                    $color = $i ? 'admin_white' : 'admin_gray';
                }
                $tmp = $i ? 'White' : 'Blue';
                $style = 'class="option' . $tmp . 'OFF" onmouseover="this.className=\'option' . $tmp . 'ON\'" onmouseout="this.className=\'option' . $tmp . 'OFF\'"';
                $i = $i ? 0 : 1;
                switch ($article['type']) {
                    case '1':
                        $type = '<span class="kb_private">' . $hesklang['kb_private'] . '</span>';
                        break;
                    case '2':
                        $type = '<span class="kb_draft">' . $hesklang['kb_draft'] . '</span>';
                        break;
                    default:
                        $type = '<span class="kb_published">' . $hesklang['kb_published'] . '</span>';
                }
                if ($hesk_settings['kb_rating']) {
                    $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
                    $rat = '<td class="' . $color . '" style="white-space:nowrap;"><img src="../img/star_' . hesk_round_to_half($article['rating']) * 10 . '.png" width="85" height="16" alt="' . $alt . '" title="' . $alt . '" border="0" style="vertical-align:text-bottom" /> (' . $article['votes'] . ') </td>';
                } else {
                    $rat = '';
                }
                ?>
			<tr>
			<td class="<?php 
                echo $color;
                ?>
"><?php 
                echo $j;
                ?>
.</td>
			<td class="<?php 
                echo $color;
                ?>
"><?php 
                echo $article['subject'];
                ?>
</td>
            <td class="<?php 
                echo $color;
                ?>
"><?php 
                echo $type;
                ?>
</td>
            <td class="<?php 
                echo $color;
                ?>
"><?php 
                echo $article['views'];
                ?>
</td>
            <?php 
                echo $rat;
                ?>
            <td class="<?php 
                echo $color;
                ?>
" style="text-align:center; white-space:nowrap;">
			<?php 
                if ($num > 1) {
                    if ($k == 1) {
                        ?>
                    <img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;" />
                	<a href="manage_knowledgebase.php?a=order_article&amp;id=<?php 
                        echo $article['id'];
                        ?>
&amp;catid=<?php 
                        echo $catid;
                        ?>
&amp;move=15&amp;token=<?php 
                        hesk_token_echo();
                        ?>
"><img src="../img/move_down.png" width="16" height="16" alt="<?php 
                        echo $hesklang['move_dn'];
                        ?>
" title="<?php 
                        echo $hesklang['move_dn'];
                        ?>
" <?php 
                        echo $style;
                        ?>
 /></a>
	            <?php 
                    } elseif ($k == $num) {
                        ?>
					<a href="manage_knowledgebase.php?a=order_article&amp;id=<?php 
                        echo $article['id'];
                        ?>
&amp;catid=<?php 
                        echo $catid;
                        ?>
&amp;move=-15&amp;token=<?php 
                        hesk_token_echo();
                        ?>
"><img src="../img/move_up.png" width="16" height="16" alt="<?php 
                        echo $hesklang['move_up'];
                        ?>
" title="<?php 
                        echo $hesklang['move_up'];
                        ?>
" <?php 
                        echo $style;
                        ?>
 /></a>
                    <img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;" />
	            <?php 
                    } else {
                        ?>
					<a href="manage_knowledgebase.php?a=order_article&amp;id=<?php 
                        echo $article['id'];
                        ?>
&amp;catid=<?php 
                        echo $catid;
                        ?>
&amp;move=-15&amp;token=<?php 
                        hesk_token_echo();
                        ?>
"><img src="../img/move_up.png" width="16" height="16" alt="<?php 
                        echo $hesklang['move_up'];
                        ?>
" title="<?php 
                        echo $hesklang['move_up'];
                        ?>
" <?php 
                        echo $style;
                        ?>
 /></a>
					<a href="manage_knowledgebase.php?a=order_article&amp;id=<?php 
                        echo $article['id'];
                        ?>
&amp;catid=<?php 
                        echo $catid;
                        ?>
&amp;move=15&amp;token=<?php 
                        hesk_token_echo();
                        ?>
"><img src="../img/move_down.png" width="16" height="16" alt="<?php 
                        echo $hesklang['move_dn'];
                        ?>
" title="<?php 
                        echo $hesklang['move_dn'];
                        ?>
" <?php 
                        echo $style;
                        ?>
 /></a>
	            <?php 
                    }
                } elseif ($num_sticky > 1 || $num_nosticky > 1) {
                    echo '<img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;vertical-align:text-bottom;" /> <img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;vertical-align:text-bottom;" />';
                }
                ?>
            <a href="manage_knowledgebase.php?a=sticky&amp;s=<?php 
                echo $article['sticky'] ? 0 : 1;
                ?>
&amp;id=<?php 
                echo $article['id'];
                ?>
&amp;catid=<?php 
                echo $catid;
                ?>
&amp;token=<?php 
                hesk_token_echo();
                ?>
"><img src="../img/sticky<?php 
                if (!$article['sticky']) {
                    echo '_off';
                }
                ?>
.png" width="16" height="16" alt="<?php 
                echo $article['sticky'] ? $hesklang['stickyoff'] : $hesklang['stickyon'];
                ?>
" title="<?php 
                echo $article['sticky'] ? $hesklang['stickyoff'] : $hesklang['stickyon'];
                ?>
" <?php 
                echo $style;
                ?>
 /></a>
            <a href="knowledgebase_private.php?article=<?php 
                echo $article['id'];
                ?>
&amp;back=1<?php 
                if ($article['type'] == 2) {
                    echo '&amp;draft=1';
                }
                ?>
" target="_blank"><img src="../img/article_text.png" width="16" height="16" alt="<?php 
                echo $hesklang['viewart'];
                ?>
" title="<?php 
                echo $hesklang['viewart'];
                ?>
" <?php 
                echo $style;
                ?>
 /></a>
            <a href="manage_knowledgebase.php?a=edit_article&amp;id=<?php 
                echo $article['id'];
                ?>
"><img src="../img/edit.png" width="16" height="16" alt="<?php 
                echo $hesklang['edit'];
                ?>
" title="<?php 
                echo $hesklang['edit'];
                ?>
" <?php 
                echo $style;
                ?>
 /></a>
            <a href="manage_knowledgebase.php?a=remove_article&amp;id=<?php 
                echo $article['id'];
                ?>
&amp;token=<?php 
                hesk_token_echo();
                ?>
" onclick="return hesk_confirmExecute('<?php 
                echo hesk_makeJsString($hesklang['del_art']);
                ?>
');"><img src="../img/delete.png" width="16" height="16" alt="<?php 
                echo $hesklang['delete'];
                ?>
" title="<?php 
                echo $hesklang['delete'];
                ?>
" <?php 
                echo $style;
                ?>
 /></a>&nbsp;</td>
			</tr>
            <?php 
                $j++;
                $k++;
            }
            // End while
            ?>
		</table>
		</div>
		<?php 
        }
    }
    // END if hide article list
    /* Manage Category (except the default one) */
    if ($catid != 1) {
        ?>

        &nbsp;<br />


    <div class="container insertCategory">
		<?php 
        echo '<a href="manage_knowledgebase.php?a=add_category&amp;parent=' . $catid . '"><img src="../img/add_category.png" width="16" height="16" alt="' . $hesklang['kb_i_cat2'] . '" title="' . $hesklang['kb_i_cat2'] . '" border="0" style="border:none;vertical-align:text-bottom" /></a> <a href="manage_knowledgebase.php?a=add_category&amp;parent=' . $catid . '"><b>' . $hesklang['kb_i_cat2'] . '</b></a>';
        ?>
	</div>

	<div class="container category-settings-title"><?php 
        echo $hesklang['catset'];
        ?>
</div>
	<div class="container category-settings-form">
	<br/>
		<form action="manage_knowledgebase.php" method="post" name="form1" onsubmit="Javascript:return hesk_deleteIfSelected('dodelete','<?php 
        echo hesk_makeJsString($hesklang['kb_delcat']);
        ?>
')">
			<div class="form-inline">
				<span class="col-sm-2"><b><?php 
        echo $hesklang['kb_cat_title'];
        ?>
:</b></span>
				<span><input class="form-control" type="text" name="title" size="70" maxlength="255" value="<?php 
        echo $this_cat['name'];
        ?>
" /></span>
			</div>
			<br/>
			<div class="form-inline">
				<span class="col-sm-2"><b><?php 
        echo $hesklang['kb_cat_parent'];
        ?>
:</b></span>
				<span><select class="form-control" name="parent"><?php 
        $listBox->printMenu();
        ?>
</select></span>
			</div>
			<br/>
			<div class="form-inline">
				<span class="col-sm-2"><b><?php 
        echo $hesklang['kb_type'];
        ?>
:</b></span>
				<div class="form-group">
					<label><input type="radio" name="type" value="0" <?php 
        if (!$this_cat['type']) {
            echo 'checked="checked"';
        }
        ?>
 /> <b><i><?php 
        echo $hesklang['kb_published'];
        ?>
</i></b></label><br />
					<span><?php 
        echo $hesklang['kb_cat_published'];
        ?>
</span><br/><br/>
					<label><input type="radio" name="type" value="1" <?php 
        if ($this_cat['type']) {
            echo 'checked="checked"';
        }
        ?>
 /> <b><i><?php 
        echo $hesklang['kb_private'];
        ?>
</i></b></label><br />
					<span><?php 
        echo $hesklang['kb_cat_private'];
        ?>
</span>
				</div>
			</div>
			<br/>
	        <div class="form-inline">
				<span class="col-sm-2"><b><?php 
        echo $hesklang['opt'];
        ?>
:</b></span>
				<div class="form-group">
					<label><input type="checkbox" name="dodelete" id="dodelete" value="Y" onclick="Javascript:hesk_toggleLayerDisplay('deleteoptions')" /> <i><?php 
        echo $hesklang['delcat'];
        ?>
</i></label>
					<div id="deleteoptions" style="display: none;">
					<label><input type="radio" name="movearticles" value="Y" checked="checked" /> <?php 
        echo $hesklang['move1'];
        ?>
</label><br />
					<label><input type="radio" name="movearticles" value="N" /> <?php 
        echo $hesklang['move2'];
        ?>
</label>
					</div>
				</div>
	        </div>
			<br/>
	</div>
	<br/>
		<div class="col-sm-6 col-sm-offset-6">
			<input type="hidden" name="a" value="edit_category" />
	        <input type="hidden" name="token" value="<?php 
        hesk_token_echo();
        ?>
" />
	        <input type="hidden" name="catid" value="<?php 
        echo $catid;
        ?>
" /><input type="submit" value="<?php 
        echo $hesklang['save_changes'];
        ?>
" class="btn btn-default save-cat-changes-btn" />
		</div>
	</form>
	

	<?php 
    }
    // END if $catid != 1
    /* Clean unneeded session variables */
    hesk_cleanSessionVars(array('hide', 'manage_cat', 'edit_article'));
    require_once HESK_PATH . 'inc/footer.inc.php';
    exit;
}
Ejemplo n.º 2
0
function convert_html_to_text($data)
{
    $h2t =& ref_new(new html2text($data));
    // Simply call the get_text() method for the class to convert
    // the HTML to the plain text. Store it into the variable.
    $text = $h2t->get_text();
    return $text;
}
Ejemplo n.º 3
0
 /**
  * Creates a treeMenu from XML. The structure of your XML should be
  * like so:
  *
  * <treemenu>
  *     <node text="First node" icon="folder.gif" expandedIcon="folder-expanded.gif" />
  *     <node text="Second node" icon="folder.gif" expandedIcon="folder-expanded.gif">
  *         <node text="Sub node" icon="folder.gif" expandedIcon="folder-expanded.gif" />
  *     </node>
  *     <node text="Third node" icon="folder.gif" expandedIcon="folder-expanded.gif">
  * </treemenu>
  *
  * Any of the options you can supply to the HTML_TreeNode constructor can be supplied as
  * attributes to the <node> tag. If there are no subnodes for a particular node, you can
  * use the XML shortcut <node ... /> instead of <node ... ></node>. The $xml argument can
  * be either the XML as a string, or an pre-created XML_Tree object. Also, this method
  * REQUIRES my own Tree class to work (http://www.phpguru.org/static/tree.html). If this has not
  * been include()ed or require()ed this method will die().
  *
  * @param  mixed  $xml  This can be either a string containing the XML, or an XML_Tree object
  *                      (the PEAR::XML_Tree package).
  * @return object       The HTML_TreeMenu object
  */
 function createFromXML($xml)
 {
     if (!class_exists('Tree')) {
         die('Could not find Tree class');
     }
     // Supplied $xml is a string
     if (is_string($xml)) {
         require_once 'XML/Tree.php';
         $xmlTree =& ref_new(new XML_Tree());
         $xmlTree->getTreeFromString($xml);
         // Supplied $xml is an XML_Tree object
     } else {
         $xmlTree = $xml;
     }
     // Now process the XML_Tree object, setting the XML attributes
     // to be the tag data (with out the XML tag name or contents).
     $treeStructure = Tree::createFromXMLTree($xmlTree, true);
     $treeStructure->nodes->traverse(create_function('&$node', '$tagData = $node->getTag(); $node->setTag($tagData["attributes"]);'));
     return HTML_TreeMenu::createFromStructure(array('structure' => $treeStructure));
 }