示例#1
0
 public function eventRmcommonTextTodisplay($text, $source)
 {
     if (defined("XOOPS_CPFUNC_LOADED")) {
         return $text;
     }
     $search = "/\\[gallery (.*?)\\]/is";
     $replace = "\$1";
     $amatches = array();
     $count = preg_match_all($search, $text, $amatches);
     if ($count <= 0) {
         return $text;
     }
     for ($ic = 0; $ic < $count; $ic++) {
         $matches = array($amatches[0][$ic], $amatches[1][$ic]);
         $search = explode(" ", strip_tags($matches[1]));
         foreach ($search as $i) {
             $t = explode("=", $i);
             ${$t}[0] = $t[1];
         }
         include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php';
         $data = GSFunctions::load_images($id, $num, 1);
         if (empty($data)) {
             $text = str_replace($matches[0], '', $text);
             continue;
         }
         $images = $data['images'];
         if (!defined("GS_INCLUDED_GALS")) {
             if (RMFunctions::plugin_installed("lightbox")) {
                 RMLightbox::get()->add_element('.gs_gsl_item a');
                 RMLightbox::get()->render();
             }
             RMTemplate::get()->add_xoops_style('inclusion.css', 'galleries');
             RMTemplate::get()->add_local_script('inclusion.js', 'galleries');
             RMTemplate::get()->add_head('<script type="text/javascript">var gsurl = "' . XOOPS_URL . '/modules/galleries";</script>');
             define("GS_INCLUDED_GALS", 1);
         }
         // Pagination
         $page = $data['current'];
         $limit = $data['limit'];
         $num = $data['total'];
         $set = $data['set'];
         if ($full == 'true') {
             $nav = new RMPageNav($num, $limit, $page);
             $nav->set_template(RMTemplate::get()->get_template("other/gs_nav_included.php", "module", "galleries"));
             $nav->target_url($set['id'] . ',' . $limit);
         }
         $content = '';
         ob_start();
         echo '<div class="gals_loader">';
         include RMTemplate::get()->get_template('other/gs_gals_inclusion.php', 'module', 'galleries');
         echo '</div>';
         $content = ob_get_clean();
         $text = str_replace($matches[0], $content, $text);
     }
     return $text;
 }
示例#2
0
 public function eventRmcommonGetFeedsList($feeds)
 {
     load_mod_locale('galleries');
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php';
     $module = RMFunctions::load_module('galleries');
     $config = RMUtilities::module_config('galleries');
     $data = array('title' => $module->name(), 'url' => GSFunctions::get_url(), 'module' => 'galleries');
     $options[] = array('title' => __('All Recent Pictures', 'galleries'), 'params' => 'show=pictures', 'description' => __('Show all recent pictures', 'galleries'));
     $options[] = array('title' => __('All Recent Albums', 'galleries'), 'params' => 'show=albums', 'description' => __('Show all recent albums', 'galleries'));
     $feed = array('data' => $data, 'options' => $options);
     $feeds[] = $feed;
     return $feeds;
 }
