Example #1
0
 /**
  * Muestra los controles para lanzar el administrador de imágenes
  * desde cualqueir punto
  * @param string Element name for inputs
  */
 public function image_manager($name, $default = '')
 {
     if ($default != '') {
         $img = new RMImage();
         $img->load_from_params($default);
     }
     $ret = '<div id="' . $name . '-container" class="rmimage_container">';
     $ret .= '<div class="thumbnail">';
     if ($default != '' && !$img->isNew()) {
         $ret .= '<a href="' . $img->url() . '" target="_blank"><img src="' . $img->get_smallest() . '" /></a>';
         $ret .= '<input type="hidden" name="' . $name . '" id="' . $name . '" value="' . $default . '" />';
         $ret .= '<br /><a href="#" class="removeButton removeButton-' . $name . '">' . __('Remove Image', 'rmcommon') . '</a>';
     } else {
         $ret .= '<input type="hidden" name="' . $name . '" id="' . $name . '" value="" />';
     }
     $ret .= '</div>';
     $ret .= '<span class="image_manager_launcher button buttonGreen">' . __('Image manager...', 'rmcommon') . '</span>';
     $ret .= '</div>';
     $tpl = RMTemplate::get();
     $tpl->add_head_script('var imgmgr_title = "' . __('Image Manager', 'rmcommon') . '"' . "\n" . 'var mgrURL = "' . RMCURL . '/include/tiny-images.php";');
     $tpl->add_local_script('image_mgr_launcher.js', 'rmcommon', 'include');
     return $ret;
 }
