function formCategory($edit = 0) { global $mc, $xoopsModule, $db; PWFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Category', 'works') : __('Add Category', 'works')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » \n\t\t<a href='categos.php'>" . __('Categories', 'works') . '</a> » ' . ($edit ? __('Edit Category', 'works') : __('Add Category', 'works'))); xoops_cp_header(); $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; if ($edit) { //Verificamos si la categoría es válida if ($id <= 0) { redirectMsg('./categos.php?op=edit&id=' . $id, __('Provide a category ID!', 'works'), 1); die; } //Verificamos si la categoría existe $cat = new PWCategory($id); if ($cat->isNew()) { redirectMsg('./categos.php?op=edit&id=' . $id, __('Specified category was not found!', 'works'), 1); die; } } $form = new RMForm($edit ? __('Edit Category', 'works') : __('Add Category', 'works'), 'frmNew', 'categos.php'); $form->addElement(new RMFormText(__('Name', 'works'), 'name', 50, 150, $edit ? $cat->name() : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Short name', 'works'), 'nameid', 50, 150, $cat->nameId()), true); } $form->addElement(new RMFormEditor(__('Description', 'works'), 'desc', '100%', '250px', $edit ? $cat->desc('e') : '')); $form->addElement(new RMFormYesNo(__('Enable category', 'works'), 'active', $edit ? $cat->active() : 1)); $form->addElement(new RMFormText(__('Display order', 'works'), 'order', 8, 3, $edit ? $cat->order() : 0), true, 'num'); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $cat->id())); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes!', 'works') : __('Add Now!', 'works'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'categos.php\';"'); $form->addElement($ele); $form = RMEvents::get()->run_event('works.form.categories', $form); $form->display(); xoops_cp_footer(); }
//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