示例#3
0
function createLinks()
{
    global $tpl, $xoopsModuleConfig, $xmh, $xoopsUser;
    $mc =& $xoopsModuleConfig;
    $tpl->assign('link_bookmarks', GSFunctions::get_url() . ($mc['urlmode'] ? "cp/bookmarks/" : "?cp=bookmarks"));
    $tpl->assign('lang_favourites', __('Favorites', 'galleries'));
    $tpl->assign('user', 0);
    $users = GSFunctions::getAllowedUsers();
    if (in_array($xoopsUser->uid(), $users)) {
        $tpl->assign('link_friends', GSFunctions::get_url() . ($mc['urlmode'] ? "cp/friends/" : "?cp=friends"));
        $tpl->assign('link_photos', GSFunctions::get_url() . ($mc['urlmode'] ? "cp/images/" : "?cp=images"));
        $tpl->assign('link_sets', GSFunctions::get_url() . ($mc['urlmode'] ? "cp/sets/" : "?cp=sets"));
        $tpl->assign('lang_friends', __('Friends', 'galleries'));
        $tpl->assign('lang_msets', __('My Albums', 'galleries'));
        $tpl->assign('lang_mpics', __('My Images', 'galleries'));
        $tpl->assign('user', 1);
    }
}
示例#4
0
/**
* @desc Formulario de creación/edición de usuarios
**/
function formUsers($edit = 0)
{
    global $xoopsModule, $xoopsModuleConfig;
    $mc =& $xoopsModuleConfig;
    $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : '';
    $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15;
    $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
    $ruta = "pag={$page}&search={$search}";
    if ($edit) {
        //Verificamos que el usuario sea válido
        if ($id <= 0) {
            redirectMsg('./users.php?' . $ruta, __('User id is not valid!', 'galleries'), 1);
            die;
        }
        //Verificamos que el usuario exista
        $user = new GSUser($id);
        if ($user->isNew()) {
            redirectMsg('./users.php?' . $ruta, __('Specified user does not exists!', 'galleries'), 1);
            die;
        }
    }
    GSFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='./users.php'>" . __('Users management', 'galleries') . "</a> &raquo; " . ($edit ? __('Edit User', 'galleries') : __('New User', 'galleries')));
    RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit User', 'galleries') : __('New User', 'galleries'));
    xoops_cp_header();
    $form = new RMForm($edit ? __('Edit User', 'galleries') : __('New User', 'galleries'), 'frmuser', 'users.php');
    $form->addElement(new RMFormUser(__('Xoops User', 'galleries'), 'uid', 0, $edit ? array($user->uid()) : '', 30));
    $ele = new RMFormText(__('Max Quota', 'galleries'), 'quota', 10, 10, $edit ? $user->quota() / 1024 / 1024 : $mc['quota']);
    $ele->setDescription(__('This value determines the total disc quota to be used for user and must be specified in megabytes.', 'galleries'));
    $form->addElement($ele, true);
    $form->addElement(new RMFormYesno(__('Blocked', 'galleries'), 'block', $edit ? $user->blocked() : 0));
    $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save'));
    $form->addElement(new RMFormHidden('id', $id));
    $form->addElement(new RMFormHidden('page', $page));
    $form->addElement(new RMFormHidden('search', $search));
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', $edit ? __('Save Changes', 'galleries') : __('Create User', 'galleries'), 'submit');
    $buttons->addButton('cancel', __('Cancel', 'galleries'), 'button', 'onclick="window.location=\'users.php?' . $ruta . '\'"');
    $form->addElement($buttons);
    $form->display();
    xoops_cp_footer();
}
示例#5
0
function send_pictures()
{
    global $xoopsLogger;
    $xoopsLogger->renderingEnabled = false;
    error_reporting(0);
    $xoopsLogger->activated = false;
    $db = Database::getInstance();
    $limit = rmc_server_var($_GET, 'limit', 5);
    // recent pictures
    $sql = "SELECT * FROM " . $db->prefix("gs_images") . " ORDER BY `created` DESC LIMIT 0,{$limit}";
    $result = $db->query($sql);
    $recents = GSFunctions::process_image_data($result);
    ob_start();
    ?>
    <?php 
    foreach ($recents as $pic) {
        ?>
    <a href="<?php 
        echo $pic['link'];
        ?>
" target="_blank" title="<?php 
        echo $pic['title'];
        ?>
"><img src="<?php 
        echo $pic['thumbnail'];
        ?>
" alt="<?php 
        echo $pic['title'];
        ?>
" /></a>
    <?php 
    }
    ?>
    <?php 
    $recents = ob_get_clean();
    echo $recents;
    die;
}
示例#6
0
/**
* @desc Visualiza todas las postales existentes
**/
function showPostCards()
{
    global $xoopsModule, $tpl, $xoopsModuleConfig, $xoopsSecurity;
    $mc =& $xoopsModuleConfig;
    $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
    $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15;
    $limit = $limit <= 0 ? 15 : $limit;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_postcards');
    list($num) = $db->fetchRow($db->query($sql));
    list($num) = $db->fetchRow($db->query($sql));
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $tpages = ceil($num / $limit);
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url("postcards.php?page={PAGE_NUM}&limit={$limit}");
    //Fin de barra de navegación
    $sql = "SELECT * FROM " . $db->prefix('gs_postcards');
    $sql .= " LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    $posts = array();
    $tf = new RMTimeFormatter(0, __('%M% %d%, %Y% - %h%:%i%:%s%', 'galleries'));
    while ($rows = $db->fetchArray($result)) {
        $post = new GSPostcard();
        $post->assignVars($rows);
        $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'postcard/view/id/' . $post->code() . '/' : '?postcard=view&amp;id=' . $post->code());
        $posts[] = array('id' => $post->id(), 'title' => $post->title(), 'date' => $tf->format($post->date()), 'toname' => $post->toName(), 'name' => $post->email(), 'view' => $post->viewed(), 'link' => $link);
    }
    GSFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('E-cards', 'galleries'));
    xoops_cp_header();
    RMTemplate::get()->add_local_script('gsscripts.php?file=sets&form=frm-postcards&', 'galleries');
    RMTemplate::get()->add_head("<script type='text/javascript'>\nvar delete_warning='" . __('Do you really wish to delete selected e-cards?', 'galleries') . "';\n</script>");
    include RMTemplate::get()->get_template('admin/gs_postcards.php', 'module', 'galleries');
    xoops_cp_footer();
}
示例#7
0
/**
* @desc Busca la posición exacta de una etiqueta
*/
function browsePic()
{
    global $usr, $mc, $xoopsModuleConfig, $xoopsConfig, $xoopsUser, $pag, $set, $browse;
    $mc =& $xoopsModuleConfig;
    $user = new GSUser($usr);
    if ($user->isNew()) {
        redirect_header(XOOPS_URL . '/modules/galleries', 0, _MS_GS_ERRUSR);
        die;
    }
    $image = new GSImage($browse);
    if ($image->isNew()) {
        redirect_header(XOOPS_URL . '/modules/galleries', 0, _MS_GS_ERRIMG);
        die;
    }
    if (isset($set)) {
        $set = new GSSet($set);
        if ($set->isNew()) {
            redirect_header(XOOPS_URL . '/modules/galleries', 0, _MS_GS_ERRSET);
            die;
        }
    }
    $page = GSFunctions::pageFromPic($image, $user, $set > 0 ? $set : 0);
    header('location: ' . $user->userURL() . 'pag/' . $page);
}
示例#8
0
/**
* @desc Envia la postal
*/
function sendPostcard()
{
    global $tpl, $xoopsModule, $xoopsModuleConfig, $rmc_config, $mc, $xoopsUser, $xoopsConfig, $util;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    if (!$xoopsUser) {
        redirect_header(XOOPS_URL . '/user.php#register', 1, _MS_GS_ERRUSR);
        die;
    }
    $img = new GSImage($img);
    if ($img->isNew()) {
        redirect_header(XOOPS_URL . '/modules/galleries/', 1, _MS_GS_ERRIMG);
        die;
    }
    // Recaptcha check
    if (!RMEvents::get()->run_event('rmcommon.captcha.check', true)) {
        redirect_header(GSFunctions::get_url() . ($xoopsModuleConfig['urlmode'] ? 'postcard/new/img/' . $img->id() . '/' : '?postcard=new&amp;img=' . $img->id()), 1, __('Please check the security words and write it correctly!', 'contact'));
        die;
    }
    $post = new GSPostcard();
    $post->setTitle($title);
    $post->setMessage($msg);
    $post->setDate(time());
    $post->setToName($tname);
    $post->setToEmail($tmail);
    $post->setImage($img->id());
    $post->setName($fname);
    $post->setEmail($fmail);
    $post->setUid($uid);
    $post->setIp($_SERVER['REMOTE_ADDR']);
    $post->setViewed(0);
    //Generamos el código de la postal
    $post->setCode(RMUtilities::randomString(10, 1, false, 1, 1));
    if (!$post->save()) {
        redirect_header(base64_decode($return), 2, __('Unable to send e-card. Please try again!', 'galleries'));
        die;
    }
    $xoopsMailer =& getMailer();
    $xoopsMailer->useMail();
    $ectpl = is_file(XOOPS_ROOT_PATH . '/modules/galleries/lang/' . 'postcard-' . $rmc_config['language'] . '.tpl') ? $rmc_config['language'] . '.tpl' : 'postcard-en_US.tpl';
    $xoopsMailer->setTemplate($ectpl);
    $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']);
    $xoopsMailer->assign('SITEURL', XOOPS_URL . "/");
    $xoopsMailer->assign('FNAME', $fname);
    $xoopsMailer->assign('FMAIL', $fmail);
    $xoopsMailer->assign('TNAME', $tname);
    $xoopsMailer->assign('MODULE_LINK', GSfunctions::get_url());
    $xoopsMailer->assign('POSTAL_LINK', GSfunctions::get_url() . ($mc['urlmode'] ? 'postcard/view/id/' . $post->code() . '/' : '?postcard=view&amp;id=' . $post->code()));
    $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . "/modules/galleries/lang/");
    $xoopsMailer->setFromEmail($fmail);
    $xoopsMailer->setFromName($fname);
    $xoopsMailer->setToEmails($tmail);
    $xoopsMailer->setSubject(sprintf(_MS_GS_SUBJECT, $tname));
    if (!$xoopsMailer->send(true)) {
        redirect_header(base64_decode($return), 2, $xoopsMailer->getErrors());
    } else {
        redirect_header($user->userURL() . 'img/' . $img->id() . '/', 1, __('E-card sent successfully!', 'galleries'));
    }
}
} elseif ($action == 'load_structure') {
    include RMTemplate::get()->get_template('other/gs_for_editor.php', 'module', 'galleries');
    die;
} elseif ($action == 'load_included') {
    if (!$xoopsSecurity->checkReferer()) {
        die;
    }
    $set = rmc_server_var($_POST, 'set', 0);
    $page = rmc_server_var($_POST, 'page', 1);
    $limit = rmc_server_var($_POST, 'limit', 0);
    $full = true;
    if ($set <= 0 || $limit <= 0) {
        die;
    }
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php';
    $data = GSFunctions::load_images($set, $limit, $page);
    if (empty($data)) {
        die;
    }
    $images = $data['images'];
    // Pagination
    $page = $data['current'];
    $limit = $data['limit'];
    $num = $data['total'];
    $set = $data['set'];
    $nav = new RMPageNav($num, $limit, $page);
    $nav->set_template(RMTemplate::get()->get_template("other/gs_nav_included.php", "module", "galleries"));
    $nav->target_url($set['id'] . ',' . $limit);
    include RMTemplate::get()->get_template('other/gs_gals_inclusion.php', 'module', 'galleries');
    die;
}
示例#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;
    }
}
示例#11
0
 /**
  * @desc Determina el total de espacio usado en disco
  */
 public function usedQuota()
 {
     $path = $this->filesPath();
     return GSFunctions::folderSize($path);
 }
