/** * @desc Visualiza las caracteríticas existentes de un elemento especificado **/ function dt_show_features() { global $xoopsModule, $tpl, $functions; define('RMCSUBLOCATION', 'showfeatures'); $item = rmc_server_var($_REQUEST, 'item', 0); $sw = new DTSoftware($item); if ($sw->isNew() && $item > 0) { redirectMsg('items.php', __('Specified download item does not exists!', 'dtransport'), RMMSG_WARN); } $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix('dtrans_features') . " WHERE id_soft={$item}"; $result = $db->query($sql); $features = array(); $tf = new RMTimeFormatter(0, "%T%-%d%-%Y% %h%:%i%"); while ($rows = $db->fetchArray($result)) { $ft = new DTFeature(); $ft->assignVars($rows); $features[] = array('id' => $ft->id(), 'title' => $ft->title(), 'created' => $tf->format($ft->created()), 'modified' => $tf->format($ft->modified()), 'software' => $sw->getVar('name')); } $functions->toolbar(); $tpl->assign('xoops_pagetitle', sprintf(__('Features of "%s"', 'dtransport'), $sw->getVar('name'))); // Styles $tpl->add_style('admin.css', 'dtransport'); // scripts $tpl->add_local_script('admin.js', 'dtransport'); $tpl->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include'); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='./items.php'>" . __('Downloads', 'dtransport') . "</a> » " . __('Features', 'dtransport')); xoops_cp_header(); include $tpl->get_template('admin/dtrans_features.php', 'module', 'dtransport'); xoops_cp_footer(); }
/** * Muestra las características existentes de una descarga */ function dt_show_features($edit = 0) { global $xoopsOption, $db, $tpl, $xoopsTpl, $xoopsUser, $mc, $dtfunc, $page, $item, $xoopsConfig, $xoopsModuleConfig, $feature; include 'header.php'; $dtfunc->cpHeader($item, sprintf(__('%s Features', 'dtransport'), $item->getVar('name'))); if ($feature > 0 && $edit) { $feature = new DTFeature($feature); if ($feature->isNew() || $feature->software() != $item->id()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->id() . '/' : '/?p=cpanel&action=features&id=' . $item->id()), 1, __('Specified feature does not exists!', 'dtransport')); } } $tc = TextCleaner::getInstance(); $sql = "SELECT * FROM " . $db->prefix('dtrans_features') . " WHERE id_soft=" . $item->id(); $result = $db->queryF($sql); while ($rows = $db->fetchArray($result)) { $feat = new DTFeature(); $feat->assignVars($rows); $xoopsTpl->append('features', array('id' => $feat->id(), 'title' => $feat->title(), 'content' => $tc->truncate($tc->clean_disabled_tags($feat->content()), 80), 'software' => $item->getVar('name'), 'links' => array('permalink' => $feat->permalink(), 'edit' => DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->getVar('nameid') . '/edit/' . $feat->id() . '/' : '/?p=cpanel&id=' . $item->id() . '&action=features&feature=' . $feat->id()), 'delete' => DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->getVar('nameid') . '/delete/' . $feat->id() . '/' : '/?p=cpanel&id=' . $item->id() . '&action=delete&feature=' . $feat->id())))); } $formurl = DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->id() . '/save/' . ($edit ? $feature->id() : '0') . '/' : '/p=cpanel'); // Features Form $form = new RMForm($edit ? sprintf(__('Editing feature of "%s"', 'dtransport'), $item->getVar('name')) : sprintf(__('New feature for "%s"', 'dtransport'), $item->getVar('name')), 'frmfeat', $formurl); $form->addElement(new RMFormLabel(__('Download item', 'dtransport'), $item->getVar('name'))); $form->addElement(new RMFormText(__('Feature title', 'dtransport'), 'title', 50, 200, $edit ? $feature->title() : ''), true); $form->addElement(new RMFormText(__('Short name', 'dtransport'), 'nameid', 50, 200, $edit ? $feature->nameId() : '')); $form->addElement(new RMFormEditor(__('Feature content', 'dtransport'), 'content', 'auto', '350px', $edit ? $feature->content('e') : ''), true); $dtfunc->meta_form('feat', $edit ? $feature->id() : 0, $form); $form->addElement(new RMFormHidden('action', 'save')); $form->addElement(new RMFormHidden('id', $item->id())); $form->addElement(new RMFormHidden('feature', $edit ? $feature->id() : 0)); $form->addElement(new RMFormHidden('op', 'save')); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', _SUBMIT, 'submit'); $buttons->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'' . (DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->id() . '/' : '/?p=cpanel&action=features&id=' . $item->id())) . '\';"'); $form->addElement($buttons); $xoopsTpl->assign('feat_form', $form->render()); $tpl->add_xoops_style('cpanel.css', 'dtransport'); $tpl->add_head_script('$(document).ready(function(){ $("a.delete").click(function(){ if(!confirm("' . __('Do you really want to delete selected feature?', 'dtransport') . '")) return false; }); });'); $xoopsTpl->assign('lang_id', __('ID', 'dtransport')); $xoopsTpl->assign('lang_title', __('Title', 'dtransport')); $xoopsTpl->assign('lang_content', __('Content', 'dtransport')); $xoopsTpl->assign('lang_edit', __('Edit', 'dtransport')); $xoopsTpl->assign('lang_delete', __('Delete', 'dtransport')); $xoopsTpl->assign('lang_addfeat', __('Add Feature', 'dtransport')); $xoopsTpl->assign('edit', $edit); include 'footer.php'; }
/** * @desc Obtiene las pantallas del elemento * @param bool True devuelve objetos {@link DTFeature} * @return array */ function features($asobj = false) { if (empty($this->_features) || $asobj && !is_a($this->_features[0], 'DTFeature')) { $this->_features = array(); $sql = "SELECT * FROM " . $this->db->prefix("dtrans_features") . " WHERE id_soft='" . $this->id() . "' ORDER BY modified DESC"; $result = $this->db->query($sql); while ($row = $this->db->fetchArray($result)) { if ($asobj) { $tmp = new DTFeature(); $tmp->assignVars($row); } else { $tmp = $row['id_feat']; } $this->_features[] = $tmp; } } return $this->_features; }