Changeset 387

Show
Ignore:
Timestamp:
03/19/07 23:37:14 (2 years ago)
Author:
laurentj
Message:

ext: work on jelix_scan_module_sel and jelix_scan_action_sel

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ext/jelix/jelix.c

    r383 r387  
    3131        PHP_FE(jelix_version,   NULL) 
    3232        PHP_FE(jelix_read_ini,  NULL) 
    33         PHP_FE(jelix_scan_selector,  NULL) 
     33        PHP_FE(jelix_scan_module_sel,  NULL) 
     34        PHP_FE(jelix_scan_action_sel,  NULL) 
    3435        {NULL, NULL, NULL}      /* Must be the last line in jelix_functions[] */ 
    3536}; 
     
    8788        PHP_MINIT(jelix_interfaces)(INIT_FUNC_ARGS_PASSTHRU); 
    8889 
    89     REGISTER_LONG_CONSTANT("JELIX_SEL_MODULE", JELIX_SELECTOR_MODULE, CONST_CS | CONST_PERSISTENT); 
    90     REGISTER_LONG_CONSTANT("JELIX_SEL_ACTION", JELIX_SELECTOR_ACTION, CONST_CS | CONST_PERSISTENT); 
    91     REGISTER_LONG_CONSTANT("JELIX_SEL_LOCALE", JELIX_SELECTOR_LOCALE, CONST_CS | CONST_PERSISTENT); 
    92     REGISTER_LONG_CONSTANT("JELIX_SEL_SIMPLEFILE", JELIX_SELECTOR_SIMPLEFILE, CONST_CS | CONST_PERSISTENT); 
    9390    REGISTER_STRING_CONSTANT("JELIX_NAMESPACE_BASE", "http://jelix.org/ns/", CONST_CS | CONST_PERSISTENT); 
    9491    REGISTER_LONG_CONSTANT("JPDO_FETCH_OBJ", 5, CONST_CS | CONST_PERSISTENT); 
     
    204201 
    205202                if (JELIX_G(active_ini_file_section)) { 
    206                         // il faut ajouter la valeur en tant qu'element n tableau 
     203                        // il faut ajouter la valeur en tant qu'element à un tableau 
    207204                        zval * arr; 
    208205                        arr = JELIX_G(active_ini_file_section); 
     
    243240 
    244241                } else if (is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) != IS_LONG) { 
    245                         // il faut ajouter la valeur en tant que propri d'objet 
     242                        // il faut ajouter la valeur en tant que propriété d'objet 
    246243                        if (callback_type == ZEND_INI_PARSER_ENTRY) { 
    247244 
     
    312309/* }}} */ 
    313310 
    314 /* {{{ proto boolean jelix_scan_selector(string arg, object tofill [, int type]) 
    315    scna a string as a jelix selector, and fill object properties with founded values */ 
    316 PHP_FUNCTION(jelix_scan_selector) 
     311/* {{{ proto boolean jelix_scan_module_sel(string arg, object tofill) 
     312   scan a string as a jelix selector, and fill object properties with founded values  
     313/^(([\w\.]+)~)?([\w\.]+)$/ 
     314*/ 
     315PHP_FUNCTION(jelix_scan_module_sel) 
     316
     317    zval **selectorStr, **objectArg; 
     318    int length; 
     319    char *sel, *cursor, *module, *resource; 
     320 
     321 
     322    switch (ZEND_NUM_ARGS()) { 
     323        case 2: 
     324            if (zend_get_parameters_ex(2, &selectorStr, &objectArg) == FAILURE) { 
     325                RETURN_FALSE; 
     326            } 
     327                        break; 
     328 
     329/*              case 3: 
     330                        if (zend_get_parameters_ex(3, &selectorStr, &objectArg, &typeArg) == FAILURE) { 
     331                php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot read arguments"); 
     332                                RETURN_FALSE; 
     333                        } 
     334                convert_to_long_ex(typeArg); 
     335            type = Z_LVAL_PP(typeArg); 
     336            if(type < 1 || type > 4){ 
     337                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Third argument doesn't correspond to one of JELIX_SEL_* constant"); 
     338                RETURN_FALSE 
     339            } 
     340            break;*/ 
     341                default: 
     342                        ZEND_WRONG_PARAM_COUNT(); 
     343                        break; 
     344        } 
     345 
     346    if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 
     347                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 
     348        RETURN_FALSE 
     349        } 
     350 
     351    int module_length=0; 
     352    int resource_length=0; 
     353    int cursor_count=0; 
     354 
     355    convert_to_string_ex(selectorStr); 
     356    length = Z_STRLEN_PP(selectorStr); 
     357    sel = Z_STRVAL_PP(selectorStr); 
     358 
     359    cursor_count=0; 
     360    cursor = module = resource = sel; 
     361 
     362    int error = 0; 
     363 
     364    // parse the module part 
     365    while(cursor_count < length){ 
     366        if(*cursor == '~'){ 
     367            break; 
     368        } 
     369        if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     370            || ( *cursor >= 'A' && *cursor <= 'Z') 
     371            || ( *cursor >= '0' && *cursor <= '9') 
     372            || *cursor == '_' || *cursor == '.')){ 
     373            RETURN_FALSE 
     374        } 
     375        module_length ++; 
     376        cursor_count ++; 
     377        cursor++; 
     378    } 
     379 
     380 
     381    if(cursor_count >= length){ 
     382        // we don't find any '~' characters, so we have parsed the resource 
     383        resource_length = module_length; 
     384        module_length = 0; 
     385    }else{ 
     386        // the string starts by a ~ : it's not really a problem, but we generate an error 
     387        // to keep compatibily with php version of selectors. 
     388        if(module_length == 0){ 
     389            RETURN_FALSE 
     390        } 
     391 
     392        cursor_count++; 
     393        cursor++; 
     394        resource = cursor; 
     395        resource_length = 0; 
     396        while(cursor_count < length){ 
     397            if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     398                || ( *cursor >= 'A' && *cursor <= 'Z') 
     399                || ( *cursor >= '0' && *cursor <= '9') 
     400                || *cursor == '_' || *cursor == '.')){ 
     401                RETURN_FALSE 
     402            } 
     403            resource_length ++; 
     404            cursor_count ++; 
     405            cursor++; 
     406        } 
     407    } 
     408 
     409    if( resource_length == 0 ){ 
     410        RETURN_FALSE 
     411    } 
     412 
     413    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1,     module, module_length TSRMLS_CC); 
     414    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, resource, resource_length TSRMLS_CC); 
     415        RETURN_TRUE 
     416
     417/* }}} */ 
     418 
     419 
     420/* {{{ proto boolean jelix_scan_action_sel(string arg, object tofill *) 
     421   scan a string as a jelix selector, and fill object properties with founded values  
     422/^(?:([\w\.]+|\#)~)?([\w\.]+|\#)?(?:@([\w\.]+))?$/ 
     423*/ 
     424PHP_FUNCTION(jelix_scan_action_sel) 
     425
     426    zval **selectorStr, **objectArg; 
     427    int length; 
     428    char * sel, *cursor, *module, *resource, *request; 
     429 
     430 
     431    switch (ZEND_NUM_ARGS()) { 
     432        case 2: 
     433            if (zend_get_parameters_ex(2, &selectorStr, &objectArg) == FAILURE) { 
     434                RETURN_FALSE; 
     435            } 
     436                        break; 
     437                default: 
     438                        ZEND_WRONG_PARAM_COUNT(); 
     439                        break; 
     440        } 
     441 
     442    if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 
     443                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 
     444        RETURN_FALSE 
     445        } 
     446 
     447    int module_length=0; 
     448    int resource_length=0; 
     449    int request_length=0; 
     450    int cursor_count=0; 
     451 
     452    /* 
     453    JELIX_SELECTOR_MODULE           /^(([\w\.]+)~)?([\w\.]+)$/ 
     454    JELIX_SELECTOR_ACTION            
     455    JELIX_SELECTOR_LOCALE           /^(([\w\.]+)~)?(\w+)\.([\w\.]+)$/ 
     456    JELIX_SELECTOR_SIMPLEFILE       /^([\w\.\/]+)$/ 
     457    */ 
     458    convert_to_string_ex(selectorStr); 
     459    length = Z_STRLEN_PP(selectorStr); 
     460    sel = Z_STRVAL_PP(selectorStr); 
     461 
     462    cursor_count=0; 
     463    cursor = module = resource = sel; 
     464 
     465    int error = 0; 
     466    int sharpOk = 0; 
     467    int hasRequest=0; 
     468 
     469    // parse the module part 
     470    while(cursor_count < length){ 
     471        if(*cursor == '~' || *cursor == '@'){ 
     472            break; 
     473        } 
     474        if(*cursor == '#'){ 
     475            if(sharpOk || module_length > 1){ 
     476                RETURN_FALSE 
     477            } 
     478            sharpOk=1; 
     479        }else if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     480                || ( *cursor >= 'A' && *cursor <= 'Z') 
     481                || ( *cursor >= '0' && *cursor <= '9') 
     482                || *cursor == '_' || *cursor == '.') || sharpOk){ 
     483                RETURN_FALSE 
     484        } 
     485        module_length ++; 
     486        cursor_count ++; 
     487        cursor++; 
     488    } 
     489 
     490 
     491    if(cursor_count >= length){ 
     492        // we don't find any '~' characters, so we have parsed the resource 
     493        resource_length = module_length; 
     494        module_length = 0; 
     495    }else if( *cursor == '@'){ 
     496        // we don't find any '~' characters, so we have parsed the resource 
     497        resource_length = module_length; 
     498        module_length = 0; 
     499        hasRequest = 1; 
     500        // now we parse the @ section 
     501        cursor_count ++; 
     502        cursor++; 
     503 
     504        request = cursor; 
     505        request_length = 0; 
     506        while(cursor_count < length){ 
     507            if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     508                || ( *cursor >= 'A' && *cursor <= 'Z') 
     509                || ( *cursor >= '0' && *cursor <= '9') 
     510                || *cursor == '_' || *cursor == '.')){ 
     511                RETURN_FALSE 
     512            } 
     513            request_length ++; 
     514            cursor_count ++; 
     515            cursor++; 
     516        } 
     517    }else{ 
     518        // the string starts by a ~ : it's not really a problem, but we generate an error 
     519        // to keep compatibily with php version of selectors. 
     520        if(module_length == 0){ 
     521            RETURN_FALSE 
     522        } 
     523 
     524        cursor_count++; 
     525        cursor++; 
     526        resource = cursor; 
     527        resource_length = 0; 
     528        sharpOk = 0; 
     529        while(cursor_count < length){ 
     530            if(*cursor == '@'){ 
     531                break; 
     532            } 
     533 
     534            if(*cursor == '#'){ 
     535                if(sharpOk || resource_length > 1){ 
     536                    RETURN_FALSE 
     537                } 
     538                sharpOk=1; 
     539            }else if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     540                    || ( *cursor >= 'A' && *cursor <= 'Z') 
     541                    || ( *cursor >= '0' && *cursor <= '9') 
     542                    || *cursor == '_' || *cursor == '.') || sharpOk){ 
     543                    RETURN_FALSE 
     544            } 
     545            resource_length ++; 
     546            cursor_count ++; 
     547            cursor++; 
     548        } 
     549 
     550        if(*cursor == '@'){ 
     551            hasRequest = 1; 
     552            cursor_count++; 
     553            cursor++; 
     554            request = cursor; 
     555            request_length = 0; 
     556            while(cursor_count < length){ 
     557                if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     558                    || ( *cursor >= 'A' && *cursor <= 'Z') 
     559                    || ( *cursor >= '0' && *cursor <= '9') 
     560                    || *cursor == '_' || *cursor == '.')){ 
     561                    RETURN_FALSE 
     562                } 
     563                request_length ++; 
     564                cursor_count ++; 
     565                cursor++; 
     566            } 
     567        } 
     568    } 
     569 
     570    if(hasRequest && request_length == 0){ 
     571        RETURN_FALSE 
     572    } 
     573 
     574    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1,     module, module_length TSRMLS_CC); 
     575    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, resource, resource_length TSRMLS_CC); 
     576    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "request", sizeof("request") - 1,   request, request_length TSRMLS_CC); 
     577        RETURN_TRUE 
     578
     579/* }}} */ 
     580 
     581 
     582 
     583 
     584 
     585  /* 
     586    JELIX_SELECTOR_MODULE           /^(([\w\.]+)~)?([\w\.]+)$/ 
     587    JELIX_SELECTOR_ACTION           /^(?:([\w\.]+|\#)~)?([\w\.]+|\#)?(?:@([\w\.]+))?$/ 
     588    JELIX_SELECTOR_LOCALE           /^(([\w\.]+)~)?(\w+)\.([\w\.]+)$/ 
     589    JELIX_SELECTOR_SIMPLEFILE       /^([\w\.\/]+)$/ 
     590    */ 
     591/* 
     592 
     593PHP_FUNCTION(jelix_scan_action_sel) 
    317594{ 
    318595    zval **selectorStr, **objectArg, **typeArg; 
    319596    int length, type; 
    320     char * sel, *cursor, *module, *resource
     597    char * sel, *cursor, *module, *resource, *request
    321598 
    322599 
     
    353630    int module_length=0; 
    354631    int resource_length=0; 
     632    int request_length=0; 
    355633    int cursor_count=0; 
    356634 
    357     /* 
    358     JELIX_SELECTOR_MODULE           /^(([\w\.]+)~)?([\w\.]+)$/ 
    359     JELIX_SELECTOR_ACTION           /^(?:([\w\.]+|\#)~)?([\w\.]+|\#)?(?:@([\w\.]+))?$/ 
    360     JELIX_SELECTOR_LOCALE           /^(([\w\.]+)~)?(\w+)\.([\w\.]+)$/ 
    361     JELIX_SELECTOR_SIMPLEFILE       /^([\w\.\/]+)$/ 
    362     */ 
     635   
    363636    convert_to_string_ex(selectorStr); 
    364637    length = Z_STRLEN_PP(selectorStr); 
     
    370643    int error = 0; 
    371644    int sharpOk = 0; 
     645    int hasRequest=0; 
    372646 
    373647    // parse the module part 
     
    376650            break; 
    377651        } 
     652        if(*cursor == '@' && type == JELIX_SELECTOR_ACTION){ 
     653            break; 
     654        } 
     655 
    378656        if(*cursor == '#'){ 
    379657            if(type != JELIX_SELECTOR_ACTION ){ 
     
    402680        resource_length = module_length; 
    403681        module_length = 0; 
     682    }else if( *cursor == '@' && type == JELIX_SELECTOR_ACTION){ 
     683        // we don't find any '~' characters, so we have parsed the resource 
     684        resource_length = module_length; 
     685        module_length = 0; 
     686        hasRequest = 1; 
     687        // now we parse the @ section 
     688        cursor_count ++; 
     689        cursor++; 
     690 
     691        request = cursor; 
     692        request_length = 0; 
     693        while(cursor_count < length){ 
     694            if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     695                || ( *cursor >= 'A' && *cursor <= 'Z') 
     696                || ( *cursor >= '0' && *cursor <= '9') 
     697                || *cursor == '_' || *cursor == '.')){ 
     698                RETURN_FALSE 
     699            } 
     700            request_length ++; 
     701            cursor_count ++; 
     702            cursor++; 
     703        } 
    404704    }else{ 
    405705        // the string starts by a ~ : it's not really a problem, but we generate an error 
    406         // to keep compatibily with php version
     706        // to keep compatibily with php version of selectors
    407707        if(module_length == 0){ 
    408708            RETURN_FALSE 
     
    413713        resource = cursor; 
    414714        resource_length = 0; 
     715        sharpOk = 0; 
    415716        while(cursor_count < length){ 
    416             if( ( *cursor >= 'a' && *cursor <= 'z') 
    417                 || ( *cursor >= 'A' && *cursor <= 'Z') 
    418                 || ( *cursor >= '0' && *cursor <= '9') 
    419                 || ( *cursor == '_') || ( *cursor == '.')){ 
    420                 resource_length ++; 
     717            if(*cursor == '@' && type == JELIX_SELECTOR_ACTION){ 
     718                break; 
     719            } 
     720 
     721            if(*cursor == '#'){ 
     722                if(type != JELIX_SELECTOR_ACTION ){ 
     723                    RETURN_FALSE 
     724                } 
     725                if(sharpOk || resource_length > 1){ 
     726                    RETURN_FALSE 
     727                } 
     728                sharpOk=1; 
     729            }else{ 
     730                if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     731                    || ( *cursor >= 'A' && *cursor <= 'Z') 
     732                    || ( *cursor >= '0' && *cursor <= '9') 
     733                    || *cursor == '_' || *cursor == '.') || sharpOk){ 
     734                    RETURN_FALSE 
     735                } 
     736            } 
     737            resource_length ++; 
     738            cursor_count ++; 
     739            cursor++; 
     740        } 
     741 
     742        if(*cursor == '@' && type == JELIX_SELECTOR_ACTION){ 
     743            hasRequest = 1; 
     744            cursor_count++; 
     745            cursor++; 
     746            request = cursor; 
     747            request_length = 0; 
     748            while(cursor_count < length){ 
     749                if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     750                    || ( *cursor >= 'A' && *cursor <= 'Z') 
     751                    || ( *cursor >= '0' && *cursor <= '9') 
     752                    || *cursor == '_' || *cursor == '.')){ 
     753                    RETURN_FALSE 
     754                } 
     755                request_length ++; 
    421756                cursor_count ++; 
    422757                cursor++; 
    423             }else{ 
    424                 error =1; 
    425                 break; 
    426             } 
    427         } 
    428         if(error){ 
     758            } 
     759        } 
     760    } 
     761 
     762    if(type == JELIX_SELECTOR_ACTION){ 
     763        if(hasRequest && request_length == 0){ 
    429764            RETURN_FALSE 
    430765        } 
    431     } 
    432  
    433     if( resource_length == 0 ){ 
     766    }else if( resource_length == 0 ){ 
    434767        RETURN_FALSE 
    435768    } 
     769     
    436770 
    437771    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1,     module, module_length TSRMLS_CC); 
    438772    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, resource, resource_length TSRMLS_CC); 
    439  
     773    if(type == JELIX_SELECTOR_ACTION){ 
     774        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "request", sizeof("request") - 1,       request, request_length TSRMLS_CC); 
     775    } 
    440776        RETURN_TRUE 
    441 
    442 /* }}} */ 
    443  
     777}*/ 
     778 
  • trunk/ext/jelix/jelix_interfaces.c

    r383 r387  
    3131 
    3232 
    33 // declaration des arguments aux modes 
     33// declaration des arguments aux méthodes 
    3434 
    3535/* ------------------------------------- 
  • trunk/ext/jelix/php_jelix.h

    r383 r387  
    1212 
    1313#define JELIX_VERSION "0.1" 
    14 #define JELIX_SELECTOR_MODULE 1 
    15 #define JELIX_SELECTOR_ACTION 2 
    16 #define JELIX_SELECTOR_LOCALE 3 
    17 #define JELIX_SELECTOR_SIMPLEFILE 4 
    1814 
    1915extern zend_module_entry jelix_module_entry; 
     
    3834PHP_FUNCTION(jelix_version); 
    3935PHP_FUNCTION(jelix_read_ini); 
    40 PHP_FUNCTION(jelix_scan_selector); 
     36PHP_FUNCTION(jelix_scan_module_sel); 
     37PHP_FUNCTION(jelix_scan_action_sel); 
    4138 
    4239 
  • trunk/ext/jelix/testperf.php

    r383 r387  
    11<?php 
    22 
    3 function selector($foo, $obj){ 
     3function module_selector($foo, $obj){ 
    44    if(preg_match("/^(([\w\.]+)~)?([\w\.]+)$/", $foo, $m)){ 
    55        if($m[1]!='' && $m[2]!=''){ 
     
    1515} 
    1616 
     17function action_selector($foo, $obj){ 
     18    if(preg_match("/^(?:([\w\.]+|\#)~)?([\w\.]+|\#)?(?:@([\w\.]+))?$/", $foo, $m)){ 
     19        $m=array_pad($m,4,''); 
     20        if($m[1]!=''){ 
     21            if($m[1] == '#') 
     22                $obj->module = ''; 
     23            else 
     24                $obj->module = $m[1]; 
     25        }else{ 
     26            $obj->module = ''; 
     27        } 
     28        if($m[2] == '#') 
     29            $obj->resource = 'index'; 
     30        else 
     31            $obj->resource = $m[2]; 
     32 
     33        $r = explode('_',$obj->resource); 
     34 
     35        if(count($r) == 1){ 
     36            $obj->controller = 'default'; 
     37            $obj->method = $r[0]==''?'index':$r[0]; 
     38        }else{ 
     39            $obj->controller = $r[0]=='' ? 'default':$r[0]; 
     40            $obj->method = $r[1]==''?'index':$r[1]; 
     41        } 
     42        $obj->resource = $obj->controller.'_'.$obj->method; 
     43        if($m[3] != '' && $enableRequestPart) 
     44            $obj->request = $m[3]; 
     45        else 
     46            $obj->request = 'classic'; 
     47 
     48        return true; 
     49    }else{ 
     50        return false; 
     51    } 
     52} 
     53 
     54 
    1755 
    1856class obj { 
    1957    public $module; 
    2058    public $resource; 
     59    public $request; 
    2160} 
    2261 
     
    2564for($i=0; $i < 1000; $i++){ 
    2665    $o = new obj(); 
    27     selector("aaa~bbb",$o); 
     66    module_selector("aaa~bbb",$o); 
    2867} 
    2968$t2 = microtime(true); 
     
    3170for($i=0; $i < 1000; $i++){ 
    3271    $o = new obj(); 
    33     jelix_scan_selector("aaa~bbb",$o); 
     72    jelix_scan_module_sel("aaa~bbb",$o); 
    3473} 
    3574$t3 = microtime(true); 
    3675 
    37 echo "selector = ".($t2-$t1)."\n"; 
     76echo "module_selector = ".($t2-$t1)."\n"; 
    3877echo "jelix_scan_selector = ".($t3-$t2)."\n"; 
     78 
     79 
     80$t1 = microtime(true); 
     81 
     82for($i=0; $i < 1000; $i++){ 
     83    $o = new obj(); 
     84    action_selector("aaa~bbb@classic",$o); 
     85} 
     86$t2 = microtime(true); 
     87 
     88for($i=0; $i < 1000; $i++){ 
     89    $o = new obj(); 
     90    jelix_scan_action_sel("aaa~bbb@classic",$o); 
     91} 
     92$t3 = microtime(true); 
     93 
     94echo "action_selector = ".($t2-$t1)."\n"; 
     95echo "jelix_scan_selector = ".($t3-$t2)."\n"; 
     96 
     97 
     98 
     99 
     100 
    39101?> 
  • trunk/ext/jelix/tests/jelix_const_001.phpt

    r383 r387  
    55--FILE-- 
    66<?php  
    7 echo JELIX_SEL_MODULE ,"\n"; 
    8 echo JELIX_SEL_ACTION ,"\n"; 
    9 echo JELIX_SEL_LOCALE ,"\n"; 
    10 echo JELIX_SEL_SIMPLEFILE ,"\n"; 
     7echo  JELIX_NAMESPACE_BASE,"\n"; 
     8echo  JPDO_FETCH_OBJ,"\n"; 
     9echo  JPDO_FETCH_ORI_NEXT,"\n"; 
     10echo  JPDO_FETCH_ORI_FIRST,"\n"; 
     11echo  JPDO_FETCH_COLUMN,"\n"; 
     12echo  JPDO_FETCH_CLASS,"\n"; 
     13echo  JPDO_ATTR_STATEMENT_CLASS,"\n"; 
     14echo  JPDO_ATTR_AUTOCOMMIT,"\n"; 
     15echo  JPDO_ATTR_CURSOR,"\n"; 
     16echo  JPDO_CURSOR_SCROLL,"\n"; 
     17echo  JPDO_ATTR_ERRMODE,"\n"; 
     18echo  JPDO_ERRMODE_EXCEPTION,"\n"; 
     19echo  JPDO_MYSQL_ATTR_USE_BUFFERED_QUERY,"\n"; 
     20 
    1121?> 
    1222--EXPECT-- 
     23http://jelix.org/ns/ 
     245 
     250 
     262 
     277 
     288 
     2913 
     300 
     3110 
    13321 
     333 
    14342 
    15 
    16 
     351000 
  • trunk/ext/jelix/tests/scan_selector_001.phpt

    r383 r387  
    11--TEST-- 
    2 Test jelix_scan_selector with some simple selectors 
     2Test jelix_scan_module_sel with some simple selectors 
    33--SKIPIF-- 
    44<?php if (!extension_loaded("jelix")) print "skip"; ?> 
     
    1717 
    1818    $obj = new obj(); 
    19     $ret = jelix_scan_selector($t, $obj); 
     19    $ret = jelix_scan_module_sel($t, $obj); 
    2020    echo $k,":"; 
    2121    if($ret === true){ 
  • trunk/ext/jelix/tests/scan_selector_002.phpt

    r383 r387  
    11--TEST-- 
    2 Test jelix_scan_selector with some bad simple selectors 
     2Test jelix_scan_module_sel with some bad simple selectors 
    33--SKIPIF-- 
    44<?php if (!extension_loaded("jelix")) print "skip"; ?> 
     
    1010} 
    1111 
    12 $tests = array("a-b~toto", "ab~ro-ro", "~toPO__etto"); 
     12$tests = array("a-b~toto", "ab~ro-ro", "~toPO__etto","#",  "#~foo", "foo~#", "#~#"); 
    1313 
    1414foreach($tests as $k=>$t){ 
    1515 
    1616    $obj = new obj(); 
    17     $ret = jelix_scan_selector($t, $obj); 
     17    $ret = jelix_scan_module_sel($t, $obj); 
    1818    echo $k,":"; 
    1919    if($ret === false){ 
     
    3838 
    3939 
     403:ok 
     41 
     42 
     434:ok 
     44 
     45 
     465:ok 
     47 
     48 
     496:ok 
     50 
     51 
  • trunk/ext/jelix/tests/scan_selector_003.phpt

    r383 r387  
    11--TEST-- 
    2 Test jelix_scan_selector with some action selectors 
     2Test jelix_scan_action_sel with some action selectors 
    33--SKIPIF-- 
    44<?php if (!extension_loaded("jelix")) print "skip"; ?> 
     
    88    public $module; 
    99    public $resource; 
     10    public $request; 
     11    public $controller; 
     12    public $method; 
    1013} 
    1114 
    12 $tests = array("toto", "aaa~toto", "aa_AZ123aR~toPO__etto", "foo.bar~truc.muche", 
    13                 "#",  "#~foo"); 
     15$tests = array( 0=>"toto", 1=>"aaa~toto", 2=>"aa_AZ123aR~toPO_etto", 3=>"foo.bar~truc.muche", 4=>"#", 
     16                5=>"#~foo", 6=>"foo~#", 7=>"#~#", 8=>"@classic", 9=>"foo.bar~truc.muche@classic", 
     17                10=>"foo.bar~truc_muche@classic", 11=>"#@classic",  12=>"#~foo@classic",  
     18                13=>"foo~#@classic", 14=>"#~#@classic" 
     19 
     20 ); 
    1421 
    1522foreach($tests as $k=>$t){ 
    1623 
    1724    $obj = new obj(); 
    18     $ret = jelix_scan_selector($t, $obj, JELIX_SEL_ACTION); 
     25    $ret = jelix_scan_action_sel($t, $obj); 
    1926    echo $k,":"; 
    2027    if($ret === true){ 
     
    2532    } 
    2633 
    27     echo $obj->module,"\n"; 
    28     echo $obj->resource,"\n"; 
     34    echo 'm=',$obj->module,"\n"; 
     35    echo 'r=',$obj->resource,"\n"; 
     36    echo 'q=',$obj->request,"\n"; 
    2937} 
    3038?> 
    3139--EXPECT-- 
    32400:ok 
    33  
    34 toto 
     41m= 
     42r=toto 
     43q= 
    35441:ok 
    36 aaa 
    37 toto 
     45m=aaa 
     46r=toto 
     47q= 
    38482:ok 
    39 aa_AZ123aR 
    40 toPO__etto 
     49m=aa_AZ123aR 
     50r=toPO_etto 
     51q= 
    41523:ok 
    42 foo.bar 
    43 truc.muche 
     53m=foo.bar 
     54r=truc.muche 
     55q= 
    44564:ok 
    45  
    46 
     57m= 
     58r=# 
     59q= 
    47605:ok 
    48 
    49 foo 
     61m=# 
     62r=foo 
     63q= 
     646:ok 
     65m=foo 
     66r=# 
     67q= 
     687:ok 
     69m=# 
     70r=# 
     71q= 
     728:ok 
     73m= 
     74r= 
     75q=classic 
     769:ok 
     77m=foo.bar 
     78r=truc.muche 
     79q=classic 
     8010:ok 
     81m=foo.bar 
     82r=truc_muche 
     83q=classic 
     8411:ok 
     85m= 
     86r=# 
     87q=classic 
     8812:ok 
     89m=# 
     90r=foo 
     91q=classic 
     9213:ok 
     93m=foo 
     94r=# 
     95q=classic 
     9614:ok 
     97m=# 
     98r=# 
     99q=classic 
  • trunk/ext/jelix/tests/scan_selector_004.phpt

    r383 r387  
    11--TEST-- 
    2 Test jelix_scan_selector with some bad action selectors 
     2Test jelix_scan_action_sel with some bad action selectors 
    33--SKIPIF-- 
    44<?php if (!extension_loaded("jelix")) print "skip"; ?> 
     
    88    public $module; 
    99    public $resource; 
     10    public $request; 
    1011} 
    1112 
    1213$tests = array("a-b~toto", "ab~ro-ro", "~toPO__etto",  
    1314   "#aaa", "##" , "aa#aa", "aaa#", 
    14   // "foo~#aaa", "foo~aa#aa", "foo~aaa#" 
    15  ); 
     15   "foo~#aaa", "foo~aa#aa", "foo~aaa#", "~@classic", "@", "#@"); 
    1616 
    1717foreach($tests as $k=>$t){ 
    1818 
    1919    $obj = new obj(); 
    20     $ret = jelix_scan_selector($t, $obj, JELIX_SEL_ACTION); 
     20    $ret = jelix_scan_action_sel($t, $obj); 
    2121    echo $k,":"; 
    2222    if($ret === false){ 
     
    2727    } 
    2828 
    29     echo $obj->module,"\n"; 
    30     echo $obj->resource,"\n"; 
     29    echo $obj->module,"!", $obj->resource,"!",$obj->resource,"\n"; 
    3130} 
    3231?> 
    3332--EXPECT-- 
    34330:ok 
    35  
    36  
     34!! 
    37351:ok 
    38  
    39  
     36!! 
    40372:ok 
    41  
    42  
     38!! 
    43393:ok 
    44  
    45  
     40!! 
    46414:ok 
    47  
    48  
     42!! 
    49435:ok 
    50  
    51  
     44!! 
    52456:ok 
    53  
    54  
     46!! 
     477:ok 
     48!! 
     498:ok 
     50!! 
     519:ok 
     52!! 
     5310:ok 
     54!! 
     5511:ok 
     56!! 
     5712:ok 
     58!! 
  • trunk/ext/jelix/TODO

    r383 r387  
    77========= 
    88 
    9 ajouter dans $_SERVER (pour jRequest) : 
     9à rajouter dans $_SERVER (pour jRequest) : 
    1010 
    1111JX_URL_SCRIPT_PATH 
Download in other formats: Unified Diff Zip Archive