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


PHP Sitemap::date_format方法代码示例

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


在下文中一共展示了Sitemap::date_format方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_index

 public function action_index()
 {
     if (!file_exists(DOCROOT . $this->sitemap_directory_base)) {
         throw new HTTP_Exception_404();
     }
     $this->site_code = ORM::factory('site', $this->request->site_id)->code;
     $this->sitemap_directory = $this->sitemap_directory_base . DIRECTORY_SEPARATOR . $this->site_code;
     $this->response->headers('Content-Type', 'text/xml')->headers('cache-control', 'max-age=0, must-revalidate, public')->headers('expires', gmdate('D, d M Y H:i:s', time()) . ' GMT');
     try {
         $dir = new DirectoryIterator(DOCROOT . $this->sitemap_directory);
         $xml = new DOMDocument('1.0', Kohana::$charset);
         $xml->formatOutput = TRUE;
         $root = $xml->createElement('sitemapindex');
         $root->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
         $xml->appendChild($root);
         foreach ($dir as $fileinfo) {
             if ($fileinfo->isDot() or $fileinfo->isDir()) {
                 continue;
             }
             $_file_path = str_replace(DOCROOT, '', $fileinfo->getPathName());
             $_file_url = $this->domain . '/' . str_replace(DIRECTORY_SEPARATOR, '/', $_file_path);
             $sitemap = $xml->createElement('sitemap');
             $root->appendChild($sitemap);
             $sitemap->appendChild(new DOMElement('loc', $_file_url));
             $_last_mod = Sitemap::date_format($fileinfo->getCTime());
             $sitemap->appendChild(new DOMElement('lastmod', $_last_mod));
         }
     } catch (Exception $e) {
         echo Debug::vars($e->getMessage());
         die;
     }
     echo $xml->saveXML();
 }
开发者ID:greor,项目名称:satin-spb,代码行数:33,代码来源:sitemap.php

示例2: test_date_format

 /**
  * @test
  * @group sitemap
  * @dataProvider provider_date_format
  */
 public function test_date_format($date, $expected)
 {
     if (!$expected) {
         try {
             Sitemap::date_format($date);
         } catch (InvalidArgumentException $e) {
             return;
         }
         $this->fail('The InvalidArgumentException was not raised');
     }
     $return = Sitemap::date_format($date);
     $this->assertSame($expected, $return);
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:18,代码来源:DataTest.php

示例3: set_last_mod

 /**
  * The date of last modification of the file.
  * @param integer $lastmod Unix timestamp
  */
 public function set_last_mod($lastmod)
 {
     $this->attributes['lastmod'] = Sitemap::date_format($lastmod);
     return $this;
 }
开发者ID:hkilter,项目名称:OpenSupplyChains,代码行数:9,代码来源:url.php

示例4: test_create

 /**
  * @test
  * @group sitemap
  * @dataProvider provider_create
  * @covers Sitemap_News::create
  * @param <type> $pub
  * @param <type> $lang
  * @param <type> $access
  * @param <type> $genre
  * @param <type> $date
  * @param <type> $title
  * @param <type> $tags
  */
 public function test_create($pub, $lang, $access, $genre, $date, $title, $tags)
 {
     $instance = new Sitemap_News();
     $instance->set_publication($pub)->set_lang($lang)->set_access($access)->set_genres($genre)->set_publication_date($date)->set_title($title)->set_keywords($tags);
     $return = $instance->create();
     $xml = simplexml_import_dom($return);
     $this->assertEquals($pub, (string) $xml->{'news:publication'}->{'news:name'});
     $this->assertEquals($lang, (string) $xml->{'news:publication'}->{'news:lang'});
     $this->assertEquals($access, (string) $xml->{'news:access'});
     $this->assertEquals(implode(',', $genre), (string) $xml->{'news:genres'});
     $this->assertEquals(Sitemap::date_format($date), (string) $xml->{'news:publication_date'});
     $this->assertEquals($title, (string) $xml->{'news:title'});
     $this->assertEquals(implode(',', $tags), (string) $xml->{'news:keywords'});
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:27,代码来源:NewsTest.php

示例5: test_create

 /**
  * @test
  * @group sitemap
  * @dataProvider provider_create
  * @param string $location
  * @param integer $lastmod
  * @param string $change_frequency
  * @param integer|float $priority
  */
 public function test_create($location, $lastmod, $change_frequency, $priority)
 {
     $instance = new Sitemap_URL();
     $instance->set_loc($location)->set_last_mod($lastmod)->set_change_frequency($change_frequency)->set_priority($priority);
     $return = $instance->create();
     // This solution allows me to see failure results displayed in the
     // CLI runner. Using assertTag or assertSelectEquals only gives me a boolean
     // value back and makes it very hard to track down errors.
     $xml = simplexml_import_dom($return);
     $this->assertEquals(Sitemap::encode($location), (string) $xml->loc);
     $this->assertEquals(Sitemap::date_format($lastmod), (string) $xml->lastmod);
     $this->assertEquals($change_frequency, (string) $xml->changefreq);
     $this->assertEquals($priority, (string) $xml->priority);
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:23,代码来源:UrlTest.php

示例6: set_publication_date

 /**
  * @param integer $date Article publication date in unixtimestamp format
  */
 public function set_publication_date($date)
 {
     $this->_attributes['publication_date'] = Sitemap::date_format($date);
     return $this;
 }
开发者ID:ariol,项目名称:adminshop,代码行数:8,代码来源:News.php


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