示例#1
1
 public static function getUrlUploadMultiImages($obj, $user_id)
 {
     $url_arr = array();
     $min_size = 1024 * 1000 * 700;
     $max_size = 1024 * 1000 * 1000 * 3.5;
     foreach ($obj["tmp_name"] as $key => $tmp_name) {
         $ext_arr = array('png', 'jpg', 'jpeg', 'bmp');
         $name = StringHelper::filterString($obj['name'][$key]);
         $storeFolder = Yii::getPathOfAlias('webroot') . '/images/' . date('Y-m-d', time()) . '/' . $user_id . '/';
         $pathUrl = 'images/' . date('Y-m-d', time()) . '/' . $user_id . '/' . time() . $name;
         if (!file_exists($storeFolder)) {
             mkdir($storeFolder, 0777, true);
         }
         $tempFile = $obj['tmp_name'][$key];
         $targetFile = $storeFolder . time() . $name;
         $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
         $size = $obj['name']['size'];
         if (in_array($ext, $ext_arr)) {
             if ($size >= $min_size && $size <= $max_size) {
                 if (move_uploaded_file($tempFile, $targetFile)) {
                     array_push($url_arr, $pathUrl);
                 } else {
                     return NULL;
                 }
             } else {
                 return NULL;
             }
         } else {
             return NULL;
         }
     }
     return $url_arr;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new KqxsNam();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $model->image = CUploadedFile::getInstance($model, 'image');
     if (isset($_POST['KqxsNam'])) {
         $model->attributes = $_POST['KqxsNam'];
         $kqxs = KqxsBac::model()->find("date=:date and provice=:provice", array(':date' => $model->date, ":provice" => $model->provice));
         if (!$kqxs && $model->save()) {
             $folder = 'upload/' . date('Ymd');
             if (!file_exists($folder)) {
                 mkdir($folder);
             }
             if (is_object($model->image)) {
                 $model->image->saveAs(Yii::getPathOfAlias('webroot') . '/' . $folder . '/' . $model->image);
             }
             $model->image = $folder . '/' . $model->image;
             $model->update(array('image'));
             $this->redirect(array('view', 'id' => $model->id));
         } else {
             $model->addError('date', 'Kết quả này đã có vui lòng chỉnh lại thông tin');
         }
     }
     $model->date = date("d-m-Y", time());
     $this->render('create', array('model' => $model));
 }
示例#3
0
 function init()
 {
     parent::init();
     if (trim($this->id) == '' || trim($this->name) == '') {
         throw new CException('必须设置容器id和name值');
     }
     //发布资源
     $this->_assetUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('ext.baiduUeditor.resource'));
     $clientScript = Yii::app()->clientScript;
     //注册常量
     $jsConstant = 'window.UEDITOR_HOME_URL = "' . $this->_assetUrl . '/"';
     $clientScript->registerScript('ueditor_constant', $jsConstant, CClientScript::POS_BEGIN);
     //注册js文件
     foreach ($this->jsFiles as $jsFile) {
         $clientScript->registerScriptFile($this->_assetUrl . $jsFile, CClientScript::POS_END);
     }
     //注册css文件
     foreach ($this->cssFiles as $cssFile) {
         $clientScript->registerCssFile($this->_assetUrl . $cssFile);
     }
     //判断是否存在module
     if ($this->owner->module != null) {
         $moduleId = $this->owner->module->id;
         $this->serverUrl = Yii::app()->createUrl($moduleId . '/ueditor');
     } else {
         $this->serverUrl = Yii::app()->createUrl('ueditor');
     }
     //config
     $this->config['serverUrl'] = $this->serverUrl;
     $this->render('ueditor');
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Photo();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Photo'])) {
         $model->attributes = $_POST['Photo'];
         if (isset($_FILES['images']['name'][0]) && $_FILES['images']['name'][0] !== '') {
             $model->name = 'new';
         }
         if ($model->validate()) {
             $images = CUploadedFile::getInstancesByName('images');
             foreach ($images as $image) {
                 $imageModel = new Photo();
                 $name = uniqid() . $image->name;
                 $image->saveAs(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . $name);
                 copy(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . $name, Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . 'thumbs' . DIRECTORY_SEPARATOR . $name);
                 $thumb = Yii::app()->image->load(Yii::getPathOfAlias('webroot.uploads.images') . DIRECTORY_SEPARATOR . 'thumbs' . DIRECTORY_SEPARATOR . $name);
                 $thumb->resize(300, 300);
                 $thumb->save();
                 $imageModel->name = $name;
                 $imageModel->category_id = $_POST['Photo']['category_id'];
                 $imageModel->save();
             }
             Yii::app()->user->setFlash('success', Yii::t('main', 'Данные успешно сохранены!'));
             $this->refresh();
         } else {
             Yii::app()->user->setFlash('error', Yii::t('main', 'Ошибка!'));
         }
     }
     $this->render('create', array('model' => $model));
 }
