Exemple #1
0
function &gs_rssshow($limit)
{
    global $util, $mc;
    $db =& Database::getInstance();
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsuser.class.php';
    foreach ($_GET as $k => $v) {
        ${$k} = $v;
    }
    $feed = array();
    // Información General
    $items = array();
    $mc =& $util->moduleConfig('galleries');
    if ($show == 'imgs') {
        $feed['title'] = htmlspecialchars(_MI_GS_RSSNAME);
        $feed['link'] = htmlspecialchars(XOOPS_URL . '/modules/galleries/' . ($mc['urlmode'] ? 'explore/photos/' : 'explore.php?by=explore/photos'));
        $feed['description'] = htmlspecialchars(_MI_GS_RSSIMGS_DESC);
        $sql = "SELECT * FROM " . $db->prefix("gs_images") . " WHERE public='2' ORDER BY created DESC LIMIT 0,15";
        $result = $db->query($sql);
        $users = array();
        while ($row = $db->fetchArray($result)) {
            $pic = new GSImage();
            $pic->assignVars($row);
            if (!isset($users[$pic->owner()])) {
                $users[$pic->owner()] = new GSUser($pic->owner(), 1);
            }
            $user =& $users[$pic->owner()];
            $rtn = array();
            $rtn['title'] = htmlspecialchars($pic->title());
            $rtn['link'] = $user->userURL() . 'img/' . $pic->id() . '/';
            $rtn['description'] = htmlspecialchars('<img src="' . $user->filesURL() . '/ths/' . $pic->image() . '" alt="" /><br />' . sprintf(_MI_GS_RSSIMGDESC, $pic->desc(), formatTimestamp($pic->created(), 'string'), $user->uname(), $pic->views()));
            $rtn['date'] = formatTimestamp($pic->created());
            $items[] = $rtn;
        }
    } elseif ($show == 'sets') {
        $feed['title'] = htmlspecialchars(_MI_GS_RSSSETS);
        $feed['link'] = htmlspecialchars(XOOPS_URL . '/modules/galleries/' . ($mc['urlmode'] ? 'explore/sets/' : 'explore.php?by=explore/sets'));
        $feed['description'] = htmlspecialchars(_MI_GS_RSSSETS_DESC);
        $sql = "SELECT * FROM " . $db->prefix("gs_sets") . " WHERE public='2' ORDER BY date DESC LIMIT 0,15";
        $result = $db->query($sql);
        $users = array();
        while ($row = $db->fetchArray($result)) {
            $set = new GSSet();
            $set->assignVars($row);
            if (!isset($users[$set->owner()])) {
                $users[$set->owner()] = new GSUser($set->owner(), 1);
            }
            $user =& $users[$set->owner()];
            $rtn = array();
            $rtn['title'] = htmlspecialchars($set->title());
            $rtn['link'] = $user->userURL() . 'set/' . $set->id() . '/';
            $rtn['description'] = htmlspecialchars(sprintf(_MI_GS_RSSSETDESC, $user->uname(), formatTimestamp($set->date(), 'string'), $set->pics()));
            $rtn['date'] = formatTimestamp($set->date());
            $items[] = $rtn;
        }
    }
    $ret = array('feed' => $feed, 'items' => $items);
    return $ret;
}
Exemple #2
0
function show_dashboard()
{
    global $xoopsModuleConfig;
    $db = Database::getInstance();
    // Sets count
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("gs_sets");
    list($set_count) = $db->fetchRow($db->query($sql));
    // Pictures count
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("gs_images");
    list($pic_count) = $db->fetchRow($db->query($sql));
    // Users count
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("gs_users");
    list($user_count) = $db->fetchRow($db->query($sql));
    // Tags count
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("gs_tags");
    list($tag_count) = $db->fetchRow($db->query($sql));
    // E-Cards count
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("gs_postcards");
    list($post_count) = $db->fetchRow($db->query($sql));
    // Used space
    $space = RMUtilities::formatBytesSize(GSFunctions::folderSize($xoopsModuleConfig['storedir']));
    // Number of files
    $file_count = count_files(rtrim($xoopsModuleConfig['storedir'], '/'));
    // First picture
    $sql = "SELECT * FROM " . $db->prefix("gs_images") . " ORDER BY `created` ASC LIMIT 0,1";
    $result = $db->query($sql);
    if ($db->getRowsNum($result) > 0) {
        $img = new GSImage();
        $img->assignVars($db->fetchArray($result));
        $user = new GSUser($img->owner(), 1);
        $tf = new RMTimeFormatter(0, '%M% %d%, %Y%');
        $first_pic['date'] = $tf->format($img->created());
        $first_pic['link'] = $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'img/' . $img->id() . '/set/' : '&amp;img=' . $img->id());
    }
    xoops_cp_header();
    GSFunctions::toolbar();
    RMTemplate::get()->add_style('dashboard.css', 'galleries');
    RMTemplate::get()->add_style('admin.css', 'galleries');
    RMTemplate::get()->add_head('<script type="text/javascript">var xurl = "' . XOOPS_URL . '";</script>');
    RMTemplate::get()->add_local_script('dashboard.js', 'galleries');
    include RMTemplate::get()->get_template('admin/gs_dashboard.php', 'module', 'galleries');
    xoops_cp_footer();
}
Exemple #3
0
/**
* @desc Realiza una búsqueda en el módulo desde EXM
*/
function gsSearch($queryarray, $andor, $limit, $offset, $userid)
{
    global $db, $myts;
    include_once XOOPS_ROOT_PATH . "/modules/galleries/class/gsimage.class.php";
    include_once XOOPS_ROOT_PATH . "/modules/galleries/class/gsuser.class.php";
    $mc = RMUtilities::get()->module_config('galleries');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT DISTINCT c.* FROM " . $db->prefix('gs_tags') . " a INNER JOIN " . $db->prefix('gs_tagsimages') . " b INNER JOIN ";
    $sql .= $db->prefix('gs_images') . " c ON (";
    $sql .= "a.id_tag=b.id_tag AND b.id_image=c.id_image AND c.public=2 AND (";
    $sql1 = '';
    foreach ($queryarray as $k) {
        $sql1 .= ($sql1 == '' ? "" : "{$andor}") . " (a.tag LIKE '%{$k}%' OR c.title LIKE '%{$k}%') ";
    }
    $sql1 .= "))";
    $sql1 .= " ORDER BY c.created DESC LIMIT {$offset}, {$limit}";
    $result = $db->queryF($sql . $sql1);
    $ret = array();
    $users = array();
    while ($row = $db->fetchArray($result)) {
        $img = new GSImage();
        $img->assignVars($row);
        if (!isset($users[$img->owner()])) {
            $users[$img->owner()] = new GSUser($img->owner(), 1);
        }
        $rtn = array();
        $rtn['image'] = 'images/images.png';
        $link = $mc['urlmode'] ? "usr/" . $users[$img->owner()]->uname() . "/img/" . $img->id() : "user.php?id=" . "usr/" . $users[$img->owner()]->uname() . "/img/" . $img->id();
        $rtn['title'] = $img->title();
        $rtn['time'] = $img->created();
        $rtn['uid'] = $img->owner();
        $rtn['desc'] = $img->desc();
        $rtn['link'] = $link;
        $ret[] = $rtn;
    }
    return $ret;
}
function gs_photos_show($options)
{
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsuser.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php';
    $options[0] <= 0 ? 4 : $options[0];
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT * FROM " . $db->prefix("gs_images");
    $order = $options[1] == '0' ? "created DESC" : ($options[1] == '1' ? 'RAND()' : 'views DESC');
    $sql .= " ORDER BY {$order} LIMIT 0,{$options['0']}";
    $result = $db->query($sql);
    $mc =& RMUtilities::module_config('galleries');
    $block = array();
    $tf = new RMTimeFormatter(0, '%T% %d%, %Y%');
    while ($row = $db->fetchArray($result)) {
        $pic = new GSImage();
        $pic->assignVars($row);
        if (!isset($users[$pic->owner()])) {
            $users[$pic->owner()] = new GSUser($pic->owner(), 1);
        }
        $user =& $users[$pic->owner()];
        $rtn = array();
        if ($options[3]) {
            $rtn['title'] = $pic->title();
        }
        $rtn['created'] = $tf->format($pic->created());
        $rtn['views'] = $pic->views();
        $rtn['by'] = sprintf(__('by %s', 'galleries'), '<a href="' . $user->userURL() . '">' . $user->uname() . '</a>');
        $rtn['link'] = $user->userURL() . ($mc['urlmode'] ? 'img/' . $pic->id() . '/' : '&amp;img=' . $pic->id());
        $rtn['file'] = $user->filesURL() . '/ths/' . $pic->image();
        $block['pics'][] = $rtn;
    }
    RMTemplate::get()->add_xoops_style('blocks.css', 'galleries');
    RMTemplate::get()->add_local_script('blocks.js', 'galleries');
    $block['item_width'] = $options[2];
    return $block;
}
 /**
  * Get image data
  */
 public function process_image_data($result)
 {
     $mc = RMUtilities::module_config('galleries');
     $users = array();
     $ret = array();
     $tf = new RMTimeFormatter(0, "%M%/%d%/%Y%");
     $db = Database::getInstance();
     $i = 0;
     while ($row = $db->fetchArray($result)) {
         $img = new GSImage();
         $img->assignVars($row);
         if (!isset($users[$img->owner()])) {
             $users[$img->owner()] = new GSUser($img->owner(), 1);
         }
         $imglink = $users[$img->owner()]->userURL() . ($mc['urlmode'] ? 'img/' . $img->id() . '/' : '&amp;img=' . $img->id());
         $ret[$i] = array('id' => $img->id(), 'title' => $img->title(), 'thumbnail' => $users[$img->owner()]->filesURL() . '/ths/' . $img->image(), 'thumbuser' => $users[$img->owner()]->filesURL() . '/' . ($mc['user_format_mode'] ? 'formats/user_' : 'ths/') . $img->image(), 'thumbsrh' => $users[$img->owner()]->filesURL() . '/' . ($mc['search_format_mode'] ? 'formats/srh_' : 'ths/') . $img->image(), 'image' => $users[$img->owner()]->filesURL() . '/' . $img->image(), 'by' => sprintf(__('by %s', 'galleries'), '<a href="' . $users[$img->owner()]->userUrl() . '">' . $users[$img->owner()]->uname() . '</a>'), 'link' => $imglink, 'created' => $tf->format($img->created()), 'public' => $img->isPublic(), 'desc' => $img->desc());
         // Format resize
         if (!$img->userFormat() && $mc['user_format_mode']) {
             $format = $mc['user_format_values'];
             GSFunctions::resizeImage($format[0], $users[$img->owner()]->filesPath() . '/' . $img->image(), $users[$img->owner()]->filesPath() . '/formats/user_' . $img->image(), $format[1], $format[2]);
             $img->setUserFormat(1, 1);
         }
         if (!$img->searchFormat() && $mc['search_format_mode']) {
             $format = $mc['search_format_values'];
             GSFunctions::resizeImage($format[0], $users[$img->owner()]->filesPath() . '/' . $img->image(), $users[$img->owner()]->filesPath() . '/formats/srh_' . $img->image(), $format[1], $format[2]);
             $img->setSearchFormat(1, 1);
         }
         if ($mc['search_format_mode']) {
             $ret[$i]['viewmore'] = sprintf(__('Ver <a href="%s">más fotos</a>.', 'galleries'), $users[$img->owner()]->userURL());
             $ret[$i]['avatar'] = RMEvents::get()->run_event('rmcommon.get.avatar', $users[$img->owner()]->userVar('email'), 0, $users[$img->owner()]->userVar('user_avatar'));
             $tags = $img->tags(true);
             $tagurl = self::get_url() . ($mc['urlmode'] ? 'explore/tags/tag/' : '?explore=tags&amp;tag=');
             $strtag = '';
             foreach ($tags as $tag) {
                 $strtag .= $strtag == '' ? "<a href=\"{$tagurl}" . $tag->getVar('nameid') . "\">" . $tag->tag() . "</a>" : ", <a href=\"{$tagurl}" . $tag->getVar('nameid') . "\">" . $tag->tag() . "</a>";
             }
             $ret[$i]['tags'] = $strtag;
         }
         $i++;
     }
     RMTemplate::get()->add_local_script('photos.js', 'galleries');
     if (!$mc['quickview']) {
         return $ret;
     }
     if (RMFunctions::plugin_installed('lightbox')) {
         RMLightbox::get()->add_element('.pic_qview a');
         RMLightbox::get()->render();
     }
     return $ret;
 }
