コード例 #1
1
ファイル: Listing.php プロジェクト: jasonhai/onehome
 public function getDefaultImageUrl($width = null, $height = null)
 {
     $noImageUrl = null;
     $model = ProListingPhotos::model()->findByAttributes(array('listing_id' => $this->id, 'default' => 1));
     if ($model) {
         return $model->getImageUrl($width, $height, true);
     }
     return $noImageUrl;
 }
コード例 #2
1
ファイル: listing_detail.php プロジェクト: jasonhai/onehome
                    Listing Map
                </a>
            </li>
        </ul>
        <!-- Tab panes -->
        <div class="tab-content">
            <div class="tab-pane active">
                <div class="row">
                    <div class="col-md-9">
                        <!-- photo and video -->
                        <div class="box-3">
                            <h2 class="title-2">Photos &amp; Videos</h2>
                            <div class="clearfix">
                                <p class="btn-6 pull-left">
                                    <?php 
$photoList = ProListingPhotos::getPhotoByListing($model->id);
if (count($photoList) <= 1) {
    echo count($photoList) . ' Photo';
} else {
    echo count($photoList) . ' Photos';
}
?>
                                </p>
                                <p class="pull-right">
                                    <a href="javascript:;"><strong class="Fullscreen">Fullscreen</strong></a>
                                </p>
                            </div>

                            <?php 
if (empty($photoList)) {
    ?>
コード例 #3
1
    public static function syncListing($data)
    {
        // if listing is not from OneHome, skip it
        // if listing is not created by OneHome Agent, skip it
        if (strcasecmp($data['comp_lis'], 'L3010619I') != 0 || !$data['user_id']) {
            return -1;
            //			$data['user_id'] = 627;	// arthur zang
        }
        if (LhListing::model()->exists('property_name_or_address LIKE :s 
			AND display_address LIKE :a', array(':s' => $data['property_name_or_address'], ':a' => $data['display_address']))) {
            return -2;
        }
        // save listing
        $model = new LhListing('sync');
        $model->attributes = $data;
        $model->save();
        // save photo
        $notDef = false;
        foreach ($data['photos'] as $url) {
            $ext = pathinfo($url, PATHINFO_EXTENSION);
            if (!in_array($ext, array('jpg', 'png', 'gif'))) {
                continue;
            }
            $photo = new ProListingPhotos();
            $photo->display_order = 0;
            $photo->default = $notDef ? 0 : 1;
            $notDef = true;
            $photo->listing_id = $model->id;
            $photo->image = basename($url);
            $photo->created_date = date('Y-m-d H:i:s');
            $photo->save();
            // get image from remote server and save to disk
            $file = $photo->generateImagePath();
            if (!file_exists(dirname($file))) {
                mkdir(dirname($file));
            }
            file_put_contents($file, static::getContent($url));
        }
        return 1;
    }
コード例 #4
1
 public function actionSetdefault($listing, $photo)
 {
     $model = ProListingPhotos::model()->findByPk($photo);
     if ($model) {
         ProListingPhotos::model()->updateAll(array('default' => 0), "listing_id={$listing}");
         $model->default = 1;
         $model->save();
     }
 }
コード例 #5
1
ファイル: ProListingPhotos.php プロジェクト: jasonhai/onehome
 /**
  * @Author: ANH DUNG Jan 19, 2015
  * @Todo: handle sort photo
  * @Param: $model is model Listing
  */
 public static function HandleSortPhoto($model)
 {
     $order = 1;
     $sql = '';
     $tableName = ProListingPhotos::model()->tableName();
     foreach ($_POST['photo_display_order'] as $key => $pk) {
         $sql .= "UPDATE {$tableName} SET `display_order`={$order} WHERE `id` = {$pk} AND `listing_id`={$model->id} ;";
         $order++;
     }
     //UPDATE mytable SET (id, column_a, column_b) FROM VALUES ( (1, 12, 6), (2, 1, 45), (3, 56, 3), … );
     Yii::app()->db->createCommand($sql)->execute();
 }