Example #1
0
 public function init($category_id = null, $current_tuid = null)
 {
     parent::init();
     global $js_file;
     $js_file['tservices/tservices_catalog'] = 'tservices/tservices_catalog.js';
     if (isset($this->options['limit'])) {
         $this->limit = $this->options['limit'];
     }
     if (isset($this->options['prof_group_id'], $this->options['prof_id']) && !$category_id) {
         require_once ABS_PATH . '/classes/tservices/tservices_categories.php';
         $tservices_categories = new tservices_categories();
         $category_data = $tservices_categories->getCategoryByFreelancersCatalog($this->options['prof_group_id'], $this->options['prof_id']);
         if ($category_data) {
             $category_id = $category_data['id'];
             $this->options['category_title'] = $category_data['title'];
             $this->options['category_stitle'] = $category_data['link'];
         }
     }
     $tservicesCatalogModel = new tservices_catalog();
     $tservicesCatalogModel->setPage($this->limit, 1);
     if (isset($this->options['user_id']) && $this->options['user_id'] > 0) {
         $tservicesCatalogModel->user_id = $this->options['user_id'];
     } elseif ($category_id) {
         $tservicesCatalogModel->category_id = $category_id;
     }
     $exclude_ids = $current_tuid ? array($current_tuid) : array();
     $list = $tservicesCatalogModel->cache($this->ttl_cache)->getList($exclude_ids);
     $this->tservices = $list['list'];
     if ($this->tservices) {
         //расширение сведений о типовых услугах
         $tserviceModel = new TServiceModel();
         $tserviceModel->addOwnerInfo()->extend($this->tservices, 'id');
     }
 }
