Beispiel #1
0
function moveCats($cat_id, $cat_parent, $option)
{
    $database =& JFactory::getDBO();
    if (!is_array($cat_id) || count($cat_id) < 1) {
        echo "<script> alert('" . JText::_('Select an item to move') . "'); window.history.go(-1);</script>\n";
        exit;
    }
    # Get Pathway
    $pathWay = new mtPathWay($cat_parent);
    # Get all category under cat_parent except those which is moving
    $cat_ids = implode(',', $cat_id);
    $database->setQuery('SELECT cat_id AS value, cat_name AS text FROM #__mt_cats WHERE cat_parent = ' . $database->quote($cat_parent) . ' AND cat_id NOT IN (' . $cat_ids . ') ORDER BY cat_name ASC');
    $rows = $database->loadObjectList();
    # Get Parent's parent
    if ($cat_parent > 0) {
        $database->setQuery('SELECT cat_parent FROM #__mt_cats WHERE cat_id = ' . $database->quote($cat_parent));
        $cat_back = JHTML::_('select.option', $database->loadResult(), '&lt;--Back');
        array_unshift($rows, $cat_back);
    }
    $cats = $rows;
    $catList = JHTML::_('select.genericlist', $cats, 'cat_parent', 'class="text_area" size="8" style="width:30%"', 'value', 'text', null, 'browsecat');
    HTML_mtree::move_cats($cat_id, $cat_parent, $catList, $pathWay, $option);
}