本文整理汇总了PHP中Sitemap类的典型用法代码示例。如果您正苦于以下问题:PHP Sitemap类的具体用法?PHP Sitemap怎么用?PHP Sitemap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sitemap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$this->controller->layout = false;
//rss创建
$obj = new Sitemap();
$rss = $obj->show();
$this->controller->render('sitemap', array('rss' => $rss));
}
示例2: addSitemap
function addSitemap(Sitemap $sitemap, $lastmod = null)
{
$url = array('loc' => $sitemap->getSitemapUrl());
if ($lastmod) {
$url['lastmod'] = $lastmod;
}
$this->addUrl($url);
}
示例3: addSitemap
public function addSitemap(Sitemap $sitemap)
{
if (!$sitemap->getUrl()) {
throw new Exception('Sitemaps needs to have an URL to be indexable');
}
if ($this->maxUrls && count($sitemap) > $this->maxUrls) {
throw new OutOfBoundsException('Sitemap has more than ' . $this->maxUrls . ' URLs and needs to be spitted');
}
$this->sitemaps[] = $sitemap;
}
示例4: index
public function index()
{
// load sitemap.php
if (file_exists(APP . DS . 'Config' . DS . 'Sitemap.php')) {
App::import('Config', 'Sitemap');
} else {
App::import('Trois.Config', 'Sitemap');
}
$sitemap = new Sitemap($this->request, $this->response);
$sitemap->constructClasses();
$this->set('data', $sitemap->get_sitemap_array());
}
示例5: addMap
public function addMap($iterable, \Closure $step, $name)
{
$sitemap = new Sitemap($iterable, $step);
$sitemap->setHost($this->host);
if ($this->limit > 0) {
$url = dirname($this->url . '/' . $name);
$file = explode(".", basename($name));
$ext = array_pop($file);
$url = $url . '/' . implode(".", $file) . '-%d.' . $ext;
$sitemap->multipleFiles($url, $this->limit);
}
$sitemap->generate($this->dir . '/' . $name);
return $this;
}
示例6: action_index
public function action_index()
{
$cache_key = 'sourcemap-sitemap';
$ttl = 60 * 60 * 24;
if ($cached = Cache::instance()->get($cache_key)) {
$xml = $cached;
} else {
// Sitemap instance.
$sitemap = new Sitemap();
// basics
$urls = array('home' => array('', 0.9, 'daily', time()), 'register' => array('register/', 0.6, 'yearly'), 'browse' => array('browse/', 0.7, 'daily', time()), 'login' => array('auth/login', 0.5, 'yearly'), 'about' => array('info/', 0.7, 'monthly'), 'api' => array('info/api', 0.7, 'monthly'), 'contact' => array('info/contact', 0.8, 'monthly'));
// categories
$cats = Sourcemap_Taxonomy::arr();
$nms = array();
foreach ($cats as $i => $cat) {
$slug = Sourcemap_Taxonomy::slugify($cat->name);
$urls['browse-' . $cat->name] = array('browse/' . $slug . '/', 0.7);
}
// public maps
$o = 0;
$l = 100;
while (($results = Sourcemap_Search::find(array('o' => $o, 'l' => $l))) && $results->hits_ret) {
foreach ($results->results as $i => $r) {
$urls['sc-' . $r->id] = array('view/' . $r->id, 0.5, 'daily', $r->modified);
}
$o += $l;
}
$defaults = array(false, 0.5, 'daily', false);
foreach ($urls as $k => $urld) {
foreach ($defaults as $i => $d) {
if (!isset($urld[$i])) {
$urld[$i] = $d;
}
}
list($loc, $priority, $freq, $lastmod) = $urld;
$new_url = new Sitemap_URL();
$new_url->set_loc(URL::site($loc, true))->set_priority($priority)->set_change_frequency($freq);
if ($lastmod) {
$new_url->set_last_mod($lastmod);
}
$sitemap->add($new_url);
}
$xml = $sitemap->render();
Cache::instance()->set($cache_key, $xml, $ttl);
}
header('Content-Type: application/xml');
$this->response = $xml;
die($this->response);
}
示例7: test_root
/**
* @test
* @group sitemap
*/
public function test_root()
{
// Base Sitemap
$sitemap = new Sitemap();
// Create basic Mobile Sitemap
$instance = new Sitemap_URL(new Sitemap_Geo());
$instance->set_loc('http://google.com');
$sitemap->add($instance);
// Load the end XML
$xml = new SimpleXMLElement($sitemap->render());
// Namespaces.
$namespaces = $xml->getDocNamespaces();
$this->assertSame(TRUE, isset($namespaces['geo']));
$this->assertSame('http://www.google.com/geo/schemas/sitemap/1.0', $namespaces['geo']);
}
示例8: show
public function show($id)
{
// Получаем ряд
$id = intval($id);
$this->nId = $id;
try {
// Получаем детей
$aChild = Sitemap::selectChild($id);
if ($id != 0) {
$aRow = Sitemap_Sample::get($id);
} else {
$aRow = null;
}
/*$aData = array();
foreach ($aChild as $row)
{
$aData[] = $row['id'];
}*/
$aData = $aChild;
//
$this->formatDesign($aRow);
// Выводим форму сортировки
print UParser::parsePHPFile(LIB_PATH . 'sitemap/controller/tpl/order.tpl', array('szTitle' => $this->szTitle, 'aBegin' => $this->aBegin, 'id' => $id, 'back' => $this->back, 'aData' => $aData));
$this->output();
} catch (SiteMapException $e) {
$this->addError(_msg('Ряд не найден в бд'));
$this->jump('./');
}
}
示例9: instance
/**
* create an instance of Sitemap_Base using sitemap
*
* @return void
* @author Andy Bennett
*/
public static function instance()
{
if (self::$instance == NULL) {
self::$instance = Sitemap_Base::factory('sitemap');
}
return self::$instance;
}
示例10: create
/**
* Create sitemap
*/
public static function create()
{
// Get pages list
$pages_list = Pages::getPages();
// Create sitemap content
$map = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
foreach ($pages_list as $page) {
if ($page['parent'] != '') {
$parent = $page['parent'] . '/';
$priority = '0.5';
} else {
$parent = '';
$priority = '1.0';
}
$map .= "\t" . '<url>' . "\n\t\t" . '<loc>' . Option::get('siteurl') . '/' . $parent . $page['slug'] . '</loc>' . "\n\t\t" . '<lastmod>' . date("Y-m-d", (int) $page['date']) . '</lastmod>' . "\n\t\t" . '<changefreq>weekly</changefreq>' . "\n\t\t" . '<priority>' . $priority . '</priority>' . "\n\t" . '</url>' . "\n";
}
// Get list of components
$components = Sitemap::getComponents();
// Add components to sitemap
if (count($components) > 0) {
foreach ($components as $component) {
$map .= "\t" . '<url>' . "\n\t\t" . '<loc>' . Option::get('siteurl') . '/' . Text::lowercase($component) . '</loc>' . "\n\t\t" . '<lastmod>' . date("Y-m-d", time()) . '</lastmod>' . "\n\t\t" . '<changefreq>weekly</changefreq>' . "\n\t\t" . '<priority>1.0</priority>' . "\n\t" . '</url>' . "\n";
}
}
// Close sitemap
$map .= '</urlset>';
// Save sitemap
return File::setContent(ROOT . DS . 'sitemap.xml', $map);
}
示例11: testGzip
/**
* @covers Sitemap::gzip
*/
public function testGzip()
{
$result = $this->object->gzip();
// Check return value
$this->assertEquals(NULL, $result);
// Check valid returnd value
$this->expectOutputRegex('/<urlset xmlns=/');
}
示例12: actionIndex
public function actionIndex()
{
if (!$this->isXml) {
Sitemap::publishAssets();
}
$map = $this->generateMap($this->isXml);
$this->render('index', array('map' => $map));
}
示例13: generate
public static function generate()
{
//@TODO: Implemet your own logic here
$path = $_SERVER['DOCUMENT_ROOT'];
$xmlDateFormat = "Y-m-d";
$changeFreq = "weekly";
$timeZoneInst = new DateTimeZone(CURRENT_TIMEZONE);
$dateTime = new DateTime("now", $timeZoneInst);
$sitemapGenInst = new Sitemap("http://" . $_SERVER['SERVER_NAME']);
$sitemapGenInst->setPath($path . "/");
$dateTime->setTimestamp(time());
$sitemapGenInst->addItem('/', 1.0, $changeFreq, $dateTime->format($xmlDateFormat));
$dateTime->setTimestamp(time());
$sitemapGenInst->addItem('/contacts', 0.5, $changeFreq, $dateTime->format($xmlDateFormat));
$sitemapGenInst->createSitemapIndex("http://" . $_SERVER['SERVER_NAME'] . "/");
return true;
}
示例14: _getPage
/**
* Gets a page and children based on it's ID
* @param string $id The page ID
* @return object A JSON tree
*/
private static function _getPage($id)
{
self::$_result = null;
self::_getPageHelper(self::$_data->pages, $id);
if (!isset(self::$_result)) {
throw new \Exception('Sitemap: Page not found.');
}
return self::$_result;
}
示例15: sitemap
public function sitemap()
{
if ($_POST) {
Sitemap::save();
$this->redirect('/tools/sitemap/');
} else {
View::render('tools/sitemap/list', array('list' => Sitemap::getList()));
}
}