예제 #1
0
파일: test.php 프로젝트: bermi/akelos
 public function deliver(&$Mailer, $settings = array())
 {
     $encoded_message = $Mailer->getRawMessage();
     $settings['ActionMailer']->deliveries[] = $encoded_message;
     if (!AK_PRODUCTION_MODE) {
         $Logger = Ak::getLogger('mail');
         $Logger->message($encoded_message);
     }
     if (AK_TEST_MODE) {
         Ak::setStaticVar('last_mail_delivered', $encoded_message);
     }
 }
예제 #2
0
파일: inflector.php 프로젝트: bermi/akelos
 static function loadConfig($dictionary)
 {
     static $_loaded = array();
     if (!($return = Ak::getStaticVar('AkInflectorConfig::' . $dictionary))) {
         $return = Ak::getSettings($dictionary, false);
         if ($return !== false) {
             Ak::setStaticVar('AkInflectorConfig::' . $dictionary, $return);
             $_loaded[$dictionary] = true;
         } else {
             trigger_error(Ak::t('Could not load inflector rules file: %file', array('%file' => 'config' . DS . $dictionary . '.yml')), E_USER_ERROR);
         }
     }
     return $return;
 }
예제 #3
0
파일: mongo_db.php 프로젝트: bermi/akelos
 public function connect($options = null)
 {
     $this->setOptions($options);
     if ($this->_meetsDependencies()) {
         $port = $this->getOption('port');
         if (!($Connection = Ak::getStaticVar(__CLASS__ . '_' . $this->_connetion_signature))) {
             try {
                 $Connection = new Mongo($this->getOption('host') . (empty($port) ? '' : ':' . $port));
             } catch (MongoConnectionException $e) {
                 $Connection = false;
             }
             Ak::setStaticVar(__CLASS__ . '_' . $this->_connetion_signature, $Connection);
         }
         $this->_Mongo[$this->_connetion_signature] = $Connection;
         if ($Connection && !$this->isConnected()) {
             $Connection->connect();
         }
     }
     return $this->isConnected();
 }
예제 #4
0
파일: observer.php 프로젝트: bermi/akelos
 /**
  * Register the reference to an object object
  *
  *
  * @param $observer AkObserver
  * @param $options array of options for the observer
  * @return void
  */
 public function addObserver($observer)
 {
     $staticVarNs = 'AkActiveModel::observers::' . $this->_Model->getModelName();
     $observer_class_name = get_class($observer);
     /**
      * get the statically stored observers for the namespace
      */
     $observers = Ak::getStaticVar($staticVarNs);
     if (!is_array($observers)) {
         $observers = array('classes' => array(), 'objects' => array());
     }
     /**
      * if not already registered, the observerclass will
      * be registered now
      */
     if (!in_array($observer_class_name, $observers['classes'])) {
         $observers['classes'][] = $observer_class_name;
         $observers['objects'][] = $observer;
         Ak::setStaticVar($staticVarNs, $observers);
     }
 }
예제 #5
0
파일: AkUnitTest.php 프로젝트: joeymetal/v1
 function populateTables()
 {
     
     $args = func_get_args();
     $tables = !empty($args) ? (is_array($args[0]) ? $args[0] : (count($args) > 1 ? $args : Ak::toArray($args))) : array();
     foreach ($tables as $table){
         $file = AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.(empty($this->module)?'':$this->module.DS).Ak::sanitize_include($table).'.yaml';
         if(!file_exists($file)){
             continue;
         }
         $class_name = AkInflector::classify($table);
         if($this->instantiateModel($class_name)){
             $contents = &Ak::getStaticVar('yaml_fixture_'.$file);
             if (!$contents) {
                 ob_start();
                 require_once($file);
                 $contents = ob_get_clean();
                 Ak::setStaticVar('yaml_fixture_'.$file, $contents);
             }
             $items = Ak::convert('yaml','array',$contents);
             foreach ($items as $item){
                 
                 $obj=&$this->{$class_name}->create($item);
                 if (isset($item['created_at'])) {
                     $obj->updateAttribute('created_at',$item['created_at']);
                 } else if (isset($item['created_on'])) {
                     $obj->updateAttribute('created_on',$item['created_on']);
                 }
             }
         }
     }
 }
