Exemplo n.º 1
0
function editCategory($section = '', $uid = 0)
{
    $my = JFactory::getUser();
    $database = JFactory::getDBO();
    $mainframe = JFactory::getApplication();
    // disable the main menu to force user to use buttons
    $_REQUEST['hidemainmenu'] = 1;
    $type = JRequest::getCmd('type', '');
    $redirect = JRequest::getCmd('section', '', 'post');
    $row = new mosDMCategory($database);
    // load the row from the db table
    $row->load($uid);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        $mainframe->redirect('index.php?option=com_docman&task=categories', 'The category ' . $row->title . ' is currently being edited by another administrator');
    }
    if ($uid) {
        // existing record
        $row->checkout($my->id);
        // code for Link Menu
    } else {
        // new record
        $row->section = $section;
        $row->published = 1;
    }
    // make order list
    $order = array();
    $database->setQuery("SELECT COUNT(*) FROM #__categories WHERE section='{$row->section}'");
    $max = intval($database->loadResult()) + 1;
    for ($i = 1; $i < $max; $i++) {
        $order[] = JHTML::_('select.option', $i);
    }
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__categories" . "\n WHERE section = '{$row->section}'" . "\n ORDER BY ordering";
    $lists['ordering'] = JHTML::_('list.specificordering', $row, $uid, $query);
    // build the select list for the image positions
    $active = $row->image_position ? $row->image_position : 'left';
    $lists['image_position'] = JHTML::_('list.positions', 'image_position', $active, null, 0, 0);
    // Imagelist
    $lists['image'] = dmHTML::imageList('image', $row->image);
    // build the html select list for the group access
    $lists['access'] = JHTML::_('list.accesslevel', $row);
    // build the html radio buttons for published
    $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published);
    // build the html select list for paraent item
    $options = array();
    $options[] = JHTML::_('select.option', '0', _DML_TOP);
    $lists['parent'] = dmHTML::categoryParentList($row->id, "", $options);
    HTML_DMCategories::edit($row, $section, $lists, $redirect);
}
Exemplo n.º 2
0
function editCategory($section = '', $uid = 0)
{
    global $database, $my;
    global $mosConfig_absolute_path, $mosConfig_live_site;
    // disable the main menu to force user to use buttons
    $_REQUEST['hidemainmenu'] = 1;
    $type = mosGetParam($_REQUEST, 'type', '');
    $redirect = mosGetParam($_POST, 'section', '');
    $row = new mosDMCategory($database);
    // load the row from the db table
    $row->load($uid);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        mosRedirect('index2.php?option=com_docman&task=categories', 'The category ' . $row->title . ' is currently being edited by another administrator');
    }
    if ($uid) {
        // existing record
        $row->checkout($my->id);
        // code for Link Menu
    } else {
        // new record
        $row->section = $section;
        $row->published = 1;
    }
    // make order list
    $order = array();
    $database->setQuery("SELECT COUNT(*) FROM #__categories WHERE section='{$row->section}'");
    $max = intval($database->loadResult()) + 1;
    for ($i = 1; $i < $max; $i++) {
        $order[] = mosHTML::makeOption($i);
    }
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__categories" . "\n WHERE section = '{$row->section}'" . "\n ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query);
    // build the select list for the image positions
    $active = $row->image_position ? $row->image_position : 'left';
    $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, null, 0, 0);
    // Imagelist
    $lists['image'] = dmHTML::imageList('image', $row->image);
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // build the html radio buttons for published
    $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published);
    // build the html select list for paraent item
    $options = array();
    $options[] = mosHTML::makeOption('0', _DML_TOP);
    $lists['parent'] = dmHTML::categoryParentList($row->id, "", $options);
    HTML_DMCategories::edit($row, $section, $lists, $redirect);
}