Ejemplo n.º 1
0
 public function Test_of_addObserver()
 {
     $Observed = new ObservedPerson();
     $null = null;
     $Observer =& Ak::singleton('ObservedPersonObserver', $null);
     $params = 'ObservedAccount';
     $Auditor =& Ak::singleton('TestAuditor', $params);
     $Auditor->observe($Observed);
     $ObeserversReference =& $Observed->getObservers();
     $ObeserversReference[0]->message = 'Hello. I come from the past';
     $this->assertEqual($ObeserversReference[0]->__singleton_id, $Observer->__singleton_id);
     $this->assertReference($ObeserversReference[1], $Auditor);
 }
Ejemplo n.º 2
0
    /**
	* AkCharset::RecodeString() Pure PHP implementation
	*
	* @access private
	* @uses _Utf8StringEncode
	* @uses _Utf8StringDecode
	* @see RecodeString
	* @see _Utf8StringEncode
	* @see _Utf8StringDecode
	* @return    string    Recoded string if possible, otherwise it will
	* return the string without modifications.
	*/
    function _PhpStringRecode($string, $target_charset, $origin_charset)
    {
        $target_charset = $this->_GetCharset($target_charset,false);
        $origin_charset = $this->_GetCharset($origin_charset,false);

        if((!$this->_ConversionIsNeeded($origin_charset, $target_charset)|!$this->usePhpRecoding) && !$this->isUtf8($string)){
            return $string;
        }
        if($origin_charset=='utf8'){
            include_once(AK_LIB_DIR.DS.'AkCharset'.DS.'utf8_mappings'.DS.$target_charset.'.php');
            if(class_exists($target_charset)){

                $mappingObject =& Ak::singleton($target_charset, $target_charset);

                if(method_exists($mappingObject,'_Utf8StringDecode')){
                    return $mappingObject->_Utf8StringDecode($string);
                }else{
                    return $string;
                }
            }else{
                return $string;
            }
        }elseif($target_charset=='utf8'){
            include_once(AK_LIB_DIR.DS.'AkCharset'.DS.'utf8_mappings'.DS.$origin_charset.'.php');
            if(class_exists($origin_charset)){
                $mappingObject =& Ak::singleton($origin_charset, $origin_charset);
                if(method_exists($mappingObject,'_Utf8StringEncode')){
                    return $mappingObject->_Utf8StringEncode($string);
                }else{
                    return $string;
                }
            }else{
                return $string;
            }
        }else{
            $utf8String = $this->_PhpStringRecode($string,'utf8',$origin_charset);
            return $this->_PhpStringRecode($utf8String,$target_charset,'utf8');
        }
    }// -- end of &_PhpStringRecode -- //
Ejemplo n.º 3
0
/**
 * Function for getting the singleton controller;
 *
 * @return AkActionController instance
 */
function &AkActionController()
{
    $params = func_num_args() == 0 ? null : func_get_args();
    $AkActionController =& Ak::singleton('AkActionController', $params);
    return $AkActionController;
}
Ejemplo n.º 4
0
 function init($options = array())
 {
     $default_options = array('inflector' => 'AkInflector', 'file_path' => false);
     $options = array_merge($default_options, $options);
     $this->_code = $options['code'];
     require_once AK_LIB_DIR . DS . $options['inflector'] . '.php';
     $this->_Inflector = Ak::singleton('AkInflector', $options['inflector']);
     $this->options = $options;
 }
Ejemplo n.º 5
0
function &AkRouter()
{
    $null = null;
    $AkRouter =& Ak::singleton('AkRouter', $null);
    return $AkRouter;
}
Ejemplo n.º 6
0
 /**
  * AkCharset::recodeString() Pure PHP implementation
  *
  * @access private
  * @uses _utf8StringEncode
  * @uses _utf8StringDecode
  * @see recodeString
  * @see _utf8StringEncode
  * @see _utf8StringDecode
  * @return    string    Recoded string if possible, otherwise it will
  * return the string without modifications.
  */
 protected function _phpStringRecode($string, $target_charset, $origin_charset)
 {
     $target_charset = $this->_getCharset($target_charset, false);
     $origin_charset = $this->_getCharset($origin_charset, false);
     if (!$target_charset || !$origin_charset || (!$this->_conversionIsNeeded($origin_charset, $target_charset) || !$this->usePhpRecoding) && !$this->isUtf8($string)) {
         return $string;
     }
     if ($origin_charset == 'utf8') {
         require_once AK_ACTIVE_SUPPORT_DIR . DS . 'i18n' . DS . 'charset' . DS . 'utf8_mappings' . DS . $target_charset . '.php';
         if (class_exists($target_charset)) {
             $mappingObject =& Ak::singleton($target_charset, $target_charset);
             if (method_exists($mappingObject, '_utf8StringDecode')) {
                 return $mappingObject->_utf8StringDecode($string);
             } else {
                 return $string;
             }
         } else {
             return $string;
         }
     } elseif ($target_charset == 'utf8') {
         require_once AK_ACTIVE_SUPPORT_DIR . DS . 'i18n' . DS . 'charset' . DS . 'utf8_mappings' . DS . $origin_charset . '.php';
         if (class_exists($origin_charset)) {
             $mappingObject =& Ak::singleton($origin_charset, $origin_charset);
             if (method_exists($mappingObject, '_utf8StringEncode')) {
                 return $mappingObject->_utf8StringEncode($string);
             } else {
                 return $string;
             }
         } else {
             return $string;
         }
     } else {
         $utf8String = $this->_phpStringRecode($string, 'utf8', $origin_charset);
         return $this->_phpStringRecode($utf8String, $target_charset, 'utf8');
     }
 }
