本文整理汇总了PHP中yii类的典型用法代码示例。如果您正苦于以下问题:PHP yii类的具体用法?PHP yii怎么用?PHP yii使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了yii类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: actionView
public function actionView()
{
$radioId = Yii::app()->request->getParam("id", 0);
$radioName = WapRadioModel::model()->findByPk($radioId)->name;
$albumId = WapRadioModel::model()->getAlbumByRadio($radioId, "c2.id");
$radioAvatar = RadioModel::model()->getAvatarUrl($radioId, 's1');
$album = WapAlbumModel::model()->published()->findByPk($albumId);
if (!$album) {
$this->forward("/site/error", true);
}
$songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($albumId);
$artists = AlbumArtistModel::model()->getArtistsByAlbum($albumId);
$phone = yii::app()->user->getState('msisdn');
$errorCode = 'success';
$errorDescription = '';
$registerText = WapAlbumModel::model()->getCustomMetaData('REG_TEXT');
///meta tag
$AlbumDetail = AlbumModel::model()->findByPk($albumId);
$artistId = !empty($artists) ? $artists[0]->artist_id : $AlbumDetail->artist_id;
$ArtistInfo = ArtistModel::model()->findByPk($artistId);
$this->itemName = $AlbumDetail->name;
$this->artist = $ArtistInfo->name;
$this->thumb = AlbumModel::model()->getAvatarUrl($albumId, 's1');
$this->url = URLHelper::buildFriendlyURL("album", $albumId, Common::makeFriendlyUrl($ArtistInfo->name));
$this->description = strip_tags($AlbumDetail->description);
//get other radio
$parent_id = Yii::app()->params['horoscope']['parent_id'];
$radioListOther = WapRadioModel::model()->getHoroscopes($parent_id);
$this->render('detail', array('album' => $album, 'songsOfAlbum' => $songsOfAlbum, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'registerText' => $registerText, 'radioListOther' => $radioListOther, 'radioAvatar' => $radioAvatar));
}
开发者ID:giangnh264,项目名称:mobileplus,代码行数:30,代码来源:HoroscopesController.php
示例3: isItSelfContact
/**
* validate, if its actual user contacts sor actions:
* - editableSaver
* - ajaxCreate
* - delete
* @return boolean
*/
public static function isItSelfContact()
{
$ppcn_id = false;
$action = Yii::app()->controller->action->id;
switch (Yii::app()->controller->action->id) {
//update
case 'editableSaver':
$ppcn_id = yii::app()->request->getParam('pk');
//delete
//delete
case 'delete':
if (!$ppcn_id) {
$ppcn_id = yii::app()->request->getParam('ppcn_id');
}
if (!$ppcn_id) {
return false;
}
$ppcn = PpcnPersonContact::model()->findByPk($ppcn_id);
if (!$ppcn || $ppcn->ppcnPprs->pprs_id != Yii::app()->getModule('user')->user()->profile->person_id) {
return false;
}
break;
//create
//create
case 'ajaxCreate':
if (yii::app()->request->getParam('value') != Yii::app()->getModule('user')->user()->profile->person_id) {
return false;
}
break;
default:
return false;
break;
}
return true;
}
开发者ID:dbrisinajumi,项目名称:d2person,代码行数:42,代码来源:PpcnPersonContactController.php
示例4: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($idobservacion)
{
$model = new Observacionesdetalle();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Observacionesdetalle'])) {
$model->attributes = $_POST['Observacionesdetalle'];
$model->hidobservaciones = $idobservacion;
$model->usuario = Yii::app()->user->name;
$model->fecha = date("d-m-Y H:i:s");
if ($model->save()) {
$modeloinventario = Observaciones::model()->findByPk($idobservacion);
}
if (!$this->enviamail($modeloinventario, $model->comentario)) {
echo "fallo";
yii::app()->end();
}
$model->refresh();
if (!empty($_GET['asDialog'])) {
//Close the dialog, reset the iframe and update the grid
echo CHtml::script("window.parent.\$('#cru-dialog1').dialog('close');\n\t\t\t\t\t\t\t\t\t\t\t\t\t window.parent.\$('#cru-frame1').attr('src','');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twindow.parent.\$.fn.yiiGridView.update('{$_GET['gridId']}');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
Yii::app()->end();
}
$this->render('Confirma', array('id' => $model->id));
Yii::app()->end();
//$this->redirect(array('view','id'=>$model->id));
}
$this->layout = '//layouts/iframe';
$this->render('create', array('model' => $model, 'idobservacion' => $idobservacion));
}
开发者ID:hipogea,项目名称:zega,代码行数:34,代码来源:ObservacionesdetalleController.php
示例5: init
public function init()
{
parent::init();
// custom initialization code goes here
\yii::configure($this, require __DIR__ . '/config.php');
$this->params['maxPostCount'] = 50;
}
开发者ID:xiaohongyang,项目名称:yii_shop,代码行数:7,代码来源:AdminModule.php
示例6: actionIndex
/**
* Lists all Country models.
* @return mixed
*/
public function actionIndex()
{
yii::warning('yyy aaa ', __METHOD__);
$searchModel = new CountrySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
}
开发者ID:yunlongmain,项目名称:yii2-test,代码行数:11,代码来源:CountryController.php
示例7: hayerrores
public function hayerrores($codocu)
{
if (count($_SESSION[self::NOMBRE_SESION][yii::app()->user->id][$codocu]) > 0) {
return $_SESSION[self::NOMBRE_SESION][yii::app()->user->id][$codocu];
}
return null;
}
开发者ID:hipogea,项目名称:zega,代码行数:7,代码来源:MensajesCompo.php
示例8: admin_log
/**
* 记录管理员的操作内容
*
* @access public
* @param string $sn 数据的唯一值
* @param string $action 操作的类型
* @param string $content 操作的内容
* @return void
*/
public static function admin_log($sn = '', $action, $content)
{
$log_info = \yii::t('log', $action) . \yii::t('log', $content) . ":" . Html::encode($sn);
$time = time();
$sql = "INSERT INTO " . self::tableName() . " (log_time,user_id,log_info,ip_address) " . " VALUES ('{$time}','" . \yii::$app->user->id . "','" . Html::encode($log_info) . "','" . \yii::$app->request->userIP . "')";
return \yii::$app->getDb()->createCommand($sql)->execute();
}
开发者ID:styleyoung,项目名称:taoshop,代码行数:16,代码来源:AdminLog.php
示例9: 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
示例10: run
public function run()
{
if ($sourcetype == '') {
$sourcetype = 37;
}
$connection = yii::app()->db;
$tracked_userid = Yii::app()->session['login']['id'];
$Criteria = new CDbCriteria();
$Criteria->condition = "upload_sourceid = '" . $this->sourceid . "' AND tracked_userid ='" . $tracked_userid . "'and upload_sourcetype='" . $this->sourcetype . "' and view_status=0 and block_status=0";
$Criteria->order = "note_id DESC";
$note = Notess::model()->findAll($Criteria);
foreach ($note as $notes) {
$ids[] = $notes->tracker_userid;
}
$Criteria->join = 'join fn_users as t1 on t1.userid = t.tracker_userid ';
$Criteria->join .= 'join fn_contentnote as t2 on t2.id = t.contentnote_id ';
$Criteria->addInCondition('t.tracker_userid', $ids);
//$Criteria->group = 't.tracker_userid';
$Criteria->select = "t.*,t1.fname,t2.name";
$note = Notess::model()->findAll($Criteria);
$content_note = Contentnote::model()->findAll();
//echo $content_note->contentnote_id;
//print_r($content_note);
/*SELECT t.*,t1.fname FROM `fn_notes` as t
join fn_users as t1
on t1.userid = t.tracker_userid
WHERE t.`tracker_userid` in (616,115)
group by t.`tracker_userid`*/
//echo count($note);
$this->render('_note', array('type' => $this->widgettype, 'i' => $this->i, 'sourceid' => $this->sourceid, 'userid' => $this->userid, 'uname' => $this->uname, 'sourcetype' => $this->sourcetype, 'notek' => $note, 'result' => $content_note));
}
开发者ID:gopi158,项目名称:Sample,代码行数:31,代码来源:Notestest_261213.php
示例11: beforeSave
public function beforeSave()
{
if ($this->isNewRecord) {
$this->iduser = yii::app()->user->id;
}
return parent::beforeSave();
}
开发者ID:hipogea,项目名称:experimento,代码行数:7,代码来源:Listamateriales.php
示例12: checkpermission
/**
* example:
* $permissionName can be
* action
* controller/action
* module/controller/action
* @param string $permissionName Permisssion Name
* @return array Array of formated Data
*/
protected function checkpermission($permissionName)
{
$return = [];
$pm_list = explode('/', $permissionName);
if (is_array($pm_list)) {
$count = count($pm_list);
switch ($count) {
case 1:
if ($permissionName == \Yii::$app->controller->module->id) {
$return = ['module' => \Yii::$app->controller->module->id];
} else {
$return = ['module' => \Yii::$app->controller->module->id, 'controller' => \Yii::$app->controller->id, 'action' => $permissionName];
}
break;
case 2:
$return = ['module' => \Yii::$app->controller->module->id, 'controller' => $pm_list[0], 'action' => $pm_list[1]];
break;
case 3:
$controller = $pm_list[1];
$module = $pm_list[0];
$action = $pm_list[2];
$return = ['module' => $pm_list[0], 'controller' => $pm_list[1], 'action' => $pm_list[2]];
break;
}
\yii::trace(print_r($return, true));
} else {
$controller = \Yii::$app->controller;
$module = $controller->module->id;
$action = $permissionName;
$return = ['module' => $module, 'controller' => $controller, 'action' => $action];
}
return $return;
}
开发者ID:mithun12000,项目名称:yii2-usermanage,代码行数:42,代码来源:PermissionManager.php
示例13: renderContent
protected function renderContent()
{
yii::beginProfile('loc');
$session = new CHttpSession();
$session->open();
$newCountry = $this->newCountry ? $this->newCountry : ($session['top-country'] ? $session['top-country'] : $this->defaultCountry);
$session['top-country'] = $newCountry;
$newCity = $this->newCity ? $this->newCity : ($session['top-city'] ? $session['top-city'] : $this->defaultCity);
$session['top-location'] = $newCity;
if ($newCountry == "international") {
$country = 'international';
$city = GeoCityApi::getCityByName($newCity);
if ($city) {
$cities = GeoCityApi::getTopPrioritiesInternational($city->id);
} else {
$cities = GeoCityApi::getTopPrioritiesInternational();
}
} else {
$country = GeoCountryApi::getCountryByName($newCountry);
$city = GeoCityApi::getCityByName($newCity);
if ($country && $city) {
$cities = GeoCityApi::getTopPrioritiesByCountry($country->id, $city->id);
} elseif ($country) {
$cities = GeoCityApi::getTopPrioritiesByCountry($country->id);
}
}
if ($country && $cities) {
$this->render('topLocation', array('city' => $city, 'country' => $country, 'current' => $this->current, 'cities' => $cities));
}
yii::endProfile('loc');
}
开发者ID:romeo14,项目名称:wallfeet,代码行数:31,代码来源:TopLocation.php
示例14: actionUpdate
public function actionUpdate()
{
$pictures = array();
$lid = Yii::app()->request->getParam('lid');
Until::isUpdateValid(array($lid), $this->companyId, $this);
//0,表示企业任何时候都在云端更新。
$criteria = new CDbCriteria();
$criteria->with = 'productImg';
$criteria->addCondition('t.lid=:lid and t.dpid=:dpid and t.delete_flag=0 ');
$criteria->order = ' t.lid desc ';
$criteria->params[':lid'] = $lid;
$criteria->params[':dpid'] = $this->companyId;
$model = Product::model()->find($criteria);
if (Yii::app()->request->isPostRequest) {
$postData = Yii::app()->request->getPost('productImg');
if (ProductPicture::saveImg($this->companyId, $lid, $postData)) {
Yii::app()->user->setFlash('success', yii::t('app', '修改成功'));
$this->redirect(array('productImg/index', 'companyId' => $this->companyId));
}
}
if (!empty($model->productImg)) {
foreach ($model->productImg as $pic) {
array_push($pictures, $pic->pic_path);
}
}
$this->render('updateProductImg', array('model' => $model, 'pictures' => $pictures));
}
开发者ID:song-yuan,项目名称:wymenujp,代码行数:27,代码来源:ProductImgController.php
示例15: actionSaveNew
public function actionSaveNew()
{
try {
$channelName = Yii::app()->request->getParam('channelName');
$contentType = Yii::app()->request->getParam('contentType');
$channelType = Yii::app()->request->getParam('channelType');
$channelIdentify = Yii::app()->request->getParam('channelIdentify');
$pid = yii::app()->request->getParam('pid');
$list = TSChannel::model()->findAll('Channel_Identify=:channelIdentify', array(':channelIdentify' => $channelIdentify));
if (count($list) >= 1) {
$result = array('flag' => 'ERROR', 'message' => '栏目标识符已经存在!');
echo json_encode($result, JSON_UNESCAPED_UNICODE);
} else {
$model = new TSChannel();
$model->Channel_Pid = $pid;
$model->Channel_Is_Title = $contentType;
$model->Channel_Is_Parent = $channelType == '0' ? 'true' : 'false';
$model->Channel_Name = $channelName;
$model->Channel_Is_Open = 'true';
$model->Channel_Identify = $channelIdentify;
$flag = $model->save();
$result = array('flag' => 'SUCCESS', 'message' => '栏目添加成功!', 'newNodes' => array('id' => $model->Id, 'name' => $model->Channel_Name, 'pId' => $model->Channel_Pid, 'isParent' => $model->Channel_Is_Parent, 'open' => $model->Channel_Is_Open));
echo json_encode($result, JSON_UNESCAPED_UNICODE);
}
} catch (Exception $e) {
$result = array('flag' => 'Exception', 'message' => $e->getMessage());
echo json_encode($result, JSON_UNESCAPED_UNICODE);
}
}
开发者ID:JavaBird,项目名称:Easy3W,代码行数:29,代码来源:ChannelController.php
示例16: 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
示例17: actionAlarm
public function actionAlarm()
{
$mes = $_REQUEST['ids'];
$mes = json_decode($mes, true);
$res = array();
//获取的是一个RFID数组
foreach ($mes as $key => $value) {
$data = AsAsset::model()->findByPk($value);
if (is_null($data)) {
$res[] = array("id" => $value, "name" => 'null', "alarm" => 0);
} else {
if ($data['outPrm'] == 'y') {
if ($data['state'] == 'out') {
// echo "1";
$res[] = array("id" => $data['RFID'], "name" => $data['assetName'], "alarm" => 0);
} elseif ($data['state'] == 'in') {
// echo "2";
$res[] = array("id" => $data['RFID'], "name" => $data['assetName'], "alarm" => 1);
$mes = "RFID:" . $value . "原因:该商品显示在库存中";
yii::log($mes, "info", "alarm.log");
//将报警信息写入日志
}
} else {
$mes = "RFID:" . $value . "原因:该商品不允许外借";
yii::log($mes, "info", "alarm.log");
$res[] = array("id" => $data['RFID'], "name" => $data['assetName'], "alarm" => 1);
}
}
}
//返回值的形式为RFID,assetName,alarm(1是报警,0是不报警)
$res1 = json_encode($res);
echo $res1;
}
开发者ID:jiahongwei,项目名称:newland-project,代码行数:33,代码来源:AssetAlarmController.php
示例18: actionLogin
/**
* User login
*/
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$userDriver = isset(\Yii::$app->params['user_driver']) == true && empty(\Yii::$app->params['user_driver']) == false ? strtolower(\Yii::$app->params['user_driver']) : 'local';
if ($userDriver == 'ldap') {
if (isset(\Yii::$app->params['ldap']) == false) {
throw new \Exception(yii::t('walle', 'the login dirver configs does not defined', array('loginType' => \Yii::$app->params['user_driver'])));
}
if (is_array(\Yii::$app->params['ldap']) == false) {
throw new \Exception(yii::t('walle', 'the login dirver configs parse error', array('loginType' => \Yii::$app->params['user_driver'])));
}
$model = new LdapLoginForm(\Yii::$app->params['ldap']);
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', ['isLdapLigin' => true, 'model' => $model]);
}
} elseif ($userDriver == 'local') {
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', ['isLdapLigin' => false, 'model' => $model]);
}
} else {
throw new \Exception(yii::t('walle', 'login type could not support', array('loginType' => \Yii::$app->params['user_driver'])));
}
}
开发者ID:meolu,项目名称:walle-web,代码行数:33,代码来源:SiteController.php
示例19: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$pageSize = Yii::app()->request->getParam('pageSize', Yii::app()->params['pageSize']);
Yii::app()->user->setState('pageSize', $pageSize);
$model = new RejectModel('search');
$model->unsetAttributes();
// clear any default values
//lay mang phone
$phone = Yii::app()->request->getParam('phone');
$phoneModel = RejectModel::model()->findByAttributes(array('phone' => $phone));
if (empty($phoneModel)) {
$model = new RejectModel();
$model->phone = $phone;
try {
if ($model->save()) {
$message = yii::t('SpamModule', 'Success!');
} else {
$message = yii::t('SpamModule', 'Insert fail');
}
} catch (Exception $exc) {
echo $exc->getTrace();
}
} else {
$message = yii::t('SpamModule', 'The number had exists');
}
echo $message;
}
开发者ID:giangnh264,项目名称:mobileplus,代码行数:31,代码来源:RejectController.php
示例20: 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
注:本文中的yii类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论