本文整理汇总了PHP中Context::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::getInstance方法的具体用法?PHP Context::getInstance怎么用?PHP Context::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModule
/**
* (non-PHPdoc)
* @see FrontController::loadModule()
*/
public function loadModule()
{
$resolver = new Resolver($this->getRequest());
// load the responsible extension
common_ext_ExtensionsManager::singleton()->getExtensionById($resolver->getExtensionId());
\Context::getInstance()->setExtensionName($resolver->getExtensionId());
//if the controller is a rest controller we try to authenticate the user
$controllerClass = $resolver->getControllerClass();
if (is_subclass_of($controllerClass, 'tao_actions_CommonRestModule')) {
$authAdapter = new \tao_models_classes_HttpBasicAuthAdapter(common_http_Request::currentRequest());
try {
$user = $authAdapter->authenticate();
$session = new \common_session_RestSession($user);
\common_session_SessionManager::startSession($session);
} catch (\common_user_auth_AuthFailedException $e) {
$class = new $controllerClass();
$class->requireLogin();
}
}
try {
$enforcer = new ActionEnforcer($resolver->getExtensionId(), $resolver->getControllerClass(), $resolver->getMethodName(), $this->getRequest()->getParams());
$enforcer->execute();
} catch (InterruptedActionException $iE) {
// Nothing to do here.
}
}
示例2: redirect
public function redirect($url, $statusCode = 302)
{
$context = Context::getInstance();
header(HTTPToolkit::statusCodeHeader($statusCode));
header(HTTPToolkit::locationHeader($url));
throw new InterruptedActionException('Interrupted action after a redirection', $context->getModuleName(), $context->getActionName());
}
示例3: outputFile
public static function outputFile($relPath, $filename = null)
{
$fullpath = self::getExportPath() . DIRECTORY_SEPARATOR . $relPath;
if (tao_helpers_File::securityCheck($fullpath, true) && file_exists($fullpath)) {
Context::getInstance()->getResponse()->setContentHeader(tao_helpers_File::getMimeType($fullpath));
$fileName = empty($filename) ? basename($fullpath) : $filename;
header('Content-Disposition: attachment; fileName="' . $fileName . '"');
header("Content-Length: " . filesize($fullpath));
//Clean all levels of output buffering
while (ob_get_level() > 0) {
ob_end_clean();
}
flush();
$fp = fopen($fullpath, "r");
if ($fp !== false) {
while (!feof($fp)) {
echo fread($fp, 65536);
flush();
}
fclose($fp);
@unlink($fullpath);
} else {
common_Logger::e('Unable to open File to export' . $fullpath);
}
} else {
common_Logger::e('Could not find File to export: ' . $fullpath);
}
}
示例4: __getTemplate
private function __getTemplate($content)
{
$oContext = Context::getInstance();
$oTemplate = new Template('site/searchPages.tpl.php');
$oTemplate->pages = $content;
return $oTemplate->parse();
}
示例5: index
/**
* render the main layout
*
* @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
*/
public function index()
{
if ($this->hasRequestParameter('openFolder')) {
$folder = $this->getRequestParameter('openFolder');
if (tao_helpers_File::securityCheck($folder, true)) {
$folder = preg_replace('/^\\//', '', $folder);
$folder = preg_replace('/\\/$/', '', $folder);
$this->setData('openFolder', $folder);
}
}
if ($this->hasRequestParameter('urlData')) {
$this->setData('urlData', $this->getRequestParameter('urlData'));
}
if ($this->hasRequestParameter('error')) {
$this->setData('error', $this->getRequestParameter('error'));
}
// Show select action?
$this->setData('showSelect', false);
if ($this->hasRequestParameter('showselect') && $this->getRequestParameter('showselect') == '1') {
$this->setData('showSelect', true);
}
//creates the URL of the action used to configure the client side
$context = Context::getInstance();
$clientConfigParameters = array('extension' => $context->getExtensionName(), 'module' => $context->getModuleName(), 'action' => $context->getActionName());
$this->setData('client_config_url', _url('config', 'ClientConfig', 'tao', $clientConfigParameters));
$this->setData('upload_limit', $this->getFileUploadLimit());
$this->setView('index.tpl');
}
示例6: legacy
/**
* Run the controller
*
* @param common_http_Request $pRequest
* @throws \ActionEnforcingException
* @throws \Exception
* @throws \common_exception_Error
* @throws \common_ext_ExtensionException
*/
public function legacy(common_http_Request $pRequest)
{
$resolver = new Resolver($pRequest);
// load the responsible extension
$ext = common_ext_ExtensionsManager::singleton()->getExtensionById($resolver->getExtensionId());
\Context::getInstance()->setExtensionName($resolver->getExtensionId());
// load translations
$uiLang = \common_session_SessionManager::getSession()->getInterfaceLanguage();
\tao_helpers_I18n::init($ext, $uiLang);
//if the controller is a rest controller we try to authenticate the user
$controllerClass = $resolver->getControllerClass();
if (is_subclass_of($controllerClass, \tao_actions_RestController::class)) {
$authAdapter = new \tao_models_classes_HttpBasicAuthAdapter(common_http_Request::currentRequest());
try {
$user = $authAdapter->authenticate();
$session = new \common_session_RestSession($user);
\common_session_SessionManager::startSession($session);
} catch (\common_user_auth_AuthFailedException $e) {
$data['success'] = false;
$data['errorCode'] = '401';
$data['errorMsg'] = 'You are not authorized to access this functionality.';
$data['version'] = TAO_VERSION;
header('HTTP/1.0 401 Unauthorized');
header('WWW-Authenticate: Basic realm="' . GENERIS_INSTANCE_NAME . '"');
echo json_encode($data);
exit(0);
}
}
try {
$enforcer = new ActionEnforcer($resolver->getExtensionId(), $resolver->getControllerClass(), $resolver->getMethodName(), $pRequest->getParams());
$enforcer->execute();
} catch (InterruptedActionException $iE) {
// Nothing to do here.
}
}
示例7: setUp
/**
* Prepare runtime context - tell DB class that current DB is CUBRID
*/
protected function setUp()
{
$oContext =& Context::getInstance();
$db_info->master_db = array('db_type' => 'sqlite3_pdo', 'db_table_prefix' => 'xe_');
$db_info->slave_db = array(array('db_type' => 'sqlite3_pdo', 'db_table_prefix' => 'xe_'));
$oContext->setDbInfo($db_info);
DB::getParser(true);
}
示例8: __construct
public function __construct()
{
$this->context = Context::getInstance();
$this->_helper = new ViewHelper();
$date = date('m');
$this->headerImg = 'MLink/images/structure/';
$this->headerImg .= 'newheader.png';
}
示例9: delete
public function delete()
{
$context = Context::getInstance();
$role = $this->checkAccess($context->user);
if ($role <= Acl::READER) {
throw new PermissionDenied("No permission to delete");
}
parent::delete();
}
示例10: getInstance
public static function getInstance()
{
if (empty(self::$_instance)) {
$db = new Db();
$context = Context::getInstance();
self::$_instance = new self($db, $context);
}
return self::$_instance;
}
示例11: loadModule
public function loadModule()
{
$enforcer = new RoutingActionEnforcer(Context::getInstance());
try {
$enforcer->execute();
} catch (InterruptedActionException $iE) {
// Nothing to do here.
}
}
示例12: setUp
/**
* Prepare runtime context - tell DB class that current DB is CUBRID
*/
protected function setUp()
{
$oContext =& Context::getInstance();
$db_info->master_db = array('db_type' => 'cubrid', 'db_table_prefix' => 'xe_');
$db_info->slave_db = array(array('db_type' => 'cubrid', 'db_table_prefix' => 'xe_'));
$oContext->setDbInfo($db_info);
$db = new MockDb();
$db->getParser(true);
}
示例13: AllTests
function AllTests()
{
$oContext =& Context::getInstance();
$oContext->init();
$this->TestSuite('Classes Test');
$this->addFile(dirname(__FILE__) . '/classes/context/Context.test.php');
$this->TestSuite('Module Test');
$this->addFile(dirname(__FILE__) . '/modules/module/module.test.php');
$this->addFile(dirname(__FILE__) . '/modules/module/opage.test.php');
}
示例14: ltiOverview
public function ltiOverview()
{
//creates the URL of the action used to configure the client side
$context = \Context::getInstance();
$clientConfigParameters = array('extension' => $context->getExtensionName(), 'module' => $context->getModuleName(), 'action' => $context->getActionName());
$this->setData('client_config_url', _url('config', 'ClientConfig', 'tao', $clientConfigParameters));
$this->setData('delivery', $this->getRequestParameter('delivery'));
$this->setData('allowRepeat', true);
$this->setView('learner/overview.tpl');
}
示例15: setCookieToken
public static function setCookieToken(User $user, $salt)
{
$instance = new UserToken();
$instance->sid = $salt;
$instance->uid = $user->id;
$instance->save(true);
$cookie_val = sprintf('%s_%s_%s', $instance->uid, $instance->sid, $instance->token);
$context = Context::getInstance();
$context->session->set_cookie('frmauth', $cookie_val, time() + 60 * 60 * 24 * 30);
}