Changeset 649

Show
Ignore:
Timestamp:
11/22/07 00:31:33 (1 year ago)
Author:
laurentj
Message:

enhancement #256: added new selector parsers in the extension

Files:

Legend:

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

    r390 r649  
    3333        PHP_FE(jelix_scan_module_sel,  NULL) 
    3434        PHP_FE(jelix_scan_action_sel,  NULL) 
     35        PHP_FE(jelix_scan_class_sel,  NULL) 
     36        PHP_FE(jelix_scan_locale_sel,  NULL) 
    3537        {NULL, NULL, NULL}      /* Must be the last line in jelix_functions[] */ 
    3638}; 
     
    420422/* {{{ proto boolean jelix_scan_action_sel(string arg, object tofill *) 
    421423   scan a string as a jelix selector, and fill object properties with founded values  
    422 /^(?:([\w\.]+|\#)~)?([\w\.]+|\#)?(?:@([\w\.]+))?$/ 
     424/^(?:([a-zA-Z0-9_\.]+|\#)~)?([a-zA-Z0-9_]+|\#)?(?:@([a-zA-Z0-9_]+))?$/ 
    423425*/ 
    424426PHP_FUNCTION(jelix_scan_action_sel) 
     
    661663/* }}} */ 
    662664 
    663  
    664  
    665  
    666  
    667   /* 
    668     JELIX_SELECTOR_MODULE           /^(([\w\.]+)~)?([\w\.]+)$/ 
    669     JELIX_SELECTOR_ACTION           /^(?:([\w\.]+|\#)~)?([\w\.]+|\#)?(?:@([\w\.]+))?$/ 
    670     JELIX_SELECTOR_LOCALE           /^(([\w\.]+)~)?(\w+)\.([\w\.]+)$/ 
    671     JELIX_SELECTOR_SIMPLEFILE       /^([\w\.\/]+)$/ 
    672     */ 
     665/* {{{ proto boolean jelix_scan_class_sel(string arg, object tofill *) 
     666   scan a string as a jelix selector, and fill object properties with founded values  
     667/^(([a-zA-Z0-9_\.]+)~)?([a-zA-Z0-9_\.\\/]+)$/ 
     668*/ 
     669PHP_FUNCTION(jelix_scan_class_sel) 
     670
     671    zval **selectorStr, **objectArg; 
     672    switch (ZEND_NUM_ARGS()) { 
     673        case 2: 
     674            if (zend_get_parameters_ex(2, &selectorStr, &objectArg) == FAILURE) { 
     675                RETURN_FALSE; 
     676            } 
     677                        break; 
     678                default: 
     679                        ZEND_WRONG_PARAM_COUNT(); 
     680                        break; 
     681        } 
     682 
     683    if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 
     684                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 
     685        RETURN_FALSE 
     686        } 
     687 
     688    int length; 
     689    char *sel, *cursor, *module, *resource, *classname, *subpath; 
     690 
     691    int module_length=0; 
     692    int resource_length=0; 
     693    int class_length=0; 
     694    int subpath_length=0; 
     695    int cursor_count=0; 
     696 
     697    convert_to_string_ex(selectorStr); 
     698    length = Z_STRLEN_PP(selectorStr); 
     699    sel = Z_STRVAL_PP(selectorStr); 
     700 
     701    cursor_count=0; 
     702    cursor = module = resource = classname = subpath = sel; 
     703 
     704    int error = 0; 
     705    int hasSlash = 0; 
     706 
     707    // parse the module part 
     708    while(cursor_count < length){ 
     709        if(*cursor == '~'){ 
     710            break; 
     711        } 
     712        if (*cursor == '/') { 
     713            subpath_length = module_length + 1; 
     714            classname = cursor+1; 
     715        } else  if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     716            || ( *cursor >= 'A' && *cursor <= 'Z') 
     717            || ( *cursor >= '0' && *cursor <= '9') 
     718            || *cursor == '_' || *cursor == '.')) { 
     719            RETURN_FALSE 
     720        } 
     721        module_length ++; 
     722        cursor_count ++; 
     723        cursor++; 
     724    } 
     725 
     726 
     727    if(cursor_count >= length){ 
     728        // we don't find any '~' characters, so we have parsed the resource 
     729        resource_length = module_length; 
     730        module_length = 0; 
     731    }else{ 
     732        // the string starts by a ~ : it's not really a problem, but we generate an error 
     733        // to keep compatibility with php version of selectors. 
     734        if(module_length == 0 || subpath_length != 0){ 
     735            RETURN_FALSE 
     736        } 
     737 
     738        cursor_count++; 
     739        cursor++; 
     740        classname = subpath = resource = cursor; 
     741        resource_length = 0; 
     742        while(cursor_count < length){ 
     743            if (*cursor == '/') { 
     744                subpath_length = resource_length + 1; 
     745                classname = cursor+1; 
     746            } else if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     747                || ( *cursor >= 'A' && *cursor <= 'Z') 
     748                || ( *cursor >= '0' && *cursor <= '9') 
     749                || *cursor == '_' || *cursor == '.')){ 
     750                RETURN_FALSE 
     751            } 
     752            resource_length ++; 
     753            cursor_count ++; 
     754            cursor++; 
     755        } 
     756 
     757    } 
     758 
     759    if( resource_length == 0 ){ 
     760        RETURN_FALSE 
     761    } 
     762 
     763    if (subpath_length == 0) { 
     764        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "className", sizeof("className") - 1,   resource, resource_length TSRMLS_CC); 
     765        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "subpath", sizeof("subpath") - 1,       subpath, 0 TSRMLS_CC); 
     766    } 
     767    else if (subpath_length == 1) { 
     768        if (resource_length == 1) { 
     769            RETURN_FALSE 
     770        } 
     771        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "className", sizeof("className") - 1,   classname, resource_length-1 TSRMLS_CC); 
     772        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "subpath", sizeof("subpath") - 1,       subpath, 0 TSRMLS_CC); 
     773    } 
     774    else { 
     775        if (resource_length == subpath_length) { 
     776            RETURN_FALSE 
     777        } 
     778        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "className", sizeof("className") - 1,   classname, resource_length - subpath_length TSRMLS_CC); 
     779        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "subpath", sizeof("subpath") - 1,       subpath, subpath_length TSRMLS_CC); 
     780    } 
     781 
     782    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1,     module, module_length TSRMLS_CC); 
     783    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, resource, resource_length TSRMLS_CC); 
     784 
     785        RETURN_TRUE 
     786
     787 
     788/* {{{ proto boolean jelix_scan_locale_sel(string arg, object tofill *) 
     789   scan a string as a jelix selector, and fill object properties with founded values  
     790/^(([a-zA-Z0-9_\.]+)~)?([a-zA-Z0-9_]+)\.([a-zA-Z0-9_\.]+)$/ 
     791*/ 
     792PHP_FUNCTION(jelix_scan_locale_sel) 
     793
     794    zval **selectorStr, **objectArg; 
     795    switch (ZEND_NUM_ARGS()) { 
     796        case 2: 
     797            if (zend_get_parameters_ex(2, &selectorStr, &objectArg) == FAILURE) { 
     798                RETURN_FALSE; 
     799            } 
     800                        break; 
     801                default: 
     802                        ZEND_WRONG_PARAM_COUNT(); 
     803                        break; 
     804        } 
     805 
     806    if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 
     807                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 
     808        RETURN_FALSE 
     809        } 
     810 
     811    int length; 
     812    char *sel, *cursor, *module, *resource, *filekey, *localekey; 
     813 
     814    int module_length=0; 
     815    int resource_length=0; 
     816    int filekey_length=0; 
     817    int localkey_length=0; 
     818    int cursor_count=0; 
     819 
     820    convert_to_string_ex(selectorStr); 
     821    length = Z_STRLEN_PP(selectorStr); 
     822    sel = Z_STRVAL_PP(selectorStr); 
     823 
     824    cursor_count=0; 
     825    cursor = module = resource = filekey = localekey = sel; 
     826 
     827    int error = 0; 
     828    int hasPoint = 0; 
     829 
     830    // parse the module part 
     831    while(cursor_count < length){ 
     832        if(*cursor == '~'){ 
     833            break; 
     834        } 
     835        if (*cursor == '.' && !hasPoint) { 
     836            filekey_length = module_length; 
     837            localekey = cursor+1; 
     838            hasPoint = 1; 
     839        } else  if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     840            || ( *cursor >= 'A' && *cursor <= 'Z') 
     841            || ( *cursor >= '0' && *cursor <= '9') 
     842            || *cursor == '_' || *cursor == '.')) { 
     843            RETURN_FALSE 
     844        } 
     845        module_length ++; 
     846        cursor_count ++; 
     847        cursor++; 
     848    } 
     849 
     850    if(cursor_count >= length){ 
     851        // we don't find any '~' characters, so we have parsed the resource 
     852        resource_length = module_length; 
     853        module_length = 0; 
     854    }else{ 
     855        // the string starts by a ~ : it's not really a problem, but we generate an error 
     856        // to keep compatibility with php version of selectors. 
     857        if(module_length == 0){ 
     858            RETURN_FALSE 
     859        } 
     860        hasPoint = 0; 
     861        cursor_count++; 
     862        cursor++; 
     863        filekey = localekey = resource = cursor; 
     864        resource_length = 0; 
     865        filekey_length = 0; 
     866        while(cursor_count < length){ 
     867            if (*cursor == '.' && !hasPoint) { 
     868                filekey_length = resource_length; 
     869                localekey = cursor+1; 
     870                hasPoint = 1; 
     871            } else if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     872                || ( *cursor >= 'A' && *cursor <= 'Z') 
     873                || ( *cursor >= '0' && *cursor <= '9') 
     874                || *cursor == '_' || *cursor == '.')){ 
     875                RETURN_FALSE 
     876            } 
     877            resource_length ++; 
     878            cursor_count ++; 
     879            cursor++; 
     880        } 
     881    } 
     882 
     883    if (resource_length == 0 || filekey_length == 0 || filekey_length == 1  
     884        || filekey_length == resource_length || filekey_length == resource_length -1) { 
     885        RETURN_FALSE 
     886    } 
     887 
     888    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "fileKey", sizeof("fileKey") - 1,   filekey, filekey_length TSRMLS_CC); 
     889    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "messageKey", sizeof("messageKey") - 1,     localekey, resource_length - filekey_length -1 TSRMLS_CC); 
     890    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1,     module, module_length TSRMLS_CC); 
     891    /*zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,       resource, resource_length TSRMLS_CC);*/ 
     892    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, filekey, filekey_length TSRMLS_CC); 
     893 
     894        RETURN_TRUE 
     895
     896/* }}} */ 
  • trunk/ext/jelix/jelix.c

    r390 r649  
    3333        PHP_FE(jelix_scan_module_sel,  NULL) 
    3434        PHP_FE(jelix_scan_action_sel,  NULL) 
     35        PHP_FE(jelix_scan_class_sel,  NULL) 
     36        PHP_FE(jelix_scan_locale_sel,  NULL) 
    3537        {NULL, NULL, NULL}      /* Must be the last line in jelix_functions[] */ 
    3638}; 
     
    420422/* {{{ proto boolean jelix_scan_action_sel(string arg, object tofill *) 
    421423   scan a string as a jelix selector, and fill object properties with founded values  
    422 /^(?:([\w\.]+|\#)~)?([\w\.]+|\#)?(?:@([\w\.]+))?$/ 
     424/^(?:([a-zA-Z0-9_\.]+|\#)~)?([a-zA-Z0-9_]+|\#)?(?:@([a-zA-Z0-9_]+))?$/ 
    423425*/ 
    424426PHP_FUNCTION(jelix_scan_action_sel) 
     
    661663/* }}} */ 
    662664 
    663  
    664  
    665  
    666  
    667   /* 
    668     JELIX_SELECTOR_MODULE           /^(([\w\.]+)~)?([\w\.]+)$/ 
    669     JELIX_SELECTOR_ACTION           /^(?:([\w\.]+|\#)~)?([\w\.]+|\#)?(?:@([\w\.]+))?$/ 
    670     JELIX_SELECTOR_LOCALE           /^(([\w\.]+)~)?(\w+)\.([\w\.]+)$/ 
    671     JELIX_SELECTOR_SIMPLEFILE       /^([\w\.\/]+)$/ 
    672     */ 
     665/* {{{ proto boolean jelix_scan_class_sel(string arg, object tofill *) 
     666   scan a string as a jelix selector, and fill object properties with founded values  
     667/^(([a-zA-Z0-9_\.]+)~)?([a-zA-Z0-9_\.\\/]+)$/ 
     668*/ 
     669PHP_FUNCTION(jelix_scan_class_sel) 
     670
     671    zval **selectorStr, **objectArg; 
     672    switch (ZEND_NUM_ARGS()) { 
     673        case 2: 
     674            if (zend_get_parameters_ex(2, &selectorStr, &objectArg) == FAILURE) { 
     675                RETURN_FALSE; 
     676            } 
     677                        break; 
     678                default: 
     679                        ZEND_WRONG_PARAM_COUNT(); 
     680                        break; 
     681        } 
     682 
     683    if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 
     684                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 
     685        RETURN_FALSE 
     686        } 
     687 
     688    int length; 
     689    char *sel, *cursor, *module, *resource, *classname, *subpath; 
     690 
     691    int module_length=0; 
     692    int resource_length=0; 
     693    int class_length=0; 
     694    int subpath_length=0; 
     695    int cursor_count=0; 
     696 
     697    convert_to_string_ex(selectorStr); 
     698    length = Z_STRLEN_PP(selectorStr); 
     699    sel = Z_STRVAL_PP(selectorStr); 
     700 
     701    cursor_count=0; 
     702    cursor = module = resource = classname = subpath = sel; 
     703 
     704    int error = 0; 
     705    int hasSlash = 0; 
     706 
     707    // parse the module part 
     708    while(cursor_count < length){ 
     709        if(*cursor == '~'){ 
     710            break; 
     711        } 
     712        if (*cursor == '/') { 
     713            subpath_length = module_length + 1; 
     714            classname = cursor+1; 
     715        } else  if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     716            || ( *cursor >= 'A' && *cursor <= 'Z') 
     717            || ( *cursor >= '0' && *cursor <= '9') 
     718            || *cursor == '_' || *cursor == '.')) { 
     719            RETURN_FALSE 
     720        } 
     721        module_length ++; 
     722        cursor_count ++; 
     723        cursor++; 
     724    } 
     725 
     726 
     727    if(cursor_count >= length){ 
     728        // we don't find any '~' characters, so we have parsed the resource 
     729        resource_length = module_length; 
     730        module_length = 0; 
     731    }else{ 
     732        // the string starts by a ~ : it's not really a problem, but we generate an error 
     733        // to keep compatibility with php version of selectors. 
     734        if(module_length == 0 || subpath_length != 0){ 
     735            RETURN_FALSE 
     736        } 
     737 
     738        cursor_count++; 
     739        cursor++; 
     740        classname = subpath = resource = cursor; 
     741        resource_length = 0; 
     742        while(cursor_count < length){ 
     743            if (*cursor == '/') { 
     744                subpath_length = resource_length + 1; 
     745                classname = cursor+1; 
     746            } else if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     747                || ( *cursor >= 'A' && *cursor <= 'Z') 
     748                || ( *cursor >= '0' && *cursor <= '9') 
     749                || *cursor == '_' || *cursor == '.')){ 
     750                RETURN_FALSE 
     751            } 
     752            resource_length ++; 
     753            cursor_count ++; 
     754            cursor++; 
     755        } 
     756 
     757    } 
     758 
     759    if( resource_length == 0 ){ 
     760        RETURN_FALSE 
     761    } 
     762 
     763    if (subpath_length == 0) { 
     764        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "className", sizeof("className") - 1,   resource, resource_length TSRMLS_CC); 
     765        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "subpath", sizeof("subpath") - 1,       subpath, 0 TSRMLS_CC); 
     766    } 
     767    else if (subpath_length == 1) { 
     768        if (resource_length == 1) { 
     769            RETURN_FALSE 
     770        } 
     771        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "className", sizeof("className") - 1,   classname, resource_length-1 TSRMLS_CC); 
     772        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "subpath", sizeof("subpath") - 1,       subpath, 0 TSRMLS_CC); 
     773    } 
     774    else { 
     775        if (resource_length == subpath_length) { 
     776            RETURN_FALSE 
     777        } 
     778        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "className", sizeof("className") - 1,   classname, resource_length - subpath_length TSRMLS_CC); 
     779        zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "subpath", sizeof("subpath") - 1,       subpath, subpath_length TSRMLS_CC); 
     780    } 
     781 
     782    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1,     module, module_length TSRMLS_CC); 
     783    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, resource, resource_length TSRMLS_CC); 
     784 
     785        RETURN_TRUE 
     786
     787 
     788/* {{{ proto boolean jelix_scan_locale_sel(string arg, object tofill *) 
     789   scan a string as a jelix selector, and fill object properties with founded values  
     790/^(([a-zA-Z0-9_\.]+)~)?([a-zA-Z0-9_]+)\.([a-zA-Z0-9_\.]+)$/ 
     791*/ 
     792PHP_FUNCTION(jelix_scan_locale_sel) 
     793
     794    zval **selectorStr, **objectArg; 
     795    switch (ZEND_NUM_ARGS()) { 
     796        case 2: 
     797            if (zend_get_parameters_ex(2, &selectorStr, &objectArg) == FAILURE) { 
     798                RETURN_FALSE; 
     799            } 
     800                        break; 
     801                default: 
     802                        ZEND_WRONG_PARAM_COUNT(); 
     803                        break; 
     804        } 
     805 
     806    if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 
     807                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 
     808        RETURN_FALSE 
     809        } 
     810 
     811    int length; 
     812    char *sel, *cursor, *module, *resource, *filekey, *localekey; 
     813 
     814    int module_length=0; 
     815    int resource_length=0; 
     816    int filekey_length=0; 
     817    int localkey_length=0; 
     818    int cursor_count=0; 
     819 
     820    convert_to_string_ex(selectorStr); 
     821    length = Z_STRLEN_PP(selectorStr); 
     822    sel = Z_STRVAL_PP(selectorStr); 
     823 
     824    cursor_count=0; 
     825    cursor = module = resource = filekey = localekey = sel; 
     826 
     827    int error = 0; 
     828    int hasPoint = 0; 
     829 
     830    // parse the module part 
     831    while(cursor_count < length){ 
     832        if(*cursor == '~'){ 
     833            break; 
     834        } 
     835        if (*cursor == '.' && !hasPoint) { 
     836            filekey_length = module_length; 
     837            localekey = cursor+1; 
     838            hasPoint = 1; 
     839        } else  if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     840            || ( *cursor >= 'A' && *cursor <= 'Z') 
     841            || ( *cursor >= '0' && *cursor <= '9') 
     842            || *cursor == '_' || *cursor == '.')) { 
     843            RETURN_FALSE 
     844        } 
     845        module_length ++; 
     846        cursor_count ++; 
     847        cursor++; 
     848    } 
     849 
     850    if(cursor_count >= length){ 
     851        // we don't find any '~' characters, so we have parsed the resource 
     852        resource_length = module_length; 
     853        module_length = 0; 
     854    }else{ 
     855        // the string starts by a ~ : it's not really a problem, but we generate an error 
     856        // to keep compatibility with php version of selectors. 
     857        if(module_length == 0){ 
     858            RETURN_FALSE 
     859        } 
     860        hasPoint = 0; 
     861        cursor_count++; 
     862        cursor++; 
     863        filekey = localekey = resource = cursor; 
     864        resource_length = 0; 
     865        filekey_length = 0; 
     866        while(cursor_count < length){ 
     867            if (*cursor == '.' && !hasPoint) { 
     868                filekey_length = resource_length; 
     869                localekey = cursor+1; 
     870                hasPoint = 1; 
     871            } else if(!( ( *cursor >= 'a' && *cursor <= 'z') 
     872                || ( *cursor >= 'A' && *cursor <= 'Z') 
     873                || ( *cursor >= '0' && *cursor <= '9') 
     874                || *cursor == '_' || *cursor == '.')){ 
     875                RETURN_FALSE 
     876            } 
     877            resource_length ++; 
     878            cursor_count ++; 
     879            cursor++; 
     880        } 
     881    } 
     882 
     883    if (resource_length == 0 || filekey_length == 0 || filekey_length == 1  
     884        || filekey_length == resource_length || filekey_length == resource_length -1) { 
     885        RETURN_FALSE 
     886    } 
     887 
     888    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "fileKey", sizeof("fileKey") - 1,   filekey, filekey_length TSRMLS_CC); 
     889    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "messageKey", sizeof("messageKey") - 1,     localekey, resource_length - filekey_length -1 TSRMLS_CC); 
     890    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1,     module, module_length TSRMLS_CC); 
     891    /*zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,       resource, resource_length TSRMLS_CC);*/ 
     892    zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, filekey, filekey_length TSRMLS_CC); 
     893 
     894        RETURN_TRUE 
     895
     896/* }}} */ 
  • trunk/ext/jelix/php_jelix.h

    r387 r649  
    3636PHP_FUNCTION(jelix_scan_module_sel); 
    3737PHP_FUNCTION(jelix_scan_action_sel); 
    38  
     38PHP_FUNCTION(jelix_scan_class_sel); 
     39PHP_FUNCTION(jelix_scan_locale_sel); 
    3940 
    4041ZEND_BEGIN_MODULE_GLOBALS(jelix) 
  • trunk/ext/jelix/php_jelix.h

    r387 r649  
    3636PHP_FUNCTION(jelix_scan_module_sel); 
    3737PHP_FUNCTION(jelix_scan_action_sel); 
    38  
     38PHP_FUNCTION(jelix_scan_class_sel); 
     39PHP_FUNCTION(jelix_scan_locale_sel); 
    3940 
    4041ZEND_BEGIN_MODULE_GLOBALS(jelix) 
  • trunk/lib/jelix/core/jSelector.class.php

    r630 r649  
    332332 
    333333    function __construct($sel){ 
     334#if ENABLE_PHP_JELIX 
     335        if(jelix_scan_class_sel($sel, $this)){ 
     336            if($this->module ==''){ 
     337                $this->module = jContext::get (); 
     338            } 
     339#else 
    334340        if(preg_match("/^(([a-zA-Z0-9_\.]+)~)?([a-zA-Z0-9_\.\\/]+)$/", $sel, $m)){ 
    335341            if($m[1]!='' && $m[2]!=''){ 
     
    346352                $this->subpath =''; 
    347353            } 
    348              
     354#endif 
    349355            $this->_createPath(); 
    350356            $this->_createCachePath(); 
     
    411417    public $locale =''; 
    412418    public $charset=''; 
     419    public $_compiler = 'jLocalesCompiler'; 
    413420 
    414421    function __construct($sel, $locale=null, $charset=null){ 
     
    428435        $this->_suffix = '.'.$charset.'.properties'; 
    429436        $this->_cacheSuffix = '.'.$charset.'.php'; 
    430         $this->_compiler='jLocalesCompiler'; 
    431437        $this->_compilerPath=JELIX_LIB_CORE_PATH.'jLocalesCompiler.class.php'; 
    432438 
     439#if ENABLE_PHP_JELIX 
     440        if(jelix_scan_locale_sel($sel, $this)){ 
     441            if($this->module ==''){ 
     442                $this->module = jContext::get (); 
     443            } 
     444#else 
    433445        if(preg_match("/^(([a-zA-Z0-9_\.]+)~)?([a-zA-Z0-9_]+)\.([a-zA-Z0-9_\.]+)$/", $sel, $m)){ 
    434446            if($m[1]!='' && $m[2]!=''){ 
     
    440452            $this->fileKey = $m[3]; 
    441453            $this->messageKey = $m[4]; 
     454#endif 
    442455            $this->_createPath(); 
    443456            $this->_createCachePath(); 
  • trunk/lib/jelix/core/jSelector.class.php

    r630 r649  
    332332 
    333333    function __construct($sel){ 
     334#if ENABLE_PHP_JELIX 
     335        if(jelix_scan_class_sel($sel, $this)){ 
     336            if($this->module ==''){ 
     337                $this->module = jContext::get (); 
     338            } 
     339#else 
    334340        if(preg_match("/^(([a-zA-Z0-9_\.]+)~)?([a-zA-Z0-9_\.\\/]+)$/", $sel, $m)){ 
    335341            if($m[1]!='' && $m[2]!=''){ 
     
    346352                $this->subpath =''; 
    347353            } 
    348              
     354#endif 
    349355            $this->_createPath(); 
    350356            $this->_createCachePath(); 
     
    411417    public $locale =''; 
    412418    public $charset=''; 
     419    public $_compiler = 'jLocalesCompiler'; 
    413420 
    414421    function __construct($sel, $locale=null, $charset=null){ 
     
    428435        $this->_suffix = '.'.$charset.'.properties'; 
    429436        $this->_cacheSuffix = '.'.$charset.'.php'; 
    430         $this->_compiler='jLocalesCompiler'; 
    431437        $this->_compilerPath=JELIX_LIB_CORE_PATH.'jLocalesCompiler.class.php'; 
    432438 
     439#if ENABLE_PHP_JELIX 
     440        if(jelix_scan_locale_sel($sel, $this)){ 
     441            if($this->module ==''){ 
     442                $this->module = jContext::get (); 
     443            } 
     444#else 
    433445        if(preg_match("/^(([a-zA-Z0-9_\.]+)~)?([a-zA-Z0-9_]+)\.([a-zA-Z0-9_\.]+)$/", $sel, $m)){ 
    434446            if($m[1]!='' && $m[2]!=''){ 
     
    440452            $this->fileKey = $m[3]; 
    441453            $this->messageKey = $m[4]; 
     454#endif 
    442455            $this->_createPath(); 
    443456            $this->_createCachePath(); 
Download in other formats: Unified Diff Zip Archive