当前位置: 首页>>代码示例>>PHP>>正文


PHP Sitemap类代码示例

本文整理汇总了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));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:8,代码来源:SitemapAction.php

示例2: addSitemap

 function addSitemap(Sitemap $sitemap, $lastmod = null)
 {
     $url = array('loc' => $sitemap->getSitemapUrl());
     if ($lastmod) {
         $url['lastmod'] = $lastmod;
     }
     $this->addUrl($url);
 }
开发者ID:vasiatka,项目名称:sitemap,代码行数:8,代码来源:SitemapIndex.class.php

示例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;
 }
开发者ID:cfrancois7,项目名称:site.ontowiki,代码行数:10,代码来源:Index.php

示例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());
 }
开发者ID:awallef,项目名称:trois,代码行数:12,代码来源:SitemapController.php

示例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;
 }
开发者ID:pristavu,项目名称:SitemapGenerator,代码行数:14,代码来源:SitemapGenerator.php

示例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);
 }
开发者ID:hkilter,项目名称:OpenSupplyChains,代码行数:49,代码来源:sitemap.php

示例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']);
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:19,代码来源:GeoTest.php

示例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('./');
     }
 }
开发者ID:gudwin,项目名称:extasy,代码行数:29,代码来源:order.php

示例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;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:13,代码来源:Sitemap.php

示例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);
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:33,代码来源:sitemap.plugin.php

示例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=/');
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:11,代码来源:SitemapTest.php

示例12: actionIndex

 public function actionIndex()
 {
     if (!$this->isXml) {
         Sitemap::publishAssets();
     }
     $map = $this->generateMap($this->isXml);
     $this->render('index', array('map' => $map));
 }
开发者ID:barricade86,项目名称:raui,代码行数:8,代码来源:MainController.php

示例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;
 }
开发者ID:indiwine,项目名称:EMA-engine,代码行数:17,代码来源:SitemapConnector.php

示例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;
 }
开发者ID:sleepymustache,项目名称:routed,代码行数:14,代码来源:class.sitemap.php

示例15: sitemap

 public function sitemap()
 {
     if ($_POST) {
         Sitemap::save();
         $this->redirect('/tools/sitemap/');
     } else {
         View::render('tools/sitemap/list', array('list' => Sitemap::getList()));
     }
 }
开发者ID:sov-20-07,项目名称:billing,代码行数:9,代码来源:ToolsController.php


注:本文中的Sitemap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。