示例#1
0
 function testGetFormRequestPost()
 {
     $app = new Application();
     $_POST['post'] = "Today I learnt that you can only treat your friends so badly before they quit working for you and go and work for Halutte(sp)";
     $array = $app->getArrayFromRequest();
     $this->assertEquals("Today I learnt that you can only treat your friends so badly before they quit working for you and go and work for Halutte(sp)", $array['post']);
 }
示例#2
0
 public function __construct($message, $code)
 {
     Log::add($message . 'URI: ' . $_SERVER['REQUEST_URI'], $code);
     if (!DEV) {
         switch ($code) {
             case 500:
                 Fw_Request::setGet('hard_controller', 'err');
                 Fw_Request::setGet('hard_action', 'error' . $code);
                 $error_app = new Application();
                 $error_app->run();
                 die;
                 break;
             case 404:
             default:
                 Fw_Request::setGet('hard_controller', 'err');
                 Fw_Request::setGet('hard_action', 'error' . $code);
                 $error_app = new Application();
                 $error_app->run();
                 die;
                 break;
         }
     }
     $code = 0;
     parent::__construct($message);
 }
示例#3
0
 /**
  * Implementation for 'POST' method for Rest API
  *
  * @param  mixed $appUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function post($appUid, $appNumber, $appParent, $appStatus, $proUid, $appProcStatus, $appProcCode, $appParallel, $appInitUser, $appCurUser, $appCreateDate, $appInitDate, $appFinishDate, $appUpdateDate, $appData, $appPin)
 {
     try {
         $result = array();
         $obj = new Application();
         $obj->setAppUid($appUid);
         $obj->setAppNumber($appNumber);
         $obj->setAppParent($appParent);
         $obj->setAppStatus($appStatus);
         $obj->setProUid($proUid);
         $obj->setAppProcStatus($appProcStatus);
         $obj->setAppProcCode($appProcCode);
         $obj->setAppParallel($appParallel);
         $obj->setAppInitUser($appInitUser);
         $obj->setAppCurUser($appCurUser);
         $obj->setAppCreateDate($appCreateDate);
         $obj->setAppInitDate($appInitDate);
         $obj->setAppFinishDate($appFinishDate);
         $obj->setAppUpdateDate($appUpdateDate);
         $obj->setAppData($appData);
         $obj->setAppPin($appPin);
         $obj->save();
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
 }
示例#4
0
 /**
  * Конструктор (проверка авторизации):
  */
 public function __construct(Application $application, Template $template)
 {
     $session = Session::getInstance();
     if (!$session->isAdminSession()) {
         die($application->go('errors_error403'));
     }
 }
