public function testMetaFieldFirstEqual() { $items = $this->_getItemsArray(); foreach ($items as $item) { $meta = lmbCmsSeo::getMetaForUrl(new lmbUri($item['url'] . '/test/test')); $this->assertEqual($meta->get('title'), $item['title']); $this->assertEqual($meta->get('keywords'), $item['keywords']); $this->assertEqual($meta->get('description'), $item['description']); } }
protected static function _getMetadataForUrl($uri = null) { if (!$uri) { $uri = lmbToolkit::instance()->getRequest()->getUri(); } $count_path = $uri->countPath(); $meta = null; $sql = 'SELECT keywords, description, title FROM lmb_cms_seo WHERE url = \'/\' OR '; for ($i = 1; $i < $count_path; $i++) { $sql .= ' url = \'' . self::getDefaultConnection()->escape($uri->getPathToLevel($i)) . '\'' . ($i < $count_path - 1 ? ' OR ' : ''); } $sql .= ' ORDER BY url DESC LIMIT 1'; $meta = lmbDBAL::fetchOneRow($sql); if (!empty($meta)) { self::$_meta = $meta; } else { self::$_meta = new lmbObject(array('title' => '', 'description' => '', 'keywords' => '')); } }