public function get_item_url($params, $com) { static $works; $params = urldecode($params); parse_str($params); if (!isset($work) || $work <= 0) { return ''; } if (isset($works[$work])) { $ret = $works[$work]->link() . '#comment-' . $com->id(); return $ret; } include_once XOOPS_ROOT_PATH . '/modules/works/class/pwwork.class.php'; $item = new PWWork($work); if ($item->isNew()) { return ''; } $ret = $item->link() . '#comment-' . $com->id(); $works[$work] = $item; return $ret; }
/** * @desc Almacena las imágenes en la base de datos **/ function saveImages($edit = 0) { global $xoopsModuleConfig, $xoopsSecurity; foreach ($_POST as $k => $v) { ${$k} = $v; } $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 (!$xoopsSecurity->check()) { redirectMsg('./images.php?work=' . $work->id() . $ruta, __('Session token expired!', '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; } } else { $img = new PWImage(); } $img->setTitle($title); $img->setDesc(substr($desc, 0, 100)); $img->setWork($work->id()); //Imagen include_once RMCPATH . '/class/uploader.php'; $folder = XOOPS_UPLOAD_PATH . '/works'; $folderths = XOOPS_UPLOAD_PATH . '/works/ths'; if ($edit) { $image = $img->image(); $filename = $img->image(); } else { $filename = ''; } //Obtenemos el tamaño de la imagen $thSize = $xoopsModuleConfig['image_ths']; $imgSize = $xoopsModuleConfig['image']; $up = new RMFileUploader($folder, $xoopsModuleConfig['size_image'] * 1024, array('jpg', 'png', 'gif')); if ($up->fetchMedia('image')) { if (!$up->upload()) { redirectMsg('./images.php?op=' . ($edit ? 'edit' : 'new') . '&work=' . $work->id() . $ruta, $up->getErrors(), 1); die; } if ($edit && $img->image() != '') { @unlink(XOOPS_UPLOAD_PATH . '/works/' . $img->image()); @unlink(XOOPS_UPLOAD_PATH . '/works/ths/' . $img->image()); } $filename = $up->getSavedFileName(); $fullpath = $up->getSavedDestination(); // Redimensionamos la imagen $redim = new RMImageResizer($fullpath, $fullpath); switch ($xoopsModuleConfig['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; } } $img->setImage($filename); RMEvents::get()->run_event('works.save.image', $img); if (!$img->save()) { redirectMsg('./images.php?work=' . $work->id() . $ruta, __('Errors ocurred while trying to save the image', 'works') . '<br />' . $img->errors(), 1); die; } else { redirectMsg('./images.php?work=' . $work->id() . $ruta, __('Database updated successfully!', 'works'), 0); die; } }
// License: GPL 2.0 // -------------------------------------------------------------- if (!defined('XOOPS_ROOT_PATH')) { require '../../mainfile.php'; } $xoopsOption['template_main'] = 'pw_work.html'; $xoopsOption['module_subpage'] = 'work'; include 'header.php'; $mc =& $xoopsModuleConfig; if ($id == '') { redirect_header(PW_URL . '/', 2, __('Work id not provided!', 'works')); die; } //Verificamos si el trabajo existe $work = new PWWork($id); if ($work->isNew()) { redirect_header(PW_URL . '/', 2, __('Specified id does not exists!', 'works')); die; } if (!$work->isPublic() && !($xoopsUser && $xoopsUser->isAdmin())) { redirect_header(PW_URL, 1, __('The requested content is not available!', 'works')); die; } 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);
function works_delete_meta() { global $xoopsSecurity; $id = rmc_server_var($_POST, 'id', 0); if ($id <= 0) { redirectMsg('works.php', __('You must provide a work ID!', 'works'), 1); die; } $work = new PWWork($id); if ($work->isNew()) { redirectMsg('works.php', __('Specified work does not exists!', 'works'), 1); die; } if (!$xoopsSecurity->check()) { redirectMsg('works.php?id=' . $id . '&op=meta', __('Session token expired!', 'works'), 1); die; } $ids = rmc_server_var($_POST, 'ids', array()); if (!is_array($ids) || empty($ids)) { redirectMsg('works.php', __('Select some fields to delete!', 'works'), 1); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "DELETE FROM " . $db->prefix("pw_meta") . " WHERE id_meta IN(" . implode(",", $ids) . ")"; if ($db->queryF($sql)) { redirectMsg('works.php?id=' . $id . '&op=meta', __('Custom fields deleted successfully!', 'works'), 0); } else { redirectMsg('works.php?id=' . $id . '&op=meta', __('Custom fields could not be deleted!', 'works') . '<br />' . $db->error(), 1); } }