Beispiel #1
1
 /**
  * displays the topics on a forums
  * @return [type] [description]
  */
 public function action_list()
 {
     //in case performing a search
     if (strlen($search = core::get('search')) >= 3) {
         return $this->action_search($search);
     }
     $this->template->styles = array('css/forums.css' => 'screen');
     $this->template->scripts['footer'][] = 'js/forums.js';
     $forum = new Model_Forum();
     $forum->where('seoname', '=', $this->request->param('forum', NULL))->cached()->limit(1)->find();
     if ($forum->loaded()) {
         //template header
         $this->template->title = $forum->name . ' - ' . __('Forum');
         $this->template->meta_description = $forum->description;
         Breadcrumbs::add(Breadcrumb::factory()->set_title($forum->name));
         //count all topics
         $count = DB::select(array(DB::expr('COUNT("id_post")'), 'count'))->from(array('posts', 'p'))->where('id_post_parent', 'IS', NULL)->where('id_forum', '=', $forum->id_forum)->cached()->execute();
         $count = array_keys($count->as_array('count'));
         $pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => isset($count[0]) ? $count[0] : 0))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action(), 'forum' => $this->request->param('forum')));
         $pagination->title($this->template->title);
         //getting all the topic for the forum
         $topics = DB::select('p.*')->select(array(DB::select(DB::expr('COUNT("id_post")'))->from(array('posts', 'pc'))->where('pc.id_post_parent', '=', DB::expr(Database::instance('default')->table_prefix() . 'p.id_post'))->where('pc.id_forum', '=', $forum->id_forum)->where('pc.status', '=', Model_Post::STATUS_ACTIVE)->group_by('pc.id_post_parent'), 'count_replies'))->select(array(DB::select('ps.created')->from(array('posts', 'ps'))->where('ps.id_post', '=', DB::expr(Database::instance('default')->table_prefix() . 'p.id_post'))->or_where('ps.id_post_parent', '=', DB::expr(Database::instance('default')->table_prefix() . 'p.id_post'))->where('ps.id_forum', '=', $forum->id_forum)->where('ps.status', '=', Model_Post::STATUS_ACTIVE)->order_by('ps.created', 'DESC')->limit(1), 'last_message'))->from(array('posts', 'p'))->where('id_post_parent', 'IS', NULL)->where('id_forum', '=', $forum->id_forum)->where('status', '=', Model_Post::STATUS_ACTIVE)->order_by('last_message', 'DESC')->limit($pagination->items_per_page)->offset($pagination->offset)->as_object()->execute();
         $pagination = $pagination->render();
         $this->template->bind('content', $content);
         $this->template->content = View::factory('pages/forum/list', array('topics' => $topics, 'forum' => $forum, 'pagination' => $pagination));
     } else {
         //throw 404
         throw HTTP_Exception::factory(404, __('Page not found'));
     }
 }
Beispiel #2
0
 /**
  * List all Advertisements (PUBLISHED)
  */
 public function action_index()
 {
     //template header
     $this->template->title = __('Advertisements');
     $this->template->meta_description = __('Advertisements');
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('List')));
     $this->template->scripts['footer'][] = 'js/jquery.toolbar.js';
     $this->template->scripts['footer'][] = 'js/oc-panel/moderation.js';
     $ads = new Model_Ad();
     $fields = array('title', 'id_ad', 'published', 'created', 'id_category', 'id_location', 'status');
     //filter ads by status
     $status = is_numeric(Core::get('status')) ? Core::get('status') : Model_Ad::STATUS_PUBLISHED;
     $ads = $ads->where('status', '=', $status);
     // sort ads by search value
     if ($q = $this->request->query('search')) {
         $ads = $ads->where('title', 'like', '%' . $q . '%');
         if (core::config('general.search_by_description') == TRUE) {
             $ads = $ads->or_where('description', 'like', '%' . $q . '%');
         }
     }
     $ads_count = clone $ads;
     $res_count = $ads_count->count_all();
     if ($res_count > 0) {
         $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $res_count, 'items_per_page' => 50))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
         $ads = $ads->order_by(core::get('order', 'published'), core::get('sort', 'desc'))->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
         $this->template->content = View::factory('oc-panel/pages/ad', array('res' => $ads, 'pagination' => $pagination, 'fields' => $fields));
     } else {
         $this->template->content = View::factory('oc-panel/pages/ad', array('res' => NULL, 'fields' => $fields));
     }
 }
