예제 #1
0
function dt_save_screen_info()
{
    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);
    }
    $title = rmc_server_var($_POST, 'title', '');
    $desc = rmc_server_var($_POST, 'desc', '');
    if ($title == '') {
        $func->dt_send_message(__('You must provide a title for this screenshot!', 'dtransport'), 1, 1);
    }
    $sc->setTitle($title);
    $sc->setDesc($desc);
    if (!$sc->save()) {
        $func->dt_send_message(__('Screenshot changes could not be saved!', 'dtransport') . '<br />' . $sc->errors(), 1, 1);
    }
    $ret = array('title' => $sc->title(), 'description' => $sc->desc(), 'id' => $sc->id());
    $func->dt_send_message($ret, 0, 1);
}
예제 #2
0
/**
* @desc Formulario de Pantallass
**/
function formScreens($edit = 0)
{
    global $xoopsModule, $xoopsConfig, $db, $xoopsModuleConfig;
    $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    $item = isset($_REQUEST['item']) ? intval($_REQUEST['item']) : 0;
    //Verificamos que el software sea válido
    if ($item <= 0) {
        redirectMsg('./screens.php', _AS_DT_ERR_ITEMVALID, 1);
        die;
    }
    //Verificamos que el software exista
    $sw = new DTSoftware($item);
    if ($sw->isNew()) {
        redirectMsg('./screens.php', _AS_DT_ERR_ITEMEXIST, 1);
        die;
    }
    //Verificamos el limite de pantallas a almacenar
    if ($xoopsModuleConfig['limit_screen'] <= $sw->getVar('screens')) {
        redirectMsg('./screens.php?item=' . $item, _AS_DT_ERRCOUNT, 1);
        die;
    }
    if ($edit) {
        //Verificamos si pantalla es válida
        if ($id <= 0) {
            redirectMsg('./screens.php?item=' . $item, _AS_DT_ERR_SCVALID, 1);
            //
            die;
        }
        //Verificamos que la pantalla exista
        $sc = new DTScreenshot($id);
        if ($sc->isNew()) {
            redirectMsg('./screens.php?item=' . $item, _AS_DT_ERR_SCEXIST, 1);
            die;
        }
    }
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='./items.php'>" . _AS_DT_SW . "</a> &raquo; " . ($edit ? _AS_DT_EDITSCREEN : _AS_DT_NEWSCREEN));
    xoops_cp_header();
    $form = new RMForm($edit ? sprintf(_AS_DT_EDITSCREENS, $sw->getVar('name')) : sprintf(_AS_DT_NEWSCREENS, $sw->getVar('name')), 'frmscreen', 'screens.php');
    $form->setExtra("enctype='multipart/form-data'");
    $form->addElement(new RMFormLabel(_AS_DT_ITEM, $sw->getVar('name')));
    $form->addElement(new RMFormText(_AS_DT_TITLE, 'title', 50, 100, $edit ? $sc->title() : ''), true);
    $form->addElement(new RMFormEditor(_AS_DT_DESC, 'desc', '100%', '100px', $edit ? $sc->desc() : '', 'textarea'));
    $form->addElement(new RMFormFile(_AS_DT_IMAGE, 'image', 45, $xoopsModuleConfig['image'] * 1024), $edit ? '' : true);
    if ($edit) {
        $img = "<img src='" . XOOPS_URL . "/uploads/dtransport/ths/" . $sc->image() . "' border='0' />";
        $form->addElement(new RMFormLabel(_AS_DT_IMAGEACT, $img));
    }
    $form->addElement(new RMFormHidden('op', $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=\'screens.php?item=' . $item . '\';"');
    $form->addElement($buttons);
    $form->display();
    xoops_cp_footer();
}
예제 #3
0
/**
* @desc Visualiza las pantallas del software y 
* el formulario de creación de pantallas
**/
function dt_screens($edit = 0)
{
    global $xoopsOption, $db, $tpl, $xoopsTpl, $xoopsUser, $mc, $dtfunc, $page, $item, $xoopsConfig, $xoopsModuleConfig, $screen;
    include 'header.php';
    $dtfunc->cpHeader($item, sprintf(__('Screenshots for "%s"', 'dtransport'), $item->getVar('name')));
    $tc = TextCleaner::getInstance();
    $sql = "SELECT * FROM " . $db->prefix('dtrans_screens') . " WHERE id_soft=" . $item->id();
    $result = $db->queryF($sql);
    while ($rows = $db->fetchArray($result)) {
        $sc = new DTScreenshot();
        $sc->assignVars($rows);
        $xoopsTpl->append('screens', array('id' => $sc->id(), 'title' => $sc->title(), 'desc' => $tc->clean_disabled_tags($sc->desc()), 'software' => $item->getVar('name'), 'image' => $sc->url('ths'), 'links' => array('edit' => DT_URL . ($mc['permalinks'] ? '/cp/screens/' . $item->getVar('nameid') . '/edit/' . $sc->id() . '/' : '/?p=cpanel&amp;id=' . $item->id() . '&amp;action=screens&amp;screen=' . $sc->id()), 'delete' => DT_URL . ($mc['permalinks'] ? '/cp/screens/' . $item->getVar('nameid') . '/delete/' . $sc->id() . '/' : '/?p=cpanel&amp;id=' . $item->id() . '&amp;action=delete&amp;screen=' . $sc->id()))));
    }
    //Formulario de pantallas
    if ($edit) {
        //Verificamos si la pantalla es válida
        if ($screen <= 0) {
            redirect_header(DT_URL . ($mc['permalinks'] ? '/screens/' . $item->getVar('nameid') : '/?p=cpanel&amp;action=screens&amp;id=' . $item->id()), 1, __('Invalid screen', 'dtransport'));
        }
        //Verificamos si la pantalla existe
        $sc = new DTScreenshot($screen);
        if ($sc->isNew()) {
            redirect_header(DT_URL . ($mc['permalinks'] ? '/screens/' . $item->getVar('nameid') : '/?p=cpanel&amp;action=screens&amp;id=' . $item->id()), 1, __('Invalid screen', 'dtransport'));
        }
    }
    if ($edit || $mc['limit_screen'] > $item->getVar('screens')) {
        if ($edit) {
            $faction = DT_URL . ($mc['permalinks'] ? '/cp/screens/' . $item->id() . '/save/' . $sc->id() . '/' : '');
        } else {
            $faction = DT_URL . ($mc['permalinks'] ? '/cp/screens/' . $item->id() . '/save/0/' : '');
        }
        $form = new RMForm($edit ? sprintf(__('Edit Screenshot of %s', 'dtransport'), $item->getVar('name')) : sprintf(__('Add screen for %s', 'dtransport'), $item->getVar('name')), 'frmscreen', $faction);
        $form->setExtra("enctype='multipart/form-data'");
        $form->addElement(new RMFormLabel(__('Download item', 'dtransport'), $item->getVar('name')));
        $form->addElement(new RMFormText(__('Title', 'dtransport'), 'title', 50, 100, $edit ? $sc->title() : ''), true);
        $form->addElement(new RMFormEditor(__('Description', 'dtransport'), 'desc', 'auto', '100px', $edit ? $sc->desc() : '', 'simple'));
        $form->addElement(new RMFormFile(__('Image file', 'dtransport'), 'image', 45, $xoopsModuleConfig['image'] * 1024), $edit ? '' : true);
        if ($edit) {
            $img = "<img src='" . $sc->url('ths') . "' border='0' />";
            $form->addElement(new RMFormLabel(__('Current image', 'dtransport'), $img));
        }
        $form->addElement(new RMFormHidden('p', 'cpanel'));
        $form->addElement(new RMFormHidden('action', 'screens'));
        $form->addElement(new RMFormHidden('id', $item->id()));
        $form->addElement(new RMFormHidden('op', 'save'));
        $form->addElement(new RMFormHidden('screen', $edit ? $sc->id() : 0));
        $buttons = new RMFormButtonGroup();
        $buttons->addButton('sbt', $edit ? __('Save Changes', 'dtransport') : __('Save Screenshot', 'dtransport'), 'submit');
        $buttons->addButton('cancel', __('Cancel', 'dtransport'), 'button', 'onclick="window.location=\'' . DT_URL . ($mc['permalinks'] ? '/cp/screens/' . $item->getVar('nameid') . '/' : '/?p=cpanel&amp;action=screens&amp;id=' . $item->id()) . '\';"');
        $form->addElement($buttons);
        $xoopsTpl->assign('formscreens', $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 images?', 'dtransport') . '")) return false;
        });
        
    });');
    $xoopsTpl->assign('lang_id', __('ID', 'dtransport'));
    $xoopsTpl->assign('lang_title', __('Title', 'dtransport'));
    $xoopsTpl->assign('lang_desc', __('Description', 'dtransport'));
    $xoopsTpl->assign('lang_opts', __('Options', 'dtransport'));
    $xoopsTpl->assign('lang_edit', __('Edit', 'dtransport'));
    $xoopsTpl->assign('lang_delete', __('Delete', 'dtransport'));
    $xoopsTpl->assign('lang_image', __('Image', 'dtransport'));
    $xoopsTpl->assign('lang_deletescreen', _MS_DT_DELETESCREEN);
    $xoopsTpl->assign('lang_deletescreens', _MS_DT_DELETESCREENS);
    $xoopsTpl->assign('edit', $edit);
    include 'footer.php';
}