示例#5
0
 /**
  * @return string base URL that contains all published asset files of this module.
  */
 public function getAssetsUrl()
 {
     if ($this->_assetsUrl == null) {
         $this->_assetsUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias($this->id . '.assets'), false, -1, true);
     }
     return $this->_assetsUrl;
 }
示例#6
0
 public function init()
 {
     if (isset($_GET[$this->grid_mode_var])) {
         $this->grid_mode = $_GET[$this->grid_mode_var];
     }
     if (isset($_GET['exportType'])) {
         $this->exportType = $_GET['exportType'];
     }
     $lib = Yii::getPathOfAlias($this->libPath) . '.php';
     if ($this->grid_mode == 'export' and !file_exists($lib)) {
         $this->grid_mode = 'grid';
         Yii::log("PHP Excel lib not found({$lib}). Export disabled !", CLogger::LEVEL_WARNING, 'EExcelview');
     }
     if ($this->grid_mode == 'export') {
         $this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle();
         $this->initColumns();
         //parent::init();
         //Autoload fix
         spl_autoload_unregister(array('YiiBase', 'autoload'));
         Yii::import($this->libPath, true);
         $this->objPHPExcel = new PHPExcel();
         spl_autoload_register(array('YiiBase', 'autoload'));
         // Creating a workbook
         $this->objPHPExcel->getProperties()->setCreator($this->creator);
         $this->objPHPExcel->getProperties()->setTitle($this->title);
         $this->objPHPExcel->getProperties()->setSubject($this->subject);
         $this->objPHPExcel->getProperties()->setDescription($this->description);
         $this->objPHPExcel->getProperties()->setCategory($this->category);
     } else {
         parent::init();
     }
 }
 public function actionIndex($is_product = 1)
 {
     if (!empty($_POST)) {
         $is_new_product = $is_product;
         $images = CUploadedFile::getInstancesByName('images');
         if (isset($images) && count($images) > 0) {
             // go through each uploaded image
             foreach ($images as $image => $pic) {
                 $model = new Slides();
                 $imageType = explode('.', $pic->name);
                 $imageType = $imageType[count($imageType) - 1];
                 $imageName = md5(uniqid()) . '.' . $imageType;
                 if ($pic->saveAs(Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName)) {
                     $model->image = $imageName;
                     $model->name = $pic->name;
                     $model->is_product = $is_new_product;
                     $model->save();
                     Yii::app()->user->setFlash('success', translate('Thêm thành công.'));
                 }
                 // handle the errors here, if you want
             }
         }
         PIUrl::createUrl('/admin/slides/index', array('is_product' => $is_product));
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition("is_product= {$is_product}");
     $criteria->order = 'id DESC';
     $count = Slides::model()->count($criteria);
     $pages = new CPagination($count);
     // results per page
     $pages->pageSize = 6;
     $pages->applyLimit($criteria);
     $model = Slides::model()->findAll($criteria);
     $this->render('index', compact('model', 'pages'));
 }
示例#8
0
 public function init()
 {
     $this->setImport(array($this->id . '.models.*', $this->id . '.components.*'));
     $ass = Yii::getPathOfAlias('objectExport.assets');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->assetManager->publish($ass . "/script.js"));
     Yii::app()->clientScript->registerCssFile(Yii::app()->assetManager->publish($ass . "/style.css"));
 }
