Exemple #1
0
 public function send()
 {
     if (!$this->_to || !$this->_subject || !$this->_view) {
         return FALSE;
     }
     if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
         ini_set('sendmail_from', $this->_from);
     }
     $headers = array('From: ' . $this->_from, 'Reply-to: ' . $this->_from);
     $this->config->base_url = 'http://' . $_SERVER['HTTP_HOST'] . url();
     $this->template->parse_data($this->_data, $this->load);
     $message = $html = $this->load->view('emails/' . $this->_view, $this->_data);
     $text = $this->load->view('emails/' . $this->_view . '.txt', $this->_data);
     if ($text) {
         $headers[] = 'MIME-Version: 1.0';
         $headers[] = 'Content-Type: multipart/alternative;' . "\n" . ' boundary="' . ($boundary = '--------' . unique_id()) . '"';
         $message = '--' . $boundary . "\n";
         $message .= 'Content-Type: text/plain; charset=UTF-8; format=flowed' . "\n\n";
         $message .= str_replace('\\r', '', $text) . "\n\n";
         $message .= '--' . $boundary . "\n";
         $message .= 'Content-Type: text/html; charset=UTF-8;' . "\n\n";
         $message .= str_replace('\\r', '', $html) . "\n\n";
     }
     $result = mail(trim_word($this->_to, ', '), $this->config->nf_name . ' :: ' . $this->_subject, wordwrap($message, 70), implode("\r\n", $headers));
     $this->reset();
     return $result;
 }
Exemple #2
0
 public function builder($request)
 {
     if (isset($request['query'])) {
         return $request['query'];
     } else {
         if (isset($request['from'])) {
             return 'SELECT ' . (!empty($request['select']) && is_array($request['select']) ? trim_word(implode(', ', array_map(array(&$this, 'escape_keyword'), $request['select'])), ', ') : '*') . ' FROM ' . $request['from'] . (isset($request['join']) ? ' ' . $request['join'] : '') . (isset($request['where']) ? ' WHERE ' . trim_word($request['where'], ' AND ', ' OR ') : '') . (isset($request['group_by']) ? ' GROUP BY ' . trim_word(implode(', ', $request['group_by']), ', ') : '') . (isset($request['having']) ? ' HAVING ' . trim_word(implode(', ', $request['having']), ', ') : '') . (isset($request['order_by']) ? ' ORDER BY ' . trim_word(implode(', ', array_map(array(&$this, 'escape_keyword'), $request['order_by'])), ', ') : '') . (isset($request['limit']) ? ' LIMIT ' . $request['limit'] : '');
         } else {
             if (isset($request['insert'], $request['values'])) {
                 $keys = '';
                 foreach (array_keys($request['values']) as $key) {
                     $keys .= $this->escape_keyword($key) . ', ';
                 }
                 $values = '';
                 foreach ($request['values'] as $value) {
                     $values .= $this->escape_string($value) . ', ';
                 }
                 return 'INSERT INTO ' . $request['insert'] . ' (' . trim_word($keys, ', ') . ') VALUES (' . trim_word($values, ', ') . ')';
             } else {
                 if (isset($request['update'], $request['set'])) {
                     if (is_array($request['set'])) {
                         $sets = '';
                         foreach ($request['set'] as $key => $value) {
                             $sets .= $this->escape_keyword($key) . ' = ' . $this->escape_string($value) . ', ';
                         }
                     } else {
                         $sets = $request['set'];
                     }
                     return 'UPDATE ' . $request['update'] . ' SET ' . trim_word($sets, ', ') . (isset($request['where']) ? ' WHERE ' . trim_word($request['where'], ' AND ', ' OR ') : '');
                 } else {
                     if (isset($request['delete'])) {
                         $query = 'DELETE ';
                         if (isset($request['multi_tables'])) {
                             $query .= $request['delete'] . ' FROM ' . $request['multi_tables'];
                         } else {
                             $query .= 'FROM ' . $request['delete'];
                         }
                         return $query . (isset($request['where']) ? ' WHERE ' . trim_word($request['where'], ' AND ', ' OR ') : '');
                     }
                 }
             }
         }
     }
     return '';
 }
