public function actionSave() { $uid = Yii::app()->user->id; $pid = $_GET['pid']; $lat = $_GET['lat']; $lng = $_GET['lng']; $zoom = $_GET['zoom'] == 0 ? 13 : (int) $_GET['zoom']; if (NULL === ($fm = Filemarks::model()->find("file_id=:fid", array('fid' => $pid)))) { $fm = new Filemarks(); } $fm->file_id = $pid; $fm->lat = $lat; $fm->long = $lng; $fm->zoom = $zoom; $fm->created_at = time(); $fm->status = 1; $fm->save(); exit; }
/** * * @param mixed $param could be either upload name or array of params.<br/> * An array will be like this:<br/><pre> * array( * 'field' => 'files', //field name * 'type' => 'photos', //kind of file: 'photos' or 'video' * 'resize' => false, //will photos be resized now * 'previews' => $this->previews, //what thumbs will be generated * ) * </pre> * @return mixed Array of basename of the file and it's extension or false otherwise */ public function uploadFile($param = array()) { $options = array('field' => 'files', 'type' => 'photos', 'resize' => false, 'previews' => $this->previews); if (is_string($param)) { $options['field'] = $param; } else { $options = array_merge($options, $param); } $folder = Yii::getPathOfAlias('webroot') . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . $options['type'] . DIRECTORY_SEPARATOR; $upload = CUploadedFile::getInstanceByName($options['field']); if ($upload == null || $upload->error != 0) { return false; } $fn = sha1_file($upload->tempName); $ext = pathinfo($upload->name, PATHINFO_EXTENSION); $return_ext = 'jpg'; switch ($options['type']) { case 'photos': $return_ext = $ext; break; case 'video': $return_ext = 'jpg'; break; } $error = false; if (!$this->findByPk($fn)) { move_uploaded_file($upload->tempName, $folder . $fn . '.' . $ext); $this->isNewRecord = true; $this->type = $options['type']; $this->id = $fn; $this->extension = $ext; switch ($options['type']) { case 'photos': if (FALSE !== ($coords = $this->getLongLat())) { $error = Filemarks::addPlace($coords, '14', $fn); } if ($options['resize']) { $this->resizeAll(); } break; case 'video': $this->convertVideo($folder, $fn, $ext, $options['previews']); break; } $this->save(); } return array('filename' => $fn, 'extension' => $return_ext, 'error' => $error); }
<?php $marks = Filemarks::model()->find("file_id=:fl", array(':fl' => $photo['file'])); ?> <div class="viewPhoto"> <table cellpadding="0" cellspacing="0" width="1160px"> <tr> <td class="left"> <div class="container"> <div class="title" style="margin-bottom:10px;"> Фотография <?php echo $aroundInfo['num']; ?> из <?php echo $aroundInfo['count']; ?> </div> <div class="photo"> <a class="navigation prev" href="/id<?php echo $user_id; ?> /aphotos/<?php echo $nav_link; ?> /<?php echo $aroundInfo['prev']; ?> "></a> <a class="navigation next" href="/id<?php echo $user_id; ?>