Exemple #1
0
 public function onRun()
 {
     $user = $this->user();
     if (!$user) {
         return false;
     }
     $name = trim($user->name);
     $parts = explode(" ", $name);
     $last_name = array_pop($parts);
     $first_name = implode(" ", $parts);
     $path = !empty($user->avatar) ? $user->avatar->getPath() : '';
     $this->page['user'] = $user;
     $this->page['last_name'] = $last_name;
     $this->page['first_name'] = $first_name;
     $this->page['avatar'] = $path;
     $asset_script[] = '~/plugins/dlnlab/classified/assets/js/components/headerbar.js';
     $asset_css[] = '~/plugins/dlnlab/classified/assets/css/components/headerbar.css';
     $this->page['asset_css'] = $asset_css;
     $this->page['asset_script'] = $asset_script;
     $this->page['types'] = HelperCache::getAdType();
     $this->page['categories'] = HelperCache::getAdCategory();
     $this->page['amenities'] = HelperCache::getAdAmenities();
     $this->page['bed_rooms'] = AdInfor::getBedRoomOptions();
     $this->page['bath_rooms'] = AdInfor::getBathRoomOptions();
     $this->page['directions'] = AdInfor::getDirectionOptions();
 }
Exemple #2
0
 public function onRun()
 {
     //$this->addJs('http://maps.google.com/maps/api/js?sensor=false&libraries=places&language=vi');
     //$this->addJs(CLF_ASSETS . '/js/helper-googlemap.js');
     //$this->addJs(CLF_ASSETS . '/js/com-ad-edit.js');
     $this->addCss(CLF_ASSETS . '/css/com-ad-edit.css');
     $type = $this->property('type', 'quick');
     switch ($type) {
         case 'quick':
             break;
         case 'edit':
             //$asset_script[] = '~/plugins/dlnlab/classified/assets/js/components/ad-edit2.js';
             break;
         case 'edit2':
             $ad_id = intval($this->param('ad_id'));
             if (empty($ad_id)) {
                 Redirect::to('/ad/quick');
             }
             $ad = Ad::find($ad_id);
             $ad_infor = AdInfor::where('ad_id', '=', $ad_id);
             $ad_tags = Tag::getTagsOfAd($ad_id);
             $this->page['ad'] = $ad;
             $this->page['ad_infor'] = $ad_infor;
             $this->page['ad_tags'] = $ad_tags;
             break;
         case 'edit-detail':
             $kind = HelperCache::getAdKind();
             $category = HelperCache::getAdCategory();
             $amenity = HelperCache::getAdAmenities();
             $bed_rooms = AdInfor::getBedRoomOptions();
             $bath_rooms = AdInfor::getBathRoomOptions();
             $direction = AdInfor::getDirectionOptions();
             $caches = new \stdClass();
             $caches->kind = !empty($kind) ? $kind->toJson() : '';
             $caches->category = !empty($category) ? $category->toJson() : '';
             $caches->amenity = !empty($amenity) ? $amenity->toJson() : '';
             $caches->bed = json_encode($bed_rooms);
             $caches->bath = json_encode($bath_rooms);
             $caches->direction = json_encode($direction);
             $this->page['user'] = $this->user();
             $this->page['ad'] = !empty($ad) ? $ad : '';
             $this->page['ad_json'] = !empty($ad) ? $ad->toJson() : '';
             $this->page['dln_caches'] = !empty($caches) ? json_encode($caches) : '';
             break;
     }
     $this->page['type'] = $type;
 }
Exemple #3
0
 public function onRun()
 {
     $asset_css = array();
     $asset_script = array();
     $type = Input::has('type') ? Input::get('type') : '';
     switch ($type) {
         case 'ad-location':
             $asset_script[] = '~/plugins/dlnlab/classified/assets/js/helpers/helper-googlemap.js';
             $asset_script[] = '~/plugins/dlnlab/classified/assets/js/modals/ad-location.js';
             break;
         case 'ad-photo':
             $asset_script[] = 'assets/vendor/jquery-ui/jquery-ui.min.js';
             $asset_script[] = 'assets/vendor/jquery-fileupload/js/vendor/jquery.ui.widget.js';
             $asset_script[] = 'assets/vendor/jquery-fileupload/js/jquery.fileupload.js';
             $asset_script[] = '~/plugins/dlnlab/classified/assets/js/modals/ad-photo.js';
             // Get photos of Ad
             $ad_id = Input::has('ad_id') ? Input::get('ad_id') : '';
             $records = null;
             if ($ad_id) {
                 $ad = Ad::find($ad_id);
                 $records = $ad->ad_images;
             }
             $this->page['photos'] = $records;
             break;
         case 'ad-amenity':
             $asset_script[] = '~/plugins/dlnlab/classified/assets/js/modals/ad-amenity.js';
             $arr_selected = Input::has('values') ? explode(',', Input::get('values')) : '';
             $this->page['arr_selected'] = $arr_selected;
             $this->page['amenities'] = HelperCache::getAdAmenities();
             break;
         case 'ad-title':
             break;
     }
     $this->page['type'] = $type;
     $this->page['asset_css'] = $asset_css;
     $this->page['asset_script'] = $asset_script;
 }
Exemple #4
0
 public static function gen_auto_ad_name($data)
 {
     $default = array('type_id' => '', 'category_id' => '', 'price' => '');
     $merge = array_merge($default, $data);
     $merge = \DLNLab\Classified\Classes\HelperClassified::trim_value($merge);
     extract($merge);
     $kind = '';
     $types = HelperCache::getAdType();
     foreach ($types as $id => $type) {
         if ($id == $type_id) {
             $kind = $type;
         }
     }
     $category = HelperCache::findAdCategoryById($category_id);
     $ad_name = ucfirst($kind);
     $ad_name .= ' ' . mb_strtolower($category->name);
     $ad_name .= ' giá ' . mb_strtolower($price) . ' đồng';
     return $ad_name;
 }