Beispiel #1
0
 public function rules()
 {
     $video = ApartmentVideo::model();
     $panorama = ApartmentPanorama::model();
     $rules = array(array('price', 'priceValidator', 'except' => 'video_file, video_html, panorama'), array('location_id', 'locationRequired', 'except' => 'video_file, video_html, panorama'), array('title', 'i18nRequired', 'except' => 'video_file, video_html, panorama'), array('price, price_to, floor, floor_total, window_to, type, price_type, obj_type_id, city_id, activity_always', 'numerical', 'integerOnly' => true), array('square, land_square', 'numerical'), array('type', 'numerical', 'min' => 1), array('price_to', 'priceToValidator'), array('berths', 'length', 'max' => 255), array('title', 'i18nLength', 'max' => 255), array('lat, lng', 'length', 'max' => 25), array('phone', 'length', 'max' => 15), array('id', 'safe', 'on' => 'search'), array('floor', 'myFloorValidator'), array('is_price_poa', 'boolean'), array('in_currency, owner_active, num_of_rooms, is_special_offer, is_free_from, is_free_to, active, metroStations, note, period_activity, sublocation_id, region_id', 'safe'), array($this->getI18nFieldSafe(), 'safe'), array('city_id, owner_active, active, type, obj_type_id, ownerEmail, ownerUsername, popularity', 'safe', 'on' => 'search'), array('video_html', 'checkHtmlCode'), array('video_file', 'file', 'types' => $video->supportExt, 'maxSize' => $video->fileMaxSize, 'allowEmpty' => true), array('panoramaFile', 'file', 'types' => $panorama->supportedExt, 'maxSize' => $panorama->maxSize, 'tooLarge' => Yii::t('module_apartments', 'The file was larger than {size}MB. Please upload a smaller file.', array('{size}' => $panorama->maxSizeMb)), 'allowEmpty' => true));
     if (issetModule('formeditor')) {
         Yii::import('application.modules.formeditor.models.HFormEditor');
         $addRules = HFormEditor::getRulesForModel();
         $rules = CMap::mergeArray($rules, $addRules);
     }
     if (issetModule('location') && param('useLocation', 1)) {
         $rules[] = array('loc_city, loc_region, loc_country', 'safe', 'on' => 'search');
         $rules[] = array('loc_city, loc_region, loc_country', 'numerical', 'integerOnly' => true);
     }
     return $rules;
 }
        }
    }
}
if ($panExists) {
    echo '<div>';
    $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'button', 'type' => 'success', 'icon' => 'plus white', 'label' => tc('Add'), 'htmlOptions' => array('onclick' => '$(".add-panorama").toggle();')));
    echo '</div><br/>';
    Yii::app()->clientScript->registerScript('add-panorama-toggle', '
			$(".add-panorama").hide();
		', CClientScript::POS_READY);
}
?>

<div class="rowold add-panorama" >
	<?php 
echo $form->labelEx($model, 'panoramaFile');
?>
	<?php 
echo $form->fileField($model, 'panoramaFile');
?>
    <div class="padding-bottom10">
		<span class="label label-info">
			<?php 
echo Yii::t('module_apartments', 'Supported file: {supportExt}.', array('{supportExt}' => ApartmentPanorama::model()->supportedExt));
?>
		</span>
    </div>
	<?php 
echo $form->error($model, 'panoramaFile');
?>
</div>
Beispiel #3
0
 public function actionDeletePanorama($id = null, $apId = null)
 {
     if (Yii::app()->user->isGuest) {
         throw404();
     }
     if (!$id && !$apId) {
         throw404();
     }
     if (Yii::app()->user->checkAccess('backend_access')) {
         $modelPanorama = ApartmentPanorama::model()->findByPk($id);
         $modelPanorama->delete();
         $this->redirect(array('/apartments/backend/main/update', 'id' => $apId));
     } else {
         $modelApartment = Apartment::model()->findByPk($apId);
         if ($modelApartment->owner_id != Yii::app()->user->id) {
             throw404();
         }
         $modelPanorama = ApartmentPanorama::model()->findByPk($id);
         $modelPanorama->delete();
         $this->redirect(array('/userads/main/update', 'id' => $apId));
     }
 }