PHP Class Context, thinksns Code Examples

This page contains top rated real world PHP examples of class Context from package thinksns extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: Verify.php Project: saintho/phpdisk
0
 /**
  *  获取校验结果
  * @return type
  */
 public static function getVerifyResult()
 {
     $context = new Context();
     $typhoon = new Typhoon();
     if ($typhoon->isValid()) {
         $ssid = $typhoon->_ssid;
         $name = $typhoon->_name;
         $value = $context->get($name, '');
         if ($value != '') {
             if ($typhoon->_request_type == 1) {
                 $ret = Valid::sendVerifyRemoteRequest($ssid, $value, $typhoon->_diff_time);
             } else {
                 $ret = Valid::sendVerifyLocalRequest($ssid, $value);
             }
             self::$_result = Valid::getResult();
             self::$_code = Valid::getCode();
             self::$_details = Valid::getDetails();
         } else {
             self::$_result = 0;
             self::$_code = 'E_VALUEEMPTY_001';
             self::$_details = '验证码不可以为空';
         }
     } else {
         self::$_result = 0;
         self::$_code = 'E_PARAM_001';
         self::$_details = '重要参数传递错误';
     }
     return self::$_result === 1 ? TRUE : FALSE;
 }
Example #2
Show file File: CaptchaAction.class.php Project: RBSWebFactory/modules.form
0
 /**
  * @param Context $context
  * @param Request $request
  */
 public function _execute($context, $request)
 {
     controller_ChangeController::setNoCache();
     $generator = form_CaptchaGenerator::getInstance();
     $renew = $request->hasParameter('renew');
     // Set optionnal parameters.
     if ($request->hasParameter('ml')) {
         $generator->setCodeMaxLength(intval($request->getParameter('ml')));
         if ($renew) {
             $generator->setCodeMinLength(intval($request->getParameter('ml')));
         }
     }
     if ($request->hasParameter('iw')) {
         $generator->setWidth(intval($request->getParameter('iw')));
     }
     if ($request->hasParameter('ih')) {
         $generator->setHeight(intval($request->getParameter('ih')));
     }
     if ($request->hasParameter('fs')) {
         $generator->setFontSize(intval($request->getParameter('fs')));
     }
     if ($request->hasParameter('fd')) {
         $generator->setFontDepth(intval($request->getParameter('fd')));
     }
     // Renders the image.
     if ($renew) {
         $generator->generateCode();
     }
     $generator->render($context->getUser()->getAttribute(CAPTCHA_SESSION_KEY));
     return View::NONE;
 }
Example #3
Show file File: class.cronmodule.php Project: umonkey/molinos-cms
0
 /**
  * Запуск периодических задач.
  *
  * Проверяется время последнего запуска, чаще установленного администратором
  * времени запуск производиться не будет (по умолчанию 15 минут).
  */
 public static function on_rpc(Context $ctx)
 {
     $status = "DELAYED";
     $lastrun = $ctx->config->get('modules/cron/lastrun');
     $delay = $ctx->config->get('modules/cron/delay', 15) * 60;
     if (time() >= $lastrun + $delay) {
         $ctx->config->set('modules/cron/lastrun', time());
         $ctx->config->save();
         @set_time_limit(0);
         ob_start();
         try {
             $ctx->registry->broadcast('ru.molinos.cms.cron', array($ctx));
             $status = "OK";
         } catch (Exception $e) {
             Logger::trace($e);
             $status = "ERROR: " . get_class($e) . '; ' . trim($e->getMessage(), '.') . '.';
         }
         ob_end_clean();
     }
     if ($ctx->get('destination')) {
         return $ctx->getRedirect();
     }
     if (!MCMS_CONSOLE) {
         header('Content-Type: text/plain; charset=utf-8');
         die($status);
     }
     die;
 }
Example #4
Show file File: html.helper.php Project: RNKushwaha022/orange-php
0
 function __construct(Context $context = null)
 {
     if (!$context) {
         $context = new Context('helper', 'phaxsi');
     }
     $this->module = $context->getModule();
 }