示例#9
0
 public function init()
 {
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $id = $this->htmlOptions['id'] = $this->getId();
     }
     if ($this->url !== null) {
         $this->url = CHtml::normalizeUrl($this->url);
     }
     $cs = Yii::app()->getClientScript();
     //$cs->registerCoreScript('treeview');
     $baseUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.yii-jqTree.source'));
     $cs->registerScriptFile($baseUrl . '/tree.jquery.js');
     $options = $this->getClientOptions();
     $options = $options === array() ? '{}' : CJavaScript::encode($options);
     $cs->registerScript('Yii.JQTree#0' . $id, "if (jQuery.jqTree == undefined) {jQuery.jqTree = new Array;}");
     $cs->registerScript('Yii.JQTree#' . $id, "jQuery.jqTree[\"{$id}\"] = jQuery(\"#{$id}\").tree({$options});");
     if ($this->cssFile === null) {
         $cs->registerCssFile($baseUrl . '/jqtree.css');
     } else {
         if ($this->cssFile !== false) {
             $cs->registerCssFile($this->cssFile);
         }
     }
     echo CHtml::tag('ul', $this->htmlOptions, false, false) . "\n";
 }
示例#10
0
 public function afterSave($event)
 {
     if ($this->owner->isNewRecord && ($tmpId = $this->getTmpId())) {
         if ($this->owner instanceof DaInstance) {
             $finder = $this->owner;
         } else {
             $finder = $this->owner->model();
         }
         if ($this->resetScope) {
             $finder->resetScope();
         }
         $model = $finder->findByIdInstance($this->owner->getIdInstance());
         foreach ($this->getFiles() as $files) {
             foreach ($files as $file) {
                 $modelDir = $model->getDir(true);
                 $file->file_path = $modelDir . $file->getName();
                 $file->id_instance = $model->getIdInstance();
                 $file->id_tmp = null;
                 $file->save(false);
             }
         }
         if (count($this->getFiles()) > 0) {
             //переносим файлы
             $mpDir = Yii::getPathOfAlias('temp') . '/' . $this->getTmpId();
             HFile::copyDirectory($mpDir, $model->getDir(true, true));
             HFile::removeDirectoryRecursive($mpDir, true);
         }
     }
 }
示例#11
0
 public function getAssetsUrl()
 {
     if ($this->_assetsUrl === null) {
         $this->_assetsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.components.blocs.document.assets'), false, -1, YII_DEBUG);
     }
     return $this->_assetsUrl;
 }
示例#12
0
 /**
  * @return string the base URL that contains all published asset files of gii.
  */
 public function getAssetsUrl()
 {
     if ($this->_assetsUrl === null) {
         $this->_assetsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('cache.assets'));
     }
     return $this->_assetsUrl;
 }
示例#13
0
 protected function beforeValidate()
 {
     if (!parent::beforeValidate()) {
         return false;
     }
     if ($this->scenario == "fromAdmin") {
         if ($this->teacher_path_file == NULL) {
             $this->addError("teacher_avatar", "teacher_avatar is required");
             return false;
         }
         if (!$this->teacher_path_file->checkExt(array('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG'))) {
             return FALSE;
         }
         $ext = $this->teacher_path_file->getExtension();
         $name = StringHelper::unicode_str_filter($this->teacher_path_file->name);
         $storeFolder = Yii::getPathOfAlias('webroot') . '/uploads/teacher/';
         $targetPath = $storeFolder;
         //4
         $teacher_ava = Yii::app()->createAbsoluteUrl('uploads') . '/teacher/' . $name;
         if ($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "pjepg" || $ext == "png" || $ext == "x-png" || $ext == "GIF" || $ext == "JPG" || $ext == "JPEG" || $ext == "PJEPG" || $ext == "PNG" || $ext == "X_PNG") {
             $this->teacher_path_file->save($targetPath, $name);
             $this->teacher_avatar = $teacher_ava;
         }
     }
     return TRUE;
 }