示例#12
0
/**
* @desc Almacena la asignación de albumes a las imágenes
**/
function saveSets()
{
    global $db, $xoopsUser, $xoopsConfig;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si la imagen es válida
        if ($k <= 0) {
            $errors .= sprintf(__('Picture with id %u is not valid!', 'galleries'), $k);
            continue;
        }
        //Verificamos si la imagen existe
        $img = new GSImage($k);
        if ($img->isNew()) {
            $errors .= sprintf(__('Picture with id %u does not exists!', 'galleries'), $k);
            continue;
        }
        if ($img->owner() != $xoopsUser->uid()) {
            $errors = sprintf(__('You don\'t have authorization!', 'galleries'), $k);
            continue;
        }
        $db = XoopsDatabaseFactory::getDatabaseConnection();
        $sets = '';
        $tbl1 = $db->prefix("gs_sets");
        $tbl2 = $db->prefix("gs_setsimages");
        foreach ($albums as $k => $v) {
            // Si el album existe no incrementamos el numero de imagenes
            if ($img->inSet($v)) {
                continue;
            }
            $album = new GSSet($v);
            $album->addPic($img->id());
        }
        // Actualizamos los valores de los ignorados
        $sql = "UPDATE {$tbl1}, {$tbl2} SET {$tbl1}.pics={$tbl1}.pics-1 WHERE ({$tbl2}.id_image='" . $img->id() . "'" . ($sets != '' ? ' AND ' . $sets : '') . ") AND {$tbl1}.id_set={$tbl2}.id_set";
        $db->queryF($sql);
    }
    if (!$referer) {
        $referer = GSFunctions::get_url();
    }
    if ($errors != '') {
        redirect_header($referer, 2, __('Errors ocurred while trying to update picture!', 'galleries') . $errors);
        die;
    } else {
        redirect_header($referer, 2, __('Pictures updated successfully!', 'galleries'));
        die;
    }
}
示例#13
0
 public function url()
 {
     global $xoopsModule, $xoopsModuleConfig;
     if (isset($xoopsModule) && $xoopsModule->dirname() == 'galleries') {
         $mc =& $xoopsModuleConfig;
     } else {
         $mc = RMUtilities::module_config('galleries');
     }
     $url = GSFunctions::get_url();
     $url .= $mc['urlmode'] ? 'usr/' . $this->uname() . "/set/" . $this->id() . '/' : "?usr="******"&amp;set=" . $this->id();
     return $url;
 }
