/** * @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 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; }
require 'files.php'; switch ($op) { case 'save': dt_save_file($file > 0 ? 1 : 0); break; case 'delete': dt_delete_file(); break; default: dt_show_files($op == 'edit' && $file > 0 ? 1 : 0); break; } break; case 'delete': $item->setVar('delete', 1); $item->licences(); $item->tags(); $item->categories(); $item->platforms(); if ($item->save()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/' : '/?p=cp'), 2, sprintf(__('Item marked to deletion successfully! From now and on, "%s" will be unavailable for download while administrators delete it.', 'dtransport'), $item->getVar('name'))); } else { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/' : '/?p=cp'), 2, __('Item could not be marked to deletion! Please try again.', 'dtransport')); } break; case 'canceldel': $item->setVar('delete', 0); $item->licences(); $item->tags(); $item->categories(); $item->platforms();
$data['download'] = $candownload ? $item->permalink(0, 'download') : ''; $data['features'] = $item->permalink(0, 'features'); $data['logs'] = $item->permalink(0, 'logs'); // Datos generales $data['name'] = $item->getVar('name'); $data['version'] = $item->getVar('version'); // Imagen por defecto $img = new RMImage(); $img->load_from_params($item->getVar('image')); $data['image'] = $img->url(); $data['thumbnail'] = $img->get_smallest(); $data['rating'] = @number_format($item->getVar('rating') / $item->getVar('votes'), 1); $data['votes'] = $item->getVar('votes'); // Licencias $data['licenses'] = array(); foreach ($item->licences(true) as $lic) { $data['licenses'][] = array('url' => $lic->link(), 'name' => $lic->name(), 'link' => $lic->permalink()); } // Plataformas $data['platforms'] = array(); foreach ($item->platforms(true) as $os) { $data['platforms'][] = array('name' => $os->name(), 'link' => $os->permalink()); } $tf = new RMTimeFormatter(0, '%T% %d%, %Y%'); // Time formatter $data['created'] = $tf->format($item->getVar('created')); $data['update'] = $item->getVar('created') > 0 ? $tf->format($item->getVar('modified')) : ''; $data['author'] = array('name' => $item->getVar('author_name'), 'url' => $item->getVar('author_url'), 'email' => $item->getVar('author_email'), 'contact' => $item->getVar('author_contact')); $data['langs'] = $item->getVar('langs'); $data['downs'] = $item->getVar('hits'); $data['version'] = $item->getVar('version');