Ejemplo n.º 7
0
 /**
  * AkCharset::RecodeString() Pure PHP implementation
  *
  * @access private
  * @uses _Utf8StringEncode
  * @uses _Utf8StringDecode
  * @see RecodeString
  * @see _Utf8StringEncode
  * @see _Utf8StringDecode
  * @return    string    Recoded string if possible, otherwise it will
  * return the string without modifications.
  */
 function _PhpStringRecode($string, $target_charset, $origin_charset)
 {
     $this->_originCharset = $origin_charset;
     $this->_error = false;
     $target_charset = $this->_GetCharset($target_charset, false);
     $origin_charset = $this->_GetCharset($origin_charset, false);
     if (empty($origin_charset)) {
         $this->_error = true;
         return $string;
     }
     if (!$this->_ConversionIsNeeded($origin_charset, $target_charset) | !$this->usePhpRecoding && !$this->isUtf8($string)) {
         return $string;
     }
     if ($origin_charset == 'utf8') {
         include_once AK_LIB_DIR . DS . 'AkCharset' . DS . 'utf8_mappings' . DS . $target_charset . '.php';
         if (class_exists($target_charset)) {
             $mappingObject =& Ak::singleton($target_charset, $target_charset);
             if (method_exists($mappingObject, '_Utf8StringDecode')) {
                 return $mappingObject->_Utf8StringDecode($string);
             } else {
                 return $string;
             }
         } else {
             return $string;
         }
     } elseif ($target_charset == 'utf8') {
         @(include_once AK_LIB_DIR . DS . 'AkCharset' . DS . 'utf8_mappings' . DS . Ak::sanitize_include($origin_charset, 'paranoid') . '.php');
         if (class_exists($origin_charset)) {
             $mappingObject =& Ak::singleton($origin_charset, $origin_charset);
             if (method_exists($mappingObject, '_Utf8StringEncode')) {
                 return $mappingObject->_Utf8StringEncode($string);
             } else {
                 return $string;
             }
         } else {
             return $string;
         }
     } else {
         $utf8String = $this->_PhpStringRecode($string, 'utf8', $origin_charset);
         return $this->_PhpStringRecode($utf8String, $target_charset, 'utf8');
     }
 }
Ejemplo n.º 8
0
 function _init($url, $constants = array(), $controllerVars = array())
 {
     $this->_reset();
     $this->_response = null;
     $this->_cacheHeaders = array();
     $this->_setConstants($constants);
     $parts = parse_url($url);
     $_REQUEST['ak'] = isset($parts['path']) ? $parts['path'] : '/';
     $_SERVER['AK_HOST'] = isset($parts['host']) ? $parts['host'] : 'localhost';
     $cache_settings = Ak::getSettings('caching', false);
     if ($cache_settings['enabled']) {
         require_once AK_LIB_DIR . DS . 'AkActionController' . DS . 'AkCacheHandler.php';
         $null = null;
         $pageCache =& Ak::singleton('AkCacheHandler', $null);
         $pageCache->init($null, $cache_settings);
         if ($cachedPage = $pageCache->getCachedPage()) {
             static $_cachedHeaders = array();
             ob_start();
             global $sendHeaders, $returnHeaders, $exit;
             $sendHeaders = false;
             $returnHeaders = true;
             $exit = false;
             $headers = (include $cachedPage);
             //$headers = $cachedPage->render(false,false,true);
             $this->_response = ob_get_clean();
             if (is_array($headers)) {
                 $this->_cacheHeaders = $headers;
             }
             return true;
         }
     }
     require_once AK_LIB_DIR . DS . 'AkUnitTest' . DS . 'AkTestDispatcher.php';
     $this->Dispatcher =& new AkTestDispatcher($controllerVars);
 }
