/** * @desc Formulario de creación/edición de Imágenes **/ function formImages($edit = 0) { global $xoopsModule, $xoopsModuleConfig; $id = rmc_server_var($_REQUEST, 'id', 0); $work = rmc_server_var($_REQUEST, 'work', 0); $page = rmc_server_var($_REQUEST, 'page', 0); $ruta = "&page={$page}"; //Verificamos que el trabajo sea válido if ($work <= 0) { redirectMsg('./works.php', __('You must specify a work ID!', 'works'), 1); die; } //Verificamos que el trabajo exista $work = new PWWork($work); if ($work->isNew()) { redirectMsg('./works.php', __('Specified work does not exists!', 'works'), 1); die; } if ($edit) { //Verificamos que la imagen sea válida if ($id <= 0) { redirectMsg('./images.php?work=' . $work->id() . $ruta, __('You must specify an image ID!', 'works'), 1); die; } //Verificamos que la imagen exista $img = new PWImage($id); if ($img->isNew()) { redirectMsg('./images.php?work=' . $work->id() . $ruta, __('Specified image does not exists!', 'works'), 1); die; } } PWFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $work->title() . ' » ' . __('Work Images', 'works')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » <a href='./images.php?work=" . $work->id() . "'>" . __('Work Images', 'works') . "</a> »" . ($edit ? __('Edit Image', 'works') : __('Add Image', 'works'))); xoops_cp_header(); $form = new RMForm($edit ? __('Edit Image', 'works') : __('Add Image', 'works'), 'frmImg', 'images.php'); $form->setExtra("enctype='multipart/form-data'"); $form->addElement(new RMFormText(__('Title', 'works'), 'title', 50, 100, $edit ? $img->title() : ''), true); $form->addElement(new RMFormFile(__('Image file', 'works'), 'image', 45, $xoopsModuleConfig['size_image'] * 1024), $edit ? false : true); if ($edit) { $form->addElement(new RMFormLabel(__('Current image file', 'works'), "<img src='" . XOOPS_UPLOAD_URL . "/works/ths/" . $img->image() . "' />")); } $form->addElement(new RMFormTextArea(__('Description', 'works'), 'desc', 4, 50, $edit ? $img->desc() : '')); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $form->addElement(new RMFormHidden('work', $work->id())); $form->addElement(new RMFormHidden('page', $page)); $form->addElement(new RMFormHidden('limit', $limit)); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', _SUBMIT, 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'images.php?work=' . $work->id() . $ruta . '\';"'); $form->addElement($ele); $form->display(); xoops_cp_footer(); }
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() . ' » ' . $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']; } $result = $db->query($sql);