templateVars["'.$data.'"] . "'; } if ( isset($options['default']) ) { $phpCode .= "\n" . '$this->templateVars[\'' . $data . '\'] = "' . str_replace( '"', '\\"', $options['default'] ) . '";'; $phpCode .= "\n" . '$this->__default__templateVars[\'' . $data . '\'] = "' . str_replace( '"', '\\"', $options['default'] ) . '";'; } if ( $options['oncondition'] AND isset( $options['value'] ) ) { $phpCode .= "\nif ( {$options['oncondition']} )\n{\n\t".'$this->templateVars[\'' . $data . '\'] = "' . str_replace( '"', '\\"', $options['value'] ) . '";' . "\n}"; $phpCode .= "\nelse {" . '$this->templateVars[\'' . $data . '\'] = $this->__default__templateVars[\'' . $data . '\']; }'; } //----------------------------------------- // Process the tag and return the data //----------------------------------------- return ( $phpCode ) ? "" . $phpCode . "" : ''; } /** * Return information about this modifier * * It MUST contain an array of available options in 'options'. If there are no allowed options, then use an empty array. * Failure to keep this up to date will most likely break your template tag. * * @access public * @author Matt Mecham * @return array */ public function getPluginInfo() { return array( 'name' => 'variable', 'author' => 'IPS, Inc.', 'usage' => '{parse variable="testKey" default="foo" oncondition="$data == \'new\'" value="bar"}', 'options' => array( 'default', 'oncondition', 'value' ) ); } }