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


PHP Yii::App方法代码示例

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


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

示例1: actionSearch

 function actionSearch($q = null, $page = 1)
 {
     $pages = new CPagination();
     $pages->pageSize = 50;
     $pages->currentPage = $page;
     $p = new CHtmlPurifier();
     $q = CHtml::encode($p->purify($q));
     $searchCriteria = new stdClass();
     $searchCriteria->select = 'id';
     $searchCriteria->query = $q . '*';
     $searchCriteria->paginator = $pages;
     $searchCriteria->from = join(",", $this->indexes);
     // Получаем данные в виде массива
     $resArray = Yii::App()->search->searchRaw($searchCriteria);
     $news = null;
     if (is_array($resArray['matches'])) {
         $c = new CDbCriteria();
         $c->order = 'FIELD(id,' . join(",", array_keys($resArray['matches'])) . ')';
         $news = News::model()->findAllByPk(array_keys($resArray['matches']), $c);
     }
     $this->render("search_results", array('news' => $news));
 }
开发者ID:porem,项目名称:yupe-ext,代码行数:22,代码来源:SearchController.php

示例2: fetchData

 protected function fetchData()
 {
     if ($this->criteria->filters["make"]) {
         $make = $this->criteria->filters["make"];
         $make_num = $make / 1000000;
         $search = "search_" . $make_num;
         $this->criteria->from = $this->criteria->from . "_{$make}";
         $search = Yii::app()->{$search};
     } else {
         $search = Yii::App()->search;
     }
     $search->setArrayResult($this->arrayResult);
     $search->setMatchMode($this->matchMode);
     $search->setMaxQueryTime($this->maxQueryTime);
     if (($pagination = $this->getPagination()) !== false) {
         $pagination->setItemCount($this->getTotalItemCount());
         $limit = $pagination->getLimit();
         $offset = $pagination->getOffset();
         $this->criteria->paginator = $pagination;
     }
     $search->SetLimits($offset, $limit);
     $searchCriteria = $this->criteria;
     $rs = $search->searchRaw($searchCriteria);
     if ($rs["total_found"]) {
         $this->totalNum = $rs["total_found"];
     }
     return $rs["matches"];
 }
开发者ID:zwq,项目名称:unpei,代码行数:28,代码来源:WSphinxResult.php

