Created
February 14, 2010 22:07
-
-
Save mheadd/304297 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Contents of vxml.php | |
*/ | |
abstract class :xhp:vxml-element extends :x:primitive { | |
protected | |
$tagName; | |
protected final function renderBaseAttrs() { | |
$buf = '<'.$this->tagName; | |
foreach ($this->getAttributes() as $key => $val) { | |
if ($val !== null && $val !== false) { | |
$buf .= ' ' . htmlspecialchars($key) . '="' . htmlspecialchars($val, true) . '"'; | |
} | |
} | |
return $buf; | |
} | |
public function addClass($class) { | |
$class = trim($class); | |
$currentClasses = $this->getAttribute('class'); | |
$has = strpos(' '.$currentClasses.' ', ' '.$class.' ') !== false; | |
if ($has) { | |
return $this; | |
} | |
$this->setAttribute('class', trim($currentClasses.' '.$class)); | |
return $this; | |
} | |
protected function stringify() { | |
$buf = $this->renderBaseAttrs() . '>'; | |
foreach ($this->getChildren() as $child) { | |
$buf .= :x:base::renderChild($child); | |
} | |
$buf .= '</'.$this->tagName.'>'; | |
return $buf; | |
} | |
} | |
abstract class :xhp:vxml-singleton extends :xhp:vxml-element { | |
children empty; | |
protected function stringify() { | |
return $this->renderBaseAttrs() . ' />'; | |
} | |
} | |
class :block extends :xhp:vxml-element { | |
attribute | |
enum {"true", "false"} cond, string name; | |
children (:log, :prompt*); | |
protected $tagName = 'block'; | |
} | |
class :prompt extends :xhp:vxml-element { | |
children (pcdata | %phrase)*; | |
protected $tagName = 'prompt'; | |
} | |
class :log extends :xhp:vxml-element { | |
children (pcdata | %phrase)*; | |
protected $tagName = 'log'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment