• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP YII类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __construct

 public function __construct($url, $passwrod)
 {
     YII::import('application.modules.site.components.sharedkey_api.curl.ACurl');
     $this->type = Yii::app()->params->serviceType;
     $this->host = $url;
     $this->password = $passwrod;
 }
开发者ID:salem-dev-acc,项目名称:yiiapp,代码行数:7,代码来源:serviceAPI.php


示例2: actionSubmit

 public function actionSubmit()
 {
     $data = array('email' => YII::app()->request->getParam('email', null), 'name' => YII::app()->request->getParam('name', null), 'message' => YII::app()->request->getParam('message', null));
     $model = new ContactusForm();
     $model->setAttributes($data);
     $isValid = $model->validate();
     $emails = array(Yii::app()->params['contactusEmail']);
     if (Yii::app()->user->isGuest) {
         if ($model->validate()) {
             $this->_send($model);
             //redirect
             Yii::app()->request->redirect(basePath('contactus/confirm'));
         } else {
             //render errors
             $this->layout = "main";
             $this->render('guest', array('email' => $data['email'], 'name' => $data['name'], 'contact' => Yii::app()->params['contactusEmail'], 'message' => $data['message'], 'errors' => $model->getErrors()));
         }
     } else {
         $model->email = Yii::app()->user->getState('email');
         if ($model->validate()) {
             $this->_send($model);
             //redirect
             Yii::app()->request->redirect(basePath('contactus/confirm'));
         } else {
             //render errors
             $this->layout = "app";
             $this->render('user', array('email' => $data['email'], 'name' => $data['name'], 'contact' => Yii::app()->params['contactusEmail'], 'message' => $data['message'], 'errors' => $model->getErrors()));
         }
     }
 }
开发者ID:salem-dev-acc,项目名称:yiiapp,代码行数:30,代码来源:ContactusController.php


示例3: getPrincipalByPath

 public function getPrincipalByPath($path)
 {
     $base = YII::app()->createUrl("termine/dav", ["termin_id" => $this->termin_id]);
     if ($path == 'principals/guest') {
         return ['{DAV:}displayname' => 'Gast', 'uri' => "principals/guest"];
     }
     return null;
 }
开发者ID:CatoTH,项目名称:Muenchen-Transparent,代码行数:8,代码来源:TermineCalDAVPrincipalBackend.php


示例4: update

 public function update()
 {
     $id = YII::app()->user->getState('id');
     $userApi = sharedkeyApi::create('usersAPI');
     $userApi->addParams(array('id' => $id, 'format' => 'json'));
     $data = $userApi->byid('get');
     $data = json_decode($data);
     $this->setData((array) $data);
     return true;
 }
开发者ID:salem-dev-acc,项目名称:yiiapp,代码行数:10,代码来源:userControl.php


示例5: create

 /**
  *
  * 
  * @param type $name
  * @param type $access
  * @param type $host
  * @return serviceApi 
  */
 static function create($name, $access = 'default')
 {
     $host = YII::app()->params->type;
     $names = explode('.', $name);
     $className = array_pop($names);
     $path = implode('.', $names);
     YII::import('application.modules.site.components.sharedkey_api.services' . $path . '.' . $className);
     $api = new $className(self::getHosts($host), self::getPassword($access));
     return $api;
 }
开发者ID:salem-dev-acc,项目名称:yiiapp,代码行数:18,代码来源:sharedkeyApi.php


示例6: actionEmail

 public function actionEmail()
 {
     $data = $_GET;
     $data['email_confirm'] = isset($data['email']) ? $data['email'] : '';
     $validator = new signUpModel();
     $validator->setAttributes($data);
     $validator->validate();
     $emailError = $validator->getError('email');
     $valid = $emailError != null ? false : true;
     echo json_encode($valid);
     YII::app()->end();
 }
开发者ID:salem-dev-acc,项目名称:yiiapp,代码行数:12,代码来源:ValidationController.php


示例7: actionDeleteActive

 public function actionDeleteActive()
 {
     if ($this->access > UserAccessTable::FULL_ACCESS) {
         return 0;
     }
     $data = array();
     $data['property_id'] = Yii::app()->user->getState('property_id', 0);
     $data['id'] = YII::app()->request->getPost('id', 0);
     $api = sharedkeyApi::create('keycontactAPI');
     $api->addParams($data);
     $result = $api->byContactId('delete');
     $result = json_decode($result);
     $this->renderPartial('delete', array('result' => $result->result));
 }
开发者ID:salem-dev-acc,项目名称:yiiapp,代码行数:14,代码来源:KeycontactsController.php


示例8: loadModel

 public function loadModel()
 {
     $model = null;
     if ($model == null) {
         if (isset($_POST['User']['userId'])) {
             $model = User::model()->findByPk($_POST['User']['userId']);
         } else {
             $model = User::model()->findByPk(YII::app()->user->userId);
         }
         if ($model === null) {
             throw new CHttpException(404, '您访问的用户不存在');
         }
     }
     return $model;
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:15,代码来源:ProfileController.php


示例9: upload

 /**
  *上传多个key不同的文件这里头像解析就要注意了!字段名发生了变化
  * @param        $model
  * @param array  $array  上传表单的attribute
  */
 public function upload($model, $array = array())
 {
     $files = array();
     foreach ($array as $index => $attribute) {
         $attach = CUploadedFile::getInstance($model, $attribute);
         if ($attach) {
             if (isset(YII::app()->user->userId)) {
                 $prefix = YII::app()->user->userId . time() . $index . '.';
             } else {
                 $prefix = md5(microtime()) . $index . '.';
             }
             $imageName = $prefix . $attach->extensionName;
             $attach->saveAs($this->savePath . $imageName);
             $thumbName = $this->saveThumb($prefix, $attach->extensionName);
             $model->{$attribute} = CJSON::encode(array('origin' => $imageName, 'thumb' => $thumbName));
         }
     }
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:23,代码来源:UploadBehavior.php


示例10: run

 public function run()
 {
     echo '<div>';
     if ($this->all_time) {
         echo 'Отработало за ' . sprintf('%0.5f', Yii::getLogger()->getExecutionTime()) . ' с. ';
     }
     if ($this->memory) {
         echo 'Скушано памяти: ' . round(memory_get_peak_usage() / (1024 * 1024), 2) . ' MB';
     }
     echo '<br>';
     $sql_stats = YII::app()->db->getStats();
     if ($this->db_query) {
         echo $sql_stats[0] . ' запросов к БД. ';
     }
     if ($this->db_time) {
         echo 'время выполнения запросов - ' . sprintf('%0.5f', $sql_stats[1]) . ' c.';
     }
     echo '</div>';
 }
开发者ID:rahmanjis,项目名称:yii-catalog,代码行数:19,代码来源:PerformanceStatisticWidget.php


示例11: __construct

 function __construct($topic_name, $identity, $host_name = "kafka")
 {
     $conf = YII::app()->params[$host_name];
     if ($conf == '' || $topic_name == '' || $identity == '') {
         echo "error : no init param";
         exit;
     }
     if (!in_array($identity, array('producer', 'consumer'))) {
         echo "error : wrong identity";
         exit;
     }
     $this->topic_name = $topic_name;
     //初始化全局配置
     $rd_conf = new RdKafka\Conf();
     $rd_conf->set('metadata.broker.list', $conf['host']);
     #$rd_conf -> set('socket.keepalive.enable',true);
     #$rd_conf -> set('log_level',LOG_DEBUG);//Logging level (syslog(3) levels)
     //print_r($rd_conf->dump());exit;
     switch ($identity) {
         case 'producer':
             $rd_conf->set('compression.codec', 'none');
             //Compression codec to use for compressing message sets: none, gzip or snappy;default none
             $this->producer = new RdKafka\Producer($rd_conf);
             break;
         case 'consumer':
             $rd_conf->set('fetch.message.max.bytes', self::CONSUMER_MESSAGE_MAX_BYTES);
             $this->consumer = new RdKafka\Consumer($rd_conf);
             $rd_topic_conf = new RdKafka\TopicConf();
             $back = debug_backtrace();
             $back = $back[1];
             $group = $this->topic_name . "_" . $back['class'] . "_" . $back['function'];
             $rd_topic_conf->set('group.id', $group);
             $rd_topic_conf->set('auto.commit.interval.ms', 1000);
             $rd_topic_conf->set("offset.store.path", $this->offset_path);
             $rd_topic_conf->set('auto.offset.reset', 'smallest');
             //$rd_topic_conf -> set('offset.store.method','broker');//flie(offset.store.path),broker
             //$rd_topic_conf -> set('offset.store.sync.interval.ms',60000);//fsync() interval for the offset file, in milliseconds. Use -1 to disable syncing, and 0 for immediate sync after each write.
             $this->consumer_topic = $this->consumer->newTopic($topic_name, $rd_topic_conf);
             break;
     }
 }
开发者ID:jinglinhu,项目名称:comkafka-php,代码行数:41,代码来源:ComKafka.php


示例12: generarPlantilla

 public static function generarPlantilla($plantilla, $datos, $enPDF = false)
 {
     $contenido = self::obtenerPlantilla($plantilla);
     if ($contenido == false) {
         $resultado = 'No hay plantilla';
     } else {
         $claves = array_keys($datos);
         $valores = array_values($datos);
         foreach ($claves as $indice => $clave) {
             $claves[$indice] = '{' . $clave . '}';
         }
         $resultado = str_replace($claves, $valores, $contenido);
     }
     if ($enPDF) {
         $mpdf = YII::app()->ePdf->mpdf();
         $mpdf->WriteHTML($resultado);
         $mpdf->Output();
     } else {
         echo $resultado;
     }
 }
开发者ID:EPSZ-DAW2,项目名称:daw2-2013-consulta-medico,代码行数:21,代码来源:plantilla.php


示例13: actionAdd

 public function actionAdd()
 {
     $model = new Blogshop();
     $categories = Category::getAllCategories();
     $selected_categories = array();
     if (isset($_POST['Blogshop'])) {
         $model->attributes = $_POST['Blogshop'];
         $model->openidurl = YII::app()->user->id;
         if ($model->validate()) {
             $selected_categories = $_POST['category'];
             Yii::trace(print_r($_POST['category']), 'application');
             if ($model->save()) {
                 $model->addCategories($model->id, $selected_categories);
                 $this->redirect(array('list'));
             } else {
                 throw new CHttpException(500, 'Error in saving Blogshop.');
             }
         }
     }
     $this->render('add', array('model' => $model, 'categories' => $categories, 'selected' => $selected_categories));
 }
开发者ID:sljm12,项目名称:TestDrive,代码行数:21,代码来源:BlogShopController.php


示例14: actionUpdate

 /**
  * UPDATE action. Only accessible by author and admin
  */
 public function actionUpdate($id)
 {
     $post = Post::model()->findByPk($id);
     if (null == $post) {
         throw new CHttpException(404, 'Post not found.');
     }
     if (!Yii::app()->user->isForumAdmin() && YII::app()->user->id != $post->author_id) {
         throw new CHttpException(403, 'You are not allowed to edit this post.');
     }
     $thread = $post->thread;
     if (isset($_POST['Post'])) {
         if (!isset($_POST['YII_CSRF_TOKEN']) || $_POST['YII_CSRF_TOKEN'] != Yii::app()->getRequest()->getCsrfToken()) {
             throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
         }
         $post->attributes = $_POST['Post'];
         if ($post->validate()) {
             $post->save(false);
             $this->redirect($post->thread->url);
         }
     }
     $this->render('editpost', array('model' => $post, 'thread' => $thread));
 }
开发者ID:CrystReal,项目名称:Site_frontend,代码行数:25,代码来源:PostController.php


示例15: actionIndex

 public function actionIndex($propertyId)
 {
     $this->pageName = "billing";
     if (Yii::app()->user->isGuest) {
         $this->redirect(basePath('?url=property/' . $propertyId));
     }
     $this->updateActiveProperty($propertyId);
     $property = Properties::model()->findByPk($propertyId);
     YII::app()->user->setState("redirect_url", null);
     //$property->trialPeriodStartDate != null &&
     if (!UserAccessTable::checkUser2PropertyAccess(Yii::app()->user->getState('id'), $propertyId, UserAccessTable::OWNER)) {
         Yii::app()->user->logout();
         $this->redirect(basePath('?url=property/' . $propertyId));
     }
     $adminMode = false;
     if (UserAccessTable::checkUser2PropertyAccess(Yii::app()->user->getState('id'), Yii::app()->user->getState('property_id'), UserAccessTable::OWNER)) {
         $adminMode = true;
     }
     if ($property->getAttribute('isdeactivated') == 0 && $property->trialPeriodStartDate == null) {
         $this->redirect(basePath('app/properties'));
     }
     //TODO Live
     //        $DaysAfterTrialWhenUserCanReturnProperty = 7;
     //        $TrialPeriod = 31;
     if ($property->trialPeriodStartDate != null) {
         $DaysAfterTrialWhenUserCanReturnProperty = 2;
         $TrialPeriod = 2;
         $allDays = $DaysAfterTrialWhenUserCanReturnProperty + $TrialPeriod;
         $trialStartDate = new DateTime($property->trialPeriodStartDate);
         $trialStartDate->modify("+{$allDays} day");
         $nowDate = new DateTime();
         if ($trialStartDate->format("Y/m/d") < $nowDate->format("Y/m/d")) {
             $this->redirect(basePath('app/properties'));
         }
     }
     $this->render('index', array('errors' => null, 'adminMode' => $adminMode, 'countries' => $this->getCountries(), 'provinces' => $this->getProvinces()));
 }
开发者ID:salem-dev-acc,项目名称:yiiapp,代码行数:37,代码来源:PropertyController.php


示例16: _getSignUpData

 protected function _getSignUpData()
 {
     $allData = array('email', 'email_confirm', 'password', 'password_confirm', 'country', 'firstname', 'lastname', 'phone', 'property_name', 'street_one', 'street_two', 'city', 'state', 'zip', 'property_phone', 'agree', 'PP_FIRSTNAME', 'PP_LASTNAME', 'PP_ACCT', 'PP_CREDITCARDTYPE', 'PP_CCEXPIRYMTH', 'PP_CCEXPIRYYR', 'PP_CVV2', 'PP_COUNTRYCODE', 'PP_STREET', 'PP_CITY', 'PP_STATE', 'PP_ZIP', 'PP_STREET2');
     $data = array();
     foreach ($allData as $item) {
         $data[$item] = YII::app()->user->getFlash('signup_data_' . $item);
     }
     return $data;
 }
开发者ID:salem-dev-acc,项目名称:yiiapp,代码行数:9,代码来源:1+-+MainController.php


示例17: array

echo $form->errorSummary($model);
?>
    
    <?php 
echo $form->textFieldGroup($model, 'name', array('wrapperHtmlOptions' => array('class' => 'col-sm-5')));
?>

    <?php 
echo $form->dropDownListGroup($model, 'yeshuv_id', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => Yeshuv::model()->getYeshuvOptions(), 'htmlOptions' => array())));
?>
    

    <?php 