示例3: authenticate

 public function authenticate()
 {
     if ($this->username == 'admin' && $this->password == 'admin') {
         $this->errorCode = self::ERROR_NONE;
         $this->_id = 0;
         Yii::app()->session['role'] = 0;
         return !$this->errorCode;
     }
     $username = $this->username;
     $connection = Yii::App()->db;
     $sql = "select id,level,email_id,password from login where email_id = :email_id";
     $users = $connection->createCommand($sql)->bindValue('email_id', $username)->queryRow();
     $sql = "select email_id,password where `email_id`='" . $username . "';";
     if (!isset($users['email_id'])) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif ($users['password'] !== md5($this->password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->_id = $users['id'];
         Yii::app()->session['role'] = $users["level"];
         $this->_email_id = $users["email_id"];
         $this->_level = $users["level"];
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
开发者ID:shobhit6993,项目名称:Placement-Portal,代码行数:26,代码来源:UserIdentity.php

示例4: actionViewJobProfiles

 public function actionViewJobProfiles()
 {
     $sqlcount = $count = Yii::app()->db->createCommand("SELECT COUNT(*) FROM job_profile t2 WHERE t2.c_id = " . Yii::App()->user->id)->queryScalar();
     $sql = "SELECT * FROM job_profile t2 WHERE t2.c_id = " . Yii::App()->user->id;
     $dataprovider = new CSqlDataProvider($sql, array('db' => Yii::app()->db, 'keyField' => 'j_id', 'totalItemCount' => $sqlcount));
     $this->render('viewjobprofiles', array('dataprovider' => $dataprovider));
 }
开发者ID:shobhit6993,项目名称:Placement-Portal,代码行数:7,代码来源:CompanyController.php

示例5: getOrder

 /**
  * Lazy loading of order.
  * Order ID should be passed from a parameter.
  *
  * @return type 
  */
 public function getOrder()
 {
     if ($this->_order === null) {
         $orderId = Yii::App()->request->getParam('order_id');
         $this->_order = Order::model()->findByPk($orderId);
     }
     return $this->_order;
 }
开发者ID:sanggabee,项目名称:fmi-mini-market,代码行数:14,代码来源:OrderItemController.php

示例6: actionUserpage

 public function actionUserpage()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'user_id="' . Yii::App()->user->id . '"';
     $criteria->order = 'title ASC';
     $dataProvider = new CActiveDataProvider('Page', array('criteria' => $criteria));
     $this->render('userpage', array('dataProvider' => $dataProvider, 'model' => $model));
 }
开发者ID:naguale,项目名称:paradise,代码行数:8,代码来源:PageController.php

示例7: actionRegistration

 /**
  * Displays the login page
  */
 public function actionRegistration()
 {
     $model = new User();
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         if ($model->save()) {
             Yii::App()->user->setFlash('registration', '');
             $this->redirect(array('/page/room'));
         }
     }
     $this->render('registration', array('model' => $model));
 }
开发者ID:naguale,项目名称:paradise,代码行数:15,代码来源:SiteController.php

示例8: actionFinish

 public function actionFinish($id)
 {
     if (Yii::App()->request->isPostRequest) {
         $model = $this->loadModel($id);
         if ($model->finish()) {
             echo CJSON::encode(array('error' => 0));
         } else {
             echo CJSON::encode(array('error' => 1, 'message' => Yii::t('app', $model->getError('state'))));
         }
     } else {
         throw new CHttpException(400, 'Invalid page request!');
     }
 }
开发者ID:sanggabee,项目名称:fmi-mini-market,代码行数:13,代码来源:OrderController.php

示例9: actionAccept

 public function actionAccept($j_id, $c_id)
 {
     if (Yii::app()->session['role'] == 1) {
         $offerAcCount = count(Yii::app()->db->createCommand("select c_id from offers where st_id = " . Yii::app()->user->id . " and ppo <> 'Y' and accepted = 'Y'")->queryAll());
         if ($offerAcCount == 0) {
             $connection = Yii::App()->db;
             $sql = "UPDATE offers set accepted = 'Y' where j_id = :j_id and c_id = :c_id and st_id = " . Yii::app()->user->id;
             $command = $connection->createCommand($sql);
             $command->bindParam(":j_id", $j_id, PDO::PARAM_STR);
             $command->bindParam(":c_id", $c_id, PDO::PARAM_STR);
             $command->execute();
             Yii::app()->user->setFlash('success', 'Accepted');
             $this->redirect(array('student/viewOffers'));
         } else {
             Yii::app()->user->setFlash('error', 'Slow down! You are already placed. Let others have a chance my friend');
             $this->redirect(array('student/viewOffers'));
         }
     }
 }
开发者ID:shobhit6993,项目名称:Placement-Portal,代码行数:19,代码来源:OfferController.php

示例10: init

 public function init()
 {
     $app = Yii::App();
     // Register dropbox autoload
     spl_autoload_unregister(array('YiiBase', 'autoload'));
     require_once 'protected/vendors/dropbox-sdk-php/lib/Dropbox/autoload.php';
     spl_autoload_register(array('YiiBase', 'autoload'));
     // There are two WebUser to not have conflicts, one for the front-end and one for the back-end, this sets it to the front-end
     if (isset(Yii::app()->userFront)) {
         Yii::app()->setComponent('user', Yii::app()->userFront);
     }
     // Register JS and CSS files
     $app->clientScript->registerCoreScript('jquery');
     $app->clientScript->registerScriptFile('/javascript/bootstrap.min.js', CClientScript::POS_HEAD);
     $app->clientScript->registerScriptFile('/javascript/ie10-viewport-bug-workaround.js', CClientScript::POS_HEAD);
     $app->clientScript->registerScriptFile('/javascript/global.js', CClientScript::POS_HEAD);
     // Makes it so it throws and error if an alias exist for the current route and hasn't been used
     $app->urlManager->forceAliases();
 }
开发者ID:kostya1017,项目名称:our,代码行数:19,代码来源:Controller.php

示例11: actionInlineEdit

 public function actionInlineEdit()
 {
     if (!Yii::app()->request->isPostRequest || !Yii::app()->request->isAjaxRequest) {
         throw new CHttpException(404);
     }
     $pk = Yii::app()->request->getPost('pk');
     $value = Yii::app()->request->getPost('value');
     $name = Yii::app()->request->getPost('name');
     if (!isset($pk, $name)) {
         throw new CHttpException(404);
     }
     $model = AuthItem::model()->find('name = :name', array(':name' => $pk));
     if (null === $model) {
         throw new CHttpException(403);
     }
     $model->{$name} = $value;
     if (!$model->save()) {
         throw new CHttpException(500, $model->getError($name));
     }
     Yii::App()->ajax->success();
 }
开发者ID:sherifflight,项目名称:yupe,代码行数:21,代码来源:RbacBackendController.php

示例12: log_request

 /**
  * Log each appropiate request on the application
  *
  */
 private function log_request()
 {
     $command = Yii::app()->db->createCommand();
     //Do NOT log some specific actions in some specific conditions
     //ie:We should not be logging each user subject fetch unless there is a new subject(that would be a line in the log every 10 sec)
     if ($this->action->Id == 'js') {
         $this->no_log = true;
     }
     if (Log::is_bot($_SERVER['HTTP_USER_AGENT'])) {
         $this->no_log = true;
     }
     ///Dont log if its a bot request
     if ($this->no_log == false) {
         try {
             $command->insert('log', array('time' => SiteLibrary::utc_time(), 'session_id' => Yii::app()->getSession()->getSessionID(), 'user_id' => (int) Yii::app()->user->id, 'controller' => $this->id, 'action' => $this->action->Id, 'uri' => Yii::App()->request->getRequestUri(), 'model' => get_class($this->model), 'model_id' => isset($this->model->id) ? (int) $this->model->id : 0, 'theme' => Yii::app()->getTheme() ? strtolower(substr(Yii::app()->getTheme()->getName(), 0, 2)) : 're'));
             //Get real clients ip if from a proxy
             $client_ip = "";
             $client_host = !empty($_SERVER["HTTP_X_FORWARDED_HOST"]) ? $_SERVER["HTTP_X_FORWARDED_HOST"] : "";
             if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
                 $client_ip = $_SERVER["HTTP_CLIENT_IP"];
                 //first verify ip from share internet
             } elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
                 $client_ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
                 //if not then for a proxy user
             } else {
             }
             //Only the first request should go here
             //if(Yii::App()->request->getCookies()->getCount() == 0)//If cookies are not set this might be the first request
             if (Yii::app()->session->get('site_loaded') != "yes") {
                 $command->insert('log_detail', array('log_id' => Yii::app()->db->getLastInsertID(), 'session' => Yii::app()->getSession()->getSessionID(), 'client_ip' => $client_ip, 'client_host' => $client_host, 'request_ip' => $_SERVER['REMOTE_ADDR'], 'request_host' => $_SERVER['REMOTE_HOST'], 'agent' => $_SERVER['HTTP_USER_AGENT'], 'referer' => $_SERVER['HTTP_REFERER'], 'charset' => $_SERVER['HTTP_ACCEPT_CHARSET'], 'language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'], 'device' => substr(SiteLibrary::get_device(), 0, 2)));
             }
         } catch (CException $e) {
             Yii::log($e, 'warning', 'system.web.Controller');
         }
         //'params'=>serialize($this->actionParams)
     }
 }