Exemple #6
0
     $users = array();
     $rss_items = array();
     while ($row = $db->fetchArray($result)) {
         $img = new GSImage();
         $img->assignVars($row);
         if (!isset($users[$img->owner()])) {
             $users[$img->owner()] = new GSUser($img->owner(), 1);
         }
         $imglink = $users[$img->owner()]->userURL() . ($mc['urlmode'] ? 'img/' . $img->id() . '/' : '&amp;img=' . $img->id());
         $desc = '<a href="' . $imglink . '"><img src="' . $users[$img->owner()]->filesURL() . '/ths/' . $img->image() . '" alt="' . $img->title() . '" /></a><br />' . ($img->desc() != '' ? $img->desc() . '<br />' : '');
         $desc .= sprintf(__('By: <strong>%s</strong>', 'galleries'), $users[$img->owner()]->uname());
         $item = array();
         $item['title'] = $img->title();
         $item['link'] = $imglink;
         $item['description'] = XoopsLocal::convert_encoding(htmlspecialchars($desc, ENT_QUOTES));
         $item['pubdate'] = formatTimestamp($img->created(), 'rss');
         $item['guid'] = $imglink;
         $rss_items[] = $item;
     }
     break;
 case 'albums':
     $rss_channel['title'] = $xoopsModule->name();
     $rss_channel['link'] = GSFunctions::get_url();
     $rss_channel['description'] = __('These are the recent albums created on our galleries.', 'galleries');
     $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss');
     $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true);
     $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true);
     $rss_channel['category'] = __('Pictures Albums', 'galleries');
     $rss_channel['generator'] = 'MyGalleries 3';
     $rss_channel['language'] = RMCLANG;
     $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE public='2' ORDER BY `date` DESC LIMIT 0, 10";