Beispiel #3
0
 public function action_index()
 {
     //if they want to see a single post
     $seotitle = $this->request->param('seotitle', NULL);
     if ($seotitle !== NULL) {
         return $this->action_view($seotitle);
     }
     //in case performing a search
     $search = core::get('search');
     if (strlen($search) >= 3) {
         return $this->action_search($search);
     }
     //template header
     $this->template->title = __(' Frequently Asked Questions - FAQ');
     $this->template->meta_description = core::config('general.site_name') . ' ' . __('frequently asked questions.');
     $this->template->styles = array('css/faq.css' => 'screen');
     $this->template->scripts['footer'] = array('js/faq.js');
     //FAQ CMS
     $faqs = new Model_Content();
     $faqs = $faqs->where('type', '=', 'help')->where('status', '=', '1')->order_by('order', 'asc')->find_all();
     $this->template->bind('content', $content);
     if (strlen(core::config('general.faq_disqus')) > 0) {
         $disqus = View::factory('pages/disqus', array('disqus' => core::config('general.faq_disqus')));
     } else {
         $disqus = '';
     }
     $this->template->content = View::factory('pages/faq/listing', array('faqs' => $faqs, 'disqus' => $disqus));
 }
 /**
  * saves the forum in a specific order and change the parent
  * @return void 
  */
 public function action_saveorder()
 {
     $this->auto_render = FALSE;
     $this->template = View::factory('js');
     $forum = new Model_Forum(core::get('id_forum'));
     if ($forum->loaded()) {
         //saves the current forum
         $forum->id_forum_parent = core::get('id_forum_parent');
         $forum->parent_deep = core::get('deep');
         //saves the forums in the same parent the new orders
         $order = 0;
         foreach (core::get('brothers') as $id_forum) {
             $id_forum = substr($id_forum, 3);
             //removing the li_ to get the integer
             //not the main forum so loading and saving
             if ($id_forum != core::get('id_forum')) {
                 $c = new Model_Forum($id_forum);
                 $c->order = $order;
                 $c->save();
             } else {
                 //saves the main forum
                 $forum->order = $order;
                 $forum->save();
             }
             $order++;
         }
         Core::delete_cache();
         $this->template->content = __('Saved');
     } else {
         $this->template->content = __('Error');
     }
 }
Beispiel #5
0
 /**
  * saves the location in a specific order and change the parent
  * @return void 
  */
 public function action_saveorder()
 {
     $this->auto_render = FALSE;
     $this->template = View::factory('js');
     $loc = new Model_Location(core::get('id_location'));
     if ($loc->loaded()) {
         //saves the current location
         $loc->id_location_parent = core::get('id_location_parent');
         $loc->parent_deep = core::get('deep');
         //saves the categories in the same parent the new orders
         $order = 0;
         foreach (core::get('brothers') as $id_loc) {
             $id_loc = substr($id_loc, 3);
             //removing the li_ to get the integer
             //not the main location so loading and saving
             if ($id_loc != core::get('id_location')) {
                 $c = new Model_Location($id_loc);
                 $c->order = $order;
                 $c->save();
             } else {
                 //saves the main location
                 $loc->order = $order;
                 $loc->save();
             }
             $order++;
         }
         $this->template->content = __('Saved');
     } else {
         $this->template->content = __('Error');
     }
 }
Beispiel #6
0
function lili($item, $key, $cats)
{
    ?>
                <option value="<?php 
    echo $cats[$key]['seoname'];
    ?>
" <?php 
    echo core::get('category') == $cats[$key]['seoname'] ? 'selected' : '';
    ?>
 >
                    <?php 
    echo $cats[$key]['name'];
    ?>
</option>
                    <?php 
    if (count($item) > 0) {
        ?>
                    <optgroup label="<?php 
        echo HTML::chars($cats[$key]['name']);
        ?>
">    
                        <?php 
        if (is_array($item)) {
            array_walk($item, 'lili', $cats);
        }
        ?>
                    <?php 
    }
    ?>
                <?php 
}
 /**
  *
  * Loads a basic list info
  * @param string $view template to render 
  */
 public function action_index($view = NULL)
 {
     $this->template->title = __('Coupons');
     $this->template->scripts['footer'][] = 'js/oc-panel/coupon.js';
     $elements = new Model_Coupon();
     if (core::get('name') !== NULL) {
         $elements = $elements->where('name', '=', core::get('name'));
     }
     $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $elements->count_all()))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
     $pagination->title($this->template->title);
     $elements = $elements->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
     $pagination = $pagination->render();
     $this->render('oc-panel/pages/coupon/index', array('elements' => $elements, 'pagination' => $pagination));
 }