echo $form->textFieldGroup($model, 'file_name', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('htmlOptions' => array('onClick' => 'js:openKCFinder(this)', 'style' => 'direction:ltr', 'readonly' => true, 'class' => 'default-cursor'))));
?>
</fieldset>        

<div class="form-actions">
        <?php 
$this->widget('booster.widgets.TbButton', array('buttonType' => 'submit', 'context' => 'primary', 'label' => YII::t('default', 'Submit')));
?>
        <?php 
$this->widget('booster.widgets.TbButton', array('buttonType' => 'reset', 'label' => YII::t('default', 'Reset')));
?>
</div>

<?php 
$this->endWidget();
?>

</div><!-- form -->
开发者ID:nurielmeni,项目名称:nymedia,代码行数:31,代码来源:_form.php


示例18: array

<?php

/* @var $this CommercialController */
/* @var $model Commercial */
$this->breadcrumbs = array(YII::t('commercial', 'Commercials') => array('index'), YII::t('default', 'Create'));
$this->menu = array(array('label' => YII::t('commercial', 'List Commercial Area'), 'url' => array('index')), array('label' => YII::t('commercial', 'Manage Commercial Area'), 'url' => array('admin')));
?>

<h1><?php 
echo YII::t('commercial', 'Create Commercial Area');
?>
</h1>