示例#14
0
/**
* @desc Elimina de la base de datos los amigos especificados
**/
function deleteFriends()
{
    global $xoopsModuleConfig, $db, $xoopsUser, $page, $id;
    $mc =& $xoopsModuleConfig;
    $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/friends/pag/' . $page . '/' : 'cp=friends&amp;pag=' . $page);
    //Verificamos si nos proporcionaron al menos un amigo para eliminar
    if ($id <= 0) {
        redirect_header($link, 2, __('Specified id for friend is not valid!', 'galleries'));
        die;
    }
    //Verificamos si el amigo existe
    $exu = new XoopsUser($id);
    if ($exu->isNew()) {
        redirect_header($link, 2, __('Specified user does not exists!', 'galleries'));
        die;
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Verificamos si se trata de un amigo
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_friends') . " WHERE uid='" . $id . "' AND gsuser='******'";
    list($num) = $db->fetchRow($db->query($sql));
    if ($num <= 0) {
        redirect_header($link, 2, __('Specified user is not yoru friend!', 'galleries'));
        die;
    }
    $sql = "DELETE FROM " . $db->prefix('gs_friends') . " WHERE uid='" . $id . "' AND gsuser='******'";
    $result = $db->queryF($sql);
    if (!$result) {
        redirect_header($link, 2, __('Friend could not be deleted!', 'galleries'));
        die;
    } else {
        redirect_header($link, 1, __('Friend deleted successfully!', 'galleries'));
        die;
    }
}
 /**
  * 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;
 }
示例#16
0
/**
* @desc Elimina de la base de datos la información del album especificado
**/
function deleteSets()
{
    global $util, $xoopsModule, $db, $xoopsModuleConfig, $page;
    $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
    $mc =& $xoopsModuleConfig;
    $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/sets/pag/' . $pag . '/' : '?cp=sets&amp;pag=' . $pag);
    //Verificamos si nos proporcionaron al menos un imagen para eliminar
    if (!is_array($ids)) {
        redirect_header($link, 2, __('You must selecte one album at least!', 'galleries'));
        die;
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si el album es válido
        if ($k <= 0) {
            $errors .= sprintf(__('Album id %u is not valid!', 'galleries'), $k);
            continue;
        }
        //Verificamos si el album existe
        $set = new GSSet($k);
        if ($set->isNew()) {
            $errors .= sprintf(__('Album with id %u does not exists!', 'galleries'), $k);
            continue;
        }
        if (!$set->delete()) {
            $errors .= sprintf(__('Album "%s" could not be deleted!', 'galleries'), $set->title());
        }
    }
    if ($errors != '') {
        redirect_header($link, 2, __('Errors ocurred while trying to delete albums', 'galleries') . '<br />' . $errors);
        die;
    } else {
        redirect_header($link, 1, __('Abums deleted successfully!', 'galleries'));
        die;
    }
}
示例#17
0
/**
* @desc Visualiza todas las imágenes de la etiqueta especificada
**/
function imgsTag()
{
    global $tpl, $xoopsOption, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $db, $page, $tag, $usr, $hits;
    $xoopsOption['template_main'] = 'gs_imagestag.html';
    $xoopsOption['module_subpage'] = 'exploretags';
    include 'header.php';
    $mc =& $xoopsModuleConfig;
    GSFunctions::makeHeader();
    //Verificamos si la etiqueta existe
    $tag = new GSTag($tag);
    if ($tag->isNew()) {
        redirect_header(GSFunctions::get_url(), 1, __('Specified tag does not exists!', 'galleries'));
        die;
    }
    //Incrementamos el número de hits de la etiqueta
    if (!isset($_SESSION['vtags'])) {
        $tag->addHit();
        $_SESSION['vtags'] = array($tag->id());
    } elseif (!in_array($tag->id(), $_SESSION['vtags'])) {
        $tag->addHit();
        $_SESSION['vtags'][] = $tag->id();
    }
    //Verificamos si el usuario existe
    if (isset($usr)) {
        $user = new GSUser($usr);
        if ($user->isNew()) {
            redirect_header(GSFunctions::get_url(), 1, __('Specified user does not exists!', 'galleries'));
            die;
        }
        $users[$user->uid()] = $user;
    }
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_tagsimages') . " a INNER JOIN " . $db->prefix('gs_images');
    $sql .= " b ON (a.id_tag=" . $tag->id() . " AND a.id_image=b.id_image  AND b.public=2";
    $sql .= $usr ? " AND b.owner=" . $user->uid() . ") " : ")";
    $limit = $xoopsModuleConfig['num_imgstags'];
    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 = 'explore/tags/tag/' . $tag->getVar('nameid') . '/';
            $urlnav .= $usr ? 'usr/' . $user->uname() . '/' : '';
        } else {
            $urlnav = '?xplore=tags&amp;tag=' . $tag->getVar('nameid');
            $urlnav .= $usr ? '&amp;usr='******'';
        }
        $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('tagsNavPage', $nav->render(false));
    }
    $showmax = $start + $limit;
    $showmax = $showmax > $num ? $num : $showmax;
    $tpl->assign('lang_showing', sprintf(__('Showing photos %u to %u from %u.', 'galleries'), $start + 1, $showmax, $num));
    $tpl->assign('limit', $limit);
    $tpl->assign('pag', $pactual);
    //Fin de barra de navegación
    //Obtenemos las imágenes pertenecientes a la etiqueta
    $sql = "SELECT b.* FROM " . $db->prefix('gs_tagsimages') . " a INNER JOIN " . $db->prefix('gs_images');
    $sql .= " b ON (a.id_tag=" . $tag->id() . " AND a.id_image=b.id_image  AND b.public=2";
    $sql .= $usr ? " AND b.owner=" . $user->uid() . ") " : ")";
    $sql .= " GROUP BY b.id_image";
    $sql .= " ORDER BY `created` DESC LIMIT {$start}, {$limit}";
    $result = $db->query($sql);
    $tpl->assign('images', GSFunctions::process_image_data($result));
    $tpl->assign('lang_picstag', $usr ? sprintf(__('%s: tagged as %s', 'galleries'), $user->uname(), $tag->tag()) : sprintf(__('Images tagged as "%s"', 'galleries'), $tag->tag()));
    $tpl->assign('tagname', $tag->tag());
    $tpl->assign('usr', $usr);
    if ($usr) {
        $tpl->assign('pics_link', GS_URL . '/' . ($mc['urlmode'] ? "usr/" . $user->uname() : "user.php?id=usr/" . $user->uname() . "/"));
        $tpl->assign('tags_link', GS_URL . '/' . ($mc['urlmode'] ? "explore/tags/usr/" . $user->uname() . "/" : "explore.php?by=explore/tags/usr/" . $user->uname() . "/"));
        $tpl->assign('sets_link', GS_URL . '/' . ($mc['urlmode'] ? "explore/sets/usr/" . $user->uname() . "/" : "explore.php?by=explore/sets/usr/" . $user->uname() . "/"));
        $tpl->assign('bmark_link', GS_URL . '/' . ($mc['urlmode'] ? "cpanel/booksmarks/" : "cpanel.php?s=cpanel/bookmarks"));
    }
    include 'footer.php';
}
 public function url()
 {
     global $mc;
     $url = GSFunctions::get_url();
     $url .= $mc['urlmode'] ? "postcard/" . $this->id() . '/' : 'postcard.php?id=' . $this->id();
     return $url;
 }