Beispiel #8
0
 public function action_index()
 {
     $messages = Model_Message::get_threads($this->user, core::get('status'));
     $res_count = $messages->count_all();
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Messaging'))->set_url(Route::url('oc-panel', array('controller' => 'messages', 'action' => 'index'))));
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Inbox')));
     Controller::$full_width = TRUE;
     if ($res_count > 0) {
         $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $res_count, 'items_per_page' => core::config('advertisement.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
         Breadcrumbs::add(Breadcrumb::factory()->set_title(sprintf(__("Page %d"), $pagination->current_page)));
         $messages = $messages->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
         $this->template->styles = array('css/jquery.sceditor.default.theme.min.css' => 'screen');
         $this->template->scripts['footer'] = array('js/jquery.sceditor.bbcode.min.js', 'js/messages.js');
         $this->template->content = View::factory('oc-panel/pages/messages/index', array('messages' => $messages, 'pagination' => $pagination, 'user' => $this->user));
     } else {
         $this->template->content = View::factory('oc-panel/pages/messages/index', array('messages' => NULL, 'pagination' => NULL, 'user' => $this->user));
     }
 }
Beispiel #9
0
 /**
  * Initialize properties before running the controller methods (actions),
  * so they are available to our action.
  * @param  string $template view to use as template
  * @return void           
  */
 public function before($template = NULL)
 {
     Theme::checker();
     $this->maintenance();
     //Gets a coupon if selected
     Model_Coupon::current();
     if ($this->auto_render === TRUE) {
         // Load the template
         $this->template = $template === NULL ? 'oc-panel/main' : $template;
         //if its and ajx request I want only the content
         if (Core::get('rel') == 'ajax') {
             $this->template = 'oc-panel/content';
         }
         $this->template = View::factory($this->template);
         // Initialize empty values
         $this->template->title = __('Panel') . ' - ' . core::config('general.site_name');
         $this->template->meta_keywords = '';
         $this->template->meta_description = '';
         $this->template->meta_copyright = 'Open eShop ' . Core::VERSION;
         $this->template->header = '';
         $this->template->content = '';
         $this->template->footer = '';
         $this->template->styles = array();
         $this->template->scripts = array();
         $this->template->user = Auth::instance()->get_user();
         //non ajax request
         if (Core::get('rel') != 'ajax') {
             if (core::get('print') == 1) {
                 $this->template->header = '';
                 $this->template->footer = '';
             } else {
                 $this->template->header = View::factory('oc-panel/header');
                 $this->template->footer = View::factory('oc-panel/footer');
             }
             //other color
             if (Theme::get('admin_theme') == 'bootstrap') {
                 Theme::$styles = array('//cdn.jsdelivr.net/bootswatch/3.3.6/paper/bootstrap.min.css' => 'screen', '//cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css?v=print' => 'print', '//cdn.jsdelivr.net/chosen/1.0.0/chosen.css' => 'screen', '//cdn.jsdelivr.net/bootstrap.tagsinput/0.3.9/bootstrap-tagsinput.css' => 'screen', '//cdn.jsdelivr.net/sweetalert/1.1.3/sweetalert.css' => 'screen', 'css/jquery.sceditor.default.theme.min.css' => 'screen', 'css/loadingbar.css' => 'screen', 'css/icon-picker.min.css' => 'screen', 'css/font-awesome.min.css' => 'screen', 'css/summernote.css' => 'screen', 'css/admin-styles.css?v=' . Core::VERSION => 'screen');
             } else {
                 Theme::$styles = array('//cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css' => 'screen', '//cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css?v=print' => 'print', '//cdn.jsdelivr.net/bootswatch/3.3.6/' . Theme::get('admin_theme', 'cerulean') . '/bootstrap.min.css' => 'screen', '//cdn.jsdelivr.net/chosen/1.0.0/chosen.css' => 'screen', '//cdn.jsdelivr.net/bootstrap.tagsinput/0.3.9/bootstrap-tagsinput.css' => 'screen', '//cdn.jsdelivr.net/sweetalert/1.1.3/sweetalert.css' => 'screen', 'css/jquery.sceditor.default.theme.min.css' => 'screen', 'css/loadingbar.css' => 'screen', 'css/icon-picker.min.css' => 'screen', 'css/font-awesome.min.css' => 'screen', 'css/summernote.css' => 'screen', 'css/admin-styles.css?v=' . Core::VERSION => 'screen');
             }
             Theme::$scripts['footer'] = array('//code.jquery.com/jquery-1.10.2.min.js', '//cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js', '//cdn.jsdelivr.net/chosen/1.0.0/chosen.jquery.min.js', Route::url('jslocalization', array('controller' => 'jslocalization', 'action' => 'chosen')), (Kohana::$environment !== Kohana::DEVELOPMENT ? 'market.' . Core::DOMAIN . '' : 'eshop.lo') . '/embed.js', 'js/oc-panel/theme.init.js?v=' . Core::VERSION, 'js/jquery.sceditor.bbcode.min.js', 'js/summernote.min.js', 'js/summernote-ext-video.js', 'js/jquery.validate.min.js', Route::url('jslocalization', array('controller' => 'jslocalization', 'action' => 'validate')), 'js/jquery.cookie.min.js', 'js/iconPicker.min.js', 'js/oc-panel/sidebar.js?v=' . Core::VERSION, '//cdn.jsdelivr.net/bootstrap.tagsinput/0.3.9/bootstrap-tagsinput.min.js', '//cdn.jsdelivr.net/sweetalert/1.1.3/sweetalert.min.js', 'js/jquery.bootgrid.min.js', 'js/query.bootgrid.fa.min.js', 'js/form.js?v=' . Core::VERSION);
         }
     }
 }
Beispiel #10
0
 /**
  *
  * Loads a basic list info
  * @param string $view template to render 
  */
 public function action_index($view = NULL)
 {
     $this->template->title = __('Reviews');
     $this->template->scripts['footer'][] = 'js/oc-panel/crud/index.js';
     $reviews = new Model_Review();
     //$reviews = $reviews->where('status', '=', Model_Review::STATUS_ACTIVE);
     if (core::get('email') !== NULL) {
         $user = new Model_User();
         $user->where('email', '=', core::get('email'))->limit(1)->find();
         if ($user->loaded()) {
             $reviews = $reviews->where('id_user', '=', $user->id_user);
         }
     }
     $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $reviews->count_all()))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
     $pagination->title($this->template->title);
     $reviews = $reviews->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
     $pagination = $pagination->render();
     $this->render('oc-panel/pages/review/index', array('reviews' => $reviews, 'pagination' => $pagination));
 }
