예제 #1
0
function pw_comments_show($options)
{
    global $xoopsModule, $xoopsModuleConfig;
    include_once XOOPS_ROOT_PATH . '/modules/works/class/pwwork.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/works/class/pwclient.class.php';
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    if (isset($xoopsModule) && $xoopsModule->dirname() == 'works') {
        $mc =& $xoopsModuleConfig;
    } else {
        $mc =& RMUtilities::module_config('works');
    }
    $sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE comment<>'' ORDER BY " . ($options[1] ? " created DESC " : " RAND() ");
    $sql .= " LIMIT 0," . $options[0];
    $result = $db->query($sql);
    $clients = array();
    while ($row = $db->fetchArray($result)) {
        $work = new PWWork();
        $work->assignVars($row);
        if (!isset($clients[$work->client()])) {
            $clients[$work->client()] = new PWClient($work->client(), 1);
        }
        $client =& $clients[$work->client()];
        $rtn = array();
        $rtn['client'] = $client->businessName();
        $rtn['link'] = $work->link();
        $rtn['comment'] = $work->comment();
        $block['works'][] = $rtn;
    }
    return $block;
}
예제 #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
/**
* @desc Formulario de creacion/edición de trabajos
**/
function formWorks($edit = 0)
{
    global $xoopsModule, $xoopsModuleConfig;
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $ruta = "page={$page}";
    PWFunctions::toolbar();
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; <a href='./works.php'>" . __('Works Management', 'works') . "</a> &raquo; " . ($edit ? __('Editing work', 'works') : __('New work', 'works')));
    xoops_cp_header();
    $id = rmc_server_var($_REQUEST, 'id', 0);
    if ($edit) {
        //Verificamos que el trabajo sea válido
        if ($id <= 0) {
            redirectMsg('./works.php?' . $ruta, __('Provided Work ID is not valid!', 'works'), 1);
            die;
        }
        //Verificamos que el trabajo exista
        $work = new PWWork($id);
        if ($work->isNew()) {
            redirectMsg('./works.php?' . $ruta, __('Specified work does not exists!', 'works'), 1);
            die;
        }
    }
    $form = new RMForm($edit ? __('Edit Work', 'works') : __('Create Work', 'works'), 'frmwork', 'works.php');
    $form->setExtra("enctype='multipart/form-data'");
    $form->addElement(new RMFormText(__('Title', 'works'), 'title', 50, 200, $edit ? $work->title() : ''), true);
    $form->addElement(new RMFormTextArea(__('Short description', 'works'), 'short', 4, 50, $edit ? $work->descShort() : ''), true);
    $form->addElement(new RMFormEditor(__('Description', 'works'), 'desc', '90%', '200px', $edit ? $work->desc('e') : ''), true);
    if ($edit) {
        $dohtml = $work->getVar('dohtml');
        $doxcode = $work->getVar('doxcode');
        $dobr = $work->getVar('dobr');
        $dosmiley = $work->getVar('dosmiley');
        $doimage = $work->getVar('doimage');
    } else {
        $dohtml = 1;
        $doxcode = 0;
        $dobr = 0;
        $dosmiley = 0;
        $doimage = 0;
    }
    $form->addElement(new RMFormTextOptions(_OPTIONS, $dohtml, $doxcode, $doimage, $dosmiley, $dobr));
    $ele = new RMFormSelect(__('Category', 'works'), 'catego');
    $ele->addOption(0, __('Select...', 'works'));
    //Categorias existentes
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $result = $db->query("SELECT * FROM " . $db->prefix("pw_categos") . " ORDER BY `order`");
    while ($rows = $db->fetchArray($result)) {
        $ele->addOption($rows['id_cat'], $rows['name'], $edit ? $work->category() == $rows['id_cat'] ? 1 : 0 : '');
    }
    $form->addElement($ele, true, 'noselect:0');
    if ($xoopsModuleConfig['show_customer']) {
        //Clientes Existentes
        $ele = new RMFormSelect(__('Customer', 'works'), 'client');
        $ele->addOption(0, __('Select...', 'works'));
        $sql = "SELECT * FROM " . $db->prefix('pw_clients');
        $result = $db->query($sql);
        while ($row = $db->fetchArray($result)) {
            $ele->addOption($row['id_client'], $row['name'], $edit ? $work->client() == $row['id_client'] ? 1 : 0 : '');
        }
        $form->addElement($ele, true, 'noselect:0');
        $form->addElement(new RMFormTextArea(__('Customer comment', 'works'), 'comment', 4, 50, $edit ? $work->comment() : ''));
    }
    if ($xoopsModuleConfig['show_web']) {
        $form->addElement(new RMFormText(__('Web site', 'works'), 'site', 50, 150, $edit ? $work->nameSite() : ''));
        $form->addElement(new RMFormText(__('Site URL', 'works'), 'url', 50, 255, $edit ? $work->url() : ''));
    }
    $form->addElement(new RMFormDate(__('Start date', 'works'), 'start', $edit ? $work->start() : time()));
    $form->addElement(new RMFormText(__('Long time', 'works'), 'period', 50, 255, $edit ? $work->period() : ''));
    $form->addElement(new RMFormText(__('Monetary cost', 'works'), 'cost', 10, 20, $edit ? $work->cost() : 0));
    $form->addElement(new RMFormYesno(__('Featured', 'works'), 'mark', $edit ? $work->mark() : 0));
    $form->addElement(new RMFormYesno(__('Visible', 'works'), 'public', $edit ? $work->isPublic() : 1));
    $form->addElement(new RMFormFile(__('Work image', 'works'), 'image', 45, $xoopsModuleConfig['size_image'] * 1024));
    if ($edit) {
        $form->addElement(new RMFormLabel(__('Current image', 'works'), "<img src='" . XOOPS_UPLOAD_URL . "/works/ths/" . $work->image() . "' />"));
    }
    $ele = new RMFormSelect(__('Rating', 'works'), 'rating');
    for ($i = 0; $i <= 10; $i++) {
        $ele->addOption($i, $i, $edit ? $work->rating() == $i ? 1 : 0 : 0);
    }
    $form->addElement($ele, true);
    $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save'));
    $form->addElement(new RMFormHidden('id', $id));
    $form->addElement(new RMFormHidden('page', $page));
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', $edit ? __('Save Changes', 'works') : __('Create Work', 'works'), 'submit');
    $ele->addButton('cancel', __('Cancel', 'works'), 'button', 'onclick="window.location=\'works.php?' . $ruta . '\';"');
    $form->addElement($ele);
    if ($edit) {
        include RMTemplate::get()->get_template("admin/pw_work_options.php", 'module', 'works');
        RMTemplate::get()->add_style('admin.css', 'works');
    }
    $form->display();
    xoops_cp_footer();
}