示例#5
0
 public function AdminList(\Application $application)
 {
     $ret = '<h1>Manage plugins</h1>
         <div class="table-wrapper"><form action="" method="POST"><table><tr><th>Plugin Name</th><th>Active</th><th>Description</th><th>Version</th></tr>';
     $installed = $this->model->InstalledPlugins();
     foreach ($this->model->GetAvailablePlugins() as $available => $facade) {
         $data = $application->GetPluginMeta($available);
         if (!in_array($available, $application->GetConstantPlugins())) {
             $ret .= '<tr><td>' . (!empty($data->Name) ? $data->Name : $available) . '</td>
             <td>
             <div class="onoffswitch">
                 <input type="hidden" name="plugin[' . $available . '][action]" value="' . (!in_array($available, $installed) ? 'uninstalled' : '') . '"/>
                 <input type="checkbox" name="plugin[' . $available . '][value]" id="myonoffswitch_' . $available . '" class="onoffswitch-checkbox checkbox-submit" ' . (in_array($available, $installed) ? 'checked="checked"' : '') . '/>
                 <label class="onoffswitch-label" for="myonoffswitch_' . $available . '">
                     <span class="onoffswitch-inner"></span>
                     <span class="onoffswitch-switch"></span>
                 </label>
             </div>
             </td>
             <td>' . (!empty($data->Description) ? $data->Description : '<em>Unavailable</em>') . '</td>
             <td>' . (!empty($data->Version) ? $data->Version : '<em>Unavailable</em>') . '</td></tr>';
         }
     }
     return $ret . '</table></div><input type="hidden" name="placeholder" value="1"/><button type="submit" name="submit">Submit</button></form>';
 }
 private static function createDatabase()
 {
     $application = new Application(static::$kernel);
     // drop the database
     $command = new DropDatabaseDoctrineCommand();
     $application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:database:drop', '--force' => true));
     $command->run($input, new NullOutput());
     // we have to close the connection after dropping the database
     //  so we don't get "No database selected" error
     $connection = $application->getKernel()->getContainer()->get('doctrine')->getConnection();
     if ($connection->isConnected()) {
         $connection->close();
     }
     // create the database
     $command = new CreateDatabaseDoctrineCommand();
     $application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:database:create'));
     $command->run($input, new NullOutput());
     // create the database
     $command = new CreateSchemaDoctrineCommand();
     $application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:schema:create', '--em' => 'default'));
     $command->run($input, new NullOutput());
     // get the Entity Manager
     $em = static::$kernel->getContainer()->get('doctrine')->getManager();
     // load fixtures
     $client = static::createClient();
     $loader = new ContainerAwareLoader($client->getContainer());
     $loader->loadFromDirectory(static::$kernel->locateResource('@MainBundle/DataFixtures/ORM'));
     $purger = new ORMPurger($em);
     $executor = new ORMExecutor($em, $purger);
     $executor->execute($loader->getFixtures());
 }
示例#7
0
 /**
  * @param array $app
  * @param array $config
  * @throws AppException
  */
 public function __construct($app, $config = array())
 {
     parent::__construct($app, $config);
     $this->_jbrequest = $this->app->jbrequest;
     $task = $this->_jbrequest->getWord('task');
     $ctrl = $this->_jbrequest->getCtrl();
     if (!method_exists($this, $task)) {
         throw new AppException('Action method not found!  ' . $ctrl . ' :: ' . $task . '()');
     }
     // internal vars
     $this->application = $this->app->zoo->getApplication();
     $this->_params = $this->application->getParams('frontpage');
     $this->joomla = $this->app->system->application;
     $isSite = $this->app->jbenv->isSite();
     if (!$isSite) {
         $this->app->document->addStylesheet("root:administrator/templates/system/css/system.css");
         $this->app->jbassets->uikit(true, true);
         $this->_setToolbarTitle();
     } else {
         $this->params = $this->joomla->getParams();
         $this->pathway = $this->joomla->getPathway();
         $this->app->jbassets->setAppCSS();
         $this->app->jbassets->setAppJS();
     }
     $this->_config = JBModelConfig::model();
 }
示例#8
0
 /**
  * 退出登录处理
  *
  */
 public function doLogout()
 {
     $_SESSION['admin'] = false;
     session_destroy();
     $this->app->redirect($this->app->cfg['url']['root'] . 'system/');
     exit;
 }
示例#9
0
 /**
  * {@inheritdoc}
  */
 public function createResponse(Application $application, Request $request, Socket $socket) : Response
 {
     if (!$request->hasHeader('Sec-WebSocket-Key')) {
         $sink = new MemorySink('No WebSocket key header provided.');
         return new BasicResponse(Response::BAD_REQUEST, ['Connection' => 'close', 'Content-Length' => $sink->getLength()], $sink);
     }
     $headers = ['Connection' => 'upgrade', 'Upgrade' => 'websocket', 'Sec-WebSocket-Accept' => $this->responseKey(trim($request->getHeader('Sec-WebSocket-Key')))];
     if ($application instanceof SubProtocol) {
         $protocol = $application->selectSubProtocol(array_map('trim', explode(',', $request->getHeader('Sec-WebSocket-Protocol'))));
         if (strlen($protocol)) {
             $headers['Sec-WebSocket-Protocol'] = $protocol;
         }
     }
     /*
     $extensions = $application->selectExtensions(
         array_map('trim', explode(',', $request->getHeader('Sec-WebSocket-Extensions')))
     );
     
     if (!empty($extensions)) {
         $headers['Sec-WebSocket-Extensions'] = $extensions;
     }
     */
     $response = new BasicResponse(Response::SWITCHING_PROTOCOLS, $headers);
     $connection = $this->createConnection($response, $socket, false);
     return new WebSocketResponse($application, $connection, $response);
 }