Beispiel #11
0
 /**
  *
  * Loads a basic list info
  * @param string $view template to render 
  */
 public function action_index($view = NULL)
 {
     $this->template->title = __('Affiliates Commissions');
     $this->template->scripts['footer'][] = 'js/oc-panel/crud/index.js';
     $commissions = new Model_Affiliate();
     //filter by email
     if (core::get('email') !== NULL) {
         $user = new Model_User();
         $user->where('email', '=', core::get('email'))->limit(1)->find();
         if ($user->loaded()) {
             $commissions = $commissions->where('id_user', '=', $user->id_user);
         }
     }
     $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $commissions->count_all()))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
     $pagination->title($this->template->title);
     $commissions = $commissions->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
     $pagination = $pagination->render();
     $this->render('oc-panel/pages/affiliate/index', array('commissions' => $commissions, 'pagination' => $pagination));
 }
Beispiel #12
0
 /**
  *
  * Loads a basic list info
  * @param string $view template to render 
  */
 public function action_index($view = NULL)
 {
     $this->template->title = __($this->_orm_model);
     $this->template->scripts['footer'][] = 'js/oc-panel/crud/index.js';
     $elements = ORM::Factory($this->_orm_model);
     //->find_all();
     //email search
     if (Valid::email(core::get('email'))) {
         $users = new Model_User();
         $users->where('email', '=', core::get('email'))->limit(1)->find();
         if ($users->loaded()) {
             $elements->where('id_user', '=', $users->id_user);
         }
     }
     $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $elements->count_all()))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
     $pagination->title($this->template->title);
     $elements = $elements->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
     $pagination = $pagination->render();
     $this->render('oc-panel/pages/download/index', array('elements' => $elements, 'pagination' => $pagination));
 }
Beispiel #13
0
 public function action_index()
 {
     require_once Kohana::find_file('vendor', 'php-googlemap/GoogleMap', 'php');
     $this->before('/pages/maps');
     $this->template->title = __('Map');
     $height = Core::get('height', '100%');
     $width = Core::get('width', '100%');
     $map = new GoogleMapAPI();
     $map->setWidth($width);
     $map->setHeight($height);
     $map->disableSidebar();
     $map->setMapType('map');
     $map->setZoomLevel(Core::get('zoom', core::config('advertisement.map_zoom')));
     //$map->mobile = TRUE;
     $atributes = array("target='_blank'");
     if (core::get('controls') == 0) {
         $map->disableMapControls();
         $map->disableTypeControls();
         $map->disableScaleControl();
         $map->disableZoomEncompass();
         $map->disableStreetViewControls();
         $map->disableOverviewControl();
     }
     //only 1 marker
     if (core::get('address') != '') {
         $map->addMarkerByAddress(core::get('address'), core::get('address'));
     } else {
         //last ads, you can modify this value at: general.feed_elements
         $ads = DB::select('a.seotitle')->select(array('c.seoname', 'category'), 'a.title', 'a.published', 'a.address')->from(array('ads', 'a'))->join(array('categories', 'c'), 'INNER')->on('a.id_category', '=', 'c.id_category')->where('a.status', '=', Model_Ad::STATUS_PUBLISHED)->where('a.address', 'IS NOT', NULL)->order_by('published', 'desc')->limit(Core::config('general.map_elements'))->as_object()->cached()->execute();
         foreach ($ads as $a) {
             //d($a);
             if (strlen($a->address) > 3) {
                 $url = Route::url('ad', array('category' => $a->category, 'seotitle' => $a->seotitle));
                 $map->addMarkerByAddress($a->address, $a->title, HTML::anchor($url, $a->title, $atributes));
             }
         }
         //only center if not a single ad
         $map->setCenterCoords(Core::get('lon', core::config('advertisement.center_lon')), Core::get('lat', core::config('advertisement.center_lat')));
     }
     $this->template->map = $map;
 }
 /**
  * simple registration without password
  * @return [type] [description]
  */
 public function action_register()
 {
     $provider_name = $this->request->param('id');
     $this->template->content = View::factory('pages/auth/register-social', array('provider' => $provider_name, 'uid' => core::get('uid'), 'name' => core::get('name')));
     if (core::post('email') and CSRF::valid('register_social')) {
         $email = core::post('email');
         if (Valid::email($email, TRUE)) {
             //register the user in DB
             Model_User::create_social($email, core::post('name'), $provider_name, core::get('uid'));
             //log him in
             Auth::instance()->social_login($provider_name, core::get('uid'));
             Alert::set(Alert::SUCCESS, __('Welcome!'));
             //change the redirect
             $this->redirect(Route::url('default'));
         } else {
             Form::set_errors(array(__('Invalid Email')));
         }
     }
     //template header
     $this->template->title = __('Register new user');
 }
Beispiel #15
0
 /**
  * shortcut to get or post
  * @param  [type] $key     [description]
  * @param  [type] $default [description]
  * @return [type]          [description]
  */
 public static function request($key, $default = NULL)
 {
     return core::post($key) !== NULL ? core::post($key) : core::get($key, $default);
 }