예제 #6
0
 public function recognizeRouteForPath($path, $request_method = null)
 {
     $path = is_string($path) ? '/' . ltrim($path, '/') : (function_exists($path) ? $path() : $path);
     // Assume given controller
     Ak::setStaticVar('AkRouterSingleton', $this->Router);
     $Request = $this->_UnitTester->partialMock('AkRequest', array('getRequestedUrl', 'getPath', 'getMethod'), array('getRequestedUrl' => $path, 'getPath' => $path, 'getMethod' => empty($request_method) ? 'get' : $request_method));
     Ak::setStaticVar('AkRequestSingleton', $Request);
     $Request->mapRoutes($this->Router);
     $UrlWriter = new AkUrlWriter($Request, $this->Router);
     Ak::setStaticVar('AkUrlWriterSingleton', $UrlWriter);
     return $Request;
 }
예제 #7
0
파일: Ak.php 프로젝트: joeymetal/v1
 public function test_static_var_destruct_all_vars()
 {
     $value = new stdClass();
     $value->id = 1;
     $return = Ak::setStaticVar('testVar1', $value);
     $this->assertEqual(true, $return);
     $value2 = new stdClass();
     $value2->id = 2;
     $return = Ak::setStaticVar('testVar2', $value2);
     $this->assertEqual(true, $return);
     $value3 = new stdClass();
     $value3->id = 3;
     $return = Ak::setStaticVar('testVar3', $value3);
     $this->assertEqual(true, $return);
     $null = null;
     Ak::unsetStaticVar('testVar1');
     $storedValue1 =& Ak::getStaticVar('testVar1');
     $this->assertEqual($null, $storedValue1);
     $storedValue2 =& Ak::getStaticVar('testVar2');
     $this->assertEqual($value2, $storedValue2);
     $storedValue3 =& Ak::getStaticVar('testVar3');
     $this->assertEqual($value3, $storedValue3);
     Ak::unsetStaticVar($null);
     $storedValue1 =& Ak::getStaticVar('testVar1');
     $this->assertEqual($null, $storedValue1);
     $storedValue2 =& Ak::getStaticVar('testVar2');
     $this->assertEqual($null, $storedValue2);
     $storedValue3 =& Ak::getStaticVar('testVar3');
     $this->assertEqual($null, $storedValue3);
 }
예제 #8
0
파일: Ak.php 프로젝트: joeymetal/v1
 /**
  * Add a profile message that can be displayed after executing the script
  *
  * You can add benchmark markers by calling
  *
  *    Ak::profile('Searching for books');
  *
  * To display the results you need to call
  *
  *     Ak::profile(true);
  *
  * You might also find handy adding this to your application controller.
  *
  *     class ApplicationController extends BaseActionController
  *     {
  *         function __construct(){
  *             $this->afterFilter('_displayBenchmark');
  *             parent::__construct();
  *         }
  *         public function _displayBenchmark(){
  *             Ak::profile(true);
  *         }
  *     }
  *
  * IMPORTANT NOTE: You must define AK_ENABLE_PROFILER to true for this to work.
 */
 function profile($message = '')
 {
     if(AK_ENABLE_PROFILER){
         if(!$ProfileTimer = $Timer = Ak::getStaticVar('ProfileTimer')){
             require_once 'Benchmark/Timer.php';
             $ProfileTimer = new Benchmark_Timer();
             $ProfileTimer->start();
             Ak::setStaticVar('ProfileTimer', $ProfileTimer);
         }elseif($message === true){
             $ProfileTimer->display();
         }else {
             $ProfileTimer->setMarker($message);
         }
     }
 }
예제 #9
0
파일: resources.php 프로젝트: bermi/akelos
 public function tearDown()
 {
     foreach (array_keys($this->_singletons) as $singleton) {
         Ak::setStaticVar($singleton, $this->_singletons[$singleton]);
     }
 }
예제 #10
0
파일: base.php 프로젝트: bermi/akelos
function ak_test_case($test_case_name, $show_enviroment_flags = true)
{
    $test_cases = (array) Ak::getStaticVar('ak_test_cases');
    $test_cases[] = $test_case_name;
    Ak::setStaticVar('ak_test_cases', $test_cases);
    $levels = count(debug_backtrace());
    if ($levels == 1 || $levels == 2 && isset($_ENV['SCRIPT_NAME']) && $_ENV['SCRIPT_NAME'] == 'dummy.php') {
        if ($show_enviroment_flags) {
            echo "(" . AK_ENVIRONMENT . " environment) Error reporting set to: " . AkConfig::getErrorReportingLevelDescription() . "\n";
        }
        ak_test($test_case_name);
    }
}
예제 #11
0
 /**
  * caching the meta info
  *
  * @return unknown
  */
 function availableTables($force_lookup = false)
 {
     $available_tables = array();
     !AK_TEST_MODE && $available_tables = Ak::getStaticVar('available_tables');
     if(!$force_lookup && empty($available_tables)){
         if (($available_tables = AkDbSchemaCache::get('avaliable_tables')) === false) {
             if(empty($available_tables)){
                 $available_tables = $this->connection->MetaTables();                
             }
             AkDbSchemaCache::set('avaliable_tables', $available_tables);
             !AK_TEST_MODE && Ak::setStaticVar('available_tables', $available_tables);
         }
     }
     $available_tables = $force_lookup ? $this->connection->MetaTables() : $available_tables;
     $force_lookup && !AK_TEST_MODE && Ak::setStaticVar('available_tables', $available_tables);
     return $available_tables;
 }
