mirror of
https://github.com/danpros/htmly.git
synced 2026-04-22 21:46:22 +05:30
Initial commit
Yay! HTMLy was born today.
This commit is contained in:
commit
643b3be88d
69 changed files with 7950 additions and 0 deletions
7
vendor/autoload.php
vendored
Normal file
7
vendor/autoload.php
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
// autoload.php generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit352930101c1dc3fb72305f7934017105::getLoader();
|
||||
240
vendor/composer/ClassLoader.php
vendored
Normal file
240
vendor/composer/ClassLoader.php
vendored
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0 class loader
|
||||
*
|
||||
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
private $prefixes = array();
|
||||
private $fallbackDirs = array();
|
||||
private $useIncludePath = false;
|
||||
private $classMap = array();
|
||||
|
||||
public function getPrefixes()
|
||||
{
|
||||
return $this->prefixes;
|
||||
}
|
||||
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirs;
|
||||
}
|
||||
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of classes, merging with any others previously set.
|
||||
*
|
||||
* @param string $prefix The classes prefix
|
||||
* @param array|string $paths The location(s) of the classes
|
||||
* @param bool $prepend Prepend the location(s)
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirs = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirs
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirs = array_merge(
|
||||
$this->fallbackDirs,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (!isset($this->prefixes[$prefix])) {
|
||||
$this->prefixes[$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixes[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixes[$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixes[$prefix] = array_merge(
|
||||
$this->prefixes[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of classes, replacing any others previously set.
|
||||
*
|
||||
* @param string $prefix The classes prefix
|
||||
* @param array|string $paths The location(s) of the classes
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirs = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
$this->prefixes[$prefix] = (array) $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True, if loaded
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
include $file;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|null The path, if found
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if ('\\' == $class[0]) {
|
||||
$class = substr($class, 1);
|
||||
}
|
||||
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR;
|
||||
$className = substr($class, $pos + 1);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$classPath = null;
|
||||
$className = $class;
|
||||
}
|
||||
|
||||
$classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
|
||||
|
||||
foreach ($this->prefixes as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
|
||||
return $dir . DIRECTORY_SEPARATOR . $classPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->fallbackDirs as $dir) {
|
||||
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
|
||||
return $dir . DIRECTORY_SEPARATOR . $classPath;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return $this->classMap[$class] = false;
|
||||
}
|
||||
}
|
||||
9
vendor/composer/autoload_classmap.php
vendored
Normal file
9
vendor/composer/autoload_classmap.php
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
// autoload_classmap.php generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
11
vendor/composer/autoload_namespaces.php
vendored
Normal file
11
vendor/composer/autoload_namespaces.php
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
// autoload_namespaces.php generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'dflydev\\markdown' => $vendorDir . '/dflydev/markdown/src',
|
||||
'Suin\\RSSWriter' => $vendorDir . '/suin/php-rss-writer/Source',
|
||||
);
|
||||
43
vendor/composer/autoload_real.php
vendored
Normal file
43
vendor/composer/autoload_real.php
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
// autoload_real.php generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit352930101c1dc3fb72305f7934017105
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit352930101c1dc3fb72305f7934017105', 'loadClassLoader'));
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit352930101c1dc3fb72305f7934017105', 'loadClassLoader'));
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->add($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
105
vendor/composer/installed.json
vendored
Normal file
105
vendor/composer/installed.json
vendored
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
[
|
||||
{
|
||||
"name": "dflydev/markdown",
|
||||
"version": "v1.0.2",
|
||||
"version_normalized": "1.0.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dflydev/dflydev-markdown.git",
|
||||
"reference": "v1.0.2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/dflydev/dflydev-markdown/zipball/v1.0.2",
|
||||
"reference": "v1.0.2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"time": "2012-01-15 19:36:37",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"dflydev\\markdown": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"New BSD License"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dragonfly Development Inc.",
|
||||
"email": "info@dflydev.com",
|
||||
"homepage": "http://dflydev.com"
|
||||
},
|
||||
{
|
||||
"name": "Beau Simensen",
|
||||
"email": "beau@dflydev.com",
|
||||
"homepage": "http://beausimensen.com"
|
||||
},
|
||||
{
|
||||
"name": "Michel Fortin",
|
||||
"homepage": "http://michelf.com"
|
||||
},
|
||||
{
|
||||
"name": "John Gruber",
|
||||
"homepage": "http://daringfireball.net"
|
||||
}
|
||||
],
|
||||
"description": "PHP Markdown & Extra",
|
||||
"homepage": "http://github.com/dflydev/dflydev-markdown",
|
||||
"keywords": [
|
||||
"markdown"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "suin/php-rss-writer",
|
||||
"version": "1.2",
|
||||
"version_normalized": "1.2.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/suin/php-rss-writer.git",
|
||||
"reference": "1.2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/suin/php-rss-writer/zipball/1.2",
|
||||
"reference": "1.2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"time": "2012-08-23 00:45:18",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Suin\\RSSWriter": "Source"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "suin",
|
||||
"email": "suinyeze@gmail.com",
|
||||
"homepage": "https://www.facebook.com/suinyeze",
|
||||
"role": "Developer, Renaming Specialist"
|
||||
}
|
||||
],
|
||||
"description": "Yet another simple RSS writer library for PHP 5.3 or later.",
|
||||
"homepage": "https://github.com/suin/php-rss-writer",
|
||||
"keywords": [
|
||||
"feed",
|
||||
"generator",
|
||||
"rss",
|
||||
"writer"
|
||||
]
|
||||
}
|
||||
]
|
||||
2
vendor/dflydev/markdown/.gitignore
vendored
Normal file
2
vendor/dflydev/markdown/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
vendor
|
||||
composer.lock
|
||||
7
vendor/dflydev/markdown/.travis.yml
vendored
Normal file
7
vendor/dflydev/markdown/.travis.yml
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
language: php
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
before_script:
|
||||
- wget -nc http://getcomposer.org/composer.phar
|
||||
- php composer.phar update
|
||||
40
vendor/dflydev/markdown/LICENSE
vendored
Normal file
40
vendor/dflydev/markdown/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
PHP Markdown & Extra
|
||||
Copyright (c) 2011, Dragonfly Development Inc
|
||||
All rights reserved.
|
||||
|
||||
Based on PHP Markdown & Extra
|
||||
Copyright (c) 2004-2009 Michel Fortin
|
||||
<http://michelf.com/>
|
||||
All rights reserved.
|
||||
|
||||
Based on Markdown
|
||||
Copyright (c) 2003-2006 John Gruber
|
||||
<http://daringfireball.net/>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name "Markdown" nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
This software is provided by the copyright holders and contributors "as
|
||||
is" and any express or implied warranties, including, but not limited
|
||||
to, the implied warranties of merchantability and fitness for a
|
||||
particular purpose are disclaimed. In no event shall the copyright owner
|
||||
or contributors be liable for any direct, indirect, incidental, special,
|
||||
exemplary, or consequential damages (including, but not limited to,
|
||||
procurement of substitute goods or services; loss of use, data, or
|
||||
profits; or business interruption) however caused and on any theory of
|
||||
liability, whether in contract, strict liability, or tort (including
|
||||
negligence or otherwise) arising in any way out of the use of this
|
||||
software, even if advised of the possibility of such damage.
|
||||
98
vendor/dflydev/markdown/README.md
vendored
Normal file
98
vendor/dflydev/markdown/README.md
vendored
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
PHP Markdown & Extra
|
||||
====================
|
||||
|
||||
An updated and stripped version of the original [PHP Markdown](http://michelf.com/projects/php-markdown/)
|
||||
by [Michel Fortin](http://michelf.com/). Works quite well with PSR-0
|
||||
autoloaders and is [Composer](http://packagist.org/) friendly.
|
||||
|
||||
|
||||
Changes from the official PHP Markdown & Extra
|
||||
----------------------------------------------
|
||||
|
||||
The initial pass at updating PHP Markdown & Extra left the core of
|
||||
the code more or less intact but the changes to the organization
|
||||
and naming were quite substantial. This effectively makes this package
|
||||
a hard fork from Markdown 1.0.1n and MarkdownExtra 1.2.4.
|
||||
|
||||
Updated in the following ways:
|
||||
|
||||
* Moved parser classes into their own files
|
||||
* Using PHP 5.3 namespaces
|
||||
* Following [PSR-0](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) standards
|
||||
* Replaced `@define` configuration variables with class `const` variables
|
||||
* Integrated with [Travis CI](http://travis-ci.org/)
|
||||
* Made [Composer](http://packagist.org/) friendly
|
||||
|
||||
Stripped in the following ways:
|
||||
|
||||
* No more embedded plugin code (WordPress, bBlog, etc.)
|
||||
* No more top level function calls (`Markdown()`, etc.)
|
||||
|
||||
Last synced with:
|
||||
|
||||
* PHP Markdown v1.0.1o
|
||||
* PHP Markdown Extra v1.2.5
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
* PHP 5.3+
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Simple usage for the standard Markdown ([details](http://michelf.com/projects/php-markdown/)) parser:
|
||||
|
||||
<?php
|
||||
use dflydev\markdown\Markdown;
|
||||
|
||||
$markdownParser = new MarkdownParser();
|
||||
|
||||
// Will return <h1>Hello World</h1>
|
||||
$markdownParser->transformMarkdown("#Hello World");
|
||||
|
||||
Simple usage for the Markdown Extra ([details](http://michelf.com/projects/php-markdown/extra/)) parser:
|
||||
|
||||
<?php
|
||||
use dflydev\markdown\MarkdownExtra;
|
||||
|
||||
$markdownParser = new MarkdownExtraParser();
|
||||
|
||||
// Will return <h1>Hello World</h1>
|
||||
$markdownParser->transformMarkdown("#Hello World");
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
This library is licensed under the New BSD License - see the LICENSE file for details.
|
||||
|
||||
|
||||
Community
|
||||
---------
|
||||
|
||||
If you have questions or want to help out, join us in the
|
||||
[#dflydev](irc://irc.freenode.net/#dflydev) channel on irc.freenode.net.
|
||||
|
||||
|
||||
Not Invented Here
|
||||
-----------------
|
||||
|
||||
The original [PHP Markdown](http://michelf.com/projects/php-markdown/) was
|
||||
quite excellent but was not as easy to use as it could be in more modern PHP
|
||||
applications. Having started to use [Composer](http://packagist.org/) for a
|
||||
few newer applications that needed to transform Markdown, I decided to strip
|
||||
and update the original PHP Markdown so that it could be more easily managed
|
||||
by the likes of Composer.
|
||||
|
||||
All of the initial work done for this library (which I can only assume
|
||||
was quite substantial after having looked at the code) was done by
|
||||
[Michel Fortin](http://michelf.com/) during the original port from Perl to
|
||||
PHP.
|
||||
|
||||
If you do not need to install PHP Markdown by way of Composer or need to
|
||||
leverage PSR-0 autoloading, I suggest you continue to use the official and
|
||||
likely more stable and well used original version of
|
||||
[PHP Markdown](http://michelf.com/projects/php-markdown/)
|
||||
34
vendor/dflydev/markdown/composer.json
vendored
Normal file
34
vendor/dflydev/markdown/composer.json
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "dflydev/markdown",
|
||||
"type": "library",
|
||||
"description": "PHP Markdown & Extra",
|
||||
"homepage": "http://github.com/dflydev/dflydev-markdown",
|
||||
"keywords": ["markdown"],
|
||||
"license": "New BSD License",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dragonfly Development Inc.",
|
||||
"email": "info@dflydev.com",
|
||||
"homepage": "http://dflydev.com"
|
||||
},
|
||||
{
|
||||
"name": "Beau Simensen",
|
||||
"email": "beau@dflydev.com",
|
||||
"homepage": "http://beausimensen.com"
|
||||
},
|
||||
{
|
||||
"name": "Michel Fortin",
|
||||
"homepage": "http://michelf.com"
|
||||
},
|
||||
{
|
||||
"name": "John Gruber",
|
||||
"homepage": "http://daringfireball.net"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "dflydev\\markdown": "src" }
|
||||
}
|
||||
}
|
||||
28
vendor/dflydev/markdown/phpunit.xml.dist
vendored
Normal file
28
vendor/dflydev/markdown/phpunit.xml.dist
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="dflydev-markdown Test Suite">
|
||||
<directory>./tests/dflydev/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./src/dflydev/</directory>
|
||||
<exclude>
|
||||
<directory>./src/dflydev/*/resources</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
||||
23
vendor/dflydev/markdown/src/dflydev/markdown/IMarkdownParser.php
vendored
Normal file
23
vendor/dflydev/markdown/src/dflydev/markdown/IMarkdownParser.php
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of the PHP Markdown library.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace dflydev\markdown;
|
||||
|
||||
interface IMarkdownParser {
|
||||
|
||||
/**
|
||||
* Transform Markdown text to HTML.
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public function transformMarkdown($text);
|
||||
|
||||
}
|
||||
1359
vendor/dflydev/markdown/src/dflydev/markdown/MarkdownExtraParser.php
vendored
Normal file
1359
vendor/dflydev/markdown/src/dflydev/markdown/MarkdownExtraParser.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
1529
vendor/dflydev/markdown/src/dflydev/markdown/MarkdownParser.php
vendored
Normal file
1529
vendor/dflydev/markdown/src/dflydev/markdown/MarkdownParser.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
12
vendor/dflydev/markdown/tests/bootstrap.php
vendored
Normal file
12
vendor/dflydev/markdown/tests/bootstrap.php
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is a part of the PHP Markdown library.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
$loader = require dirname(__DIR__).'/vendor/.composer/autoload.php';
|
||||
$loader->add('dflydev\\tests\\markdown', 'tests');
|
||||
34
vendor/dflydev/markdown/tests/dflydev/tests/markdown/MarkdownExtraParserTest.php
vendored
Normal file
34
vendor/dflydev/markdown/tests/dflydev/tests/markdown/MarkdownExtraParserTest.php
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of the PHP Markdown library.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace dflydev\tests\markdown;
|
||||
|
||||
use dflydev\markdown\MarkdownExtraParser;
|
||||
|
||||
class MarkdownExtraParserTest extends MarkdownParserTest
|
||||
{
|
||||
|
||||
protected $configKeyTabWidth = \dflydev\markdown\MarkdownExtraParser::CONFIG_TAB_WIDTH;
|
||||
|
||||
/**
|
||||
* Create a markdown parser.
|
||||
* @param array $configuration Optional configuration
|
||||
* @return \dflydev\markdown\IMarkdownParser
|
||||
*/
|
||||
public function createParser($configuration = null)
|
||||
{
|
||||
if ($configuration !== null) {
|
||||
return new \dflydev\markdown\MarkdownExtraParser($configuration);
|
||||
}
|
||||
return new \dflydev\markdown\MarkdownExtraParser();
|
||||
}
|
||||
|
||||
}
|
||||
73
vendor/dflydev/markdown/tests/dflydev/tests/markdown/MarkdownParserTest.php
vendored
Normal file
73
vendor/dflydev/markdown/tests/dflydev/tests/markdown/MarkdownParserTest.php
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of the PHP Markdown library.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace dflydev\tests\markdown;
|
||||
|
||||
use dflydev\markdown\MarkdownParser;
|
||||
|
||||
class MarkdownParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
protected $configKeyTabWidth = \dflydev\markdown\MarkdownParser::CONFIG_TAB_WIDTH;
|
||||
|
||||
/**
|
||||
* Create a markdown parser.
|
||||
* @param array $configuration Optional configuration
|
||||
* @return \dflydev\markdown\IMarkdownParser
|
||||
*/
|
||||
public function createParser($configuration = null)
|
||||
{
|
||||
if ( $configuration !== null ) {
|
||||
return new \dflydev\markdown\MarkdownParser($configuration);
|
||||
}
|
||||
return new \dflydev\markdown\MarkdownParser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple test to ensure that parser can be created and most basic of
|
||||
* Markdown can be transformed.
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$markdownParser = $this->createParser();
|
||||
$html = $markdownParser->transformMarkdown('#Hello World');
|
||||
$this->assertEquals("<h1>Hello World</h1>\n", $html, 'Simple H1 works');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test tab width for code blocks
|
||||
*/
|
||||
public function testTabWidth()
|
||||
{
|
||||
$markdownParser = $this->createParser();
|
||||
$html = $markdownParser->transformMarkdown(' Hello World');
|
||||
$this->assertEquals("<pre><code>Hello World\n</code></pre>\n", $html, 'Default 4 space tab code block works');
|
||||
$this->configureTabWidth($markdownParser, 6);
|
||||
$html = $markdownParser->transformMarkdown(' Hello World');
|
||||
$this->assertEquals("<p>Hello World</p>\n", $html, 'Default 4 space tab code block not triggered when tab width set to 6');
|
||||
$html = $markdownParser->transformMarkdown(' Hello World');
|
||||
$this->assertEquals("<pre><code>Hello World\n</code></pre>\n", $html, 'Setting 6 space tab code block (via method) works');
|
||||
$markdownParser = $this->createParser(array($this->configKeyTabWidth => 8));
|
||||
$html = $markdownParser->transformMarkdown(' Hello World');
|
||||
$this->assertEquals("<pre><code>Hello World\n</code></pre>\n", $html, 'Setting 8 space tab code block (via constructor) works');
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure a Markdown parser for a specific tab width
|
||||
* @param \dflydev\markdown\MarkdownParser $markdownParser
|
||||
* @param integer $width
|
||||
*/
|
||||
protected function configureTabWidth(MarkdownParser $markdownParser, $width)
|
||||
{
|
||||
$markdownParser->configureMarkdownParser($this->configKeyTabWidth, $width);
|
||||
}
|
||||
|
||||
}
|
||||
3
vendor/suin/php-rss-writer/.gitignore
vendored
Normal file
3
vendor/suin/php-rss-writer/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
.idea/
|
||||
.phpmake
|
||||
.DS_Store
|
||||
11
vendor/suin/php-rss-writer/.travis.yml
vendored
Normal file
11
vendor/suin/php-rss-writer/.travis.yml
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
language: php
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
|
||||
before_script:
|
||||
- cd Tests
|
||||
- wget http://getcomposer.org/composer.phar
|
||||
- php composer.phar install
|
||||
|
||||
script: ./phpunit --coverage-text --configuration phpunit.xml.dist
|
||||
84
vendor/suin/php-rss-writer/README.md
vendored
Normal file
84
vendor/suin/php-rss-writer/README.md
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
# \Suin\RSSWriter
|
||||
|
||||
`\Suin\RSSWriter` is yet another simple RSS writer library for PHP 5.3 or later. This component is Licensed under MIT license.
|
||||
|
||||
The build status of the current master branch is tracked by Travis CI: [](http://travis-ci.org/suin/php-rss-writer)
|
||||
|
||||
|
||||
Implementation:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$feed = new Feed();
|
||||
|
||||
$channel = new Channel();
|
||||
$channel
|
||||
->title("Channel Title")
|
||||
->description("Channel Description")
|
||||
->url('http://blog.example.com')
|
||||
->appendTo($feed);
|
||||
|
||||
$item = new Item();
|
||||
$item
|
||||
->title("Blog Entry Title")
|
||||
->description("<div>Blog body</div>")
|
||||
->url('http://blog.example.com/2012/08/21/blog-entry/')
|
||||
->appendTo($channel);
|
||||
|
||||
|
||||
echo $feed;
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0"?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>Channel Title</title>
|
||||
<link>http://blog.example.com</link>
|
||||
<description>Channel Description</description>
|
||||
<item>
|
||||
<title>Blog Entry Title</title>
|
||||
<link>http://blog.example.com/2012/08/21/blog-entry/</link>
|
||||
<description><div>Blog body</div></description>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
You can install via Composer.
|
||||
|
||||
At first create `composer.json` file:
|
||||
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"suin/php-rss-writer": ">=1.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Run composer to install.
|
||||
|
||||
```
|
||||
$ composer install
|
||||
```
|
||||
|
||||
Finally, include `vendor/autoload.php` in your product.
|
||||
|
||||
```
|
||||
require_once 'vendor/autoload.php';
|
||||
```
|
||||
|
||||
## How to Use
|
||||
|
||||
`example.php` is an example usage of RSSWriter.
|
||||
|
||||
If you want to know APIs, please see `FeedInterface`, `ChannelInterface` and `ItemInterface`.
|
||||
|
||||
## License
|
||||
|
||||
MIT license
|
||||
189
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/Channel.php
vendored
Normal file
189
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/Channel.php
vendored
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
<?php
|
||||
|
||||
namespace Suin\RSSWriter;
|
||||
|
||||
use \Suin\RSSWriter\SimpleXMLElement;
|
||||
|
||||
class Channel implements \Suin\RSSWriter\ChannelInterface
|
||||
{
|
||||
/** @var string */
|
||||
protected $title;
|
||||
/** @var string */
|
||||
protected $url;
|
||||
/** @var string */
|
||||
protected $description;
|
||||
/** @var string */
|
||||
protected $language;
|
||||
/** @var string */
|
||||
protected $copyright;
|
||||
/** @var int */
|
||||
protected $pubDate;
|
||||
/** @var int */
|
||||
protected $lastBuildDate;
|
||||
/** @var int */
|
||||
protected $ttl;
|
||||
/** @var \Suin\RSSWriter\ItemInterface[] */
|
||||
protected $items = array();
|
||||
|
||||
/**
|
||||
* Set channel title
|
||||
* @param string $title
|
||||
* @return $this
|
||||
*/
|
||||
public function title($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set channel URL
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function url($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set channel description
|
||||
* @param string $description
|
||||
* @return $this
|
||||
*/
|
||||
public function description($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ISO639 language code
|
||||
*
|
||||
* The language the channel is written in. This allows aggregators to group all
|
||||
* Italian language sites, for example, on a single page. A list of allowable
|
||||
* values for this element, as provided by Netscape, is here. You may also use
|
||||
* values defined by the W3C.
|
||||
*
|
||||
* @param string $language
|
||||
* @return $this
|
||||
*/
|
||||
public function language($language)
|
||||
{
|
||||
$this->language = $language;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set channel copyright
|
||||
* @param string $copyright
|
||||
* @return $this
|
||||
*/
|
||||
public function copyright($copyright)
|
||||
{
|
||||
$this->copyright = $copyright;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set channel published date
|
||||
* @param int $pubDate Unix timestamp
|
||||
* @return $this
|
||||
*/
|
||||
public function pubDate($pubDate)
|
||||
{
|
||||
$this->pubDate = $pubDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set channel last build date
|
||||
* @param int $lastBuildDate Unix timestamp
|
||||
* @return $this
|
||||
*/
|
||||
public function lastBuildDate($lastBuildDate)
|
||||
{
|
||||
$this->lastBuildDate = $lastBuildDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set channel ttl (minutes)
|
||||
* @param int $ttl
|
||||
* @return $this
|
||||
*/
|
||||
public function ttl($ttl)
|
||||
{
|
||||
$this->ttl = $ttl;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item object
|
||||
* @param \Suin\RSSWriter\ItemInterface $item
|
||||
* @return $this
|
||||
*/
|
||||
public function addItem(ItemInterface $item)
|
||||
{
|
||||
$this->items[] = $item;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append to feed
|
||||
* @param \Suin\RSSWriter\FeedInterface $feed
|
||||
* @return $this
|
||||
*/
|
||||
public function appendTo(FeedInterface $feed)
|
||||
{
|
||||
$feed->addChannel($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return XML object
|
||||
* @return \Suin\RSSWriter\SimpleXMLElement
|
||||
*/
|
||||
public function asXML()
|
||||
{
|
||||
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><channel></channel>', LIBXML_NOERROR|LIBXML_ERR_NONE|LIBXML_ERR_FATAL);
|
||||
$xml->addChild('title', $this->title);
|
||||
$xml->addChild('link', $this->url);
|
||||
$xml->addChild('description', $this->description);
|
||||
|
||||
if ( $this->language !== null )
|
||||
{
|
||||
$xml->addChild('language', $this->language);
|
||||
}
|
||||
|
||||
if ( $this->copyright !== null )
|
||||
{
|
||||
$xml->addChild('copyright', $this->copyright);
|
||||
}
|
||||
|
||||
if ( $this->pubDate !== null )
|
||||
{
|
||||
$xml->addChild('pubDate', date(DATE_RSS, $this->pubDate));
|
||||
}
|
||||
|
||||
if ( $this->lastBuildDate !== null )
|
||||
{
|
||||
$xml->addChild('lastBuildDate', date(DATE_RSS, $this->lastBuildDate));
|
||||
}
|
||||
|
||||
if ( $this->ttl !== null )
|
||||
{
|
||||
$xml->addChild('ttl', $this->ttl);
|
||||
}
|
||||
|
||||
foreach ( $this->items as $item )
|
||||
{
|
||||
$toDom = dom_import_simplexml($xml);
|
||||
$fromDom = dom_import_simplexml($item->asXML());
|
||||
$toDom->appendChild($toDom->ownerDocument->importNode($fromDom, true));
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
}
|
||||
91
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/ChannelInterface.php
vendored
Normal file
91
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/ChannelInterface.php
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace Suin\RSSWriter;
|
||||
|
||||
use \Suin\RSSWriter\FeedInterface;
|
||||
use \Suin\RSSWriter\ItemInterface;
|
||||
|
||||
interface ChannelInterface
|
||||
{
|
||||
/**
|
||||
* Set channel title
|
||||
* @param string $title
|
||||
* @return $this
|
||||
*/
|
||||
public function title($title);
|
||||
|
||||
/**
|
||||
* Set channel URL
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function url($url);
|
||||
|
||||
/**
|
||||
* Set channel description
|
||||
* @param string $description
|
||||
* @return $this
|
||||
*/
|
||||
public function description($description);
|
||||
|
||||
/**
|
||||
* Set ISO639 language code
|
||||
*
|
||||
* The language the channel is written in. This allows aggregators to group all
|
||||
* Italian language sites, for example, on a single page. A list of allowable
|
||||
* values for this element, as provided by Netscape, is here. You may also use
|
||||
* values defined by the W3C.
|
||||
*
|
||||
* @param string $language
|
||||
* @return $this
|
||||
*/
|
||||
public function language($language);
|
||||
|
||||
/**
|
||||
* Set channel copyright
|
||||
* @param string $copyright
|
||||
* @return $this
|
||||
*/
|
||||
public function copyright($copyright);
|
||||
|
||||
/**
|
||||
* Set channel published date
|
||||
* @param int $pubDate Unix timestamp
|
||||
* @return $this
|
||||
*/
|
||||
public function pubDate($pubDate);
|
||||
|
||||
/**
|
||||
* Set channel last build date
|
||||
* @param int $lastBuildDate Unix timestamp
|
||||
* @return $this
|
||||
*/
|
||||
public function lastBuildDate($lastBuildDate);
|
||||
|
||||
/**
|
||||
* Set channel ttl (minutes)
|
||||
* @param int $ttl
|
||||
* @return $this
|
||||
*/
|
||||
public function ttl($ttl);
|
||||
|
||||
/**
|
||||
* Add item object
|
||||
* @param \Suin\RSSWriter\ItemInterface $item
|
||||
* @return $this
|
||||
*/
|
||||
public function addItem(ItemInterface $item);
|
||||
|
||||
/**
|
||||
* Append to feed
|
||||
* @param \Suin\RSSWriter\FeedInterface $feed
|
||||
* @return $this
|
||||
*/
|
||||
public function appendTo(FeedInterface $feed);
|
||||
|
||||
/**
|
||||
* Return XML object
|
||||
* @return \Suin\RSSWriter\SimpleXMLElement
|
||||
*/
|
||||
public function asXML();
|
||||
}
|
||||
54
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/Feed.php
vendored
Normal file
54
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/Feed.php
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Suin\RSSWriter;
|
||||
|
||||
use \DOMDocument;
|
||||
use \Suin\RSSWriter\ChannelInterface;
|
||||
use \Suin\RSSWriter\SimpleXMLElement;
|
||||
|
||||
class Feed implements \Suin\RSSWriter\FeedInterface
|
||||
{
|
||||
/** @var \Suin\RSSWriter\ChannelInterface[] */
|
||||
protected $channels = array();
|
||||
|
||||
/**
|
||||
* Add channel
|
||||
* @param \Suin\RSSWriter\ChannelInterface $channel
|
||||
* @return $this
|
||||
*/
|
||||
public function addChannel(ChannelInterface $channel)
|
||||
{
|
||||
$this->channels[] = $channel;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render XML
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" />', LIBXML_NOERROR|LIBXML_ERR_NONE|LIBXML_ERR_FATAL);
|
||||
|
||||
foreach ( $this->channels as $channel )
|
||||
{
|
||||
$toDom = dom_import_simplexml($xml);
|
||||
$fromDom = dom_import_simplexml($channel->asXML());
|
||||
$toDom->appendChild($toDom->ownerDocument->importNode($fromDom, true));
|
||||
}
|
||||
|
||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$dom->appendChild($dom->importNode(dom_import_simplexml($xml), true));
|
||||
$dom->formatOutput = true;
|
||||
return $dom->saveXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render XML
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
}
|
||||
27
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/FeedInterface.php
vendored
Normal file
27
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/FeedInterface.php
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Suin\RSSWriter;
|
||||
|
||||
use \Suin\RSSWriter\ChannelInterface;
|
||||
|
||||
interface FeedInterface
|
||||
{
|
||||
/**
|
||||
* Add channel
|
||||
* @param \Suin\RSSWriter\ChannelInterface $channel
|
||||
* @return $thisJ
|
||||
*/
|
||||
public function addChannel(ChannelInterface $channel);
|
||||
|
||||
/**
|
||||
* Render XML
|
||||
* @return string
|
||||
*/
|
||||
public function render();
|
||||
|
||||
/**
|
||||
* Render XML
|
||||
* @return string
|
||||
*/
|
||||
public function __toString();
|
||||
}
|
||||
142
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/Item.php
vendored
Normal file
142
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/Item.php
vendored
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
namespace Suin\RSSWriter;
|
||||
|
||||
use \Suin\RSSWriter\SimpleXMLElement;
|
||||
|
||||
class Item implements \Suin\RSSWriter\ItemInterface
|
||||
{
|
||||
/** @var string */
|
||||
protected $title;
|
||||
/** @var string */
|
||||
protected $url;
|
||||
/** @var string */
|
||||
protected $description;
|
||||
/** @var array */
|
||||
protected $categories = array();
|
||||
/** @var string */
|
||||
protected $guid;
|
||||
/** @var bool */
|
||||
protected $isPermalink;
|
||||
/** @var int */
|
||||
protected $pubDate;
|
||||
|
||||
/**
|
||||
* Set item title
|
||||
* @param string $title
|
||||
* @return $this
|
||||
*/
|
||||
public function title($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set item URL
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function url($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set item description
|
||||
* @param string $description
|
||||
* @return $this
|
||||
*/
|
||||
public function description($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set item category
|
||||
* @param string $name Category name
|
||||
* @param string $domain Category URL
|
||||
* @return $this
|
||||
*/
|
||||
public function category($name, $domain = null)
|
||||
{
|
||||
$this->categories[] = array($name, $domain);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set GUID
|
||||
* @param string $guid
|
||||
* @param bool $isPermalink
|
||||
* @return $this
|
||||
*/
|
||||
public function guid($guid, $isPermalink = false)
|
||||
{
|
||||
$this->guid = $guid;
|
||||
$this->isPermalink = $isPermalink;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set published date
|
||||
* @param int $pubDate Unix timestamp
|
||||
* @return $this
|
||||
*/
|
||||
public function pubDate($pubDate)
|
||||
{
|
||||
$this->pubDate = $pubDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append item to the channel
|
||||
* @param \Suin\RSSWriter\ChannelInterface $channel
|
||||
* @return $this
|
||||
*/
|
||||
public function appendTo(ChannelInterface $channel)
|
||||
{
|
||||
$channel->addItem($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return XML object
|
||||
* @return \Suin\RSSWriter\SimpleXMLElement
|
||||
*/
|
||||
public function asXML()
|
||||
{
|
||||
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><item></item>', LIBXML_NOERROR|LIBXML_ERR_NONE|LIBXML_ERR_FATAL);
|
||||
$xml->addChild('title', $this->title);
|
||||
$xml->addChild('link', $this->url);
|
||||
$xml->addChild('description', $this->description);
|
||||
|
||||
foreach ( $this->categories as $category )
|
||||
{
|
||||
$element = $xml->addChild('category', $category[0]);
|
||||
|
||||
if ( isset($category[1]) )
|
||||
{
|
||||
$element->addAttribute('domain', $category[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->guid )
|
||||
{
|
||||
$guid = $xml->addChild('guid', $this->guid);
|
||||
|
||||
if ( $this->isPermalink )
|
||||
{
|
||||
$guid->addAttribute('isPermaLink', 'true');
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->pubDate !== null )
|
||||
{
|
||||
$xml->addChild('pubDate', date(DATE_RSS, $this->pubDate));
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
}
|
||||
66
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/ItemInterface.php
vendored
Normal file
66
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/ItemInterface.php
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace Suin\RSSWriter;
|
||||
|
||||
use \Suin\RSSWriter\ChannelInterface;
|
||||
use \Suin\RSSWriter\SimpleXMLElement;
|
||||
|
||||
interface ItemInterface
|
||||
{
|
||||
/**
|
||||
* Set item title
|
||||
* @param string $title
|
||||
* @return $this
|
||||
*/
|
||||
public function title($title);
|
||||
|
||||
/**
|
||||
* Set item URL
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function url($url);
|
||||
|
||||
/**
|
||||
* Set item description
|
||||
* @param string $description
|
||||
* @return $this
|
||||
*/
|
||||
public function description($description);
|
||||
|
||||
/**
|
||||
* Set item category
|
||||
* @param string $name Category name
|
||||
* @param string $domain Category URL
|
||||
* @return $this
|
||||
*/
|
||||
public function category($name, $domain = null);
|
||||
|
||||
/**
|
||||
* Set GUID
|
||||
* @param string $guid
|
||||
* @param bool $isPermalink
|
||||
* @return $this
|
||||
*/
|
||||
public function guid($guid, $isPermalink = false);
|
||||
|
||||
/**
|
||||
* Set published date
|
||||
* @param int $pubDate Unix timestamp
|
||||
* @return $this
|
||||
*/
|
||||
public function pubDate($pubDate);
|
||||
|
||||
/**
|
||||
* Append item to the channel
|
||||
* @param \Suin\RSSWriter\ChannelInterface $channel
|
||||
* @return $this
|
||||
*/
|
||||
public function appendTo(ChannelInterface $channel);
|
||||
|
||||
/**
|
||||
* Return XML object
|
||||
* @return \Suin\RSSWriter\SimpleXMLElement
|
||||
*/
|
||||
public function asXML();
|
||||
}
|
||||
16
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/SimpleXMLElement.php
vendored
Normal file
16
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/SimpleXMLElement.php
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Suin\RSSWriter;
|
||||
|
||||
class SimpleXMLElement extends \SimpleXMLElement
|
||||
{
|
||||
public function addChild($name, $value = null, $namespace = null)
|
||||
{
|
||||
if ( $value !== null and is_string($value) === true )
|
||||
{
|
||||
$value = str_replace('&', '&', $value);
|
||||
}
|
||||
|
||||
return parent::addChild($name, $value, $namespace);
|
||||
}
|
||||
}
|
||||
10
vendor/suin/php-rss-writer/Tests/.gitignore
vendored
Normal file
10
vendor/suin/php-rss-writer/Tests/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
Coverage/
|
||||
Vendor/*
|
||||
/composer.lock
|
||||
/dbunit
|
||||
/phpcov
|
||||
/phpcpd
|
||||
/phpdcd
|
||||
/phploc
|
||||
/phpunit
|
||||
/phpunit-skelgen
|
||||
8
vendor/suin/php-rss-writer/Tests/Bootstrap.php
vendored
Normal file
8
vendor/suin/php-rss-writer/Tests/Bootstrap.php
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
// For composer
|
||||
require_once 'Vendor/autoload.php';
|
||||
|
||||
// Load test target classes
|
||||
spl_autoload_register(function($c) { @include_once strtr($c, '\\_', '//').'.php'; });
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__DIR__).'/Source');
|
||||
28
vendor/suin/php-rss-writer/Tests/README.md
vendored
Normal file
28
vendor/suin/php-rss-writer/Tests/README.md
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# How to Test
|
||||
|
||||
## Installation
|
||||
|
||||
Install [composer](https://github.com/composer/composer) to your ~/bin:
|
||||
|
||||
```sh
|
||||
$ curl -s http://getcomposer.org/installer | php
|
||||
```
|
||||
|
||||
Run composer and install depending packages:
|
||||
|
||||
```sh
|
||||
$ composer.phar install
|
||||
```
|
||||
|
||||
## Executing Tests
|
||||
|
||||
Run phpunit:
|
||||
|
||||
```sh
|
||||
$ ./phpunit
|
||||
```
|
||||
|
||||
## View Reports
|
||||
|
||||
|
||||
If you want to see code coverages, open Coverage/index.html.
|
||||
252
vendor/suin/php-rss-writer/Tests/Suin/RSSWriter/ChannelTest.php
vendored
Normal file
252
vendor/suin/php-rss-writer/Tests/Suin/RSSWriter/ChannelTest.php
vendored
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
<?php
|
||||
|
||||
namespace Suin\RSSWriter;
|
||||
|
||||
class ChannelTest extends \XoopsUnit\TestCase
|
||||
{
|
||||
private $itemInterface = '\Suin\RSSWriter\ItemInterface';
|
||||
private $feedInterface = '\Suin\RSSWriter\FeedInterface';
|
||||
|
||||
public function testTitle()
|
||||
{
|
||||
$title = uniqid();
|
||||
$channel = new Channel();
|
||||
$this->assertSame($channel, $channel->title($title));
|
||||
$this->assertAttributeSame($title, 'title', $channel);
|
||||
}
|
||||
|
||||
public function testUrl()
|
||||
{
|
||||
$url = uniqid();
|
||||
$channel = new Channel();
|
||||
$this->assertSame($channel, $channel->url($url));
|
||||
$this->assertAttributeSame($url, 'url', $channel);
|
||||
}
|
||||
|
||||
public function testDescription()
|
||||
{
|
||||
$description = uniqid();
|
||||
$channel = new Channel();
|
||||
$this->assertSame($channel, $channel->description($description));
|
||||
$this->assertAttributeSame($description, 'description', $channel);
|
||||
}
|
||||
|
||||
public function testLanguage()
|
||||
{
|
||||
$language = uniqid();
|
||||
$channel = new Channel();
|
||||
$this->assertSame($channel, $channel->language($language));
|
||||
$this->assertAttributeSame($language, 'language', $channel);
|
||||
}
|
||||
|
||||
public function testCopyright()
|
||||
{
|
||||
$copyright = uniqid();
|
||||
$channel = new Channel();
|
||||
$this->assertSame($channel, $channel->copyright($copyright));
|
||||
$this->assertAttributeSame($copyright, 'copyright', $channel);
|
||||
}
|
||||
|
||||
public function testPubDate()
|
||||
{
|
||||
$pubDate = mt_rand(0, 9999999);
|
||||
$channel = new Channel();
|
||||
$this->assertSame($channel, $channel->pubDate($pubDate));
|
||||
$this->assertAttributeSame($pubDate, 'pubDate', $channel);
|
||||
}
|
||||
|
||||
public function testLastBuildDate()
|
||||
{
|
||||
$lastBuildDate = mt_rand(0, 9999999);
|
||||
$channel = new Channel();
|
||||
$this->assertSame($channel, $channel->lastBuildDate($lastBuildDate));
|
||||
$this->assertAttributeSame($lastBuildDate, 'lastBuildDate', $channel);
|
||||
}
|
||||
|
||||
public function testTtl()
|
||||
{
|
||||
$ttl = mt_rand(0, 99999999);
|
||||
$channel = new Channel();
|
||||
$this->assertSame($channel, $channel->ttl($ttl));
|
||||
$this->assertAttributeSame($ttl, 'ttl', $channel);
|
||||
}
|
||||
|
||||
public function testAddItem()
|
||||
{
|
||||
$item = $this->getMock($this->itemInterface);
|
||||
$channel = new Channel();
|
||||
$this->assertSame($channel, $channel->addItem($item));
|
||||
$this->assertAttributeSame(array($item), 'items', $channel);
|
||||
}
|
||||
|
||||
public function testAppendTo()
|
||||
{
|
||||
$channel = new Channel();
|
||||
$feed = $this->getMock($this->feedInterface);
|
||||
$feed->expects($this->once())->method('addChannel')->with($channel);
|
||||
$this->assertSame($channel, $channel->appendTo($feed));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $expect
|
||||
* @param array $data
|
||||
* @dataProvider dataForAsXML
|
||||
*/
|
||||
public function testAsXML($expect, array $data)
|
||||
{
|
||||
$data = (object) $data;
|
||||
$channel = new Channel();
|
||||
|
||||
foreach ( $data as $key => $value )
|
||||
{
|
||||
$this->reveal($channel)->attr($key, $value);
|
||||
}
|
||||
|
||||
$this->assertXmlStringEqualsXmlString($expect, $channel->asXML()->asXML());
|
||||
}
|
||||
|
||||
public static function dataForAsXML()
|
||||
{
|
||||
$now = time();
|
||||
$nowString = date(DATE_RSS, $now);
|
||||
|
||||
return array(
|
||||
array(
|
||||
"
|
||||
<channel>
|
||||
<title>GoUpstate.com News Headlines</title>
|
||||
<link>http://www.goupstate.com/</link>
|
||||
<description>The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.</description>
|
||||
</channel>
|
||||
",
|
||||
array(
|
||||
'title' => "GoUpstate.com News Headlines",
|
||||
'url' => 'http://www.goupstate.com/',
|
||||
'description' => "The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.",
|
||||
)
|
||||
),
|
||||
array(
|
||||
"
|
||||
<channel>
|
||||
<title>GoUpstate.com News Headlines</title>
|
||||
<link>http://www.goupstate.com/</link>
|
||||
<description>The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.</description>
|
||||
<language>en-us</language>
|
||||
</channel>
|
||||
",
|
||||
array(
|
||||
'title' => "GoUpstate.com News Headlines",
|
||||
'url' => 'http://www.goupstate.com/',
|
||||
'description' => "The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.",
|
||||
'language' => 'en-us',
|
||||
)
|
||||
),
|
||||
array(
|
||||
"
|
||||
<channel>
|
||||
<title>GoUpstate.com News Headlines</title>
|
||||
<link>http://www.goupstate.com/</link>
|
||||
<description>The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.</description>
|
||||
<pubDate>{$nowString}</pubDate>
|
||||
</channel>
|
||||
",
|
||||
array(
|
||||
'title' => "GoUpstate.com News Headlines",
|
||||
'url' => 'http://www.goupstate.com/',
|
||||
'description' => "The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.",
|
||||
'pubDate' => $now,
|
||||
)
|
||||
),
|
||||
array(
|
||||
"
|
||||
<channel>
|
||||
<title>GoUpstate.com News Headlines</title>
|
||||
<link>http://www.goupstate.com/</link>
|
||||
<description>The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.</description>
|
||||
<lastBuildDate>{$nowString}</lastBuildDate>
|
||||
</channel>
|
||||
",
|
||||
array(
|
||||
'title' => "GoUpstate.com News Headlines",
|
||||
'url' => 'http://www.goupstate.com/',
|
||||
'description' => "The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.",
|
||||
'lastBuildDate' => $now,
|
||||
)
|
||||
),
|
||||
array(
|
||||
"
|
||||
<channel>
|
||||
<title>GoUpstate.com News Headlines</title>
|
||||
<link>http://www.goupstate.com/</link>
|
||||
<description>The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.</description>
|
||||
<ttl>60</ttl>
|
||||
</channel>
|
||||
",
|
||||
array(
|
||||
'title' => "GoUpstate.com News Headlines",
|
||||
'url' => 'http://www.goupstate.com/',
|
||||
'description' => "The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.",
|
||||
'ttl' => 60,
|
||||
)
|
||||
),
|
||||
array(
|
||||
"
|
||||
<channel>
|
||||
<title>GoUpstate.com News Headlines</title>
|
||||
<link>http://www.goupstate.com/</link>
|
||||
<description>The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.</description>
|
||||
<copyright>Copyright 2002, Spartanburg Herald-Journal</copyright>
|
||||
</channel>
|
||||
",
|
||||
array(
|
||||
'title' => "GoUpstate.com News Headlines",
|
||||
'url' => 'http://www.goupstate.com/',
|
||||
'description' => "The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.",
|
||||
'copyright' => "Copyright 2002, Spartanburg Herald-Journal",
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function testAppendTo_with_items()
|
||||
{
|
||||
$channel = new Channel();
|
||||
|
||||
$xml1 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><item><title>item1</title></item>');
|
||||
$xml2 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><item><title>item2</title></item>');
|
||||
$xml3 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><item><title>item3</title></item>');
|
||||
|
||||
$item1 = $this->getMock($this->itemInterface);
|
||||
$item1->expects($this->once())->method('asXML')->will($this->returnValue($xml1));
|
||||
$item2= $this->getMock($this->itemInterface);
|
||||
$item2->expects($this->once())->method('asXML')->will($this->returnValue($xml2));
|
||||
$item3 = $this->getMock($this->itemInterface);
|
||||
$item3->expects($this->once())->method('asXML')->will($this->returnValue($xml3));
|
||||
|
||||
$this->reveal($channel)
|
||||
->attr('title', "GoUpstate.com News Headlines")
|
||||
->attr('url', 'http://www.goupstate.com/')
|
||||
->attr('description', "The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.")
|
||||
->attr('items', array($item1, $item2, $item3));
|
||||
|
||||
$expect = '<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<channel>
|
||||
<title>GoUpstate.com News Headlines</title>
|
||||
<link>http://www.goupstate.com/</link>
|
||||
<description>The latest news from GoUpstate.com, a Spartanburg Herald-Journal Web site.</description>
|
||||
<item>
|
||||
<title>item1</title>
|
||||
</item>
|
||||
<item>
|
||||
<title>item2</title>
|
||||
</item>
|
||||
<item>
|
||||
<title>item3</title>
|
||||
</item>
|
||||
</channel>
|
||||
';
|
||||
|
||||
$this->assertXmlStringEqualsXmlString($expect, $channel->asXML()->asXML());
|
||||
}
|
||||
}
|
||||
96
vendor/suin/php-rss-writer/Tests/Suin/RSSWriter/FeedTest.php
vendored
Normal file
96
vendor/suin/php-rss-writer/Tests/Suin/RSSWriter/FeedTest.php
vendored
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
namespace Suin\RSSWriter;
|
||||
|
||||
use \Mockery;
|
||||
|
||||
class FeedTest extends \XoopsUnit\TestCase
|
||||
{
|
||||
private $channelInterface = '\Suin\RSSWriter\ChannelInterface';
|
||||
|
||||
public function testAddChannel()
|
||||
{
|
||||
$channel = Mockery::mock($this->channelInterface);
|
||||
$feed = new Feed();
|
||||
$this->assertSame($feed, $feed->addChannel($channel));
|
||||
$this->assertAttributeSame(array($channel), 'channels', $feed);
|
||||
}
|
||||
|
||||
public function testRender()
|
||||
{
|
||||
$feed = new Feed();
|
||||
$xml1 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><channel><title>channel1</title></channel>');
|
||||
$xml2 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><channel><title>channel2</title></channel>');
|
||||
$xml3 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><channel><title>channel3</title></channel>');
|
||||
$channel1 = $this->getMock($this->channelInterface);
|
||||
$channel1->expects($this->once())->method('asXML')->will($this->returnValue($xml1));
|
||||
$channel2 = $this->getMock($this->channelInterface);
|
||||
$channel2->expects($this->once())->method('asXML')->will($this->returnValue($xml2));
|
||||
$channel3 = $this->getMock($this->channelInterface);
|
||||
$channel3->expects($this->once())->method('asXML')->will($this->returnValue($xml3));
|
||||
$this->reveal($feed)->attr('channels', array($channel1, $channel2, $channel3));
|
||||
$expect = '<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel><title>channel1</title></channel>
|
||||
<channel><title>channel2</title></channel>
|
||||
<channel><title>channel3</title></channel>
|
||||
</rss>
|
||||
';
|
||||
$this->assertXmlStringEqualsXmlString($expect, $feed->render());
|
||||
}
|
||||
|
||||
public function testRender_with_japanese()
|
||||
{
|
||||
$feed = new Feed();
|
||||
$xml1 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><channel><title>日本語1</title></channel>');
|
||||
$xml2 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><channel><title>日本語2</title></channel>');
|
||||
$xml3 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><channel><title>日本語3</title></channel>');
|
||||
$channel1 = $this->getMock($this->channelInterface);
|
||||
$channel1->expects($this->once())->method('asXML')->will($this->returnValue($xml1));
|
||||
$channel2 = $this->getMock($this->channelInterface);
|
||||
$channel2->expects($this->once())->method('asXML')->will($this->returnValue($xml2));
|
||||
$channel3 = $this->getMock($this->channelInterface);
|
||||
$channel3->expects($this->once())->method('asXML')->will($this->returnValue($xml3));
|
||||
$this->reveal($feed)->attr('channels', array($channel1, $channel2, $channel3));
|
||||
$expect = <<< 'XML'
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>日本語1</title>
|
||||
</channel>
|
||||
<channel>
|
||||
<title>日本語2</title>
|
||||
</channel>
|
||||
<channel>
|
||||
<title>日本語3</title>
|
||||
</channel>
|
||||
</rss>
|
||||
|
||||
XML;
|
||||
$this->assertSame($expect, $feed->render());
|
||||
|
||||
}
|
||||
|
||||
public function test__toString()
|
||||
{
|
||||
$feed = new Feed();
|
||||
$xml1 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><channel><title>channel1</title></channel>');
|
||||
$xml2 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><channel><title>channel2</title></channel>');
|
||||
$xml3 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><channel><title>channel3</title></channel>');
|
||||
$channel1 = $this->getMock($this->channelInterface);
|
||||
$channel1->expects($this->once())->method('asXML')->will($this->returnValue($xml1));
|
||||
$channel2 = $this->getMock($this->channelInterface);
|
||||
$channel2->expects($this->once())->method('asXML')->will($this->returnValue($xml2));
|
||||
$channel3 = $this->getMock($this->channelInterface);
|
||||
$channel3->expects($this->once())->method('asXML')->will($this->returnValue($xml3));
|
||||
$this->reveal($feed)->attr('channels', array($channel1, $channel2, $channel3));
|
||||
$expect = '<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel><title>channel1</title></channel>
|
||||
<channel><title>channel2</title></channel>
|
||||
<channel><title>channel3</title></channel>
|
||||
</rss>
|
||||
';
|
||||
$this->assertXmlStringEqualsXmlString($expect, $feed);
|
||||
}
|
||||
}
|
||||
186
vendor/suin/php-rss-writer/Tests/Suin/RSSWriter/ItemTest.php
vendored
Normal file
186
vendor/suin/php-rss-writer/Tests/Suin/RSSWriter/ItemTest.php
vendored
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
<?php
|
||||
|
||||
namespace Suin\RSSWriter;
|
||||
|
||||
class ItemTest extends \XoopsUnit\TestCase
|
||||
{
|
||||
private $channelInterface = '\Suin\RSSWriter\ChannelInterface';
|
||||
|
||||
public function testTitle()
|
||||
{
|
||||
$title = uniqid();
|
||||
$item = new Item();
|
||||
$this->assertSame($item, $item->title($title));
|
||||
$this->assertAttributeSame($title, 'title', $item);
|
||||
}
|
||||
|
||||
public function testUrl()
|
||||
{
|
||||
$url = uniqid();
|
||||
$item = new Item();
|
||||
$this->assertSame($item, $item->url($url));
|
||||
$this->assertAttributeSame($url, 'url', $item);
|
||||
}
|
||||
|
||||
public function testDescription()
|
||||
{
|
||||
$description = uniqid();
|
||||
$item = new Item();
|
||||
$this->assertSame($item, $item->description($description));
|
||||
$this->assertAttributeSame($description, 'description', $item);
|
||||
}
|
||||
|
||||
public function testCategory()
|
||||
{
|
||||
$category = uniqid();
|
||||
$item = new Item();
|
||||
$this->assertSame($item, $item->category($category));
|
||||
$this->assertAttributeSame(array(
|
||||
array($category, null),
|
||||
), 'categories', $item);
|
||||
}
|
||||
|
||||
public function testCategory_with_domain()
|
||||
{
|
||||
$category = uniqid();
|
||||
$domain = uniqid();
|
||||
$item = new Item();
|
||||
$this->assertSame($item, $item->category($category, $domain));
|
||||
$this->assertAttributeSame(array(
|
||||
array($category, $domain),
|
||||
), 'categories', $item);
|
||||
}
|
||||
|
||||
public function testGuid()
|
||||
{
|
||||
$guid = uniqid();
|
||||
$item = new Item();
|
||||
$this->assertSame($item, $item->guid($guid));
|
||||
$this->assertAttributeSame($guid, 'guid', $item);
|
||||
}
|
||||
|
||||
public function testGuid_with_permalink()
|
||||
{
|
||||
$item = new Item();
|
||||
$item->guid('guid', true);
|
||||
$this->assertAttributeSame(true, 'isPermalink', $item);
|
||||
|
||||
$item->guid('guid', false);
|
||||
$this->assertAttributeSame(false, 'isPermalink', $item);
|
||||
|
||||
$item->guid('guid'); // default
|
||||
$this->assertAttributeSame(false, 'isPermalink', $item);
|
||||
}
|
||||
|
||||
public function testPubDate()
|
||||
{
|
||||
$pubDate = mt_rand(1000000, 9999999);
|
||||
$item = new Item();
|
||||
$this->assertSame($item, $item->pubDate($pubDate));
|
||||
$this->assertAttributeSame($pubDate, 'pubDate', $item);
|
||||
}
|
||||
|
||||
public function testAppendTo()
|
||||
{
|
||||
$item = new Item();
|
||||
$channel = $this->getMock($this->channelInterface);
|
||||
$channel->expects($this->once())->method('addItem')->with($item);
|
||||
$this->assertSame($item, $item->appendTo($channel));
|
||||
}
|
||||
|
||||
public function testAsXML()
|
||||
{
|
||||
$now = time();
|
||||
$nowString = date(DATE_RSS, $now);
|
||||
|
||||
$data = array(
|
||||
'title' => "Venice Film Festival Tries to Quit Sinking",
|
||||
'url' => 'http://nytimes.com/2004/12/07FEST.html',
|
||||
'description' => "Some of the most heated chatter at the Venice Film Festival this week was about the way that the arrival of the stars at the Palazzo del Cinema was being staged.",
|
||||
'categories' => array(
|
||||
array("Grateful Dead", null),
|
||||
array("MSFT", 'http://www.fool.com/cusips'),
|
||||
),
|
||||
'guid' => "http://inessential.com/2002/09/01.php#a2",
|
||||
'isPermalink' => true,
|
||||
'pubDate' => $now,
|
||||
);
|
||||
|
||||
$item = new Item();
|
||||
|
||||
foreach ( $data as $key => $value )
|
||||
{
|
||||
$this->reveal($item)->attr($key, $value);
|
||||
}
|
||||
|
||||
$expect ="
|
||||
<item>
|
||||
<title>{$data['title']}</title>
|
||||
<link>{$data['url']}</link>
|
||||
<description>{$data['description']}</description>
|
||||
<category>{$data['categories'][0][0]}</category>
|
||||
<category domain=\"{$data['categories'][1][1]}\">{$data['categories'][1][0]}</category>
|
||||
<guid isPermaLink=\"true\">{$data['guid']}</guid>
|
||||
<pubDate>{$nowString}</pubDate>
|
||||
</item>
|
||||
";
|
||||
$this->assertXmlStringEqualsXmlString($expect, $item->asXML()->asXML());
|
||||
}
|
||||
|
||||
public function testAsXML_test_Japanese()
|
||||
{
|
||||
$now = time();
|
||||
$nowString = date(DATE_RSS, $now);
|
||||
|
||||
$data = array(
|
||||
'title' => "日本語",
|
||||
'url' => 'http://nytimes.com/2004/12/07FEST.html',
|
||||
'description' => "Some of the most heated chatter at the Venice Film Festival this week was about the way that the arrival of the stars at the Palazzo del Cinema was being staged.",
|
||||
);
|
||||
|
||||
$item = new Item();
|
||||
|
||||
foreach ( $data as $key => $value )
|
||||
{
|
||||
$this->reveal($item)->attr($key, $value);
|
||||
}
|
||||
|
||||
$expect = "
|
||||
<item>
|
||||
<title>{$data['title']}</title>
|
||||
<link>{$data['url']}</link>
|
||||
<description>{$data['description']}</description>
|
||||
</item>
|
||||
";
|
||||
|
||||
$this->assertXmlStringEqualsXmlString($expect, $item->asXML()->asXML());
|
||||
}
|
||||
|
||||
public function test_with_amp()
|
||||
{
|
||||
$item = new Item();
|
||||
$item
|
||||
->title('test&test')
|
||||
->url('url&url')
|
||||
->description('desc&desc');
|
||||
$expect = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item><title>test&test</title><link>url&url</link><description>desc&desc</description></item>
|
||||
';
|
||||
|
||||
$this->assertSame($expect, $item->asXML()->asXML());
|
||||
}
|
||||
|
||||
public function test_fail_safe_against_invalid_string()
|
||||
{
|
||||
$item = new Item();
|
||||
$item
|
||||
->title("test\0test")
|
||||
->url("url\0test")
|
||||
->description("desc\0desc");
|
||||
$expect = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item><title>test</title><link>url</link><description>desc</description></item>
|
||||
';
|
||||
|
||||
$this->assertSame($expect, $item->asXML()->asXML());
|
||||
}
|
||||
}
|
||||
12
vendor/suin/php-rss-writer/Tests/composer.json
vendored
Normal file
12
vendor/suin/php-rss-writer/Tests/composer.json
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"config": {
|
||||
"bin-dir": ".",
|
||||
"vendor-dir": "Vendor"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2",
|
||||
"EHER/PHPUnit": ">=1.6",
|
||||
"suin/xoopsunit": ">=1.2",
|
||||
"mockery/mockery": ">=0.7.2"
|
||||
}
|
||||
}
|
||||
42
vendor/suin/php-rss-writer/Tests/phpunit.xml.dist
vendored
Normal file
42
vendor/suin/php-rss-writer/Tests/phpunit.xml.dist
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
bootstrap="Bootstrap.php"
|
||||
processIsolation="false"
|
||||
verbose="true"
|
||||
strict="false"
|
||||
colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="PHPUnit">
|
||||
<directory>Suin</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<logging>
|
||||
<log
|
||||
type="coverage-html"
|
||||
target="Coverage"
|
||||
charset="UTF-8"
|
||||
yui="true"
|
||||
highlight="false"
|
||||
lowUpperBound="35"
|
||||
highLowerBound="70" />
|
||||
<!-- <log type="coverage-text" target="php://stdout" lowUpperBound="35" highLowerBound="70" /> -->
|
||||
</logging>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">../Source</directory>
|
||||
<!-- <file>/path/to/file</file> -->
|
||||
<exclude>
|
||||
<file>../Public/index.php</file>
|
||||
<directory suffix="Interface.php">../Source</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
<blacklist>
|
||||
<directory suffix=".php" group="PHPUNIT">../Vendor</directory>
|
||||
</blacklist>
|
||||
</filter>
|
||||
<listeners>
|
||||
<listener class="\Mockery\Adapter\Phpunit\TestListener" file="Vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php" />
|
||||
</listeners>
|
||||
</phpunit>
|
||||
20
vendor/suin/php-rss-writer/composer.json
vendored
Normal file
20
vendor/suin/php-rss-writer/composer.json
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "suin/php-rss-writer",
|
||||
"type": "library",
|
||||
"description": "Yet another simple RSS writer library for PHP 5.3 or later.",
|
||||
"keywords": ["rss", "generator", "writer", "feed"],
|
||||
"homepage": "https://github.com/suin/php-rss-writer",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Hidehito Nozawa aka Suin",
|
||||
"email": "suinyeze@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Suin\\RSSWriter": "Source" }
|
||||
}
|
||||
}
|
||||
35
vendor/suin/php-rss-writer/example.php
vendored
Normal file
35
vendor/suin/php-rss-writer/example.php
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
// Load test target classes
|
||||
spl_autoload_register(function($c) { @include_once strtr($c, '\\_', '//').'.php'; });
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__.'/Source');
|
||||
|
||||
use \Suin\RSSWriter\Feed;
|
||||
use \Suin\RSSWriter\Channel;
|
||||
use \Suin\RSSWriter\Item;
|
||||
|
||||
$feed = new Feed();
|
||||
|
||||
$channel = new Channel();
|
||||
$channel
|
||||
->title("Channel Title")
|
||||
->description("Channel Description")
|
||||
->url('http://blog.example.com')
|
||||
->language('en-US')
|
||||
->copyright('Copyright 2012, Foo Bar')
|
||||
->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
|
||||
->lastBuildDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
|
||||
->ttl(60)
|
||||
->appendTo($feed);
|
||||
|
||||
$item = new Item();
|
||||
$item
|
||||
->title("Blog Entry Title")
|
||||
->description("<div>Blog body</div>")
|
||||
->url('http://blog.example.com/2012/08/21/blog-entry/')
|
||||
->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
|
||||
->guid('http://blog.example.com/2012/08/21/blog-entry/', true)
|
||||
->appendTo($channel);
|
||||
|
||||
|
||||
echo $feed; // or echo $feed->render();
|
||||
Loading…
Add table
Add a link
Reference in a new issue