Beispiel #16
0
 /**
  * saves the location in a specific order and change the parent
  * @return void 
  */
 public function action_saveorder()
 {
     $this->auto_render = FALSE;
     $this->template = View::factory('js');
     $loc = new Model_Location(core::get('id_location'));
     //check if the parent is loaded/exists avoiding errors
     $parent_loc = new Model_Location(core::get('id_location_parent'));
     if ($loc->loaded() and $parent_loc->loaded()) {
         //saves the current location
         $loc->id_location_parent = core::get('id_location_parent');
         $loc->parent_deep = core::get('deep');
         //saves the locations in the same parent the new orders
         $order = 0;
         foreach (core::get('brothers') as $id_loc) {
             $id_loc = substr($id_loc, 3);
             //removing the li_ to get the integer
             //not the main location so loading and saving
             if ($id_loc != core::get('id_location')) {
                 $c = new Model_Location($id_loc);
                 $c->parent_deep = core::get('deep');
                 $c->order = $order;
                 try {
                     $c->save();
                 } catch (Exception $e) {
                     Kohana::$log->add(Log::ERROR, 'Controller Location saveorder id_location: ' . $c->id_location . '- URL:' . URL::current());
                 }
             } else {
                 //saves the main location
                 $loc->order = $order;
                 try {
                     $loc->save();
                 } catch (Exception $e) {
                     Kohana::$log->add(Log::ERROR, 'Controller Location saveorder id_location: ' . $loc->id_location . '- URL:' . URL::current());
                 }
             }
             $order++;
         }
         //update deep for all the locations
         $this->action_deep();
         Core::delete_cache();
         $this->template->content = __('Saved');
     } else {
         $this->template->content = __('Error');
     }
 }
Beispiel #17
0
        <a href="?status=<?php 
echo Model_Message::STATUS_ARCHIVED;
?>
" class="btn <?php 
echo core::get('status', -1) == Model_Message::STATUS_ARCHIVED ? 'btn-primary' : 'btn-default';
?>
">
            <span class="glyphicon glyphicon-folder-close" aria-hidden="true"></span> <?php 
echo _e('Archieved');
?>
        </a>
        <a href="?status=<?php 
echo Model_Message::STATUS_SPAM;
?>
" class="btn <?php 
echo core::get('status', -1) == Model_Message::STATUS_SPAM ? 'btn-primary' : 'btn-default';
?>
">
            <span class="glyphicon glyphicon-fire" aria-hidden="true"></span> <?php 
echo _e('Spam');
?>
        </a>
    </div>
</div>
<br>
<div class="panel">
    <?php 
if (count($messages) > 0) {
    ?>
        <br>
        <table class="table table-striped">
Beispiel #18
0
        position: relative;
        right: -20px;
        top: 0px;
      }
      .close:after {
        content: '✖';
      }
    </style>
</head>

<body style="<?php 
echo core::get('controls') != 0 ? 'padding:0 20px 20px;' : 'margin:0;';
?>
">
    <?php 
if (core::get('controls') != 0) {
    ?>
        <div>
          <button class="close" onclick="window.history.back();">
            <span>&nbsp;</span>
          </button>
        </div>
    <?php 
}
?>
    <div id="gmap" style="height:<?php 
echo $height;
?>
;width:<?php 
echo $width;
?>
Beispiel #19
0
 public function action_logs()
 {
     $this->template->title = __('System logs');
     Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
     //local files
     if (Theme::get('cdn_files') == FALSE) {
         $this->template->styles = array('css/datepicker.css' => 'screen');
         $this->template->scripts['footer'] = array('js/bootstrap-datepicker.js', 'js/oc-panel/logs.js');
     } else {
         $this->template->styles = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/css/datepicker.css' => 'screen');
         $this->template->scripts['footer'] = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/js/bootstrap-datepicker.js', 'js/oc-panel/logs.js');
     }
     $date = core::get('date', date('Y-m-d'));
     $file = APPPATH . 'logs/' . str_replace('-', '/', $date) . '.php';
     if (file_exists($file)) {
         $log = file_get_contents($file);
     } else {
         $log = NULL;
     }
     $this->template->content = View::factory('oc-panel/pages/tools/logs', array('file' => $file, 'log' => $log, 'date' => $date));
 }
Beispiel #20
0
<?php

defined('SYSPATH') or die('No direct script access.');
?>

<form class="form-inline" method="get" action="<?php 
echo URL::current();
?>
">
  	<div class="form-group pull-right">
  		<div class="">
	      	<input type="text" class="form-control search-query" name="email" placeholder="<?php 
echo __('email');
?>
" value="<?php 
echo core::get('email');
?>
">
		</div>
	</div>
</form>

<div class="page-header">
	<h1><?php 
echo __('Reviews');
?>
</h1>
</div>

<div class="panel panel-default">
    <div class="panel-body">
Beispiel #21
0
				                    <?php 
} else {
    ?>
				                    	<td class="text-center text-danger"><h4><strong><?php 
    echo $order->id_product == Model_Order::PRODUCT_AD_SELL ? i18n::money_format($order->amount, $order->currency) : i18n::format_currency($order->amount, $order->currency);
    ?>
</strong></h4></td>
				                    <?php 
}
?>
								</tr>
			                    <tr>
			                    	<td></td>
			                    	<td class="text-right">
			                    		<?php 
