Пример #1
0
/**
* 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';
}
Пример #2
0
/**
* @desc Formulario de características
**/
function dt_form_features($edit = 0)
{
    global $xoopsModule, $xoopsConfig, $functions, $tpl;
    define('RMCSUBLOCATION', 'newfeature');
    $id = rmc_server_var($_REQUEST, 'id', 0);
    $item = rmc_server_var($_REQUEST, 'item', 0);
    //Verificamos que el software sea válido
    if ($item <= 0) {
        redirectMsg('items.php', __('Download item ID not provided!', 'dtransport'), RMMSG_WARN);
    }
    //Verificamos que el software exista
    $sw = new DTSoftware($item);
    if ($sw->isNew()) {
        redirectMsg('items.php', __('Specified download item does not exists!', 'dtransport'), RMMSG_ERROR);
    }
    if ($edit) {
        if ($id <= 0) {
            redirectMsg('features.php?item=' . $item, __('Feature ID not specified!', 'dtransport'), RMMSG_WARN);
        }
        //Verificamos que la característica exista
        $ft = new DTFeature($id);
        if ($ft->isNew()) {
            redirectMsg('features.php?item=' . $item, __('Specified feature does not exists!', 'dtransport'), RMMSG_ERROR);
        }
    }
    $functions->toolbar();
    //styles
    $tpl->add_style('admin.css', 'dtransport');
    //scripts
    include_once DT_PATH . '/include/js_strings.php';
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='items.php'>" . __('Downloads', 'dtransport') . "</a> &raquo; " . ($edit ? __('Edit Feature', 'dtransport') : __('New Feature', 'dtransport')));
    xoops_cp_header();
    $form = new RMForm($edit ? sprintf(__('Editing feature of "%s"', 'dtransport'), $sw->getVar('name')) : sprintf(__('New feature for "%s"', 'dtransport'), $sw->getVar('name')), 'frmfeat', 'features.php');
    $form->addElement(new RMFormLabel(__('Download item', 'dtransport'), $sw->getVar('name')));
    $form->addElement(new RMFormText(__('Feature title', 'dtransport'), 'title', 50, 200, $edit ? $ft->title() : ''), true);
    $form->addElement(new RMFormText(__('Short name', 'dtransport'), 'nameid', 50, 200, $edit ? $ft->nameId() : ''));
    $form->addElement(new RMFormEditor(__('Feature content', 'dtransport'), 'content', '90%', '350px', $edit ? $ft->content() : ''), true);
    $functions->meta_form('feat', $edit ? $ft->id() : 0, $form);
    $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save'));
    $form->addElement(new RMFormHidden('id', $id));
    $form->addElement(new RMFormHidden('item', $item));
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', _SUBMIT, 'submit');
    $buttons->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'features.php?item=' . $item . '\';"');
    $form->addElement($buttons);
    $form->display();
    xoops_cp_footer();
}