Exemple #3
0
    public function display()
    {
        NeoFrag::loader()->css('neofrag.table')->js('neofrag.table');
        $output = '';
        $search = trim(post('search'));
        if (post('table_id')) {
            if (post('table_id') == $this->id) {
                $this->config->ajax_url = TRUE;
                $this->_ajax = TRUE;
            } else {
                $this->reset();
                return;
            }
        }
        if (!is_null($session_sort = $this->session('table', $this->id, 'sort'))) {
            foreach ($session_sort as $session) {
                list($column_id, $order) = $session;
                $this->sort_by($column_id, $order);
            }
        }
        if ($this->_pagination && !empty($this->pagination) && !is_null($items_per_page = $this->session('table', $this->id, 'items_per_page'))) {
            $this->pagination->set_items_per_page($items_per_page);
        }
        if (!is_null($sort = post('sort')) && $this->_ajax) {
            list($column_id, $order) = json_decode($sort);
            if (in_array($order, array('asc', 'desc', 'none'))) {
                if ($order == 'asc') {
                    $order = SORT_ASC;
                } else {
                    if ($order == 'desc') {
                        $order = SORT_DESC;
                    } else {
                        if ($order == 'none') {
                            $order = -1;
                        }
                    }
                }
                $added = FALSE;
                if (!is_null($session_sort = $this->session('table', $this->id, 'sort'))) {
                    foreach ($session_sort as $i => $session) {
                        if ($column_id == $session[0]) {
                            $added = TRUE;
                            if ($order != -1 || isset($this->_sortings[$column_id])) {
                                $this->session->set('table', $this->id, 'sort', $i, array($column_id, $order));
                            } else {
                                $this->session->destroy('table', $this->id, 'sort', $i);
                            }
                        }
                    }
                }
                if (!$added) {
                    $this->session->add('table', $this->id, 'sort', array($column_id, $order));
                }
                $this->sort_by($column_id, $order);
            }
            $search = $this->session('table', $this->id, 'search');
        }
        $count_results = $this->_pagination && !empty($this->pagination) ? $this->pagination->count() : count($this->_data);
        if ($this->_is_searchable() && $search && $this->_pagination && !empty($this->pagination)) {
            $this->_data = $this->pagination->display_all();
        } else {
            if (!empty($this->_sortings) && $this->_pagination && !empty($this->pagination) && (!isset($search) || !$search)) {
                $this->_data = $this->pagination->get_data();
            }
        }
        $this->_preprocessing();
        //Gestion des recherches
        if ($this->_is_searchable()) {
            if ($search) {
                $results = array();
                $words = explode(' ', trim($search));
                foreach ($this->_data as $data_id => $data) {
                    $found = 0;
                    $data = array_merge(array('data_id' => $data_id), $data);
                    foreach ($this->_columns as $value) {
                        if (!isset($value['search']) || is_null($value['search'])) {
                            continue;
                        }
                        $value = $this->template->parse($value['search'], $data, $this->load);
                        foreach ($words as $word) {
                            if (in_string($word, $value, FALSE)) {
                                $found++;
                            }
                        }
                        if ($found == count($words)) {
                            break;
                        }
                    }
                    if ($found == count($words)) {
                        $results[] = $data;
                    }
                }
                $this->session->set('table', $this->id, 'search', $search);
                $this->_data = $results;
                $this->_no_data = NeoFrag::loader()->lang('no_result');
            } else {
                $this->session->destroy('table', $this->id, 'search');
            }
            $words = array();
            foreach ($this->_data as $data_id => $data) {
                $data = array_merge(array('data_id' => $data_id), $data);
                foreach ($this->_columns as $value) {
                    if (!isset($value['search']) || is_null($value['search'])) {
                        continue;
                    }
                    $this->_words[] = $value = $this->template->parse($value['search'], $data, $this->load);
                    $words[] = '"' . $value . '"';
                }
            }
        }
        if (empty($this->_data)) {
            $output = '<div class="clearfix"></div>' . ($this->_no_data ?: NeoFrag::loader()->lang('no_data'));
        } else {
            if (!$this->_ajax && $this->_is_searchable()) {
                $search_input = '	<div class="table-search pull-left">
										<div class="form-group has-feedback">
											<input class="form-control" data-provide="typeahead" data-items="5" data-source="' . utf8_htmlentities('[' . trim_word(implode(', ', array_unique($words)), ', ') . ']') . '" type="text"' . (isset($search) ? ' value="' . $search . '"' : '') . ' placeholder="' . NeoFrag::loader()->lang('search') . '" autocomplete="off" />
										</div>
									</div>';
            }
            //Gestion des tris
            if (!empty($this->_sortings)) {
                $sortings = array();
                foreach ($this->_sortings as $column => $order) {
                    if (!isset($this->_columns[$column]) || !isset($this->_columns[$column]['sort']) || $order[0] == -1) {
                        continue;
                    }
                    $tmp = array();
                    foreach ($this->_data as $data_id => $data) {
                        $data = array_merge(array('data_id' => $data_id), $data);
                        $tmp[] = $this->template->parse($this->_columns[$column]['sort'], $data, $this->load);
                    }
                    $sortings[] = array_map('strtolower', $tmp);
                    $sortings = array_merge($sortings, $order);
                }
                $data = array();
                foreach ($this->_data as $key => $value) {
                    $data[$key . ' '] = $value;
                }
                $sortings[] =& $data;
                call_user_func_array('array_multisort', $sortings);
                $this->_data = array();
                foreach ($data as $key => $value) {
                    $this->_data[trim($key)] = $value;
                }
                if ($this->_pagination && !empty($this->pagination) && ($items_per_page = $this->pagination->get_items_per_page()) > 0) {
                    $this->_data = array_slice($this->_data, ($this->pagination->get_page() - 1) * $items_per_page, $items_per_page);
                }
            }
            if ($this->_pagination && !empty($this->pagination) && $this->pagination->count() > 10) {
                $output .= '<div class="form-group pull-left">
								<select class="form-control" style="width: auto;" onchange="window.location=\'' . $this->pagination->get_url() . '/\'+$(this).find(\'option:selected\').data(\'url\')+\'.html\'" autocomplete="off">
									<option value="10"' . ($this->pagination->get_items_per_page() == 10 ? ' selected="selected"' : '') . ' data-url="page/1/10">' . NeoFrag::loader()->lang('results', 10, 10) . '</option>
									<option value="25"' . ($this->pagination->get_items_per_page() == 25 ? ' selected="selected"' : '') . ' data-url="page/1/25">' . NeoFrag::loader()->lang('results', 25, 25) . '</option>
									<option value="50"' . ($this->pagination->get_items_per_page() == 50 ? ' selected="selected"' : '') . ' data-url="page/1/50">' . NeoFrag::loader()->lang('results', 50, 50) . '</option>
									<option value="100"' . ($this->pagination->get_items_per_page() == 100 ? ' selected="selected"' : '') . ' data-url="page/1/100">' . NeoFrag::loader()->lang('results', 100, 100) . '</option>
									<option value="all"' . ($this->pagination->get_items_per_page() == 0 ? ' selected="selected"' : '') . ' data-url="all">' . NeoFrag::loader()->lang('show_all') . '</option>
								</select>
							</div>';
            }
            if ($this->_pagination && !empty($this->pagination) && ($pagination = $this->pagination->get_pagination()) != '') {
                $output .= '<div class="form-group pull-right">' . $pagination . '</div>';
            }
            $count = count($this->_data);
            $output .= '<div class="table-responsive"><table class="table table-hover table-striped">';
            if ($this->_display_header()) {
                $output .= '<thead>';
                $header = '			<tr class="navbar-inner">';
                $i = 0;
                foreach ($this->_columns as $th) {
                    $width = isset($th['size']) ? $th['size'] : FALSE;
                    $class = array();
                    $sort = '';
                    if ($width === TRUE) {
                        $class[] = 'action';
                    }
                    if (!empty($this->_data) && isset($th['sort'])) {
                        $class[] = 'sort';
                        $sort = ' data-column="' . ($i + 1) . '"';
                        if (isset($this->_sortings[$i]) && $this->_sortings[$i][0] == SORT_ASC) {
                            $class[] = 'sorting_asc';
                            $sort .= ' data-order-by="desc"';
                        } else {
                            if (isset($this->_sortings[$i]) && $this->_sortings[$i][0] == SORT_DESC) {
                                $class[] = 'sorting_desc';
                                $sort .= ' data-order-by="none"';
                            } else {
                                $class[] = 'sorting';
                                $sort .= ' data-order-by="asc"';
                            }
                        }
                    }
                    $header .= '		<th' . (!empty($class) ? ' class="' . implode(' ', $class) . '"' : '') . (!is_bool($width) ? ' style="width: ' . $width . ';"' : '') . (!empty($sort) ? $sort : '') . '>' . (!empty($th['title']) ? $th['title'] : '') . '</th>';
                    $i++;
                }
                $header .= '		</tr>';
                $output .= $header . '
								</thead>';
            }
            $output .= '	<tbody>';
            foreach ($this->_data as $data_id => $data) {
                $data = array_merge(array('data_id' => $data_id), $data);
                $output .= '<tr>';
                foreach ($this->_columns as $value) {
                    if (is_array($value['content'])) {
                        $actions = array();
                        foreach ($value['content'] as $val) {
                            $actions[] = $this->template->parse($val, $data, $this->load);
                        }
                        $output .= '<td class="action">' . implode('&nbsp;', array_filter($actions)) . '</td>';
                    } else {
                        $content = $this->template->parse($value['content'], $data, $this->load);
                        if (!isset($value['td']) || $value['td']) {
                            $classes = array();
                            if (isset($value['size']) && $value['size'] === TRUE) {
                                $classes[] = 'action';
                            }
                            if (!empty($value['class'])) {
                                $classes[] = $value['class'];
                            }
                            if (!empty($value['align']) && in_array($value['align'], array('left', 'center', 'right'))) {
                                $classes[] = 'text-' . $value['align'];
                            }
                            $content = '<td' . (!empty($classes) ? ' class="' . implode(' ', $classes) . '"' : '') . '>' . $content . '</td>';
                        }
                        $output .= $content;
                    }
                }
                $output .= '</tr>';
            }
            $output .= '	</tbody>';
            if ($this->_pagination && !empty($this->pagination) && $this->pagination->get_items_per_page() >= 50 && $count >= 50) {
                $output .= '<tfoot>' . $header . '</tfoot>';
            }
            $output .= '</table></div>';
            if (!empty($pagination)) {
                $output .= '<div class="pull-right">' . $pagination . '</div>';
            }
            $output .= '<i>' . NeoFrag::loader()->lang('results', $count, $count) . ($count < $count_results ? NeoFrag::loader()->lang('results_total', $count_results) : '') . '</i>';
            if (!$this->_ajax) {
                $output = '<div class="table-area" data-table-id="' . $this->id . '"' . ($this->config->ajax_url ? ' data-ajax-url="' . url($this->config->request_url) . '"  data-ajax-post="' . http_build_query(post()) . '"' : '') . '>' . (isset($search_input) ? $search_input : '') . '<div class="table-content">' . $output . '</div></div>';
            }
        }
        $this->reset();
        if ($this->_ajax) {
            $this->session->save();
            echo $output;
            return '';
        } else {
            return $output;
        }
    }
