Skip to content

Commit

Permalink
fix suppression of html parsing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaudiomv committed Oct 28, 2023
1 parent a6d8438 commit 77241de
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 35 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.0.6 (October 28, 2023)
* Fix suppression of html parsing warnings.

## 1.0.5 (October 28, 2023)
* Fix for PHP 8.1 compatibility, rm readonly class.

Expand Down
6 changes: 3 additions & 3 deletions src/FetchMeditation/EnglishJFT.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public function getLanguage(): JFTLanguage

public function fetch(): JFTEntry
{
libxml_use_internal_errors(true);
$data = HttpUtility::httpGet('https://www.jftna.org/jft/');
$doc = new \DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML('<?xml encoding="UTF-8">' . $data);
libxml_clear_errors();
libxml_use_internal_errors(false);
$doc = new \DOMDocument();
$doc->loadHTML('<?xml encoding="UTF-8">' . $data);
$jftKeys = ['date', 'title', 'page', 'quote', 'source', 'content', 'thought', 'copyright'];
$result = [];
foreach ($doc->getElementsByTagName('td') as $i => $td) {
Expand Down
7 changes: 4 additions & 3 deletions src/FetchMeditation/EnglishSPAD.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ public function getLanguage(): SPADLanguage

public function fetch(): SPADEntry
{
libxml_use_internal_errors(true);

$data = HttpUtility::httpGet('https://spadna.org');
$doc = new \DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML('<?xml encoding="UTF-8">' . $data);
libxml_clear_errors();
libxml_use_internal_errors(false);
$doc = new \DOMDocument();
$doc->loadHTML($data);
$spadKeys = ['date', 'title', 'page', 'quote', 'source', 'content', 'divider', 'thought', 'copyright'];
$result = [];
foreach ($doc->getElementsByTagName('td') as $i => $td) {
Expand Down
2 changes: 1 addition & 1 deletion src/FetchMeditation/FrenchJFT.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public function getLanguage(): JFTLanguage

public function fetch(): JFTEntry
{
libxml_use_internal_errors(true);
$data = HttpUtility::httpGet('https://jpa.narcotiquesanonymes.org/');
$doc = new \DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML('<?xml encoding="UTF-8">' . $data);
libxml_clear_errors();
libxml_use_internal_errors(false);
Expand Down
2 changes: 1 addition & 1 deletion src/FetchMeditation/ItalianJFT.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public function getLanguage(): JFTLanguage

public function fetch(): JFTEntry
{
libxml_use_internal_errors(true);
$data = HttpUtility::httpGet('https://na-italia.org/get-jft');
$data = json_decode($data, true)[0];
$doc = new \DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML('<?xml encoding="UTF-8">' . $data['content']);
libxml_clear_errors();
libxml_use_internal_errors(false);
Expand Down
2 changes: 1 addition & 1 deletion src/FetchMeditation/JapaneseJFT.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public function getLanguage(): JFTLanguage

public function fetch(): JFTEntry
{
libxml_use_internal_errors(true);
$data = HttpUtility::httpGet('https://najapan.org/just_for_today/');
$doc = new \DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML('<?xml encoding="UTF-8">' . $data);
libxml_clear_errors();
libxml_use_internal_errors(false);
Expand Down
4 changes: 2 additions & 2 deletions src/FetchMeditation/PortugueseJFT.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public function getLanguage(): JFTLanguage

public function fetch(): JFTEntry
{
libxml_use_internal_errors(true);
$data = HttpUtility::httpGet('https://www.na.org.br/meditacao/');
$doc = new \DOMDocument();
$doc->loadHTML($data);
libxml_use_internal_errors(true);
$doc->loadHTML('<?xml encoding="UTF-8">' . $data);
libxml_clear_errors();
libxml_use_internal_errors(false);
$xpath = new \DOMXPath($doc);
Expand Down
4 changes: 2 additions & 2 deletions src/FetchMeditation/RussianJFT.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public function getLanguage(): JFTLanguage

public function fetch(): JFTEntry
{
libxml_use_internal_errors(true);
$data = HttpUtility::httpGet('https://na-russia.org/eg');
$doc = new \DOMDocument();
$doc->loadHTML('<?xml encoding="UTF-8">' . $data);
libxml_use_internal_errors(true);
$doc->loadHTML('<?xml encoding="UTF-8">' . $data);
libxml_clear_errors();
libxml_use_internal_errors(false);
$jftKeys = ['date', 'title', 'quote', 'source', 'content', 'thought', 'page'];
Expand Down
2 changes: 1 addition & 1 deletion src/FetchMeditation/SpanishJFT.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public function getLanguage(): JFTLanguage

public function fetch(): JFTEntry
{
libxml_use_internal_errors(true);
$timezone = new \DateTimeZone('America/Mexico_City');
$date = new \DateTime('now', $timezone);
$data = HttpUtility::httpGet('https://forozonalatino.org/wp-content/uploads/meditaciones/' . $date->format('m/d') . '.html');
$doc = new \DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML('<?xml encoding="ISO-8859-1">' . $data);
libxml_clear_errors();
libxml_use_internal_errors(false);
Expand Down
2 changes: 1 addition & 1 deletion src/FetchMeditation/SwedishJFT.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public function getLanguage(): JFTLanguage

public function fetch(): JFTEntry
{
libxml_use_internal_errors(true);
$data = HttpUtility::httpGet('https://www.nasverige.org/dagens-text/');
$doc = new \DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML('<?xml encoding="UTF-8">' . $data);
libxml_clear_errors();
libxml_use_internal_errors(false);
Expand Down
40 changes: 20 additions & 20 deletions test.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@



//foreach (JFTLanguage::cases() as $shape) {
// if ($shape->name == 'French') {
// continue;
// }
// echo "\n\n-=-=-=-=-=-=-=-= JFT - $shape->name -=-=-=-=-=-=-=-=\n\n";
// $settings = new JFTSettings($shape);
// $jft = JFT::getInstance($settings);
// $entry = $jft->fetch();
// print_r($entry->quote);
// echo "-- " . $jft->getLanguage()->name;
//}
//
//foreach (SPADLanguage::cases() as $shape) {
// echo "\n\n-=-=-=-=-=-=-=-= SPAD - $shape->name -=-=-=-=-=-=-=-=\n\n";
// $settings = new SPADSettings($shape);
// $spad = SPAD::getInstance($settings);
// $entry = $spad->fetch();
// print_r($entry->quote);
// echo "-- " . $spad->getLanguage()->name;
//}
foreach (JFTLanguage::cases() as $shape) {
if ($shape->name == 'French') {
continue;
}
echo "\n\n-=-=-=-=-=-=-=-= JFT - $shape->name -=-=-=-=-=-=-=-=\n\n";
$settings = new JFTSettings($shape);
$jft = JFT::getInstance($settings);
$entry = $jft->fetch();
print_r($entry->quote);
echo "-- " . $jft->getLanguage()->name;
}

foreach (SPADLanguage::cases() as $shape) {
echo "\n\n-=-=-=-=-=-=-=-= SPAD - $shape->name -=-=-=-=-=-=-=-=\n\n";
$settings = new SPADSettings($shape);
$spad = SPAD::getInstance($settings);
$entry = $spad->fetch();
print_r($entry->quote);
echo "-- " . $spad->getLanguage()->name;
}

0 comments on commit 77241de

Please sign in to comment.