Changeset 691 for trunk/ext

Show
Ignore:
Timestamp:
12/11/07 23:53:59 (1 year ago)
Author:
laurentj
Message:

ticket #317: main patch for the new action selector format. p=Thibault Piront and me

Files:

Legend:

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

    r669 r691  
    3333        PHP_FE(jelix_scan_module_sel,  NULL) 
    3434        PHP_FE(jelix_scan_action_sel,  NULL) 
     35        PHP_FE(jelix_scan_old_action_sel,  NULL) 
    3536        PHP_FE(jelix_scan_class_sel,  NULL) 
    3637        PHP_FE(jelix_scan_locale_sel,  NULL) 
     
    412413/^(?:([a-zA-Z0-9_\.]+|\#)~)?([a-zA-Z0-9_]+|\#)?(?:@([a-zA-Z0-9_]+))?$/ 
    413414*/ 
    414 PHP_FUNCTION(jelix_scan_action_sel) 
     415PHP_FUNCTION(jelix_scan_old_action_sel) 
    415416{ 
    416417    zval **selectorStr, **objectArg, **defaultActionArg; 
     
    651652/* }}} */ 
    652653 
     654 
     655/* {{{ proto boolean jelix_scan_action_sel(string arg, object tofill *) 
     656   scan a string as a jelix selector, and fill object properties with founded values  
     657/^(?:([a-zA-Z0-9_\.]+|\#)~)?([a-zA-Z0-9_:]+|\#)?(?:@([a-zA-Z0-9_]+))?$/ 
     658*/ 
     659PHP_FUNCTION(jelix_scan_action_sel) 
     660{ 
     661    zval **selectorStr, **objectArg, **defaultActionArg; 
     662    int length; 
     663    char * sel, *cursor, *module, *resource, *request; 
     664 
     665 
     666    if(ZEND_NUM_ARGS() != 3) { 
     667        ZEND_WRONG_PARAM_COUNT(); 
     668    } 
     669    if (zend_get_parameters_ex(3, &selectorStr, &objectArg, &defaultActionArg) == FAILURE) { 
     670        php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot read arguments"); 
     671        RETURN_FALSE; 
     672    } 
     673 
     674    if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 
     675                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 
     676        RETURN_FALSE 
     677        } 
     678    if(Z_TYPE_P(*defaultActionArg) != IS_STRING){ 
     679                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid third argument, not a string"); 
     680        RETURN_FALSE 
     681        } 
     682 
     683    int module_length=0; 
     684    int resource_length=0; 
     685    int request_length=0; 
     686    int cursor_count=0; 
     687 
     688    convert_to_string_ex(selectorStr); 
     689    length = Z_STRLEN_PP(selectorStr); 
     690    sel = Z_STRVAL_PP(selectorStr); 
     691 
     692    cursor_count=0; 
     693    cursor = module = resource = sel; 
     694 
     695    int error = 0; 
     696    int sharpOk = 0; 
     697    int hasRequest=0; 
     698    int firstDashPos = -1; 
     699    int hasDot = 0; 
     700 
     701    // parse the module part 
     702    while(cursor_count < length){ 
     703        if(*cursor == '~' || *cursor == '@'){ 
     704            break; 
     705        } 
     706        if(*cursor == '#'){ 
     707            if(sharpOk || module_length > 1){ 
     708                RETURN_FALSE 
     709            } 
     710            sharpOk=1; 
     711        }else if(*cursor == '.'){ 
     712            hasDot = 1; 
     713        }else if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     714                || ( *cursor >= 'A' && *cursor <= 'Z') 
     715                || ( *cursor >= '0' && *cursor <= '9') 
     716                || *cursor == '_' || *cursor == ':' ) || sharpOk){ 
     717                RETURN_FALSE 
     718        } 
     719        if(*cursor == ':' && firstDashPos == -1){ 
     720            firstDashPos = module_length; 
     721        } 
     722 
     723        module_length ++; 
     724        cursor_count ++; 
     725        cursor++; 
     726    } 
     727 
     728    if(cursor_count >= length){ 
     729        // we don't find any '~' characters, so we have parsed the resource 
     730        if(hasDot) RETURN_FALSE 
     731 
     732        resource_length = module_length; 
     733        module_length = 0; 
     734    }else if( *cursor == '@'){ 
     735        // we don't find any '~' characters, so we have parsed the resource 
     736        if(hasDot) RETURN_FALSE 
     737 
     738        resource_length = module_length; 
     739        module_length = 0; 
     740        hasRequest = 1; 
     741        // now we parse the @ section 
     742        cursor_count ++; 
     743        cursor++; 
     744 
     745        request = cursor; 
     746        request_length = 0; 
     747        while(cursor_count < length){ 
     748            if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     749                || ( *cursor >= 'A' && *cursor <= 'Z') 
     750                || ( *cursor >= '0' && *cursor <= '9') 
     751                || *cursor == '_' || *cursor == ':' || *cursor == '.')){ 
     752                RETURN_FALSE 
     753            } 
     754            request_length ++; 
     755            cursor_count ++; 
     756            cursor++; 
     757        } 
     758    }else{ 
     759        // the string starts by a ~ : it's not really a problem, but we generate an error 
     760        // to keep compatibily with php version of selectors. 
     761        if(module_length == 0){ 
     762            RETURN_FALSE 
     763        } 
     764        firstDashPos=-1; 
     765        cursor_count++; 
     766        cursor++; 
     767        resource = cursor; 
     768        resource_length = 0; 
     769        sharpOk = 0; 
     770        while(cursor_count < length){ 
     771            if(*cursor == '@'){ 
     772                break; 
     773            } 
     774 
     775            if(*cursor == '#'){ 
     776                if(sharpOk || resource_length > 1){ 
     777                    RETURN_FALSE 
     778                } 
     779                sharpOk=1; 
     780            }else if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     781                    || ( *cursor >= 'A' && *cursor <= 'Z') 
     782                    || ( *cursor >= '0' && *cursor <= '9') 
     783                    || *cursor == '_' || *cursor == ':') || sharpOk){ 
     784                    RETURN_FALSE 
     785            } 
     786            if(*cursor == ':' && firstDashPos == -1){ 
     787                firstDashPos = resource_length; 
     788            } 
     789 
     790            resource_length ++; 
     791            cursor_count ++; 
     792            cursor++; 
     793        } 
     794 
     795        if(*cursor == '@'){ 
     796            hasRequest = 1; 
     797            cursor_count++; 
     798            cursor++; 
     799            request = cursor; 
     800            request_length = 0; 
     801            while(cursor_count < length){ 
     802                if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     803                    || ( *cursor >= 'A' && *cursor <= 'Z') 
     804                    || ( *cursor >= '0' && *cursor <= '9') 
     805                    || *cursor == '_' || *cursor == '.')){ 
     806                    RETURN_FALSE 
     807                } 
     808                request_length ++; 
     809                cursor_count ++; 
     810                cursor++; 
     811            } 
     812        } 
     813    } 
     814 
     815    // request shouldn't empty if there is a @ 
     816    if(hasRequest && request_length == 0){ 
     817        RETURN_FALSE 
     818    } 
     819 
     820    if(resource_length == 0){ 
     821        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     "default_index", sizeof("default_index")-1 TSRMLS_CC); 
     822        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "controller", sizeof("controller") - 1, "default", sizeof("default")-1 TSRMLS_CC); 
     823        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "method", sizeof("method") - 1, "index", sizeof("index")-1 TSRMLS_CC); 
     824    }else{ 
     825        if(resource_length == 1 && *resource == '#'){ 
     826           resource_length = Z_STRLEN_PP(defaultActionArg); 
     827           resource = Z_STRVAL_PP(defaultActionArg); 
     828           firstDashPos=-1; 
     829           int i; 
     830           for(i=0; i < resource_length;i++){ 
     831                if(resource[i] == '_'){ 
     832                    firstDashPos=i; 
     833                    break; 
     834                } 
     835           } 
     836        } 
     837 
     838        if(firstDashPos == -1){ 
     839            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "controller", sizeof("controller") - 1,     "default", sizeof("default")-1 TSRMLS_CC); 
     840            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "method", sizeof("method") - 1,     resource, resource_length TSRMLS_CC); 
     841 
     842            char *r; 
     843            int ld = sizeof("default:") -1; 
     844            int lr = ld + resource_length; 
     845            r= emalloc(lr+1); 
     846            if (r) { 
     847                memcpy(r, "default:", ld); 
     848                memcpy(r+ld, resource, resource_length); 
     849                r[lr] = 0; 
     850                zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr TSRMLS_CC); 
     851                efree(r); 
     852            } 
     853 
     854        }else if(firstDashPos == 0){ 
     855            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "controller", sizeof("controller") - 1,     "default", sizeof("default")-1 TSRMLS_CC); 
     856            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "method", sizeof("method") - 1,     resource+1, resource_length-1 TSRMLS_CC); 
     857 
     858            char *r; 
     859            int ld = sizeof("default") -1; 
     860            int lr = ld + resource_length; 
     861            r= emalloc(lr+1); 
     862            if (r) { 
     863                memcpy(r, "default", ld); 
     864                memcpy(r+ld, resource, resource_length); 
     865                r[lr] = 0; 
     866                zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr TSRMLS_CC); 
     867                efree(r); 
     868            } 
     869 
     870        }else if(firstDashPos == resource_length-1){ 
     871            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "controller", sizeof("controller") - 1,     resource, resource_length-1 TSRMLS_CC); 
     872            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "method", sizeof("method") - 1,     "index", sizeof("index")-1 TSRMLS_CC); 
     873            char *r; 
     874            int ld = sizeof("index") -1; 
     875            int lr = resource_length + ld; 
     876            r= emalloc(lr+1); 
     877            if (r) { 
     878                memcpy(r, resource, resource_length); 
     879                memcpy(r+resource_length, "index", ld); 
     880                r[lr] = 0; 
     881                zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr TSRMLS_CC); 
     882                efree(r); 
     883            } 
     884 
     885        }else{ 
     886            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "controller", sizeof("controller") - 1,     resource, firstDashPos TSRMLS_CC); 
     887            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "method", sizeof("method") - 1,     resource+firstDashPos+1, resource_length-firstDashPos-1 TSRMLS_CC); 
     888            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, resource, resource_length TSRMLS_CC); 
     889        } 
     890    } 
     891 
     892    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1,     module, module_length TSRMLS_CC); 
     893    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "request", sizeof("request") - 1,   request, request_length TSRMLS_CC); 
     894        RETURN_TRUE 
     895} 
     896/* }}} */ 
     897 
     898 
    653899/* {{{ proto boolean jelix_scan_class_sel(string arg, object tofill *) 
    654900   scan a string as a jelix selector, and fill object properties with founded values  
  • trunk/ext/jelix/jelix.c

    r669 r691  
    3333        PHP_FE(jelix_scan_module_sel,  NULL) 
    3434        PHP_FE(jelix_scan_action_sel,  NULL) 
     35        PHP_FE(jelix_scan_old_action_sel,  NULL) 
    3536        PHP_FE(jelix_scan_class_sel,  NULL) 
    3637        PHP_FE(jelix_scan_locale_sel,  NULL) 
     
    412413/^(?:([a-zA-Z0-9_\.]+|\#)~)?([a-zA-Z0-9_]+|\#)?(?:@([a-zA-Z0-9_]+))?$/ 
    413414*/ 
    414 PHP_FUNCTION(jelix_scan_action_sel) 
     415PHP_FUNCTION(jelix_scan_old_action_sel) 
    415416{ 
    416417    zval **selectorStr, **objectArg, **defaultActionArg; 
     
    651652/* }}} */ 
    652653 
     654 
     655/* {{{ proto boolean jelix_scan_action_sel(string arg, object tofill *) 
     656   scan a string as a jelix selector, and fill object properties with founded values  
     657/^(?:([a-zA-Z0-9_\.]+|\#)~)?([a-zA-Z0-9_:]+|\#)?(?:@([a-zA-Z0-9_]+))?$/ 
     658*/ 
     659PHP_FUNCTION(jelix_scan_action_sel) 
     660{ 
     661    zval **selectorStr, **objectArg, **defaultActionArg; 
     662    int length; 
     663    char * sel, *cursor, *module, *resource, *request; 
     664 
     665 
     666    if(ZEND_NUM_ARGS() != 3) { 
     667        ZEND_WRONG_PARAM_COUNT(); 
     668    } 
     669    if (zend_get_parameters_ex(3, &selectorStr, &objectArg, &defaultActionArg) == FAILURE) { 
     670        php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot read arguments"); 
     671        RETURN_FALSE; 
     672    } 
     673 
     674    if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 
     675                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 
     676        RETURN_FALSE 
     677        } 
     678    if(Z_TYPE_P(*defaultActionArg) != IS_STRING){ 
     679                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid third argument, not a string"); 
     680        RETURN_FALSE 
     681        } 
     682 
     683    int module_length=0; 
     684    int resource_length=0; 
     685    int request_length=0; 
     686    int cursor_count=0; 
     687 
     688    convert_to_string_ex(selectorStr); 
     689    length = Z_STRLEN_PP(selectorStr); 
     690    sel = Z_STRVAL_PP(selectorStr); 
     691 
     692    cursor_count=0; 
     693    cursor = module = resource = sel; 
     694 
     695    int error = 0; 
     696    int sharpOk = 0; 
     697    int hasRequest=0; 
     698    int firstDashPos = -1; 
     699    int hasDot = 0; 
     700 
     701    // parse the module part 
     702    while(cursor_count < length){ 
     703        if(*cursor == '~' || *cursor == '@'){ 
     704            break; 
     705        } 
     706        if(*cursor == '#'){ 
     707            if(sharpOk || module_length > 1){ 
     708                RETURN_FALSE 
     709            } 
     710            sharpOk=1; 
     711        }else if(*cursor == '.'){ 
     712            hasDot = 1; 
     713        }else if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     714                || ( *cursor >= 'A' && *cursor <= 'Z') 
     715                || ( *cursor >= '0' && *cursor <= '9') 
     716                || *cursor == '_' || *cursor == ':' ) || sharpOk){ 
     717                RETURN_FALSE 
     718        } 
     719        if(*cursor == ':' && firstDashPos == -1){ 
     720            firstDashPos = module_length; 
     721        } 
     722 
     723        module_length ++; 
     724        cursor_count ++; 
     725        cursor++; 
     726    } 
     727 
     728    if(cursor_count >= length){ 
     729        // we don't find any '~' characters, so we have parsed the resource 
     730        if(hasDot) RETURN_FALSE 
     731 
     732        resource_length = module_length; 
     733        module_length = 0; 
     734    }else if( *cursor == '@'){ 
     735        // we don't find any '~' characters, so we have parsed the resource 
     736        if(hasDot) RETURN_FALSE 
     737 
     738        resource_length = module_length; 
     739        module_length = 0; 
     740        hasRequest = 1; 
     741        // now we parse the @ section 
     742        cursor_count ++; 
     743        cursor++; 
     744 
     745        request = cursor; 
     746        request_length = 0; 
     747        while(cursor_count < length){ 
     748            if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     749                || ( *cursor >= 'A' && *cursor <= 'Z') 
     750                || ( *cursor >= '0' && *cursor <= '9') 
     751                || *cursor == '_' || *cursor == ':' || *cursor == '.')){ 
     752                RETURN_FALSE 
     753            } 
     754            request_length ++; 
     755            cursor_count ++; 
     756            cursor++; 
     757        } 
     758    }else{ 
     759        // the string starts by a ~ : it's not really a problem, but we generate an error 
     760        // to keep compatibily with php version of selectors. 
     761        if(module_length == 0){ 
     762            RETURN_FALSE 
     763        } 
     764        firstDashPos=-1; 
     765        cursor_count++; 
     766        cursor++; 
     767        resource = cursor; 
     768        resource_length = 0; 
     769        sharpOk = 0; 
     770        while(cursor_count < length){ 
     771            if(*cursor == '@'){ 
     772                break; 
     773            } 
     774 
     775            if(*cursor == '#'){ 
     776                if(sharpOk || resource_length > 1){ 
     777                    RETURN_FALSE 
     778                } 
     779                sharpOk=1; 
     780            }else if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     781                    || ( *cursor >= 'A' && *cursor <= 'Z') 
     782                    || ( *cursor >= '0' && *cursor <= '9') 
     783                    || *cursor == '_' || *cursor == ':') || sharpOk){ 
     784                    RETURN_FALSE 
     785            } 
     786            if(*cursor == ':' && firstDashPos == -1){ 
     787                firstDashPos = resource_length; 
     788            } 
     789 
     790            resource_length ++; 
     791            cursor_count ++; 
     792            cursor++; 
     793        } 
     794 
     795        if(*cursor == '@'){ 
     796            hasRequest = 1; 
     797            cursor_count++; 
     798            cursor++; 
     799            request = cursor; 
     800            request_length = 0; 
     801            while(cursor_count < length){ 
     802                if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     803                    || ( *cursor >= 'A' && *cursor <= 'Z') 
     804                    || ( *cursor >= '0' && *cursor <= '9') 
     805                    || *cursor == '_' || *cursor == '.')){ 
     806                    RETURN_FALSE 
     807                } 
     808                request_length ++; 
     809                cursor_count ++; 
     810                cursor++; 
     811            } 
     812        } 
     813    } 
     814 
     815    // request shouldn't empty if there is a @ 
     816    if(hasRequest && request_length == 0){ 
     817        RETURN_FALSE 
     818    } 
     819 
     820    if(resource_length == 0){ 
     821        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     "default_index", sizeof("default_index")-1 TSRMLS_CC); 
     822        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "controller", sizeof("controller") - 1, "default", sizeof("default")-1 TSRMLS_CC); 
     823        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "method", sizeof("method") - 1, "index", sizeof("index")-1 TSRMLS_CC); 
     824    }else{ 
     825        if(resource_length == 1 && *resource == '#'){ 
     826           resource_length = Z_STRLEN_PP(defaultActionArg); 
     827           resource = Z_STRVAL_PP(defaultActionArg); 
     828           firstDashPos=-1; 
     829           int i; 
     830           for(i=0; i < resource_length;i++){ 
     831                if(resource[i] == '_'){ 
     832                    firstDashPos=i; 
     833                    break; 
     834                } 
     835           } 
     836        } 
     837 
     838        if(firstDashPos == -1){ 
     839            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "controller", sizeof("controller") - 1,     "default", sizeof("default")-1 TSRMLS_CC); 
     840            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "method", sizeof("method") - 1,     resource, resource_length TSRMLS_CC); 
     841 
     842            char *r; 
     843            int ld = sizeof("default:") -1; 
     844            int lr = ld + resource_length; 
     845            r= emalloc(lr+1); 
     846            if (r) { 
     847                memcpy(r, "default:", ld); 
     848                memcpy(r+ld, resource, resource_length); 
     849                r[lr] = 0; 
     850                zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr TSRMLS_CC); 
     851                efree(r); 
     852            } 
     853 
     854        }else if(firstDashPos == 0){ 
     855            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "controller", sizeof("controller") - 1,     "default", sizeof("default")-1 TSRMLS_CC); 
     856            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "method", sizeof("method") - 1,     resource+1, resource_length-1 TSRMLS_CC); 
     857 
     858            char *r; 
     859            int ld = sizeof("default") -1; 
     860            int lr = ld + resource_length; 
     861            r= emalloc(lr+1); 
     862            if (r) { 
     863                memcpy(r, "default", ld); 
     864                memcpy(r+ld, resource, resource_length); 
     865                r[lr] = 0; 
     866                zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr TSRMLS_CC); 
     867                efree(r); 
     868            } 
     869 
     870        }else if(firstDashPos == resource_length-1){ 
     871            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "controller", sizeof("controller") - 1,     resource, resource_length-1 TSRMLS_CC); 
     872            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "method", sizeof("method") - 1,     "index", sizeof("index")-1 TSRMLS_CC); 
     873            char *r; 
     874            int ld = sizeof("index") -1; 
     875            int lr = resource_length + ld; 
     876            r= emalloc(lr+1); 
     877            if (r) { 
     878                memcpy(r, resource, resource_length); 
     879                memcpy(r+resource_length, "index", ld); 
     880                r[lr] = 0; 
     881                zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr TSRMLS_CC); 
     882                efree(r); 
     883            } 
     884 
     885        }else{ 
     886            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "controller", sizeof("controller") - 1,     resource, firstDashPos TSRMLS_CC); 
     887            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "method", sizeof("method") - 1,     resource+firstDashPos+1, resource_length-firstDashPos-1 TSRMLS_CC); 
     888            zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, resource, resource_length TSRMLS_CC); 
     889        } 
     890    } 
     891 
     892    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1,     module, module_length TSRMLS_CC); 
     893    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "request", sizeof("request") - 1,   request, request_length TSRMLS_CC); 
     894        RETURN_TRUE 
     895} 
     896/* }}} */ 
     897 
     898 
    653899/* {{{ proto boolean jelix_scan_class_sel(string arg, object tofill *) 
    654900   scan a string as a jelix selector, and fill object properties with founded values  
  • trunk/ext/jelix/php_jelix.h

    r649 r691  
    3636PHP_FUNCTION(jelix_scan_module_sel); 
    3737PHP_FUNCTION(jelix_scan_action_sel); 
     38PHP_FUNCTION(jelix_scan_old_action_sel); 
    3839PHP_FUNCTION(jelix_scan_class_sel); 
    3940PHP_FUNCTION(jelix_scan_locale_sel); 
  • trunk/ext/jelix/php_jelix.h

    r649 r691  
    3636PHP_FUNCTION(jelix_scan_module_sel); 
    3737PHP_FUNCTION(jelix_scan_action_sel); 
     38PHP_FUNCTION(jelix_scan_old_action_sel); 
    3839PHP_FUNCTION(jelix_scan_class_sel); 
    3940PHP_FUNCTION(jelix_scan_locale_sel); 
  • trunk/ext/jelix/tests/scan_action_sel_001.phpt

    r389 r691  
    1313} 
    1414 
    15 $tests = array( 0=>"toto", 1=>"aaa~toto", 2=>"aa_AZ123aR~toPO_etto", 3=>"foo.bar~trucmuche", 4=>"#", 
     15$tests = array( 0=>"toto", 1=>"aaa~toto", 2=>"aa_AZ123aR~toPO:etto", 3=>"foo.bar~trucmuche", 4=>"#", 
    1616                5=>"#~foo", 6=>"foo~#", 7=>"#~#", 8=>"@classic", 9=>"foo.bar~trucmuche@classic", 
    17                 10=>"foo.bar~truc_muche@classic", 11=>"#@classic",  12=>"#~foo@classic",  
     17                10=>"foo.bar~truc:muche@classic", 11=>"#@classic",  12=>"#~foo@classic",  
    1818                13=>"foo~#@classic", 14=>"#~#@classic", 
    19                 15=>"testapp~ctrl_meth@truc", 16=>"testapp~_meth@truc", 17=>"testapp~meth@truc", 
    20                 18=>"testapp~ctrl_@truc", 19=>"testapp~@truc", 20=>"testapp~#@truc", 
    21                 21=>"testapp~ctrl_meth", 22=>"testapp~_meth", 23=>"testapp~meth", 
    22                 24=>"testapp~ctrl_", 25=>"testapp~", 26=>"testapp~#", 
    23                 27=>"#~ctrl_meth@truc", 28=>"#~_meth@truc", 29=>"#~meth@truc", 
    24                 30=>"#~ctrl_@truc", 31=>"#~@truc", 32=>"#~#@truc", 
    25                 33=>"#~ctrl_meth", 34=>"#~_meth", 35=>"#~meth", 
    26                 36=>"#~ctrl_", 37=>"#~", 38=>"#~#", 39=>"ctrl_meth@truc", 
    27                 40=>"_meth@truc", 41=>"ctrl_@truc", 42=>"@truc", 
    28                 43=>"#@truc", 44=>"ctrl_meth", 45=>"_meth", 
    29                 46=>"meth", 47=>"ctrl_", 48=>"", 
     19                15=>"testapp~ctrl:meth@truc", 16=>"testapp~:meth@truc", 17=>"testapp~meth@truc", 
     20                18=>"testapp~ctrl:@truc", 19=>"testapp~@truc", 20=>"testapp~#@truc", 
     21                21=>"testapp~ctrl:meth", 22=>"testapp~:meth", 23=>"testapp~meth", 
     22                24=>"testapp~ctrl:", 25=>"testapp~", 26=>"testapp~#", 
     23                27=>"#~ctrl:meth@truc", 28=>"#~:meth@truc", 29=>"#~meth@truc", 
     24                30=>"#~ctrl:@truc", 31=>"#~@truc", 32=>"#~#@truc", 
     25                33=>"#~ctrl:meth", 34=>"#~:meth", 35=>"#~meth", 
     26                36=>"#~ctrl:", 37=>"#~", 38=>"#~#", 39=>"ctrl:meth@truc", 
     27                40=>":meth@truc", 41=>"ctrl:@truc", 42=>"@truc", 
     28                43=>"#@truc", 44=>"ctrl:meth", 45=>":meth", 
     29                46=>"meth", 47=>"ctrl:", 48=>"", 
     30                49=>"aa_AZ123aR~to_PO:etto", 
     31                50=>"aa_AZ123aR~toPO:et_to", 
     32                51=>"aa_AZ123aR~t_oPO:et_t_o", 
    3033 ); 
    3134 
     
    52550:ok 
    5356m= 
    54 r=default_toto 
     57r=default:toto 
    5558q= 
    5659c=default 
     
    58611:ok 
    5962m=aaa 
    60 r=default_toto 
     63r=default:toto 
    6164q= 
    6265c=default 
     
    64672:ok 
    6568m=aa_AZ123aR 
    66 r=toPO_etto 
     69r=toPO:etto 
    6770q= 
    6871c=toPO 
     
    70733:ok 
    7174m=foo.bar 
    72 r=default_trucmuche 
     75r=default:trucmuche 
    7376q= 
    7477c=default 
     
    76794:ok 
    7780m= 
    78 r=machin_bidule 
     81r=machin:bidule 
    7982q= 
    8083c=machin 
     
    82855:ok 
    8386m=# 
    84 r=default_foo 
     87r=default:foo 
    8588q= 
    8689c=default 
     
    88916:ok 
    8992m=foo 
    90 r=machin_bidule 
     93r=machin:bidule 
    9194q= 
    9295c=machin 
     
    94977:ok 
    9598m=# 
    96 r=machin_bidule 
     99r=machin:bidule 
    97100q= 
    98101c=machin 
     
    1001038:ok 
    101104m= 
    102 r=default_index 
     105r=default:index 
    103106q=classic 
    104107c=default 
     
    1061099:ok 
    107110m=foo.bar 
    108 r=default_trucmuche 
     111r=default:trucmuche 
    109112q=classic 
    110113c=default 
     
    11211510:ok 
    113116m=foo.bar 
    114 r=truc_muche 
     117r=truc:muche 
    115118q=classic 
    116119c=truc 
     
    11812111:ok 
    119122m= 
    120 r=machin_bidule 
     123r=machin:bidule 
    121124q=classic 
    122125c=machin 
     
    12412712:ok 
    125128m=# 
    126 r=default_foo 
     129r=default:foo 
    127130q=classic 
    128131c=default 
     
    13013313:ok 
    131134m=foo 
    132 r=machin_bidule 
     135r=machin:bidule 
    133136q=classic 
    134137c=machin 
     
    13613914:ok 
    137140m=# 
    138 r=machin_bidule 
     141r=machin:bidule 
    139142q=classic 
    140143c=machin 
     
    14214515:ok 
    143146m=testapp 
    144 r=ctrl_meth 
     147r=ctrl:meth 
    145148q=truc 
    146149c=ctrl 
     
    14815116:ok 
    149152m=testapp 
    150 r=default_meth 
     153r=default:meth 
    151154q=truc 
    152155c=default 
     
    15415717:ok 
    155158m=testapp 
    156 r=default_meth 
     159r=default:meth 
    157160q=truc 
    158161c=default 
     
    16016318:ok 
    161164m=testapp 
    162 r=ctrl_index 
     165r=ctrl:index 
    163166q=truc 
    164167c=ctrl 
     
    16616919:ok 
    167170m=testapp 
    168 r=default_index 
     171r=default:index 
    169172q=truc 
    170173c=default 
     
    17217520:ok 
    173176m=testapp 
    174 r=machin_bidule 
     177r=machin:bidule 
    175178q=truc 
    176179c=machin 
     
    17818121:ok 
    179182m=testapp 
    180 r=ctrl_meth 
     183r=ctrl:meth 
    181184q= 
    182185c=ctrl 
     
    18418722:ok 
    185188m=testapp 
    186 r=default_meth 
     189r=default:meth 
    187190q= 
    188191c=default 
     
    19019323:ok 
    191194m=testapp 
    192 r=default_meth 
     195r=default:meth 
    193196q= 
    194197c=default 
     
    19619924:ok 
    197200m=testapp 
    198 r=ctrl_index 
     201r=ctrl:index 
    199202q= 
    200203c=ctrl 
     
    20220525:ok 
    203206m=testapp 
    204 r=default_index 
     207r=default:index 
    205208q= 
    206209c=default 
     
    20821126:ok 
    209212m=testapp 
    210 r=machin_bidule 
     213r=machin:bidule 
    211214q= 
    212215c=machin 
     
    21421727:ok 
    215218m=# 
    216 r=ctrl_meth 
     219r=ctrl:meth 
    217220q=truc 
    218221c=ctrl 
     
    22022328:ok 
    221224m=# 
    222 r=default_meth 
     225r=default:meth 
    223226q=truc 
    224227c=default 
     
    22622929:ok 
    227230m=# 
    228 r=default_meth 
     231r=default:meth 
    229232q=truc 
    230233c=default 
     
    23223530:ok 
    233236m=# 
    234 r=ctrl_index 
     237r=ctrl:index 
    235238q=truc 
    236239c=ctrl 
     
    23824131:ok 
    239242m=# 
    240 r=default_index 
     243r=default:index 
    241244q=truc 
    242245c=default 
     
    24424732:ok 
    245248m=# 
    246 r=machin_bidule 
     249r=machin:bidule 
    247250q=truc 
    248251c=machin 
     
    25025333:ok 
    251254m=# 
    252 r=ctrl_meth 
     255r=ctrl:meth 
    253256q= 
    254257c=ctrl 
     
    25625934:ok 
    257260m=# 
    258 r=default_meth 
     261r=default:meth 
    259262q= 
    260263c=default 
     
    26226535:ok 
    263266m=# 
    264 r=default_meth 
     267r=default:meth 
    265268q= 
    266269c=default 
     
    26827136:ok 
    269272m=# 
    270 r=ctrl_index 
     273r=ctrl:index 
    271274q= 
    272275c=ctrl 
     
    27427737:ok 
    275278m=# 
    276 r=default_index 
     279r=default:index 
    277280q= 
    278281c=default 
     
    28028338:ok 
    281284m=# 
    282 r=machin_bidule 
     285r=machin:bidule 
    283286q= 
    284287c=machin 
     
    28628939:ok 
    287290m= 
    288 r=ctrl_meth 
     291r=ctrl:meth 
    289292q=truc 
    290293c=ctrl 
     
    29229540:ok 
    293296m= 
    294 r=default_meth 
     297r=default:meth 
    295298q=truc 
    296299c=default 
     
    29830141:ok 
    299302m= 
    300 r=ctrl_index 
     303r=ctrl:index 
    301304q=truc 
    302305c=ctrl 
     
    30430742:ok 
    305308m= 
    306 r=default_index 
     309r=default:index 
    307310q=truc 
    308311c=default 
     
    31031343:ok 
    311314m= 
    312 r=machin_bidule 
     315r=machin:bidule 
    313316q=truc 
    314317c=machin 
     
    31631944:ok 
    317320m= 
    318 r=ctrl_meth 
     321r=ctrl:meth 
    319322q= 
    320323c=ctrl 
     
    32232545:ok 
    323326m= 
    324 r=default_meth 
     327r=default:meth 
    325328q= 
    326329c=default 
     
    32833146:ok 
    329332m= 
    330 r=default_meth 
     333r=default:meth 
    331334q= 
    332335c=default 
     
    33433747:ok 
    335338m= 
    336 r=ctrl_index 
     339r=ctrl:index 
    337340q= 
    338341c=ctrl 
     
    34034348:ok 
    341344m= 
    342 r=default_index 
    343 q= 
    344 c=default 
    345 m=index 
     345r=default:index 
     346q= 
     347c=default 
     348m=index 
     34949:ok 
     350m=aa_AZ123aR 
     351r=to_PO:etto 
     352q= 
     353c=to_PO 
     354m=etto 
     35550:ok 
     356m=aa_AZ123aR 
     357r=toPO:et_to 
     358q= 
     359c=toPO 
     360m=et_to 
     36151:ok 
     362m=aa_AZ123aR 
     363r=t_oPO:et_t_o 
     364q= 
     365c=t_oPO 
     366m=et_t_o 
  • trunk/ext/jelix/tests/scan_action_sel_001.phpt

    r389 r691  
    1313} 
    1414 
    15 $tests = array( 0=>"toto", 1=>"aaa~toto", 2=>"aa_AZ123aR~toPO_etto", 3=>"foo.bar~trucmuche", 4=>"#", 
     15$tests = array( 0=>"toto", 1=>"aaa~toto", 2=>"aa_AZ123aR~toPO:etto", 3=>"foo.bar~trucmuche", 4=>"#", 
    1616                5=>"#~foo", 6=>"foo~#", 7=>"#~#", 8=>"@classic", 9=>"foo.bar~trucmuche@classic", 
    17                 10=>"foo.bar~truc_muche@classic", 11=>"#@classic",  12=>"#~foo@classic",  
     17                10=>"foo.bar~truc:muche@classic", 11=>"#@classic",  12=>"#~foo@classic",  
    1818                13=>"foo~#@classic", 14=>"#~#@classic", 
    19                 15=>"testapp~ctrl_meth@truc", 16=>"testapp~_meth@truc", 17=>"testapp~meth@truc", 
    20                 18=>"testapp~ctrl_@truc", 19=>"testapp~@truc", 20=>"testapp~#@truc", 
    21                 21=>"testapp~ctrl_meth", 22=>"testapp~_meth", 23=>"testapp~meth", 
    22                 24=>"testapp~ctrl_", 25=>"testapp~", 26=>"testapp~#", 
    23                 27=>"#~ctrl_meth@truc", 28=>"#~_meth@truc", 29=>"#~meth@truc", 
    24                 30=>"#~ctrl_@truc", 31=>"#~@truc", 32=>"#~#@truc", 
    25                 33=>"#~ctrl_meth", 34=>"#~_meth", 35=>"#~meth", 
    26                 36=>"#~ctrl_", 37=>"#~", 38=>"#~#", 39=>"ctrl_meth@truc", 
    27                 40=>"_meth@truc", 41=>"ctrl_@truc", 42=>"@truc", 
    28                 43=>"#@truc", 44=>"ctrl_meth", 45=>"_meth", 
    29                 46=>"meth", 47=>"ctrl_", 48=>"", 
     19                15=>"testapp~ctrl:meth@truc", 16=>"testapp~:meth@truc", 17=>"testapp~meth@truc", 
     20                18=>"testapp~ctrl:@truc", 19=>"testapp~@truc", 20=>"testapp~#@truc", 
     21                21=>"testapp~ctrl:meth", 22=>"testapp~:meth", 23=>"testapp~meth", 
     22                24=>"testapp~ctrl:", 25=>"testapp~", 26=>"testapp~#", 
     23    &