if (!core::get('print')) {
    ?>
				                        	<div class="pull-right">
				                            	<a target="_blank" class="btn btn-xs btn-success" title="<?php 
    echo __('Print this');
    ?>
" href="<?php 
    echo Route::url('oc-panel', array('controller' => 'profile', 'action' => 'order', 'id' => $order->id_order)) . URL::query(array('print' => 1));
    ?>
"><i class="glyphicon glyphicon-print"></i><?php 
    echo __('Print this');
    ?>
</a>
				                        	</div>
				                    <?php 
}
Beispiel #22
0
 public function action_order()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('My Purchases'))->set_url(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders'))));
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Order')));
     $this->template->title = __('View Order');
     $user = Auth::instance()->get_user();
     $id_order = $this->request->param('id');
     $order = new Model_Order();
     $order->where('id_order', '=', $id_order);
     //if admin we do not verify the user
     if ($user->id_role != Model_Role::ROLE_ADMIN) {
         $order->where('id_user', '=', $user->id_user);
     }
     $order->find();
     if (!$order->loaded()) {
         Alert::set(ALERT::WARNING, __('Order could not be loaded'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
     }
     $this->template->bind('content', $content);
     $this->template->content = View::factory('oc-panel/profile/order');
     $content->order = $order;
     $content->product = $order->id_product;
     $content->user = $user;
     if (core::get('print') == 1) {
         $this->template->scripts['footer'] = array('js/oc-panel/order.js');
     }
 }
Beispiel #23
0
 public function action_edit()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit Translation')));
     $this->template->title = __('Edit Translation');
     $this->template->bind('content', $content);
     $content = View::factory('oc-panel/pages/translations/edit');
     $this->template->scripts['footer'][] = 'js/oc-panel/translations.js';
     $language = $this->language_fix($this->request->param('id'));
     //get the translated ad not translated.
     list($translation_array, $untranslated_array) = $this->get_translation($language);
     //watch out at any standard php installation there's a limit of 1000 posts....edit php.ini max_input_vars = 10000 to amend it.
     if ($this->request->post() and is_array(Core::post('translations'))) {
         $data_translated = Core::post('translations');
         if ($this->save_translation($language, $translation_array, $data_translated)) {
             Alert::set(Alert::SUCCESS, $language . ' ' . __('Language saved'));
         } else {
             Alert::set(Alert::ALERT, $language);
         }
         $this->redirect(URL::current());
     }
     //add filters to search
     $translation_array_filtered = $translation_array;
     //only display not translated
     if (core::get('translated') == 1) {
         $translation_array_filtered_aux = array();
         foreach ($untranslated_array as $key => $value) {
             $translation_array_filtered_aux[] = $translation_array_filtered[$value];
         }
         $translation_array_filtered = $translation_array_filtered_aux;
     } elseif (core::get('search') !== NULL) {
         $translation_array_filtered_aux = array();
         foreach ($translation_array as $key => $value) {
             if (strpos($value['original'], core::get('search')) !== FALSE or strpos($value['translated'], core::get('search')) !== FALSE) {
                 $translation_array_filtered_aux[] = $value;
             }
         }
         $translation_array_filtered = $translation_array_filtered_aux;
     }
     //how many translated items we have?
     $total_items = count($translation_array_filtered);
     //get elements for current page
     $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $total_items, 'items_per_page' => 20))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action(), 'id' => $language));
     $trans_array_paginated = array();
     $from = $pagination->offset;
     $to = $from + $pagination->items_per_page;
     for ($key = $from; $key < $to; $key++) {
         if (isset($translation_array_filtered[$key])) {
             $trans_array_paginated[$key] = $translation_array_filtered[$key];
         }
     }
     $content->edit_language = $language;
     $content->translation_array = $trans_array_paginated;
     $content->cont_untranslated = count($untranslated_array);
     $content->total_items = count($translation_array);
     $content->pagination = $pagination->render();
 }
echo FORM::close();
?>
</div>

