public function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { $this->_hasTitle = false; $this->_hasMetaDescription = false; $this->_hasMetaKeywords = false; $this->_recurseThroughChildren($this); if (!$this->_hasTitle) { new Typeframe_Tag_Seo_Title('title', array(), $this); } if (!$this->_hasMetaDescription) { new Typeframe_Tag_Seo_Meta('meta', array('name' => 'description'), $this); } if (!$this->_hasMetaKeywords) { new Typeframe_Tag_Seo_Meta('meta', array('name' => 'keywords'), $this); } $urlmeta = Model_UrlMeta::GetUrl(null, false); $tag = null; if ($urlmeta->exists()) { $seo = Model_SeoHead::Get($urlmeta['id']); if ($seo->exists()) { if ($seo['extra']) { $fragment = new Pagemill_Node_Frag($this->doctype()); $fragment->appendRawText($seo['extra']); $this->appendChild($fragment); } } } parent::output($data, $stream); // TODO: Do we need to detach the fragment? }
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 output(Pagemill_Data $data, Pagemill_Stream $stream) { if (self::$_loaded) { return ''; } self::$_loaded = true; if (defined('COMMENTS_DISABLED') && COMMENTS_DISABLED) { return ''; } $data = $data->fork(); $urlmeta = Model_UrlMeta::GetUrl(); if (!$urlmeta->exists()) { return ''; } $commeta = Model_Comment_Meta::Get($urlmeta['id']); if (!$commeta->exists()) { $commeta['urlmetaid'] = $urlmeta['id']; $commeta->save(); } else { if ($commeta['closed']) { $pm->setVariable('comments_closed', true); } } $data->set('meta', $commeta); $comments = new Model_Comment(); $comments->where('urlmetaid = ?', $urlmeta['id']); if (defined('COMMENTS_REQUIRE_APPROVAL') && 1 == COMMENTS_REQUIRE_APPROVAL) { $comments->where('approved = 1'); } $comments->order('datecreated ASC'); $data->set('comments', $comments); $data->set('comments_require_captcha', COMMENTS_REQUIRE_CAPTCHA); parent::output($data, $stream); }
protected function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { $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['title']) { parent::output($data, $stream); return; } $title = new Pagemill_Tag_AlwaysExpand('title', $this->attributes(), null, $this->doctype()); $title->appendText($seo['title']); $title->output($data, $stream); }
<?php function _DownloadToBuffer($url) { // TODO: Throw exceptions for invalid requests $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $buffer = curl_exec($curl); curl_close($curl); return $buffer; } $pages = new Model_Page(); foreach ($pages as $page) { $uri = TYPEF_WEB_DIR . $page['uri']; Model_UrlMeta::GetUrl($uri); $buffer = _DownloadToBuffer("http://{$_SERVER['HTTP_HOST']}{$uri}"); $xml = Pagemill_SimpleXmlElement::LoadString($buffer); $links = $xml->select('a'); foreach ($links as $link) { $uri = (string) $link['href']; if (substr($uri, 0, strlen(TYPEF_WEB_DIR)) == TYPEF_WEB_DIR) { Model_UrlMeta::GetUrl($uri); } } }
<?php if ($_REQUEST['url']) { $parts = parse_url($_REQUEST['url']); $urlmeta = Model_UrlMeta::GetUrl($parts['path']); if (!$urlmeta->exists()) { Typeframe::Redirect('Invalid page specified: ' . $_REQUEST['url'], Typeframe::CurrentPage()->applicationUri(), -1); return; } $head = Model_SeoHead::Get($urlmeta['id']); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $head['title'] = $_POST['title']; $head['metakeywords'] = $_POST['metakeywords']; $head['metadescription'] = $_POST['metadescription']; $head['extra'] = $_POST['extra']; $head->save(); Typeframe::Redirect('Title and meta content updated.', Typeframe::CurrentPage()->applicationUri()); return; } $pm->setVariable('urlmeta_path', $parts['path']); $pm->setVariable('seo', $head); } else { Typeframe::Redirect('No page specified.', Typeframe::CurrentPage()->applicationUri(), -1); }
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $urlmeta = Model_UrlMeta::GetUrl($_REQUEST['url']); $head = Model_SeoHead::Get($urlmeta['id']); $head->delete(); Typeframe::Redirect('SEO content reset.', Typeframe::CurrentPage()->applicationUri()); } else { Typeframe::Redirect('Nothing to do.', Typeframe::CurrentPage()->applicationUri()); }