当前位置: 首页>>代码示例>>PHP>>正文


PHP yii::getAlias方法代码示例

本文整理汇总了PHP中yii::getAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP yii::getAlias方法的具体用法?PHP yii::getAlias怎么用?PHP yii::getAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii的用法示例。


在下文中一共展示了yii::getAlias方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionAdd

 public function actionAdd()
 {
     $shipping_id = (int) \yii::$app->request->get('shipping', 0);
     $sql = "SELECT shipping_name,shipping_code FROM " . Shipping::tableName() . " WHERE id={$shipping_id}";
     $shipping = \yii::$app->getDb()->createCommand($sql)->queryOne();
     $set_modules = 1;
     include_once \yii::getAlias('@ext') . '/shipping/' . $shipping['shipping_code'] . '.php';
     $fields = [];
     foreach ($modules[0]['configure'] as $key => $val) {
         $fields[$key]['name'] = $val['name'];
         $fields[$key]['value'] = $val['value'];
         $fields[$key]['label'] = \yii::t('shipping', $val['name']);
     }
     $count = count($fields);
     $fields[$count]['name'] = "freee_money";
     $fields[$count]['value'] = "0";
     $fields[$count]['label'] = \yii::t('shipping', 'free_money');
     //如果支持货到付款,则允许设置货到付款支付费用
     if ($modules[0]['cod']) {
         $count++;
         $fields[$count]['name'] = "pay_fee";
         $fields[$count]['value'] = "0";
         $fields[$count]['label'] = \yii::t('shipping', 'pay_fee');
     }
     $shipping_area['shipping_id'] = 0;
     $shipping_area['free_money'] = 0;
     return $this->render('shipping_area_info', ['shipping_area' => ['shipping_id' => $shipping_id, 'shipping_code' => $shipping['shipping_code']], 'fields' => $fields, 'form_action' => 'insert']);
 }
开发者ID:styleyoung,项目名称:taoshop,代码行数:28,代码来源:ShippingAreaController.php

示例2: save

 public function save()
 {
     $base = yii::getAlias("@app/config");
     $handle = fopen($base . "/smsdb.php", "w+");
     $content = "<?php\nreturn [\n    'class' => 'yii\\db\\Connection',\n    'dsn' => 'mysql:host={$this->host};port={$this->port};dbname={$this->dbname}',\n    'username' => '{$this->user}',\n    'password' => '{$this->pass}',\n    'charset' => 'utf8',\n];";
     fwrite($handle, $content);
 }
开发者ID:oyoy8629,项目名称:yii-core,代码行数:7,代码来源:SmsDbForm.php

示例3: UploadImage

 /**
  * 图片上传的处理函数
  *
  * @access public
  * @param
  *            array upload 包含上传的图片文件信息的数组
  * @param
  *            array dir 文件要上传在$this->data_dir下的目录名。如果为空图片放在则在$this->images_dir下以当月命名的目录下
  * @param
  *            array img_name 上传图片名称,为空则随机生成
  * @return mix 如果成功则返回文件名,否则返回false
  */
 public function UploadImage($upload, $dir = '', $img_name = '')
 {
     if (empty($dir)) {
         $dir = date('Ym');
         $dir = \yii::getAlias('@static') . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR;
     } else {
         $dir = \yii::getAlias('@static') . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR;
         if ($img_name) {
             $img_name = $dir . $img_name;
         }
     }
     if (!file_exists($dir)) {
         if (!$this->make_dir($dir)) {
             return false;
         }
     }
     if (empty($img_name)) {
         $img_name = $this->unique_name($dir);
         $img_name = $dir . $img_name . UtilD::get_filetype($upload['name']);
     }
     if (!UtilD::check_img_type($upload['type'])) {
         return false;
     }
     //允许上传的类型
     $allow_file_types = ['gif', 'jpg', 'jpeg', 'png', 'bmp', 'swf'];
     //'|GIF|JPG|JEPG|PNG|BMP|SWF|';
     if (!UtilD::check_file_type($upload['tmp_name'], $img_name, $allow_file_types)) {
         return false;
     }
     if ($this->move_file($upload, $img_name)) {
         return str_replace(\yii::getAlias('@static') . DIRECTORY_SEPARATOR, '', $img_name);
     } else {
         return false;
     }
 }
开发者ID:styleyoung,项目名称:taoshop,代码行数:47,代码来源:ImageD.php

示例4: getMainDependenciesConfig

 private function getMainDependenciesConfig()
 {
     if (is_null($this->mainDependenciesConfig)) {
         $this->mainDependenciesConfig = (require \yii::getAlias("@appBuilder") . "/config/Dependencies.php");
     }
     return $this->mainDependenciesConfig;
 }
开发者ID:Vlsirko,项目名称:yii2-application-builder,代码行数:7,代码来源:ConfigLoader.php

