Esempio n. 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;
}
 public function get_item($params, $com, $url = false)
 {
     static $cimgs;
     static $csets;
     $params = urldecode($params);
     parse_str($params);
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gstag.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php';
     if (isset($set) && $set > 0) {
         if (isset($csets[$set])) {
             return $csets[$set]->title();
         }
         $sobj = new GSSet($set);
         if ($sobj->isNew()) {
             return __('Unknow element', 'galleries');
         }
         $ret = $sobj->title();
         $csets[$set] = $sobj;
         return $ret;
     } elseif (isset($image) && $image > 0) {
         if (isset($cimgs[$image])) {
             $ret = $cresources[$res]->getVar('title');
             return $ret;
         }
         $img = new GSImage($image);
         if ($img->isNew()) {
             return __('Unknow element', 'docs');
         }
         $ret = $img->title(true);
         $cimgs[$image] = $img;
         return $ret;
     }
 }
Esempio n. 3
0
/**
* @desc Muestra el formulario para la creación de la postal
*/
function newPostcard()
{
    global $xoopsUser, $xoopsModule, $xoopsModuleConfig, $mc, $tpl, $img, $xoopsOption, $xoopsConfig;
    if (!$xoopsUser) {
        redirect_header(XOOPS_URL . '/user.php#register', 1, __('You must be a registered user in order to send postcards!', 'galleries'));
        die;
    }
    $image = new GSImage($img);
    if ($image->isNew()) {
        redirect_header(GSFunctions::get_url(), 1, __('Specified image does not exists!', 'galleries'));
        die;
    }
    $xoopsOption['template_main'] = "gs_postcard_form.html";
    include 'header.php';
    //Eliminamos las postales que han cumplido si tiempo
    GSFunctions::deletePostcard();
    GSFunctions::makeHeader();
    $tpl->assign('xoops_pagetitle', sprintf(__('Send Postcard', 'galleries'), $image->title()));
    $postlink = GSFunctions::get_url() . ($mc['urlmode'] ? 'postcard/new/img/' . $image->id() . '/' : '?postcard=new&amp;img=' . $image->id());
    $sendlink = str_replace('/new/', '/send/', $postlink);
    $form = new RMForm(__('Send Postcard', 'galleries'), 'frmNewPostcard', $sendlink);
    $form->addElement(new RMFormText(__('Your name', 'galleries'), 'fname', 50, 100, $xoopsUser->getVar('name')), true);
    $form->addElement(new RMFormText(__('Your email', 'galleries'), 'fmail', 50, 150, $xoopsUser->getVar('email')), true, 'email');
    $form->addElement(new RMFormText(__('Friend name', 'galleries'), 'tname', 50, 100, ''), true);
    $form->addElement(new RMFormText(__('Friend email', 'galleries'), 'tmail', 50, 150, ''), true, 'email');
    $form->addElement(new RMFormText(__('Postcard title', 'galleries'), 'title', 50, 150, $image->title(false)), true);
    $form->addElement(new RMFormTextArea(__('Postcard text', 'galleries'), 'msg', 0, 0, '', '90%', '150px'), true);
    $cap = RMEvents::get()->run_event('rmcommon.recaptcha.field');
    if ($cap != '') {
        $form->addElement(new RMFormLabel(__('Please enter the captcha below', 'galleries'), $cap));
    }
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', _SUBMIT, 'submit', 'onclick="$(\'op\').value=\'send\';"');
    $previewlink = str_replace('/new/', '/preview/', $postlink);
    $ele->addButton('preview', __('Preview Postcard', 'galleries'), 'button', 'onclick="$(\'#frmNewPostcard\').attr(\'action\', \'' . $previewlink . '\'); $(\'#frmNewPostcard\').submit();"');
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('op', 'send'));
    $form->addElement(new RMFormHidden('img', $image->id()));
    $form->addElement(new RMFormHidden('uid', $xoopsUser->uid()));
    $form->addElement(new RMFormHidden('return', base64_encode($postlink)));
    $tpl->assign('postcard_form', $form->render());
    include 'footer.php';
}
Esempio n. 4
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;
}
Esempio n. 5
0
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;
 }