Exemple #4
0
function path($file, $file_type = '', $paths = array())
{
    if (func_num_args() == 1) {
        static $paths = array();
        if (!isset($paths[$file])) {
            $paths[$file] = NeoFrag::loader()->db->select('path')->from('nf_files')->where('file_id', $file)->row();
        }
        return $paths[$file] ? url($paths[$file]) : '';
    } else {
        if (is_valid_url($file)) {
            return $file;
        }
        if (!$paths) {
            $paths = NeoFrag::loader()->load->paths['assets'];
        }
        if (!in_array($file_type, array('images', 'css', 'js'))) {
            NeoFrag::loader()->profiler->log(NeoFrag::loader()->lang('invalide_filetype'), Profiler::WARNING);
            return url($file_type . '/' . $file);
        }
        //json_encode backslashe les /
        $file = str_replace('\\/', '/', $file);
        static $assets;
        if (!isset($assets[$checksum = md5(serialize($paths))][$file_type][$file])) {
            foreach ($paths as $path) {
                if (file_exists($file_path = $path . '/' . $file_type . '/' . $file)) {
                    return $assets[$checksum][$file_type][$file] = url(trim_word($file_path, './'));
                }
            }
        } else {
            return $assets[$checksum][$file_type][$file];
        }
        if (file_exists($file)) {
            return url($file);
        }
        return url($file_type . '/' . $file);
    }
}
Exemple #5
0
 public function index($search = '', $module_name = '', $page = '')
 {
     $this->title('Rechercher');
     $this->load->library('form')->add_rules(array('keywords' => array('type' => 'text', 'rules' => 'required')));
     if ($keywords = post('keywords')) {
         redirect('search/' . rawurlencode($keywords) . '.html');
     } else {
         if ($search) {
             $value = $search;
         } else {
             $value = '';
         }
     }
     if ($value) {
         $keywords = $not_keywords = array();
         $results = array();
         $count = 0;
         foreach (array_map($trim = create_function('$a', 'return trim($a, \';,."\\\'\');'), preg_split('/[\\s;,.]*(-?"[^"]+")[\\s;,.]*|[\\s;,.]*(-?\'[^\']+\')[\\s;,.]*|[\\s;,.]+/', $value, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)) as $keyword) {
             if (substr($keyword, 0, 1) == '-') {
                 $not_keywords[] = call_user_func($trim, substr($keyword, 1));
             } else {
                 $keywords[] = call_user_func($trim, $keyword);
             }
         }
         $keywords = array_filter($keywords);
         $not_keywords = array_filter($not_keywords);
         if ($keywords) {
             foreach ($this->get_modules() as $module) {
                 if (($search_controller = $module->load->controller('search')) && ($result = $search_controller->search($keywords, $not_keywords))) {
                     $results[$module->load->template->parse($search_controller->name, array(), $module->load)] = array($module, $search_controller, $result);
                     $count += count($result);
                 }
             }
         }
         ksort($results);
         if ($count == 0) {
             echo $this->load->view('unfound');
         } else {
             if ($count == 1) {
                 $this->add_data('search_count', '1 résultat trouvé');
             } else {
                 $this->add_data('search_count', $count . ' résultats trouvés');
             }
             if (1 || count($results) > 1) {
                 $modules = array();
                 foreach ($results as $title => $result) {
                     if (($name = url_title($result[0]->name)) == $module_name) {
                         $display = $result[0]->load->template->parse($result[1]->method('detail', array($result[2])), array(), $result[0]->load);
                         $details = TRUE;
                     } else {
                         if (!$module_name) {
                             $display = $result[0]->load->template->parse($result[1]->method('index', array($result[2])), array(), $result[0]->load);
                         } else {
                             $display = '';
                         }
                     }
                     $modules[] = array('name' => $name, 'title' => $title . ' (' . count($result[2]) . ')', 'display' => $display);
                 }
                 echo $this->load->view('results', array('search' => rawurlencode($value), 'modules' => $modules, 'details' => isset($details)));
             } else {
             }
         }
     } else {
         $value = '';
         echo $this->load->view('index');
     }
     $source = $this->db->select('CONCAT("\\"", keyword, "\\"")')->from('nf_search_keywords')->order_by('count DESC')->get();
     $this->subtitle($this->load->view('search', array('source' => utf8_htmlentities('[' . trim_word(implode(', ', $source), ', ') . ']'), 'value' => utf8_htmlentities($value))));
 }
