當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CController類代碼示例

本文整理匯總了PHP中CController的典型用法代碼示例。如果您正苦於以下問題:PHP CController類的具體用法?PHP CController怎麽用?PHP CController使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CController類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: renderList

 /**
  * @return rendered content from view as string.
  */
 public static function renderList(CController $controller, $dataProvider)
 {
     assert('$dataProvider instanceof RedBeanModelDataProvider');
     $auditEventsListView = new AuditEventsModalListView($controller->getId(), $controller->getModule()->getId(), 'AuditEvent', $dataProvider, 'modal');
     $view = new ModalView($controller, $auditEventsListView);
     return $view->render();
 }
開發者ID:youprofit,項目名稱:Zurmo,代碼行數:10,代碼來源:AuditEventsListControllerUtil.php

示例2: isUserAllowed

 /**
  * Checks whether the Web user is allowed to perform the specified action.
  * @param CWebUser $user the user object
  * @param CController $controller the controller currently being executed
  * @param CAction $action the action to be performed
  * @param string $ip the request IP address
  * @param string $verb the request verb (GET, POST, etc.)
  * @return integer 1 if the user is allowed, -1 if the user is denied, 0 if the rule does not apply to the user
  */
 public function isUserAllowed($user, $controller, $action, $ip, $verb)
 {
     try {
         /*
         			$sesMod = $user->getState('modType');
         			$oCurMod = $controller->getModule();
         			if( $oCurMod != NULL ){
         				if( ($oCurMod->getId() == 'ad' && $sesMod == 'pub') ||
         					($oCurMod->getId() == 'pub' && $sesMod == 'ad') )
         					
         				throw new CHttpException(EXCEPTION_NO_RIGHTS, Yii::t('general', 'pub_ad_mod_confused'));	
         			}
         */
         echo 'user access';
         return false;
         $aPerm = $user->perm;
         $aAction = $aPerm[$controller->getId()]['_p'];
         if (is_array($aAction) && in_array(strtolower($action->getId()), $aAction)) {
             return true;
         } else {
             throw new CHttpException(EXCEPTION_NO_RIGHTS, Yii::t('general', 'sorry, you have no rights to do this'));
         }
     } catch (Exception $e) {
         throw new CHttpException(EXCEPTION_NO_RIGHTS, Yii::t('general', 'sorry, you have no rights to do this'));
     }
 }
開發者ID:wheatma,項目名稱:react_study,代碼行數:35,代碼來源:UserAccessControl.php

示例3: renderList

 /**
  * @return rendered content from view as string.
  */
 public static function renderList(CController $controller, $dataProvider, $action)
 {
     assert('$dataProvider instanceof RedBeanModelDataProvider');
     $modalListLinkProvider = new UserDetailsModalListLinkProvider('users', 'default', 'details');
     $usersListView = new UsersByModelModalListView($controller->getId(), $controller->getModule()->getId(), $action, 'User', $modalListLinkProvider, $dataProvider, 'modal');
     $view = new ModalView($controller, $usersListView);
     return $view->render();
 }
開發者ID:RamaKavanan,項目名稱:InitialVersion,代碼行數:11,代碼來源:UsersByModelModalListControllerUtil.php

示例4: renderMailContent

 public function renderMailContent(CController $controller)
 {
     if ($this->templatePath) {
         $controller->renderPartial($this->getMailTemplatePath(), $this->getParamsToRender());
     } else {
         echo '';
     }
 }
開發者ID:shnellpavel,項目名稱:bcgroup_lk,代碼行數:8,代碼來源:WizardFormModel.php

示例5: renderMessage

 public function renderMessage($view, array $data = array())
 {
     $controller = new \CController('SmsSender');
     $viewPath = \Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'views';
     $viewFile = $controller->resolveViewFile($view, $viewPath, $viewPath);
     $body = $controller->renderInternal($viewFile, $data, true);
     return $body;
 }
開發者ID:knyga,項目名稱:sms-sender,代碼行數:8,代碼來源:SmsSender.php

示例6: generate

 public function generate()
 {
     $model = new MainAccountModel();
     $model->save();
     $ccc = new CController('context');
     $fileName = tempnam(sys_get_temp_dir(), "asd");
     $fileName .= ".html";
     $htmlOutput = $ccc->renderInternal(Yii::getPathOfAlias("application.views.templates") . '/index.php', $model->attributes, true);
     file_put_contents($fileName, $htmlOutput);
     return $fileName;
 }
開發者ID:branJakJak,項目名稱:biOaypiaccount,代碼行數:11,代碼來源:TemplateGenerator.php

