Allow Smarty to Call Static Methods
I don't quite understand why they don't allow static methods -- it seems like static methods would be a more obvious choice to allow than to disallow in a templating system. Add this to your object that extends the main Smarty object enable.See the original forum post for more on this:
function _parse_attrs( $tag_args )
{
$attrs = parent::_parse_attrs( $tag_args );
foreach( $attrs as $key=>$value )
{
// perhaps this was intended as a static callback?
if( preg_match( '#^["\']([a-zA-Z_]\w*::[a-zA-Z_]\w*)\((.*)?\)["\']$#', $value, $matches ) )
{
$arguments = '()';
if( isset( $matches[2] ) )
{
// strip '".' and '."' from beginning and end
$arguments = substr( $matches[2], 2, -2 );
// remove '.",".' from between parameters
$arguments = explode( '.",".', $arguments );
// combine arguments into string
$arguments = '('.implode( ',', $arguments ).')';
}
$attrs[$key] = $matches[1].$arguments;
}
}
return $attrs;
}
PHP Headers for IE Over SSL
To get a file to download properly in Internet Explorer, you gotta send the right headers. It took a little digging around to find:
header("Pragma: private");
header("Cache-control: private, must-revalidate");
header("Content-Type: your/application-type'");
ActionScript2.0
A Connection object. [ Get file ]
// Free to use. Just include my name and website somewhere.
// Copyright, 2005 Andrew Ettinger. http://frugalprogrammer.com
var CONNECTED = 1;
var NOT_CONNECTED = 0;
// generic socket connection class
class Connection
{
public port:Number;
public host:String;
public socket;
public state;
// create a new connection
// if host and port, then it will auto connect.
public function Connection(host, port) {
this.socket = new XMLSocket();
this.host = host;
this.port = port;
if (host != undefined && port != undefined)
{
this.connect();
}
}
// connect to the host and port
public function connect():Void
{
this.socket.connect(this.host, this.port);
this.socket.onConnect = this.setConnectionState;
this.socket.onXML = this.receive;
this.socket.onClose = this.closeConnection;
}
// close down the connection;
public function closeConnection():Void
{
this.socket = null;
this.setConnectionState(false);
}
// set whether or not we are connected
public function setConnectionState(gotConnection):Void
{
if (gotConnection)
this.state = CONNECTED;
else
this.state = NOT_CONNECTED;
}
// receive some xml from the server
public function receive( input ):XML
{
return input;
}
// send a string as xml to the server
public function send( output ):Void
{
this.socket.send( new XML(output) );
}
} // end connection