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


PHP Yii::app方法代码示例

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


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

示例1: run

 /**
  * Run this widget.
  * This method registers necessary javascript and renders the needed HTML code.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($name, $this->value, $this->htmlOptions);
     }
     $options = CJavaScript::encode($this->options);
     $js = "jQuery('#{$id}').datepicker({$options});";
     if (isset($this->language)) {
         $this->registerScriptFile($this->i18nScriptFile);
         $js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));";
     }
     $cs = Yii::app()->getClientScript();
     $cs->registerScript(__CLASS__, $this->defaultOptions ? 'jQuery.datepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : '');
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
开发者ID:BGCX261,项目名称:zii-svn-to-git,代码行数:32,代码来源:CJuiDatePicker.php

示例2: getPackages

 /**
  * Magic getter. Returns this widget's packages. 
  */
 public function getPackages()
 {
     if (!isset($this->_packages)) {
         $this->_packages = array_merge(parent::getPackages(), array('TwoColumnSortableWidgetManagerJS' => array('baseUrl' => Yii::app()->request->baseUrl, 'js' => array('js/sortableWidgets/TwoColumnSortableWidgetManager.js'), 'depends' => array('SortableWidgetManagerJS'))));
     }
     return $this->_packages;
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:10,代码来源:TwoColumnSortableWidgetManager.php

示例3: run

 public function run($action, $to, $id)
 {
     $to = CActiveRecord::model($this->getController()->CQtreeGreedView['modelClassName'])->findByPk((int) $to);
     $moved = CActiveRecord::model($this->getController()->CQtreeGreedView['modelClassName'])->findByPk((int) $id);
     if (!is_null($to) && !is_null($moved)) {
         try {
             switch ($action) {
                 case 'child':
                     $moved->moveAsLast($to);
                     break;
                 case 'before':
                     if ($to->isRoot()) {
                         $moved->moveAsRoot();
                     } else {
                         $moved->moveBefore($to);
                     }
                     break;
                 case 'after':
                     if ($to->isRoot()) {
                         $moved->moveAsRoot();
                     } else {
                         $moved->moveAfter($to);
                     }
                     break;
             }
         } catch (Exception $e) {
             Yii::app()->user->setFlash('CQTeeGridView', $e->getMessage());
         }
     }
     $this->getController()->redirect(array($this->getController()->CQtreeGreedView['adminAction']));
 }
开发者ID:kostya1017,项目名称:our,代码行数:31,代码来源:MoveNode.php

示例4: request

 /**
  * @param string $url
  * @param string $method
  * @param string $body
  *
  * @return FhirResponse
  */
 public function request($url, $method = 'GET', $body = null)
 {
     $server_name = null;
     foreach ($this->servers as $name => $server) {
         if (substr($url, 0, strlen($server['base_url']))) {
             $server_name = $name;
             break;
         }
     }
     $this->applyServerConfig($server_name ? $this->servers[$server_name] : array());
     $this->http_client->setUri($url);
     $this->http_client->setMethod($method);
     if ($body) {
         $this->http_client->setRawData($body, 'application/xml+fhir; charset=utf-8');
     }
     $response = $this->http_client->request();
     $this->http_client->resetParameters();
     if ($body = $response->getBody()) {
         $use_errors = libxml_use_internal_errors(true);
         $value = Yii::app()->fhirMarshal->parseXml($body);
         $errors = libxml_get_errors();
         libxml_use_internal_errors($use_errors);
         if ($errors) {
             throw new Exception("Error parsing XML response from {$method} to {$url}: " . print_r($errors, true));
         }
     } else {
         $value = null;
     }
     return new FhirResponse($response->getStatus(), $value);
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:37,代码来源:FhirClient.php

示例5: run

 /**
  * Renders the content of the widget.
  * @throws CException
  */
 public function run()
 {
     // Hide empty breadcrumbs.
     if (empty($this->links)) {
         return;
     }
     $links = array();
     if (!isset($this->homeLink)) {
         $content = CHtml::link(Yii::t('zii', 'Inicio'), Yii::app()->homeUrl);
         $links[] = $this->renderItem($content);
     } else {
         if ($this->homeLink !== false) {
             $links[] = $this->renderItem($this->homeLink);
         }
     }
     foreach ($this->links as $label => $url) {
         if (is_string($label) || is_array($url)) {
             $content = CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url);
             $links[] = $this->renderItem($content);
         } else {
             $links[] = $this->renderItem($this->encodeLabel ? CHtml::encode($url) : $url, true);
         }
     }
     echo CHtml::tag('ul', $this->htmlOptions, implode('', $links));
 }
开发者ID:VrainSystem,项目名称:Proyecto_PROFIT,代码行数:29,代码来源:TbBreadcrumbs.php

示例6: actionRegister

 /**
  * Creates account for new users
  */
 public function actionRegister()
 {
     if (!Yii::app()->user->isGuest) {
         Yii::app()->request->redirect('/');
     }
     $user = new User('register');
     $profile = new UserProfile();
     if (Yii::app()->request->isPostRequest && isset($_POST['User'], $_POST['UserProfile'])) {
         $user->attributes = $_POST['User'];
         $profile->attributes = $_POST['UserProfile'];
         $valid = $user->validate();
         $valid = $profile->validate() && $valid;
         if ($valid) {
             $user->save();
             $profile->save();
             $profile->setUser($user);
             // Add user to authenticated group
             Yii::app()->authManager->assign('Authenticated', $user->id);
             $this->addFlashMessage(Yii::t('UsersModule.core', 'Спасибо за регистрацию на нашем сайте.'));
             // Authenticate user
             $identity = new UserIdentity($user->username, $_POST['User']['password']);
             if ($identity->authenticate()) {
                 Yii::app()->user->login($identity, Yii::app()->user->rememberTime);
                 Yii::app()->request->redirect($this->createUrl('/users/profile/index'));
             }
         }
     }
     $this->render('register', array('user' => $user, 'profile' => $profile));
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:32,代码来源:RegisterController.php

示例7: checkAccess

 public function checkAccess()
 {
     // Save users last action on this space
     $membership = $this->space->getMembership(Yii::app()->user->id);
     if ($membership != null) {
         $membership->updateLastVisit();
     } else {
         // Super Admin can always enter
         if (!Yii::app()->user->isAdmin()) {
             // Space invisible?
             if ($this->space->visibility == Space::VISIBILITY_NONE) {
                 // Not Space Member
                 throw new CHttpException(404, Yii::t('SpaceModule.behaviors_SpaceControllerBehavior', 'Space is invisible!'));
             }
         }
     }
     // Delete all pending notifications for this space
     $notifications = Notification::model()->findAllByAttributes(array('space_id' => $this->space->id, 'user_id' => Yii::app()->user->id), 'seen != 1');
     foreach ($notifications as $n) {
         // Ignore Approval Notifications
         if ($n->class == "SpaceApprovalRequestNotification" || $n->class == "SpaceInviteNotification") {
             continue;
         }
         $n->seen = 1;
         $n->save();
     }
 }
开发者ID:alefernie,项目名称:intranet,代码行数:27,代码来源:SpaceControllerBehavior.php

示例8: makeBuilderPredefinedEmailTemplate

 protected function makeBuilderPredefinedEmailTemplate($name, $unserializedData, $subject = null, $modelClassName = null, $language = null, $type = null, $isDraft = 0, $textContent = null, $htmlContent = null)
 {
     $emailTemplate = new EmailTemplate();
     $emailTemplate->type = $type;
     //EmailTemplate::TYPE_WORKFLOW;
     $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE;
     $emailTemplate->isDraft = $isDraft;
     $emailTemplate->modelClassName = $modelClassName;
     $emailTemplate->name = $name;
     if (empty($subject)) {
         $subject = $name;
     }
     $emailTemplate->subject = $subject;
     if (!isset($language)) {
         $language = Yii::app()->languageHelper->getForCurrentUser();
     }
     $emailTemplate->language = $language;
     $emailTemplate->htmlContent = $htmlContent;
     $emailTemplate->textContent = $textContent;
     $emailTemplate->serializedData = CJSON::encode($unserializedData);
     $emailTemplate->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
     $saved = $emailTemplate->save(false);
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
     $emailTemplate = EmailTemplate::getById($emailTemplate->id);
     ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($emailTemplate, Group::getByName(Group::EVERYONE_GROUP_NAME));
     $saved = $emailTemplate->save(false);
     assert('$saved');
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:30,代码来源:EmailTemplatesBaseDefaultDataMaker.php

示例9: error

 /**
  *  $controller::$configuration['statusKey'] = 'status' by default
  * $controller::$configuration['statusError'] = 'error' by default
  * $controller::$configuration['resourceKey'] = 'resource' by default
  * $controller::$configuration['errorDescriptionKey'] = 'errorDescription' by default
  * @param string $errorCode is a key of Response::$errorDictionary array.
  * @param array $errorresource null by default. Can be added to specify error body (resource) of response
  * @return array  prepeared to be JSON encoded 
  */
 public static function error($errorCode, $errorresource = null)
 {
     $controller = Yii::app()->controller;
     $errorDescription = self::errorDescription($errorCode);
     self::$response = array($controller::$configuration['statusKey'] => $controller::$configuration['statusError'], $controller::$configuration['statusError'] => array($controller::$configuration['errorCodeKey'] => $errorCode, $controller::$configuration['errorDescriptionKey'] => $errorDescription, $controller::$configuration['resourceKey'] => $errorresource));
     return self::get();
 }
开发者ID:rosko,项目名称:backvendor,代码行数:16,代码来源:Response.php

示例10: authenticate

 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $identity = new UserIdentity($this->username, $this->password);
         $identity->authenticate();
         switch ($identity->errorCode) {
             case UserIdentity::ERROR_NONE:
                 $duration = $this->rememberMe ? Yii::app()->controller->module->rememberMeTime : 0;
                 Yii::app()->user->login($identity, $duration);
                 break;
             case UserIdentity::ERROR_EMAIL_INVALID:
                 $this->addError("username", t("Email is incorrect."));
                 break;
             case UserIdentity::ERROR_USERNAME_INVALID:
                 $this->addError("username", t("Username is incorrect."));
                 break;
             case UserIdentity::ERROR_STATUS_NOTACTIV:
                 $this->addError("status", t("You account is not activated."));
                 break;
             case UserIdentity::ERROR_STATUS_BAN:
                 $this->addError("status", t("You account is blocked."));
                 break;
             case UserIdentity::ERROR_PASSWORD_INVALID:
                 $this->addError("password", t("Password is incorrect."));
                 break;
         }
     }
 }
开发者ID:kosenka,项目名称:yboard,代码行数:32,代码来源:UserLogin.php

示例11: getBanners

 protected function getBanners()
 {
     // images at {theme_path}/bnr
     $base_url = Yii::app()->theme->baseUrl;
     // 150x40
     $banners[] = array('link' => 'http://www.adyra.com', 'image' => $base_url . '/bnr/adyra.png');
     //$banners[] = array('link' => 'http://www.grupomoyvesa.com', 'image' => $base_url.'/bnr/moyvesa.png');
     //$banners[] = array('link' => 'http://www.melicar.com', 'image' => $base_url.'/bnr/melicar.png');
     //$banners[] = array('link' => 'http://www.fiateira.com', 'image' => $base_url.'/bnr/fiateira.png');
     $banners[] = array('link' => 'http://www.llantaslandin.com', 'image' => $base_url . '/bnr/landin.png');
     $banners[] = array('link' => 'http://www.grupotrigocar.com', 'image' => $base_url . '/bnr/trigocar.png');
     $banners[] = array('link' => 'http://www.imgautosubastas.com', 'image' => $base_url . '/bnr/imgautosubastas.png');
     $banners[] = array('link' => 'http://www.autosrema.com', 'image' => $base_url . '/bnr/rema.png');
     $banners[] = array('link' => 'http://www.automovilesmlosada.com', 'image' => $base_url . '/bnr/losada.png');
     $banners[] = array('link' => 'http://www.carballeiraautomocion.com', 'image' => $base_url . '/bnr/carballeira.png');
     $banners[] = array('link' => '#', 'image' => $base_url . '/bnr/monterey.png');
     $banners[] = array('link' => '#', 'image' => $base_url . '/bnr/mediodia.png');
     $banners[] = array('link' => 'http://www.donsilencioso.com', 'image' => $base_url . '/bnr/donsilencioso.png');
     $banners[] = array('link' => 'http://www.hangar.es', 'image' => $base_url . '/bnr/hangar.png');
     $banners[] = array('link' => 'http://rysservicios.com/', 'image' => $base_url . '/bnr/rys.png');
     // talleresmonterrey
     // talleresmediodia
     // donsilencioso
     shuffle($banners);
     return $banners;
 }
开发者ID:CHILMEX,项目名称:amocasion,代码行数:26,代码来源:Banners.php

示例12: authenticate

 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $identity = new UserIdentity($this->username, $this->password);
         $identity->authenticate();
         switch ($identity->errorCode) {
             case UserIdentity::ERROR_NONE:
                 $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
                 // 30 days
                 Yii::app()->user->login($identity, $duration);
                 break;
             case UserIdentity::ERROR_USERNAME_INVALID:
                 $this->addError('username', Yii::t('lan', 'Username is incorrect.'));
                 break;
             case UserIdentity::ERROR_BANNED:
                 $this->addError('username', Yii::t('lan', 'User is banned.'));
                 break;
             case UserIdentity::ERROR_CONFIRMREGISTRATION:
                 $this->addError('username', Yii::t('lan', 'Confirm user email.'));
                 break;
             default:
                 $this->addError('password', Yii::t('lan', 'Password is incorrect.'));
                 break;
         }
     }
 }
