Skip to content

Commit

Permalink
Merge pull request #3 from splitbrain-forks/master
Browse files Browse the repository at this point in the history
PSR1/2 reformatting
  • Loading branch information
flack committed May 18, 2017
2 parents 6a75dbf + 3707dc5 commit 6261e13
Show file tree
Hide file tree
Showing 29 changed files with 822 additions and 618 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# PHP PSR-2 Coding Standards
# http://www.php-fig.org/psr/psr-2/

root = true

[*.php]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

104 changes: 55 additions & 49 deletions lib/Creator/AtomCreator03.php
Original file line number Diff line number Diff line change
@@ -1,89 +1,95 @@
<?php

/**
* AtomCreator03 is a FeedCreator that implements the atom specification,
* as in http://www.intertwingly.net/wiki/pie/FrontPage.
* Please note that just by using AtomCreator03 you won't automatically
* produce valid atom files. For example, you have to specify either an editor
* for the feed or an author for every single feed item.
*
* Some elements have not been implemented yet. These are (incomplete list):
* author URL, item author's email and URL, item contents, alternate links,
* other link content types than text/html. Some of them may be created with
* AtomCreator03::additionalElements.
*
* @see FeedCreator#additionalElements
* @since 1.6
* @author Kai Blankenhorn <kaib@bitfolge.de>, Scott Reynen <scott@randomchaos.com>
* @see FeedCreator#additionalElements
* @since 1.6
* @author Kai Blankenhorn <kaib@bitfolge.de>, Scott Reynen <scott@randomchaos.com>
* @package de.bitfolge.feedcreator
*/
class AtomCreator03 extends FeedCreator {
class AtomCreator03 extends FeedCreator
{

/**
* AtomCreator03 constructor.
*/
public function __construct() {
public function __construct()
{
$this->contentType = "application/atom+xml";
$this->encoding = "utf-8";
}

/** @inheritdoc */
public function createFeed() {
public function createFeed()
{
$feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n";
$feed.= $this->_createGeneratorComment();
$feed.= $this->_createStylesheetReferences();
$feed.= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\"";
if ($this->format=='TOOLBAR') {
$feed.= " xmlns:gtb=\"http://toolbar.google.com/custombuttons/\"";
$feed .= $this->_createGeneratorComment();
$feed .= $this->_createStylesheetReferences();
$feed .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\"";
if ($this->format == 'TOOLBAR') {
$feed .= " xmlns:gtb=\"http://toolbar.google.com/custombuttons/\"";
}
if ($this->language!="") {
$feed.= " xml:lang=\"".$this->language."\"";
if ($this->language != "") {
$feed .= " xml:lang=\"".$this->language."\"";
}
$feed.= ">\n";
$feed.= " <title>".htmlspecialchars($this->title)."</title>\n";
$feed.= " <tagline>".htmlspecialchars($this->description)."</tagline>\n";
$feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\"/>\n";
$feed.= " <id>".htmlspecialchars($this->link)."</id>\n";
$feed .= ">\n";
$feed .= " <title>".htmlspecialchars($this->title)."</title>\n";
$feed .= " <tagline>".htmlspecialchars($this->description)."</tagline>\n";
$feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\"/>\n";
$feed .= " <id>".htmlspecialchars($this->link)."</id>\n";
$now = new FeedDate();
$feed.= " <modified>".htmlspecialchars($now->iso8601())."</modified>\n";
if ($this->editor!="") {
$feed.= " <author>\n";
$feed.= " <name>".$this->editor."</name>\n";
if ($this->editorEmail!="") {
$feed.= " <email>".$this->editorEmail."</email>\n";
$feed .= " <modified>".htmlspecialchars($now->iso8601())."</modified>\n";
if ($this->editor != "") {
$feed .= " <author>\n";
$feed .= " <name>".$this->editor."</name>\n";
if ($this->editorEmail != "") {
$feed .= " <email>".$this->editorEmail."</email>\n";
}
$feed.= " </author>\n";
$feed .= " </author>\n";
}
$feed.= " <generator>".FEEDCREATOR_VERSION."</generator>\n";
$feed.= $this->_createAdditionalElements($this->additionalElements, " ");
for ($i=0;$i<count($this->items);$i++) {
$feed.= " <entry>\n";
$feed.= " <title>".htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n";
$feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n";
if ($this->items[$i]->date=="") {
$feed .= " <generator>".FEEDCREATOR_VERSION."</generator>\n";
$feed .= $this->_createAdditionalElements($this->additionalElements, " ");
for ($i = 0; $i < count($this->items); $i++) {
$feed .= " <entry>\n";
$feed .= " <title>".htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n";
$feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars(
$this->items[$i]->link
)."\"/>\n";
if ($this->items[$i]->date == "") {
$this->items[$i]->date = time();
}
$itemDate = new FeedDate($this->items[$i]->date);
$feed.= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n";
$feed.= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n";
$feed.= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n";
$feed.= " <id>".htmlspecialchars($this->items[$i]->link)."</id>\n";
$feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " ");
if ($this->items[$i]->author!="") {
$feed.= " <author>\n";
$feed.= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n";
$feed.= " </author>\n";
$feed .= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n";
$feed .= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n";
$feed .= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n";
$feed .= " <id>".htmlspecialchars($this->items[$i]->link)."</id>\n";
$feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, " ");
if ($this->items[$i]->author != "") {
$feed .= " <author>\n";
$feed .= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n";
$feed .= " </author>\n";
}
if ($this->items[$i]->description!="") {
$feed.= " <summary>".htmlspecialchars($this->items[$i]->description)."</summary>\n";
if ($this->items[$i]->description != "") {
$feed .= " <summary>".htmlspecialchars($this->items[$i]->description)."</summary>\n";
}
if (isset($this->items[$i]->thumbdata)) {
$feed.= " <gtb:icon mode=\"base64\" type=\"image/jpeg\">\n";
$feed.= chunk_split(base64_encode($this->items[$i]->thumbdata))."\n";
$feed.= " </gtb:icon>\n";
$feed .= " <gtb:icon mode=\"base64\" type=\"image/jpeg\">\n";
$feed .= chunk_split(base64_encode($this->items[$i]->thumbdata))."\n";
$feed .= " </gtb:icon>\n";
}
$feed.= " </entry>\n";
$feed .= " </entry>\n";
}
$feed.= "</feed>\n";
$feed .= "</feed>\n";

return $feed;
}
}

0 comments on commit 6261e13

Please sign in to comment.