Example #2
0
// Comprobamos los límites
if ($item->getVar('limits') > 0) {
    if ($item->downloadsCount() >= $item->getVar('limits')) {
        redirect_header($item->permalink(), 1, __('You have reached your download limit for this file!', 'dtransport'));
    }
}
// Verificamos si la descarga se debe realizar
$token = isset($_SESSION['dttoken']) ? $_SESSION['dttoken'] : '';
if ($token == '' || !$xoopsSecurity->validateToken($token)) {
    $_SESSION['dttoken'] = $xoopsSecurity->createToken();
    $xoopsOption['template_main'] = 'dtrans_getfile.html';
    $xoopsOption['module_subpage'] = 'getfile';
    include 'header.php';
    $img = new RMImage();
    $img->load_from_params($item->getVar('image'));
    $xoopsTpl->assign('item', array('title' => $item->getVar('name'), 'image' => $img->get_smallest(), 'link' => $item->permalink()));
    $xoopsTpl->assign('lang_message', sprintf(__('Your %s download will start shortly...', 'dtransport'), '<a href="' . $item->permalink() . '">' . $item->getVar('name') . '</a>'));
    $xoopsTpl->assign('lang_problems', sprintf(__('Problems with the download? Please %s to download immediately.', 'dtransport'), '<a href="' . $file->permalink() . '">' . __('use this link', 'dtransport') . '</a>'));
    $tpl->add_style('main.css', 'dtransport');
    $tpl->add_local_script('main.js', 'dtransport');
    $tpl->add_head_script('var down_message = "' . sprintf(__('Your %s download will start in {x} seconds...', 'dtransport'), '<a href=\'' . $item->permalink() . '\'>' . $item->getVar('name') . '</a>') . '";');
    $tpl->add_head_script('var timeCounter = ' . $mc['pause'] . ";\nvar dlink = '" . $file->permalink() . "';");
    $dtfunc->makeHeader();
    include 'footer.php';
    die;
}
// Comprobamos si el archivo es seguro o no
if (!$item->getVar('secure')) {
    // Comprobamos si es un archivo remoto o uno local
    if ($file->remote()) {
        // Almacenamos las estadísticas
 /**
  * @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;
 }
Example #4
0
/**
* @desc Muestra todos lo elementos registrados
**/
function dt_show_items()
{
    define('RMCSUBLOCATION', 'downitems');
    global $xoopsModule, $xoopsSecurity;
    $search = rmc_server_var($_REQUEST, 'search', '');
    $sort = rmc_server_var($_REQUEST, 'sort', 'id_soft');
    $mode = rmc_server_var($_REQUEST, 'mode', 1);
    $sort = $sort == '' ? 'id_soft' : $sort;
    $catid = rmc_server_var($_REQUEST, 'cat', 0);
    $type = rmc_server_var($_REQUEST, 'type', '');
    //Barra de Navegación
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT COUNT(*) FROM " . ($type == 'edit' ? $db->prefix('dtrans_software_edited') : $db->prefix('dtrans_software'));
    $sql .= $catid ? " WHERE id_cat='{$catid}'" : '';
    $sql .= $type == 'wait' ? $catid ? " AND approved=0" : " WHERE approved=0" : "";
    $sql1 = '';
    if ($search) {
        $words = explode(" ", $search);
        foreach ($words as $k) {
            //Verificamos si la palabra proporcionada es mayor a 2 caracteres
            if (strlen($k) <= 2) {
                continue;
            }
            $sql1 .= ($sql1 == '' ? $catid || $type == 'wait' ? " AND " : " WHERE " : " OR ") . " (name LIKE '%{$k}%' OR uname LIKE '%{$k}%') ";
        }
    }
    $sql2 = " ORDER BY {$sort} " . ($mode ? "DESC" : "ASC");
    list($num) = $db->fetchRow($db->queryF($sql . $sql1 . $sql2));
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $limit = 15;
    $nav = new RMPageNav($num, $limit, $page);
    $nav->target_url("items.php?search={$search}&amp;sort={$sort}&amp;mode={$mode}&amp;cat={$catid}&amp;type={$type}&page={PAGE_NUM}");
    $navpage = $nav->render(false, true);
    $start = $nav->start();
    //Fin de barra de navegación
    $catego = new DTCategory($catid);
    $sql = "SELECT * FROM " . ($type == 'edit' ? $db->prefix('dtrans_software_edited') : $db->prefix('dtrans_software'));
    $sql .= $catid ? " WHERE id_cat={$catid}" : '';
    $sql .= $type == 'wait' ? $catid ? " AND approved=0" : " WHERE approved=0" : "";
    $sql2 .= " LIMIT {$start},{$limit}";
    $result = $db->queryF($sql . $sql1 . $sql2);
    $items = array();
    $timeFormat = new RMTimeFormatter(0, '%m%-%d%-%Y%');
    while ($rows = $db->fetchArray($result)) {
        if ($type == 'edit') {
            $sw = new DTSoftwareEdited();
        } else {
            $sw = new DTSoftware();
        }
        $sw->assignVars($rows);
        $img = new RMImage($sw->getVar('image'));
        $user = new XoopsUser($sw->getVar('uid'));
        $items[] = array('id' => $type == 'edit' ? $sw->software() : $sw->id(), 'name' => $sw->getVar('name'), 'screens' => $sw->getVar('screens'), 'image' => $img->get_smallest(), 'secure' => $sw->getVar('secure'), 'approved' => $sw->getVar('approved'), 'uname' => $user->getVar('uname'), 'created' => $timeFormat->format($sw->getVar('created')), 'modified' => $timeFormat->format($sw->getVar('modified')), 'link' => $sw->permalink(), 'featured' => $sw->getVar('featured'), 'daily' => $sw->getVar('daily'), 'password' => $sw->getVar('password') != '', 'deletion' => $sw->getVar('delete'));
    }
    //Lista de categorías
    $categories = array();
    DTFunctions::getCategos($categos, 0, 0, array(), true);
    foreach ($categos as $k) {
        $cat = $k['object'];
        $categories[] = array('id' => $cat->id(), 'name' => str_repeat('--', $k['jumps']) . ' ' . $cat->name());
    }
    switch ($type) {
        case 'wait':
            $loc = __('Pending Downloads', 'dtransport');
            break;
        case 'edit':
            $loc = __('Edited Downloads', 'dtransport');
            break;
        default:
            $loc = __('Downloads Management', 'dtransport');
            break;
    }
    DTFunctions::toolbar();
    $tpl = RMTemplate::get();
    $tpl->add_style('admin.css', 'dtransport');
    $tpl->add_local_script('admin.js', 'dtransport');
    $tpl->add_local_script('items.js', 'dtransport');
    $tpl->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include');
    include DT_PATH . '/include/js_strings.php';
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . $loc);
    xoops_cp_header();
    include RMTemplate::get()->get_template('admin/dtrans_items.php', 'module', 'dtransport');
    xoops_cp_footer();
}
Example #5
0
$candownload = $item->canDownload($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS);
// Enlaces del elemento
$data = array();
$data['link'] = $item->permalink();
$data['screens'] = $item->permalink(0, 'screens');
$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'));