예제 #1
0
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> &raquo; \n\t\t<a href='categos.php'>" . __('Categories', 'works') . '</a> &raquo; ' . ($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();
}
예제 #2
0
//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() . ' &raquo; ' . $mc['title']);
/**
* Otros trabajos
예제 #3
0
function pw_works_edit($options)
{
    global $db;
    include_once XOOPS_ROOT_PATH . '/modules/works/class/pwclient.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/works/class/pwcategory.class.php';
    //Tipo de Trabajo
    $form = new RMForm(__('Block Options', 'works'), 'form_options', '');
    $ele = new RMFormSelect(__('Works type', 'works'), 'options[0]');
    $ele->addOption(0, __('Reandom works', 'works'), $options[0] == 0 ? 1 : 0);
    $ele->addOption(1, __('Featured works', 'works'), $options[0] == 1 ? 1 : 0);
    $ele->addOption(2, __('Recent works', 'works'), $options[0] == 2 ? 1 : 0);
    $form->addElement($ele);
    //Obtenemos las categorías
    $ele = new RMFormSelect(__('Category', 'works'), 'options[1]');
    $ele->addOption(0, __('All categories', 'works'));
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $result = $db->query("SELECT * FROM " . $db->prefix('pw_categos') . " WHERE active=1");
    while ($row = $db->fetchArray($result)) {
        $cat = new PWCategory();
        $cat->assignVars($row);
        $ele->addOption($cat->id(), $cat->name(), $options[1] == $cat->id() ? 1 : 0);
    }
    $form->addElement($ele, true);
    //Obtenemos los clientes
    $ele = new RMFormSelect(__('Customer', 'works'), 'options[2]');
    $ele->addOption(0, __('All customers', 'works'));
    $result = $db->query("SELECT * FROM " . $db->prefix('pw_clients'));
    while ($row = $db->fetchArray($result)) {
        $client = new PWClient();
        $client->assignVars($row);
        $ele->addOption($client->id(), $client->name(), isset($ptions[2]) ? $options[2] == $client->id() ? 1 : 0 : 0);
    }
    $form->addElement($ele, true);
    //Número de trabajos
    $form->addElement(new RMFormText(__('Works number', 'works'), 'options[3]', 5, 5, isset($options[3]) ? $options[3] : ''), true);
    $form->addElement(new RMFormText(__('Columns', 'works'), 'options[4]', 5, 5, isset($options[4]) ? $options[4] : ''), true);
    $form->addElement(new RMFormYesno(__('Show work image', 'works'), 'options[5]', isset($options[5]) ? $options[5] ? 1 : 0 : 0), true);
    $form->addElement(new RMFormYesno(__('Show description', 'works'), 'options[6]', isset($options[6]) ? $options[6] ? 1 : 0 : 0), true);
    return $form->render(false);
}