<?php 
$this->renderPartial('_form', array('model' => $model));
开发者ID:nurielmeni,项目名称:nymedia,代码行数:15,代码来源:create.php


示例19: actionDelete

 public function actionDelete()
 {
     if ($this->access > UserAccessTable::FULL_ACCESS) {
         return 0;
     }
     $id = $_POST['id'];
     $calendarModel = new Calendar();
     $calendarModel = $calendarModel->findByPk($id);
     if ($calendarModel == null || $calendarModel == false) {
         echo json_encode(array('result' => 0));
         die;
     }
     $usersEmail = array();
     if (YII::app()->request->getParam('notification', 0) == 1 || YII::app()->request->getParam('notification', 0) == true) {
         $links = $this->getPropertyMembers();
         foreach ($links as $key => $link) {
             array_push($usersEmail, $link['user']['email']);
         }
     }
     $attrs = $calendarModel->attributes;
     $result = $calendarModel->deleteByPk($id);
     $date1 = new DateTime();
     $end_date = date(strtotime($calendarModel->attributes['end_date']));
     $date1->setTimestamp($end_date);
     $real_end_date = $date1->modify('-1 day');
     $end_date1 = $real_end_date->format('F d, Y');
     if ($result == 1 || $result == true) {
         $this->layout = "emailmaster";
         $body = $this->render('../emails/emailCalendar', array('fullname' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'property' => $this->propertyName, 'start' => date('F d, Y', strtotime($attrs['create_date'])), 'end' => $end_date1, 'event' => $attrs['event'], 'message' => $attrs['notes'], 'action' => 'Deleted'), true);
         MailHelper::send($body, "SharedKey.com - " . $this->propertyName . " - Deleted  Calendar Event", $usersEmail);
     }
     echo json_encode(array('result' => $result));
     die;
 }