示例7: resolveBreadCrumbViewForDetailsControllerAction

 /**
  * @param CController $controller
  * @param $stickySearchKey
  * @param RedBeanModel $model
  * @return mixed
  */
 public static function resolveBreadCrumbViewForDetailsControllerAction(CController $controller, $stickySearchKey, RedBeanModel $model)
 {
     assert('is_string($stickySearchKey)');
     if (ArrayUtil::getArrayValue(GetUtil::getData(), 'stickyOffset') !== null && StickySearchUtil::getDataByKey($stickySearchKey) != null) {
         $stickyLoadUrl = Yii::app()->createUrl($controller->getModule()->getId() . '/' . $controller->getId() . '/renderStickyListBreadCrumbContent', array('stickyKey' => $stickySearchKey, 'stickyOffset' => ArrayUtil::getArrayValue(GetUtil::getData(), 'stickyOffset'), 'stickyModelId' => $model->id));
     } else {
         $stickyLoadUrl = null;
     }
     $className = static::resolveStickyDetailsAndRelationsBreadCrumbViewClassName();
     return new $className($controller->getId(), $controller->getModule()->getId(), static::resolveBreadcrumbLinks($model), $controller->getModule()->getModuleLabelByTypeAndLanguage('Plural'), $stickyLoadUrl);
 }
開發者ID:youprofit,項目名稱:Zurmo,代碼行數:17,代碼來源:StickySearchUtil.php

示例8: testDefaultProperties

 public function testDefaultProperties()
 {
     $app = new TestApplication();
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $c = new CController('test/subtest');
     $this->assertEquals($c->id, 'test/subtest');
     $this->assertEquals($c->filters(), array());
     $this->assertEquals($c->actions(), array());
     $this->assertNull($c->action);
     $this->assertEquals($c->defaultAction, 'index');
     $this->assertEquals($c->viewPath, $app->viewPath . DIRECTORY_SEPARATOR . 'test/subtest');
     $this->setExpectedException('CHttpException');
     $c->missingAction('index');
 }
開發者ID:super-d2,項目名稱:codeigniter_demo,代碼行數:14,代碼來源:CControllerTest.php

