Ejemplo n.º 1
0
 public function get_search_items($parent_id = 0, $group_type)
 {
     $group_type = strtolower($group_type);
     $group_type = $group_type && in_array($group_type, array('property', 'pricing')) ? $group_type : 'property';
     \View::set_global('group_type', $group_type);
     // Override category_id if its a search
     $parent_id = \Input::get('parent_id', $parent_id);
     // If we are viewing category products
     // We need to find all products from that and child categories
     if ($parent_id) {
         $group = \Product\Model_Group::find_one_by_id($parent_id);
         $group and \View::set_global('group', $group);
     }
     // Reset $parent_id if its invalid value
     is_numeric($parent_id) or $parent_id = 0;
     /************ Start generating query ***********/
     $items = Model_Group::find(function ($query) use($group_type, $parent_id) {
         $query->where('type', '=', $group_type);
         $query->where('parent_id', '=', $parent_id);
         // Get search filters
         foreach (\Input::get() as $key => $value) {
             if (!empty($value) || $value == '0') {
                 switch ($key) {
                     case 'title':
                         $query->where($key, 'like', "%{$value}%");
                         break;
                     case 'status':
                         if (is_numeric($value)) {
                             $query->where($key, $value);
                         }
                         break;
                 }
             }
         }
         // Order query
         $query->order_by('sort', 'asc');
         $query->order_by('id', 'asc');
     });
     /************ End generating query ***********/
     // Reset to empty array if there are no result found by query
     if (is_null($items)) {
         $items = array();
     }
     // Initiate pagination
     $pagination = \Hybrid\Pagination::make(array('total_items' => count($items), 'per_page' => \Input::get('per_page', 10), 'uri_segment' => null));
     // Remove unwanted items, and show only required ones
     $items = array_slice($items, $pagination->offset, $pagination->per_page);
     return array('items' => $items, 'pagination' => $pagination);
 }
