/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new MCompany(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['MCompany'])) { $model->attributes = $_POST['MCompany']; $brandImage = CUploadedFile::getInstance($model, 'image_id'); if ($brandImage instanceof CUploadedFile) { $image = new MImage(); $path_parts = pathinfo($brandImage->getName()); $file_name = time() . "." . $path_parts['extension']; $path = Yii::app()->storagePath . "brand" . DIRECTORY_SEPARATOR . $file_name; $brandImage->saveAs($path); $image->created = time(); $image->path = "/storage/brand/" . $file_name; $image->created_by = Yii::app()->user->id; $image->save(false); } $model->image_id = $image->id; $model->created = time(); $model->created_by = Yii::app()->user->id; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function generateInner() { $this->setClass('mFieldLabel'); $this->setRender('label'); if ($this->property->width) { $this->addStyle('width', $this->property->width); } if ($this->property->help) { $id = $this->getId() . 'help'; $this->page->addDojoRequire("dijit.Tooltip"); $help = new MImage($id, ' ', 'managerIconButtonHelp'); $this->text .= ' ' . $help->generate(); $this->getPage()->onLoad("new dijit.Tooltip({connectId: [\"{$id}\"], label: \"{$this->property->help}\"});"); } $this->inner = trim($this->text) != '' ? $this->render() : ''; }
public function generateControl($i, $row) { $class = "mGridActionIconDetail"; $row = $this->grid->data[$this->grid->currentRow]; $n = count($row); $href = $this->href; if (preg_match('/%(.*)%/', $href, $matches)) { $value = preg_replace('/%(.*)%/', $row[$matches[0][1]], $href); } $href = str_replace("%r%", $this->grid->currentRow, $href); $hrefOn = str_replace("%s%", '1', $href); $hrefOff = str_replace("%s%", '0', $href); $controlOn = new MImage('', '', $this->path[true]); $controlOff = new MImage('', '', $this->path[false]); $controlOn->addAttribute('onclick', $hrefOn); $controlOn->setClass($class); $controlOff->addAttribute('onclick', $hrefOff); $controlOff->setClass($class); $this->control[$i] = new MDiv('', array($controlOn, $controlOff), 'detail'); return $this->control[$i]; }
public function generateInner() { parent::generateInner(); $link = $this->generateLink($this->inner); $this->inner = $link->generate(); }
function helper_image($matches) { $m = explode('|', $matches[1]); $source = Manager::getStaticURL('', 'images/' . $m[0], true); $image = new MImage('', '', '', $source); // return '<a ' . $class . ' href="/' . $target . '">' . $text . '</a>'; return $image->generate(); }