Exemple #6
0
    private function _display_text($var, $options, $post, $type = 'text')
    {
        $typeahead = isset($options['values']) && is_array($options['values']) && $options['values'] ? ' data-provide="typeahead" data-source="' . utf8_htmlentities('[' . trim_word(implode(', ', array_map(create_function('$a', 'return \'"\'.$a.\'"\';'), $options['values'])), ', ') . ']') . '"' : '';
        $classes = array();
        if (in_array($type, array('date', 'datetime', 'time'))) {
            $types = array('date' => 'L', 'datetime' => 'L LT', 'time' => 'LT');
            NeoFrag::loader()->css('bootstrap-datetimepicker.min')->js('bootstrap-datetimepicker/moment.min')->js('bootstrap-datetimepicker/bootstrap-datetimepicker.min')->js('bootstrap-datetimepicker/locales/' . $this->config->lang)->js_load('$(".input-group.' . $type . '").datetimepicker({allowInputToggle: true, locale: "' . $this->config->lang . '", format: "' . $types[$type] . '"});');
            $classes[] = $type;
            if (empty($options['icon'])) {
                $options['icon'] = $type == 'time' ? 'fa-clock-o' : 'fa-calendar';
            }
            $type = 'text';
        } else {
            if ($type == 'email') {
                $type = 'text';
                if (empty($options['icon'])) {
                    $options['icon'] = 'fa-envelope-o';
                }
            } else {
                if ($type == 'url') {
                    $type = 'text';
                    if (empty($options['icon'])) {
                        $options['icon'] = 'fa-globe';
                    }
                } else {
                    if ($type == 'colorpicker') {
                        $type = 'text';
                        $classes[] = 'color';
                        $options['icon'] = FALSE;
                        NeoFrag::loader()->css('bootstrap-colorpicker.min')->js('bootstrap-colorpicker.min')->js_load('$(".input-group.color").colorpicker({format: "hex", component: ".input-group-addon,input", colorSelectors: ' . json_encode(get_colors()) . '});');
                    }
                }
            }
        }
        $output = '';
        if (isset($options['icon'])) {
            $output .= '<div class="input-group' . (!empty($classes) ? ' ' . implode(' ', $classes) : '') . '">
				<span class="input-group-addon">' . ($options['icon'] ? icon($options['icon']) : '<i></i>') . '</span>';
        }
        if ($type != 'file') {
            $class = ' class="form-control"';
            $value = ' value="' . addcslashes($this->_display_value($var, $options), '"') . '"';
        }
        $input = '<input id="form_' . $this->id . '_' . $var . '" name="' . $this->id . '[' . $var . ']" type="' . $type . '"' . (!empty($value) ? $value : '') . $typeahead . (!empty($class) ? $class : '') . (($type == 'password' || $typeahead) && isset($options['autocomplete']) && $options['autocomplete'] === FALSE ? ' autocomplete="off"' : '') . (!empty($options['rules']) && in_array('disabled', $options['rules']) ? ' disabled="disabled"' : '') . ($this->_fast_mode && !empty($options['label']) && $type != 'file' ? ' placeholder="' . $this->load->lang($options['label'], NULL) . '"' : '') . ' />';
        if ($type == 'file') {
            $post = post();
            $input = '<div style="margin: 7px 0;"><p>' . icon('fa-download') . ' ' . NeoFrag::loader()->lang('upload_file') . (!empty($options['info']) ? $options['info'] : '') . '</p>' . $input . '</div>';
            if (!empty($options['value'])) {
                if (isset($post[$this->id][$var]) && $post[$this->id][$var] == 'delete') {
                    $input = '<input type="hidden" name="' . $this->id . '[' . $var . ']" value="delete" />' . $input;
                } else {
                    $input = '	<div class="row">
									<div class="col-md-3">
										<div class="thumbnail no-margin">
											<img src="' . url($this->db->select('path')->from('nf_files')->where('file_id', $options['value'])->row()) . '" alt="" />
											<div class="caption text-center">
												<a class="btn btn-outline btn-danger btn-xs form-file-delete" href="#" data-input="' . $this->id . '[' . $var . ']">' . icon('fa-trash-o') . ' ' . NeoFrag::loader()->lang('remove') . '</a>
											</div>
										</div>
									</div>
									<div class="col-md-9">
										' . $input . '
									</div>
								</div>';
                }
            }
        }
        $output .= $input;
        if (isset($options['icon'])) {
            if (in_array('color', $classes)) {
                $output .= '<span class="input-group-addon"><span class="fa fa-eyedropper"></span></span>';
            }
            $output .= '</div>';
        }
        return $output;
    }