Ejemplo n.º 2
0
 /**
  * Get additional content data selected
  * 
  * @param $result = Query result
  */
 public static function post_find($result)
 {
     if ($result !== null) {
         if (is_array($result)) {
             foreach ($result as $item) {
                 // It will first check if we already have result in temporary result,
                 // and only execute query if we dont. That way we dont have duplicate queries
                 // Get related products
                 $item->get_products = static::lazy_load(function () use($item) {
                     $products = Model_Product_To_Groups::find(function ($query) use($item) {
                         return $query->where('group_id', $item->id);
                     }, 'product_id');
                     if (!empty($products)) {
                         $products = '(' . implode(',', array_keys($products)) . ')';
                         return Model_Product::find(function ($query) use($products, $item) {
                             $query->where('id', 'IN', \DB::expr($products));
                             $query->order_by('sort', 'asc');
                             return $query;
                         }, 'id');
                     }
                     return array();
                 }, $item->id, 'products');
                 // Get content children
                 $item->get_children = static::lazy_load(function () use($item) {
                     return Model_Group::find(array('where' => array('parent_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'children');
                 // Get group images
                 $item->get_images = static::lazy_load(function () use($item) {
                     return Model_Group_Image::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'images');
                 // Get product groups
                 $item->get_product_groups = static::lazy_load(function () use($item) {
                     $product_groups = \Product\Model_Group::find_by_type('discount');
                     foreach ($product_groups as $product_group) {
                         $product_group->set_user_group_id($item->id);
                     }
                     return $product_groups;
                 }, $item->id, 'product_groups');
             }
         }
     }
     // return the result
     return $result;
 }
Ejemplo n.º 3
0
	                                	<?php 
    }
    ?>
									<?php 
}
?>
                                </div>
                            </div>
                        </div>

                        <?php 
if ($product) {
    ?>

                            <?php 
    $property_groups = \Product\Model_Group::find_by_type('property');
    ?>
                            
                            <div class="side_tree_holder" style="display: none;">
                                <div class="tree_heading">
                                    <h4>Property Groups</h4>
                                    <div id="sidetreecontrol2" class="sidetreecontrol"><a href="#">Collapse All</a><a href="#">Expand All</a></div>
                                </div>
                                <div class="tree_content">
                                    <div id="sidetree">

                                        <?php 
    if (!$product && empty($property_groups)) {
        ?>
                                            <div class="wide"><span class="req">Note: </span> There are no property groups yet.</div>
                                        <?php 
Ejemplo n.º 4
0
 /**
  * Index page
  * 
  * @access  public
  * @param   $slug
  */
 public function action_index($slug = false, $gallery_id = null)
 {
     // Get home page
     $home_page = \Config::get('details.locked_items.home_page');
     $gallery_page = \Config::get('details.locked_items.gallery');
     $item = false;
     if ($slug == 'referrals' && strtolower(\Sentry::user()->groups()[0]['name']) != 'club members') {
         \Messages::error('Only club members can access this page.');
         \Response::redirect('/');
     }
     //var_dump($slug);die();
     // Find content by slug
     if ($slug !== false) {
         $item = \Page\Model_Page::get_by_slug($slug);
     } elseif ($slug === false) {
         $item = \Page\Model_Page::find_one_by_id($home_page);
     }
     if ($item) {
         // Home page is always without slug so we redirect if someone tries to access home page with slug
         if ($item->id == $home_page && $slug !== false) {
             \Response::redirect(\Uri::base(false));
         }
     } else {
         // Send to 404 page
         throw new \HttpNotFoundException();
     }
     $result = \Page\Model_Page::get_content_file($item->id);
     if ($result) {
         foreach ($result as $rs) {
             $item->content_file_pdf = $rs->file;
             //pdf file
             $item->content_file_title = $rs->title;
             //pdf title
         }
     }
     // Default view file
     $view_file = 'default';
     // Fill in home page slug if none is supplied
     if ($slug === false && $item->id == $home_page) {
         $slug = $item->seo->slug;
         // Home page has its standard template
         $view_file = 'home';
     } else {
         // Search for page specific template
         $files = \File::read_dir($this->theme_view_path);
         if (!empty($files)) {
             foreach ($files as $file) {
                 $path_parts = pathinfo($file);
                 if (strpos($path_parts['filename'], '_') === 0) {
                     $file_id = substr($path_parts['filename'], strripos($path_parts['filename'], '_') + 1);
                     if (is_numeric($file_id) && $item->id == $file_id) {
                         $view_file = $path_parts['filename'];
                     }
                 }
             }
         }
     }
     $stock_options = \Config::load('stock-option.db');
     // TODO delete this
     srand($item->id);
     $this->page_theme = \Theme::instance()->set_partial('content', $this->view_dir . $view_file);
     $this->page_theme->set('item', $item, false);
     $this->page_theme->set('manage_stock', $stock_options['manage_stock'], false);
     $this->page_theme->set('hide_out_of_stock', $stock_options['hide_out_of_stock'], false);
     $this->page_theme->set('allow_buy_out_of_stock', $stock_options['allow_buy_out_of_stock'], false);
     if ($item->id == $gallery_page) {
         if ($gallery_id && \Input::is_ajax()) {
             // This will return gallery images only if it is ajax call
             $this->returnGalleryImages($gallery_id);
         }
     }
     // Data for home page
     if ($view_file == 'home') {
         $featured_products = \Product\Model_Group::find_one_by_id(4);
         if ($featured_products) {
             $featured_products = $featured_products->products;
         }
         $this->page_theme->set('featured_products', $featured_products, false);
         $categories = \Product\Model_Category::find(array('where' => array('parent_id' => 0, 'status' => 1), 'order_by' => array('sort' => 'asc'), 'limit' => 8));
         $this->page_theme->set('categories', $categories, false);
         $applications = \Application\Model_Application::find(array('where' => array('parent_id' => 0, 'status' => 1), 'order_by' => array('sort' => 'asc'), 'limit' => 8));
         $this->page_theme->set('applications', $applications, false);
         // $this->page_theme->set('blog', $this->wp_blog(), false);
     }
     \View::set_global('title', $item->seo->meta_title ?: $item->title);
     \View::set_global('meta_description', $item->seo->meta_description ?: '');
     \View::set_global('meta_keywords', $item->seo->meta_keywords ?: '');
     $robots = array('meta_robots_index' => $item->seo->meta_robots_index == 1 ? 'index' : 'noindex', 'meta_robots_follow' => $item->seo->meta_robots_follow == 1 ? 'follow' : 'nofollow');
     \View::set_global('robots', $robots);
     \View::set_global('canonical', $item->seo->canonical_links);
     \View::set_global('h1_tag', $item->seo->h1_tag);
     if ($item->seo->redirect_301) {
         \Response::redirect($item->seo->redirect_301);
     }
 }
Ejemplo n.º 5
0
                            <?php 
    // END OF: USER SPECIFIC SEARCH FILTERS
    ?>
                            
                            <?php 
    if (in_array('group_id', $options)) {
        ?>
                                <div class="filter_width <?php 
        echo $margin();
        ?>
">
                                    <?php 
        echo \Form::label('Parent Group');
        ?>
                                    <?php 
        echo \Form::select('parent_id', \Input::get('parent_id'), array('false' => 'Select') + \Product\Model_Group::fetch_pair('id', 'title', array(), false, \Product\Model_Group::find_by_type('property')), array('class' => 'select_init filter_width'));
        ?>
                                </div>
                            <?php 
    }
    ?>
                            
                            <?php 
    if (in_array('category_id', $options)) {
        ?>
                                <div class="filter_width <?php 
        echo $margin();
        ?>
">
                                    <?php 
        echo \Form::label('Product Categories');
Ejemplo n.º 6
0
 public function action_update_new($id = false)
 {
     if (!is_numeric($id)) {
         \Response::redirect('admin/user/group/list');
     }
     // Get group to edit
     if (!($item = \Sentry::group((int) $id))) {
         \Response::redirect('admin/user/group/list');
     }
     \View::set_global('title', 'Edit Group');
     $group = \Sentry::group((int) $id);
     // Find all product groups and set usergroup id
     $group->product_groups = \Product\Model_Group::find_by_type('pricing');
     foreach ($group->product_groups as $product_group) {
         $product_group->set_user_group_id($group->id);
     }
     \Theme::instance()->set_partial('content', $this->view_dir . 'update_new')->set('group', $group);
 }
Ejemplo n.º 7
0
						<?php 
// Define group type (property, pricing, etc.)
$group_type = isset($group_type) ? $group_type : (isset($group) ? $group->type : 'property');
// Get groups
$groups = \Product\Model_Group::find(function ($query) use($group_type) {
    $query->where('type', $group_type);
    $query->order_by('sort', 'asc');
    $query->order_by('id', 'asc');
});
$group = isset($group) ? $group : false;
$link = isset($link) ? $link : 'update';
$selected = isset($selected) ? $selected : false;
// hide radio buttons on non property groups
if ($group && $group->type == 'pricing') {
    $group = false;
}
// show radio buttons only on update page
if ($group && $group->type == 'property' && $link != 'update') {
    $group = false;
}
?>
						<?php 
if ($group) {
    ?>
                        <div class="side_tree_holder">
                            <div class="tree_heading">
                                <h4><?php 
    echo ucfirst($group_type);
    ?>
 Product Groups</h4>
                                <div id="sidetreecontrol" class="sidetreecontrol"><a href="#">Collapse All</a><a href="#">Expand All</a></div>