Beispiel #1
0
/**
* @des Visualiza todas las pantallas existentes
**/
function showScreens()
{
    global $xoopsModule, $xoopsSecurity, $tpl, $functions, $xoopsModule, $xoopsModuleConfig, $xoopsUser, $xoopsConfig;
    define('RMCSUBLOCATION', 'screenshots');
    if ($xoopsConfig['closesite']) {
        showMessage(__('Screenshop uploader does not work when site is closed. Before to start uploding, please change this configuration.', 'rmcommon'), RMMSG_WARN);
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $tc = TextCleaner::getInstance();
    $item = rmc_server_var($_REQUEST, 'item', 0);
    if ($item <= 0) {
        redirectMsg('items.php', __('Download item ID not provided!', 'dtransport'), RMMSG_WARN);
    }
    $sw = new DTSoftware($item);
    $sql = "SELECT * FROM " . $db->prefix('dtrans_screens') . " WHERE id_soft={$item}";
    $result = $db->queryF($sql);
    while ($rows = $db->fetchArray($result)) {
        $sc = new DTScreenshot();
        $sc->assignVars($rows);
        $screens[] = array('id' => $sc->id(), 'title' => $sc->title(), 'desc' => substr($tc->clean_disabled_tags($sc->desc()), 0, 80) . "...", 'image' => XOOPS_UPLOAD_URL . '/screenshots/' . date('Y', $sc->date()) . '/' . date('m', $sc->date()) . '/ths/' . $sc->image());
    }
    // CSS Styles
    $tpl->add_style('admin.css', 'dtransport');
    $tpl->add_style('screens.css', 'dtransport');
    $tpl->add_style('uploadify.css', 'rmcommon');
    // Javascripts
    $tpl->add_local_script('swfobject.js', 'rmcommon', 'include');
    $tpl->add_local_script('jquery.uploadify.js', 'rmcommon', 'include');
    $tpl->add_local_script('screens.js', 'dtransport');
    $tc = TextCleaner::getInstance();
    $rmf = RMFunctions::get();
    ob_start();
    include DT_PATH . '/js/screenshots.js';
    $script = ob_get_clean();
    $tpl->add_head_script($script);
    $functions->toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='items.php'>" . __('Downloads', 'dtransport') . "</a> &raquo; " . __('Screenshots Management', 'dtransport'));
    $tpl->assign('xoops_pagetitle', sprintf(__("%s Screenshots", 'dtransport'), $sw->getVar('name')));
    include DT_PATH . '/include/js_strings.php';
    xoops_cp_header();
    include $tpl->get_template('admin/dtrans_screens.php', 'module', 'dtransport');
    xoops_cp_footer();
}
 public function delete()
 {
     //Eliminamos las relaciones con etiquetas
     $sql = "DELETE FROM " . $this->db->prefix('dtrans_softtag') . " WHERE id_soft=" . $this->id();
     $result = $this->db->queryF($sql);
     if (!$result) {
         return false;
     }
     //Eliminar caracteristicas
     $sql = "DELETE FROM " . $this->db->prefix('dtrans_features') . " WHERE id_soft=" . $this->id();
     $result = $this->db->queryF($sql);
     if (!$result) {
         return false;
     }
     //Eliminar pantallas
     $sql = "SELECT * FROM " . $this->db->prefix('dtrans_screens') . " WHERE id_soft=" . $this->id();
     $result = $this->db->queryF($sql);
     while ($rows = $this->db->fetchArray($result)) {
         $sc = new DTScreenshot();
         $sc->assignVars($rows);
         $sc->delete();
     }
     //Eliminar Archivos
     $sql = "SELECT * FROM " . $this->db->prefix('dtrans_files') . " WHERE id_soft=" . $this->id();
     $result = $this->db->queryF($sql);
     while ($rows = $this->db->fetchArray($result)) {
         $file = new DTFile();
         $file->assignVars($rows);
         $file->delete($this);
     }
     //Eliminar Logs
     $sql = "DELETE FROM " . $this->db->prefix('dtrans_logs') . " WHERE id_soft=" . $this->id();
     $result = $this->db->queryF($sql);
     if (!$result) {
         return false;
     }
     //Eliminar grupo
     $sql = "DELETE FROM " . $this->db->prefix('dtrans_groups') . " WHERE id_soft=" . $this->id();
     $result = $this->db->queryF($sql);
     if (!$result) {
         return false;
     }
     //Eliminar relación de licencias
     $sql = "DELETE FROM " . $this->db->prefix('dtrans_licsoft') . " WHERE id_soft=" . $this->id();
     $result = $this->db->queryF($sql);
     if (!$result) {
         return false;
     }
     //Eliminar relación de plataformas
     $sql = "DELETE FROM " . $this->db->prefix('dtrans_platsoft') . " WHERE id_soft=" . $this->id();
     $result = $this->db->queryF($sql);
     if (!$result) {
         return false;
     }
     //Eliminar alerta
     $sql = "DELETE FROM " . $this->db->prefix('dtrans_alerts') . " WHERE id_soft=" . $this->id();
     $result = $this->db->queryF($sql);
     if (!$result) {
         return false;
     }
     return $this->deleteFromTable();
 }
 /**
  * @desc Obtiene las caracteristicas del elemento
  * @param bool True devuelve objetos {@link STScreenshot}
  * @return array
  */
 function screens($asobj = false)
 {
     if (empty($this->_screens) || $asobj && !is_a($this->_screens[0], 'DTScreenshot')) {
         $this->_screens = array();
         $sql = "SELECT * FROM " . $this->db->prefix("dtrans_screens") . " WHERE id_soft='" . $this->id() . "' ORDER BY modified DESC";
         $result = $this->db->query($sql);
         while ($row = $this->db->fetchArray($result)) {
             if ($asobj) {
                 $tmp = new DTScreenshot();
                 $tmp->assignVars($row);
             } else {
                 $tmp = $row['id_screen'];
             }
             $this->_screens[] = $tmp;
         }
     }
     return $this->_screens;
 }
Beispiel #4
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';
}