function dt_block_categories($options) { include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtcategory.class.php'; $rmu = RMUtilities::get(); $rmf = RMFunctions::get(); $mc = $rmu->module_config('dtransport'); $url = $rmf->current_url(); $rpath = parse_url($url); $xpath = parse_url(XOOPS_URL); if ($mc['permalinks']) { $params = trim(str_replace($xpath['path'] . '/' . trim($mc['htbase'], '/'), '', rtrim($rpath['path'], "/")), '/'); $search = array('category', 'publisher', 'recents', 'popular', 'rated', 'updated'); if ($params == '') { $params = array(); } else { $params = explode("/", trim($params)); } if (!empty($params) && $params[0] == 'category') { $db = XoopsDatabaseFactory::getDatabaseConnection(); $params = explode("page", implode("/", array_slice($params, 1))); $path = explode("/", $params[0]); foreach ($path as $k) { if ($k == '') { continue; } $category = new DTCategory(); $sql = "SELECT * FROM " . $db->prefix("dtrans_categos") . " WHERE nameid='{$k}' AND parent='{$idp}'"; $result = $db->query($sql); if ($db->getRowsNum($result) > 0) { $row = $db->fetchArray($result); $idp = $row['id_cat']; $category->assignVars($row); } else { $dtfunc->error_404(); } } } else { $category = new DTCategory(); } } $tpl = RMTemplate::get(); $tpl->add_xoops_style('blocks.css', 'dtransport'); include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtfunctions.class.php'; $categories = array(); $dtfunc = new DTFunctions(); $dtfunc->getCategos($categories, 0, $category->id(), array(), false, 1); $block = array(); foreach ($categories as $cat) { if ($cat['jumps'] > $options[0] - 1 && $options[0] > 0) { continue; } $block['categories'][] = $cat; } if (!$category->isNew()) { $block['parent'] = array('name' => $category->name(), 'link' => $category->permalink()); } return $block; }
/** * @desc Visualiza todas las licencias existentes **/ function showLicences() { global $xoopsModule, $xoopsSecurity; $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix('dtrans_licences'); $result = $db->queryF($sql); $licences = array(); while ($rows = $db->fetchArray($result)) { $lc = new DTLicense(); $lc->assignVars($rows); $licences[] = array('id' => $lc->id(), 'name' => $lc->name(), 'url' => $lc->link(), 'type' => $lc->type()); } RMTemplate::get()->add_xoops_style('admin.css', 'dtransport'); RMTemplate::get()->add_local_script('jquery.validate.min.js', 'rmcommon', 'include'); RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include'); RMTemplate::get()->add_local_script('admin.js', 'dtransport'); RMTemplate::get()->add_head('<script type="text/javascript"> var dt_message = "' . __('Do you really want to delete selected licenses', 'dtransport') . '"; var dt_select_message = "' . __('Select at least one licence to delete!', 'dtransport') . '"; </script>'); DTFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . __('Licences Management', 'dtransport')); xoops_cp_header(); include RMTemplate::get()->get_template('admin/dtrans_licenses.php', 'module', 'dtransport'); xoops_cp_footer(); }
/** * @desc Formulario de Logs **/ function dt_form_logs($edit = 0) { global $xoopsModule, $xoopsConfig; define('RMCSUBLOCATION', 'newlog'); $id = rmc_server_var($_GET, 'id', 0); $item = rmc_server_var($_GET, 'item', 0); //Verificamos si el software es válido if ($item <= 0) { redirectMsg('items.php', __('Download item ID has not been provided!', 'dtransport'), RMMSG_WARN); } //Verificamos si existe el software $sw = new DTSoftware($item); if ($sw->isNew()) { redirectMsg('items.php', __('Specified download item does not exists!', 'dtransport'), 1); } if ($edit) { //Verificamos si log es válido if ($id <= 0) { redirectMsg('logs.php?item=' . $item, __('Log item ID has not been provided!', 'dtransport'), RMMSG_WARN); } //Verificamos si log existe $log = new DTLog($id); if ($log->isNew()) { redirectMsg('logs.php?item=' . $item, __('Specified item log does not exists!', 'dtranport'), 1); } } $dtf = new DTFunctions(); $dtf->toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='./items.php'>" . sprintf(__('"%s" Logs', 'dtransport'), $sw->getVar('name')) . "</a> » " . ($edit ? __('Edit Log', 'dtransport') : __('New Log', 'dtransport'))); xoops_cp_header(); $form = new RMForm($edit ? sprintf(__('Edit Change Log of "%s"', 'dtransport'), $sw->getVar('name')) : sprintf(__('New Log for "%s"', 'dtransport'), $sw->getVar('name')), 'frmlog', 'logs.php'); $form->addElement(new RMFormLabel(__('Download Item', 'dtransport'), $sw->getVar('name'))); $form->addElement(new RMFormText(__('Log title', 'dtransport'), 'title', 50, 100, $edit ? $log->title() : ''), true); $form->addElement(new RMFormEditor(__('Log content', 'dtransport'), 'log', '90%', '350px', $edit ? $log->getVar('log', 'e') : ''), true); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('item', $item)); $form->addElement(new RMFormHidden('id', $id)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', _SUBMIT, 'submit'); $buttons->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'logs.php?item=' . $item . '\';"'); $form->addElement($buttons); $form->display(); xoops_cp_footer(); }
/** * @desc Formulario de creación/edición de categorías **/ function formCategos($edit = 0) { global $xoopsModule, $db; $id = rmc_server_var($_GET, 'id', 0); if ($edit) { //Verificamos si categoría es válida if ($id <= 0) { redirectMsg('categories.php', __('Specified category is not valid!', 'dtransport'), 1); } //Verificamos si la categoría existe $cat = new DTCategory($id); if ($cat->isNew()) { redirectMsg('categories.php', __('Specified category does not exists!', 'dtransport'), 1); } } DTFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . ($edit ? __('Edit category', 'dtransport') : __('New category', 'dtransport'))); xoops_cp_header(); $form = new RMForm($edit ? __('Edit Category', 'dtransport') : __('New Category', 'dtransport'), 'frmcat', 'categories.php'); $form->addElement(new RMFormText(__('Category name', 'dtransport'), 'name', 50, 150, $edit ? $cat->name() : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Category short name', 'dtransport'), 'nameid', 50, 150, $edit ? $cat->nameId() : '')); } $form->addElement(new RMFormTextArea(__('Description', 'dtransport'), 'desc', 5, 40, $edit ? $cat->desc('e') : '')); //Lista de categorías $ele = new RMFormSelect(__('Root category', 'dtransport'), 'parent'); $ele->addOption(0, __('Select category...', 'dtransport')); $categos = array(); DTFunctions::getCategos($categos, 0, 0, $edit ? $cat->id() : array()); foreach ($categos as $catego) { $ele->addOption($catego['id_cat'], str_repeat('--', $catego['jumps']) . ' ' . $catego['name'], $edit ? $catego['id_cat'] == $cat->parent() ? 1 : 0 : 0); } $form->addElement($ele); $form->addElement(new RMFormYesno(__('Active category', 'dtransport'), 'active', $edit ? $cat->active() : 1)); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', __('Submit', 'dtransport'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'dtransport'), 'button', 'onclick="window.location=\'categories.php\';"'); $form->addElement($buttons); $form->display(); xoops_cp_footer(); }
/** * @desc Visualiza las plataformas existentes y muestra formulario de plataformas **/ function showPlatforms($edit = 0) { global $xoopsSecurity, $xoopsModule; $id = rmc_server_var($_REQUEST, 'id', 0); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix('dtrans_platforms'); $result = $db->queryF($sql); $platforms = array(); while ($rows = $db->fetchArray($result)) { $plat = new DTPlatform(); $plat->assignVars($rows); $platforms[] = array('id' => $plat->id(), 'name' => $plat->name()); } if ($edit) { //Verificamos si plataforma es válida if ($id <= 0) { redirectMsg('platforms.php', __('You must specified a valid platform ID!', 'dtransport'), 1); die; } //Verificamos si plataforma existe $plat = new DTPlatform($id); if ($plat->isNew()) { redirectMsg('platforms.php', __('Sepecified platform does not exists!', 'dtransport'), 1); die; } } RMTemplate::get()->add_xoops_style('admin.css', 'dtransport'); RMTemplate::get()->add_local_script('jquery.validate.min.js', 'rmcommon', 'include'); RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include'); RMTemplate::get()->add_local_script('admin.js', 'dtransport'); RMTemplate::get()->add_head('<script type="text/javascript"> var dt_message = "' . __('Do you really want to delete selected platforms', 'dtransport') . '"; var dt_select_message = "' . __('Select at least one platform to delete!', 'dtransport') . '"; </script>'); DTFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . ($edit ? __('Edit Platform', 'dtransport') : __('New Platform', 'dtransport'))); xoops_cp_header(); include RMTemplate::get()->get_template('admin/dtrans_platforms.php', 'module', 'dtransport'); xoops_cp_footer(); }
function dt_block_items_edit($options) { include_once RMCPATH . '/class/form.class.php'; include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtcategory.class.php'; include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtfunctions.class.php'; $dtfunc = new DTFunctions(); $elements = array(); $ele = new RMFormSelect(__('Donwloads type', 'dtransport'), 'options[0]', 0, array($options[0])); $ele->addOption('all', __('All downloads', 'dtransport')); $ele->addOption('recent', __('Recent downloads', 'dtransport')); $ele->addOption('popular', __('Popular downloads', 'dtransport')); $ele->addOption('rated', __('Best rated downloads', 'dtransport')); $ele->addOption('featured', __('Featured download', 'dtransport')); $ele->addOption('daily', __('Daily downloads', 'dtransport')); $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render()); // Categoría include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtfunctions.class.php'; $categos = array(); $dtfunc->getCategos($categos, 0, 0, array(), false, 1); $ele = new RMFormSelect(__('Downloads from category', 'dtransport'), 'options[1]', false, $options[1]); $ele->addOption(0, __('All categories', 'dtransport')); foreach ($categos as $cat) { $ele->addOption($cat['id_cat'], str_repeat("—", $cat['jumps']) . ' ' . $cat['name']); } $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render()); // Numero de Descargas $ele = new RMFormText(__('Items limit', 'dtransport'), 'options[2]', 5, 2, $options[2]); $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render()); // Mostrar imágen $ele = new RMFormYesNo(__('Show image', 'dtransport'), 'options[3]', $options[3]); $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render()); // Tamaño de imágen utilizado $ele = new RMFormText(__('Image size', 'dtransport'), 'options[11]', 20, 100, $options[11]); $ele->setDescription(__('This name must match with a size configured previously in image manager.', 'dtransport')); $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render()); // Mostrar Descripción $ele = new RMFormYesNo(__('Show description', 'dtransport'), 'options[4]', $options[4]); $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render()); // Mostrar Hits $ele = new RMFormYesNo(__('Show hits', 'dtransport'), 'options[5]', $options[5]); $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render()); // Mostrar Ratig de Usuarios $ele = new RMFormYesNo(__('Show user rating', 'dtransport'), 'options[6]', $options[6]); $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render()); // Mostrar Rating del Sitio $ele = new RMFormYesNo(__('Show site rating', 'dtransport'), 'options[7]', $options[7]); $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render()); // Mostrar Enlace de descarga $ele = new RMFormYesNo(__('Show download link', 'dtransport'), 'options[8]', $options[8]); $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render()); // Mostrar Nombre de Usuario $ele = new RMFormYesNo(__('Show author', 'dtransport'), 'options[9]', $options[9]); $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render()); // Descargas de usuario $ele = new RMFormText(__('Show downloads from a single user', 'dtransport'), 'options[10]', 10, 100, $options[10]); $ele->setDescription(__('You can specify a user name or a integer id of the user.', 'dtransport')); $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render(), 'description' => $ele->getDescription()); $form = '<table class="outer">'; foreach ($elements as $ele) { $form .= '<tr><td>' . $ele['title'] . ($ele['description'] != '' ? '<span class="description">' . $ele['description'] . '</span>' : '') . '</td><td>' . $ele['content'] . '</td></tr>'; } $form .= '</table>'; return $form; }
// $Id$ // -------------------------------------------------------------- // D-Transport // Manage files for download in XOOPS // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- require '../../mainfile.php'; //include 'header.php'; $mc = $xoopsModuleConfig; // Constantes del Módulo define('DT_PATH', XOOPS_ROOT_PATH . '/modules/dtransport'); define('DT_URL', $mc['permalinks'] ? XOOPS_URL . '/' . trim($mc['htbase'], "/") : XOOPS_URL . '/modules/dtransport'); // Xoops Module Header $dtfunc = new DTFunctions(); $rmf = RMFunctions::get(); $rmu = RMUtilities::get(); $url = $rmf->current_url(); $rpath = parse_url($url); $xpath = parse_url(XOOPS_URL); // Comprobar si el host es correcto if ($rpath['host'] != $xpath['host']) { /** * @todo Agregar header 303 */ header("location: " . DT_URL); die; } if (substr($rpath['path'], 0, strlen($xpath['path'])) != $xpath['path']) { $dtfunc->error_404();
public function permalink() { $util = RMUtilities::get(); $mc = $util->module_config('dtransport'); if (!$mc['permalinks']) { return XOOPS_URL . '/modules/dtransport/category.php?id=' . $this->id(); } if ($this->parent() <= 0) { return XOOPS_URL . '/' . trim($mc['htbase'], '/') . '/category/' . $this->nameId() . '/'; } $func = new DTFunctions(); $path[] = $this->nameId(); $path = array_merge($path, $func->category_path($this->parent())); $path = array_reverse($path, true); return XOOPS_URL . '/' . trim($mc['htbase'], '/') . '/category/' . implode("/", $path) . '/'; }
/** * @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(); }
/** * @desc Formulario de archivos **/ function formFiles($edit = 0) { global $tpl, $xoopsModule, $xoopsModuleConfig, $xoopsUser, $xoopsSecurity; define("RMCSUBLOCATION", 'newfile'); $id = rmc_server_var($_GET, 'id', 0); $item = rmc_server_var($_GET, 'item', 0); //Verificamos si el software es válido if ($item <= 0) { redirectMsg('files.php', __('No download item ID has been provided!', 'dtransport'), RMMSG_WARN); } //Verificamos si existe el software $sw = new DTSoftware($item); if ($sw->isNew()) { redirectMsg('files.php', __('Specified download item does not exists!', 'dtransport'), RMMSG_ERROR); } $file_exists = true; if ($edit) { //Verificamos si archivo es válido if ($id <= 0) { redirectMsg('./files.php?item=' . $item, __('No file ID has been specified!', 'dtransport'), RMMSG_WARN); } //Verificamos si existe archivo $fl = new DTFile($id); if ($fl->isNew()) { redirectMsg('files.php?item=' . $item, __('Specified file does not exists!', 'dtransport'), RMMSG_ERROR); } if ($sw->getVar('secure')) { $dir = $xoopsModuleConfig['directory_secure']; } else { $dir = $xoopsModuleConfig['directory_insecure']; } if (!$fl->remote()) { if (!is_file($dir . '/' . $fl->file())) { $file_exists = false; showMessage(sprintf(__('File %s does not exists! You need to upload this file again.', 'dtransport'), $dir . '/' . $fl->file()), RMMSG_WARN); } } } xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='items.php'>" . $sw->getVar('name') . "</a> » <a href='files.php?item=" . $sw->id() . "'>" . __('Files', 'dtransport') . "</a> » " . ($edit ? __('Edit file', 'dtransport') : __('New file', 'dtransport'))); $tpl->assign('xoops_pagetitle', $xoopsModule->name() . " » " . $sw->getVar('name') . " » " . __('Files', 'dtransport') . " » " . ($edit ? __('Edit file', 'dtransport') : __('New file', 'dtransport'))); $db = XoopsDatabaseFactory::getDatabaseConnection(); $func = new DTFunctions(); $func->toolbar(); $rmf = RMFunctions::get(); $rmu = RMUtilities::get(); // Uploader $tc = TextCleaner::getInstance(); $uploader = new RMFlashUploader('dtfiles-uploader', DT_URL . '/ajax/upload.php'); $token = $xoopsSecurity->createToken(); $uploader->add_setting('onUploadStart', 'function(file){ $("#dtfiles-uploader").uploadify("settings", "formData", { action: "upload", item: $("#item").val(), XOOPS_TOKEN_REQUEST: $("#XOOPS_TOKEN_REQUEST").val(), data: "' . $tc->encrypt($_SERVER['HTTP_USER_AGENT'] . '|' . session_id() . '|' . $xoopsUser->uid() . '|' . $rmf->current_url()) . '" }); }'); $uploader->add_setting('multi', false); $uploader->add_setting('fileExt', '*.' . implode(";*.", $xoopsModuleConfig['type_file'])); $uploader->add_setting('fileDesc', sprintf(__('Allowed files (%s)', 'dtransport'), implode(";*.", $xoopsModuleConfig['type_file']) . ')')); $uploader->add_setting('sizeLimit', $xoopsModuleConfig['size_file'] * 1024 * 1024); $uploader->add_setting('buttonText', __('Select File...', 'rmcommon')); $uploader->add_setting('queueSizeLimit', 1); $uploader->add_setting('auto', true); $uploader->add_setting('onUploadSuccess', "function(file, resp, data){\n eval('ret = '+resp);\n if (ret.error==1){\n \$('.dt-errors').html(ret.message).slideDown('fast');\n upload_error = 1;\n } else {\n upload_error = 0;\n getFilesToken();\n \$('#dtfiles-preview .name').html(ret.file);\n \$('#dtfiles-preview .size').html(ret.size);\n \$('#size').val(ret.fullsize);\n \$('#dtfiles-preview .type').html(ret.type);\n \$('#dtfiles-preview .secure').html(ret.secure);\n }\n return true;\n }"); $uploader->add_setting('onQueueComplete', "function(event, data){\n if(upload_error==1) return;\n \$('.dt-errors').slideUp('fast');\n \$('#dtfiles-uploader').fadeOut('fast');\n \$('#dtfiles-preview').fadeIn('fast');\n }"); $uploader->add_setting('onSelectOnce', "function(event, data){\n \$('#upload-errors').html('');\n }"); if ($edit && $file_exists) { $uploader->add_setting('onInit', 'function(instance){ $("#dtfiles-uploader").hide(); }'); } $groups = array(); //Lista de grupos $sql = "SELECT * FROM " . $db->prefix('dtrans_groups') . " WHERE id_soft={$item}"; $result = $db->queryF($sql); while ($rows = $db->fetchArray($result)) { $group = new DTFileGroup(); $group->assignVars($rows); $groups[] = array('id' => $group->id(), 'name' => $group->name()); } $tpl->add_head($uploader->render()); $tpl->add_style('admin.css', 'dtransport'); $tpl->add_style('files.css', 'dtransport'); $tpl->add_local_script('admin.js', 'dtransport'); $tpl->add_local_script('files.js', 'dtransport'); $tpl->add_head_script('var upload_error = 0;'); include DT_PATH . '/include/js_strings.php'; xoops_cp_header(); include $tpl->get_template("admin/dtrans_filesform.php", 'module', 'dtransport'); xoops_cp_footer(); }
function dt_delete_screen() { global $xoopsSecurity, $xoopsConfig, $xoopsModule, $xoopsUser; $rmf = RMFunctions::get(); $xoopsModule = $rmf->load_module('dtransport'); include_once '../../../include/cp_header.php'; $func = new DTFunctions(); if (!$xoopsSecurity->check()) { $func->dt_send_message(__('Session token not valid!', 'dtransport'), 1, 0); } $id = rmc_server_var($_POST, 'id', 0); $sc = new DTScreenshot($id); if ($sc->isNew()) { $func->dt_send_message(__('Specified screenshot does not exists!', 'dtransport'), 1, 1); } if (!$sc->delete()) { $func->dt_send_message(__('Screenshot could not be deleted!', 'dtransport') . '<br />' . $sc->errors(), 1, 1); } $ret = array('id' => $sc->id()); $func->dt_send_message($ret, 0, 1); }
/** * @desc Genera un array con los datos de un elemento específico * @param object {@link DTSoftware()} * @return array */ public function createItemData(DTSoftware &$item) { global $mc, $xoopsUser; if (!$mc) { $mc = RMUtilities::module_config('dtransport'); } $rmfunc = RMFunctions::get(); $data = array(); $data['link'] = $item->permalink(); // Vinculo para detalles $data['dlink'] = $item->permalink(0, 'download'); // Vinculo de descarga $data['id'] = $item->id(); $data['name'] = $item->getVar('name'); $data['description'] = $item->getVar('shortdesc'); $data['votes'] = $item->getVar('votes'); $data['comments'] = $item->getVar('comments'); $data['siterate'] = DTFunctions::ratingStars($item->getVar('siterate')); $data['rating'] = @number_format($item->getVar('rating') / $item->getVar('votes'), 1); $data['language'] = $item->getVar('langs'); // Image $img = new RMImage(); $img->load_from_params($item->getVar('image')); $data['image'] = $img->get_smallest(); $data['created'] = formatTimestamp($item->getVar('created'), 's'); if ($item->getVar('created') < $item->getVar('modified')) { $data['modified'] = formatTimestamp($item->getVar('modified'), 's'); } $data['is_new'] = $item->getVar('created') > time() - $mc['new'] * 86400; $data['is_updated'] = $data['is_new'] ? false : $item->getVar('modified') > time() - $mc['update'] * 86400; $data['approved'] = $item->getVar('approved'); $data['downs'] = $item->getVar('hits'); $data['screens'] = $item->getVar('screens'); $data['featured'] = $item->getVar('featured'); $data['nameid'] = $item->getVar('nameid'); $data['candownload'] = $item->canDownload($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS); // Licencias $data['lics'] = ''; foreach ($item->licences(true) as $lic) { $data['lics'] .= $data['lics'] == '' ? '<a href="' . $lic->link() . '" target="_blank">' . $lic->name() . '</a>' : ', <a href="' . $lic->link() . '" target="_blank">' . $lic->name() . '</a>'; } // Plataformas $data['os'] = ''; foreach ($item->platforms(true) as $os) { $data['os'] .= $data['os'] == '' ? $os->name() : ', ' . $os->name(); } $data['metas'] = $this->get_metas('down', $item->id()); return $data; }