Exemple #1
0
/**
* Form for copying item(s) to a specific menu
*/
function copyCategorySelect($option, $cid, $sectionOld)
{
    global $database;
    global $adminLanguage;
    $redirect = mosGetParam($_POST, 'section', 'content');
    if (!is_array($cid) || count($cid) < 1) {
        echo "<script> alert('" . $adminLanguage->A_COMP_CATEG_ITEM_MOVE . "'); window.history.go(-1);</script>\n";
        exit;
    }
    ## query to list selected categories
    $cids = implode(',', $cid);
    $query = "SELECT a.name, a.section FROM #__categories AS a WHERE a.id IN ( " . $cids . " )";
    $database->setQuery($query);
    $items = $database->loadObjectList();
    ## query to list items from categories
    $query = "SELECT a.title, a.id FROM #__content AS a WHERE a.catid IN ( " . $cids . " ) ORDER BY a.catid, a.title";
    $database->setQuery($query);
    $contents = $database->loadObjectList();
    ## query to choose section to move to
    $query = "SELECT a.name AS `text`, a.id AS `value` FROM #__sections AS a WHERE a.published = '1' ORDER BY a.name";
    $database->setQuery($query);
    $sections = $database->loadObjectList();
    // build the html select list
    $SectionList = mosHTML::selectList($sections, 'sectionmove', 'class="inputbox" size="10"', 'value', 'text', null);
    categories_html::copyCategorySelect($option, $cid, $SectionList, $items, $sectionOld, $contents, $redirect);
}
/**
* Form for copying item(s) to a specific menu
*/
function copyCategorySelect($option, $cid, $sectionOld)
{
    global $mainframe;
    // Check for request forgeries
    JRequest::checkToken() or die('Invalid Token');
    $db =& JFactory::getDBO();
    $redirect = JRequest::getCmd('section', 'com_content', 'post');
    JArrayHelper::toInteger($cid);
    if (count($cid) < 1) {
        JError::raiseError(500, JText::_('Select an item to move', true));
    }
    ## query to list selected categories
    $cids = implode(',', $cid);
    $query = 'SELECT a.title, a.section' . ' FROM #__categories AS a' . ' WHERE a.id IN ( ' . $cids . ' )';
    $db->setQuery($query);
    $items = $db->loadObjectList();
    ## query to list items from categories
    $query = 'SELECT a.title, a.id' . ' FROM #__content AS a' . ' WHERE a.catid IN ( ' . $cids . ' )' . ' ORDER BY a.catid, a.title';
    $db->setQuery($query);
    $contents = $db->loadObjectList();
    ## query to choose section to move to
    $query = 'SELECT a.title AS `text`, a.id AS `value`' . ' FROM #__sections AS a' . ' WHERE a.published = 1' . ' ORDER BY a.name';
    $db->setQuery($query);
    $sections = $db->loadObjectList();
    // build the html select list
    $SectionList = JHTML::_('select.genericlist', $sections, 'sectionmove', 'class="inputbox" size="10"', 'value', 'text', null);
    categories_html::copyCategorySelect($option, $cid, $SectionList, $items, $sectionOld, $contents, $redirect);
}
/**
* Form for copying item(s) to a specific menu
*/
function copyCategorySelect($option, $cid, $sectionOld)
{
    global $database;
    $redirect = mosGetParam($_POST, 'section', 'content');
    if (!is_array($cid) || count($cid) < 1) {
        echo "<script> alert('Select an item to move'); window.history.go(-1);</script>\n";
        exit;
    }
    ## query to list selected categories
    mosArrayToInts($cid);
    $cids = 'a.id=' . implode(' OR a.id=', $cid);
    $query = "SELECT a.name, a.section" . "\n FROM #__categories AS a" . "\n WHERE ( {$cids} )";
    $database->setQuery($query);
    $items = $database->loadObjectList();
    ## query to list items from categories
    // mosArrayToInts( $cid ); // Just done a few lines earlier
    $cids = 'a.catid=' . implode(' OR a.catid=', $cid);
    $query = "SELECT a.title, a.id" . "\n FROM #__content AS a" . "\n WHERE ( {$cids} )" . "\n ORDER BY a.catid, a.title";
    $database->setQuery($query);
    $contents = $database->loadObjectList();
    ## query to choose section to move to
    $query = "SELECT a.name AS `text`, a.id AS `value`" . "\n FROM #__sections AS a" . "\n WHERE a.published = 1" . "\n ORDER BY a.name";
    $database->setQuery($query);
    $sections = $database->loadObjectList();
    // build the html select list
    $SectionList = mosHTML::selectList($sections, 'sectionmove', 'class="inputbox" size="10"', 'value', 'text', null);
    categories_html::copyCategorySelect($option, $cid, $SectionList, $items, $sectionOld, $contents, $redirect);
}