示例#10
0
/**
 * Preps the application for running, then runs it. If this function is called more than once, an E_USER_ERROR is triggered.
 * 
 * @param string $root_dir The path to the root of the installation.
 * @return void
 */
function StartCurator()
{
    static $did_start = false;
    // set up the exit status.
    $exit_status = 0;
    // make sure this is only run once.
    if ($did_start === false) {
        $autoload = Autoload::singleton();
        // configure the autoloader.
        try {
            $autoload->setBaseDir(CURATOR_APP_DIR);
            $autoload->register();
        } catch (\Exception $e) {
            Console::stderr('** Could not register the autoloader:');
            Console::stderr('   ' . $e->getMessage());
            die;
        }
        // once the autoloader is in place, we are started up.
        $did_start = true;
        try {
            $app = new Application();
            $exit_status = $app->run();
        } catch (\Exception $e) {
            Console::stderr('** Could not run the application:');
            Console::stderr('   ' . $e->getMessage());
            die;
        }
    } else {
        // if we are called again, bail.
        trigger_error('StartCurator called after already being called.', E_USER_ERROR);
    }
    // send the status back.
    return $exit_status;
}
示例#11
0
 /**
  *
  * @param clagiordano\weblibs\mvc\Application $application
  * @return clagiordano\weblibs\mvc\Controller
  */
 public function __construct(Application $application)
 {
     $this->application = $application;
     $this->request = new Request();
     $this->application->getRegistry()->requestType = $this->request->getType();
     $this->application->getRegistry()->requestData = $this->request->getData();
 }
示例#12
0
 /**
 	Get core application class
 		@public
 	**/
 static function &getApplication()
 {
     static $app;
     // create if don't exists
     if (!is_object($app)) {
         // single app instance only
         if (isset($GLOBALS['_globalapp'])) {
             $app = $GLOBALS['_globalapp'];
         } else {
             $app = new Application();
             // config
             $config =& Factory::getConfig();
             $app->set('config', $config);
             // authentication
             $auth =& Factory::getAuth();
             $app->set('auth', $auth);
             // set our timezone
             if (isset($config->timezone)) {
                 @(list($tz_script, $tz_db) = explode('|', $config->timezone));
                 date_default_timezone_set($tz_script);
             }
             $GLOBALS['_globalapp'] = $app;
         }
     }
     return $app;
 }
示例#13
0
 public function generatePage($view, $data = array())
 {
     $app = new Application();
     $template = $app->getTemplate();
     include $template;
     //include PATH_SITE.'/templates/default_theme/index.php';
 }
示例#14
0
 /**
  * Helper function to create a new application with a new keypair.
  * @param type $title
  * @return \IdnoPlugins\OAuth2\Application
  */
 public static function newApplication($title)
 {
     $app = new Application();
     $app->setTitle($title);
     $app->generateKeypair();
     return $app;
 }
 /**
  * Execute a command.
  *
  * @param $command
  * @return mixed
  */
 public function execute($command)
 {
     $validator = $this->translator->toValidator($command);
     if (class_exists($validator)) {
         $this->app->make($validator)->validate($command);
     }
     return $this->bus->execute($command);
 }
示例#16
0
 /**
  * Add a new main menu. Sticky means that it will be shown for all applications.
  *
  * @param MenuShortcut $menu
  * @param Application $application     The application this menu is linked to, if null it is always shown
  */
 public function addMenu(MenuShortcut $menu, Application $application = null)
 {
     $context = $application ? $application->getApplicationId() : 'global';
     if (!isset($this->menus[$context])) {
         $this->menus[$context] = [];
     }
     $this->menus[$context][] = $menu;
 }