Esempio n. 7
0
function send_sets()
{
    global $xoopsLogger, $xoopsModuleConfig;
    $xoopsLogger->renderingEnabled = false;
    error_reporting(0);
    $xoopsLogger->activated = false;
    $mc =& $xoopsModuleConfig;
    $db = Database::getInstance();
    $limit = rmc_server_var($_GET, 'limit', 5);
    // recent pictures
    $sql = "SELECT * FROM " . $db->prefix("gs_sets") . " ORDER BY `date` DESC LIMIT 0,{$limit}";
    $result = $db->query($sql);
    $sets = array();
    $users = array();
    while ($row = $db->fetchArray($result)) {
        $set = new GSSet();
        $set->assignVars($row);
        $pics = $set->getPics('RAND()');
        $img = new GSImage($pics[0]);
        if (!isset($users[$img->owner()])) {
            $users[$img->owner()] = new GSUser($img->owner(), 1);
        }
        if ($img->isNew()) {
            $image = array('title' => __('Empty album', 'galleries'), 'link' => '', 'thumbnail' => GS_URL . '/images/empty.jpg');
        } else {
            $image = array('title' => $img->title(), 'link' => $users[$img->owner()]->userURL() . ($mc['urlmode'] ? 'img/' . $img->id() . '/' : '&amp;img=' . $img->id()), 'thumbnail' => $users[$img->owner()]->filesURL() . '/ths/' . $img->image());
        }
        $sets[] = array('title' => $set->title(), 'link' => $set->url(), 'image' => $image);
    }
    ob_start();
    ?>
    <?php 
    foreach ($sets as $set) {
        ?>
    <a href="<?php 
        echo $set['link'];
        ?>
" target="_blank" title="<?php 
        echo $set['title'];
        ?>
"><img src="<?php 
        echo $set['image']['thumbnail'];
        ?>
" alt="<?php 
        echo $set['title'];
        ?>
" /></a>
    <?php 
    }
    ?>
    <?php 
    $recents = ob_get_clean();
    echo $recents;
    die;
}
Esempio n. 8
0
     $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss');
     $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true);
     $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true);
     $rss_channel['category'] = __('Pictures', 'galleries');
     $rss_channel['generator'] = 'MyGalleries 3';
     $rss_channel['language'] = RMCLANG;
     $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');
