Ejemplo n.º 1
0
function pw_categories_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';
    include_once XOOPS_ROOT_PATH . '/modules/works/class/pwcategory.class.php';
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    if (isset($xoopsModule) && $xoopsModule->dirname() == 'works') {
        $mc =& $xoopsModuleConfig;
    } else {
        $mc =& RMUtilities::module_config('works');
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $result = $db->query("SELECT * FROM " . $db->prefix("pw_categos") . " ORDER BY name");
    $block = array();
    while ($row = $db->fetchArray($result)) {
        $cat = new PWCategory();
        $cat->assignVars($row);
        $ret = array();
        $ret['name'] = $row['name'];
        $ret['link'] = $cat->link();
        $block['categos'][] = $ret;
    }
    return $block;
}
Ejemplo n.º 2
0
/**
* @desc Visualiza todos los trabajos existentes
**/
function showWorks()
{
    global $xoopsModule, $xoopsSecurity;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $limit = rmc_server_var($_REQUEST, 'limit', 15);
    $show = rmc_server_var($_REQUEST, 'show', '');
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_works');
    if ($show == 'public') {
        $sql .= " WHERE public=1";
    } elseif ($show == 'hidden') {
        $sql .= " WHERE public=0";
    }
    list($num) = $db->fetchRow($db->query($sql));
    $tpages = ceil($num / $limit);
    $page = $page > $tpages ? $tpages : $page;
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url('works.php?page={PAGE_NUM}');
    $sql = "SELECT * FROM " . $db->prefix('pw_works');
    if ($show == 'public') {
        $sql .= " WHERE public=1";
    } elseif ($show == 'hidden') {
        $sql .= " WHERE public=0";
    }
    $sql .= " ORDER BY id_work DESC LIMIT {$start}, {$limit}";
    $result = $db->query($sql);
    $works = array();
    //Container
    while ($row = $db->fetchArray($result)) {
        $work = new PWWork();
        $work->assignVars($row);
        //Obtenemos la categoría
        $cat = new PWCategory($work->category());
        //Obtenemos el cliente
        $user = new PWClient($work->client());
        $works[] = array('id' => $work->id(), 'title' => $work->title(), 'catego' => $cat->name(), 'client' => $user->name(), 'start' => formatTimeStamp($work->start(), 's'), 'mark' => $work->mark(), 'public' => $work->isPublic(), 'description' => $work->descShort());
    }
    PWFunctions::toolbar();
    RMTemplate::get()->add_style('admin.css', 'works');
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->add_script('../include/js/admin_works.js');
    RMTemplate::get()->add_head("<script type='text/javascript'>\nvar pw_message='" . __('Do you really want to delete selected works?', 'works') . "';\n\n        var pw_select_message = '" . __('You must select some work before to execute this action!', 'works') . "';</script>");
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; " . __('Works', 'works'));
    xoops_cp_header();
    include RMTemplate::get()->get_template("admin/pw_works.php", 'module', 'works');
    xoops_cp_footer();
}
Ejemplo n.º 3
0
/**
* @desc Activa/desactiva las categorías especificadas
**/
function activeCategory($act = 0)
{
    global $xoopsSecurity;
    $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : null;
    if (!$xoopsSecurity->check()) {
        redirectMsg('./categos.php', __('Session token expired!', 'works'), 1);
        die;
    }
    //Verificamos que nos hayan proporcionado una categoría
    if (!is_array($ids)) {
        redirectMsg('./categos.php', __('You must select a category to enable/disable', 'works'), 1);
        die;
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si la categoría es válida
        if ($k <= 0) {
            $errors .= sprintf(__('Category id "%s" is not valid!', 'works'), $k);
            continue;
        }
        //Verificamos si la categoría existe
        $cat = new PWCategory($k);
        if ($cat->isNew()) {
            $errors .= sprintf(__('Specified category "%s" does not exists!', 'works'), $k);
            continue;
        }
        $cat->setActive($act);
        RMEvents::get()->run_event('works.activate.category', $cat);
        if (!$cat->save()) {
            $errors .= sprintf(__('Category "%s" could not be saved!', 'works'), $k);
        }
    }
    if ($errors != '') {
        redirectMsg('./categos.php', __('Errors ocurred while trying to save category', 'works') . $errors, 1);
        die;
    } else {
        redirectMsg('./categos.php', __('Database updated successfully!', 'works'), 0);
        die;
    }
}
Ejemplo n.º 4
0
    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);
$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']);
Ejemplo n.º 5
0
// Advanced Portfolio System
// Author: BitC3R0 <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
$xoopsOption['template_main'] = 'pw_catego.html';
$xoopsOption['module_subpage'] = 'category';
include 'header.php';
PWFunctions::makeHeader();
$mc =& $xoopsModuleConfig;
if ($id == '') {
    header('location: ' . PW_URL);
    die;
}
//Verificamos si la categoría existe
$cat = new PWCategory($id);
if ($cat->isNew()) {
    redirect_header(PW_URL . '/', 2, __('Specified category does not exists!', 'works'));
    die;
}
RMEvents::get()->run_event('works.starting.categories', $cat);
// Category
$tpl->assign('category', array('id' => $cat->id(), 'title' => $cat->name(), 'name' => $cat->nameId(), 'desc' => $cat->desc()));
//Barra de Navegación
$sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_works') . " WHERE public=1 AND catego='" . $cat->id() . "'";
list($num) = $db->fetchRow($db->query($sql));
$limit = $mc['num_recent'];
$limit = $limit <= 0 ? 10 : $limit;
if (!isset($page)) {
    $page = rmc_server_var($_GET, 'page', 1);
}
Ejemplo n.º 6
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);
}