开发者ID:salem-dev-acc,项目名称:yiiapp,代码行数:34,代码来源:CalendarController.php


示例20: actionUpdate

 public function actionUpdate($id = false, $page = 1)
 {
     $role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id;
     if ($role_id != 7 || $role_id == 7 && $id == 1) {
         $pages = new Pages();
         if (!empty($id) && Pages::model()->existsPage($id)) {
             $active = Modules::model()->getActiveModule($id);
             $model = $pages->findByPk($id);
             if (isset($_POST['Pages'])) {
                 if ($model->validate()) {
                     $old_file_id = $model->image_id;
                     if ($_POST['Pages']['image_id'] == 'NULL') {
                         $_POST['Pages']['image_id'] = '';
                     }
                     $model->attributes = $_POST['Pages'];
                     if ($model->save()) {
                         if ((int) $_POST['Pages']['image_id']) {
                             Files::model()->saveTempFile((int) $_POST['Pages']['image_id']);
                         } elseif ($_POST['Pages']['image_id'] == '') {
                             Files::model()->deleteFile($old_file_id, 'page');
                         }
                         if ($old_file_id != $model->image_id) {
                             Files::model()->deleteFile($old_file_id, 'page');
                         }
                         // Yii::app()->user->setFlash('message','<p style="color:green;">Сохранено</p>');
                         $this->redirect(YII::app()->baseUrl . '/admin.php?r=pages/update&id=' . $id);
                     } else {
                         // Yii::app()->user->setFlash('message','<p style="color:red;">Ошибка</p>');
                     }
                 }
             }
             $image = Pages::model()->getImage($id, 'page');
             $this->pageTitle = 'Редактирование раздела — ' . $model->name;
             $this->render('update', array('model' => $model, 'name' => $model->getPageNameById($id), 'active' => $active, 'image' => $image, 'page' => $page));
         } else {
             $this->redirect(Yii::app()->request->baseUrl);
         }
     } else {
         $this->redirect(Yii::app()->baseUrl . '/admin.php?r=pages/access');
     }
 }
开发者ID:arduanov,项目名称:eco,代码行数:41,代码来源:PagesController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Yaf_Application类代码示例发布时间:2022-05-23
下一篇:
PHP YDForm类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap