Changeset 5399 for trunk/prototype/api


Ignore:
Timestamp:
01/18/12 16:10:57 (12 years ago)
Author:
cristiano
Message:

Ticket #2434 - Alteração da estrutura de diretórios da nova API

Location:
trunk/prototype
Files:
12 deleted
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/prototype

    • Property svn:ignore set to
      .links.php.kate-swp
  • trunk/prototype/api/cache/MemoryCache.php

    r5341 r5399  
    4242 
    4343    public function  __construct($conf=Null) { 
    44         $this->_memcache = new Memcache(); 
    45         $this->_config = $conf; 
     44        //$this->_memcache = new Memcache(); 
     45//        $this->_config = $conf; 
    4646 
    4747        // host, port, persistent, weight 
    48         if($conf!==Null){ 
    49             foreach ($conf as $c){ 
    50                 $result = $this->_memcache->addServer($c[0], $c[1], $c[2], $c[3]); 
    51             } 
    52         } 
    53         else{ 
    54             $this->_memcache->addServer('localhost', 11211); 
    55         } 
     48//        if($conf!==Null){ 
     49//            foreach ($conf as $c){ 
     50//                $result = $this->_memcache->addServer($c[0], $c[1], $c[2], $c[3]); 
     51//            } 
     52//        } 
     53//        else{ 
     54//            $this->_memcache->addServer('localhost', 11211); 
     55//        } 
    5656    } 
    5757 
     
    6767    public function put($id, $data, $expire=0, $compressed=false){ 
    6868 
    69         ob_start(); 
    70         print_r( "criando $id e armazenando no cache" ); 
    71         $output = ob_get_clean(); 
    72         file_put_contents( "/tmp/cache.log", file_get_contents( "/tmp/cache.log" ) . $output . "\n" ); 
    7369 
    7470//         if($compressed) 
     
    8985//         $return = $this->_memcache->get($id); 
    9086          $return = false; 
    91  
    92         if( $return ){ 
    93             ob_start(); 
    94             print_r( "lendo $id do cache" ); 
    95             $output = ob_get_clean(); 
    96             file_put_contents( "/tmp/cache.log", file_get_contents( "/tmp/cache.log" ) . $output . "\n" ); 
    97         } 
    9887 
    9988        return( $return ); 
  • trunk/prototype/api/config.php

    r5341 r5399  
    88    static function module($config , $module = false) 
    99    { 
    10         self::init(); 
    11        
    1210        //Todo: registrar na nova api o currentapp 
    1311        if(!$module) 
    1412            $module =  $_SESSION['flags']['currentapp']; 
    15         /* 
    16         if( !isset( $_SESSION['config'][$module] ) ) 
    17             Carregar Config do modulo 
    18          */   
     13   
     14        if( !isset( $_SESSION['config'][$module] ) || !isset( $_SESSION['config'][$module][$config] )) 
     15            $_SESSION['config'][$module] = parse_ini_file( ROOTPATH."/config/$module.ini", true ); 
    1916         
    2017        return isset($_SESSION['config'][$module][$config]) ? $_SESSION['config'][$module][$config] : false; 
     
    2421    static function me($config) 
    2522    { 
    26         self::init(); 
     23         
    2724        return isset($_SESSION['wallet']['user'][$config]) ? $_SESSION['wallet']['user'][$config] : false; 
    28       
    2925    } 
    30  
     26     
     27    static function service( $service , $config ) 
     28    { 
     29        if( !isset( $_SESSION['wallet'][$service] ) || !isset( $_SESSION['wallet'][$service][$config] )) 
     30            $_SESSION['wallet'][$service] = parse_ini_file( ROOTPATH."/config/$service.srv", true ); 
     31         
     32        return isset($_SESSION['wallet'][$service][$config]) ? $_SESSION['wallet'][$service][$config] : false; 
     33    } 
     34     
    3135    static function regSet( $name , $value) 
    3236    { 
    33             self::$register[$name] = $value; 
     37        self::$register[$name] = $value; 
    3438    } 
    3539    static function regGet ($name ) 
    3640    { 
    37             return (isset(self::$register[$name]) ? self::$register[$name] : false ); 
     41        return (isset(self::$register[$name]) ? self::$register[$name] : false ); 
    3842    } 
    3943 
    40     static function init() 
     44    static function init( $header = false ) 
    4145    { 
    42         if ( isset( $_COOKIE[ 'sessionid' ] ) )  
    43             session_id( $_COOKIE[ 'sessionid' ] );  
     46         
     47        if( !defined( 'ROOTPATH' ) ) 
     48            define( 'ROOTPATH', dirname(__FILE__).'/..' ); 
     49         
     50        if ( isset( $_COOKIE[ 'sessionid' ] ) )  
     51        { 
     52            session_id( $_COOKIE[ 'sessionid' ] );  
     53            $GLOBALS['phpgw']->session->sessionid = $_COOKIE[ 'sessionid' ]; 
     54        } 
     55                 
     56        if( !self::$sessionStarted ) 
     57            self::$sessionStarted = session_start(); 
     58                 
     59        if( $header === true ) 
     60        { 
     61            require_once (dirname(__FILE__).'/../../header.inc.php'); 
    4462 
    45         if( !self::$sessionStarted ) 
    46             self::$sessionStarted = session_start(); 
     63            $_SESSION['wallet']['Sieve']['user']          =  $GLOBALS['phpgw_info']['user']['account_lid']; 
     64            $_SESSION['wallet']['Sieve']['password']      =  $GLOBALS['phpgw_info']['user']['passwd']; 
     65 
     66            $_SESSION['wallet']['Cyrus']['user']          =  $GLOBALS['phpgw_info']['user']['account_lid']; 
     67            $_SESSION['wallet']['Cyrus']['password']      =  $GLOBALS['phpgw_info']['user']['passwd']; 
     68 
     69            $_SESSION['wallet']['user']['uid']            =  $GLOBALS['phpgw_info']['user']['userid']; 
     70            $_SESSION['wallet']['user']['uidNumber']      =  $GLOBALS['phpgw_info']['user']['account_id']; 
     71            $_SESSION['wallet']['user']['password']       =  $GLOBALS['phpgw_info']['user']['passwd']; 
     72            $_SESSION['wallet']['user']['cn']             =  $GLOBALS['phpgw_info']['user']['cn']; 
     73            $_SESSION['wallet']['user']['mail']           =  $GLOBALS['phpgw_info']['user']['email']; 
     74 
     75            $_SESSION['wallet']['PostgreSQL']['user']     = $GLOBALS['phpgw_info']['server']['db_user']; 
     76            $_SESSION['wallet']['PostgreSQL']['password'] = $GLOBALS['phpgw_info']['server']['db_pass']; 
     77            $_SESSION['wallet']['PostgreSQL']['dbname']   = $GLOBALS['phpgw_info']['server']['db_name']; 
     78            $_SESSION['wallet']['PostgreSQL']['host']     = $GLOBALS['phpgw_info']['server']['db_host']; 
     79             
     80            $_SESSION['wallet']['OpenLDAP']['context']   =  $GLOBALS['phpgw_info']['server']['ldap_context']; 
     81            $_SESSION['wallet']['OpenLDAP']['host']      =  $GLOBALS['phpgw_info']['server']['ldap_host']; 
     82            
     83        } 
     84                 
    4785    } 
     86 
    4887} 
    4988 
     89    Config::init(); 
     90         
     91 
    5092?> 
  • trunk/prototype/api/controller.php

    r5341 r5399  
    44    define( 'ROOTPATH', dirname(__FILE__).'/..' ); 
    55 
    6 require_once(ROOTPATH.'/app/config.php'); 
     6require_once(ROOTPATH.'/api/config.php'); 
    77 
    88/** 
     
    251251        } 
    252252 
    253         public static function links( $concept ) 
     253        //TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmo nos parametros passados 
     254        public static function links( $concept = false ) 
    254255        { 
    255256            if( !isset(self::$config[ $concept ]) ) 
     
    261262 
    262263        public static function isConcept( $concept ) 
    263             {  
     264        {  
    264265            if( isset( self::$config[ $concept ] ) &&  
    265266                self::$config[ $concept ] ) 
     
    269270        } 
    270271 
    271         public static function getConcept( $concept ) 
     272        public static function getConcept( $concept, $moduleName = false ) 
    272273        { 
    273274            if( isset( self::$config[ $concept ] ) ) 
    274275                return( self::$config[ $concept ] ); 
    275276 
    276             return( self::$config[ $concept ] = self::loadConfig( $concept ) ); 
    277             } 
     277            return( self::$config[ $concept ] = self::loadConfig( $concept, $moduleName ) ); 
     278        } 
    278279 
    279280        public static function loadCache( $cacheType = 'Memory' ) 
     
    283284        } 
    284285 
    285         public static function loadConfig( $className, $isService = false ) 
     286        //TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmo nos parametros passados 
     287        public static function loadConfig( $className, $isService = false) 
    286288        { 
    287289            $fileName = $className.'.'.($isService ? 'srv' : 'ini'); 
    288290 
    289291            $config = self::$cache->get( $fileName ); 
    290  
     292         
    291293            if( !$config ) 
    292294            { 
    293                 $config = parse_ini_file( ROOTPATH."/config/$fileName", true ); 
     295                $config = parse_ini_file( ROOTPATH.'/config/'.$fileName, true ); 
    294296 
    295297                self::$cache->put( $fileName, $config ); 
     
    379381        } 
    380382 
     383        //TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmo nos parametros passados 
    381384        public static function service( $serviceName, $concept = false ) 
    382385        { 
     
    393396                self::$config[ $serviceName ]['type'] = 'service'; 
    394397 
    395             self::import( 'app/'.self::$config[ $serviceName ]['type'] );   //TODO: Item 4 
     398            self::import( 'api/'.self::$config[ $serviceName ]['type'] );   //TODO: Item 4 
    396399 
    397400            $service = self::load( self::$config[ $serviceName ]['path'], 
     
    416419        } 
    417420 
     421        //TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmo nos parametros passados 
    418422        public static function interceptor( $method, $concept = false, $serviceName = false, $isService = false ) 
    419423        { 
     
    506510          *         array( '=' , 'campo' , 'valor' ) 
    507511        */ 
    508          
     512 
     513        //TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmo nos parametros passados 
    509514        public static function serviceName( $URI, $original = false ) 
    510515        { 
     
    530535        } 
    531536 
     537        //TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmos nas options passadas 
    532538        public static function call( $method, $URI, $properties = false, $options = false, $service = false, $noTX = false ) 
    533539        { 
  • trunk/prototype/api/datalayer.js

    r5376 r5399  
    10131013            result = this.request( concept, id || filter.filter, filter.criteria ); 
    10141014 
    1015             if( result && bothSides && !filter.criteria.format ) 
     1015            if( result && bothSides && (!filter ||  
     1016                                                                        !filter.criteria ||  
     1017                                                                        !filter.criteria.format) ) 
    10161018            { 
    10171019              var newResult = []; 
Note: See TracChangeset for help on using the changeset viewer.