Example #5
Show file File: class.authform.php Project: umonkey/molinos-cms
0
 /**
  * Вывод формы авторизации.
  * @route GET//login
  */
 public static function on_get_login_form(Context $ctx)
 {
     if ($ctx->user->id and !$ctx->get('stay')) {
         return $ctx->getRedirect();
     }
     if (class_exists('APIStream')) {
         APIStream::init($ctx);
     }
     $handler = array('theme' => $ctx->config->get('modules/auth/login_theme'));
     $content = '';
     foreach ((array) $ctx->registry->poll('ru.molinos.cms.page.head', array($ctx, $handler, null), true) as $block) {
         if (!empty($block['result'])) {
             $content .= $block['result'];
         }
     }
     $content .= self::getXML($ctx);
     $xml = html::em('page', array('status' => 401, 'base' => $ctx->url()->getBase($ctx), 'host' => MCMS_HOST_NAME, 'prefix' => os::webpath(MCMS_SITE_FOLDER, 'themes'), 'back' => urlencode(MCMS_REQUEST_URI), 'next' => $ctx->get('destination'), 'api' => APIStream::getPrefix(), 'query' => $ctx->query()), $content);
     if (file_exists($xsl = os::path(MCMS_SITE_FOLDER, 'themes', $handler['theme'], 'templates', 'login.xsl'))) {
         try {
             return xslt::transform($xml, $xsl);
         } catch (Exception $e) {
         }
     }
     return xslt::transform($xml, 'lib/modules/auth/xsl/login.xsl');
 }
Example #6
Show file File: ContextTest.php Project: mgldev/coffeetrack
0
 /** @test */
 public function getSocketShouldNotAddReadListenerForNonReadableSocketType()
 {
     $loop = $this->getMock('React\\EventLoop\\LoopInterface');
     $loop->expects($this->never())->method('addReadStream');
     $context = new Context($loop);
     $socket = $context->getSocket(\ZMQ::SOCKET_PUSH);
 }
Example #7
Show file File: class.installmodule.php Project: umonkey/molinos-cms
0
 public static function rpc_post_install(Context $ctx)
 {
     $data = $ctx->post;
     if (empty($data['dbtype'])) {
         throw new RuntimeException(t('Вы не выбрали тип БД.'));
     }
     $config = $ctx->config;
     // Выносим секцию main в самое начало.
     $config['main'] = array();
     if ($config->isok()) {
         throw new ForbiddenException(t('Инсталляция невозможна: конфигурационный файл уже есть.'));
     }
     $dsn = self::getDSN($data['dbtype'], $data['db'][$data['dbtype']]);
     if (!empty($data['db']['prefix'])) {
         $dsn['prefix'] = $data['db']['prefix'];
     }
     $config->set('modules/db', $dsn);
     foreach (array('modules/mail/server', 'modules/mail/from', 'main/debug/errors') as $key) {
         if (!empty($data[$key])) {
             $config->set($key, $data[$key]);
         }
     }
     $config->set('modules/files/storage', 'files');
     $config->set('modules/files/ftp', 'ftp');
     $config->set('main/tmpdir', 'tmp');
     $config->set('main/debug/allow', array('127.0.0.1', $_SERVER['REMOTE_ADDR']));
     // Создаём маршрут для главной страницы.
     $config['routes']['localhost/'] = array('title' => 'Molinos CMS', 'theme' => 'example', 'call' => 'BaseRoute::serve');
     // Проверим соединение с БД.
     $pdo = Database::connect($config->get('modules/db'));
     // Подключились, можно сохранять конфиг.
     $config->save();
     $ctx->redirect('admin/system/reload?destination=admin/system/settings');
 }
Example #8
Show file File: Client.php Project: CcrisS/PHP-Patterns
0
 public function killer()
 {
     $secure = new SecureData();
     $context = new Context(new DeleteRecord());
     $secure->removeRecord();
     $context->algorithm($secure->setEntry());
 }
Example #9
Show file File: class-bootstrap.php Project: arter97/h5ai
0
 public static function run()
 {
     spl_autoload_register(['Bootstrap', 'autoload']);
     putenv('LANG=en_US.UTF-8');
     setlocale(LC_CTYPE, 'en_US.UTF-8');
     date_default_timezone_set(@date_default_timezone_get());
     session_start();
     $session = new Session($_SESSION);
     $request = new Request($_REQUEST);
     $setup = new Setup($request->query_boolean('refresh', false));
     $context = new Context($session, $request, $setup);
     if ($context->is_api_request()) {
         (new Api($context))->apply();
     } else {
         if ($context->is_info_request()) {
             $public_href = $setup->get('PUBLIC_HREF');
             $x_head_tags = $context->get_x_head_html();
             require __DIR__ . '/pages/info.php';
         } else {
             $public_href = $setup->get('PUBLIC_HREF');
             $x_head_tags = $context->get_x_head_html();
             $fallback_html = (new Fallback($context))->get_html();
             require __DIR__ . '/pages/index.php';
         }
     }
 }
Example #10
Show file File: loader_tags.php Project: idlesign/dja
0
 /**
  * @param Context $context
  *
  * @return mixed
  */
 public function render($context)
 {
     /** @var $block_context BlockContext */
     $block_context = null;
     if (isset($context->render_context[BLOCK_CONTEXT_KEY])) {
         $block_context = $context->render_context[BLOCK_CONTEXT_KEY];
     }
     $context->push();
     if ($block_context === null) {
         $context['block'] = $this;
         $result = $this->nodelist->render($context);
     } else {
         $push = $block = $block_context->pop($this->name);
         if ($block === null) {
             $block = $this;
         }
         // Create new block so we can store context without thread-safety issues.
         $block = new BlockNode($block->name, $block->nodelist);
         $block->context = $context;
         $context['block'] = $block;
         $result = $block->nodelist->render($context);
         if ($push !== null) {
             $block_context->push($this->name, $push);
         }
     }
     $context->pop();
     return $result;
 }
Example #11
Show file File: auth.plugin.php Project: RNKushwaha022/orange-php
0
 /**
  * Method called after the module has been setup, but before the action
  * is executed.
  * @param Context $context
  */
 function controllerStart($context)
 {
     if (!$this->config['enabled']) {
         return;
     }
     #Execute this only when it is a page controller and not when
     #it is a block, layout or some other type of controller
     if ($context->getType() != 'controller') {
         return;
     }
     #Put the action in lowercase to avoid it not being detected due to case
     $action = strtolower($context->getAction());
     #Checks for user credentials and executes in case they are not valid
     if (!$this->isAuthorized($action)) {
         $this->callDenyFunction($action);
         $view_type = $context->getViewType();
         switch ($view_type) {
             case 'html':
             case 'process':
             case 'mail':
                 $this->loginRedirect();
                 break;
             case 'json':
             case 'feed':
             default:
                 exit;
         }
         exit;
     }
     $this->started = true;
 }
Example #12
Show file File: ContextTest.php Project: superruzafa/rules
0
 /** @test */
 public function iterator()
 {
     $context = new Context(array('foo' => 'bar'));
     $iterator = $context->getIterator();
     $this->assertInstanceOf('IteratorAggregate', $iterator);
     $iterator->offsetExists('foo');
 }
Example #13
Show file File: listing11.02.php Project: jabouzi/projet
0
 function interpret(Context $context)
 {
     if (!is_null($this->val)) {
         $context->replace($this, $this->val);
         $this->val = null;
     }
 }
Example #14
Show file File: MoveTest.php Project: shabbirvividads/magento2
0
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->scheduledStructureMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\ScheduledStructure')->disableOriginalConstructor()->getMock();
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Reader\\Context')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getScheduledStructure')->willReturn($this->scheduledStructureMock);
     $this->move = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\Layout\\Reader\\Move');
 }
Example #15
Show file File: file.php Project: srph/playground
0
 public function execute()
 {
     $context = new Context();
     $context->execute(function () {
         array_pop($this->tasks);
         echo count($this->tasks);
     });
 }
