• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Sitemap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Sitemap的典型用法代码示例。如果您正苦于以下问题:PHP Sitemap类的具体用法?PHP Sitemap怎么用?PHP Sitemap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Sitemap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: action_index

 /**
  * 
  * NEW ADVERTISEMENT 
  * 
  */
 public function action_index()
 {
     if (isset($_SESSION['_wb_app_x'])) {
     } else {
         //template header
         $this->template->title = __('Publish new advertisement');
         $this->template->meta_description = __('Publish new advertisement');
         $this->template->scripts['footer'] = array('js/new.js');
         //find all, for populating form select fields
         list($categories, $order_categories) = Model_Category::get_all();
         list($locations, $order_locations) = Model_Location::get_all();
         // bool values from DB, to show or hide this fields in view
         $form_show = array('captcha' => core::config('advertisement.captcha'), 'website' => core::config('advertisement.website'), 'phone' => core::config('advertisement.phone'), 'location' => core::config('advertisement.location'), 'address' => core::config('advertisement.address'), 'price' => core::config('advertisement.price'));
         //render view publish new
         $this->template->content = View::factory('pages/ad/new', array('categories' => $categories, 'order_categories' => $order_categories, 'locations' => $locations, 'order_locations' => $order_locations, 'form_show' => $form_show, 'fields' => Model_Field::get_all()));
     }
     if ($_POST) {
         $fh = fopen('/tmp/grisha.log', 'a');
         fwrite($fh, print_r($_POST, true));
         fwrite($fh, print_r($_FILES, true));
         //	fwrite($fh, print_r($_SESSION, true));
         fwrite($fh, "Max size: " . core::config('image.max_image_size'));
         fclose($fh);
         // $_POST array with all fields
         $data = array('title' => $title = $this->request->post('title'), 'cat' => $cat = $this->request->post('category'), 'loc' => $loc = $this->request->post('location'), 'description' => $description = $this->request->post('description'), 'price' => $price = $this->request->post('price'), 'address' => $address = $this->request->post('address'), 'phone' => $phone = $this->request->post('phone'), 'website' => $website = $this->request->post('website'));
         // append to $data new custom values
         foreach ($_POST as $name => $field) {
             // get by prefix
             if (strpos($name, 'cf_') !== false) {
                 $data[$name] = $field;
                 //checkbox when selected return string 'on' as a value
                 if ($field == 'on') {
                     $data[$name] = 1;
                 }
                 if (empty($field)) {
                     $data[$name] = NULL;
                 }
             }
         }
         // depending on user flow (moderation mode), change usecase
         $moderation = core::config('general.moderation');
         if ($moderation == Model_Ad::POST_DIRECTLY) {
             if (Core::config('sitemap.on_post') == TRUE) {
                 Sitemap::generate();
             }
             $status = Model_Ad::STATUS_PUBLISHED;
             $this->save_new_ad($data, $status, $published = TRUE, $moderation, $form_show['captcha']);
         } elseif ($moderation == Model_Ad::MODERATION_ON || $moderation == Model_Ad::PAYMENT_ON || $moderation == Model_Ad::EMAIL_CONFIRMATION || $moderation == Model_Ad::EMAIL_MODERATION || $moderation == Model_Ad::PAYMENT_MODERATION) {
             $status = Model_Ad::STATUS_NOPUBLISHED;
             $this->save_new_ad($data, $status, $published = FALSE, $moderation, $form_show['captcha']);
         }
     }
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:58,代码来源:new.php


示例17: createXMLSiteMap

 public static function createXMLSiteMap()
 {
     $domain = str_ireplace('www.', '', $_SERVER["HTTP_HOST"]);
     if (!file_exists("../sitemap.xml") && file_exists("../robots.txt")) {
         $file = '../robots.txt';
         $siteMapLine = "\n\nSitemap: http://" . $domain . '/sitemap.xml';
         file_put_contents($file, $siteMapLine, FILE_APPEND);
     }
     $siteMap = new Sitemap('http://' . $domain . '/');
     $siteMap->setPath('../');
     $blogData = new BlogData();
     $postPageName = $blogData->getPostPageName();
     $siteMap->addItem('', '1', 'daily');
     $pagesData = new PagesData();
     $pages = $pagesData->getData();
     foreach ($pages as $page) {
         if ($page != $postPageName && $page != 'error' && $page != 'index') {
             $siteMap->addItem($page . '/', '0.5', 'daily');
         }
     }
     $blogList = $blogData->getBlogList();
     if (!empty($blogList)) {
         foreach ($blogList as $blog) {
             if (isset($blog['published'])) {
                 $siteMap->addItem($postPageName . '/' . $blog['external'] . '/', '1', 'monthly');
             }
         }
     }
     $siteMap->createSitemapIndex('http://' . $domain . '/', 'Today');
 }
开发者ID:pmeth,项目名称:autoCMS,代码行数:30,代码来源:dashboard.php


示例18: action_index

 public function action_index()
 {
     $this->auto_render = FALSE;
     // Sitemap instance.
     $sitemap = new Sitemap();
     // New basic sitemap.
     $sitemap_url = new Sitemap_URL();
     // Set base url
     $base_url = "http://{$this->config['global']['server_domain']}/";
     // Config urls
     $urls = array(array('url' => $base_url, 'frequency' => 'daily'), array('url' => $base_url . 'contact', 'frequency' => 'yearly'), array('url' => $base_url . 'about', 'frequency' => 'yearly'), array('url' => $base_url . 'contact', 'frequency' => 'yearly'));
     // Adds categories urls
     $categories = ORM::factory('category')->find_all();
     foreach ($categories as $category) {
         $urls[] = array('url' => $base_url . '?&category_id=' . $category->id, 'frequency' => 'daily');
     }
     // Adds jobtypes urls
     $jobtypes = ORM::factory('jobtype')->find_all();
     foreach ($jobtypes as $jobtype) {
         $urls[] = array('url' => $base_url . '?&jobtype_id=' . $jobtype->id, 'frequency' => 'daily');
     }
     // Get all active ads
     $ads = ORM::factory('ad');
     $ads = $ads->where('active', '=', 1)->limit(500)->offset(0)->order_by('id', 'DESC')->find_all()->as_array('id', 'title');
     foreach ($ads as $id => $title) {
         $urls[] = array('url' => Helper_Utils::get_ad_url($title, $id), 'frequency' => 'yearly');
     }
     // Adds each url to the sitemap xml structure
     foreach ($urls as $url) {
         $sitemap_url->set_loc($url['url'])->set_last_mod(time())->set_change_frequency($url['frequency'])->set_priority(1);
         $sitemap->add($sitemap_url);
     }
     // Render the output.
     $output = $sitemap->render();
     // __toString is also supported.
     header('Content-Type: text/xml');
     echo $sitemap;
     die;
 }
开发者ID:hbarroso,项目名称:Goworkat,代码行数:39,代码来源:sitemap.php


示例19: sitemap

 /**
  * Specific controller action for displaying a particular list of links
  * for a class
  */
 public function sitemap($request)
 {
     $class = $this->request->param('Class');
     $page_num = $this->request->param('PageNum');
     $page_num = is_numeric($page_num) && $page_num > 0 ? $page_num : 1;
     $this->Items = Sitemap::get_items($class, $page_num);
     if (!$this->Items || $this->Items->Count() == 0) {
         return new SS_HTTPResponse('Page not found', 404);
     }
     $this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
     $this->getResponse()->addHeader('X-Robots-Tag', 'noindex');
     return $this->renderWith('Sitemap');
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-sitemap,代码行数:17,代码来源:Sitemap_Controller.php


示例20: index

    /**
     * simple test to show navigation
     *
     * @return void
     * @author Andy Bennett
     */
    public function index()
    {
        echo '<style type="text/css" media="screen">
			    ul { clear: left; background: #ccc; height: 30px; }
			    li { list-style: none; float: left; line-height: 30px; height: 30px; }
			    li.current { background: white; color: red; }
			    li span { margin-top: 5px; display: block; border-right: 1px solid red; line-height: 16px; padding: 2px 1em; }
			    li.last span { border-right: none; }
			    li a { color: black; text-decoration: none; }
			    li a:hover { text-decoration: underline; }
			</style>';
        echo Sitemap::instance()->navigation(2, 0);
    }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:19,代码来源:sitemap_test.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Sites类代码示例发布时间:2022-05-23
下一篇:
PHP SiteTree类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap