コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
ファイル: home.php プロジェクト: laiello/bitcero-modules
//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'));
$tpl->assign('link_featured', PW_URL . ($mc['urlmode'] ? '/featured/' : '/featured.php'));
$thSize = $mc['image_ths'];
$tpl->assign('width', $thSize[0] + 10);
$tpl->assign('lang_featured', __('Featured', 'works'));
include 'footer.php';
コード例 #3
0
ファイル: pw_works.php プロジェクト: laiello/bitcero-modules
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;
}
コード例 #4
0
ファイル: work.php プロジェクト: laiello/bitcero-modules
        $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'));
$tpl->assign('lang_start', __('Begins', 'works'));
$tpl->assign('lang_period', __('Time length', 'works'));
$tpl->assign('lang_comment', __('Comment', 'works'));
$tpl->assign('lang_cost', __('Price', 'works'));
$tpl->assign('lang_others', __('Related Works', 'works'));
$tpl->assign('lang_date', __('Date', 'works'));
$tpl->assign('lang_images', __('Work Images', 'works'));
$tpl->assign('lang_site', __('Web site', 'works'));
$tpl->assign('lang_mark', __('Featured', 'works'));
コード例 #5
0
ファイル: works.php プロジェクト: laiello/bitcero-modules
/**
* @desc Almacena la información del trabajo en la base de datos
**/
function saveWorks($edit = 0)
{
    global $xoopsSecurity, $xoopsModuleConfig;
    $query = '';
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
        if ($k == 'XOOPS_TOKEN_REQUEST' || $k == 'op' || $k == 'sbt') {
            continue;
        }
        $query .= $query == '' ? "{$k}=" . urlencode($v) : "&{$k}=" . urlencode($v);
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('./works.php?op=' . ($edit ? 'edit&id=' . $id : 'new') . '&' . $query, __('Session token expired!', 'works'), 1);
        die;
    }
    if ($edit) {
        //Verificamos que el trabajo sea válido
        if ($id <= 0) {
            redirectMsg('./works.php?' . $query, __('Work ID not valid!', 'works'), 1);
            die;
        }
        //Verificamos que el trabajo exista
        $work = new PWWork($id);
        if ($work->isNew()) {
            redirectMsg('./works.php?' . $query, __('Specified work does not exists!', 'works'), 1);
            die;
        }
    } else {
        $work = new PWWork();
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    // Check if work exists already
    if ($edit) {
        $sql = "SELECT COUNT(*) FROM " . $db->prefix("pw_works") . " WHERE title='{$title}' and id_work<>'{$id}'";
    } else {
        $sql = "SELECT COUNT(*) FROM " . $db->prefix("pw_works") . " WHERE title='{$title}'";
    }
    list($num) = $db->fetchRow($db->query($sql));
    if ($num > 0) {
        redirectMsg("works.php?" . $query, __('A work with same name already exists!', 'works'), 1);
        die;
    }
    $work->setTitle($title);
    $work->set_title_id(TextCleaner::sweetstring($title));
    $work->setDescShort(substr(stripcslashes($short), 0, 255));
    $work->setDesc($desc);
    $work->setCategory($catego);
    $work->setClient($client);
    $work->setComment($comment);
    $work->setNameSite($site);
    $work->setUrl(formatURL($url));
    $work->setStart($start);
    $work->setPeriod($period);
    $work->setCost($cost);
    $work->setMark($mark);
    $work->setPublic($public);
    $work->setRating($rating);
    $work->isNew() ? $work->setCreated(time()) : '';
    $work->setVar('dohtml', isset($dohtml) ? 1 : 0);
    $work->setVar('doxcode', isset($doxcode) ? 1 : 0);
    $work->setVar('dobr', isset($dobr) ? 1 : 0);
    $work->setVar('dosmiley', isset($dosmiley) ? 1 : 0);
    $work->setVar('doimage', isset($doimage) ? 1 : 0);
    //Imagen
    include_once RMCPATH . '/class/uploader.php';
    $folder = XOOPS_UPLOAD_PATH . '/works';
    $folderths = XOOPS_UPLOAD_PATH . '/works/ths';
    if ($edit) {
        $image = $work->image();
        $filename = $work->image();
    } else {
        $filename = '';
    }
    //Obtenemos el tamaño de la imagen
    $thSize = $xoopsModuleConfig['image_main_ths'];
    $imgSize = $xoopsModuleConfig['image_main'];
    $up = new RMFileUploader($folder, $xoopsModuleConfig['size_image'] * 1024, array('jpg', 'png', 'gif'));
    if ($up->fetchMedia('image')) {
        if (!$up->upload()) {
            redirectMsg('./works.php?id=' . $id . '&op=' . ($edit ? 'edit' : 'new'), $up->getErrors(), 1);
            die;
        }
        if ($edit && $work->image() != '') {
            @unlink(XOOPS_UPLOAD_PATH . '/works/' . $work->image());
            @unlink(XOOPS_UPLOAD_PATH . '/works/ths/' . $work->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->resizeAndCrop($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;
        }
    }
    $work->setImage($filename);
    if (!$work->save()) {
        redirectMsg('./works.php?' . $query, __('Errors ocurred while trying to update database!', 'works') . $work->errors(), 1);
        die;
    } else {
        redirectMsg('./works.php?op=edit&id=' . $work->id(), __('Database updated successfully!', 'works'), 0);
        die;
    }
}