示例#14
0
 /**
  * Import products
  */
 public function actionImport()
 {
     $importer = new CsvImporter();
     $importer->deleteDownloadedImages = Yii::app()->request->getPost('remove_images');
     if (Yii::app()->request->isPostRequest && isset($_FILES['file'])) {
         $importer->file = $_FILES['file']['tmp_name'];
         if ($importer->validate() && !$importer->hasErrors()) {
             // Create db backup
             if (isset($_POST['create_dump']) && $_POST['create_dump']) {
                 Yii::import('application.components.SDatabaseDumper');
                 $dumper = new SDatabaseDumper();
                 $file = Yii::getPathOfAlias('webroot.protected.backups') . DIRECTORY_SEPARATOR . 'dump_' . date('Y-m-d_H_i_s') . '.sql';
                 if (is_writable(Yii::getPathOfAlias('webroot.protected.backups'))) {
                     if (function_exists('gzencode')) {
                         file_put_contents($file . '.gz', gzencode($dumper->getDump()));
                     } else {
                         file_put_contents($file, $dumper->getDump());
                     }
                 } else {
                     throw new CHttpException(503, Yii::t('CsvModule.admin', 'Ошибка. Директория для бэкапов недоступна для записи.'));
                 }
             }
             $importer->import();
         }
     }
     $this->render('import', array('importer' => $importer));
 }
示例#15
0
 public function getViewPath($checkTheme = false)
 {
     if ($checkTheme && ($theme = Yii::app()->getTheme()) !== null) {
         return $theme->getViewPath() . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'similarads';
     }
     return Yii::getPathOfAlias('application.modules.similarads.views');
 }
示例#16
0
 public function getAssetsUrl()
 {
     if ($this->_assetsUrl === null) {
         $this->_assetsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('news.assets'), false, -1, YII_DEBUG);
     }
     return $this->_assetsUrl;
 }
示例#17
0
 public function init()
 {
     $dir = Yii::getPathOfAlias('app.migrations');
     if (!is_dir($dir)) {
         mkdir($dir);
         mkdir($dir . DIRECTORY_SEPARATOR . '1');
     }
     $migDir = glob($dir . DIRECTORY_SEPARATOR . "*", GLOB_ONLYDIR);
     natsort($migDir);
     $mig = array();
     $migrations = array();
     foreach ($migDir as $d) {
         $sqls = glob($d . DIRECTORY_SEPARATOR . "*.sql");
         $idx = str_replace($dir . DIRECTORY_SEPARATOR, '', $d);
         if (!isset($mig[$idx])) {
             $mig = array($idx => array()) + $mig;
         }
         foreach ($sqls as $sql_file) {
             $data = file_get_contents($sql_file);
             $file = str_replace($d . DIRECTORY_SEPARATOR, '', $sql_file);
             $mig[$idx][$file] = $data;
         }
     }
     foreach ($mig as $id => $m) {
         $migrations[] = array('id' => $id, 'items' => $m);
     }
     $this->migrations = $migrations;
     $this->name = Setting::get('db.migration_name', '');
     $this->done = $this->list;
 }
示例#18
0
 /**
  * Retrieves all of the themes from webroot.themes and returns them in an array group by type, each containing
  * the contents of theme.json.
  *
  * The themes are then cached for easy retrieval later. (I really hate unecessary DiskIO if something isn't changing...)
  *
  * @return array
  */
 public function getThemes()
 {
     $themes = Yii::app()->cache->get('settings_themes');
     if ($themes == false) {
         $themes = array();
         $currentTheme = Cii::getConfig('theme');
         $themePath = Yii::getPathOfAlias('base.themes') . DS;
         $directories = glob($themePath . "*", GLOB_ONLYDIR);
         // Pushes the current theme onto the top of the list
         foreach ($directories as $k => $dir) {
             if ($dir == Yii::getPathOfAlias('base.themes') . DS . $currentTheme) {
                 unset($directories[$k]);
                 break;
             }
         }
         array_unshift($directories, $themePath . $currentTheme);
         foreach ($directories as $dir) {
             $json = CJSON::decode(file_get_contents($dir . DIRECTORY_SEPARATOR . 'composer.json'));
             $name = $json['name'];
             $key = str_replace('ciims-themes/', '', $name);
             $themes[$key] = array('path' => $dir, 'name' => $name, 'hidden' => isset($json['hidden']) ? $json['hidden'] : false);
         }
         Yii::app()->cache->set('settings_themes', $themes);
         return $themes;
     }
     return $themes;
 }
 public function actionIndex()
 {
     require_once 'Zend/Mail.php';
     $sql = "SELECT * FROM client where (cli_saleemail = 'yes' or cli_letemail  = 'yes') and cli_email != '' and cli_email is not null";
     $data = Yii::app()->db->createCommand($sql)->queryAll();
     $exclude = [];
     if (file_exists('luna/exclude')) {
         $exclude = file('luna/exclude');
     }
     foreach ($data as $client) {
         if (in_array($client['cli_email'], $exclude)) {
             $this->log('excluded ' . $client['cli_email']);
             continue;
         }
         try {
             $mail = new Zend_Mail("UTF-8");
             $mail->addTo($client['cli_email']);
             $mail->setFrom('*****@*****.**');
             $mail->setSubject('Win 2 tickets to the Luna Outdoor Cinema');
             $mail->setBodyHtml($this->renderFile(Yii::getPathOfAlias('application.commands.luna') . '/template.php', compact('client'), true));
             $this->log('Sending mail to ' . $client['cli_fname'] . ' [' . $client['cli_email'] . ']');
             $mail->send();
             $this->log('Mail sent to ' . $client['cli_fname'] . ' [' . $client['cli_email'] . ']');
         } catch (Exception $e) {
             $this->log('ERROR : Mail NOT sent to ' . $client['cli_fname'] . ' [' . $client['cli_email'] . ']');
         }
     }
 }