示例#17
0
文件: User.php 项目: kzfk/emlauncher
 public function getAppInstallDate(Application $app, $format = null)
 {
     $install_apps = $this->getInstallApps();
     if (isset($install_apps[$app->getId()])) {
         return $install_apps[$app->getId()]->getLastInstalled();
     }
     return null;
 }
示例#18
0
 /**
  * Check if a page has any answers associated with it for a specific application
  * @param Page $page
  * @param Application $application
  * @return boolean
  */
 public function hasApplicationAnswers(Page $page, Application $application)
 {
     $query = $this->_em->createQuery('SELECT COUNT(answer.id) as ancnt FROM Jazzee\\Entity\\Answer answer JOIN answer.applicant applicant WHERE answer.page = :pageId AND applicant.application = :applicationId');
     $query->setParameter('pageId', $page->getId());
     $query->setParameter('applicationId', $application->getId());
     $result = $query->getResult();
     return $result[0]['ancnt'] > 0;
 }
示例#19
0
 /**
  * Unregister a collector
  * 
  * @param   string  $name
  */
 public function unregisterCollector($name)
 {
     $name = strtolower($name);
     $collectors = $this->app->config()->read('collectors');
     $collectors += $this->getCollectors();
     unset($collectors[$name]);
     $this->app->config()->write('collectors', $collectors);
 }
示例#20
0
 /**
  * Enqueue message and redirect
  *
  * @param Application $App
  * @param $type
  * @param $message
  * @param $redirect_identifier
  * @param $redirect_parameters
  */
 public static function enqueueRedirect($App, $type, $message, $redirect_identifier, $redirect_parameters = [])
 {
     if (!$App instanceof \Cyan\Framework\ApplicationWeb) {
         throw new \Cyan\Framework\ApplicationException('$App must be a instance of Cyan\\Framework\\ApplicationWeb.');
     }
     $type = strtolower($type);
     $App->enqueueMessage($App->Text->translate($message), ucfirst($type), self::$classes[$type]);
     $App->Router->redirect(strpos($redirect_identifier, '://') === false ? $App->Router->generate($redirect_identifier, $redirect_parameters) : $redirect_identifier);
 }
示例#21
0
 /**
  * Create a fresh mock instance for the given class.
  *
  * @param  string  $name
  * @return \Mockery\Expectation
  */
 protected static function createFreshMockInstance($name)
 {
     static::$resolvedInstance[$name] = $mock = static::createMockByName($name);
     $mock->shouldAllowMockingProtectedMethods();
     if (isset(static::$app)) {
         static::$app->instance($name, $mock);
     }
     return $mock;
 }
示例#22
0
 function test__get_installed_version()
 {
     $id = 'news';
     $language = 'french';
     $app = new Application($id, $language);
     $vers = $app->_get_installed_version();
     self::assertEquals($vers, '0');
     // TODO(__FILE__, __METHOD__);
 }
示例#23
0
 /**
  * コンストラクタ
  *
  * @param Application $application
  */
 public function __construct($application)
 {
     $this->controller_name = strtolower(substr(get_class($this), 0, -10));
     $this->application = $application;
     $this->request = $application->getRequest();
     $this->response = $application->getResponse();
     $this->session = $application->getSession();
     $this->db_manager = $application->getDbManager();
 }
示例#24
0
 public function initLanguage(Application $currentApp, $type)
 {
     if ($type === "default") {
         return $currentApp->config()->get(Enums\AppSettingKeys::DefaultLanguage);
     }
     if ($type === "browser") {
         return substr(strtok($_SERVER['HTTP_ACCEPT_LANGUAGE'], '?'), 0, 2);
     }
 }
/**
 * Begins execution of the plugin.
 *
 * Since everything within the plugin is registered via hooks,
 * then kicking off the plugin from this point in the file does
 * not affect the page life cycle.
 *
 * @since    1.0.0
 */