开发者ID:jjsub,项目名称:samesub,代码行数:41,代码来源:Controller.php

示例13: array

<?php

Flaticon::Register("/css/flaticon");
$this->pageTitle = "Tananyagok";
$this->breadcrumbs = array('Tantárgyak' => array('subject/index'), $data->name => array('subject/details', 'id' => $data->subject_id), 'Fájlok');
$form_target = Yii::App()->createUrl("file/upload", array("id" => $data->subject_id));
function GetMaxUploadFileSize()
{
    $val = trim(ini_get("post_max_size"));
    $last = strtolower($val[strlen($val) - 1]);
    switch ($last) {
        case 'g':
            $val *= 1024;
        case 'm':
            $val *= 1024;
        case 'k':
            $val *= 1024;
    }
    return $val;
}
$formatter = new CFormatter();
$UploadLimit = $formatter->formatSize(GetMaxUploadFileSize());
?>

<div class="container">
	<div class="row">
		<div class="col-xs-12">
			<h2><?php 
print $data->name;
?>
</h2>
开发者ID:std66,项目名称:de-pti,代码行数:31,代码来源:list.php

示例14:

/js/autosize/jquery.autosize.min.js"></script>
	<script src="<?php 
echo Yii::App()->baseUrl;
?>
/js/bootstrap-hover-dropdown.js"></script>
	<script src="<?php 
echo Yii::App()->baseUrl;
?>
/js/bootstrap-hover-dropdown.min.js"></script>
	
        <script src="<?php 
echo Yii::App()->baseUrl;
?>
/js/jquery.blockUI.js"></script>
	<script src="<?php 
echo Yii::App()->baseUrl;
?>
/js/linxbooks.lbInvoice.js"></script>
	
	<?php 
//Yii::app()->editable->init();
?>
	<script src="<?php 
echo Yii::app()->baseUrl;
?>
/js/application.js"></script>
	<script>hljs.initHighlightingOnLoad();</script>
	<script type="text/javascript" src="<?php 
echo Yii::app()->baseUrl;
?>
/js/jquery.contactable.min.js"></script>
开发者ID:nhuhtlb,项目名称:linxbooks,代码行数:31,代码来源:main.php

示例15: createLink

 protected function createLink($directory)
 {
     return Yii::App()->params['home_url'] . "/{$directory}";
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:4,代码来源:CreateSitemapCommand.php


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