Example #1
0
function showImages()
{
    global $xoopsModule, $db, $xoopsSecurity;
    $work = rmc_server_var($_REQUEST, 'work', 0);
    //Verificamos que el trabajo sea válido
    if ($work <= 0) {
        redirectMsg('./works.php', __('Provided work ID is not valid!', 'works'), 1);
        die;
    }
    //Verificamos que el trabajo exista
    $work = new PWWork($work);
    if ($work->isNew()) {
        redirectMsg('./works.php', __('Specified work does not exists!', 'admin_work'), 1);
        die;
    }
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_images') . " WHERE work='" . $work->id() . "'";
    list($num) = $db->fetchRow($db->query($sql));
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $page = $page <= 0 ? 1 : $page;
    $limit = 10;
    $tpages = ceil($num / $limit);
    $page = $page > $tpages ? $tpages : $page;
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url('images.php?page={PAGE_NUM}&amp;work=' . $work->id());
    $sql = "SELECT * FROM " . $db->prefix('pw_images') . " WHERE work='" . $work->id() . "'";
    $sql .= " LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    $images = array();
    while ($row = $db->fetchArray($result)) {
        $img = new PWImage();
        $img->assignVars($row);
        $images[] = array('id' => $img->id(), 'title' => $img->title(), 'image' => $img->image(), 'work' => $img->work(), 'desc' => $img->desc());
    }
    $images = RMEvents::get()->run_event('works.list.images', $images, $work);
    $form_fields = '';
    $form_fields = RMEvents::get()->run_event('works.images.form.fields', $form_fields, $work);
    PWFunctions::toolbar();
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; " . __('Work Images', 'works'));
    RMTemplate::get()->assign('xoops_pagetitle', $work->title() . ' &raquo; Work Images', 'admin_mywords');
    RMTemplate::get()->add_style('admin.css', 'works');
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->add_head("<script type='text/javascript'>\nvar pw_message='" . __('Do you really want to delete selected images?', 'works') . "';\n\n        var pw_select_message = '" . __('You must select an image before to execute this action!', 'works') . "';</script>");
    xoops_cp_header();
    include RMTemplate::get()->get_template("admin/pw_images.php", 'module', 'works');
    xoops_cp_footer();
}
Example #2
0
}
if (!$work->isPublic()) {
    $xoopsTpl->assign('lang_preview', __('You are in preview mode! This work is hidden for all other users.', 'works'));
}
$cat = new PWCategory($work->category());
$client = new PWClient($work->client());
$work_data = array('id' => $work->id(), 'title' => $work->title(), 'desc' => $work->desc(), 'intro' => $work->descShort(), 'category' => array('name' => $cat->name(), 'description' => $cat->desc(), 'id' => $cat->id(), 'nameid' => $cat->nameId(), 'link' => $cat->link()), 'client' => $client->businessName(), 'site' => $work->nameSite(), 'url' => formatURL($work->url()), 'created' => formatTimeStamp($work->created(), 's'), 'start' => formatTimeStamp($work->start(), 's'), 'period' => $work->period(), 'cost' => $mc['cost'] ? sprintf($mc['format_currency'], number_format($work->cost(), 2)) : '', 'mark' => $work->mark(), 'image' => XOOPS_UPLOAD_URL . '/works/' . $work->image(), 'thumb' => XOOPS_UPLOAD_URL . '/works/ths/' . $work->image(), 'comment' => $work->comment(), 'rating' => PWFunctions::rating($work->rating()), 'views' => $work->views(), 'metas' => $work->get_metas(), 'public' => $work->isPublic(), 'link' => $work->link());
$work_data = RMEvents::get()->run_event('works.work.data<{$work.l}', $work_data, $work);
$xoopsTpl->assign('work', $work_data);
$work->addView();
//Obtenemos todas las imágenes del trabajo
$sql = "SELECT * FROM " . $db->prefix('pw_images') . " WHERE work=" . $work->id();
$result = $db->query($sql);
while ($row = $db->fetchArray($result)) {
    $img = new PWImage();
    $img->assignVars($row);
    $tpl->append('images', array('id' => $img->id(), 'image' => XOOPS_UPLOAD_URL . '/works/ths/' . $img->image(), 'title' => $img->title(), 'desc' => $img->desc(), 'link_image' => XOOPS_UPLOAD_URL . '/works/' . $img->image()));
}
RMEvents::get()->run_event('works.load.work.images', $work);
$tpl->assign('xoops_pagetitle', $work->title() . ' &raquo; ' . $mc['title']);
/**
* Otros trabajos
**/
if ($mc['other_works'] > 0) {
    if ($mc['other_works'] == 2) {
        //Trabajos destacados
        $sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE public=1 AND mark=1 AND id_work<>'" . $work->id() . "' ORDER BY RAND() LIMIT 0," . $mc['num_otherworks'];
    } elseif ($mc['other_works'] == 1) {
        //Misma categoría
        $sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE public=1 AND catego=" . $work->category() . " AND id_work<>'" . $work->id() . "' ORDER BY RAND() LIMIT 0," . $mc['num_otherworks'];
    }