<?php 
if (Request::current()->query()) {
    ?>
    <?php 
    if (count($ads) > 0) {
        ?>
        <h3>
            <?php 
        if (core::get('title')) {
            ?>
                <?php 
            echo $total_ads == 1 ? sprintf(__('%d advertisement for %s'), $total_ads, core::get('title')) : sprintf(__('%d advertisements for %s'), $total_ads, core::get('title'));
            ?>
            <?php 
        } else {
            ?>
                <?php 
            echo _e('Search results');
            ?>
            <?php 
        }
        ?>
        </h3>
        <?php 
        echo View::factory('pages/ad/listing', array('pagination' => $pagination, 'ads' => $ads, 'category' => NULL, 'location' => NULL, 'user' => $user, 'featured' => NULL));
        ?>
    <?php 
                            <?php 
                if ($field['type'] == 'select' or $field['type'] == 'radio') {
                    $select = array('' => $field['label']);
                    foreach ($field['values'] as $select_name) {
                        $select[$select_name] = $select_name;
                    }
                } else {
                    $select = $field['values'];
                }
                ?>
                            <div class="col-xs-12">
                                <?php 
                echo FORM::label('cf_' . $name, $field['label'], array('for' => 'cf_' . $name));
                ?>
                                <?php 
                echo Form::cf_form_field('cf_' . $name, array('display' => $field['type'], 'label' => $field['label'], 'tooltip' => isset($field['tooltip']) ? $field['tooltip'] : "", 'default' => $field['values'], 'options' => !is_array($field['values']) ? $field['values'] : $select), core::get('cf_' . $name), FALSE, TRUE);
                ?>
 
                            </div>
                        </div>
                    <?php 
            }
            ?>
                <?php 
        }
        ?>
            <?php 
    }
    ?>
            <!-- /endcustom fields -->
        <?php 
 /**
  * saves the category in a specific order and change the parent
  * @return void 
  */
 public function action_saveorder()
 {
     $this->auto_render = FALSE;
     $this->template = View::factory('js');
     $cat = new Model_Category(core::get('id_category'));
     //check if the parent is loaded/exists avoiding errors
     $parent_cat = new Model_Category(core::get('id_category_parent'));
     if ($cat->loaded() and $parent_cat->loaded()) {
         //saves the current category
         $cat->id_category_parent = $parent_cat->id_category;
         $cat->parent_deep = core::get('deep');
         //saves the categories in the same parent the new orders
         $order = 0;
         foreach (core::get('brothers') as $id_cat) {
             $id_cat = substr($id_cat, 3);
             //removing the li_ to get the integer
             //not the main category so loading and saving
             if ($id_cat != core::get('id_category')) {
                 $c = new Model_Category($id_cat);
                 $c->order = $order;
                 $c->save();
             } else {
                 //saves the main category
                 $cat->order = $order;
                 $cat->save();
             }
             $order++;
         }
         //recalculating the deep of all the categories
         $this->action_deep();
         Core::delete_cache();
         $this->template->content = __('Saved');
     } else {
         $this->template->content = __('Error');
     }
 }
