Changeset 2301475
- Timestamp:
- 05/09/2020 10:04:08 AM (6 years ago)
- Location:
- http-syndication/trunk
- Files:
-
- 2 edited
-
http_syndication.php (modified) (7 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
http-syndication/trunk/http_syndication.php
r2260538 r2301475 61 61 return $request; 62 62 } 63 64 63 // Implements the internal or external import shortcode 65 64 function import_shortcode($atts, $content) { … … 144 143 // 145 144 145 // Adds the mediawiki url query 146 146 function http_syndication_url_mediawiki($url) { 147 147 return $url . (parse_url($url, PHP_URL_QUERY) === NULL ? "?" : "&") . "printable=yes&action=render"; 148 148 } 149 149 150 // Adds the syndication url query 150 151 function http_syndication_url_httpsyndication($url) { 151 152 return $url . (parse_url($url, PHP_URL_QUERY) === NULL ? "?" : "&") . "httpsyndication"; 152 153 } 153 154 // Returns the body content 154 155 function http_syndication_content_body($content) { 155 156 $pos = http_syndication::html_tag_pos($content, "body"); 156 157 return $pos === FALSE ? $content : substr($content, $pos['start'], $pos['stop'] - $pos['start']); 157 158 } 158 159 // Returns the content without any script 159 160 function http_syndication_content_noscript($content) { 160 161 while (true) { … … 167 168 } 168 169 } 169 170 // Returns the contents associated to a tag 170 171 function http_syndication_content_tag_name($content, $atts) { 171 172 $result = ""; … … 181 182 } 182 183 } 184 // Returns the content associated to a tag id attribute 183 185 function http_syndication_content_tag_id($content, $atts) { 184 186 return $this->http_syndication_content_att($content, "id", $atts['tag_id'], $atts); 185 187 } 188 // Returns the content associated to a tag class attribute 186 189 function http_syndication_content_tag_class($content, $atts) { 187 190 return $this->http_syndication_content_att($content, "class", $atts['tag_class'], $atts); 188 191 } 192 // Parses the content and select the 1st one associated to a given attriburte 189 193 function http_syndication_content_att($content, $att, $id, $atts) { 190 194 $offset = 0; … … 207 211 return $content; 208 212 } 209 213 // Encapsulates the content in a div with a given class or style 210 214 function http_syndication_encapsulate($content, $atts) { 211 215 if (isset($atts['class']) || isset($atts['style'])) … … 216 220 return $content; 217 221 } 218 222 // Replaces href by their absolute values 219 223 function http_syndication_content_absolute_href($content, $base) { 220 224 if (preg_match('/<\s*base\s*href=["\']([^"\']*)["\']/', $content, $matches, PREG_OFFSET_CAPTURE, 0) == 1) … … 273 277 } 274 278 275 // Ensures hat all tags are closed .279 // Ensures hat all tags are closed, no more used, juste here for info. 276 280 static function html_repair($html_fragment) { 277 281 /* -
http-syndication/trunk/readme.txt
r2260540 r2301475 49 49 * `body=1` : in order to only import the `<body..>..</body>` part of the `<html><head>..</head><body..>..</body></html>` page. 50 50 * `tag_id=#id` : only extract the content of the 1st tag of the given id, i.e. the `<#tag id="#id">..</#tag>` part, where `#tag` is any tag (e.g., `div`, `span`, ..). 51 * `tag_class=#class` : only extract the content of the 1st tag of the given class, i.e. the `<#tag class="#class">..</#tag>` part, where `#tag` is any tag (e.g., `div`, `span`, ..) .51 * `tag_class=#class` : only extract the content of the 1st tag of the given class, i.e. the `<#tag class="#class">..</#tag>` part, where `#tag` is any tag (e.g., `div`, `span`, ..); the value `#class` can be a regex to deal with multiple defined classes. 52 52 * `tag_name=#name` : only extract the content of all tags of the given name, i.e. the `<#name ..>..</#name>` part (for code safety only 100 tags can be extracted). 53 53 * Content filtering:
Note: See TracChangeset
for help on using the changeset viewer.