Exemple #7
0
        <article class="post-item tour-rating clearfix">
            <div class="thumb">
                <a href="{{route('post.show', [$plang->slug, $value->id])}}">
                    <img alt="{{$plang->name}}" src="{{get_image_url($value->image, 'small')}}">
                </a>
            </div>
            <div class="entry-content">
                <div class="entry-title">
                    <h3><a href="{{route('post.show', [$plang->slug, $value->id])}}">{{$plang->name}}</a></h3>
                </div>
                <div class="description">
                    <?php 
$length = get_setting('news_widget_length');
?>
                    <?php 
echo trim_word($plang->excerpt, $length ? $length : 20);
?>
                </div>
            </div>
        </article>
        @endforeach
    </div>
</div>
@endif
@if(count($all_banner)> 0)
<div class="widget widget-banner">
    @if ($widget_title = get_setting('banner_widget_title'))
    <div class="widget-title">
        <h3 class="label-cat">{{$widget_title}}</h3>
    </div>
    @endif
Exemple #8
0
 public function where($name, $value = NULL, $operator = 'AND')
 {
     if (func_num_args() > 3 && in_array(func_num_args() % 3, array(0, 2))) {
         $args = array();
         foreach (func_get_args() as $i => $arg) {
             if ($i % 3 == 0) {
                 $args[] = array($arg);
             } else {
                 $args[array_last_key($args)][] = $arg;
             }
         }
         $this->_request['where'] .= '(';
         foreach ($args as $arg) {
             call_user_func_array(array($this, 'where'), $arg);
         }
         $this->_request['where'] = trim_word($this->_request['where'], ' AND ', ' OR ') . ') AND ';
         return $this;
     }
     if (is_array($value)) {
         $where = $name . ' IN (' . trim_word(implode(', ', array_map(array($this->_driver, 'escape_string'), $value)), ', ') . ') ' . $operator . ' ';
         if (isset($this->_request['where'])) {
             $this->_request['where'] .= $where;
         } else {
             $this->_request['where'] = $where;
         }
         return $this;
     } else {
         $where = $name;
         if (func_num_args() > 1) {
             if (preg_match('/^(.+?) FIND_IN_SET$/', $name, $match)) {
                 $where = 'FIND_IN_SET(' . $this->_driver->escape_string($value) . ', ' . $match[1] . ')';
             } else {
                 if ($value === NULL) {
                     $where .= ' IS ';
                 } else {
                     if (preg_match('/^(.+?) (!=|<>|<|>|<=|>=|=|LIKE)?$/', $name)) {
                         $where .= ' ';
                     } else {
                         $where .= ' = ';
                     }
                 }
                 $where .= $this->_driver->escape_string($value);
             }
         }
         $where .= ' ' . $operator . ' ';
         if (isset($this->_request['where'])) {
             $this->_request['where'] .= $where;
         } else {
             $this->_request['where'] = $where;
         }
         return $this;
     }
 }