Пример #1
0
/**
* @desc Formulario de Elementos
**/
function formItems($edit = 0)
{
    global $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $rmc_config, $xoopsSecurity, $functions;
    define('RMCSUBLOCATION', 'newitem');
    // Get layout data
    $id = intval(rmc_server_var($_REQUEST, 'id', 0));
    $page = intval(rmc_server_var($_REQUEST, 'page', 0));
    $search = rmc_server_var($_REQUEST, 'search', '');
    $sort = rmc_server_var($_REQUEST, 'sort', 'id_soft');
    $mode = intval(rmc_server_var($_REQUEST, 'mode', 0));
    $catid = intval(rmc_server_var($_REQUEST, 'car', 0));
    $type = rmc_server_var($_REQUEST, 'type', '');
    $ev = RMEvents::get();
    $params = '?page=' . $page . '&search=' . $search . '&sort=' . $sort . '&mode=' . $mode . '&cat=' . $catid . '&type=' . $type;
    if ($edit) {
        //Verificamos que el software sea válido
        if ($id <= 0) {
            redirectMsg('items.php' . $params, __('Download item has not been specified!', 'dtransport'), 1);
            die;
        }
        //Verificamos que el software exista
        if ($type == 'edit') {
            $sw = new DTSoftwareEdited($id);
            $location = __('Verifying edited item!', 'dtransport');
        } else {
            $sw = new DTSoftware($id);
            $location = __('Editing download item', 'dtransport');
        }
        if ($sw->isNew()) {
            redirectMsg('./items.php' . $params, __('Specified download item does not exists!', 'dtransport'), 1);
            die;
        }
    } else {
        $sw = new DTSoftware();
        $location = __('New Download Item', 'dtransport');
    }
    $form = new RMForm('', '', '');
    $ed = new RMFormEditor('', 'desc', '99%', '300px', $edit ? $sw->getVar('desc', $rmc_config['editor_type'] != 'tiny' ? 'e' : 's') : '', $rmc_config['editor_type']);
    $ed->addClass('required');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Lista de categorías
    $categos = array();
    $swcats = $sw->categories();
    DTFunctions::getCategos($categos, 0, 0, array(), false);
    foreach ($categos as $row) {
        $cat = new DTCategory();
        $cat->assignVars($row);
        $categories[] = array('id' => $cat->id(), 'name' => $cat->name(), 'parent' => $cat->parent(), 'active' => $cat->active(), 'description' => $cat->desc(), 'indent' => $row['jumps'], 'selected' => $edit ? in_array($cat->id(), $swcats) : '');
    }
    unset($categos);
    // Licencias
    $sql = "SELECT * FROM " . $db->prefix('dtrans_licences');
    $result = $db->queryF($sql);
    $lics = array();
    $lics[] = array('id' => 0, 'name' => __('Other license', 'dtransport'), 'selected' => !$edit || in_array(0, $sw->licences()) ? 1 : 0);
    while ($row = $db->fetchArray($result)) {
        $lic = new DTLicense();
        $lic->assignVars($row);
        $lics[] = array('id' => $lic->id(), 'name' => $lic->name(), 'selected' => $edit ? in_array($lic->id(), $sw->licences()) : '');
    }
    unset($lic);
    // Plataformas
    $sql = "SELECT * FROM " . $db->prefix('dtrans_platforms');
    $result = $db->queryF($sql);
    $oss = array();
    $oss[] = array('id' => 0, 'name' => __('Other platform', 'dtransport'), 'selected' => !$edit || in_array(0, $sw->platforms()) ? 1 : 0);
    while ($row = $db->fetchArray($result)) {
        $os = new DTPlatform();
        $os->assignVars($row);
        $oss[] = array('id' => $os->id(), 'name' => $os->name(), 'selected' => $edit ? in_array($os->id(), $sw->platforms()) : '');
    }
    unset($os);
    // Allowed groups
    $field = new RMFormGroups('', 'groups', 1, 1, 1, $edit ? $sw->getVar('groups') : array(1, 2));
    $groups = $field->render();
    // Tags
    $ftags = $sw->tags(true);
    $tags = array();
    foreach ($ftags as $tag) {
        $tags[] = $tag->getVar('tag');
    }
    unset($ftags);
    RMTemplate::get()->add_style('admin.css', 'dtransport');
    RMTemplate::get()->add_style('items.css', 'dtransport');
    RMTemplate::get()->add_local_script('itemsform.js', 'dtransport');
    RMTemplate::get()->add_local_script('jquery.validate.min.js', 'rmcommon', 'include');
    include DT_PATH . '/include/js_strings.php';
    DTFunctions::toolbar();
    xoops_cp_location($location);
    xoops_cp_header();
    include RMTemplate::get()->get_template('admin/dtrans_formitems.php', 'module', 'dtransport');
    xoops_cp_footer();
}
Пример #2
0
/**
* @desc Elimina la plataforma especificada
**/
function deletePlatforms()
{
    global $xoopsModule, $xoopsSecurity;
    $ids = rmc_server_var($_POST, 'ids', array());
    //Verificamos si nos proporcionaron alguna plataforma
    if (!is_array($ids) || empty($ids)) {
        redirectMsg('platforms.php', __('You must select at least one platform to delete!', 'dtransport'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('platforms.php', __('Session token expired', 'dtransport'), 1);
        die;
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si la plataforma es válida
        if ($k <= 0) {
            $errors .= sprintf(__('Invalid platform ID: %s', 'dtransport'), $k);
            continue;
        }
        //Verificamos si la plataforma existe
        $plat = new DTPlatform($k);
        if ($plat->isNew()) {
            $errors .= sprintf(__('Does nto exists platform with ID %s', 'dtransport'), $k);
            continue;
        }
        if (!$plat->delete()) {
            $errors .= sprintf(__('Platform "%s" could not be deleted!', 'dtransport'), $plat->name());
        }
    }
    if ($errors != '') {
        redirectMsg('platforms.php', __('Errors ocurred while trying to delete platforms:', 'dtransport') . '<br />' . $errors, 1);
    } else {
        redirectMsg('platforms.php', __('Platforms deleted successfully!', 'dtransport'), 0);
    }
}
Пример #3
0
$start = $num <= 0 ? 0 : $p * $limit;
$nav = new RMPageNav($num, $limit, $page);
$nav->target_url(DT_URL . ($mc['permalinks'] ? '/platform/' . $os->nameId() . '/page/{PAGE_NUM}/' : '/?p=platform&amp;os=' . $os->id() . '&amp;page={PAGE_NUM}'));
$xoopsTpl->assign('pagenav', $nav->render(true));
// Seleccionamos los registros
$sql = str_replace('COUNT(*)', 'b.*', $sql);
$sql .= " ORDER BY created DESC";
$sql .= " LIMIT {$start}, {$limit}";
$result = $db->query($sql);
while ($row = $db->fetchArray($result)) {
    $item = new DTSoftware();
    $item->assignVars($row);
    $xoopsTpl->append('download_items', $dtfunc->createItemData($item));
}
// Datos de la etiqueta
$xoopsTpl->assign('platform', array('id' => $os->id(), 'name' => $os->name(), 'link' => $os->permalink()));
$tpl->add_xoops_style('main.css', 'dtransport');
$dtfunc->makeHeader();
$xoopsTpl->assign('xoops_pagetitle', sprintf(__('Downloads for %s', 'dtransport'), $os->name()));
if ($mc['inner_dest_download']) {
    $xoopsTpl->assign('featured_items', $dtfunc->items_by(array($os->id()), 'platforms', 0, 'featured', 0, $mc['limit_destdown']));
    $xoopsTpl->assign('lang_incatego', __('In <a href="%s">%s</a>', 'dtransport'));
    $xoopsTpl->assign('lang_featured', __('<strong>Featured</strong> Downloads', 'dtransport'));
}
// Descargas el día
if ($mc['inner_daydownload']) {
    $xoopsTpl->assign('daily_items', $dtfunc->items_by($os->id(), 'platforms', 0, 'daily', 0, $mc['limit_daydownload']));
    $xoopsTpl->assign('daily_width', floor(100 / $mc['limit_daydownload']));
    $xoopsTpl->assign('lang_daydown', __('<strong>Day</strong> Downloads', 'dtransport'));
}
$xoopsTpl->assign('lang_download', __('Download', 'dtransport'));