예제 #12
0
파일: url_writer.php 프로젝트: bermi/akelos
 static function getInstance()
 {
     if (!($UrlWriter = Ak::getStaticVar('AkUrlWriterSingleton'))) {
         $UrlWriter = new AkUrlWriter();
         Ak::setStaticVar('AkUrlWriterSingleton', $UrlWriter);
     }
     return $UrlWriter;
 }
예제 #13
0
 static function &getInstance(AkActionController &$Controller)
 {
     if (!($CacheHandler = Ak::getStaticVar('AkCacheHandlerSingleton'))) {
         $settings = Ak::getSettings('caching', false);
         if (!empty($settings['enabled'])) {
             $CacheHandler = new AkCacheHandler();
             $CacheHandler->init($Controller);
             Ak::setStaticVar('AkCacheHandlerSingleton', $CacheHandler);
         }
     }
     return $CacheHandler;
 }
예제 #14
0
 /**
  * Creates an instance of each available helper and links it into into current controller.
  *
  * Per example, if a helper TextHelper is located into the file text_helper.php.
  * An instance is created on current controller
  * at $this->text_helper. This instance is also available on the view by calling $text_helper.
  *
  * Helpers can be found at lib/AkActionView/helpers (this might change in a future)
  */
 function instantiateHelpers()
 {
     Ak::setStaticVar('AkHelperLoader', $this->getHelperLoader());
     return;
     require_once AK_LIB_DIR . DS . 'AkActionView' . DS . 'AkHelperLoader.php';
     $HelperLoader = new AkHelperLoader();
     $HelperLoader->setController(&$this);
     $HelperLoader->instantiateHelpers();
     Ak::setStaticVar('AkHelperLoader', $HelperLoader);
 }
예제 #15
0
파일: request.php 프로젝트: bermi/akelos
 static function getInstance()
 {
     if (!($Request = Ak::getStaticVar('AkRequestSingleton'))) {
         $Request = new AkRequest();
         Ak::setStaticVar('AkRequestSingleton', $Request);
     }
     return $Request;
 }
예제 #16
0
 /**
  * In order to help rendering engines to know which helpers are available
  * we need to persit them as a static var.
  */
 function _storeInstantiatedHelperNames($helpers)
 {
     Ak::setStaticVar('AkActionView::instantiated_helper_names', $helpers);
 }
예제 #17
0
파일: base.php 프로젝트: bermi/akelos
 /**
  * @return AkRouter
  */
 static function getInstance()
 {
     if (!($Router = Ak::getStaticVar('AkRouterSingleton'))) {
         $Router = new AkRouter();
         $Router->loadMap();
         Ak::setStaticVar('AkRouterSingleton', $Router);
     }
     return $Router;
 }
예제 #18
0
파일: base.php 프로젝트: bermi/akelos
 public function setAdapter(&$Adapter)
 {
     $this->_Adapter = $Adapter;
     Ak::setStaticVar($this->getModelName() . '_last_used_Adapter', $Adapter);
     Ak::setStaticVar('AkActiveDocument_last_used_Adapter', $Adapter);
 }
예제 #19
0
    public function writeCache($config, $namespace, $environment = TPV_MODE, $force = false)
    {
        if (!$force && !$this->_useWriteCache($environment)) {
            return false;
        }
        $key = $this->_getCacheKey($namespace, $environment);
        Ak::setStaticVar($key, $config);
        $var_export = var_export($config, true);
        $cache = <<<CACHE
<?php
/**
 * Auto-generated config cache from {$namespace} in environment {$environment}
 */
\$config = {$var_export};
return \$config;

CACHE;
        $cache_file_name = $this->getCacheFileName($namespace, $environment);
        if (!Ak::file_put_contents($cache_file_name, $cache, array('base_path' => AkConfig::getCacheBasePath()))) {
            trigger_error(Ak::t('Could not create config cache file %file', array('%file' => $cache_file_name)) . ' ' . Ak::getFileAndNumberTextForError(1), E_USER_ERROR);
            return false;
        } else {
            return true;
        }
    }