Exemple #7
0
/**
* @desc Mostramos el contenido de un Álbum
*/
function showSetContent()
{
    global $usr, $db, $xoopsModule, $mc, $xoopsModuleConfig, $xoopsConfig, $xoopsUser, $xoopsOption, $tpl, $page;
    global $pag, $set;
    $mc =& $xoopsModuleConfig;
    $user = new GSUser($usr);
    if ($user->isNew()) {
        redirect_header(GSFunctions::get_url(), 0, __('Specified users does not exists!', 'galleries'));
        die;
    }
    $set = new GSSet($set);
    if ($set->isNew()) {
        redirect_header(GSFunctions::get_url(), 0, __('Specified album does not exists!', 'galleries'));
        die;
    }
    //Verificamos la privacidad del album
    if (!$set->ispublic()) {
        if (!$xoopsUser || $xoopsUser->uid() != $set->owner()) {
            redirect_header(GSFunctions::get_url(), 1, __('You can not view this private album!', 'galleries'));
            die;
        }
    } else {
        if (!$xoopsUser && $set->isPublic() == 1 && !$user->isFriend($xoopsUser->uid())) {
            redirect_header(GSFunctions::get_url(), 1, sprintf(__('You must be a friend of %s in order to see this album!', 'galleries'), $user->uname()));
            die;
        }
    }
    //Incrementamos el número de hits del album
    if (!isset($_SESSION['vsets'])) {
        $set->addHit();
        $_SESSION['vsets'] = array($set->id());
    } elseif (!in_array($set->id(), $_SESSION['vsets'])) {
        $set->addHit();
        $_SESSION['vsets'][] = $set->id();
    }
    $xoopsOption['template_main'] = $mc['set_format_mode'] ? 'gs_setpics.html' : 'gs_userpics.html';
    $xoopsOption['module_subpage'] = 'userset';
    include 'header.php';
    GSFunctions::makeHeader();
    // Información del Usuario
    $tpl->assign('lang_picsof', sprintf(__('Pictures in %s'), $set->title()));
    $tpl->assign('user', array('id' => $user->uid(), 'uname' => $user->uname(), 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $user->userVar('email'), 0, $user->userVar('user_avatar')), 'link' => $user->userURL()));
    $tpl->assign('set', array('title' => $set->title(), 'description' => $set->getVar('description', 's')));
    // Lenguaje
    $tpl->assign('lang_bmark', __('Favorites', 'galleries'));
    $tpl->assign('lang_pics', __('Pictures', 'galleries'));
    $tpl->assign('sets_link', GSFunctions::get_url() . ($mc['urlmode'] ? "explore/sets/usr/" . $user->uname() . '/' : "?explore=sets&amp;usr="******"explore/tags/usr/" . $user->uname() . '/' : "?explore=tags&amp;usr="******"cp/bookmarks/" : "?cp=bookmarks"));
    $tpl->assign('xoops_pagetitle', sprintf(__('Pictures in %s'), $set->title()) . ' &raquo; ' . $mc['section_title']);
    $tpl->assign('lang_numpics', sprintf(__('Pictures: %s', 'galleries'), $set->pics()));
    $tpl->assign('lang_numviews', sprintf(__('Hits: %s'), $set->hits()));
    global $xoTheme;
    if ($set->getVar('description') != '') {
        $xoTheme->addMeta('meta', 'description', TextCleaner::clean_disabled_tags($set->getVar('description')));
    }
    //Verificamos la privacidad de las imágenes
    if ($xoopsUser && $xoopsUser->uid() == $user->uid()) {
        $public = '';
    } else {
        if ($xoopsUser && $user->isFriend($xoopsUser->uid())) {
            $public = " AND public<>0";
        } else {
            $public = "AND public='2'";
        }
    }
    $tbl1 = $db->prefix("gs_images");
    $tbl2 = $db->prefix("gs_setsimages");
    $sql = "SELECT COUNT(*) FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image {$public} AND owner='" . $user->uid() . "'";
    $page = $page > 0 ? $page : 1;
    /**
     * @desc Formato para el manejo de las imágenes
     */
    if ($mc['set_format_mode']) {
        $format = $mc['set_format_values'];
        $crop = $format[0];
        // 0 = Redimensionar, 1 = Cortar
        $width = $format[1];
        $height = $format[2];
        $limit = $format[3];
        $cols = $format[4];
        @($showdesc = $format[5]);
        // Imágenes Grandes
        $format = $mc['setbig_format_values'];
        $bcrop = $format[0];
        $bwidth = $format[1];
        $bheight = $format[2];
        $blimit = $format[3];
        $bcols = $format[4];
        @($bshowdesc = $format[5]);
        // Medidas
        $tpl->assign('big_width', $bwidth + 15);
    } else {
        $limit = $mc['limit_pics'];
        $cols = $mc['cols_pics'];
        $showdesc = 0;
    }
    list($num) = $db->fetchRow($db->query($sql));
    if ($page > 0) {
        $page -= 1;
    }
    $start = $page * $limit;
    $tpages = (int) ($num / $limit);
    if ($num % $limit > 0) {
        $tpages++;
    }
    $pactual = $page + 1;
    if ($pactual > $tpages) {
        $pactual = $tpages;
        $start = ($tpages - 1) * $limit;
    }
    $urlnav = '';
    if ($tpages > 1) {
        $urlnav .= $mc['urlmode'] ? 'usr/' . $user->uname() . '/set/' . $set->id() : '?usr='******'&amp;set=' . $set->id();
        $nav = new RMPageNav($num, $limit, $pactual, 5);
        $nav->target_url(GSFunctions::get_url() . $urlnav . ($mc['urlmode'] ? '/pag/{PAGE_NUM}/' : '&amp;pag={PAGE_NUM}'));
        $tpl->assign('upNavPage', $nav->render(false));
    }
    $showmax = $start + $limit;
    $showmax = $showmax > $num ? $num : $showmax;
    $tpl->assign('lang_showing', sprintf(__('Showing pictures %u to %u out of %u.', 'galleries'), $start + 1, $showmax, $num));
    $tpl->assign('limit', $limit);
    $tpl->assign('pag', $pactual);
    //Fin de barra de navegación
    $sql = str_replace("COUNT(*)", '*', $sql);
    $sql .= " ORDER BY a.id_image ASC, a.modified DESC LIMIT {$start}, {$limit}";
    $result = $db->query($sql);
    while ($row = $db->fetchArray($result)) {
        $img = new GSImage();
        $img->assignVars($row);
        $imglink = $user->userURL() . ($mc['urlmode'] ? 'img/' . $img->id() . '/set/' . $set->id() . '/' : '&amp;img=' . $img->id() . '&amp;set=' . $set->id());
        $imgfile = $user->filesURL() . '/' . ($mc['set_format_mode'] ? 'formats/set_' : 'ths/') . $img->image();
        // Conversion de los formatos
        if (!$img->setFormat() && $mc['set_format_mode']) {
            GSFunctions::resizeImage($crop, $user->filesPath() . '/' . $img->image(), $user->filesPath() . '/formats/set_' . $img->image(), $width, $height);
            $img->setSetFormat(1, 1);
        }
        $tpl->append('images', array('id' => $img->id(), 'title' => $img->title(), 'thumbnail' => $imgfile, 'link' => $imglink, 'bigimage' => $user->filesURL() . '/' . $img->image()));
    }
    // Imagen grande del album
    $sql = "SELECT * FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image {$public} AND owner='" . $user->uid() . "' \n\t\t\tORDER BY a.id_image DESC LIMIT 0,{$blimit}";
    $result = $db->query($sql);
    $bi = 0;
    $tf = new RMTimeFormatter(0, __('%m%/%d%/%Y% %h%:%i%', 'galleries'));
    // cremos la imagen grande para los albumes
    while ($row = $db->fetchArray($result)) {
        $img = new GSImage();
        $img->assignVars($row);
        if ($mc['set_format_mode'] && !$img->bigSetFormat()) {
            GSFunctions::resizeImage($bcrop, $user->filesPath() . '/' . $img->image(), $user->filesPath() . '/formats/bigset_' . $img->image(), $bwidth, $bheight);
            $img->setBigSetFormat(1, 1);
        }
        if ($mc['set_format_mode']) {
            list($ancho, $altura, $tipo, $atr) = getimagesize($user->filesPath() . '/formats/bigset_' . $img->image());
            $tpl->assign('big_width', $ancho);
        }
        $imglink = $user->userURL() . 'img/' . $img->id() . '/set/' . $set->id() . '/';
        // ASignamos las imagenes grandes para los albumes
        $imgfile = $user->filesURL() . '/' . ($mc['set_format_mode'] ? 'formats/bigset_' : 'ths/') . $img->image();
        if ($bi == 0) {
            $tpl->assign('lang_updated', sprintf(__('Updated on %s', 'galleries'), $tf->format($img->created())));
        }
        $tpl->append('bigs', array('id' => $img->id(), 'title' => $img->title(), 'image' => $imgfile, 'link' => $imglink));
    }
    RMFunctions::get_comments('galleries', 'set=' . $set->id());
    // Comments form
    RMFunctions::comments_form('galleries', 'set=' . $set->id(), 'module', GS_PATH . '/class/galleriescontroller.php');
    // Datos para el formato
    $tpl->assign('max_cols', $cols);
    include 'footer.php';
}
/**
* @desc Visualiza todas la imágenes de favoritos
**/
function showBookMarks()
{
    global $xoopsOption, $tpl, $db, $xoopsUser, $xoopsModuleConfig, $pag, $xoopsConfig;
    $xoopsOption['template_main'] = 'gs_panel_bookmarks.html';
    include 'header.php';
    $mc =& $xoopsModuleConfig;
    GSFunctions::makeHeader();
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_favourites') . " a INNER JOIN " . $db->prefix('gs_images') . " b ON (";
    $sql .= " a.id_image=b.id_image AND a.uid='" . $xoopsUser->uid() . "')";
    $page = isset($pag) ? $pag : '';
    $limit = 10;
    list($num) = $db->fetchRow($db->query($sql));
    if ($page > 0) {
        $page -= 1;
    }
    $start = $page * $limit;
    $tpages = (int) ($num / $limit);
    if ($num % $limit > 0) {
        $tpages++;
    }
    $pactual = $page + 1;
    if ($pactual > $tpages) {
        $rest = $pactual - $tpages;
        $pactual = $pactual - $rest + 1;
        $start = ($pactual - 1) * $limit;
    }
    if ($tpages > 1) {
        if ($mc['urlmode']) {
            $urlnav = 'cpanel/bookmarks/';
        } else {
            $urlnav = '?cpanel=bookmarks';
        }
        $nav = new RMPageNav($num, $limit, $pactual, 5);
        $nav->target_url(GSFunctions::get_url() . $urlnav . ($mc['urlmode'] ? 'pag/{PAGE_NUM}/' : '&amp;pag={PAGE_NUM}'));
        $tpl->assign('bookmarksNavPage', $nav->render(false));
    }
    $showmax = $start + $limit;
    $showmax = $showmax > $num ? $num : $showmax;
    if ($num > 0) {
        $tpl->assign('lang_showing', sprintf(__('Showing pictures %u to %u from %u'), $start + 1, $showmax, $num));
    }
    $tpl->assign('limit', $limit);
    $tpl->assign('pag', $pactual);
    //Fin de barra de navegación
    $sql = "SELECT * FROM " . $db->prefix('gs_favourites') . " a INNER JOIN " . $db->prefix('gs_images') . " b ON (";
    $sql .= " a.id_image=b.id_image AND a.uid='" . $xoopsUser->uid() . "')";
    $sql .= " LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    $users = array();
    while ($rows = $db->fetchArray($result)) {
        $img = new GSImage();
        $img->assignVars($rows);
        if (!isset($users[$img->owner()])) {
            $users[$img->owner()] = new GSUser($img->owner(), 1);
        }
        $urlimg = $users[$img->owner()]->filesURL() . '/ths/' . $img->image();
        $link = $users[$img->owner()]->userURL() . 'img/' . $img->id() . '/';
        $tpl->append('images', array('id' => $img->id(), 'title' => $img->title(false), 'desc' => $img->desc(), 'public' => $img->isPublic(), 'image' => $urlimg, 'created' => formatTimeStamp($img->created(), 's'), 'owner' => $img->owner(), 'uname' => $users[$img->owner()]->uname(), 'link' => $link));
    }
    $tpl->assign('lang_exist', __('Existing Bookmarks', 'galleries'));
    $tpl->assign('lang_id', __('ID', 'galleries'));
    $tpl->assign('lang_title', __('Title', 'galleries'));
    $tpl->assign('lang_date', __('Created', 'galleries'));
    $tpl->assign('lang_owner', __('by user', 'galleries'));
    $tpl->assign('lang_image', __('Picture', 'galleries'));
    $tpl->assign('lang_public', __('Public', 'galleries'));
    $tpl->assign('lang_options', __('Options', 'galleries'));
    $tpl->assign('lang_edit', __('Edit', 'galleries'));
    $tpl->assign('lang_del', __('Delete', 'galleries'));
    $tpl->assign('lang_confirm', __('Do you really wish to deleted selected favorite?', 'galleries'));
    $tpl->assign('lang_confirms', __('Do you really wish to deleted selected favorites?', 'galleries'));
    $tpl->assign('delete_link', GSFunctions::get_url() . $xoopsModuleConfig['urlmode'] ? 'cp/delbookmarks/' : '?cp=delbookmarks');
    RMTemplate::get()->add_style('panel.css', 'galleries');
    createLinks();
    include 'footer.php';
}
Exemple #9
0
/**
* @desc Visualiza todas las imágenes existentes
**/
function showImages()
{
    global $xoopsModule, $tpl, $xoopsConfig, $xoopsSecurity, $xoopsUser;
    $db = Database::getInstance();
    $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
    $page = $page <= 0 ? 1 : $page;
    $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15;
    $limit = $limit <= 0 ? 15 : $limit;
    $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
    $owner = isset($_REQUEST['owner']) ? $_REQUEST['owner'] : '';
    $mindate = isset($_REQUEST['mindate']) ? $_REQUEST['mindate'] : '';
    $maxdate = isset($_REQUEST['maxdate']) ? $_REQUEST['maxdate'] : '';
    $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'created';
    $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 1;
    $mode = $mode == '' ? 1 : $mode;
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_images');
    $sql1 = '';
    $words = array();
    if ($search != '') {
        //Separamos en palabras
        $words = explode(" ", $search);
        foreach ($words as $k) {
            $k = trim($k);
            if (strlen($k) <= 2) {
                continue;
            }
            $sql1 .= $sql1 == '' ? " WHERE (title LIKE '%{$k}%')" : " OR (title LIKE '%{$k}%')";
        }
    }
    if ($owner > 0) {
        $sql1 .= $search != '' ? " AND owner='{$owner}'" : " WHERE owner='{$owner}'";
    }
    if ($mindate != '') {
        $maxdate = $maxdate != '' ? $maxdate : time();
        $sql1 .= $search != '' || $owner > 0 ? " AND " : " WHERE ";
        $sql1 .= "(created>='{$mindate}' AND created<='{$maxdate}')";
    }
    list($num) = $db->fetchRow($db->query($sql . $sql1));
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $tpages = ceil($num / $limit);
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url("images.php?page={PAGE_NUM}&amp;limit={$limit}&amp;search={$search}&amp;owner={$owner}&amp;mindate={$mindate}&amp;maxdate={$maxdate}&amp;sort={$sort}&amp;mode={$mode}");
    $showmax = $start + $limit;
    $showmax = $showmax > $num ? $num : $showmax;
    //Fin de barra de navegación
    $sql = "SELECT * FROM " . $db->prefix('gs_images');
    $sql2 = " ORDER BY {$sort} " . ($mode ? "DESC" : "ASC");
    $sql2 .= " LIMIT {$start},{$limit}";
    $result = $db->query($sql . $sql1 . $sql2);
    $users = array();
    $images = array();
    while ($rows = $db->fetchArray($result)) {
        $title = '';
        foreach ($words as $k) {
            $title = eregi_replace("({$k})", "<span class='searchResalte'>\\1</span>", $rows['title']);
        }
        $img = new GSImage();
        $img->assignVars($rows);
        if (!isset($users[$img->owner()])) {
            $users[$img->owner()] = new GSUser($img->owner(), 1);
        }
        $link = $users[$img->owner()]->userURL() . "img/" . $img->id();
        $xu = $users[$img->owner()];
        $images[] = array('id' => $img->id(), 'title' => $title ? $title : $img->title(), 'desc' => substr($img->desc(), 0, 150), 'image' => $users[$img->owner()]->filesURL() . '/ths/' . $img->image(), 'created' => formatTimeStamp($img->created(), 'c'), 'owner' => $xu->uname(), 'public' => $img->isPublic(), 'link' => $link);
    }
    $form = new RMForm('', 'frmNav', '');
    $ele = new RMFormUser('', 'owner', false, $owner > 0 ? array($owner) : array(0), 50, null, null, 1);
    $ele->setForm('frmNav');
    $tpl->assign('user_field', $ele->render());
    $ele = new RMFormDate('', 'mindate', $mindate == null ? null : $mindate, 1);
    $tpl->assign('mindate_field', $ele->render());
    $ele = new RMFormDate('', 'maxdate', $maxdate == null ? null : $maxdate, 1);
    $tpl->assign('maxdate_field', $ele->render());
    GSFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Images Management', 'galleries'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Images', 'galleries'));
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->add_local_script('images.js', 'galleries');
    RMTemplate::get()->add_local_script('gsscripts.php?file=sets&form=frm-images&p=' . TextCleaner::getInstance()->encrypt($xoopsUser->uid() . '|' . GS_URL . '/admin/images.php' . '|' . $xoopsSecurity->createToken(), true), 'galleries');
    RMTemplate::get()->add_head("<script type='text/javascript'>\nvar delete_warning='" . __('Do you really wish to delete selected images?', 'galleries') . "';\n</script>");
    xoops_cp_header();
    include RMTemplate::get()->get_template("admin/gs_images.php", 'module', 'galleries');
    xoops_cp_footer();
}