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;
}
 public function get_item_url($params, $com)
 {
     static $works;
     $params = urldecode($params);
     parse_str($params);
     if (!isset($work) || $work <= 0) {
         return '';
     }
     if (isset($works[$work])) {
         $ret = $works[$work]->link() . '#comment-' . $com->id();
         return $ret;
     }
     include_once XOOPS_ROOT_PATH . '/modules/works/class/pwwork.class.php';
     $item = new PWWork($work);
     if ($item->isNew()) {
         return '';
     }
     $ret = $item->link() . '#comment-' . $com->id();
     $works[$work] = $item;
     return $ret;
 }
Exemple #3
0
/**
* @desc Realiza una búsqueda en el módulo desde EXM
*/
function pwSearch($queryarray, $andor, $limit, $offset, $userid)
{
    global $myts;
    include_once XOOPS_ROOT_PATH . "/modules/works/class/pwwork.class.php";
    $mc = RMUtilities::module_config('works');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT a.* FROM " . $db->prefix('pw_works') . " a INNER JOIN " . $db->prefix('pw_clients') . " b ON (a.public=1 AND a.client=b.id_client AND (";
    $sql1 = '';
    if (is_array($queryarray)) {
        foreach ($queryarray as $k) {
            $sql1 .= ($sql1 == '' ? "" : "{$andor}") . " (a.title LIKE '%{$k}%' OR a.short LIKE '%{$k}%' OR b.name LIKE '%{$k}%' OR b.business_name LIKE '%{$k}%') ";
        }
    }
    $sql1 .= "))";
    $sql1 .= " GROUP BY a.id_work ORDER BY a.created DESC LIMIT {$offset}, {$limit}";
    $result = $db->queryF($sql . $sql1);
    $ret = array();
    while ($row = $db->fetchArray($result)) {
        $work = new PWWork();
        $work->assignVars($row);
        $rtn = array();
        $rtn['image'] = 'images/works.png';
        $rtn['title'] = $work->title();
        $rtn['time'] = $work->created();
        $rtn['uid'] = '';
        $rtn['desc'] = $work->descShort();
        $rtn['link'] = $work->link();
        $ret[] = $rtn;
    }
    return $ret;
}
 /**
  * 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;
 }
Exemple #5
0
$nav = new RMPageNav($num, $limit, $page, 5);
$url = $xoopsModuleConfig['urlmode'] ? XOOPS_URL . rtrim($xoopsModuleConfig['htbase'], '/') . '/page/{PAGE_NUM}/' : XOOPS_URL . '/modules/works/?page={PAGE_NUM}';
$nav->target_url($url);
$tpl->assign('navpage', $nav->render(false));
//Fin de barra de navegación
//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'));
Exemple #6
0
/**
* @desc Almacena las imágenes en la base de datos
**/
function saveImages($edit = 0)
{
    global $xoopsModuleConfig, $xoopsSecurity;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    $ruta = "&page={$page}";
    //Verificamos que el trabajo sea válido
    if ($work <= 0) {
        redirectMsg('./works.php', __('You must specify a work ID!', 'works'), 1);
        die;
    }
    //Verificamos que el trabajo exista
    $work = new PWWork($work);
    if ($work->isNew()) {
        redirectMsg('./works.php', __('Specified work does not exists!', 'works'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('./images.php?work=' . $work->id() . $ruta, __('Session token expired!', 'works'), 1);
        die;
    }
    if ($edit) {
        //Verificamos que la imagen sea válida
        if ($id <= 0) {
            redirectMsg('./images.php?work=' . $work->id() . $ruta, __('You must specify an image ID!', 'works'), 1);
            die;
        }
        //Verificamos que la imagen exista
        $img = new PWImage($id);
        if ($img->isNew()) {
            redirectMsg('./images.php?work=' . $work->id() . $ruta, __('Specified image does not exists!', 'works'), 1);
            die;
        }
    } else {
        $img = new PWImage();
    }
    $img->setTitle($title);
    $img->setDesc(substr($desc, 0, 100));
    $img->setWork($work->id());
    //Imagen
    include_once RMCPATH . '/class/uploader.php';
    $folder = XOOPS_UPLOAD_PATH . '/works';
    $folderths = XOOPS_UPLOAD_PATH . '/works/ths';
    if ($edit) {
        $image = $img->image();
        $filename = $img->image();
    } else {
        $filename = '';
    }
    //Obtenemos el tamaño de la imagen
    $thSize = $xoopsModuleConfig['image_ths'];
    $imgSize = $xoopsModuleConfig['image'];
    $up = new RMFileUploader($folder, $xoopsModuleConfig['size_image'] * 1024, array('jpg', 'png', 'gif'));
    if ($up->fetchMedia('image')) {
        if (!$up->upload()) {
            redirectMsg('./images.php?op=' . ($edit ? 'edit' : 'new') . '&work=' . $work->id() . $ruta, $up->getErrors(), 1);
            die;
        }
        if ($edit && $img->image() != '') {
            @unlink(XOOPS_UPLOAD_PATH . '/works/' . $img->image());
            @unlink(XOOPS_UPLOAD_PATH . '/works/ths/' . $img->image());
        }
        $filename = $up->getSavedFileName();
        $fullpath = $up->getSavedDestination();
        // Redimensionamos la imagen
        $redim = new RMImageResizer($fullpath, $fullpath);
        switch ($xoopsModuleConfig['redim_image']) {
            case 0:
                //Recortar miniatura
                $redim->resizeWidth($imgSize[0]);
                $redim->setTargetFile($folderths . "/{$filename}");
                $redim->resizeAndCrop($thSize[0], $thSize[1]);
                break;
            case 1:
                //Recortar imagen grande
                $redim->resizeWidthOrHeight($imgSize[0], $imgSize[1]);
                $redim->setTargetFile($folderths . "/{$filename}");
                $redim->resizeWidth($thSize[0]);
                break;
            case 2:
                //Recortar ambas
                $redim->resizeWidthOrHeight($imgSize[0], $imgSize[1]);
                $redim->setTargetFile($folderths . "/{$filename}");
                $redim->resizeAndCrop($thSize[0], $thSize[1]);
                break;
            case 3:
                //Redimensionar
                $redim->resizeWidth($imgSize[0]);
                $redim->setTargetFile($folderths . "/{$filename}");
                $redim->resizeWidth($thSize[0]);
                break;
        }
    }
    $img->setImage($filename);
    RMEvents::get()->run_event('works.save.image', $img);
    if (!$img->save()) {
        redirectMsg('./images.php?work=' . $work->id() . $ruta, __('Errors ocurred while trying to save the image', 'works') . '<br />' . $img->errors(), 1);
        die;
    } else {
        redirectMsg('./images.php?work=' . $work->id() . $ruta, __('Database updated successfully!', 'works'), 0);
        die;
    }
}
Exemple #7
0
//Categorías
$sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_categos');
list($categories) = $db->fetchRow($db->query($sql));
//Tipos de Cliente
$sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_types');
list($types) = $db->fetchRow($db->query($sql));
//Clientes
$sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_clients');
list($customers) = $db->fetchRow($db->query($sql));
//Trabajos
$sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_works');
list($works) = $db->fetchRow($db->query($sql));
// IMages
$sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_images');
list($images) = $db->fetchRow($db->query($sql));
// Works not published
$sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE public=0 ORDER BY id_work DESC LIMIT 0,5";
$result = $db->query($sql);
$works_pending = array();
while ($row = $db->fetchArray($result)) {
    $work = new PWWork();
    $work->assignVars($row);
    $works_pending[] = array('id' => $work->id(), 'title' => $work->title(), 'desc' => $work->descShort(), 'date' => formatTimestamp($work->created(), 'c'));
}
xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a>");
RMTemplate::get()->add_style('admin.css', 'works');
RMTemplate::get()->add_style('dashboard.css', 'works');
RMTemplate::get()->set_help('http://redmexico.com.mx/docs/professional-works');
xoops_cp_header();
include RMTemplate::get()->get_template("admin/pw_index.php", 'module', 'works');
xoops_cp_footer();
Exemple #8
0
/**
* Otros trabajos
**/
if ($mc['other_works'] > 0) {
    if ($mc['other_works'] == 2) {
        //Trabajos destacados
        $sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE public=1 AND mark=1 AND id_work<>'" . $work->id() . "' ORDER BY RAND() LIMIT 0," . $mc['num_otherworks'];
    } elseif ($mc['other_works'] == 1) {
        //Misma categoría
        $sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE public=1 AND catego=" . $work->category() . " AND id_work<>'" . $work->id() . "' ORDER BY RAND() LIMIT 0," . $mc['num_otherworks'];
    }
    $result = $db->query($sql);
    $categos = array();
    $clients = array();
    while ($row = $db->fetchArray($result)) {
        $wk = new PWWork();
        $wk->assignVars($row);
        if (!isset($categos[$wk->category()])) {
            $categos[$wk->category()] = new PWCategory($wk->category());
        }
        if (!isset($clients[$wk->client()])) {
            $clients[$wk->client()] = new PWClient($wk->client());
        }
        echo "1 - ";
        $tpl->append('other_works', array('id' => $wk->id(), 'title' => $wk->title(), 'desc' => $wk->descShort(), 'linkcat' => $categos[$wk->category()]->link(), 'catego' => $categos[$wk->category()]->name(), 'client' => $clients[$wk->client()]->name(), 'link' => $wk->link(), 'created' => formatTimeStamp($wk->created(), 's'), 'image' => XOOPS_UPLOAD_URL . '/works/ths/' . $wk->image(), 'views' => $wk->views(), 'metas' => $wk->get_metas()));
    }
    RMEvents::get()->run_event('works.load.other.works', $work);
}
$tpl->assign('lang_desc', __('Description', 'works'));
$tpl->assign('lang_catego', __('Category', 'works'));
$tpl->assign('lang_client', __('Customer', 'admin_works'));
Exemple #9
0
function pw_works_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');
    }
    $sql = "SELECT * FROM " . $db->prefix('pw_works') . ' WHERE public=1';
    $sql1 = $options[1] ? " AND catego='" . $options[1] . "'" : '';
    $sql2 = $options[2] ? " AND  client='" . $options[2] . "'" : '';
    $sql3 = '';
    switch ($options[0]) {
        case 0:
            $sql3 .= " ORDER BY RAND()";
            break;
        case 1:
            $sql3 .= ($sql1 || $sql2 ? " AND " : " WHERE ") . " mark=1 ORDER BY RAND()";
            break;
        case 2:
            $sql3 .= " ORDER BY created DESC ";
            break;
    }
    $sql3 .= " LIMIT 0," . $options[3];
    $result = $db->query($sql . $sql1 . $sql2 . $sql3);
    $clients = array();
    $categos = 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()];
        if (!isset($categos[$work->category()])) {
            $categos[$work->category()] = new PWCategory($work->category(), 1);
        }
        $cat =& $categos[$work->category()];
        $rtn = array();
        $rtn['title'] = $work->title();
        if ($options[6]) {
            $rtn['desc'] = substr($work->descShort(), 0, 50);
        }
        $rtn['link'] = $work->link();
        $rtn['created'] = formatTimestamp($work->created(), 's');
        if ($options[5]) {
            $rtn['image'] = XOOPS_UPLOAD_URL . '/works/ths/' . $work->image();
        }
        $linkcat = XOOPS_URL . '/modules/works/' . ($mc['urlmode'] ? 'cat/' . $cat->nameId() : 'catego.php?id=' . $cat->nameId());
        $rtn['cat'] = sprintf(__('Category: %s', 'works'), '<a href="' . $cat->link() . '">' . $cat->name() . '</a>');
        $rtn['client'] = sprintf(__('Customer: %s', 'works'), $client->businessName());
        $block['works'][] = $rtn;
    }
    $block['cols'] = $options[4];
    $block['showdesc'] = $options[6];
    $block['showimg'] = $options[5];
    return $block;
}
Exemple #10
0
function works_delete_meta()
{
    global $xoopsSecurity;
    $id = rmc_server_var($_POST, 'id', 0);
    if ($id <= 0) {
        redirectMsg('works.php', __('You must provide a work ID!', 'works'), 1);
        die;
    }
    $work = new PWWork($id);
    if ($work->isNew()) {
        redirectMsg('works.php', __('Specified work does not exists!', 'works'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('works.php?id=' . $id . '&op=meta', __('Session token expired!', 'works'), 1);
        die;
    }
    $ids = rmc_server_var($_POST, 'ids', array());
    if (!is_array($ids) || empty($ids)) {
        redirectMsg('works.php', __('Select some fields to delete!', 'works'), 1);
        die;
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "DELETE FROM " . $db->prefix("pw_meta") . " WHERE id_meta IN(" . implode(",", $ids) . ")";
    if ($db->queryF($sql)) {
        redirectMsg('works.php?id=' . $id . '&op=meta', __('Custom fields deleted successfully!', 'works'), 0);
    } else {
        redirectMsg('works.php?id=' . $id . '&op=meta', __('Custom fields could not be deleted!', 'works') . '<br />' . $db->error(), 1);
    }
}