From 4260be26a234ab0d7d1724d1853ee29a9bf9a7be Mon Sep 17 00:00:00 2001 From: Korytov Pavel Date: Sun, 5 Jun 2022 19:40:48 +0300 Subject: [PATCH] [EconomistWorldInBriefBridge] indent with tabs instead of spaces (#2781) --- bridges/EconomistWorldInBriefBridge.php | 258 ++++++++++++------------ 1 file changed, 129 insertions(+), 129 deletions(-) diff --git a/bridges/EconomistWorldInBriefBridge.php b/bridges/EconomistWorldInBriefBridge.php index 02407cf9..33240f6e 100644 --- a/bridges/EconomistWorldInBriefBridge.php +++ b/bridges/EconomistWorldInBriefBridge.php @@ -1,141 +1,141 @@ array( - 'splitGobbets' => array( - 'name' => 'Split the short stories', - 'type' => 'checkbox', - 'defaultValue' => false, - 'title' => 'Whether to split the short stories into separate entries' - ), - 'limit' => array( - 'name' => 'Truncate headers for the short stories', - 'type' => 'number', - 'defaultValue' => 100 - ), - 'agenda' => array( - 'name' => 'Add agenda for the day', - 'type' => 'checkbox', - 'defaultValue' => 'checked' - ), - 'agendaPictures' => array( - 'name' => 'Include pictures to the agenda', - 'type' => 'checkbox', - 'defaultValue' => 'checked' - ), - 'quote' => array( - 'name' => 'Include the quote of the day', - 'type' => 'checkbox' - ) - ) - ); + const PARAMETERS = array( + '' => array( + 'splitGobbets' => array( + 'name' => 'Split the short stories', + 'type' => 'checkbox', + 'defaultValue' => false, + 'title' => 'Whether to split the short stories into separate entries' + ), + 'limit' => array( + 'name' => 'Truncate headers for the short stories', + 'type' => 'number', + 'defaultValue' => 100 + ), + 'agenda' => array( + 'name' => 'Add agenda for the day', + 'type' => 'checkbox', + 'defaultValue' => 'checked' + ), + 'agendaPictures' => array( + 'name' => 'Include pictures to the agenda', + 'type' => 'checkbox', + 'defaultValue' => 'checked' + ), + 'quote' => array( + 'name' => 'Include the quote of the day', + 'type' => 'checkbox' + ) + ) + ); - public function collectData() - { - $html = getSimpleHTMLDOM(self::URI); - $gobbets = $html->find('._gobbets', 0); - if ($this->getInput('splitGobbets') == 1) { - $this->splitGobbets($gobbets); - } else { - $this->mergeGobbets($gobbets); - }; - if ($this->getInput('agenda') == 1) { - $articles = $html->find('._articles', 0); - $this->collectArticles($articles); - } - if ($this->getInput('quote') == 1) { - $quote = $html->find('._quote-container', 0); - $this->addQuote($quote); - } - } + public function collectData() + { + $html = getSimpleHTMLDOM(self::URI); + $gobbets = $html->find('._gobbets', 0); + if ($this->getInput('splitGobbets') == 1) { + $this->splitGobbets($gobbets); + } else { + $this->mergeGobbets($gobbets); + }; + if ($this->getInput('agenda') == 1) { + $articles = $html->find('._articles', 0); + $this->collectArticles($articles); + } + if ($this->getInput('quote') == 1) { + $quote = $html->find('._quote-container', 0); + $this->addQuote($quote); + } + } - private function splitGobbets($gobbets) - { - $today = new Datetime(); - $today->setTime(0, 0, 0, 0); - $limit = $this->getInput('limit'); - foreach ($gobbets->find('._gobbet') as $gobbet) { - $title = $gobbet->plaintext; - $match = preg_match('/[\.,]/', $title, $matches, PREG_OFFSET_CAPTURE); - if ($match > 0) { - $point = $matches[0][1]; - $title = mb_substr($title, 0, $point); - } - if ($limit && mb_strlen($title) > $limit) { - $title = mb_substr($title, 0, $limit) . '...'; - } - $item = array( - 'uri' => self::URI, - 'title' => $title, - 'content' => $gobbet->innertext, - 'timestamp' => $today->format('U'), - 'uid' => md5($gobbet->plaintext) - ); - $this->items[] = $item; - } - } + private function splitGobbets($gobbets) + { + $today = new Datetime(); + $today->setTime(0, 0, 0, 0); + $limit = $this->getInput('limit'); + foreach ($gobbets->find('._gobbet') as $gobbet) { + $title = $gobbet->plaintext; + $match = preg_match('/[\.,]/', $title, $matches, PREG_OFFSET_CAPTURE); + if ($match > 0) { + $point = $matches[0][1]; + $title = mb_substr($title, 0, $point); + } + if ($limit && mb_strlen($title) > $limit) { + $title = mb_substr($title, 0, $limit) . '...'; + } + $item = array( + 'uri' => self::URI, + 'title' => $title, + 'content' => $gobbet->innertext, + 'timestamp' => $today->format('U'), + 'uid' => md5($gobbet->plaintext) + ); + $this->items[] = $item; + } + } - private function mergeGobbets($gobbets) - { - $today = new Datetime(); - $today->setTime(0, 0, 0, 0); - $contents = ''; - foreach ($gobbets->find('._gobbet') as $gobbet) { - $contents .= "

{$gobbet->innertext}"; - } - $this->items[] = array( - 'uri' => self::URI, - 'title' => 'World in brief at ' . $today->format('Y.m.d'), - 'content' => $contents, - 'timestamp' => $today->format('U'), - 'uid' => 'world-in-brief-' . $today->format('U') - ); - } + private function mergeGobbets($gobbets) + { + $today = new Datetime(); + $today->setTime(0, 0, 0, 0); + $contents = ''; + foreach ($gobbets->find('._gobbet') as $gobbet) { + $contents .= "

{$gobbet->innertext}"; + } + $this->items[] = array( + 'uri' => self::URI, + 'title' => 'World in brief at ' . $today->format('Y.m.d'), + 'content' => $contents, + 'timestamp' => $today->format('U'), + 'uid' => 'world-in-brief-' . $today->format('U') + ); + } - private function collectArticles($articles) - { - $i = 0; - $today = new Datetime(); - $today->setTime(0, 0, 0, 0); - foreach ($articles->find('._article') as $article) { - $title = $article->find('._headline', 0)->plaintext; - $image = $article->find('._main-image', 0); - $content = $article->find('._content', 0); + private function collectArticles($articles) + { + $i = 0; + $today = new Datetime(); + $today->setTime(0, 0, 0, 0); + foreach ($articles->find('._article') as $article) { + $title = $article->find('._headline', 0)->plaintext; + $image = $article->find('._main-image', 0); + $content = $article->find('._content', 0); - $res_content = ''; - if ($image != null && $this->getInput('agendaPictures') == 1) { - $img = $image->find('img', 0); - $res_content .= ''; - } - $res_content .= $content->innertext; - $this->items[] = array( - 'uri' => self::URI, - 'title' => $title, - 'content' => $res_content, - 'timestamp' => $today->format('U'), - 'uid' => 'story-' . $today->format('U') . "{$i}", - ); - $i++; - } - } + $res_content = ''; + if ($image != null && $this->getInput('agendaPictures') == 1) { + $img = $image->find('img', 0); + $res_content .= ''; + } + $res_content .= $content->innertext; + $this->items[] = array( + 'uri' => self::URI, + 'title' => $title, + 'content' => $res_content, + 'timestamp' => $today->format('U'), + 'uid' => 'story-' . $today->format('U') . "{$i}", + ); + $i++; + } + } - private function addQuote($quote) { - $today = new Datetime(); - $today->setTime(0, 0, 0, 0); - $this->items[] = array( - 'uri' => self::URI, - 'title' => 'Quote of the day ' . $today->format('Y.m.d'), - 'content' => $quote->innertext, - 'timestamp' => $today->format('U'), - 'uid' => 'quote-' . $today->format('U') - ); - } + private function addQuote($quote) { + $today = new Datetime(); + $today->setTime(0, 0, 0, 0); + $this->items[] = array( + 'uri' => self::URI, + 'title' => 'Quote of the day ' . $today->format('Y.m.d'), + 'content' => $quote->innertext, + 'timestamp' => $today->format('U'), + 'uid' => 'quote-' . $today->format('U') + ); + } }