Exemplo n.º 1
0
/**
* @param string
* @return string
* Deprecated - use the code within this function instead - not used in Mambo
*/
function mosParseParams($txt)
{
    $pparser = new mosParameters($txt);
    return $pparser->getParams();
}
Exemplo n.º 2
0
/**
* Form for moving item(s) to a specific menu
*/
function moveMenu($option, $cid, $menutype)
{
    global $database;
    if (!is_array($cid) || count($cid) < 1) {
        echo "<script> alert('" . T_('Select an item to move') . "'); window.history.go(-1);</script>\n";
        exit;
    }
    ## query to list selected menu items
    $cids = implode(',', $cid);
    $query = "SELECT a.name FROM #__menu AS a WHERE a.id IN ( " . $cids . " )";
    $database->setQuery($query);
    $items = $database->loadObjectList();
    ## query to choose menu
    $query = "SELECT a.params FROM #__modules AS a WHERE a.module = 'mod_mainmenu' ORDER BY a.title";
    $database->setQuery($query);
    $modules = $database->loadObjectList();
    foreach ($modules as $module) {
        $pparser = new mosParameters($module->params);
        $params = $pparser->getParams();
        // adds menutype to array
        $type = trim(@$params->menutype);
        $menu[] = mosHTML::makeOption($type, $type);
    }
    // build the html select list
    $MenuList = mosHTML::selectList($menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null);
    HTML_menusections::moveMenu($option, $cid, $MenuList, $items, $menutype);
}
Exemplo n.º 3
0
/**
* Copies a complete menu, all its items and creates a new module, using the name speified
*/
function copyMenu($option, $cid, $type)
{
    global $database;
    $menu_name = mosGetParam($_POST, 'menu_name', 'New Menu');
    $module_name = mosGetParam($_POST, 'module_name', 'New Module');
    // check for unique menutype for new menu copy
    $query = "SELECT params" . "\n FROM #__modules" . "\n WHERE module = 'mod_mainmenu'";
    $database->setQuery($query);
    $menus = $database->loadResultArray();
    foreach ($menus as $menu) {
        $pparser = new mosParameters($menu);
        $params = $pparser->getParams();
        if ($params->menutype == $menu_name) {
            echo "<script> alert('" . T_('A menu with that name already exists - you must enter a unique Menu Name') . "'); window.history.go(-1); </script>\n";
            exit;
        }
    }
    // copy the menu items
    $mids = mosGetParam($_POST, 'mids', '');
    $total = count($mids);
    $copy = new mosMenu($database);
    $original = new mosMenu($database);
    sort($mids);
    $a_ids = array();
    foreach ($mids as $mid) {
        $original->load($mid);
        $copy = $original;
        $copy->id = NULL;
        $copy->parent = $a_ids[$original->parent];
        $copy->menutype = $menu_name;
        if (!$copy->check()) {
            echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$copy->store()) {
            echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $a_ids[$original->id] = $copy->id;
    }
    // create the module copy
    $row = new mosModule($database);
    $row->load(0);
    $row->title = $module_name;
    $row->iscore = 0;
    $row->published = 1;
    $row->position = 'left';
    $row->module = 'mod_mainmenu';
    $row->params = 'menutype=' . $menu_name;
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    $row->updateOrder("position='" . $row->position . "'");
    // module assigned to show on All pages by default
    // ToDO: Changed to become a mambo db-object
    $query = "INSERT INTO #__modules_menu VALUES ( {$row->id}, 0 )";
    $database->setQuery($query);
    if (!$database->query()) {
        echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $msg = sprintf(Tn_('Copy of Menu `%s` created, consisting of %d item', 'Copy of Menu `%s` created, consisting of %d items', $total), $type, $total);
    mosRedirect('index2.php?option=' . $option, $msg);
}