public function process(\Pagemill_Tag $tag, \Pagemill_Data $data, \Pagemill_Stream $stream) { //if ($this->_method == 'post') { // TODO: Add the postlink stuff $tag->setAttribute('rel', $tag->getAttribute('rel') ? $tag->getAttribute('rel') . ' ' . $this->_method : $this->_method); //} }
public function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { if ($this->getAttribute('name') == 'keywords') { $name = 'keywords'; } else { if ($this->getAttribute('name') == 'description') { $name = 'description'; } else { parent::output($data, $stream); return; } } $urlmeta = Model_UrlMeta::GetUrl(null, false); if (!$urlmeta->exists()) { parent::output($data, $stream); return; } $seo = Model_SeoHead::Get($urlmeta['id']); if (!$seo->exists()) { parent::output($data, $stream); return; } if (!$seo['meta' . $name]) { parent::output($data, $stream); return; } $meta = new Pagemill_Tag('meta', $this->attributes, null, $this->doctype()); $meta->setAttribute('content', $seo['meta' . $name]); $meta->output($data, $stream); }
public function process(\Pagemill_Tag $tag, \Pagemill_Data $data, \Pagemill_Stream $stream) { $pmBody = Typeframe_TagPreprocessor_Export::Export('body'); if ($pmBody) { foreach ($pmBody[0]->attributes() as $key => $value) { $tag->setAttribute($key, $value); } } }
public function process(\Pagemill_Tag $tag, \Pagemill_Data $data, \Pagemill_Stream $stream) { $stream = new Pagemill_Stream(true); $this->_attributeTag->outputForAttribute($data, $stream); $value = $stream->peek(); if ($value !== '') { $tag->setAttribute($this->_attributeTag->getAttribute('name'), $value); } }
public function process(Pagemill_Tag $tag, Pagemill_Data $data, Pagemill_Stream $stream) { if ($tag->hasAttribute('value')) { $checked = $data->parseVariables($this->_checkvalue); $value = $data->parseVariables($tag->getAttribute('value')); if ($checked == $value) { $tag->setAttribute('checked', 'checked'); } else { $tag->removeAttribute('checked'); } } }
private function _findEmptyPluginTags(Pagemill_Tag $parent, $found = array()) { foreach ($parent->children() as $child) { if (is_a($child, 'Pagemill_Tag_Plugin')) { if (!count($child->attributes())) { $found[] = $child; } $found = $this->_findPlugin($child, $found); } } return $found; }
private function _attachToOptions(Pagemill_Tag $parent, Pagemill_TagPreprocessor_SelectValue $selectvalue) { foreach ($parent->children() as $child) { if (is_a($child, 'Pagemill_Tag')) { if ($child->name() == 'option') { $child->attachPreprocess($selectvalue); } else { if ($child->children()) { $this->_attachToOptions($child, $selectvalue); } } } } }
public function __construct($name, array $attributes = array(), \Pagemill_Tag $parent = null, \Pagemill_Doctype $doctype = null) { parent::__construct($name, $attributes, $parent, $doctype); $this->name = 'img'; $ratio = $this->hasAttribute('ratio'); $this->attachPreprocess(new Typeframe_TagPreprocessor_Thumb($ratio)); }
public function __construct($name, array $attributes = array(), \Pagemill_Tag $parent = null, \Pagemill_Doctype $doctype = null) { parent::__construct($name, $attributes, $parent, $doctype); $this->name = 'input'; $this->attributes['type'] = 'checkbox'; $this->attachPreprocess(new Pagemill_TagPreprocessor_CheckValue($this->attributes['checked'])); }
public function __construct($name, array $attributes = array(), Pagemill_Tag $parent = null, Pagemill_Doctype $doctype = null) { parent::__construct($name, $attributes, $parent, $doctype); if (is_null($this->parent())) { throw new Exception('Attribute element requires a parent'); } $this->parent()->attachPreprocess(new Pagemill_TagPreprocessor_AttributeTag($this)); }
/** * Initialize the tag. * @param string $name The name of the tag (i.e., the XML element name). * @param array $attributes The tag/element attributes. */ public function __construct($name, array $attributes = array(), Pagemill_Tag $parent = null, Pagemill_Doctype $doctype = null) { //$this->attach(self::EVENT_BEFORE, new Pagemill_Tag_Event_AttributeHandler()); $this->_originalName = $name; $this->_originalAttributes = $attributes; $this->name = $name; $this->attributes = $attributes; if ($parent) { $parent->appendChild($this); } if (is_null($doctype)) { if (!is_null($parent)) { $this->_doctype = $parent->doctype(); } } else { $this->_doctype = $doctype; } }
public function __construct($name, array $attributes = array(), \Pagemill_Tag $parent = null, \Pagemill_Doctype $doctype = null) { parent::__construct($name, $attributes, $parent, $doctype); $this->name = 'a'; $this->setAttribute('data-confirm', $this->getAttribute('confirm')); $this->removeAttribute('confirm'); $this->attachPreprocess(new Typeframe_TagPreprocessor_Method('post')); //Typeframe_Tag_Scriptonce::Generate(TYPEF_WEB_DIR . '/files/static/jquery/jquery.js', 'text/javascript', $this); Typeframe_Tag_Scriptonce::Generate(TYPEF_WEB_DIR . '/files/static/jquery/jquery.linkmethod.js', 'text/javascript', $this); }
public function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { $name = $data->parseVariables($this->getAttribute('name')); if ($name) { $this->name = $name; parent::output($data, $stream); } else { foreach ($this->children() as $child) { $child->process($data, $stream); } } }
public function process(Pagemill_Tag $tag, Pagemill_Data $data, Pagemill_Stream $stream) { $result = $data->evaluate($this->_expression); if ($result) { $tmp = new Pagemill_Tag($tag->name(), $tag->attributes(), $tag->parent()); $tmp->appendText($result); if ($this->_replace) { $tmp->processInner($data, $stream); } else { $tmp->process($data, $stream); } $tmp->detach(); return false; } else { if ($this->_replace) { $tag->processInner($data, $stream); return false; } } return true; }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $select = $this->_getSelect(); if (get_class($select) == 'Pagemill_Tag_Select') { $selectedValue = $select->selectedValue(); $value = $data->parseVariables($this->getAttribute('value')); if ($selectedValue == $value) { $this->setAttribute('selected', 'selected'); } else { $this->removeAttribute('selected'); } } parent::output($data, $stream); }
public function process(Pagemill_Tag $tag, Pagemill_Data $data, Pagemill_Stream $stream) { $attributes = array(); $name = $this->_loopAttributes; $parts = explode(' ', $name, 2); $attributes['name'] = $parts[0]; if (isset($parts[1])) { $attributes['as'] = $parts[1]; } $loop = new Pagemill_Tag_Loop('loop', $attributes, null, $tag->doctype()); $temptag = new Pagemill_Tag($tag->name(), $tag->attributes(), null, $tag->doctype()); foreach ($tag->children() as $child) { $temptag->appendChild($child); } $loop->appendChild($temptag); $loop->process($data, $stream); foreach ($temptag->children() as $child) { $tag->appendChild($child); } return false; }
public function __construct($name, array $attributes = array(), \Pagemill_Tag $parent = null, \Pagemill_Doctype $doctype = null) { parent::__construct($name, $attributes, $parent, $doctype); $this->attachPreprocess(new Typeframe_TagPreprocessor_DebugInBody()); $this->attachPreprocess(new Typeframe_TagPreprocessor_BodyAttributes()); }
public function __construct($name, array $attributes = array(), Pagemill_Tag $parent = null, Pagemill_Doctype $doctype = null) { parent::__construct($name, $attributes, $parent, $doctype); $this->parent()->attachPreprocess(new Typeframe_TagPreprocessor_Export('body', $this)); }
public function process(Pagemill_Tag $tag, Pagemill_Data $data, Pagemill_Stream $stream) { $src = $data->parseVariables($tag->getAttribute('src')); $attr = 'src'; if (!$src) { $src = $data->parseVariables($tag->getAttribute('href')); $attr = 'href'; } $width = $data->parseVariables($tag->getAttribute('width')); $height = $data->parseVariables($tag->getAttribute('height')); // TODO: Is this good enough? $file = TYPEF_DIR . substr($src, strlen(TYPEF_WEB_DIR)); // TODO: Should this generate an error? if (!file_exists($file) || !is_file($file)) { return; } $ext = pathinfo($file, PATHINFO_EXTENSION); if (strtolower($ext) == 'bmp') { $ext = 'jpg'; } $md5 = md5("{$src}_{$width}_{$height}_{$this->_ratio}") . ".{$ext}"; if (file_exists(TYPEF_DIR . "/files/public/timg/{$md5}")) { if (filemtime($file) < filemtime(TYPEF_DIR . '/files/public/timg/' . $md5)) { $tag->setAttribute($attr, TYPEF_WEB_DIR . "/files/public/timg/{$md5}"); $size = getimagesize(TYPEF_DIR . "/files/public/timg/{$md5}"); $tag->setAttribute('width', $size[0]); $tag->setAttribute('height', $size[1]); return; } } // Resize image now if the file is below a particular // size. We'll try it with 900kb for now. if (filesize($file) < 900000) { Gdi::Thumbnail($file, TYPEF_DIR . '/files/public/timg/' . $md5, $width, $height, $this->_ratio); if (file_exists(TYPEF_DIR . '/files/public/timg/' . $md5)) { $tag->setAttribute($attr, TYPEF_WEB_DIR . "/files/public/timg/{$md5}"); } $tag->removeAttribute('width'); $tag->removeAttribute('height'); } else { // Schedule the resizing. $queue = new Model_TimgQueue(); $queue->where('src = ?', $file); $queue->where('dst = ?', TYPEF_DIR . "/files/public/timg/{$md5}"); if (!$queue->count()) { $timg = Model_TimgQueue::Create(); $timg['src'] = $file; $timg['dst'] = TYPEF_DIR . "/files/public/timg/{$md5}"; $timg['width'] = $width; $timg['height'] = $height; $timg['ratio'] = $this->_ratio; $timg->save(); } } }
public function __construct($name, array $attributes = array(), Pagemill_Tag $parent = null, Pagemill_Doctype $doctype = null) { parent::__construct($name, $attributes, $parent, $doctype); }
public function process(Pagemill_Tag $tag, Pagemill_Data $data, Pagemill_Stream $stream) { $tag->selectedValue($data->parseVariables($this->_selectedValue)); }
public function __clone() { parent::__clone(); $this->_lastIf = null; }
private function _xmlStartElement($parser, $name, $attributes) { $last = null; if (count($this->_tagStack)) { $last =& $this->_tagStack[count($this->_tagStack) - 1]; if ($this->_currentCharacterData) { $last->appendText($this->_currentCharacterData); $this->_currentCharacterData = ''; } } if ($last) { $currentDoctype = $last->doctype(); } else { $currentDoctype = $this->_doctype; } foreach ($attributes as $k => $v) { if ($k == 'xmlns' || substr($k, 0, 6) == 'xmlns:') { $doctype = Pagemill_Doctype::ForNamespaceUri($v, substr($k, 6)); $currentDoctype->merge($doctype); if (!$doctype->keepNamespaceDeclarationInOutput()) { unset($attributes[$k]); } } else { if (substr($k, 0, 3) == 'pm:' && !isset($this->_namespaces['pm'])) { // Declare the Template doctype using the default pm prefix $this->_namespaces['pm'] = 'http://typeframe.com/pagemill'; $pm = Pagemill_Doctype::GetTemplateDoctype('pm'); $currentDoctype->merge($pm); } } } if (substr($name, 0, 3) == 'pm:' && !isset($this->_namespaces['pm'])) { // Declare the Template doctype using the default pm prefix $this->_namespaces['pm'] = 'http://typeframe.com/pagemill'; $pm = Pagemill_Doctype::GetTemplateDoctype('pm'); $currentDoctype->merge($pm); } $tagRegistry = $currentDoctype->tagRegistry(); if (isset($tagRegistry[$name])) { $cls = $tagRegistry[$name]; $tag = new $cls($name, $attributes, $last, $currentDoctype); } else { $tag = new Pagemill_Tag($name, $attributes, $last, $currentDoctype); } if (!count($this->_tagStack)) { // This appears to be a root element, so append the headers. $header = trim("{$this->_xmlDeclString}\n{$this->_doctypeString}\n"); $tag->header($header); } $this->_tagStack[] = $tag; }