Пример #1
0
/**
* Compiles information to add or edit a category
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
* @param string The name of the current user
*/
function editCategory($edit)
{
    global $mainframe;
    // Initialize variables
    $db =& JFactory::getDBO();
    $user =& JFactory::getUser();
    $uid = $user->get('id');
    $type = JRequest::getCmd('type');
    $redirect = JRequest::getCmd('section', 'com_content');
    $section = JRequest::getCmd('section', 'com_content');
    $cid = JRequest::getVar('cid', array(0), '', 'array');
    JArrayHelper::toInteger($cid, array(0));
    // check for existance of any sections
    $query = 'SELECT COUNT( id )' . ' FROM #__sections' . ' WHERE scope = "content"';
    $db->setQuery($query);
    $sections = $db->loadResult();
    if (!$sections && $type != 'other' && $section != 'com_weblinks' && $section != 'com_newsfeeds' && $section != 'com_contact_details' && $section != 'com_banner') {
        $mainframe->redirect('index.php?option=com_categories&section=' . $section, JText::_('WARNSECTION', true));
    }
    $row =& JTable::getInstance('category');
    // load the row from the db table
    if ($edit) {
        $row->load($cid[0]);
    }
    // fail if checked out not by 'me'
    if (JTable::isCheckedOut($user->get('id'), $row->checked_out)) {
        $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The category'), $row->title);
        $mainframe->redirect('index.php?option=com_categories&section=' . $row->section, $msg);
    }
    if ($edit) {
        $row->checkout($user->get('id'));
    } else {
        $row->published = 1;
    }
    // make order list
    $order = array();
    $query = 'SELECT COUNT(*)' . ' FROM #__categories' . ' WHERE section = ' . $db->Quote($row->section);
    $db->setQuery($query);
    $max = intval($db->loadResult()) + 1;
    for ($i = 1; $i < $max; $i++) {
        $order[] = JHTML::_('select.option', $i);
    }
    // build the html select list for sections
    if ($section == 'com_content') {
        if (!$row->section && JRequest::getInt('sectionid')) {
            $row->section = JRequest::getInt('sectionid');
        }
        $query = 'SELECT s.id AS value, s.title AS text' . ' FROM #__sections AS s' . ' ORDER BY s.ordering';
        $db->setQuery($query);
        $sections = $db->loadObjectList();
        $lists['section'] = JHTML::_('select.genericlist', $sections, 'section', 'class="inputbox" size="1"', 'value', 'text', $row->section);
    } else {
        if ($type == 'other') {
            $section_name = JText::_('N/A');
        } else {
            $temp =& JTable::getInstance('section');
            $temp->load($row->section);
            $section_name = $temp->name;
        }
        if (!$section_name) {
            $section_name = JText::_('N/A');
        }
        $row->section = $section;
        $lists['section'] = '<input type="hidden" name="section" value="' . $row->section . '" />' . $section_name;
    }
    // build the html select list for ordering
    $query = 'SELECT ordering AS value, title AS text' . ' FROM #__categories' . ' WHERE section = ' . $db->Quote($row->section) . ' ORDER BY ordering';
    if ($edit) {
        $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query);
    } else {
        $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $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'] = JHTML::_('list.images', '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
    $published = $row->id ? $row->published : 1;
    $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $published);
    categories_html::edit($row, $lists, $redirect);
}
Пример #2
0
/**
* Compiles information to add or edit a category
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
* @param string The name of the current user
*/
function editCategory($uid = 0, $section = '')
{
    global $database, $my, $mainframe;
    $type = strval(mosGetParam($_REQUEST, 'type', ''));
    $redirect = strval(mosGetParam($_REQUEST, 'section', 'content'));
    // check for existance of any sections
    $query = "SELECT COUNT( id )" . "\n FROM #__sections" . "\n WHERE scope = 'content'";
    $database->setQuery($query);
    $sections = $database->loadResult();
    if (!$sections && $type != 'other') {
        echo "<script> alert('You need to have at least one Section before you can create a Category'); window.history.go(-1); </script>\n";
        exit;
    }
    $row = new mosCategory($database);
    // load the row from the db table
    $row->load((int) $uid);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        mosRedirect('index2.php?option=categories&section=' . $row->section, 'The category ' . $row->title . ' is currently being edited by another administrator');
    }
    $lists['links'] = 0;
    $menus = NULL;
    $selected_folders = NULL;
    if ($uid) {
        // existing record
        $row->checkout($my->id);
        // code for Link Menu
        switch ($row->section) {
            case 'com_weblinks':
                $and = "\n AND type = 'weblink_category_table'";
                $link = 'Table - Weblink Category';
                break;
            case 'com_newsfeeds':
                $and = "\n AND type = 'newsfeed_category_table'";
                $link = 'Table - Newsfeeds Category';
                break;
            case 'com_contact_details':
                $and = "\n AND type = 'contact_category_table'";
                $link = 'Table - Contacts Category';
                break;
            default:
                $and = '';
                $link = '';
                break;
        }
        // content
        if ($row->section > 0) {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . (int) $row->id . "\n AND ( type = 'content_archive_category' OR type = 'content_blog_category' OR type = 'content_category' )";
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                switch ($menus[$i]->type) {
                    case 'content_category':
                        $menus[$i]->type = 'Table - Content Category';
                        break;
                    case 'content_blog_category':
                        $menus[$i]->type = 'Blog - Content Category';
                        break;
                    case 'content_archive_category':
                        $menus[$i]->type = 'Blog - Content Category Archive';
                        break;
                }
            }
            $lists['links'] = 1;
            // handling for MOSImage directories
            if (trim($row->params)) {
                // get params definitions
                $params = new mosParameters($row->params, $mainframe->getPath('com_xml', 'com_categories'), 'component');
                $temps = $params->get('imagefolders', '');
                $temps = explode(',', $temps);
                foreach ($temps as $temp) {
                    $selected_folders[] = mosHTML::makeOption($temp, $temp);
                }
            } else {
                $selected_folders[] = mosHTML::makeOption('*2*');
            }
        } else {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . (int) $row->id . $and;
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                $menus[$i]->type = $link;
            }
            $lists['links'] = 1;
        }
    } else {
        // new record
        $row->section = $section;
        $row->published = 1;
        $menus = NULL;
        // handling for MOSImage directories
        if ($row->section == 'content') {
            $selected_folders[] = mosHTML::makeOption('*2*');
        }
    }
    // make order list
    $order = array();
    $query = "SELECT COUNT(*)" . "\n FROM #__categories" . "\n WHERE section = " . $database->Quote($row->section);
    $database->setQuery($query);
    $max = intval($database->loadResult()) + 1;
    for ($i = 1; $i < $max; $i++) {
        $order[] = mosHTML::makeOption($i);
    }
    // build the html select list for sections
    if ($section == 'content') {
        $query = "SELECT s.id AS value, s.title AS text" . "\n FROM #__sections AS s" . "\n ORDER BY s.ordering";
        $database->setQuery($query);
        $sections = $database->loadObjectList();
        $lists['section'] = mosHTML::selectList($sections, 'section', 'class="inputbox" size="1"', 'value', 'text');
    } else {
        if ($type == 'other') {
            $section_name = 'N/A';
        } else {
            $temp = new mosSection($database);
            $temp->load($row->section);
            $section_name = $temp->name;
        }
        $lists['section'] = '<input type="hidden" name="section" value="' . $row->section . '" />' . $section_name;
    }
    // build the html select list for category types
    $types[] = mosHTML::makeOption('', 'Select Type');
    if ($row->section == 'com_contact_details') {
        $types[] = mosHTML::makeOption('contact_category_table', 'Contact Category Table');
    } else {
        if ($row->section == 'com_newsfeeds') {
            $types[] = mosHTML::makeOption('newsfeed_category_table', 'Newsfeed Category Table');
        } else {
            if ($row->section == 'com_weblinks') {
                $types[] = mosHTML::makeOption('weblink_category_table', 'Weblink Category Table');
            } else {
                $types[] = mosHTML::makeOption('content_category', 'Content Category Table');
                $types[] = mosHTML::makeOption('content_blog_category', 'Content Category Blog');
                $types[] = mosHTML::makeOption('content_archive_category', 'Content Category Archive Blog');
            }
        }
    }
    // if
    $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text');
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__categories" . "\n WHERE section = " . $database->Quote($row->section) . "\n ORDER BY ordering";
    $lists['ordering'] = stripslashes(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'] = mosAdminMenus::Images('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 menu selection
    $lists['menuselect'] = mosAdminMenus::MenuSelect();
    // handling for MOSImage directories
    if ($row->section > 0 || $row->section == 'content') {
        // list of folders in images/stories/
        $imgFiles = recursive_listdir(COM_IMAGE_BASE);
        $len = strlen(COM_IMAGE_BASE);
        $folders[] = mosHTML::makeOption('*2*', 'Use Section settings');
        $folders[] = mosHTML::makeOption('*#*', '---------------------');
        $folders[] = mosHTML::makeOption('*1*', 'All');
        $folders[] = mosHTML::makeOption('*0*', 'None');
        $folders[] = mosHTML::makeOption('*#*', '---------------------');
        $folders[] = mosHTML::makeOption('/');
        foreach ($imgFiles as $file) {
            $folders[] = mosHTML::makeOption(substr($file, $len));
        }
        $lists['folders'] = mosHTML::selectList($folders, 'folders[]', 'class="inputbox" size="17" multiple="multiple"', 'value', 'text', $selected_folders);
    }
    categories_html::edit($row, $lists, $redirect, $menus);
}
Пример #3
0
/**
* Compiles information to add or edit a category
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
* @param string The name of the current user
*/
function editCategory($uid = 0, $section = '')
{
    global $database, $my, $adminLanguage;
    global $mosConfig_absolute_path, $mosConfig_live_site;
    $type = mosGetParam($_REQUEST, 'type', '');
    $redirect = mosGetParam($_POST, 'section', '');
    $row = new mosCategory($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=categories&section=' . $row->section, $adminLanguage->A_COMP_CATEG_MESSAGE . " " . $row->title . " " . $adminLanguage->A_COMP_CATEG_MESSAGE2);
    }
    if ($uid) {
        // existing record
        $row->checkout($my->id);
        // code for Link Menu
        if ($row->section > 0) {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . $row->id . "\n AND ( type = 'content_archive_category' OR type = 'content_blog_category' OR type = 'content_category' )";
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                switch ($menus[$i]->type) {
                    case 'content_category':
                        $menus[$i]->type = $adminLanguage->A_COMP_CATEG_TABLE;
                        break;
                    case 'content_blog_category':
                        $menus[$i]->type = $adminLanguage->A_COMP_CATEG_BLOG;
                        break;
                    case 'content_archive_category':
                        $menus[$i]->type = $adminLanguage->A_COMP_CATEG_BLOG_ARCHIVE;
                        break;
                }
            }
        } else {
            $menus = array();
        }
    } else {
        // new record
        $row->section = $section;
        $row->published = 1;
        $menus = NULL;
    }
    // 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 sections
    if ($section == 'content') {
        $query = "SELECT s.id AS value, s.title AS text" . "\n FROM #__sections AS s" . "\n ORDER BY s.ordering";
        $database->setQuery($query);
        $sections = $database->loadObjectList();
        $lists['section'] = mosHTML::selectList($sections, 'section', 'class="inputbox" size="1"', 'value', 'text');
    } else {
        if ($type == 'other') {
            $section_name = 'N/A';
        } else {
            $temp = new mosSection($database);
            $temp->load($row->section);
            $section_name = $temp->name;
        }
        $lists['section'] = '<input type="hidden" name="section" value="' . $row->section . '" />' . $section_name;
    }
    // build the html select list for category types
    $types[] = mosHTML::makeOption('', $adminLanguage->A_COMP_CATEG_SELECT_TYPE);
    $types[] = mosHTML::makeOption('content_category', $adminLanguage->A_COMP_CATEG_TABLE);
    $types[] = mosHTML::makeOption('content_blog_category', $adminLanguage->A_COMP_CATEG_BLOG);
    $types[] = mosHTML::makeOption('content_archive_category', $adminLanguage->A_COMP_CATEG_BLOG_ARCHIVE);
    $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text');
    // 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'] = mosAdminMenus::Images('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 menu selection
    $lists['menuselect'] = mosAdminMenus::MenuSelect();
    categories_html::edit($row, $section, $lists, $redirect, $menus);
}
Пример #4
0
/**
* Compiles information to add or edit a category
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
* @param string The name of the current user
*/
function editCategory($uid = 0, $section = '')
{
    global $database, $my;
    $type = mosGetParam($_REQUEST, 'type', '');
    $redirect = mosGetParam($_REQUEST, 'section', 'content');
    $row = new mosCategory($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=categories&section=' . $row->section, sprintf(T_('The category %s is currently being edited by another administrator'), $row->title));
    }
    if ($uid) {
        // existing record
        $row->checkout($my->id);
        // code for Link Menu
        if ($row->section > 0) {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . $row->id . "\n AND ( type = 'content_archive_category' OR type = 'content_blog_category' OR type = 'content_category' )";
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                switch ($menus[$i]->type) {
                    case 'content_category':
                        $menus[$i]->type = T_('Category Table');
                        break;
                    case 'content_blog_category':
                        $menus[$i]->type = T_('Category Blog');
                        break;
                    case 'content_archive_category':
                        $menus[$i]->type = T_('Category Blog Archive');
                        break;
                }
            }
        } else {
            $menus = array();
        }
    } else {
        // new record
        $row->section = $section;
        $row->published = 1;
        $menus = NULL;
    }
    // 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 sections
    if ($section == 'content') {
        $query = "SELECT s.id AS value, s.title AS text" . "\n FROM #__sections AS s" . "\n ORDER BY s.ordering";
        $database->setQuery($query);
        $sections = $database->loadObjectList();
        $lists['section'] = mosHTML::selectList($sections, 'section', 'class="inputbox" size="1"', 'value', 'text');
    } else {
        if ($type == 'other') {
            $section_name = 'N/A';
        } else {
            $temp = new mosSection($database);
            $temp->load($row->section);
            $section_name = $temp->name;
        }
        $lists['section'] = '<input type="hidden" name="section" value="' . $row->section . '" />' . $section_name;
    }
    // build the html select list for category types
    $types[] = mosHTML::makeOption('', T_('Select Type'));
    if ($row->section == 'com_contact_details') {
        $types[] = mosHTML::makeOption('contact_category_table', T_('Contact Category Table'));
    } else {
        if ($row->section == 'com_newsfeeds') {
            $types[] = mosHTML::makeOption('newsfeed_category_table', T_('News Feed Category Table'));
        } else {
            if ($row->section == 'com_weblinks') {
                $types[] = mosHTML::makeOption('weblink_category_table', T_('Web Link Category Table'));
            } else {
                $types[] = mosHTML::makeOption('content_category', T_('Content Category Table'));
                $types[] = mosHTML::makeOption('content_blog_category', T_('Content Category Blog'));
                $types[] = mosHTML::makeOption('content_archive_category', T_('Content Category Archive Blog'));
            }
        }
    }
    // if
    $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text');
    // 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'] = mosAdminMenus::Images('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 menu selection
    $lists['menuselect'] = mosAdminMenus::MenuSelect();
    categories_html::edit($row, $lists, $redirect, $menus);
}