示例#20
0
 private function processDocument($path, $filename)
 {
     $basePath = Yii::getPathOfAlias('ext') . '/';
     $filePath = $basePath . $path . '/' . $filename;
     if (!file_exists($filePath)) {
         echo "File {$filePath} does not exist. Skipping.\n";
         return;
     }
     echo "Processing {$filePath}.\n";
     $markdownParser = new CMarkdownParser();
     $layout = Yii::getPathOfAlias('application.views.layouts') . '/documentation.php';
     if ($f = fopen($filePath, "r")) {
         $title = $in = fgets($f);
         while (!feof($f)) {
             $in .= fgets($f, 4096);
         }
     }
     fclose($f);
     $out = $markdownParser->transform($in);
     $out = $this->renderFile($layout, array('content' => $out, 'title' => $title), true);
     $docsPath = Yii::getPathOfAlias('application.docs') . '/';
     if (!file_exists($docsPath . $path)) {
         mkdir($docsPath . $path, 0777, true);
     }
     $outFileName = $docsPath . $path . '/' . str_replace('.txt', '.html', $filename);
     file_put_contents($outFileName, $out);
     return $outFileName;
 }
示例#21
0
 /**
  * Execute the action.
  * @param array command line parameters specific for this command
  */
 public function run($args)
 {
     if (!isset($args[0], $args[1])) {
         echo "Error: both model class and view name are required.\n";
         echo $this->getHelp();
         return;
     }
     $scenario = isset($args[2]) ? $args[2] : '';
     $modelClass = Yii::import($args[0], true);
     $model = new $modelClass($scenario);
     $attributes = $model->getSafeAttributeNames();
     $templatePath = $this->templatePath === null ? YII_PATH . '/cli/views/shell/form' : $this->templatePath;
     $viewPath = Yii::getPathOfAlias($args[1]);
     $viewName = basename($viewPath);
     $viewPath .= '.php';
     $params = array('modelClass' => $modelClass, 'viewName' => $viewName, 'attributes' => $attributes);
     $list = array(basename($viewPath) => array('source' => $templatePath . '/form.php', 'target' => $viewPath, 'callback' => array($this, 'generateForm'), 'params' => $params));
     $this->copyFiles($list);
     $actionFile = $templatePath . '/action.php';
     if (!is_file($actionFile)) {
         // fall back to default ones
         $actionFile = YII_PATH . '/cli/views/shell/form/action.php';
     }
     echo "The following form view has been successfully created:\n";
     echo "\t{$viewPath}\n\n";
     echo "You may use the following code in your controller action:\n\n";
     echo $this->renderFile($actionFile, $params, true);
     echo "\n";
 }
 public function prepare()
 {
     parent::prepare();
     $generate_whole_db = false;
     $templatePath = $this->templatePath;
     if (($pos = strrpos($this->tableName, '.')) !== false) {
         $schema = substr($this->tableName, 0, $pos);
         $tableName = substr($this->tableName, $pos + 1);
     } else {
         $schema = '';
         $tableName = $this->tableName;
     }
     if ($tableName[strlen($tableName) - 1] === '*') {
         $generate_whole_db = true;
         $this->tables = Yii::app()->{$this->connectionId}->schema->getTables($schema);
         if ($this->tablePrefix != '') {
             foreach ($this->tables as $i => $table) {
                 if (strpos($table->name, $this->tablePrefix) !== 0) {
                     unset($this->tables[$i]);
                 }
             }
         }
     } else {
         $this->tables = array($this->getTableSchema($this->tableName));
     }
     $this->relations = $this->generateRelations();
     foreach ($this->tables as $table) {
         $tableName = $this->removePrefix($table->name);
         $className = $this->generateClassName($table->name);
         $params = array('tableName' => $schema === '' ? $tableName : $schema . '.' . $tableName, 'modelClass' => $className, 'columns' => $table->columns, 'labels' => $this->generateLabels($table), 'rules' => $this->generateRules($table), 'relations' => isset($this->relations[$className]) ? $this->relations[$className] : array());
         if ($this->template != 'singlefile') {
             $this->files[] = new CCodeFile(Yii::getPathOfAlias($this->modelPath) . '/' . 'Base' . $className . '.php', $this->render($templatePath . '/basemodel.php', $params));
         }
     }
 }
示例#23
0
 public function actionCrear($id)
 {
     $micrositio = $id ? Micrositio::model()->with('seccion')->findByPk($id) : 0;
     $album_foto = new AlbumFoto();
     $album_foto->micrositio_id = $micrositio->id;
     if (isset($_POST['AlbumFoto'])) {
         $transaction = $album_foto->dbConnection->beginTransaction();
         $album_foto->attributes = $_POST['AlbumFoto'];
         $directorio = $this->slugger($micrositio->nombre) . '/' . $this->slugger($album_foto->nombre);
         $album_foto->directorio = $directorio . '/';
         $album_foto->creado = date('Y-m-d H:i:s');
         if ($album_foto->save()) {
             $micrositio = Micrositio::model()->findByPk($album_foto->micrositio_id);
             $dir = Yii::getPathOfAlias('webroot') . '/images/galeria/' . $directorio;
             if (@mkdir($dir, 0755, true)) {
                 $transaction->commit();
                 Yii::app()->user->setFlash('success', $album_foto->nombre . ' guardado con éxito');
             } else {
                 $transaction->rollBack();
                 Yii::app()->user->setFlash('warning', $album_foto->nombre . ' no se pudo guardar');
             }
             $this->redirect(array($this->slugger($micrositio->seccion->nombre) . '/view', 'id' => $micrositio->id));
         }
         //if($album_foto->save())
     }
     //if(isset($_POST['AlbumFoto']))
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $this->render('crear', array('model' => $album_foto));
 }
示例#24
0
 /**
  * Initializes the application component.
  * This method overrides the parent implementation by preprocessing
  * the user request data.
  */
 public function init()
 {
     parent::init();
     if ($this->basePath === null) {
         $this->basePath = Yii::getPathOfAlias('application.messages');
     }
 }
示例#25
0
 /**
  * Registers script and css file
  */
 protected static function registerFullCalendarScriptAndCss()
 {
     $cs = Yii::app()->getClientScript();
     $baseScriptUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.core.widgets.assets'));
     $cs->registerScriptFile($baseScriptUrl . '/fullCalendar/fullcalendar.min.js', ClientScript::POS_HEAD);
     $cs->registerCssFile($baseScriptUrl . '/fullCalendar/fullcalendar.css');
 }
