...
|
...
|
@@ -1,6 +1,25 @@
|
1
|
1
|
<?php
|
2
|
2
|
include_once( 'news-constants.php' );
|
3
|
3
|
|
|
4
|
+
|
|
5
|
+function getElementByClass(&$parentNode, $tagName, $className, $offset = 0) {
|
|
6
|
+ $response = false;
|
|
7
|
+ $childNodeList = $parentNode->getElementsByTagName($tagName);
|
|
8
|
+ $tagCount = 0;
|
|
9
|
+ for ($i = 0; $i < $childNodeList->length; $i++) {
|
|
10
|
+ $temp = $childNodeList->item($i);
|
|
11
|
+ if (stripos($temp->getAttribute('class'), $className) !== false) {
|
|
12
|
+ if ($tagCount == $offset) {
|
|
13
|
+ $response = $temp;
|
|
14
|
+ break;
|
|
15
|
+ }
|
|
16
|
+ $tagCount++;
|
|
17
|
+ }
|
|
18
|
+ }
|
|
19
|
+ return $response;
|
|
20
|
+}
|
|
21
|
+
|
|
22
|
+
|
4
|
23
|
$rss_content = http_get_contents(NEWS_RSS_SLATEFR);
|
5
|
24
|
$xml = simplexml_load_string($rss_content);
|
6
|
25
|
if ($xml === false) {
|
...
|
...
|
@@ -26,35 +45,33 @@ if ($xml === false) {
|
26
|
45
|
$article['description'] = $item->description;
|
27
|
46
|
$article['image'] = $item->enclosure['url'];
|
28
|
47
|
$articles[$cpt] = $article;
|
29
|
|
- echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
|
30
|
|
- echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>';
|
31
|
|
- echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> ';
|
|
48
|
+ echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">'.PHP_EOL;
|
|
49
|
+ echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>'.PHP_EOL;
|
|
50
|
+ echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> '.PHP_EOL;
|
32
|
51
|
echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div> ';
|
33
|
|
- echo $article['title'].' ';
|
34
|
|
- echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>';
|
|
52
|
+ echo $article['title'].' '.PHP_EOL;
|
|
53
|
+ echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>'.PHP_EOL;
|
35
|
54
|
$cpt++;
|
36
|
55
|
if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
|
37
|
56
|
break;
|
38
|
57
|
}
|
39
|
58
|
}
|
40
|
59
|
}
|
41
|
|
-echo '</div><!-- ./panel-body -->';
|
42
|
|
-echo '</div><!-- ./panel panel-default -->';
|
43
|
|
-echo '</div><!-- ./col-md-6 -->';
|
44
|
|
-echo "\n<!-- ==================== menu end ============== -->\n";
|
45
|
|
-echo '<div class="col-md-6">';
|
46
|
|
-echo '<div class="panel panel-default">';
|
47
|
|
-echo '<div class="panel-body">';
|
48
|
|
-echo '<a name="article-top"></a><div id="article-current"></div>';
|
|
60
|
+echo '</div><!-- ./panel-body -->'.PHP_EOL;
|
|
61
|
+echo '</div><!-- ./panel panel-default -->'.PHP_EOL;
|
|
62
|
+echo '</div><!-- ./col-md-6 -->'.PHP_EOL;
|
|
63
|
+echo '<div class="col-md-6">'.PHP_EOL;
|
|
64
|
+echo '<div class="panel panel-default">'.PHP_EOL;
|
|
65
|
+echo '<div class="panel-body">'.PHP_EOL;
|
|
66
|
+echo '<a name="article-top"></a><div id="article-current"></div>'.PHP_EOL;
|
49
|
67
|
$cpt=0;
|
50
|
68
|
foreach ($articles as $article ) {
|
51
|
69
|
$cpt_prev=$cpt-1;
|
52
|
70
|
$cpt_next=$cpt+1;
|
53
|
|
- echo "\n<!-- ==================== article '.$cpt.'============== -->\n";
|
|
71
|
+ echo PHP_EOL.PHP_EOL."<!-- ==================== article '.$cpt.'============== -->".PHP_EOL;
|
54
|
72
|
echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
|
55
|
73
|
echo "<hr><a name=\"article-$cpt\">\n";
|
56
|
|
- //$article_content = file_get_contents($article['link']);
|
57
|
|
- $article_content = http_get_contents($article['link']);
|
|
74
|
+ $article_content = file_get_contents($article['link']);
|
58
|
75
|
$doc = new DOMDocument();
|
59
|
76
|
$doc->preserveWhiteSpace = false;
|
60
|
77
|
$doc->formatOutput = true;
|
...
|
...
|
@@ -67,6 +84,17 @@ foreach ($articles as $article ) {
|
67
|
84
|
foreach ( $articles as $node) {
|
68
|
85
|
$article_only = DOMinnerHTML($node);
|
69
|
86
|
}
|
|
87
|
+ DEBUG("Article($cpt) : length = ".strlen($article_only));
|
|
88
|
+ $isPortfolio=false;
|
|
89
|
+ if( 0 == strlen($article_only) ) {
|
|
90
|
+ //<div class="layout layout--portfolio">
|
|
91
|
+ $node = getElementByClass($doc, 'div', 'layout layout--portfolio', $offset = 0);
|
|
92
|
+ if( false !== $node ) {
|
|
93
|
+ //Article is a portfolio
|
|
94
|
+ $article_only = DOMinnerHTML($node);
|
|
95
|
+ $isPortfolio=true;
|
|
96
|
+ }
|
|
97
|
+ }
|
70
|
98
|
|
71
|
99
|
$orgStrings = array( ' href="/',
|
72
|
100
|
' src="/sites/',
|
...
|
...
|
@@ -165,6 +193,15 @@ foreach ($articles as $article ) {
|
165
|
193
|
$article_only = $temp;
|
166
|
194
|
}
|
167
|
195
|
|
|
196
|
+ //Portfolio specific
|
|
197
|
+ if($isPortfolio) {
|
|
198
|
+ $re = '/<img class="cover parallax-enable fit lazyload" data-speed="2" data-full-src="(.+?)" alt="(.+?)">/';
|
|
199
|
+ $temp = preg_replace($re, '<img src="\\1" alt="\\2">', $article_only );
|
|
200
|
+ $article_only = $temp;
|
|
201
|
+ $re = '/" width="(.+)" height="(.+)">/';
|
|
202
|
+ $temp = preg_replace($re, '>', $article_only );
|
|
203
|
+ $article_only = $temp;
|
|
204
|
+ }
|
168
|
205
|
//Force HTTPS
|
169
|
206
|
$article_only = add_https($article_only, 'www.twitter.com');
|
170
|
207
|
$article_only = add_https($article_only, 'www.facebook.com');
|
...
|
...
|
@@ -202,3 +239,4 @@ foreach ($articles as $article ) {
|
202
|
239
|
}
|
203
|
240
|
}
|
204
|
241
|
?>
|
|
242
|
+
|