Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- */
- function new_search_show_found() {
- $query = db_select('node', 'n')
- ->fields('n', array('nid', 'title', 'type'));
- $query = $query->extend('PagerDefault');
- if ($_GET['search']) {
- $output = ('<h1>' . t('Search results') . '<span>"' . $_GET['search'] . '"</span></h1>');
- $query->leftJoin('field_revision_field_promo', 'p', 'p.entity_id = n.nid');
- $or = db_or();
- $or->condition('field_promo_value', $_GET['search']);
- $or->condition('title', '%' . $_GET['search'] . '%', 'LIKE');
- $query->condition('type', 'page', '!=');
- $query->condition($or);
- } else {
- $output = ('<h1>' . t('All promo') . '</h1>');
- $query->condition('type', 'promo');
- }
- $query->orderBy('nid', 'DESC');
- $query->limit(10);
- $query = $query->execute();
- $num = 1;
- $output .= '<div class="akcia search">
- <div class="items">';
- while($item = $query->fetchAssoc()){
- if ($item['type'] == 'promo') {
- $promo = node_load($item['nid']);
- $shop = node_load($promo->field_promo_shop['und'][0]['nid']);
- $output .= '<div class="item">';
- $output .= '
- <div class="left">
- ' . theme_image(array('path' => $shop->field_shop_logo['und'][0]['uri'])) . '
- ' . l(t('Shop actions'), 'node/' . $shop->nid) . '
- </div>
- <div class="center">';
- //echo '<pre>';
- //print_r($promo);
- //echo '<pre>';
- // set taxonomy term id for Pop-Up
- $tid_popup = 133;
- // set taxonomy term id for iFrame
- $tid_iframe = 134;
- $nalias = drupal_get_path_alias('node/'.$promo->nid);
- if (isset($promo->field_promo_link_type['und'][0]['tid'])
- && intval($promo->field_promo_link_type['und'][0]['tid']) == $tid_popup){
- $output .= '<a href="http://promokoder.com.ua/'.$nalias.'?display=pop-up" class="pop-up-title-link" target="_blank"><h4>'.$promo->title.'</h4></a>';
- }else{
- if (isset($promo->field_promo_link_type['und'][0])
- && $promo->field_promo_link_type['und'][0]['tid']
- && intval($promo->field_promo_link_type['und'][0]['tid']) == $tid_iframe){
- $output .= '<a href="http://promokoder.com.ua/'.$nalias.'?display=iframe" target="_blank"><h4>'.$promo->title.'</h4></a>';
- }else{
- if (!isset($promo->field_promo_link_type['und'][0])){
- $output .= '<a href="http://promokoder.com.ua/'.$nalias.'?display=pop-up" class="pop-up-title-link" target="_blank"><h4>'.$promo->title.'</h4></a>';
- }
- }
- }
- if (isset($promo->field_promo_to_date['und'][0]['value'])
- && strtotime($promo->field_promo_to_date['und'][0]['value']) >= time()){
- $output .= '<div class="close">
- <span class="to-date">Окончание акции: <small>';
- $getd = strtotime($promo->field_promo_to_date['und'][0]['value']);
- $conv = date("d m Y", $getd);
- $expl = explode(" ", $conv);
- switch($expl[1]){
- case 01:
- $expl[1] = "января";
- break;
- case 02:
- $expl[1] = "февраля";
- break;
- case 03:
- $expl[1] = "марта";
- break;
- case 04:
- $expl[1] = "апреля";
- break;
- case 05:
- $expl[1] = "мая";
- break;
- case 06:
- $expl[1] = "июня";
- break;
- case 07:
- $expl[1] = "июля";
- break;
- case 08:
- $expl[1] = "августа";
- break;
- case 09:
- $expl[1] = "сентября";
- break;
- case 10:
- $expl[1] = "октября";
- break;
- case 11:
- $expl[1] = "ноября";
- break;
- case 12:
- $expl[1] = "декабря";
- break;
- }
- $output .= '<div style="font-size: 14px; display: inline-block;">'.$expl[0].' '.$expl[1].', '.$expl[2].'</div>';
- $output .= '</small></span>
- </div>';
- }
- $output .= '
- </div>
- <div class="right">';
- /*<div class="link">' . l(t('Show promo'), 'node/' . $promo->nid) . '</div>
- <span></span>
- <div class="hide"></div>*/
- if (isset($promo->field_promo_to_date['und'][0]['value'])
- && strtotime($promo->field_promo_to_date['und'][0]['value']) >= time()) {
- $tid_promocode = 131;
- $tid_action = 132;
- if (isset($promo->field_type_of_content['und'][0]['tid'])
- && intval($promo->field_type_of_content['und'][0]['tid']) == $tid_action){
- $btn_text = "Перейти <br/>на акцию";
- }else{
- if (isset($promo->field_type_of_content['und'][0]['tid'])
- && intval($promo->field_type_of_content['und'][0]['tid']) == $tid_promocode){
- $btn_text = "Показать промокод";
- }else{
- if (!isset($promo->field_type_of_content['und'][0])){
- $btn_text = "Показать промокод";
- }
- }
- }
- $output .= '<div class="link">';
- // set taxonomy term id for Pop-Up
- $tid_popup = 133;
- // set taxonomy term id for iFrame
- $tid_iframe = 134;
- $nalias = drupal_get_path_alias('node/'.$promo->nid);
- if (isset($promo->field_promo_link_type['und'][0]['tid'])
- && intval($promo->field_promo_link_type['und'][0]['tid']) == $tid_popup){
- $output .= '<a href="http://promokoder.com.ua/'.$nalias.'?display=pop-up" target="_blank" class="pop-up-window">'.$btn_text.'</a>';
- }else{
- if (isset($promo->field_promo_link_type['und'][0]['tid'])
- && intval($promo->field_promo_link_type['und'][0]['tid']) == $tid_iframe){
- $output .= '<a href="http://promokoder.com.ua/'.$nalias.'?display=iframe" target="_blank">'.$btn_text.'</a>';
- }else{
- if (!isset($promo->field_promo_link_type['und'][0])){
- $output .= '<a href="http://promokoder.com.ua/'.$nalias.'?display=pop-up" target="_blank" class="pop-up-window">'.$btn_text.'</a>';
- }
- }
- }
- if(!empty($promo->field_promo_count_reviews['und'][0]['value'])){
- $vcount = ($promo->field_promo_count_reviews['und'][0]['value']);
- }else{
- $vcount = 1;
- }
- $output .= '
- </div>
- <span></span>
- <div class="hide"><div class="reviews-counter"><p class="views-title">Воспользовались:</p><img src="'.base_path().'sites/all/themes/promo/img/person.png" class="i-promo"><div class="counter">'.$vcount.'</div></div></div>';
- }else{
- if(!empty($promo->field_promo_count_reviews['und'][0]['value'])){
- $vcount = ($promo->field_promo_count_reviews['und'][0]['value']);
- }else{
- $vcount = 1;
- }
- $output .= '
- <div class="end">
- <div class="over-text">'.t('Action is over').'</div>
- <div class="reviews-counter"><p class="views-title">Воспользовались:</p><img src="'.base_path().'sites/all/themes/promo/img/person.png" class="i-promo"><div class="counter">'.$vcount.'</div></div>
- </div>';
- }
- $output .= '
- </div>
- </div>';
- } else if ($item['type'] == 'brand'){
- $output .= '
- <div class="text">' .
- l($item['title'], drupal_get_path_alias('node/' . $item['nid'])) .
- '
- </div>';
- } else {
- $output .= '
- <div class="text">' .
- l($item['title'], 'node/' . $item['nid']) .
- '
- </div>';
- }
- ++$num;
- }
- $output = $output . theme('pager', array('show_next' => TRUE), $quantity = 5) . '
- </div>
- </div>';
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement