...
|
...
|
@@ -85,126 +85,16 @@ foreach ($articles as $article ) {
|
85
|
85
|
$article['image'] = $node->getAttribute('content');
|
86
|
86
|
}
|
87
|
87
|
}
|
88
|
|
-
|
89
|
|
- $isPortfolio=false;
|
90
|
|
- if( 0 == strlen($article_only) ) {
|
91
|
|
- //<div class="layout layout--portfolio">
|
92
|
|
- $node = getElementByClass($doc, 'div', 'layout layout--portfolio', $offset = 0);
|
93
|
|
- if( false !== $node ) {
|
94
|
|
- //Article is a portfolio
|
95
|
|
- $article_only = DOMinnerHTML($node);
|
96
|
|
- $isPortfolio=true;
|
97
|
|
- }
|
98
|
|
- }
|
99
|
|
-
|
100
|
|
- $orgStrings = array( ' href="/',
|
101
|
|
- ' src="/sites/',
|
102
|
|
- '-src="/sites/',
|
103
|
|
- '<img src=');
|
104
|
|
- $newStrings = array( ' href="http://www.slate.fr/',
|
105
|
|
- ' src="http://www.slate.fr/sites/',
|
106
|
|
- '-src="http://www.slate.fr/sites/',
|
107
|
|
- '<img width="100%" src=' );
|
|
88
|
+ $orgStrings = array(' href="/');
|
|
89
|
+ $newStrings = array(' href="https://www.nouvelobs.com/');
|
108
|
90
|
$article_only = str_replace($orgStrings, $newStrings, $article_only);
|
109
|
|
-
|
110
|
|
- $orgStrings = array( '<div class="row">',
|
111
|
|
- '<div class="col-md-2">',
|
112
|
|
- '<div class="col-md-8">',
|
113
|
|
- '<div class="container width_wrap">',
|
114
|
|
- '<div class="col-left">',
|
115
|
|
- '<div class="article-header__inner col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">',
|
116
|
|
- '<div class="content-left col-md-8 col-auto">',
|
117
|
|
- '<p class="article-header__infos article-infos">',
|
118
|
|
- '<div class="article-thumb-wrapper">',
|
119
|
|
- '<div class="article-thumb">',
|
120
|
|
- '<figure class="preload article-image">',
|
121
|
|
- '<div class="article-content row">',
|
122
|
|
- '<h3> </h3>',
|
123
|
|
- '<h1>',
|
124
|
|
- '</h1>',
|
125
|
|
- '<p style="text-align:center">' );
|
126
|
|
- $newStrings = array('<div>',
|
127
|
|
- '<div>',
|
128
|
|
- '<div>',
|
129
|
|
- '<div>',
|
130
|
|
- '<div>',
|
131
|
|
- '<div>',
|
132
|
|
- '<div>',
|
133
|
|
- '<p>',
|
134
|
|
- '<div>',
|
135
|
|
- '<div>',
|
136
|
|
- '<figure>',
|
137
|
|
- '<div>',
|
138
|
|
- '',
|
139
|
|
- '<h4>',
|
140
|
|
- '</h4>',
|
141
|
|
- '<p>');
|
142
|
|
- $article_only = str_replace($orgStrings, $newStrings, $article_only);
|
143
|
|
-
|
|
91
|
+
|
144
|
92
|
$temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
|
145
|
93
|
$article_only = $temp;
|
146
|
94
|
$temp = preg_replace('/\s\s+/', ' ', $article_only);
|
147
|
95
|
$article_only = $temp;
|
148
|
|
- $re = '/ style="height:(.+?)width: 640px;">/';
|
149
|
|
- $temp = preg_replace($re, '>', $article_only);
|
150
|
|
- $article_only = $temp;
|
151
|
|
- $re = '/<script>\(function \(\) \{var sasCallOptions = \{ siteId: 59629(.+?)<\/script>/';
|
152
|
|
- $temp = preg_replace($re, '', $article_only);
|
153
|
|
- $article_only = $temp;
|
154
|
|
- $re = '/<img data-file-id=(.+?)src="(.+?)"(.+?)>/';
|
155
|
|
- $temp = preg_replace($re, '<img width="100%" src="\\2">', $article_only);
|
156
|
|
- $article_only = $temp;
|
157
|
|
- $re='/<div class="media_embed" height="(.+?)" width="(.+?)">/';
|
158
|
|
- $temp = preg_replace($re, '<div>', $article_only);
|
159
|
|
- $article_only = $temp;
|
160
|
|
- $re='/<iframe allowfullscreen="" frameborder="0" height="(.+?)" src="(.+?)" width="(.+?)"><\/iframe>/';
|
161
|
|
- $temp = preg_replace($re, '<iframe frameborder="0" width="100%" src="\\2"></iframe>', $article_only);
|
162
|
|
- $article_only = $temp;
|
163
|
|
- $re='/<img width="100%" src="(.+?)" style="height:(.+?)width: (.+?)">/';
|
164
|
|
- $temp = preg_replace($re, '<img width="100%" src="\\1">', $article_only);
|
165
|
|
- $article_only = $temp;
|
166
|
|
- $re='/<div class="icon icon--(.+?)"> (.+)/';
|
167
|
|
- $temp = preg_replace($re, '<div>', $article_only);
|
168
|
|
- $article_only = $temp;
|
169
|
|
- $re='/<div class="article-header__breadcrumb">/';
|
170
|
|
- $temp = preg_replace($re, '<div>', $article_only);
|
171
|
|
- $article_only = $temp;
|
172
|
96
|
|
173
|
|
- $re='/<img class="image image--full lazyload" data-full-src=/';
|
174
|
|
- $temp = preg_replace($re, '<img width="100%" src=', $article_only);
|
175
|
|
- $article_only = $temp;
|
176
|
|
-
|
177
|
|
- $re='/<span class="sharing-btn__numbers">(.+)<\/span>/';
|
178
|
|
- $temp = preg_replace($re, '', $article_only);
|
179
|
|
- $article_only = $temp;
|
180
|
|
-
|
181
|
|
- $re='/<span class="sharing-btn__bg"><\/span>/';
|
182
|
|
- $temp = preg_replace($re, '', $article_only);
|
183
|
|
- $article_only = $temp;
|
184
|
|
-
|
185
|
|
- $re='/<script data-cfasync="false" src=(.+)<\/script><script>(.+?)<\/script>/';
|
186
|
|
- $temp = preg_replace($re, '', $article_only);
|
187
|
|
- $article_only = $temp;
|
188
|
|
-
|
189
|
|
- //Clean so called social
|
190
|
|
- $re='/<a data-share="(fb|li|tw)" data-url="(.+)"> <div>/';
|
191
|
|
- $temp = preg_replace($re, '<a><div>', $article_only);
|
192
|
|
- $article_only = $temp;
|
193
|
|
- $re='/<a class="sharing-btn sharing-btn--circle sharing-btn--whatsapp" href="whatsapp:(.+)> <div>/';
|
194
|
|
- $temp = preg_replace($re, '<a><div>', $article_only);
|
195
|
|
- $article_only = $temp;
|
196
|
|
- $re='/<a href="fb-messenger:(.+) class="sharing-btn sharing-btn--circle sharing-btn--messenger" target="_blank"> <div>/';
|
197
|
|
- $temp = preg_replace($re, '<a><div>', $article_only);
|
198
|
|
- $article_only = $temp;
|
199
|
|
- $re='/<a href="https:\/\/www\.facebook\.com\/dialog\/send(.+)target="_blank"> <div>/';
|
200
|
|
- $temp = preg_replace($re, '<a><div>', $article_only);
|
201
|
|
- $article_only = $temp;
|
202
|
|
- $re='/<div id="inreadbis" class="ad-wrapper"><span id="wrapper_inread"><div(.+)<\/div><\/span><\/div>/';
|
203
|
|
- $temp = preg_replace($re, '', $article_only);
|
204
|
|
- $article_only = $temp;
|
205
|
|
- $re='/<\/div> <\/a> <a><div>/';
|
206
|
|
- $temp = preg_replace($re, '',$article_only);
|
207
|
|
- $article_only = $temp;
|
|
97
|
+ $article_only = re_remove($article_only, '/ <footer class="ObsArticle-footer(.+?)">(.+?)<\/footer>/');
|
208
|
98
|
|
209
|
99
|
//Remove Emptylines
|
210
|
100
|
$temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
|
...
|
...
|
@@ -213,33 +103,13 @@ foreach ($articles as $article ) {
|
213
|
103
|
$article_only = $temp;
|
214
|
104
|
|
215
|
105
|
|
216
|
|
- $re='/<iframe allow="autoplay; encrypted-media" allowfullscreen="" frameborder="0" height="(.+?)" src="https:\/\/www\.youtube\.com\/embed\/(.+?)" width="(.+?)"><\/iframe>/';
|
217
|
|
- $temp = preg_replace($re, '<iframe allow="autoplay; encrypted-media" allowfullscreen="" frameborder="0" width="100%" src="https://www.youtube.com/embed/\\2"></iframe>', $article_only);
|
218
|
|
- $article_only = $temp;
|
219
|
|
-
|
220
|
|
- $SEARCH='<div class="sharing-tools sharing-tools--align-center">';
|
221
|
|
- $posend = strpos($article_only,$SEARCH);
|
222
|
|
- if($posend) {
|
223
|
|
- $temp = substr( $article_only, 0, $posend );
|
224
|
|
- $article_only = $temp;
|
225
|
|
- }
|
226
|
|
-
|
227
|
|
- //Portfolio specific
|
228
|
|
- if($isPortfolio) {
|
229
|
|
- $re = '/<img class="cover parallax-enable fit lazyload" data-speed="2" data-full-src="(.+?)" alt="(.+?)">/';
|
230
|
|
- $temp = preg_replace($re, '<img src="\\1" alt="\\2">', $article_only );
|
231
|
|
- $article_only = $temp;
|
232
|
|
- $re = '/" width="(.+)" height="(.+)">/';
|
233
|
|
- $temp = preg_replace($re, '>', $article_only );
|
234
|
|
- $article_only = $temp;
|
235
|
|
- }
|
236
|
106
|
//Force HTTPS
|
237
|
107
|
$article_only = add_https($article_only, 'www.twitter.com');
|
238
|
108
|
$article_only = add_https($article_only, 'www.facebook.com');
|
239
|
109
|
$article_only = add_https($article_only, 'pbs.twimg.com');
|
240
|
110
|
$article_only = add_https($article_only, 'schema.org');
|
241
|
111
|
$article_only = add_https($article_only, 'www.w3.org');
|
242
|
|
- $article_only = add_https($article_only, 'www.slate.fr');
|
|
112
|
+ $article_only = add_https($article_only, 'www.nouvelobs.com');
|
243
|
113
|
echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> '.PHP_EOL;
|
244
|
114
|
echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div> '.PHP_EOL;
|
245
|
115
|
echo '<button id="html-btn" onclick="printHTML()" style="display:inline;"><img src="img/html5.png" width="24px" height="24px"></button>'.PHP_EOL;
|