function run()
{
    /**
     * The core plugin class that is used to define internationalization,
     * admin-specific hooks, and public-facing site hooks.
     */
    $plugin = new Application();
    $plugin->run();
}
示例#26
0
 private function __construct(Application $app)
 {
     $this->app = $app;
     if (!$this->name) {
         //throw new Exception(sprintf('The name of service %s is not defined', static::class));
         throw new Exception(sprintf('The name of service %s is not defined', get_called_class()));
     }
     $app->addService($this->name, $this);
 }
示例#27
0
 /**
  * Uninstall Application
  *
  * @param Application $application
  * @since 2.0
  * @throws InstallHelperException
  */
 public function uninstallApplication(Application $application)
 {
     $group = $application->getGroup();
     if ($this->_applicationExists($group)) {
         throw new InstallHelperException('Delete existing applications first.');
     }
     if (!($directory = $this->app->path->path("applications:{$group}")) || !JFolder::delete($directory)) {
         throw new InstallHelperException('Unable to delete directory: (' . $directory . ')');
     }
 }
示例#28
0
 private function needSetPassword(Application $app, Database $db, \DBMappers\EmpItem $empMapper)
 {
     if ($app->isAuthorized()) {
         $empItem = $empMapper->getById($app->getEmpId(), $db);
         if ($empItem->isPasswordEqual(null) && $this->controllerName != EMPLOYEE_CONTROLLER && $this->controllerName != LOGIN_CONTROLLER) {
             $app->setStateRedirect(EMPLOYEE_URL . '/edit/' . $empItem->getId());
             return true;
         }
     }
     return false;
 }
示例#29
0
 /**
  * Constructor, set internal vars
  * @param $app
  */
 public function __construct($app)
 {
     // load libs
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     // set internal vars
     $this->app = $app;
     $this->_name = strtolower(basename(get_class($this), 'Helper'));
     $this->_application = $app->zoo->getApplication();
     $this->_rendererPath = $this->_application->getPath() . '/templates/' . $this->_application->params->get('template') . '/renderer';
 }
示例#30
0
 public static function initialise()
 {
     require_once 'vendor/autoload.php';
     try {
         require_once 'lib/routing.php';
         $uri = Routing::fetch_uri();
         $controller = ucfirst($uri['controller']) . 'Controller';
         @(include "controllers/{$uri['controller']}_controller.php");
         if (substr($uri['action'], 0, 1) == '?') {
             $uri['action'] = '';
         }
         if (empty($uri['action']) && method_exists($controller, 'index')) {
             $uri['action'] = 'index';
         }
         // If controller found and action exists
         if (class_exists($controller) && method_exists($controller, $uri['action'])) {
             $app = new $controller();
         } else {
             $uri = Routing::route();
             $controller = ucfirst($uri['controller']) . 'Controller';
             include "controllers/{$uri['controller']}_controller.php";
             $app = new $controller();
         }
         $app->loadConfig();
         $app->loadTwig();
         $app->loadAws();
         $app->loadModels();
         $app->loadPlugins();
         $app->uri = $uri;
         // Helper var to simplify reponding to json
         $app->json = $app->uri['format'] == 'json';
         require_once 'lib/filter.php';
         $app->runFilters();
         $app->loadDefaultLibs();
         // Set timezone from config
         date_default_timezone_set($config->timezone);
         // Call relevant function in controller
         $app->loadAction();
         unset($_SESSION['flash']);
     } catch (ValidationException $e) {
         ob_end_clean();
         Application::flash('error', $e->getMessage());
         header('Location: ' . $_SERVER['HTTP_REFERER']);
     } catch (RoutingException $e) {
         ob_end_flush();
         // RoutingExceptions only thrown from static context
         // so must set up new Application before rendering 404
         $app = new Application();
         $app->loadView('pages/404');
     } catch (ApplicationException $e) {
         ob_end_flush();
         $e->app->loadView('pages/500');
     }
 }