本文整理汇总了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();
}
示例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);
}
示例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;
}
示例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'});
}
示例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);
}
示例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;
}