function Websites_before_Streams_Stream_save_Websites_seo($params) { $stream = $params['stream']; if (!$stream->wasModified('attributes')) { return; } $uri = $stream->getAttribute('uri', null); if (!$uri) { return; } $url = $stream->getAttribute('url', null); if (preg_match('/\\s/', $url)) { throw new Q_Exception_WrongValue(array('field' => 'url', 'range' => "no spaces")); } $wp = new Websites_Permalink(); $wp->uri = $uri; $wp->retrieve('*', array('ignoreCache' => true)); if ($url = $stream->getAttribute('url', null)) { $url = Q_Html::themedUrl($url); if (!isset($wp->url) or $wp->url !== $url) { $wp->url = $url; $wp->save(); } } else { $wp->remove(); } }
function Websites_before_Q_url($params, &$result) { $wp = new Websites_Permalink(); $wp->uri = (string) $params['source']; if ($wp->retrieve()) { $result = $wp->url; } }
function Websites_before_Q_uriFromUrl($params, &$result) { $wp = new Websites_Permalink(); $wp->url = $params['url']; if ($wp->retrieve()) { $result = Q_Uri::from($wp->uri); } }
function Websites_before_Q_uriFromUrl($params, &$result) { if (!Q::$bootstrapped) { return; // we probably haven't even loaded the database configuration yet. } $wp = new Websites_Permalink(); $wp->url = $params['url']; if ($wp->retrieve()) { $result = Q_Uri::from($wp->uri); } }