示例9: _jump

 /**
  * 最終跳轉處理
  * @param type $msg 提示信息
  * @param type $jumpurl 跳轉url
  * @param type $wait 等待時間
  * @param int $type 消息類型 0或1
  */
 private static function _jump($msg = "", $jumpurl = "", $wait = 3, $type = 0)
 {
     $data = array('msg' => $msg, 'jumpurl' => $jumpurl, 'wait' => $wait, 'type' => $type);
     $data['title'] = $type == 1 ? "提示信息" : "錯誤信息";
     if (empty($jumpurl)) {
         if ($type == 1) {
             $data['jumpurl'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "javascript:window.close();";
         } else {
             $data['jumpurl'] = "javascript:history.back(-1);";
         }
     }
     $cc = new CController('showmessage');
     $cc->renderPartial("/showMessage", $data);
     exit;
 }
開發者ID:00606,項目名稱:wechat,代碼行數:22,代碼來源:ShowMessage.php

示例10: handle

 public static function handle(CExceptionEvent $event)
 {
     $exception = $event->exception;
     if (get_class($exception) == "CHttpException" && $exception->statusCode === 404) {
         $pathParts = explode('/', Yii::app()->getRequest()->getRequestUri());
         $pathPart = array_pop($pathParts);
         $criteria = new CDbCriteria();
         $criteria->addSearchCondition('alias', $pathPart);
         $criteria->limit = 5;
         $models = Article::model()->findAll($criteria);
         $controller = new CController(null);
         $controller->renderPartial('//error/404', array('models' => $models));
         $event->handled = true;
     }
 }
開發者ID:moohwaan,項目名稱:yii-application-cookbook-2nd-edition-code,代碼行數:15,代碼來源:NotFoundHandler.php

示例11: __construct

 /**
  * Initializes the pager by setting some default property values.
  * @param string $html
  * @param string $title
  * @param mixed $format
  * @param string $orientation
  */
 public function __construct($html, $title = '', $format = 'A4', $orientation = 'P')
 {
     parent::__construct($this->mode, $format, $this->defaultFontSize, $this->defaultFont, $this->marginLeft, $this->marginRight, $this->marginTop, $this->marginBottom, $this->marginHeader, $this->marginFooter, $orientation);
     $controller = new CController('PDF');
     $controller->layout = $this->layouts;
     $html = $controller->renderText($html, true);
     $this->SetCreator($this->creator);
     $this->SetTitle($title);
     if (!UserWeb::instance()->isGuest) {
         $this->SetFooter(sprintf('Berkas dicetak oleh %s, %s||{PAGENO}', UserWeb::instance()->user()->username, date('Y-m-d H:i:s')));
     } else {
         throw new CHttpException(403, 'Anda tidak memiliki otoritas untuk mengakses halaman ini');
     }
     $this->writeHTML($html);
 }
開發者ID:andryluthfi,項目名稱:annotation-tools,代碼行數:22,代碼來源:PDFWriter.php

示例12: sendRequest

 public function sendRequest($hole, $user)
 {
     if (!$hole->isMoscow) {
         return false;
     }
     $client = $this->client;
     Yii::app()->request->baseUrl = Yii::app()->request->hostInfo;
     $pictures = array();
     foreach ($hole->pictures_fresh as $pict) {
         $pictures[] = array('name' => $pict->filename, 'fileType' => $pict->extension, 'content' => $pict->binary);
     }
     $answer = $client->RequestNew(array('request' => array('hidden' => false, 'informer' => array('name' => $this->name, 'surname' => $this->surname, 'fatherName' => $this->fatherName, 'phoneNumber' => $this->phoneNumber, 'email' => $this->email, 'notifyViaEmail' => $this->notifyViaEmail, 'notifyViaSms' => $this->notifyViaSms, 'address' => array('fullAddress' => $this->address)), 'category' => array('code' => $hole->type->dorogimos_id), 'details' => $this->details, 'address' => array('latitude' => $hole->LATITUDE, 'longitude' => $hole->LONGITUDE, 'fullAddress' => $this->holeAddress, 'webLink' => CController::createUrl('/holes/view', array('id' => $hole->ID))), 'pictures' => $pictures)));
     if ($answer->successful) {
         $holeRequest = new HoleRequests();
         $holeRequest->hole_id = $hole->ID;
         $holeRequest->user_id = $user->id;
         $holeRequest->date_sent = time();
         $holeRequest->response_requestid = $answer->request->requestNumber;
         $holeRequest->type = 'dorogimos';
         $holeRequest->gibdd_id = 0;
         if ($holeRequest->save()) {
             return true;
         }
         //else print_r($holeRequest->errors); die();
     } else {
         $this->errortext = $answer->failReason;
         //print_r($answer); die();
     }
     return false;
 }
開發者ID:ASDAFF,項目名稱:RosYama.2,代碼行數:30,代碼來源:DorogiMosForm.php

示例13: filters

 /**
  * (non-PHPdoc)
  * @see yii/CController#filters()
  */
 public function filters()
 {
     return array_merge(array(
         array('SetupFilter'),
         array('SslFilter')
     ), parent::filters());
 }
開發者ID:hersoncruz,項目名稱:ppma,代碼行數:11,代碼來源:Controller.php

示例14: actionRegistro

 public function actionRegistro()
 {
     $modelAlumnos = new Alumno();
     if (isset($_POST['Alumno'])) {
         try {
             $usuario = new Usuario();
             $usuario->perfil = 3;
             $usuario->nombreUsuario = $_POST['Alumno']['identificacion'];
             $usuario->password = md5($_POST['Alumno']['identificacion']);
             if ($usuario->save()) {
                 $alumno = new Alumno();
                 $alumno->attributes = $_POST['Alumno'];
                 $alumno->idUsuario = $usuario->idUsuario;
                 if (!$alumno->save()) {
                     Yii::app()->user->setFlash('alert alert-danger', "Alumno no fue creado");
                 } else {
                     Yii::app()->user->setFlash('alert alert-success', "Alumno  fue creado con éxito");
                     $this->redirect(CController::createUrl('/sitio/index'));
                 }
             } else {
                 Yii::app()->user->setFlash('alert alert-danger', "Alumno no fue creado");
             }
         } catch (Exception $e) {
             Yii::app()->user->setFlash('alert alert-danger', "Alumno no fue creado");
         }
     }
     $this->render('registroEstudiantes', array('modelAlumnos' => $modelAlumnos));
 }
開發者ID:jjaragon,項目名稱:aplicacion,代碼行數:28,代碼來源:SitioController.php

示例15: beforeAction

 protected function beforeAction($action)
 {
     parent::beforeAction($action);
     if (Yii::app()->user->isGuest) {
         if (isset(Yii::app()->request->cookies['prefLang'])) {
             $sChosenLanguage = Yii::app()->request->cookies['prefLang']->value;
         } else {
             $sPrefferedLang = Yii::app()->request->getPreferredLanguage();
             if ($sPrefferedLang !== false && strpos($sPrefferedLang, "ru") !== false) {
                 $sChosenLanguage = "ru";
             } else {
                 $sChosenLanguage = "uk_ua";
             }
             $cookie = new CHttpCookie('prefLangId', $sChosenLanguage);
             $cookie->expire = time() + 86400 * 7;
             Yii::app()->request->cookies['prefLang'] = $cookie;
         }
     } else {
         $sChosenLanguage = Yii::app()->user->getLanguage();
     }
     switch ($sChosenLanguage) {
         case "ru":
             Yii::app()->language = "ru";
             break;
         default:
             Yii::app()->language = "uk_ua";
     }
     return true;
 }
開發者ID:snipesn,項目名稱:UkrYama-2,代碼行數:29,代碼來源:Controller.php


注:本文中的CController類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。