开发者ID:Greka163,项目名称:Yii-blog-new,代码行数:30,代码来源:LoginForm.php

示例13: onBeforeGrid

 /**
  * Позволяет тонко сконфигурировать грид перед самой отрисовкой
  *
  * @param BeforeGridEvent $event
  */
 public function onBeforeGrid(BeforeGridEvent $event)
 {
     if (isset(Yii::app()->controller->buttons)) {
         foreach (Yii::app()->controller->buttons as $key => $buttonConfig) {
             if (isset($buttonConfig['code']) && $buttonConfig['code'] == 'create') {
                 // Модули - типы создаваемого экземпляра
                 $addButtonData = null;
                 $phpScripts = PhpScript::model()->findAllByAttributes(array('id_php_script_interface' => PhpScript::ID_PHP_SCRIPT_INTERFACE_MODULE));
                 if (count($phpScripts) > 0) {
                     $addButtonData = '<button class="btn navbar-btn btn-success dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>';
                     $addButtonData .= '<ul class="dropdown-menu">' . "\n";
                     foreach ($phpScripts as $phpScript) {
                         /**
                          * @var $phpScript PhpScript
                          */
                         $linkModule = ObjectUrlRule::createUrlFromCurrent(BackendModule::ROUTE_INSTANCE_LIST, array(ObjectUrlRule::PARAM_OBJECT_INSTANCE => -1, ObjectUrlRule::PARAM_SYSTEM_MODULE => $phpScript->id_php_script_type));
                         $addButtonData .= "<li><a href='" . $linkModule . "'>" . $phpScript->description . "</a></li>";
                     }
                     $addButtonData .= '</ul>' . "\n";
                 }
                 $buttonConfig['addButtonData'] = $addButtonData;
                 Yii::app()->controller->buttons[$key] = $buttonConfig;
                 break;
             }
         }
     }
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:32,代码来源:SiteModuleEventHandler.php

示例14: up

 public function up()
 {
     $sql = "SELECT a.id addressId,\n\t\t\t\tp.pro_id as propertyId,\n\t\t\t\tp.pro_addr1,p.pro_addr2,p.pro_addr3,p.pro_addr4,p.pro_addr5,p.pro_postcode,\n\t\t\t\ta.line1,a.line2,a.line3,a.line4,a.line5,a.postcode,\n\n\t\t\t\tconcat_ws(' ', p.pro_addr1, p.pro_addr2, p.pro_addr3, p.pro_addr4, p.pro_addr5, p.pro_postcode) as propertyRecordAddress,\n\t\t\t\tconcat_ws(' ', a.line1,a.line2,a.line3,a.line4,a.line5,a.postcode) as AddressRecord\n\n\t\t\t\tFROM property p\n\t\t\t\tLEFT JOIN address a on p.addressId = a.id\n\t\t\t\tWHERE\n\t\t\t\treplace(concat_ws('', p.pro_addr1, p.pro_addr2, p.pro_addr3, p.pro_addr4, p.pro_addr5, p.pro_postcode), ' ', '') != replace(concat_ws('', a.line1,a.line2,a.line3,a.line4,a.line5,a.postcode), ' ', '')\n\t\t\t\tOR p.addressId is null\n\t\t\t\tOR p.addressId = 0";
     $insertIntoAddress = "\n\t\t\t\tINSERT INTO address SET\n\t\t\t\tline1 = :pro_addr1,\n\t\t\t\tline2 = :pro_addr2,\n\t\t\t\tline3 = :pro_addr3,\n\t\t\t\tline4 = :pro_addr4,\n\t\t\t\tline5 = :pro_addr5,\n\t\t\t\tpostcode = :pro_postcode";
     $updatePropertyAddress = "\n\t\t\t\t\t\t\t\tUPDATE property SET\n\t\t\t\t\t\t\t\tpro_addr1 = :line1,\n\t\t\t\t\t\t\t\tpro_addr2 = :line2,\n\t\t\t\t\t\t\t\tpro_addr3 = :line3,\n\t\t\t\t\t\t\t\tpro_addr4 = :line4,\n\t\t\t\t\t\t\t\tpro_addr5 = :line5,\n\t\t\t\t\t\t\t\tpro_postcode = :postcode\n\t\t\t\t\t\t\t\tWHERE pro_id = :propertyId";
     $updatePropertyAddressId = "UPDATE property SET addressId = :addressId WHERE pro_id = :propertyId";
     $updatePropertyAddressId = Yii::app()->db->createCommand($updatePropertyAddressId);
     $insertIntoAddress = Yii::app()->db->createCommand($insertIntoAddress);
     $updatePropertyAddress = Yii::app()->db->createCommand($updatePropertyAddress);
     //PREPARE QUERIES
     $data = Yii::app()->db->createCommand($sql)->queryAll();
     foreach ($data as $value) {
         if ($value['addressId']) {
             // has address ID => address changed and needs to be synchronized with pro_address
             $updatePropertyAddress->execute(array('line1' => $value['line1'], 'line2' => $value['line2'], 'line3' => $value['line3'], 'line4' => $value['line4'], 'line5' => $value['line5'], 'postcode' => $value['postcode'], 'propertyId' => $value['propertyId']));
         } else {
             if (trim($value['propertyRecordAddress'])) {
                 // has pro_address fields but no related address object.
                 $insertIntoAddress->execute(array('pro_addr1' => $value['pro_addr1'], 'pro_addr2' => $value['pro_addr2'], 'pro_addr3' => $value['pro_addr3'], 'pro_addr4' => $value['pro_addr4'], 'pro_addr5' => $value['pro_addr5'], 'pro_postcode' => $value['pro_postcode']));
                 // set addressID of property to correct value
                 $updatePropertyAddressId->execute(array('addressId' => Yii::app()->db->getLastInsertID(), 'propertyId' => $value['propertyId']));
             }
         }
     }
     return true;
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:26,代码来源:m121205_132749_update_proerty_address_from_table_property_to_address.php

示例15: run

 /**
  * Runs the widget.
  */
 public function run()
 {
     $id = $this->id;
     echo '</div>';
     /** @var CClientScript $cs */
     $cs = Yii::app()->getClientScript();
     $options = CJavaScript::encode($this->options);
     $cs->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').modal({$options});");
     // Register the "show" event-handler.
     if (isset($this->events['show'])) {
         $fn = CJavaScript::encode($this->events['show']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.show', "jQuery('#{$id}').on('show', {$fn});");
     }
     // Register the "shown" event-handler.
     if (isset($this->events['shown'])) {
         $fn = CJavaScript::encode($this->events['shown']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.shown', "jQuery('#{$id}').on('shown', {$fn});");
     }
     // Register the "hide" event-handler.
     if (isset($this->events['hide'])) {
         $fn = CJavaScript::encode($this->events['hide']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.hide', "jQuery('#{$id}').on('hide', {$fn});");
     }
     // Register the "hidden" event-handler.
     if (isset($this->events['hidden'])) {
         $fn = CJavaScript::encode($this->events['hidden']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.hidden', "jQuery('#{$id}').on('hidden', {$fn});");
     }
 }
开发者ID:laiello,项目名称:what-i-need,代码行数:32,代码来源:BootModal.php


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