示例5: _parseCode

 /**
  * 根据错误状态码解析错误提示信息
  * @param $code
  * @return string
  * @deprecate 转换到parseCode方法
  */
 private static function _parseCode($code)
 {
     include_once \yii::getAlias('@common/config/error.php');
     $lang = \yii::$app->language;
     include_once \yii::getAlias('@common/lang/' . $lang . '/error_message_lang.php');
     //待优化
     return isset($lang[$code]) ? $lang[$code] : null;
 }
开发者ID:great-all,项目名称:zaizaitvServer,代码行数:14,代码来源:JsonHelper.php

示例6: getURLForAuth

 public static function getURLForAuth($fbAPI)
 {
     define('FACEBOOK_SDK_V4_SRC_DIR', \yii::getAlias('@frontend/modules/socials/fb'));
     FacebookSession::setDefaultApplication($fbAPI['APPID'], $fbAPI['SECURITY_KEY']);
     $helper = new FacebookRedirectLoginHelper(\yii::$app->params['fbAPI']['redirectURL']);
     $loginUrl = $helper->getLoginUrl();
     return $loginUrl;
 }
开发者ID:shurup312,项目名称:mywedguru,代码行数:8,代码来源:FB.php

示例7: getContent

 public function getContent()
 {
     $twig = Yii::$app->twig->env(new \Twig_Loader_Filesystem(\yii::getAlias('@app/views/cmslayouts/')));
     $insertion = [];
     foreach ($this->layout->getJsonConfig('placeholders') as $item) {
         $insertion[$item['var']] = $this->renderPlaceholder($this->id, $item['var'], 0);
     }
     return $twig->render($this->layout->view_file, ['placeholders' => $insertion, 'activeUrl' => Yii::$app->links->activeUrl]);
 }
开发者ID:efueger,项目名称:luya,代码行数:9,代码来源:NavItemPage.php

示例8: load

 /**
  * @param $langfile
  * @param string $idiom
  * @param bool|FALSE $return
  * @return array|bool|void
  * @throws InvalidConfigException
  */
 public function load($langfile, $idiom = '', $return = FALSE)
 {
     if (is_array($langfile)) {
         foreach ($langfile as $value) {
             $this->load($value, $idiom, $return);
         }
         return;
     }
     $langfile = str_replace('.php', '', $langfile) . '_lang.php';
     if (empty($idiom) or !preg_match('/^[a-z_-]+$/i', $idiom)) {
         $idiom = \yii::$app->language ?: 'zh_cn';
     }
     if ($return === FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) {
         return;
     }
     $_is_load = false;
     // Load the base file, so any others found can override it
     $lang = [];
     //循环获取多个模块下的语言文件
     foreach ($this->_lang_paths as $path) {
         $_file_path = \yii::getAlias($path . '/lang/' . $idiom . '/' . $langfile);
         if (!file_exists($_file_path)) {
             continue;
         }
         $section_lang = (include_once $_file_path);
         if (!is_array($section_lang)) {
             if ($return === true) {
                 return [];
             } else {
                 throw new InvalidConfigException('Language file contains no data: language/' . $idiom . '/' . $langfile);
             }
         }
         $_is_load = true;
         $lang = ArrayHelper::merge($lang, $section_lang);
     }
     if ($_is_load !== TRUE) {
         if ($return === true) {
             return [];
         } else {
             throw new InvalidConfigException('Unable to load the requested language file: language/' . $idiom . '/' . $langfile);
         }
     }
     $this->is_loaded[$langfile] = $idiom;
     $this->_current_lang = $lang;
     $this->language = ArrayHelper::merge($this->language, $lang);
     if ($return === TRUE) {
         return $lang;
     }
     return TRUE;
 }
开发者ID:great-all,项目名称:zaizaitvServer,代码行数:57,代码来源:Lang.php

示例9: saveImage

 public static function saveImage($location, $sourceName, $fileName)
 {
     if (isset($_FILES[$sourceName])) {
         $fileName = $fileName . '.jpg';
         $path = '/upload/' . $location . '/';
         $saveImage = self::SaveFileFromPost($sourceName, Yii::$app->basePath . $path, $fileName, false);
         $link = substr(yii::getAlias('@web'), 0, -4);
         $link = Url::to($link . $path . $fileName, true);
         if ($saveImage == true) {
             return $link;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:avrahamichler,项目名称:Highnet,代码行数:17,代码来源:UploadFile.php

示例10: load

 /**
  * Load Config File
  *
  * @param	string	$file			Configuration file name
  * @param   bool   $return             是否返回
  * @param	bool	$use_sections		Whether configuration values should be loaded into their own section
  * @param	bool	$fail_gracefully	Whether to just return FALSE or display an error message
  * @return	bool	TRUE if the file was loaded correctly or FALSE on failure
  */
 public function load($file = '', $return = true, $use_sections = FALSE, $fail_gracefully = FALSE)
 {
     $file = $file === '' ? 'main' : str_replace('.php', '', $file);
     $loaded = FALSE;
     foreach ($this->_config_paths as $path) {
         foreach ([$file, YII_ENV . '/' . $file] as $location) {
             $file_path = \yii::getAlias($path . '/config/' . $location . '.php');
             if (in_array($file_path, $this->is_loaded, TRUE)) {
                 return TRUE;
             }
             if (!file_exists($file_path)) {
                 continue;
             }
             $sction_config = (include_once $file_path);
             if (!is_array($sction_config)) {
                 if ($fail_gracefully === TRUE) {
                     return FALSE;
                 }
                 //show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
             }
             $this->current_config = ArrayHelper::merge($this->current_config, $sction_config);
             if ($use_sections === TRUE) {
                 self::$config[$file] = isset(self::$config[$file]) ? ArrayHelper::merge(self::$config[$file], $this->current_config) : $this->current_config;
             } else {
                 self::$config = ArrayHelper::merge(self::$config, $this->current_config);
             }
             $this->is_loaded[] = $file_path;
             $loaded = TRUE;
             //log_message('debug', 'Config file loaded: '.$file_path);
         }
     }
     if ($loaded === TRUE) {
         if ($return === true) {
             return $this->current_config;
         } else {
             return TRUE;
         }
     } elseif ($fail_gracefully === TRUE) {
         return FALSE;
     }
     //show_error('The configuration file '.$file.'.php does not exist.');
 }
开发者ID:great-all,项目名称:zaizaitvServer,代码行数:51,代码来源:Config.php

示例11: sendMail

 public static function sendMail($data)
 {
     $from = Utility::getConfig('admin_email');
     $url = parse_url(\yii::$app->urlManager->getHostInfo());
     $search = ['{copyright}' => '&copy; ' . date('Y') . ' - ' . \yii::$app->urlManager->getHostInfo() . ' All rights reserved.', '{logo}' => \yii::getAlias('@base_url') . '/images/logo.jpg', '{domain_name}' => $url['host'], '{domain_url}' => \yii::$app->urlManager->getHostInfo()];
     switch ($data['request']) {
         case "forget_password":
             $subject = "Reset Password Link";
             $to = $data['to'];
             $link = $data['link'];
             $emailModel = EmailTemplate::getEmailTemplate('forget_password');
             $emailContent = $emailModel->content;
             $search['{name}'] = ucwords($data['user']);
             $search['{link}'] = $data['link'];
             $emailContent = str_replace(array_keys($search), array_values($search), $emailContent);
             break;
         case "user_registration":
             $subject = "Registration";
             $to = $data['to'];
             $link = $data['activationLink'];
             $emailModel = EmailTemplate::getEmailTemplate('user_registration');
             $emailContent = $emailModel->content;
             $emailContent = str_replace('{name}', ucwords($data['user_name']), $emailContent);
             $emailContent = str_replace('{link}', $data['activationLink'], $emailContent);
             break;
         case "newsletter":
             $subject = $data['subject'];
             $to = $data['email'];
             $emailModel = EmailTemplate::getEmailTemplate('news_letter');
             $emailContent = $emailModel->et_content;
             $emailContent = str_replace('{name}', $to, $emailContent);
             $emailContent = str_replace('{message}', $data['message'], $emailContent);
             break;
         default:
             echo "default case";
     }
     \Yii::$app->mail->compose()->setFrom($from)->setTo($to)->setSubject($subject)->setHtmlBody($emailContent)->send();
     return true;
 }
开发者ID:rubedkhan2149,项目名称:2149,代码行数:39,代码来源:Utility.php

示例12: loadConfig

 /**
  * @param $file
  * @param array $config_path
  * @return array
  * @throws InvalidConfigException
  */
 public static function loadConfig($file, $config_path = [])
 {
     static $_config_paths = ['@common', '@backend'];
     if (!empty($config_path)) {
         $_config_paths = $config_path;
     }
     $_config = [];
     $file = $file === '' ? 'main' : str_replace('.php', '', $file);
     foreach ($_config_paths as $path) {
         foreach ([$file, YII_ENV . '/' . $file] as $location) {
             $file_path = \yii::getAlias($path . '/config/' . $location . '.php');
             if (!file_exists($file_path)) {
                 continue;
             }
             $_config_section = (include_once $file_path);
             if (!is_array($_config_section)) {
                 throw new InvalidConfigException('Your ' . $file_path . ' file does not appear to contain a valid configuration array.');
             }
             $_config = ArrayHelper::merge($_config, $_config_section);
         }
     }
     return $_config;
 }
开发者ID:great-all,项目名称:zaizaitvServer,代码行数:29,代码来源:CommonHelper.php

示例13: __construct

 public function __construct()
 {
     parent::__construct();
     $this->baseUrl = \yii::getAlias('@base_url');
 }
开发者ID:rubedkhan2149,项目名称:2149,代码行数:5,代码来源:AppAsset.php

示例14: actionPost

 public function actionPost()
 {
     $allow_file_types = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'swf'];
     $values = \yii::$app->request->post('value', []);
     $type = \Yii::$app->request->post('type', '');
     /* 保存变量值 */
     $count = count($values);
     $arr = [];
     $sql = "SELECT id,value FROM " . ShopConfig::tableName();
     $res = \yii::$app->db->createCommand($sql)->queryAll();
     foreach ($res as $row) {
         $arr[$row['id']] = $row['value'];
     }
     foreach ($_POST['value'] as $key => $val) {
         //值更改则更新
         if ($arr[$key] != $val) {
             $sql = "UPDATE " . ShopConfig::tableName() . " SET value='" . trim($val) . "' WHERE id=" . $key;
             $rs = \yii::$app->db->createCommand($sql)->execute();
         }
     }
     /* 处理上传文件 */
     $file_var_list = [];
     $sql = "SELECT * FROM " . ShopConfig::tableName() . " WHERE parent_id > 0 AND type='file'";
     $res = \yii::$app->db->createCommand($sql)->queryAll();
     foreach ($res as $row) {
         $file_var_list[$row['code']] = $row;
     }
     foreach ($_FILES as $code => $file) {
         /* 判断用户是否选择了文件 */
         if (isset($file['error']) && $file['error'] == 0 || !isset($file['error']) && $file['tmp_name'] != 'none') {
             //检查上传的文件类型是否合法
             if (!UtilD::check_file_type($file['tmp_name'], $file['name'], $allow_file_types)) {
                 UtilD::toJavaScriptAlert('', 'back');
                 \yii::$app->end();
             } else {
                 $file_path = \yii::getAlias('@static') . DIRECTORY_SEPARATOR . $file_var_list[$code]['store_dir'];
                 //取得文件路径
                 if ($code == 'shop_logo') {
                     $ext = array_pop(explode('.', $file['name']));
                     $file_name = 'logo.' . $ext;
                 } elseif ($code == 'watermark') {
                     $ext = array_pop(explode('.', $file['name']));
                     $file_name = 'watermark.' . $ext;
                     if (file_exists($file_var_list[$code]['value'])) {
                         @unlink($file_var_list[$code]['value']);
                     }
                 } elseif ($code == 'wap_logo') {
                     $ext = array_pop(explode('.', $file['name']));
                     $file_name = 'wap_logo.' . $ext;
                     if (file_exists($file_var_list[$code]['value'])) {
                         @unlink($file_var_list[$code]['value']);
                     }
                 } else {
                     $file_name = $file['name'];
                 }
                 /* 判断是否上传成功 */
                 if (move_uploaded_file($file['tmp_name'], $file_path . $file_name)) {
                     $sql = "UPDATE " . ShopConfig::tableName() . " SET value='" . $file_name . "' WHERE code='" . $code . "'";
                     $rs = \yii::$app->db->createCommand($sql)->execute();
                 }
             }
         }
     }
     /* 处理发票类型及税率 */
     if (!empty($_POST['invoice_rate'])) {
         foreach ($_POST['invoice_rate'] as $key => $rate) {
             $rate = round(floatval($rate), 2);
             if ($rate < 0) {
                 $rate = 0;
             }
             $_POST['invoice_rate'][$key] = $rate;
         }
         $invoice = ['type' => $_POST['invoice_type'], 'rate' => $_POST['invoice_rate']];
         $sql = "UPDATE " . ShopConfig::tableName() . " SET value='" . serialize($invoice) . "' WHERE code ='invoice_type'";
         \yii::$app->db->createCommand($sql)->execute();
     }
     AdminLog::admin_log('', 'edit', 'shop_config');
     /* 清除缓存 */
     ShopConfig::clearCache();
     if ($type == 'mail_setting') {
         return $this->redirect(Url::to('/config/mail-settings'));
     } else {
         return $this->redirect(\yii\helpers\Url::to('/config/listedit'));
     }
 }
开发者ID:styleyoung,项目名称:taoshop,代码行数:85,代码来源:ConfigController.php

示例15: getProfileUrl

 public static function getProfileUrl($id)
 {
     $user = self::find()->byUserId($id)->one();
     if (file_exists('/upload/' . $user->userProfile->profile_image)) {
         return \yii::getAlias('@profile_url') . $user->profile_image;
     } else {
         return FALSE;
     }
 }
开发者ID:rubedkhan2149,项目名称:2149,代码行数:9,代码来源:User.php


注:本文中的yii::getAlias方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。