예제 #20
0
파일: makelos.php 프로젝트: bermi/akelos
        $task_files = array_diff($task_files, array(''));
        if ($bark_on_error && empty($this->tasks[$task_name]['run']) && empty($task_files)) {
            $this->error("No task file found for {$task_name} in " . AK_TASKS_DIR, true);
        }
        return $task_files;
    }
    private function _ensurePosixAndPcntlAreAvailable()
    {
        if (!function_exists('posix_geteuid')) {
            trigger_error('POSIX functions not available. Please compile PHP with --enable-posix', E_USER_ERROR);
        } elseif (!function_exists('pcntl_fork')) {
            trigger_error('pcntl functions not available. Please compile PHP with --enable-pcntl', E_USER_ERROR);
        }
    }
}
Ak::setStaticVar('Makelos', new Makelos($MakelosRequest));
function makelos_task($task_name, $options = array())
{
    Ak::getStaticVar('Makelos')->defineTask($task_name, $options);
}
function makelos_setting($settings = array())
{
    Ak::getStaticVar('Makelos')->addSettings($settings);
}
/**
* @todo
*
*  Task
*      prequisites
*      actions
*      expected parameters
예제 #21
0
파일: session.php 프로젝트: bermi/akelos
 public function init($options = array(), $type = null)
 {
     $options = is_int($options) ? array('lifeTime' => $options) : (is_array($options) ? $options : array());
     switch ($type) {
         case 1:
             // session_save_path();
             $this->sessions_enabled = false;
             // Use PHP session handling
             session_start();
             return true;
         case 2:
             $AkDbSession = new AkDbSession();
             $AkDbSession->session_life = AK_SESSION_EXPIRE;
             session_set_save_handler(array($AkDbSession, '_open'), array($AkDbSession, '_close'), array($AkDbSession, '_read'), array($AkDbSession, '_write'), array($AkDbSession, '_destroy'), array($AkDbSession, '_gc'));
             /*
             $this->_driverInstance = new AkAdodbCache();
             $res = $this->_driverInstance->init($options);
             $this->sessions_enabled = $res;
             break;
             */
         /*
         $this->_driverInstance = new AkAdodbCache();
         $res = $this->_driverInstance->init($options);
         $this->sessions_enabled = $res;
         break;
         */
         case 3:
             $this->_driverInstance = new AkMemcache();
             $res = $this->_driverInstance->init($options);
             $this->sessions_enabled = $res;
             break;
         case 4:
             $this->_driverInstance = new AkCookieStore();
             $this->_driverInstance->init($options);
             Ak::setStaticVar('SessionHandler', $this->_driverInstance);
             return true;
         default:
             $this->sessions_enabled = false;
             break;
     }
     if ($this->sessions_enabled) {
         $this->sessionLife = $options['lifeTime'];
         session_set_save_handler(array($this, '_open'), array($this, '_close'), array($this, '_read'), array($this, '_write'), array($this, '_destroy'), array($this, '_gc'));
         session_start();
     }
 }
예제 #22
0
파일: base.php 프로젝트: bermi/akelos
 protected function _setCacheForModelMethod($method, &$value)
 {
     return AK_TEST_MODE || Ak::setStaticVar('AR_' . $this->getModelName() . $method, $value);
 }
예제 #23
0
파일: server.php 프로젝트: bermi/akelos
    {
        global $_headers, $_status;
        if (strstr($string, ':')) {
            $parts = explode(':', $string, 2);
            if (preg_match('/^[a-zA-Z\\- ]+$/', $parts[0])) {
                $_headers[] = ucfirst(strtolower($parts[0]));
                $_headers[] = $parts[1];
            }
        } elseif (preg_match('/^HTTP\\/1\\.1 (\\d+)$/', $string, $matches)) {
            $string = (int) $matches[1];
        }
    }
}
Ak::setStaticVar('AppServer.SessionHandler', new AkAppServerFunctionHandler());
Ak::setStaticVar('AppServer.HeadersHandler', new AkAppServerFunctionHandler());
Ak::setStaticVar('AppServer.PutsHandler', new AkAppServerFunctionHandler());
$_headers = array();
$_puts = '';
$_status = 200;
$counter = 0;
$app = new \MFS\AppServer\Middleware\URLMap\URLMap(array('/' => function ($context = null) {
    global $counter, $_headers, $_puts, $_status;
    $counter++;
    $_puts = '';
    $_status = 200;
    //AkConfig::setOption('Request.remote_ip', AK_REMOTE_IP);
    ob_start();
    $_headers = array('Server', 'Akelos (via AppServer)');
    $Dispatcher = new AkDispatcher();
    $Response = $Dispatcher->dispatchAppServer($context);
    if (count($_headers) == 2) {