Example #2
0
 /**
  * Возвращает диапазоны цен.
  *
  * @return array
  */
 public function getPriceRanges()
 {
     $prices = tservices_catalog::getPriceRanges();
     foreach ($prices as $i => &$price) {
         $price['id'] = "price[{$i}]";
         $price['value'] = $i;
         $price['checked'] = !empty($this->filter->prices[$i]);
     }
     return $prices;
 }
 /**
  * Отображение страницы /tu/.
  */
 public function actionIndex()
 {
     $uid = get_uid();
     $page = __paramInit('int', 'page', 'page', 1);
     $limit = 21;
     $empty_criteria = $this->filter_widget->filter->isEmpty();
     $prof_id = $this->filter_widget->filter->category ? $this->filter_widget->filter->category : $this->filter_widget->filter->category_group;
     $tserviceModel = TServiceModel::model();
     $freelancerModel = FreelancerModel::model();
     $tservicesCatalogModel = new tservices_catalog();
     $tservicesCatalogModel->category_id = $prof_id;
     $kind = tservices_binds::KIND_ROOT;
     if ($this->filter_widget->filter->category) {
         $kind = tservices_binds::KIND_SPEC;
     } elseif ($this->filter_widget->filter->category_group) {
         $kind = tservices_binds::KIND_GROUP;
     }
     if ($page == 1 && $uid && !is_emp()) {
         $this->getClips()->add('bind_teaser', $this->widget('TServiceBindTeaser', array('kind' => $kind, 'uid' => $uid, 'prof_id' => $prof_id, 'is_inner' => !$empty_criteria), true));
         $this->getClips()->add('bind_teaser_short', $this->widget('TServiceBindTeaserShort', array(), true));
     }
     $free_places = true;
     //Сначала берем закрепленные
     $tservicesCatalogModel->setPage($limit, $page);
     $tservices_binded = $tservicesCatalogModel->getBindedList($kind);
     //Тут только для текущей страницы
     $tservices_binded_ids = $tservicesCatalogModel->getBindedIds($kind);
     //Тут для всех страниц
     $count_binded = count($tservices_binded_ids);
     $count_binded_cur_page = count($tservices_binded);
     if ($count_binded_cur_page) {
         // расширение сведений о типовых услугах
         $tserviceModel->extend($tservices_binded, 'id')->readVideos($tservices_binded, 'videos', 'videos');
         // во всех строках "распаковать" массив видео-клипов
         // расширение сведений о пользователях
         $freelancerModel->extend($tservices_binded, 'user_id', 'user');
         //Добавляем попапы продления и поднятия к услугам текущего юзера
         foreach ($tservices_binded as $key => $tservice) {
             $is_owner = $tservice['user_id'] == $uid;
             if ($is_owner) {
                 $this->getClips()->add('bind_links_' . $tservice['id'], $this->widget('TServiceBindLinks', array('kind' => $kind, 'uid' => $uid, 'is_inner' => !$empty_criteria, 'date_stop' => $tservice['date_stop'], 'allow_up' => $page > 1 || $key > 0, 'tservice_id' => $tservice['id']), true));
                 if (quickPaymentPopupTservicebind::getInstance()->inited == false) {
                     quickPaymentPopupTservicebind::getInstance()->init(array('uid' => $uid, 'kind' => $kind, 'prof_id' => $prof_id));
                 }
                 $popup_id = quickPaymentPopupTservicebind::getInstance()->getPopupId($tservice['id']);
                 $popups[] = quickPaymentPopupTservicebind::getInstance()->render(array('is_prolong' => true, 'date_stop' => $tservice['date_stop'], 'popup_id' => $popup_id, 'tservices_cur' => $tservice['id'], 'tservices_cur_text' => $tservice['title']));
                 if ($key > 0) {
                     if (quickPaymentPopupTservicebindup::getInstance()->inited == false) {
                         quickPaymentPopupTservicebindup::getInstance()->init(array('uid' => $uid, 'tservices_id' => $tservice['id'], 'tservices_title' => $tservice['title'], 'kind' => $kind, 'prof_id' => $prof_id));
                     }
                     $popup_id = quickPaymentPopupTservicebindup::getInstance()->getPopupId($tservice['id']);
                     $popups[] = quickPaymentPopupTservicebindup::getInstance()->render(array('popup_id' => $popup_id, 'tservices_cur' => $tservice['id'], 'tservices_cur_text' => $tservice['title']));
                 }
             }
         }
         $free_places = $count_binded_cur_page < $limit;
     }
     if ($free_places) {
         //Есть места для отображения незакрепленных услуг
         $tservicesCatalogModel->keywords = $this->filter_widget->filter->keywords;
         $tservicesCatalogModel->price_ranges = $this->filter_widget->filter->prices;
         $tservicesCatalogModel->price_max = $this->filter_widget->filter->price_max;
         $tservicesCatalogModel->country_id = $this->filter_widget->filter->country;
         $tservicesCatalogModel->city_id = $this->filter_widget->filter->city;
         $tservicesCatalogModel->order = $this->filter_widget->filter->order;
         $tservicesCatalogModel->setPage($limit, $page, $count_binded, $count_binded_cur_page);
         // поиск записей
         $list = $tservicesCatalogModel->cache(300)->getList($tservices_binded_ids);
         $tservices_search = $list['list'];
         $total = $list['total'];
         // расширение сведений о типовых услугах
         $tserviceModel->extend($tservices_search, 'id')->readVideos($tservices_search, 'videos', 'videos');
         // во всех строках "распаковать" массив видео-клипов
         // расширение сведений о пользователях
         $freelancerModel->extend($tservices_search, 'user_id', 'user');
     }
     $tservices = $tservices_binded;
     foreach ($tservices_search as $tservice) {
         if (count($tservices) < $limit && !in_array($tservice['id'], $tservices_binded_ids)) {
             $tservices[] = $tservice;
         }
     }
     $tservicesCatalogModel2 = new tservices_catalog();
     $tservicesCatalogModel2->category_id = $prof_id;
     $tservicesCatalogModel2->order = TServiceFilter::ORDER_PRICE_ASC;
     $tservicesCatalogModel2->setPage(1, 1);
     $list2 = $tservicesCatalogModel2->cache(300)->getList();
     $min_price = $list2['list'][0]['price'];
     SeoTags::getInstance()->initTserviceList($prof_id, $this->filter_widget->filter->category > 0, $total, $min_price);
     $view_name = !$empty_criteria ? 'list' : 'tile';
     $this->is_main = $empty_criteria;
     /*
             if ($empty_criteria)
             {
                 // над списком типовых услуг вывести рекламный блок раздела
                 require_once($_SERVER['DOCUMENT_ROOT'] . '/tu/widgets/TServiceCatalogPromo.php');
                 $this->getClips()->add('content-promo', $this->widget('TServiceCatalogPromo', array(), true));
             }
     */
     $tservices_binds = new tservices_binds($kind);
     $this->render($view_name, array('category_title' => $this->filter_widget->getCategoryAngGroupTitle(' / '), 'total' => $total, 'nothing_found' => empty($tservices), 'tservices' => $tservices, 'page' => $tservicesCatalogModel->page, 'limit' => $limit, 'paging_base_url' => $this->filter_widget->getUserFriendlyUrl(), 'is_adm' => $this->is_adm, 'orders' => $this->filter_widget->getAllowedOrders(true), 'cur_order' => $this->filter_widget->filter->order, 'uid' => $uid, 'popups' => $popups, 'bind_up_price' => $tservices_binds->getPrice(true, $uid, $prof_id)));
 }