示例#26
0
    public function init()
    {
        //Yii::app()->setTheme('adm');
        $cs = Yii::app()->getClientScript();
        $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/global.js');
        $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery-ui.min.js');
        $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery.alerts.js');
        //$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/js/jquery.confirm.js');
        //$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/js/jquery.blockui.js');
        $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery-ui-1.8.2.custom.min.js');
        //$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/js/bsystemgroup.js');
        $cs->registerCssFile(Yii::app()->theme->baseUrl . '/css/jquery.alerts.css');
        Yii::app()->clientScript->registerScript('global', '                                                           
	          yii = {                                                                                                     
	              urls: {                                      
	                  base: ' . CJSON::encode(Yii::app()->theme->baseUrl) . '                                                        
	              }                                                                                                       
	          };                                                                                                          
	    ', CClientScript::POS_HEAD);
        if (Yii::app()->user->id) {
            $user = new ASystemUser();
            $userInfo = $user->getSystemUserById(Yii::app()->user->id);
            //var_dump($userInfo->cp_code);exit();
            $this->group_id = $userInfo->group_id;
            $this->username = $userInfo->username;
            Yii::app()->session['group_id'] = $this->group_id;
            Yii::app()->session['username'] = $this->username;
        }
        //$xmlPath = realpath($path = Yii::app()->basePath.'/../'.Yii::app()->params['config_folder'].'/');
        //        $xmlFile = Yii::app()->params['config_file_name'];
        //        $this->config = new LoadConfigXML($xmlPath,$xmlFile);
        Yii::$classMap = array_merge(Yii::$classMap, array('CaptchaExtendedAction' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedAction.php', 'CaptchaExtendedValidator' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedValidator.php'));
    }
 public function actionErrorDispositionNotification()
 {
     spl_autoload_unregister(array('YiiBase', 'autoload'));
     require_once Yii::getPathOfAlias('ext') . "/yandex-money-payout/lib/autoload.php";
     spl_autoload_register(array('YiiBase', 'autoload'));
     $settings = new \YandexMoney\Settings();
     $settings->host = Yii::app()->params['yandexPayout']['host'];
     $settings->cert = Yii::app()->params['yandexPayout']['cert'];
     $settings->certPassword = Yii::app()->params['yandexPayout']['certPassword'];
     $settings->privateKey = Yii::app()->params['yandexPayout']['privateKey'];
     $settings->yaCert = Yii::app()->params['yandexPayout']['yaCert'];
     $provider = new PKCS7RequestProvider($settings);
     $api = new PayoutAPI($provider, Yii::app()->params['yandexPayout']['cardSynonimUrl']);
     $api->errorDepositionNotification(function ($request) {
         $result = new \YandexMoney\ErrorDepositionParams($request['clientOrderId']);
         $deposition = PayoutDeposition::model()->findByAttributes(array('clientOrderId' => $request['clientOrderId']));
         if ($deposition) {
             $deposition->status = PayoutDeposition::STATUS_REJECTED;
             $deposition->errors = $request['error'];
             $deposition->save();
             /**
              * @var PayoutTask $task
              */
             $task = $deposition->payoutTask;
             $task->status = PayoutTask::STATUS_FAILED;
             $task->save();
         }
         return $result;
     });
 }
示例#28
0
    public function create()
    {
        ## Prepare Command Class Directory
        $path = Yii::getPathOfAlias($this->commandPath);
        if (!is_dir($path)) {
            mkdir($path, 0777, true);
        }
        ## Write New Command Class
        $filePath = $path . DIRECTORY_SEPARATOR . $this->command . "Command.php";
        if (!is_file($filePath)) {
            $content = <<<EOF
<?php

class {$this->command}Command extends Service {
    public function actionIndex() {
        ## Put your code here
        
    }
}
EOF;
            file_put_contents($filePath, $content);
        }
        if (substr($this->command, -8) != "Command") {
            $this->command = $this->command . "Command";
        }
        if (substr($this->action, 8) != "action") {
            $this->action = "action" . $this->action;
        }
        ## Setup Process Entry in Setting
        Setting::set("services.list." . $this->name, $this->attributes);
    }
示例#29
0
 public function init()
 {
     // register class paths for extension captcha extended
     Yii::$classMap = array_merge(Yii::$classMap, array('CaptchaExtendedAction' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedAction.php', 'CaptchaExtendedValidator' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedValidator.php'));
     $this->search = new Search();
     $this->link = new Linksite();
 }
示例#30
0
 public function getAssetsPath()
 {
     if ($this->_assetsPath === null) {
         $this->_assetsPath = Yii::app()->assetManager->publish(Yii::getPathOfAlias('application.modules.admin.assets'), false, -1, YII_DEBUG);
     }
     return $this->_assetsPath;
 }