Esempio n. 9
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';
}
Esempio n. 10
0
/**
*  @desc Elimina una imagen de favoritos
**/
function deleteBookMarks()
{
    global $xoopsUser, $xoopsModuleConfig;
    $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
    $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : '';
    $mc =& $xoopsModuleConfig;
    $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/bookmarks/pag/' . $page . '/' : '?cp=bookmarks&amp;pag=' . $page);
    //Verificamos si nos proporcionaron al menos un imagen para eliminar
    if (!is_array($ids)) {
        redirect_header($link, 2, __('You must select one picture at least!', 'galleries'));
        die;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $db = Database::getInstance();
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si la imagen sea válida
        if ($k <= 0) {
            $errors .= sprintf(__('ID %u is not valid!', 'galleries'), $k);
            continue;
        }
        //Verificamos si la imagen existe
        $img = new GSImage($k);
        if ($img->isNew()) {
            $errors .= sprintf(__('Image with id %u is not valid!', 'galleries'), $k);
            continue;
        }
        $sql = "DELETE FROM " . $db->prefix('gs_favourites') . " WHERE id_image='" . $k . "' AND uid='" . $xoopsUser->uid() . "'";
        $result = $db->queryF($sql);
        if (!$result) {
            $errors .= sprintf(__('Favorite picture "%s" could not be deleted!', 'galleries'), $img->title());
        }
    }
    if ($errors != '') {
        redirect_header($link, 2, __('Errors ocurred while trying to delete favorites!', 'galleries') . $errors);
        die;
    } else {
        redirect_header($link, 1, __('Favorites deleted successfully!', 'galleries'));
        die;
    }
}
Esempio n. 11
0
    if (!isset($users[$set->owner()])) {
        $users[$set->owner()] = new GSUser($set->owner(), 1);
    }
    $images = array();
    if (!empty($imgs)) {
        // Obtenemos las primeras 4 imágenes
        foreach ($imgs as $k) {
            $img = new GSImage($k);
            if ($img->isPublic() != 2) {
                continue;
            }
            if (!isset($users[$img->owner()])) {
                $users[$img->owner()] = new GSUser($img->owner(), 1);
            }
            $imglink = $users[$img->owner()]->userURL() . 'img/' . $img->id() . '/';
            $images[] = array('id' => $img->id(), 'title' => $img->title(), 'thumbnail' => $users[$img->owner()]->filesURL() . '/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);
        }
    }
    $tpl->append('sets', array('id' => $set->id(), 'title' => $set->title(), 'images' => $images, 'link' => $users[$set->owner()]->userUrl() . ($mc['urlmode'] ? 'set/' . $set->id() : '&amp;set=' . $set->id()), 'date' => formatTimestamp($set->date(), 'c'), 'by' => '<a href="' . $users[$set->owner()]->userUrl() . '">' . $users[$set->owner()]->uname() . '</a>', 'picsnum' => count($pics)));
}
$result = $db->query("SELECT * FROM " . $db->prefix("gs_sets") . " WHERE public='2' ORDER BY date DESC LIMIT {$mc['sets_num']}," . ($mc['sets_num'] > 0 ? $mc['sets_num'] : 5));
while ($row = $db->fetchArray($result)) {
    $set = new GSSet();
    $set->assignVars($row);
    if (!isset($users[$set->owner()])) {
        $users[$set->owner()] = new GSUser($set->owner(), 1);
    }
    $tpl->append('other_sets', array('id' => $set->id(), 'title' => $set->title(), 'link' => $users[$set->owner()]->userUrl() . ($mc['urlmode'] ? 'set/' . $set->id() : '&amp;set=' . $set->id()), 'date' => formatTimestamp($set->date(), 'c'), 'by' => '<a href="' . $users[$set->owner()]->userUrl() . '">' . $users[$set->owner()]->uname() . '</a>', 'picsnum' => count($pics)));
}
RMTemplate::get()->add_style('index.css', 'galleries');
include 'footer.php';
Esempio n. 12
0
/**
* @desc Formulario de creación/edición de imágenes
**/
function formImages($edit = 0)
{
    global $xoopsModule, $mc, $xoopsUser, $db;
    $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
    $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 10;
    $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
    $owner = isset($_REQUEST['owner']) ? $_REQUEST['owner'] : '';
    $uid = isset($_REQUEST['uid']) ? intval($_REQUEST['uid']) : 0;
    $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'created';
    $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 0;
    $ruta = "page={$page}&limit={$limit}&search={$search}&owner={$owner}&sort={$sort}&mode={$mode}";
    if ($edit) {
        //Verificamos si la imagen es válida
        if ($id <= 0) {
            redirectMsg('./images.php?' . $ruta, __('Image ID not valid!', 'galleries'), 1);
            die;
        }
        //Verificamos si la imagen existe
        $img = new GSImage($id);
        if ($img->isNew()) {
            redirectMsg('./images.php?' . $ruta, __('Specified image does not exists!', 'galleries'), 1);
            die;
        }
    }
    GSFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='./images.php'>" . __('Images', 'galleries') . "</a> &raquo; " . ($edit ? __('Edit image', 'galleries') : __('Add image', 'galleries')));
    xoops_cp_header();
    $form = new RMForm($edit ? __('Editing image', 'galleries') : __('Add image', 'galleries'), 'frmimg', 'images.php');
    $form->setExtra("enctype='multipart/form-data'");
    if (!$edit) {
        $ele = new RMFormUser(__('User', 'galleries'), 'uid', 0, $uid ? array($uid) : ($edit ? array($img->owner()) : array($xoopsUser->uid())), 50);
        $ele->onChange("\$('op').value='" . ($edit ? 'edit' : 'new') . "'; \$('frmimg').submit();");
        $form->addElement($ele);
    } else {
        $xu = new XoopsUser($img->owner());
        $form->addElement(new RMFormLabel(__('User', 'galleries'), $xu->uname()));
        $form->addElement(new RMFormHidden('uid', $img->owner()));
    }
    $form->addElement(new RMFormText(__('Title', 'galleries'), 'title', 50, 100, $edit ? $img->title() : ''));
    $form->addElement(new RMFormFile(__('Image file', 'galleries'), 'image', 45, $mc['size_image'] * 1024));
    if ($edit) {
        $user = new GSUser($img->owner(), 1);
        $url = $user->filesURL();
        $form->addElement(new RMFormLabel(__('Current image', 'galleries'), "<img src='" . $url . "/ths/" . $img->image() . "' />"));
    }
    $form->addElement(new RMFormTextArea(__('Description', 'galleries'), 'desc', 4, 50, $edit ? $img->desc() : ''));
    $ele = new RMFormSelect(__('Privacy', 'galleries'), 'public');
    $ele->addOption(0, __('Private', 'galleries'), $edit ? $img->isPublic() == 0 ? 1 : 0 : 0);
    $ele->addOption(1, __('Visible for friends', 'galleries'), $edit ? $img->isPublic() == 1 ? 1 : 0 : 0);
    $ele->addOption(2, __('Visible for all', 'galleries'), $edit ? $img->isPublic() == 2 ? 1 : 0 : 1);
    $form->addElement($ele, true);
    $db = Database::getInstance();
    //Albumes
    if ($edit) {
        $albums = $img->sets(false);
        foreach ($albums as $k => $v) {
            $sets[] = $v['id_set'];
        }
    }
    $ele = new RMFormSelect(__('Albums', 'galleries'), 'albums[]', 1, $edit ? $sets : '');
    $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE owner='" . ($uid ? $uid : ($edit ? $img->owner() : $xoopsUser->uid())) . "'";
    $result = $db->query($sql);
    while ($rows = $db->fetchArray($result)) {
        $ele->addOption($rows['id_set'], $rows['title']);
    }
    $form->addElement($ele);
    $ele = new RMFormText(__('Tags', 'galleries'), 'tags', 50, 100, $edit ? implode(", ", $img->tags(false, 'tag')) : '');
    $ele->setDescription(__('Separate each tag with a comma (,)', 'galleries'));
    $form->addElement($ele, true);
    $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $id));
    }
    $form->addElement(new RMFormHidden('page', $page));
    $form->addElement(new RMFormHidden('limit', $limit));
    $form->addElement(new RMFormHidden('search', $search));
    $form->addElement(new RMFormHidden('owner', $owner));
    $form->addElement(new RMFormHidden('sort', $sort));
    $form->addElement(new RMFormHidden('mode', $mode));
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', $edit ? __('Save changes', 'galleries') : __('Add image', 'galleries'), 'submit');
    $buttons->addButton('cancel', __('Cancel', 'galleries'), 'button', 'onclick="window.location=\'images.php?' . $ruta . '\'"');
    $form->addElement($buttons);
    $form->display();
    xoops_cp_footer();
}
Esempio n. 13
0
/**
* @desc Almacena el título y descripción de las imágenes
**/
function saveAll()
{
    $names = isset($_REQUEST['names']) ? $_REQUEST['names'] : null;
    $desc = isset($_REQUEST['descs']) ? $_REQUEST['descs'] : null;
    $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : '';
    $errors = '';
    foreach ($names as $k => $v) {
        //Verificamos si la imagen es válida
        if ($k <= 0) {
            $errors .= sprintf(__('Picture %s is not valid!', 'galleries'), $k);
            continue;
        }
        //Verificamos si la imagen existe
        $img = new GSImage($k);
        if ($img->isNew()) {
            $errors .= sprintf(__('Picture %s does not exists', 'galleries'), $k);
            continue;
        }
        $band = false;
        if ($v != $img->title()) {
            $img->setTitle($v);
            $band = true;
        }
        if ($desc[$k] != $img->desc()) {
            $img->setDesc($desc[$k]);
            $band = true;
        }
        if ($band) {
            $img->setModified(time());
            if (!$img->save()) {
                $errors .= sprintf(__('Picture %s could not be saved!', 'galleries'), $img->title());
            }
        }
    }
    if ($errors != '') {
        redirect_header('./cpanel.php?pag=' . $page, 2, __('Errors ocurred while trying to save changes.', 'galleries') . $errors);
        die;
    } else {
        redirect_header('./cpanel.php?pag=' . $page, 2, __('Changes applied successfully!', 'galleries'));
        die;
    }
}