Example #16
Show file File: client.php Project: luisOO/design-patterns
0
 /**
  * Main program
  */
 public static function main()
 {
     $context = new Context();
     $context->request();
     $context->request();
     $context->request();
     $context = null;
 }
Example #17
Show file
0
 /**
  * {@inheritdoc}
  *
  * @param $path
  */
 public function load($path)
 {
     $tests = $this->getTests($path);
     foreach ($tests as $test) {
         $this->context->setFile($test);
         include $test;
     }
 }
Example #18
Show file File: shell.class.php Project: RNKushwaha022/orange-php
0
 function __construct(Context $context)
 {
     $this->load = new Loader($context);
     $this->db = new DatabaseProxy($this->load);
     $this->context = $context;
     $this->view = new ShellView($context);
     $this->args = array_merge((array) $this->args, (array) $context->getArguments());
 }
Example #19
Show file File: OperatorCondition.php Project: richardskinner/qandidate-toggle
0
 /**
  * {@inheritdoc}
  */
 public function holdsFor(Context $context)
 {
     if (!$context->has($this->key)) {
         return false;
     }
     $argument = $context->get($this->key);
     return $this->operator->appliesTo($argument);
 }
Example #20
Show file File: abstract_controller.class.php Project: RNKushwaha022/orange-php
0
 /**
  * Initializes controller
  * @param Context $context
  * @param View $view
  */
 function __construct(Context $context, View $view)
 {
     $this->load = new Loader($context);
     $this->context = $context;
     $this->view = $view;
     $this->args = array_merge((array) $this->args, (array) $context->getArguments());
     $base_module = $context->getBaseModuleName();
     $this->config = isset(AppConfig::$modules[$base_module]) ? AppConfig::$modules[$base_module] : array();
 }
Example #21
Show file File: controller.class.php Project: RNKushwaha022/orange-php
0
 /**
  * Initializes the Controller instance and selects the appropiate View
  * @param Context $context
  */
 function __construct(Context $context)
 {
     $type = $context->getViewType();
     $class_name = $type . 'view';
     $view = new $class_name($context);
     parent::__construct($context, $view);
     $this->db = new DatabaseProxy($this->load);
     $this->helper = new HelperLoader($this->load);
 }
Example #22
Show file File: VariableNode.php Project: lopo/phpsass
0
 /**
  * Parse this node.
  * Sets the variable in the current context.
  *
  * @param Context $context the context in which this node is parsed
  * @return array the parsed node - an empty array
  */
 public function parse($context)
 {
     if (!$this->isDefault || !$context->hasVariable($this->name)) {
         $context->setVariable($this->name, $this->evaluate($this->value, $context));
     }
     $this->parseChildren($context);
     // Parse any warnings
     return [];
 }
Example #23
Show file File: ui.php Project: fruition-sciences/phpfw
0
 /**
  * Use the router to generate a new URL to this website.
  * This allows generating a link using a 'routeName' rather than assuming that
  * you know the actual format of the path.
  *
  * @param String $routeName the routing name to use (as defined in routes.yaml)
  * @param Array $data data to use as variables for the route
  * @param Boolean $useCurrentParams if true, uses data from current route and
  *        then overrides with params given by the $data parameter.
  * @return Href
  */
 public function generateURL($routeName, $data = array(), $useCurrentParams = false)
 {
     $router = $this->ctx->getRouter();
     if ($useCurrentParams) {
         $route = $router->getMatchedRoute();
         $data = array_merge($route->params, $data);
     }
     $url = '/' . $router->generate($routeName, $data);
     return new Href($url);
 }
Example #24
Show file File: class.avatarrpc.php Project: umonkey/molinos-cms
0
 public static function rpc_get_default(Context $ctx)
 {
     $user = Node::load(array('class' => 'user', 'deleted' => 0, 'published' => 1, 'id' => $ctx->get('id')), $ctx->db);
     $email = $user ? $user->email : 'john.doe@example.com';
     $gurl = 'http://www.gravatar.com/avatar/' . md5($email);
     if (null !== ($s = $ctx->get('s'))) {
         $gurl .= '?s=' . intval($s) . '&r=x';
     }
     return new Redirect($gurl);
 }
