@@ -14,7 +14,7 @@ public function getDefaultOperatorInputByType()
1414 {
1515 if (null === $ this ->_defaultOperatorInputByType ) {
1616 $ this ->_defaultOperatorInputByType = array (
17- 'string ' => array ('== ' , '!= ' , '{} ' , '!{} ' , '^ ' , '$ ' , '!^ ' , '!$ ' , '() ' , '!() ' , '// ' ),
17+ 'string ' => array ('== ' , '!= ' , '{} ' , '!{} ' , '^ ' , '$ ' , '!^ ' , '!$ ' , '() ' , '!() ' , '^() ' , ' !^() ' , ' // ' ),
1818 'numeric ' => array ('== ' , '!= ' , '>= ' , '> ' , '<= ' , '< ' , '.. ' , '!.. ' , '() ' , '!() ' ),
1919 'numeric_b26 ' => array ('== ' , '!= ' , '>=:b26 ' , '>:b26 ' , '<=:b26 ' , '<:b26 ' , '..:b26 ' , '!..:b26 ' , '() ' , '!() ' ),
2020 'numeric_b36 ' => array ('== ' , '!= ' , '>=:b36 ' , '>:b36 ' , '<=:b36 ' , '<:b36 ' , '..:b36 ' , '!..:b36 ' , '() ' , '!() ' ),
@@ -70,6 +70,8 @@ public function getDefaultOperatorOptions()
7070 '$ ' => Mage::helper ('meanship ' )->__ ('ends with ' ),
7171 '!^ ' => Mage::helper ('meanship ' )->__ ('does not begin with ' ),
7272 '!$ ' => Mage::helper ('meanship ' )->__ ('does not end with ' ),
73+ '^() ' => Mage::helper ('rule ' )->__ ('begins with one of ' ),
74+ '!^() ' => Mage::helper ('rule ' )->__ ('does not begin with one of ' ),
7375 '// ' => Mage::helper ('meanship ' )->__ ('matches regex ' ),
7476 );
7577 }
@@ -86,7 +88,7 @@ public function getDefaultOperatorOptions()
8688 */
8789 public function isArrayOperatorType () {
8890 $ op = $ this ->getOperator ();
89- return $ op === '() ' || $ op === '!() ' || in_array ($ this ->getInputType (), $ this ->_arrayInputTypes );
91+ return $ op === '() ' || $ op === '!() ' || $ op === ' ^() ' || $ op === ' !^() ' || in_array ($ this ->getInputType (), $ this ->_arrayInputTypes );
9092 }
9193
9294 /**
@@ -350,14 +352,30 @@ public function validateAttribute($validatedValue)
350352 $ result = (substr ($ validatedValue , -$ length ) === $ value );
351353 }
352354 break ;
355+
356+ case '^() ' : case '!^() ' :
357+ if (!is_string ($ validatedValue )) {
358+ return false ;
359+ } else {
360+ $ value = (array )$ value ;
361+ foreach ($ value as $ item ) {
362+ $ length = strlen ($ item );
363+ if (substr ($ validatedValue , 0 , $ length ) === $ item ) {
364+ $ result = true ;
365+ break ;
366+ }
367+ }
368+ }
369+ break ;
370+
353371 case '// ' :
354372 if (Mage::helper ('meanship ' )->isValidRegex ($ value )) {
355373 $ result = (bool )preg_match ($ value , $ validatedValue );
356374 }
357375 break ;
358376 }
359377
360- if (in_array ($ op , array ('!= ' , '> ' , '< ' , '>:b26 ' , '<:b26 ' , '>:b36 ' , '<:b36 ' , '!.. ' , '!..:b26 ' , '!..:b36 ' , '!{} ' , '!() ' , '!^ ' , '!$ ' ))) {
378+ if (in_array ($ op , array ('!= ' , '> ' , '< ' , '>:b26 ' , '<:b26 ' , '>:b36 ' , '<:b36 ' , '!.. ' , '!..:b26 ' , '!..:b36 ' , '!{} ' , '!() ' , '!^ ' , '!$ ' , ' !^() ' ))) {
361379 $ result = !$ result ;
362380 }
363381
0 commit comments