示例#19
0
     $set->assignVars($rows);
     //Obtenemos una imagen del album
     $sql = "SELECT b.* FROM " . $db->prefix('gs_setsimages') . " a, " . $db->prefix('gs_images') . " b WHERE";
     $sql .= " a.id_set='" . $set->id() . "' AND b.id_image=a.id_image AND b.public=2 AND b.owner='" . $set->owner() . "' ORDER BY RAND() LIMIT 0,4";
     $resimg = $db->query($sql);
     if (!isset($users[$set->owner()])) {
         $users[$set->owner()] = new GSUser($set->owner(), 1);
     }
     $imgs = '<a href="' . $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&amp;set=' . $set->id()) . '">';
     while ($rowimg = $db->fetchArray($resimg)) {
         $img = new GSImage();
         $img->assignVars($rowimg);
         $urlimg = $users[$set->owner()]->filesURL() . '/' . ($config['set_format_mode'] ? 'formats/set_' : 'ths/') . $img->image();
         // Conversion de los formatos
         if (!$img->setFormat() && $config['set_format_mode']) {
             GSFunctions::resizeImage($crop, $users[$set->owner()]->filesPath() . '/' . $img->image(), $users[$set->owner()]->filesPath() . '/formats/set_' . $img->image(), $width, $height);
             $img->setSetFormat(1, 1);
         }
         $imgs .= '<img src="' . $urlimg . '" alt="' . $set->title() . '" /> ';
     }
     $imgs .= '</a>';
     $desc = $imgs . '<br />';
     $desc .= sprintf(__('By: <strong>%s</strong>', 'galleries'), $set->uname());
     $item = array();
     $item['title'] = $set->title();
     $item['link'] = $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&amp;set=' . $set->id());
     $item['description'] = XoopsLocal::convert_encoding(htmlspecialchars($desc, ENT_QUOTES));
     $item['pubdate'] = formatTimestamp($set->date(), 'rss');
     $item['guid'] = $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&amp;set=' . $set->id());
     $rss_items[] = $item;
 }