Example #25
Show file File: model.base.php Project: RNKushwaha022/orange-php
0
 final function __construct(Context $context)
 {
     parent::__construct($this->driver_name);
     $this->load = new Loader($context);
     $this->db = new DatabaseProxy($this->load);
     $this->session = new Session($context->getModule());
     $this->plugin = $this->load->service('plugin');
     $this->table_name = strtolower($context->getAction());
     $this->id_column = $this->table_name . '_id';
 }
Example #26
Show file File: class.extrafiles.php Project: umonkey/molinos-cms
0
 /**
  * Открепление файлов от ноды.
  */
 public static function on_post_detach(Context $ctx)
 {
     if (is_array($ids = $ctx->post('remove'))) {
         $ctx->db->beginTransaction();
         $params = array();
         Node::load($ctx->get('id'), $ctx->db)->touch(ACL::UPDATE)->onSave('DELETE FROM `node__rel` WHERE `tid` = %ID% AND `key` IS NULL AND `nid` ' . sql::in($ids, $params), $params)->save();
         $ctx->db->commit();
     }
     return $ctx->getRedirect();
 }
Example #27
Show file File: BundledAsset.php Project: chh/pipe
0
 function getBody()
 {
     if (null === $this->body) {
         $body = parent::getBody();
         $bundleProcessors = $this->environment->bundleProcessors->all($this->getContentType());
         $context = new Context($this->environment);
         $this->body = $context->evaluate($this->path, array("processors" => $bundleProcessors, "data" => $body));
     }
     return $this->body;
 }
Example #28
Show file File: class.routeadmin.php Project: umonkey/molinos-cms
0
 public static function on_get_delete(Context $ctx)
 {
     $pages = '';
     foreach ((array) $ctx->get('check') as $id) {
         $pages .= html::em('page', urldecode($id));
     }
     if (empty($pages)) {
         throw new ForbiddenException(t('Не выбраны пути для удаления.'));
     }
     return html::wrap('content', $pages, array('name' => 'route-delete'));
 }
Example #29
Show file File: class.pollrpc.php Project: umonkey/molinos-cms
0
 /**
  * Возвращает результаты по опросу.
  */
 public static function on_get_results(Context $ctx)
 {
     $output = '';
     $id = $ctx->get('id');
     $data = $ctx->db->getResultsKV("option", "count", "SELECT `option`, COUNT(*) AS `count` FROM `node__poll` WHERE `nid` = ? GROUP BY `option`", array($ctx->get('id')));
     foreach ($data as $k => $v) {
         $output .= html::em('option', array('count' => $v), html::cdata($k));
     }
     $voted = $ctx->user->id ? $ctx->db->fetch("SELECT COUNT(*) FROM `node__poll` WHERE `nid` = ? AND `uid` = ?", array($id, $ctx->user->id)) : $ctx->db->fetch("SELECT COUNT(*) FROM `node__poll` WHERE `nid` = ? AND `ip` = ?", array($id, $_SERVER['REMOTE_ADDR']));
     return new Response(html::em('results', array('voted' => (bool) $voted), $output), 'text/xml');
 }
Example #30
Show file File: class.backuprpc.php Project: umonkey/molinos-cms
0
 public static function on_download(Context $ctx)
 {
     zip::fromFolder($zipFile = os::path($ctx->config->getPath('main/tmpdir'), 'backup.zip'), MCMS_ROOT, realpath($ctx->config->getPath('main/tmpdir')));
     $filename = $ctx->host() . '-' . date('YmdHi', time() - date('Z', time())) . '.zip';
     header('Content-Type: application/zip');
     header('Content-Length: ' . filesize($zipFile));
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     readfile($zipFile);
     unlink($zipFile);
     die;
 }
Frequently Used Methods