From d0f6503183524466e44860677d9af6e3abb0e80a Mon Sep 17 00:00:00 2001 From: mohrt Date: Tue, 15 Apr 2003 13:34:55 +0000 Subject: [PATCH] remove fix_vars.php file from distribution, add smarty icon gif --- .gitattributes | 1 + misc/fix_vars.php | 194 ------------------------------------------- misc/smarty_icon.gif | Bin 0 -> 1102 bytes 3 files changed, 1 insertion(+), 194 deletions(-) delete mode 100644 misc/fix_vars.php create mode 100644 misc/smarty_icon.gif diff --git a/.gitattributes b/.gitattributes index 8e948c53..11670a8e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ * text=auto !eol +misc/smarty_icon.gif -text diff --git a/misc/fix_vars.php b/misc/fix_vars.php deleted file mode 100644 index ce50a964..00000000 --- a/misc/fix_vars.php +++ /dev/null @@ -1,194 +0,0 @@ - 1.4.0. - * This script will convert Smarty variable references from the old format to - * the new one. For example, what used to look like $section1/foo.bar will now - * be $foo[section1].bar. This allows for more readable syntax and also allows - * referencing deeply nested structures of arbitrary complexity. - */ - -/* - * Set these to match your template delimeters. - */ -$left_delimiter = '{'; -$right_delimiter = '}'; - - -if ($argc < 2) { - die("\nUsage: php -q fix_vars.php \n\n"); -} - -$ldq = preg_quote($left_delimiter, '!'); -$rdq = preg_quote($right_delimiter, '!'); - -$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\''; -$pwd = $HTTP_ENV_VARS['PWD']; - -foreach (array_slice($argv, 1) as $template) { - $template = $pwd . '/' . $template; - if (!is_file($template)) continue; - - $input = implode('', file($template)); - $fp = fopen($template.'.out', 'w'); - if (!$fp) { - die("\nError: could not open $template.out for writing\n\n"); - } - - /* Gather all template tags. */ - preg_match_all("!({$ldq}\s*)(.*?)(\s*{$rdq})!s", $input, $match); - $template_tags = $match[2]; - $template_pre_tags = $match[1]; - $template_post_tags = $match[3]; - /* Split content by template tags to obtain non-template content. */ - $text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $input); - - $fixed_tags = array(); - for ($i = 0; $i < count($template_tags); $i++) { - $fixed_tags[] = fix_tag($template_tags[$i]); - } - - $output = ''; - /* Interleave the compiled contents and text blocks to get the final result. */ - for ($i = 0; $i < count($fixed_tags); $i++) { - $output .= $text_blocks[$i].$template_pre_tags[$i].$fixed_tags[$i].$template_post_tags[$i]; - } - $output .= $text_blocks[$i]; - - fwrite($fp, $output); - fclose($fp); - copy($template.'.out', $template); - unlink($template.'.out'); - - print "Fixed $template.\n"; -} - -function fix_tag($template_tag) -{ - global $qstr_regexp; - - if ($template_tag{0} == '*' && $template_tag{strlen($template_tag)-1} == '*') - return $template_tag; - - /* Split tag into two parts: command and the arguments. */ - preg_match('/^( - (?: ' . $qstr_regexp . ' | (?>[^"\'\s]+))+ - ) - (\s+(.*))? - /xs', $template_tag, $match); - list(, $tag_command, $tag_args) = $match; - if (preg_match('!^\$(\w+(\.\w+)?/)*\w+(?>\.\w+)*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tag_command)) - $tag_command = fix_var($tag_command); - else if (preg_match('!^#(\w+)#(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tag_command)) - $tag_command = fix_other_var($tag_command); - else if (preg_match('!^%\w+\.\w+%(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tag_command)) - $tag_command = fix_other_var($tag_command); - - if (function_exists("preg_replace_callback")) { - $tag_args = preg_replace_callback('!(?<=[\s(:=])\$(\w+(\.\w+)?/)*\w+(?>\.\w+)*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|}\s]+))*)*!', 'fix_var_match', $tag_args); - $tag_args = preg_replace_callback('!(?<=[\s(:=])#(\w+)#(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|}\s]+))*)*!', 'fix_other_var_match', $tag_args); - $tag_args = preg_replace_callback('!(?<=[\s(:=])%\w+\.\w+%(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|}\s]+))*)*!', 'fix_other_var_match', $tag_args); - } else { - $tag_args = preg_replace('!(?<=[\s(:=])\$(\w+(\.\w+)?/)*\w+(?>\.\w+)*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|}\s]+))*)*!F', 'fix_var_match', $tag_args); - $tag_args = preg_replace('!(?<=[\s(:=])#(\w+)#(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|}\s]+))*)*!F', 'fix_other_var_match', $tag_args); - $tag_args = preg_replace('!(?<=[\s(:=])%\w+\.\w+%(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|}\s]+))*)*!F', 'fix_other_var_match', $tag_args); - } - - return $tag_command.$tag_args; -} - -function fix_vars_props($tokens) -{ - global $qstr_regexp; - - $var_exprs = preg_grep('!^\$(\w+(\.\w+)?/)*\w+(?>\.\w+)*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tokens); - $conf_var_exprs = preg_grep('!^#(\w+)#(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tokens); - $sect_prop_exprs = preg_grep('!^%\w+\.\w+%(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tokens); - - if (count($var_exprs)) { - foreach ($var_exprs as $expr_index => $var_expr) { - $tokens[$expr_index] = fix_var($var_expr); - } - } - - /* - if (count($conf_var_exprs)) { - foreach ($conf_var_exprs as $expr_index => $var_expr) { - $tokens[$expr_index] = $this->_parse_conf_var($var_expr); - } - } - - if (count($sect_prop_exprs)) { - foreach ($sect_prop_exprs as $expr_index => $section_prop_expr) { - $tokens[$expr_index] = $this->_parse_section_prop($section_prop_expr); - } - } - */ - - return $tokens; -} - -function fix_var_match($match) -{ - return fix_var($match[0]); -} - -function fix_other_var_match($match) -{ - return fix_other_var($match[0]); -} - -function fix_var($var_expr) -{ - list($var_ref, $modifiers) = explode('|', substr($var_expr, 1), 2); - - $sections = explode('/', $var_ref); - $props = explode('.', array_pop($sections)); - $var_name = array_shift($props); - - $output = "\$$var_name"; - - foreach ($sections as $section_ref) { - $output .= "[$section_ref]"; - } - if (count($props)) - $output .= ".".implode('.', $props); - - if ($modifiers) - $output .= fix_modifiers($modifiers); - - return $output; -} - -function fix_other_var($var_expr) -{ - list($var_ref, $modifiers) = explode('|', $var_expr, 2); - - $output = $var_ref; - if ($modifiers) - $output .= fix_modifiers($modifiers); - - return $output; -} - -function fix_modifiers($modifier_string) -{ - global $qstr_regexp; - - preg_match_all('!\|(@?\w+)((?>:(?:'. $qstr_regexp . '|[^|]+))*)!', '|' . $modifier_string, $match); - list(, $modifiers, $modifier_arg_strings) = $match; - $output = ''; - for ($i = 0; $i < count($modifiers); $i++) { - $modifier_name = $modifiers[$i]; - preg_match_all('!:(' . $qstr_regexp . '|[^:]+)!', $modifier_arg_strings[$i], $match); - $modifier_args = fix_vars_props($match[1]); - - $output .= '|' . $modifier_name; - if ($modifier_args) - $output .= ':'.implode(':', $modifier_args); - } - - return $output; -} - -?> diff --git a/misc/smarty_icon.gif b/misc/smarty_icon.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d5196995c01db0c78f6ff1b3191f6dbd8225460 GIT binary patch literal 1102 zcmZ?wbhEHbj9`#wIKsg2_0zK@3uk^m8xa{9_xoC&w6yG(8(j;gg#CW8=KWrarIVzd zUf=lp1@ni4)(5vvy>WbIw72xn2Q$xKxV&vy+NnimyVh_&JkL;HSJz%?x_j4l3k$Q4 zhrJhg2+nroV_;zTaKJ(FCkq1z=zs{2oeZr17pV88WX{W2weHQYy#+ewOLFg5#C2D_ z|L-s-!9C3N$#bWs35qL;vn`r7 zHLB5NRjMGLurPlD2ipQaem+J%{zSGt{M;OT`vof*`B`QPvK`;&FMVh~_YrO>CFY}t zkK8kJ?(FH|XXg?XW@k@0E6*)1#VW@tCC<;l{E3;F^{e<_E}jzwsttBkOtK0b3l=Wi z$0PLYqO`)oL}$*wCOjPK9^ou3+%zbw6w2f9!C}#!T!yeo z4H_E{uyQJMrAR0^F&}r-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