Beispiel #27
0
 /**
  * verifies pricing in an existing order
  * @return void
  */
 public function check_pricing()
 {
     //update order based on the price and the amount of
     $days = core::get('featured_days');
     if (is_numeric($days) and ($price = Model_Order::get_featured_price($days)) !== FALSE) {
         $this->amount = $price;
         //get price from config
         $this->featured_days = $days;
         $this->save();
     }
     //original coupon so we dont lose it while we do operations
     $orig_coupon = $this->id_coupon;
     //remove the coupon forced by get/post
     if (core::request('coupon_delete') != NULL) {
         $this->id_coupon = NULL;
     } elseif (Model_Coupon::valid($this->id_product) and $this->id_coupon != Model_Coupon::current()->id_coupon) {
         $this->id_coupon = Model_Coupon::current()->id_coupon;
     } elseif ($this->coupon->loaded() and (Date::mysql2unix($this->coupon->valid_date) < time() or $this->coupon->status == 0 or $this->coupon->number_coupons == 0)) {
         Alert::set(Alert::INFO, __('Coupon not valid, expired or already used.'));
         $this->coupon->clear();
         $this->id_coupon = NULL;
     }
     //add new discount
     $new_amount = Model_Coupon::price($this->id_product, $this->original_price());
     //recalculate price since it change the coupon
     if ($orig_coupon != $this->id_coupon or $this->amount != $new_amount) {
         $this->amount = $new_amount;
         try {
             $this->save();
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
     }
 }
      <?foreach ($ads as $ad):?>
      {       
              lat: <?php 
echo $ad->latitude;
?>
,
              lon: <?php 
echo $ad->longitude;
?>
,
    
              title: '<?php 
echo htmlentities(json_encode($ad->title), ENT_QUOTES);
?>
',
              <?if(( $icon_src = $ad->category->get_icon() )!==FALSE AND !is_numeric(core::get('id_ad'))):?>
                <?if(Kohana::$environment === Kohana::DEVELOPMENT):?>
                    icon: '<?php 
echo $icon_src;
?>
',
                <?else:?>
                    icon: '<?php 
echo Core::is_HTTPS() ? "https://" : "http://";
?>
i0.wp.com/<?php 
echo preg_replace("(^https?://)", "", $icon_src);
echo strpos($icon_src, "?") ? "&" : "?";
?>
fit=50,50',
                <?endif?>
 public function action_advanced_search()
 {
     $this->template->scripts['footer'][] = 'js/jquery.toolbar.js';
     $this->template->scripts['footer'][] = 'js/sort.js';
     //template header
     $this->template->title = __('Advanced Search');
     $this->template->meta_description = __('Search in') . ' ' . core::config('general.site_name');
     //breadcrumbs
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
     Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
     $pagination = NULL;
     $ads = NULL;
     $user = Auth::instance()->get_user() == NULL ? NULL : Auth::instance()->get_user();
     if ($this->request->query()) {
         // variables
         $search_advert = core::get('title');
         $search_loc = core::get('location');
         // filter by each variable
         $ads = new Model_Ad();
         // early filter
         $ads = $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
         //if ad have passed expiration time dont show
         if (core::config('advertisement.expire_date') > 0) {
             $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql());
         }
         if (!empty($search_advert) or core::get('search') !== NULL and strlen(core::get('search')) >= 3) {
             // if user is using search from header
             if (core::get('search')) {
                 $search_advert = core::get('search');
             }
             $ads->where_open()->where('title', 'like', '%' . $search_advert . '%')->or_where('description', 'like', '%' . $search_advert . '%')->where_close();
         }
         $cf_fields = array();
         foreach ($this->request->query() as $name => $field) {
             // get by prefix
             if (strpos($name, 'cf_') !== false) {
                 $cf_fields[$name] = $field;
                 //checkbox when selected return string 'on' as a value
                 if ($field == 'on') {
                     $cf_fields[$name] = 1;
                 } elseif (empty($field)) {
                     $cf_fields[$name] = NULL;
                 }
             }
         }
         $category = NULL;
         $location = NULL;
         if (core::config('general.search_multi_catloc') and Theme::$is_mobile === FALSE) {
             //filter by category
             if (is_array(core::get('category'))) {
                 $cat_siblings_ids = array();
                 foreach (core::get('category') as $cat) {
                     if ($cat !== NULL) {
                         $category = new Model_Category();
                         $category->where('seoname', '=', $cat)->cached()->limit(1)->find();
                         if ($category->loaded()) {
                             $cat_siblings_ids = array_merge($cat_siblings_ids, $category->get_siblings_ids());
                         }
                     }
                 }
                 if (count($cat_siblings_ids) > 0) {
                     $ads->where('id_category', 'IN', $cat_siblings_ids);
                 }
             }
             //filter by location
             if (is_array(core::get('location'))) {
                 $loc_siblings_ids = array();
                 foreach (core::get('location') as $loc) {
                     if ($loc !== NULL) {
                         $location = new Model_location();
                         $location->where('seoname', '=', $loc)->cached()->limit(1)->find();
                         if ($location->loaded()) {
                             $loc_siblings_ids = array_merge($loc_siblings_ids, $location->get_siblings_ids());
                         }
                     }
                 }
                 if (count($loc_siblings_ids) > 0) {
                     $ads->where('id_location', 'IN', $loc_siblings_ids);
                 }
             }
         } else {
             if (core::get('category') !== NULL) {
                 $category = new Model_Category();
                 $category->where('seoname', '=', core::get('category'))->cached()->limit(1)->find();
                 if ($category->loaded()) {
                     $ads->where('id_category', 'IN', $category->get_siblings_ids());
                 }
             }
             $location = NULL;
             //filter by location
             if (core::get('location') !== NULL) {
                 $location = new Model_location();
                 $location->where('seoname', '=', core::get('location'))->cached()->limit(1)->find();
                 if ($location->loaded()) {
                     $ads->where('id_location', 'IN', $location->get_siblings_ids());
                 }
             }
         }
         //filter by price(s)
         if (is_numeric($price_min = str_replace(',', '.', core::get('price-min')))) {
             // handle comma (,) used in some countries for prices
             $price_min = (double) $price_min;
         }
         // round((float)$price_min,2)
         if (is_numeric($price_max = str_replace(',', '.', core::get('price-max')))) {
             // handle comma (,) used in some countries for prices
             $price_max = (double) $price_max;
         }
         // round((float)$price_max,2)
         if ($price_min and $price_max) {
             if ($price_min > $price_max) {
                 // swap 2 values
                 $price_min = $price_max + $price_min - ($price_max = $price_min);
             }
             $ads->where('price', 'BETWEEN', array($price_min, $price_max));
         } elseif ($price_min) {
             $ads->where('price', '>=', $price_min);
         } elseif ($price_max) {
             $ads->where('price', '<=', $price_max);
         }
         foreach ($cf_fields as $key => $value) {
             if (isset($value) and $value != NULL) {
                 if (is_numeric($value)) {
                     $ads->where($key, '=', $value);
                 } elseif (is_string($value)) {
                     $ads->where($key, 'like', '%' . $value . '%');
                 }
             }
         }
         // count them for pagination
         $res_count = $ads->count_all();
         if ($res_count > 0) {
             // pagination module
             $pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $res_count, 'items_per_page' => core::config('advertisement.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action(), 'category' => $category !== NULL ? $category->seoname : NULL));
             Breadcrumbs::add(Breadcrumb::factory()->set_title(__("Page ") . $pagination->offset));
             $ads = $ads->order_by('published', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
         } else {
             $ads = NULL;
         }
     }
     $this->template->bind('content', $content);
     $this->template->content = View::factory('pages/ad/advanced_search', array('ads' => $ads, 'categories' => Model_Category::get_as_array(), 'order_categories' => Model_Category::get_multidimensional(), 'locations' => Model_Location::get_as_array(), 'order_locations' => Model_Location::get_multidimensional(), 'pagination' => $pagination, 'user' => $user, 'fields' => Model_Field::get_all()));
 }
?>
" placeholder="<?php 
echo __('Price from');
?>
">
                    </div>
                </div>
            
                <div class="form-group">
                    <div class="col-xs-12">
                        <label class="" for="price-max"><?php 
echo __('Price to');
?>
</label>
                        <input type="text" id="price-max" name="price-max" class="form-control" value="<?php 
echo core::get('price-max');
?>
" placeholder="<?php 
echo __('to');
?>
">
                    </div>
                </div>
            <?endif?>
        <?endif?>
        <!-- Fields coming from custom fields feature -->
        <div id="widget-custom-fields" data-apiurl="<?php 
echo Route::url('api', array('version' => 'v1', 'format' => 'json', 'controller' => 'categories'));
?>
" data-customfield-values='<?php 
echo json_encode(Request::current()->query());