示例#20
0
/**
* @desc Almacena las imágenes en la base de datos y en el disco duro
*/
function saveImages()
{
    global $db, $xoopsOption, $xoopsUser, $mc, $tpl, $xmh, $xoopsModuleConfig, $util;
    $mc =& $xoopsModuleConfig;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    //Verificamos si el usuario se encuentra registrado
    $user = new GSUser($xoopsUser->uname());
    if ($user->isNew()) {
        //Insertamos información del usuario
        $user->setUid($xoopsUser->uid());
        $user->setUname($xoopsUser->uname());
        $user->setQuota($mc['quota'] * 1024 * 1024);
        $user->setDate(time());
        if (!$user->save()) {
            redirect_header('./submit.php', 1, __('Sorry, an error ocurred while trying to register your permissions on database. Try again later!', 'galleries'));
            die;
        }
    }
    @mkdir($mc['storedir'] . "/" . $user->uname());
    @mkdir($mc['storedir'] . "/" . $user->uname() . "/ths");
    @mkdir($mc['storedir'] . "/" . $user->uname() . "/formats");
    $mc['saveoriginal'] ? @mkdir($mc['storedir'] . "/originals") : '';
    // Insertamos las etiquetas
    $tgs = explode(" ", $tags);
    /**
     * @desc Almacena los ids de las etiquetas que se asignarán a la imagen
     */
    $ret = array();
    foreach ($tgs as $k) {
        $k = trim($k);
        $kf = TextCleaner::getInstance()->sweetstring($k);
        if ($kf == '') {
            continue;
        }
        // Comprobamos que la palabra tenga la longitud permitida
        if (strlen($kf) < $mc['min_tag'] || strlen($kf) > $mc['max_tag']) {
            continue;
        }
        // Creamos la etiqueta
        $tag = new GSTag($k);
        if (!$tag->isNew()) {
            // Si ya existe nos saltamos
            $ret[] = $tag->id();
            continue;
        }
        $tag->setTag($k);
        $tag->setVar('nameid', $kf);
        if ($tag->save()) {
            $ret[] = $tag->id();
        }
    }
    $errors = '';
    $k = 1;
    include_once RMCPATH . '/class/uploader.php';
    $up = new RMFileUploader(true);
    $folder = $mc['storedir'] . "/" . $xoopsUser->uname();
    $folderths = $mc['storedir'] . "/" . $xoopsUser->uname() . "/ths";
    foreach ($_FILES['images']['name'] as $k => $v) {
        if ($v == '') {
            continue;
        }
        $img = new GSImage();
        $img->setOwner($xoopsUser->uid());
        $img->setPublic($privacy);
        $img->setCreated(time());
        //Imagen
        $filename = '';
        $up = new RMFileUploader($folder, $mc['size_image'] * 1024, array('jpg', 'png', 'gif'));
        if ($up->fetchMedia('images', $k)) {
            if (!$up->upload()) {
                $errors .= $up->getErrors();
                continue;
            }
            $filename = $up->getSavedFileName();
            $fullpath = $up->getSavedDestination();
            $thSize = $mc['image_ths'];
            $imgSize = $mc['image'];
            if ($thSize[0] <= 0) {
                $thSize[0] = 100;
            }
            if (!isset($thSize[1]) || $thSize[1] <= 0) {
                $thSize[1] = $thSize[0];
            }
            if ($imgSize[0] <= 0) {
                $imgSize[0] = 500;
            }
            if (!isset($imgSize[1]) || $imgSize[1] <= 0) {
                $imgSize[1] = $imgSize[0];
            }
            // Almacenamos la imágen original
            if ($mc['saveoriginal']) {
                copy($fullpath, $mc['storedir'] . '/originals/' . $filename);
            }
            // Redimensionamos la imagen
            $redim = new RMImageResizer($fullpath, $fullpath);
            switch ($mc['redim_image']) {
                case 0:
                    //Recortar miniatura
                    $redim->resizeWidth($imgSize[0]);
                    $redim->setTargetFile($folderths . "/{$filename}");
                    $redim->resizeAndCrop($thSize[0], $thSize[1]);
                    break;
                case 1:
                    //Recortar imagen grande
                    $redim->resizeWidthOrHeight($imgSize[0], $imgSize[1]);
                    $redim->setTargetFile($folderths . "/{$filename}");
                    $redim->resizeWidth($thSize[0]);
                    break;
                case 2:
                    //Recortar ambas
                    $redim->resizeWidthOrHeight($imgSize[0], $imgSize[1]);
                    $redim->setTargetFile($folderths . "/{$filename}");
                    $redim->resizeAndCrop($thSize[0], $thSize[1]);
                    break;
                case 3:
                    //Redimensionar
                    $redim->resizeWidth($imgSize[0]);
                    $redim->setTargetFile($folderths . "/{$filename}");
                    $redim->resizeWidth($thSize[0]);
                    break;
            }
        }
        //Fin de Imagen
        $img->setImage($filename);
        if ($up->getErrors() == '') {
            if (!$img->save()) {
                $errors .= sprintf(__('Picture %s could not be uploaded!', 'galleries'), $v) . " (" . $img->errors() . ")";
            } else {
                $user->addPic();
                if ($ret) {
                    $img->setTags($ret);
                }
            }
        } else {
            $errors .= $up->getErrors();
        }
        ++$k;
    }
    if ($errors != '') {
        redirect_header(GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/images' : '?cp=images'), 2, __('Errors ocurred while trying to upload images!', 'galleries') . $errors);
        die;
    } else {
        redirect_header(GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/images' : '?cp=images'), 2, __('Pictures stored successfully!', 'galleries'));
        die;
    }
}
示例#21
0
/**
* @desc Formulario de creación de muchas imágenes
**/
function formBulkImages()
{
    global $mc, $xoopsUser, $tpl, $xoopsModule, $xoopsSecurity;
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $owner = rmc_server_var($_REQUEST, 'owner', 0);
    $uid = rmc_server_var($_REQUEST, 'uid', 0);
    $sort = rmc_server_var($_REQUEST, 'sort', 'created');
    $mode = rmc_server_var($_REQUEST, 'mode', 1);
    $psets = rmc_server_var($_REQUEST, 'albums', array());
    $tags = rmc_server_var($_REQUEST, 'tags', '');
    $ruta = "page={$page}&owner={$owner}&sort={$sort}&mode={$mode}";
    $db = Database::getInstance();
    //Lista de albumes
    $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE owner='" . ($uid ? $uid : $xoopsUser->uid()) . "' ORDER BY id_set DESC";
    $result = $db->query($sql);
    $sets = array();
    while ($rows = $db->fetchArray($result)) {
        $sets[] = array('id' => $rows['id_set'], 'title' => $rows['title'], 'selected' => in_array($rows['id_set'], $psets));
    }
    $show_controls = false;
    if ($uid > 0 && !empty($sets)) {
        $show_controls = true;
        $uploader = new RMFlashUploader('files-container', '../include/upload.php');
        $uploader->add_setting('scriptData', array('op' => 'savebulk', 'sets' => implode(',', $psets), 'uid' => $uid, 'owner' => $owner, 'sort' => $sort, 'mode' => $mode, 'page' => $page, 'tags' => $tags, 'token' => $xoopsSecurity->createToken(), 'rmsecurity' => TextCleaner::getInstance()->encrypt($xoopsUser->uid() . '|' . GS_URL . '/admin/images.php' . '|' . $xoopsSecurity->createToken(), true)));
        $uploader->add_setting('multi', true);
        $uploader->add_setting('fileExt', '*.jpg;*.png;*.gif;*.JPG');
        $uploader->add_setting('fileDesc', __('All Images (*.jpg, *.png, *.gif)', 'galleries'));
        $uploader->add_setting('sizeLimit', $mc['size_image'] * 1024);
        $uploader->add_setting('buttonText', __('Browse Images...', 'galleries'));
        $uploader->add_setting('queueSizeLimit', 100);
        $uploader->add_setting('onComplete', "function(event, id, file, resp, data){\n                eval('ret = '+resp);\n                if (ret.error){\n                    \$('#upload-errors').append('<span class=\"failed\"><strong>'+file.name+'</strong>: '+ret.message+'</span>');\n                } else {\n                    total++;\n                    ids[total-1] = ret.id;\n                    \$('#upload-errors').append('<span class=\"done\"><strong>'+file.name+'</strong>: " . __('Uploaded successfully!', 'rmcommon') . "</span>');\n                }\n                return true;\n            }");
        $uploader->add_setting('onAllComplete', "function(event, data){\n                \n                if(total<=0){ return; }\n                \n                \$('.select_image_cat').hide('slow');\n                \$('#upload-errors').hide('slow');\n                \$('#upload-errors').html('');\n                \$('#upload-controls').hide('slow');\n                \$('#resizer-bar').show('slow');\n                \$('#resizer-bar').effect('highlight',{},1000);\n                \$('#gen-thumbnails').show();\n                \n                var increments = 1/total*100;\n                url = '" . GS_URL . "/include/upload.php';\n                params = '" . TextCleaner::getInstance()->encrypt($xoopsUser->uid() . '|' . GS_URL . '/admin/images.php' . '|' . $xoopsSecurity->createToken(), true) . "';\n                resize_image(params);\n                \n            }");
        $uploader->add_setting('onError', 'function (event,ID,fileObj,errorObj) {
          alert(errorObj.type + \' Error: \' + errorObj.info);
        }');
        RMTemplate::get()->add_head($uploader->render());
    }
    $form = new RMForm('', 'frmImgs', 'images.php');
    $ele = new RMFormUser('', 'uid', 0, $uid ? array($uid) : array($xoopsUser->uid()), 0);
    $users_field = $ele->render();
    GSFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Create batch images', 'galleries'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Create batch images', 'galleries'));
    RMTemplate::get()->add_local_script('images.js', 'galleries');
    RMTemplate::get()->add_style('uploader.css', 'galleries');
    xoops_cp_header();
    include RMTemplate::get()->get_template("admin/gs_formimages.php", 'module', 'galleries');
    xoops_cp_footer();
}
示例#22
0
$tpl->assign('lang_created', __('Created on:', 'galleries'));
$tpl->assign('lang_by', __('Created by:', 'galleries'));
$tpl->assign('lang_pics', __('Photos:', 'galleries'));
$tpl->assign('lang_other', __('Other Albums', 'galleries'));
$tpl->assign('lang_view', __('View Photos', 'galleries'));
$tpl->assign('lang_moresets', __('More albums', 'galleries'));
$tpl->assign('explore_sets_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'explore/sets/' : '?explore=sets'));
$tpl->assign('lang_setbrowse', __('Browse albums', 'galleries'));
$tpl->assign('explore_imgs_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'explore/photos/' : '?explore=photos'));
$tpl->assign('lang_imgbrowse', __('Browse photos', 'galleries'));
$tpl->assign('explore_tags_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'explore/tags/' : '?explore=tags'));
$tpl->assign('lang_tagbrowse', __('Browse tags', 'galleries'));
// ültimas Fotos
$mc['last_num'] = $mc['last_num'] <= 0 ? 10 : $mc['last_num'];
$result = $db->query("SELECT * FROM " . $db->prefix("gs_images") . " WHERE public=2 ORDER BY created DESC LIMIT 0,{$mc['last_num']}");
$tpl->assign('last_images', GSFunctions::process_image_data($result));
// Álbumes Recientes
$result = $db->query("SELECT * FROM " . $db->prefix("gs_sets") . " WHERE public='2' ORDER BY date DESC LIMIT 0," . ($mc['sets_num'] > 0 ? $mc['sets_num'] : 5));
while ($row = $db->fetchArray($result)) {
    $set = new GSSet();
    $set->assignVars($row);
    $pics = $set->getPics('RAND()');
    $imgs = @array_slice($pics, 0, $xoopsModuleConfig['sets_num_images']);
    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);
示例#23
0
function gs_sets_show($options)
{
    global $xoopsUser, $xoopsModuleConfig;
    $db = Database::getInstance();
    $wo = '';
    $tsets = $db->prefix("gs_sets");
    $tfriends = $db->prefix("gs_friends");
    $mc = RMUtilities::module_config('galleries');
    $format = $mc['set_format_values'];
    $crop = $format[0];
    // 0 = Redimensionar, 1 = Cortar
    $width = $format[1];
    $height = $format[2];
    if ($xoopsUser) {
        $wo = "{$tsets}.owner='" . $xoopsUser->uid() . "' OR";
    }
    $sql = "SELECT * FROM {$tsets} WHERE owner='1' OR public='2' ORDER BY `date` DESC LIMIT 0,{$options['0']}";
    $result = $db->query($sql);
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsuser.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php';
    $block = array();
    $users = array();
    $tf = new RMTimeFormatter(0, '%T% %d%, %Y%');
    while ($row = $db->fetchArray($result)) {
        $rtn = array();
        $set = new GSSet();
        $set->assignVars($row);
        if (!isset($users[$set->owner()])) {
            $users[$set->owner()] = new GSUser($set->owner(), 1);
        }
        // Si se ha seleccionado la opción para mostrar imágenes entonces...
        if ($options[1]) {
            //Obtenemos una imagen del album
            $sql = "SELECT b.* FROM " . $db->prefix('gs_setsimages') . " a, " . $db->prefix('gs_images') . " b WHERE";
            $sql .= " a.id_set='" . $set->id() . "' AND b.id_image=a.id_image AND b.public=2 AND b.owner='" . $set->owner() . "' ORDER BY b.created DESC LIMIT 0,1";
            $resimg = $db->query($sql);
            if ($db->getRowsNum($resimg) > 0) {
                $rowimg = $db->fetchArray($resimg);
                $img = new GSImage();
                $img->assignVars($rowimg);
                $urlimg = $users[$set->owner()]->filesURL() . '/' . ($mc['set_format_mode'] ? 'formats/set_' : 'ths/') . $img->image();
                // Conversion de los formatos
                if (!$img->setFormat() && $mc['set_format_mode']) {
                    GSFunctions::resizeImage($crop, $users[$set->owner()]->filesPath() . '/' . $img->image(), $users[$set->owner()]->filesPath() . '/formats/set_' . $img->image(), $width, $height);
                    $img->setSetFormat(1, 1);
                }
            } else {
                $urlimg = '';
            }
            $rtn['img'] = $urlimg;
        }
        $rtn['id'] = $set->id();
        $rtn['title'] = $set->title();
        $rtn['owner'] = $set->owner();
        $rtn['link'] = $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&amp;set=' . $set->id());
        if ($options[2]) {
            $rtn['date'] = $tf->format($set->date());
            $rtn['pics'] = $set->pics();
            $rtn['uname'] = $set->uname();
            $rtn['linkuser'] = $users[$set->owner()]->userURL();
        }
        $block['sets'][] = $rtn;
    }
    $block['showimg'] = $options[1];
    $block['showinfo'] = $options[2];
    $block['item_width'] = $options[3];
    RMTemplate::get()->add_xoops_style('blocks.css', 'galleries');
    RMTemplate::get()->add_local_script('blocks.js', 'galleries');
    return $block;
}
示例#24
0
/**
* @desc Formulario de creación/edición de albums
**/
function formAlbums($edit = 0)
{
    global $xoopsModule, $xoopsUser;
    define('RMSUBLOCATION', 'newalbum');
    $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : '';
    $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15;
    $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'id_set';
    $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 0;
    $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
    $ruta = "pag={$page}&sort={$sort}&mode={$mode}&search={$search}";
    if ($edit) {
        //Verificamos que el album sea válido
        if ($id <= 0) {
            redirectMsg('./sets.php?' . $ruta, __('Please provide a valid ID!', 'galleries'), 1);
            die;
        }
        //Verificamos que el album exista
        $set = new GSSet($id);
        if ($set->isNew()) {
            redirectMsg('./sets.php?' . $ruta, __('Specified album does not exists!', 'galleries'), 1);
            die;
        }
    }
    GSFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='./sets.php'>" . __('Albums management', 'galleries') . "</a> &raquo; " . ($edit ? __('Edit album', 'galleries') : __('New album', 'galleries')));
    xoops_cp_header();
    $form = new RMForm($edit ? __('Edit album', 'galleries') : __('New Album', 'galleries'), 'frmsets', 'sets.php');
    $form->addElement(new RMFormText(__('Album title', 'galleries'), 'title', 50, 100, $edit ? $set->title() : ''), true);
    $form->addElement(new RMFormEditor(__('Description', 'galleries'), 'description', '99%', '250px', $edit ? $set->getVar('description', 'e') : ''));
    $ele = new RMFormSelect(__('Privacy level', 'galleries'), 'public');
    $ele->addOption(0, __('Private', 'galleries'), $edit ? $set->isPublic() == 0 ? 1 : 0 : 0);
    $ele->addOption(1, __('Public for friends', 'galleries'), $edit ? $set->isPublic() == 1 ? 1 : 0 : 0);
    $ele->addOption(2, __('Public', 'galleries'), $edit ? $set->isPublic() == 2 ? 1 : ($set->isPublic() == 0 ? 1 : 0) : 1);
    $form->addElement($ele, true);
    $form->addElement(new RMFormUser(__('Owner', 'galleries'), 'owner', 0, $edit ? array($set->owner()) : array($xoopsUser->uid()), 30));
    $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save'));
    $form->addElement(new RMFormHidden('id', $id));
    $form->addElement(new RMFormHidden('page', $page));
    $form->addElement(new RMFormHidden('limit', $limit));
    $form->addElement(new RMFormHidden('sort', $sort));
    $form->addElement(new RMFormHidden('mode', $mode));
    $form->addElement(new RMFormHidden('search', $search));
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', $edit ? __('Save Changes!', 'galleries') : __('Create Album!', 'galleries'), 'submit');
    $buttons->addButton('cancel', __('Cancel', 'galleries'), 'button', 'onclick="window.location=\'sets.php?' . $ruta . '\'"');
    $form->addElement($buttons);
    $form->display();
    xoops_cp_footer();
}
示例#25
0
/**
* @desc Formulario de creación/Edición de etiquetas
**/
function formTags($edit = 0)
{
    global $xoopsModule;
    $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : '';
    $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
    $ruta = "pag={$page}&search={$search}";
    $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
    $num = 10;
    if ($edit) {
        //Verificamos si nos proporcionaron al menos una etiqueta para editar
        if (!is_array($ids) && $ids <= 0) {
            redirectMsg('./tags.php?' . $ruta, __('Specify some valid IDs', 'galleries'), 1);
            die;
        }
        if (!is_array($ids)) {
            $ids = array($ids);
        }
    }
    GSFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='./tags.php'>" . __('Tags Management', 'galleries') . "</a> &raquo; " . ($edit ? _AS_GS_EDITTAG : _AS_GS_NEWTAG));
    RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Tags', 'galleries') : __('Add Tags', 'galleries'));
    xoops_cp_header();
    $form = new RMForm($edit ? __('Editing tags', 'galleries') : __('Add tags', 'galleries'), 'frmtags', 'tags.php');
    if ($edit) {
        $errors = '';
        foreach ($ids as $k) {
            //Verificamos si la etiqueta es válida
            if ($k <= 0) {
                $errors .= sprintf(__('ID "%s" is not valid', 'galleries'), $k);
                continue;
            }
            //Verificamos si la etiqueta existe
            $tag = new GSTag($k);
            if ($tag->isNew()) {
                $errors .= sprintf(__('Tag "%s" does not exists', 'galleries'), $k);
                continue;
            }
            $form->addElement(new RMFormText(__('Tag name', 'galleries'), 'tags[' . $tag->id() . ']', 50, 100, $edit ? $tag->tag() : ''));
        }
    } else {
        for ($i = 0; $i < $num; $i++) {
            $form->addElement(new RMFormText(__('Tag name', 'galleries'), 'tags[' . $i . ']', 50, 100, $edit ? $tag->tag() : ''));
        }
    }
    $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save'));
    $form->addElement(new RMFormHidden('page', $page));
    $form->addElement(new RMFormHidden('search', $search));
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', $edit ? __('Save Changes', 'galleries') : __('Create tags', 'galleries'), 'submit');
    $buttons->addButton('cancel', __('Cancel', 'galleries'), 'button', 'onclick="window.location=\'tags.php?' . $ruta . '\'"');
    $form->addElement($buttons);
    $form->display();
    xoops_cp_footer();
}