Example #4
0
// Прячем карусель вверху страницы
$hide_carouser = true;
// Прячем блок с сообщениями
$hide_notification_bar = true;
$header = "../header.php";
$footer = "../footer.html";
/**
* Типовые услуги
**/
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/tservices_binds.php';
$page = 1;
// Количество типовых услуг на главной странице
$limit = 12;
$tserviceModel = TServiceModel::model();
$freelancerModel = FreelancerModel::model();
$tservicesCatalogModel = new tservices_catalog();
$tservicesCatalogModel->setPage($limit, $page);
//Сначала берем закрепленные
$tservices_binded = $tservicesCatalogModel->getBindedList(tservices_binds::KIND_LANDING);
$binded_ids = array();
if (count($tservices_binded)) {
    foreach ($tservices_binded as $tservice) {
        $binded_ids[] = $tservice['id'];
    }
    // расширение сведений о типовых услугах
    $tserviceModel->extend($tservices_binded, 'id')->readVideos($tservices_binded, 'videos', 'videos');
    // во всех строках "распаковать" массив видео-клипов
    // расширение сведений о пользователях
    $freelancerModel->extend($tservices_binded, 'user_id', 'user');
}
$popups = array();
Example #5
0
/**
 * Получение 3х смежных по категориям ТУ.
 * 
 * @param type $cat_group
 * @param type $cat
 *
 * @return \xajaxResponse
 */
function getRelativeTU($cat_group, $cat)
{
    $objResponse = new xajaxResponse();
    $cat_group = intval($cat_group);
    $cat = intval($cat);
    if (!$cat_group) {
        return $objResponse;
    }
    require_once $_SERVER['DOCUMENT_ROOT'] . '/tu/yii/tinyyii.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/tu/widgets/TServiceFilter.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/tservices_catalog.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/tservices_categories.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/tservices_helper.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/template.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/tu/models/TServiceModel.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/tu/models/FreelancerModel.php';
    $tservices_categories = new tservices_categories();
    $category_group = $tservices_categories->getIdByGid($cat_group);
    $category = $tservices_categories->getIdByPid($cat);
    $limit = 3;
    $tservicesCatalogModel = new tservices_catalog();
    $tservicesCatalogModel->category_id = $category ? (int) $category : (int) $category_group;
    $tservicesCatalogModel->setPage($limit);
    // поиск записей
    $list = $tservicesCatalogModel->cache(300)->getList();
    $tservices = $list['list'];
    // расширение сведений о типовых услугах
    $tserviceModel = TServiceModel::model();
    $tserviceModel->extend($tservices, 'id')->readVideos($tservices, 'videos', 'videos');
    // во всех строках "распаковать" массив видео-клипов
    // расширение сведений о пользователях
    $freelancerModel = FreelancerModel::model();
    $freelancerModel->extend($tservices, 'user_id', 'user');
    if (($cat_group || $cat) && count($tservices)) {
        $html = Template::render(ABS_PATH . '/templates/recomend_tu.php', array('tservices' => $tservices));
        $objResponse->script("\$('otherprojects').addClass('b-layout_hide');");
        $objResponse->assign('recomend_tu', 'innerHTML', $html);
    } else {
        $objResponse->script("\$('otherprojects').removeClass('b-layout_hide');");
        $objResponse->assign('recomend_tu', 'innerHTML', '');
    }
    return $objResponse;
}