Ejemplo n.º 9
0
 protected function _instantiateDefaultObserver()
 {
     $default_observer_name = $this->getModelName() . 'Observer';
     if (class_exists($default_observer_name)) {
         Ak::singleton($default_observer_name, $this);
     }
 }
Ejemplo n.º 10
0
 function &AkResponse()
 {
     $null = null;
     $AkResponse =& Ak::singleton('AkResponse', $null);
     AK_LOG_EVENTS && empty($AkResponse->_Logger) ? $AkResponse->_Logger =& Ak::getLogger() : null;
     return $AkResponse;
 }
Ejemplo n.º 11
0
 function _getCachedPage($path)
 {
     $controller=$this->getController();
     if ($controller) {
         $cachedPage = $controller->getCachedPage($path);
     } else {
         $pageCache = &Ak::singleton('AkCacheHandler',$null);
         $null = null;
         $pageCache->init($null, 'file');
         $cachedPage=$pageCache->getCachedPage($path);
     }
     return $cachedPage;
 }
Ejemplo n.º 12
0
 static function recode($text, $output_string_encoding = null, $input_string_encoding = null, $recoding_engine = null)
 {
     $input_string_encoding = empty($input_string_encoding) ? Ak::encoding() : $input_string_encoding;
     $Charset = Ak::singleton('AkCharset', $text);
     return $Charset->recodeString($text, $output_string_encoding, $input_string_encoding, $recoding_engine);
 }
Ejemplo n.º 13
0
 /**
  * ########################################################################
  * #
  * #               Modules
  * #
  * ########################################################################
  */
 public function _initCacheHandler()
 {
     // TODOARNO
     $cache_settings = Ak::getSettings('caching', false);
     if ($cache_settings['enabled']) {
         $null = null;
         $this->_CacheHandler = Ak::singleton('AkCacheHandler', $null);
         $this->_CacheHandler->init($this);
     }
 }
Ejemplo n.º 14
0
function &AkRequest()
{
    var_dump('function AkRequest() should not be used, anymore. Do you need it?');
    $null = null;
    $AkRequest =& Ak::singleton('AkRequest', $null);
    return $AkRequest;
}
Ejemplo n.º 15
0
Archivo: Ak.php Proyecto: joeymetal/v1
 /**
  * Converts a JSON representation string into a PHP value.
  */
 function fromJson($json_string)
 {
     require_once AK_VENDOR_DIR . DS . 'pear' . DS . 'Services' . DS . 'JSON.php';
     $use = 0;
     $json =& Ak::singleton('Services_JSON', $use);
     return $json->decode($json_string);
 }
Ejemplo n.º 16
0
 function _initCacheHandler() 
 { 
     // TODOARNO
     $cache_settings = Ak::getSettings('caching', false);
     if ($cache_settings['enabled']) {
         $null = null;
         require_once(AK_LIB_DIR . DS . 'AkActionController' . DS . 'AkCacheHandler.php');
         $this->_CacheHandler =& Ak::singleton('AkCacheHandler', $null);
         $this->_CacheHandler->init(&$this);
     }
 }
Ejemplo n.º 17
0
function &AkResponse()
{
    $null = null;
    $AkResponse =& Ak::singleton('AkResponse', $null);
    return $AkResponse;
}
Ejemplo n.º 18
0
 /**
 * @access private
 */
 function _instantiateDefaultObserver()
 {
     $default_observer_name = ucfirst($this->getModelName().'Observer');
     if(class_exists($default_observer_name)){
         //$Observer =& new $default_observer_name($this);
         Ak::singleton($default_observer_name,  $this);
     }
 }
Ejemplo n.º 19
0
function &AkRequest()
{
    $null = null;
    $AkRequest =& Ak::singleton('AkRequest', $null);
    return $AkRequest;
}
Ejemplo n.º 20
0
<?php

//define('AK_HOST','localhost');
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
$host = AK_HOST;
require_once AK_LIB_DIR . DS . 'Ak.php';
$cache_settings = Ak::getSettings('caching', false);
if ($cache_settings['enabled']) {
    require_once AK_LIB_DIR . DS . 'AkActionController' . DS . 'AkCacheHandler.php';
    $null = null;
    $pageCache =& Ak::singleton('AkCacheHandler', $null);
    $pageCache->init($null, $cache_settings);
    if (isset($_GET['allow_get'])) {
        $options['include_get_parameters'] = split(',', $_GET['allow_get']);
    }
    if (isset($_GET['use_if_modified_since'])) {
        $options['use_if_modified_since'] = true;
    }
    if (($cachedPage = $pageCache->getCachedPage()) !== false) {
        $cachedPage->render();
    }
}
require_once AK_LIB_DIR . DS . 'AkDispatcher.php';
$Dispatcher =& new AkDispatcher();
$Dispatcher->dispatch();