public function getForm() { Yii::import('ext.colorpicker.ColorPicker'); Yii::import('ext.bootstrap.fileinput.Fileinput'); Yii::app()->controller->widget('ext.tinymce.TinymceWidget'); Yii::import('ext.bootstrap.selectinput.SelectInput'); return new TabForm(array('attributes' => array('id' => __CLASS__, 'class' => 'form-horizontal', 'enctype' => 'multipart/form-data'), 'showErrorSummary' => true, 'elements' => array('general' => array('type' => 'form', 'title' => self::t('TAB_GENERAL'), 'elements' => array('coords' => array('type' => 'text'), 'name' => array('type' => 'text'), 'map_id' => array('type' => 'SelectInput', 'data' => Html::listData(ContactsMaps::model()->findAll(), 'id', 'name')), 'balloon_content_body' => array('type' => 'textarea', 'class' => 'editor'), 'icon_content' => array('type' => 'text'), 'hint_content' => array('type' => 'text'))), 'default_icon' => array('type' => 'form', 'title' => self::t('TAB_DEF_ICON'), 'elements' => array('preset' => array('type' => 'SelectInput', 'data' => self::getIconList()), 'color' => array('type' => 'ColorPicker'))), 'my_icon' => array('type' => 'form', 'title' => self::t('TAB_MY_ICON'), 'elements' => array('icon_file' => array('type' => 'Fileinput', 'hint' => $this->overviewImage()), 'icon_file_offset_x' => array('type' => 'text'), 'icon_file_offset_y' => array('type' => 'text')))), 'buttons' => array('submit' => array('type' => 'submit', 'class' => 'btn btn-success', 'label' => $this->isNewRecord ? Yii::t('app', 'CREATE', 0) : Yii::t('app', 'SAVE')))), $this); }
public function getForm() { Yii::import('ext.colorpicker.ColorPicker'); Yii::import('ext.bootstrap.fileinput.Fileinput'); Yii::import('ext.bootstrap.selectinput.SelectInput'); Yii::app()->controller->widget('ext.tinymce.TinymceWidget'); return new TabForm(array('attributes' => array('id' => __CLASS__, 'class' => 'form-horizontal'), 'showErrorSummary' => true, 'elements' => array('general' => array('type' => 'form', 'title' => self::t('TAB_GENERAL'), 'elements' => array('name' => array('type' => 'text'), 'map_id' => array('type' => 'SelectInput', 'data' => Html::listData(ContactsMaps::model()->findAll(), 'id', 'name')), 'preset' => array('type' => 'text', 'hint' => self::t('HINT_PRESET', array('{link}' => Html::link('https://tech.yandex.ru/maps/doc/jsapi/2.1/ref/reference/option.presetStorage-docpage/', 'https://tech.yandex.ru/maps/doc/jsapi/2.1/ref/reference/option.presetStorage-docpage/', array('target' => '_blank'))))), 'mapStateAutoApply' => array('type' => 'checkbox'), 'color' => array('type' => 'ColorPicker'), 'opacity' => array('type' => 'SelectInput', 'data' => self::getOpacityList()))), 'start_point' => array('type' => 'form', 'title' => self::t('TAB_START'), 'elements' => array('start_coords' => array('type' => 'text'), 'start_icon_content' => array('type' => 'text'), 'start_balloon_content_body' => array('type' => 'textarea', 'class' => 'editor'), 'start_icon_content' => array('type' => 'text'))), 'end_point' => array('type' => 'form', 'title' => self::t('TAB_END'), 'elements' => array('end_coords' => array('type' => 'text'), 'end_icon_content' => array('type' => 'text'), 'end_balloon_content_body' => array('type' => 'textarea', 'class' => 'editor'), 'end_icon_content' => array('type' => 'text')))), 'buttons' => array('submit' => array('type' => 'submit', 'class' => 'btn btn-success', 'label' => $this->isNewRecord ? Yii::t('app', 'CREATE', 0) : Yii::t('app', 'SAVE')))), $this); }
public function afterUninstall() { Yii::app()->settings->clear('contacts'); $db = Yii::app()->db; $db->createCommand()->dropTable(ContactsMaps::model()->tableName()); $db->createCommand()->dropTable(ContactsMarkers::model()->tableName()); $db->createCommand()->dropTable(ContactsRouter::model()->tableName()); $db->createCommand()->dropTable(ContactsRouterTranslate::model()->tableName()); return parent::afterUninstall(); }
public function run() { $cs = Yii::app()->clientScript; $maps = ContactsMaps::model()->findAll(); foreach ($maps as $map) { $mapID = __CLASS__ . $map->id; $this->options[$mapID] = $this->getOptions($map); $this->renderMap($mapID, $this->options[$mapID]); $cs->registerScript($mapID, "\r\n var markers = " . CJSON::encode($this->getMapMarkers($map)) . ";\r\n var mapID = '" . $mapID . "';\r\n var mapOptions = " . CJavaScript::encode($this->options[$mapID]) . ";\r\n api.addMap(mapID,mapOptions);\r\n var min_x=999;\r\n var max_x=0;\r\n var min_y=999;\r\n var max_y=0;\r\n\r\n \$.each(markers,function(i,marker){\r\n api.setMark(marker,'#'+mapID);\r\n if(min_x > marker.coordx) min_x = marker.coordx;\r\n if(min_y > marker.coordy) min_y = marker.coordy;\r\n if(max_x < marker.coordx) max_x = marker.coordx;\r\n if(max_y < marker.coordy) max_y = marker.coordy;\r\n });\r\n if(markers.length > 1){\r\n api.setBounds([[min_y,min_x],[max_y,max_x]],mapID);\r\n api.setZoomMap(mapOptions.zoom,mapID);\r\n }\r\n ", CClientScript::POS_READY); } }
/** * Действие редактирование и добавление * @param bool $new */ public function actionUpdate($new = false) { $model = $new === true ? new ContactsMaps() : ContactsMaps::model()->findByPk($_GET['id']); $this->pageName = $model->isNewRecord ? Yii::t('app', 'CREATE', 1) : Yii::t('app', 'UPDATE', 1); if ($model->isNewRecord) { $model->center = self::DEFAULT_CENTER; } $this->breadcrumbs = array(Yii::t('ContactsModule.default', 'MODULE_NAME') => array('/admin/contacts'), Yii::t('ContactsModule.default', 'MAPS') => array('/admin/contacts/maps'), $this->pageName); if (isset($_POST['ContactsMaps'])) { $model->attributes = $_POST['ContactsMaps']; if ($model->validate()) { $model->save(); $this->redirect(array('index')); } } $this->render('update', array('model' => $model)); }
/** * Действие редактирование и добавление * @param bool $new * @throws CHttpException */ public function actionUpdate($new = false) { $mapsCount = ContactsMaps::model()->count(); if ($mapsCount < 1) { throw new CHttpException(403); } $model = $new === true ? new ContactsRouter() : ContactsRouter::model()->findByPk($_GET['id']); $this->pageName = $model->isNewRecord ? Yii::t('app', 'CREATE', 1) : Yii::t('app', 'UPDATE', 1); $this->breadcrumbs = array(Yii::t('ContactsModule.default', 'MODULE_NAME') => array('/admin/contacts'), Yii::t('ContactsModule.default', 'ROUTER') => array('/admin/contacts/router'), $this->pageName); if (isset($_POST['ContactsRouter'])) { $model->attributes = $_POST['ContactsRouter']; if ($model->validate()) { $model->save(); $this->redirect(array('index')); } } $this->render('update', array('model' => $model)); }