//Obtenemos los trabajos recientes $sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE public=1 ORDER BY created DESC LIMIT {$start},{$limit}"; $result = $db->query($sql); // Numero de resultados en esta página $t = $db->getRowsNum($result); $tpl->assign('page_total', $t); $tpl->assign('per_col', ceil($t / 2)); $categos = array(); $clients = array(); while ($row = $db->fetchArray($result)) { $recent = new PWWork(); $recent->assignVars($row); if (!isset($categos[$recent->category()])) { $categos[$recent->category()] = new PWCategory($recent->category()); } if (!isset($clients[$recent->client()])) { $clients[$recent->client()] = new PWClient($recent->client()); } $tpl->append('works', array('id' => $recent->id(), 'title' => $recent->title(), 'desc' => $recent->descShort(), 'catego' => $categos[$recent->category()]->name(), 'client' => $clients[$recent->client()]->businessName(), 'link' => $recent->link(), 'created' => formatTimeStamp($recent->created(), 's'), 'image' => XOOPS_UPLOAD_URL . '/works/ths/' . $recent->image(), 'rating' => PWFunctions::rating($recent->rating()), 'featured' => $recent->mark(), 'linkcat' => $categos[$recent->category()]->link(), 'metas' => $recent->get_metas())); } $tpl->assign('lang_works', __('Our Work', 'works')); $tpl->assign('lang_catego', __('Cetegory:', 'works')); $tpl->assign('lang_date', __('Date:', 'works')); $tpl->assign('lang_client', __('Customer:', 'works')); $tpl->assign('lang_allsrecent', __('View all recent works', 'works')); $tpl->assign('link_recent', PW_URL . ($mc['urlmode'] ? '/recent/' : '/recent.php')); $tpl->assign('link_featured', PW_URL . ($mc['urlmode'] ? '/featured/' : '/featured.php')); $thSize = $mc['image_ths']; $tpl->assign('width', $thSize[0] + 10); $tpl->assign('lang_featured', __('Featured', 'works')); include 'footer.php';
/** * Get works based on given parameters */ public function get_works($limit, $category = null, $public = 1, $object = true, $order = "created DESC") { global $xoopsModule, $xoopsModuleConfig; include_once XOOPS_ROOT_PATH . '/modules/works/class/pwwork.class.php'; include_once XOOPS_ROOT_PATH . '/modules/works/class/pwcategory.class.php'; include_once XOOPS_ROOT_PATH . '/modules/works/class/pwclient.class.php'; $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE public={$public}"; $sql .= $category > 0 ? " AND catego='{$category}'" : ''; $sql .= $order != '' ? " ORDER BY {$order}" : ''; $sql .= " LIMIT 0,{$limit}"; if ($xoopsModule && $xoopsModule->dirname() == 'works') { $mc =& $xoopsModuleConfig; } else { $mc = RMUtilities::module_config('works'); } $result = $db->query($sql); $works = array(); while ($row = $db->fetchArray($result)) { $work = new PWWork(); $work->assignVars($row); $ret = array(); if (!isset($categos[$work->category()])) { $categos[$work->category()] = new PWCategory($work->category()); } if (!isset($clients[$work->client()])) { $clients[$work->client()] = new PWClient($work->client()); } $ret = array('id' => $work->id(), 'title' => $work->title(), 'desc' => $work->descShort(), 'catego' => $categos[$work->category()]->name(), 'client' => $clients[$work->client()]->name(), 'link' => $work->link(), 'created' => formatTimeStamp($work->created(), 's'), 'created_time' => $work->created(), 'image' => XOOPS_UPLOAD_URL . '/works/ths/' . $work->image(), 'rating' => PWFunctions::rating($work->rating()), 'featured' => $work->mark(), 'linkcat' => $categos[$work->category()]->link(), 'metas' => $work->get_metas()); if ($object) { $w = new stdClass(); foreach ($ret as $var => $value) { $w->{$var} = $value; } $works[] = $w; } else { $works[] = $ret; } } return $works; }
//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); $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