Changeset 2977790
- Timestamp:
- 10/11/2023 06:10:31 PM (2 years ago)
- Location:
- news-parser
- Files:
-
- 191 added
- 38 edited
-
assets/screenshot-1.png (modified) (previous)
-
assets/screenshot-2.png (modified) (previous)
-
assets/screenshot-3.png (modified) (previous)
-
tags/2.0.0 (added)
-
tags/2.0.0/autoload.php (added)
-
tags/2.0.0/bootstrap.php (added)
-
tags/2.0.0/inc (added)
-
tags/2.0.0/inc/Ajax (added)
-
tags/2.0.0/inc/Ajax/Ajax.php (added)
-
tags/2.0.0/inc/Config (added)
-
tags/2.0.0/inc/Config/di-config.php (added)
-
tags/2.0.0/inc/Config/global-variables-config.php (added)
-
tags/2.0.0/inc/Config/menu-config.php (added)
-
tags/2.0.0/inc/Config/scripts-config-dev.php (added)
-
tags/2.0.0/inc/Config/scripts-config.php (added)
-
tags/2.0.0/inc/Config/styles-config-dev.php (added)
-
tags/2.0.0/inc/Config/styles-config.php (added)
-
tags/2.0.0/inc/Controller (added)
-
tags/2.0.0/inc/Controller/AjaxController.php (added)
-
tags/2.0.0/inc/Controller/Api (added)
-
tags/2.0.0/inc/Controller/Api/CronApiController.php (added)
-
tags/2.0.0/inc/Controller/Api/RestApiController.php (added)
-
tags/2.0.0/inc/Controller/Api/TemplateApiController.php (added)
-
tags/2.0.0/inc/Controller/CronController.php (added)
-
tags/2.0.0/inc/Controller/CronTaskController.php (added)
-
tags/2.0.0/inc/Controller/EventController.php (added)
-
tags/2.0.0/inc/Controller/ListController.php (added)
-
tags/2.0.0/inc/Controller/MediaController.php (added)
-
tags/2.0.0/inc/Controller/MiddlewareController.php (added)
-
tags/2.0.0/inc/Controller/PostController.php (added)
-
tags/2.0.0/inc/Controller/PostControllerExtendeOptions.php (added)
-
tags/2.0.0/inc/Controller/PostControllerUserID.php (added)
-
tags/2.0.0/inc/Controller/TemplateController.php (added)
-
tags/2.0.0/inc/Controller/TemplateControllerWithUserInfo.php (added)
-
tags/2.0.0/inc/Controller/VisualConstructorController.php (added)
-
tags/2.0.0/inc/Core (added)
-
tags/2.0.0/inc/Core/App.php (added)
-
tags/2.0.0/inc/Core/ScriptLoadingManager.php (added)
-
tags/2.0.0/inc/Exception (added)
-
tags/2.0.0/inc/Exception/MyException.php (added)
-
tags/2.0.0/inc/Interfaces (added)
-
tags/2.0.0/inc/Interfaces/AdapterInterface.php (added)
-
tags/2.0.0/inc/Interfaces/EventControllerInterface.php (added)
-
tags/2.0.0/inc/Interfaces/MenuPageInterface.php (added)
-
tags/2.0.0/inc/Interfaces/MiddlewareInterface.php (added)
-
tags/2.0.0/inc/Interfaces/ModelInterface.php (added)
-
tags/2.0.0/inc/Interfaces/PostControllerInterface.php (added)
-
tags/2.0.0/inc/Interfaces/ResponseFormatterInterface.php (added)
-
tags/2.0.0/inc/Menu (added)
-
tags/2.0.0/inc/Menu/Admin (added)
-
tags/2.0.0/inc/Menu/Admin/MenuPage.php (added)
-
tags/2.0.0/inc/Message (added)
-
tags/2.0.0/inc/Message/Errors.php (added)
-
tags/2.0.0/inc/Message/Success.php (added)
-
tags/2.0.0/inc/Models (added)
-
tags/2.0.0/inc/Models/CronDataModel.php (added)
-
tags/2.0.0/inc/Models/Factory (added)
-
tags/2.0.0/inc/Models/Factory/getCronModel.php (added)
-
tags/2.0.0/inc/Models/ListModel.php (added)
-
tags/2.0.0/inc/Models/PostModel.php (added)
-
tags/2.0.0/inc/Models/TemplateModel.php (added)
-
tags/2.0.0/inc/Models/TemplateModelWithPostOptions.php (added)
-
tags/2.0.0/inc/Models/TemplateModelWithUserID.php (added)
-
tags/2.0.0/inc/Modifiers (added)
-
tags/2.0.0/inc/Modifiers/ImagePrepare.php (added)
-
tags/2.0.0/inc/Modifiers/Modifier.php (added)
-
tags/2.0.0/inc/Modifiers/RemoveLineBreaks.php (added)
-
tags/2.0.0/inc/Modifiers/ReplaceRelativePathWithAbsolute.php (added)
-
tags/2.0.0/inc/Parser (added)
-
tags/2.0.0/inc/Parser/Abstracts (added)
-
tags/2.0.0/inc/Parser/Abstracts/AbstractParseContent.php (added)
-
tags/2.0.0/inc/Parser/HTMLParser.php (added)
-
tags/2.0.0/inc/Parser/HTMLPatternParser.php (added)
-
tags/2.0.0/inc/Parser/HTMLRaw.php (added)
-
tags/2.0.0/inc/Parser/Modifiers (added)
-
tags/2.0.0/inc/Parser/Modifiers/AdapterModifiers (added)
-
tags/2.0.0/inc/Parser/Modifiers/AdapterModifiers/Before (added)
-
tags/2.0.0/inc/Parser/Modifiers/AdapterModifiers/Before/addImageSizesModifier.php (added)
-
tags/2.0.0/inc/Parser/Modifiers/AdapterModifiers/Before/addSourceModifier.php (added)
-
tags/2.0.0/inc/Parser/Modifiers/AdapterModifiers/Before/groupPicturesModifier.php (added)
-
tags/2.0.0/inc/Parser/Modifiers/AdapterModifiers/Before/removeDublicatedPicturesModifier.php (added)
-
tags/2.0.0/inc/Parser/Modifiers/AdapterModifiers/Before/removeSrcSetAndSizesModifier.php (added)
-
tags/2.0.0/inc/Parser/Modifiers/PostModifiers (added)
-
tags/2.0.0/inc/Parser/Modifiers/PostModifiers/addPostThumbnailModifier.php (added)
-
tags/2.0.0/inc/Parser/XMLParser.php (added)
-
tags/2.0.0/inc/Traits (added)
-
tags/2.0.0/inc/Traits/FunctionAutoloadTrait.php (added)
-
tags/2.0.0/inc/Traits/RestApiTrait.php (added)
-
tags/2.0.0/inc/Traits/SanitizeDataTrait.php (added)
-
tags/2.0.0/inc/Traits/ValidateDataTrait.php (added)
-
tags/2.0.0/inc/Utils (added)
-
tags/2.0.0/inc/Utils/AdapterGuttenberg.php (added)
-
tags/2.0.0/inc/Utils/Chain.php (added)
-
tags/2.0.0/inc/Utils/MenuConfig.php (added)
-
tags/2.0.0/inc/Utils/Pipe.php (added)
-
tags/2.0.0/inc/Utils/ResponseFormatter.php (added)
-
tags/2.0.0/inc/Utils/ResponseFormatterStatic.php (added)
-
tags/2.0.0/inc/View (added)
-
tags/2.0.0/inc/View/TemplateRender.php (added)
-
tags/2.0.0/news-parser.php (added)
-
tags/2.0.0/public (added)
-
tags/2.0.0/public/css (added)
-
tags/2.0.0/public/css/152-2.0.0.css (added)
-
tags/2.0.0/public/css/607-2.0.0.css (added)
-
tags/2.0.0/public/css/about-news-parser.css (added)
-
tags/2.0.0/public/css/admin-menu-icon.css (added)
-
tags/2.0.0/public/css/font.css (added)
-
tags/2.0.0/public/css/frame-style.css (added)
-
tags/2.0.0/public/css/media-views.css (added)
-
tags/2.0.0/public/css/parser_rss-2.0.0.css (added)
-
tags/2.0.0/public/font (added)
-
tags/2.0.0/public/font/config.json (added)
-
tags/2.0.0/public/font/fontello.eot (added)
-
tags/2.0.0/public/font/fontello.svg (added)
-
tags/2.0.0/public/font/fontello.ttf (added)
-
tags/2.0.0/public/font/fontello.woff (added)
-
tags/2.0.0/public/font/fontello.woff2 (added)
-
tags/2.0.0/public/images (added)
-
tags/2.0.0/public/images/Grey-Gradient.png (added)
-
tags/2.0.0/public/images/banner-1280x360.png (added)
-
tags/2.0.0/public/images/clipart1375168.png (added)
-
tags/2.0.0/public/images/clipart1375168_d6sh2a.png (added)
-
tags/2.0.0/public/images/discord-icon-43742.png (added)
-
tags/2.0.0/public/images/discord-icon-43742_qoe0fc.png (added)
-
tags/2.0.0/public/images/loading.gif (added)
-
tags/2.0.0/public/images/youtube-video.jpeg (added)
-
tags/2.0.0/public/js (added)
-
tags/2.0.0/public/js/152-2.0.0.bundle.js (added)
-
tags/2.0.0/public/js/607-2.0.0.bundle.js (added)
-
tags/2.0.0/public/js/748-2.0.0.bundle.js (added)
-
tags/2.0.0/public/js/748-2.0.0.bundle.js.LICENSE.txt (added)
-
tags/2.0.0/public/js/771-2.0.0.bundle.js (added)
-
tags/2.0.0/public/js/771-2.0.0.bundle.js.LICENSE.txt (added)
-
tags/2.0.0/public/js/autopilot-2.0.0.bundle.js (added)
-
tags/2.0.0/public/js/parser_page-2.0.0.bundle.js (added)
-
tags/2.0.0/public/js/parser_rss-2.0.0.bundle.js (added)
-
tags/2.0.0/readme.txt (added)
-
tags/2.0.0/tear-down.php (added)
-
tags/2.0.0/template (added)
-
tags/2.0.0/template/menu (added)
-
tags/2.0.0/template/menu/about-menu.php (added)
-
tags/2.0.0/template/menu/autopilot-page-menu.php (added)
-
tags/2.0.0/template/menu/main-menu.php (added)
-
tags/2.0.0/template/menu/parsing-page-menu.php (added)
-
tags/2.0.0/template/menu/parsing-rss-menu.php (added)
-
tags/2.0.0/vendor (added)
-
tags/2.0.0/vendor/autoload.php (added)
-
tags/2.0.0/vendor/caophihung94 (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser/.gitignore (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser/CONTRIBUTING.md (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser/LICENSE (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser/README.md (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser/composer.json (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser/src (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser/src/HungCP (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser/src/HungCP/PhpSimpleHtmlDom (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser/src/HungCP/PhpSimpleHtmlDom/HtmlDomParser.php (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser/src/HungCP/PhpSimpleHtmlDom/lib (added)
-
tags/2.0.0/vendor/caophihung94/php-simple-html-dom-parser/src/HungCP/PhpSimpleHtmlDom/lib/simple_html_dom.php (added)
-
tags/2.0.0/vendor/composer (added)
-
tags/2.0.0/vendor/composer/ClassLoader.php (added)
-
tags/2.0.0/vendor/composer/InstalledVersions.php (added)
-
tags/2.0.0/vendor/composer/LICENSE (added)
-
tags/2.0.0/vendor/composer/autoload_classmap.php (added)
-
tags/2.0.0/vendor/composer/autoload_namespaces.php (added)
-
tags/2.0.0/vendor/composer/autoload_psr4.php (added)
-
tags/2.0.0/vendor/composer/autoload_real.php (added)
-
tags/2.0.0/vendor/composer/autoload_static.php (added)
-
tags/2.0.0/vendor/composer/installed.json (added)
-
tags/2.0.0/vendor/composer/installed.php (added)
-
tags/2.0.0/vendor/composer/platform_check.php (added)
-
tags/2.0.0/vendor/zalevsk1y (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/.github (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/.github/workflows (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/.github/workflows/container-actions.yml (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/.gitignore (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/README.md (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/composer.json (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/phpunit.xml (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/src (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/src/DI.php (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/src/Exception (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/src/Exception/MyException.php (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/src/Interfaces (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/src/Interfaces/ContainerInterface.php (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/src/Message (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/src/Message/Errors.php (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/tests (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/tests/DI (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/tests/DI/DITest.php (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/tests/mock (added)
-
tags/2.0.0/vendor/zalevsk1y/container-builder/tests/mock/di-config.php (added)
-
trunk/autoload.php (modified) (1 diff)
-
trunk/inc/Ajax/Ajax.php (modified) (7 diffs)
-
trunk/inc/Controller/AjaxController.php (modified) (7 diffs)
-
trunk/inc/Controller/EventController.php (modified) (4 diffs)
-
trunk/inc/Controller/ListController.php (modified) (4 diffs)
-
trunk/inc/Controller/MediaController.php (modified) (2 diffs)
-
trunk/inc/Controller/PostController.php (modified) (2 diffs)
-
trunk/inc/Controller/TemplateController.php (modified) (1 diff)
-
trunk/inc/Controller/VisualConstructorController.php (modified) (5 diffs)
-
trunk/inc/Message/Errors.php (modified) (3 diffs)
-
trunk/inc/Message/Success.php (modified) (1 diff)
-
trunk/inc/Models/PostModel.php (modified) (7 diffs)
-
trunk/inc/Models/TemplateModel.php (modified) (9 diffs)
-
trunk/inc/Parser/Abstracts/AbstractParseContent.php (modified) (4 diffs)
-
trunk/inc/Parser/HTMLPatternParser.php (modified) (1 diff)
-
trunk/inc/Parser/HTMLRaw.php (modified) (2 diffs)
-
trunk/inc/Parser/XMLParser.php (modified) (5 diffs)
-
trunk/inc/Traits/SanitizeDataTrait.php (modified) (4 diffs)
-
trunk/inc/Traits/ValidateDataTrait.php (modified) (6 diffs)
-
trunk/inc/Utils/Pipe.php (modified) (1 diff)
-
trunk/inc/Utils/ResponseFormatter.php (modified) (7 diffs)
-
trunk/news-parser.php (modified) (3 diffs)
-
trunk/public/css/about-news-parser.css (modified) (2 diffs)
-
trunk/public/css/frame-style.css (modified) (1 diff)
-
trunk/readme.txt (modified) (9 diffs)
-
trunk/template/menu/about-menu.php (modified) (4 diffs)
-
trunk/template/menu/parsing-rss-menu.php (modified) (1 diff)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/ClassLoader.php (modified) (24 diffs)
-
trunk/vendor/composer/autoload_classmap.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_namespaces.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_psr4.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (3 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.json (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
news-parser/trunk/autoload.php
r2265315 r2977790 13 13 $path = __DIR__ . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . $cl . ".php"; 14 14 if (file_exists($path)) { 15 include $path;15 include_once $path; 16 16 } 17 17 } -
news-parser/trunk/inc/Ajax/Ajax.php
r2265315 r2977790 1 1 <?php 2 2 namespace NewsParserPlugin\Ajax; 3 4 use NewsParserPlugin\Utils\ResponseFormatter; 3 5 4 6 /** … … 11 13 class Ajax 12 14 { 15 protected $formatter; 13 16 /** 14 17 * Checks input argument type. … … 47 50 * validate_callback - validation callback should return boolean 48 51 * sanitize_callback - sanitize input data callback. 49 * @return void52 * @return array 50 53 */ 51 54 protected function prepareArgs($dirty_request, $args_params) … … 56 59 $dirty_arg=$dirty_request[$key]; 57 60 if (is_wp_error($e = $this->checkArgType($dirty_arg, $arg['type'], $arg['description']))) { 58 $this->sendError($e );61 $this->sendError($e->get_error_message(),$e->get_error_code()); 59 62 } 60 63 //validate arguments. 61 64 if (is_wp_error($e = call_user_func($arg['validate_callback'], $dirty_arg))) { 62 $this->sendError($e );65 $this->sendError($e->get_error_message(),$e->get_error_code()); 63 66 } 64 67 //sanitize arguments. … … 76 79 * @return void 77 80 */ 78 protected function sendError($error )81 protected function sendError($error_data,$error_code) 79 82 { 80 if (!is_wp_error($error)) { 81 return; 82 } 83 $response_message=array( 84 'msg'=>array( 85 'type'=>'error', 86 'text'=>esc_html($error->get_message()) 87 ), 88 'code'=>esc_html($error->get_code()) 89 ); 90 wp_send_json($response_message, $error->get_code()); 83 wp_send_json_error($error_data, $error_code); 91 84 } 92 85 /** … … 99 92 protected function sendResponse($response) 100 93 { 101 switch ($response->contentType) { 102 case 'json': 103 wp_send_json($response->get('array')); 104 break; 105 case 'text': 106 echo $response->get('text'); 107 wp_die(); 108 break; 109 } 94 95 wp_send_json($response); 96 97 110 98 } 111 99 … … 119 107 return json_decode(file_get_contents('php://input'), true); 120 108 } 109 /** 110 * Get an instance of the response formatter. 111 * 112 * @access protected 113 * @return ResponseFormatter Returns an instance of the ResponseFormatter class. 114 */ 115 116 protected function getFormatter() 117 { 118 119 return new ResponseFormatter(); 120 121 } 121 122 } -
news-parser/trunk/inc/Controller/AjaxController.php
r2265315 r2977790 7 7 use NewsParserPlugin\Interfaces\EventControllerInterface; 8 8 use NewsParserPlugin\Message\Errors; 9 use NewsParserPlugin\Message\Success; 10 use NewsParserPlugin\Exception\MyException; 9 11 10 12 /** … … 58 60 $this->event=$event; 59 61 $this->init(); 62 $this->formatter=$this->getFormatter(); 60 63 } 61 64 /** … … 106 109 } 107 110 return true; 111 } 112 protected function sendErrorResponse(MyException $e){ 113 $error_data=$this->formatter->error($e->getCode())->message('error', $e->getMessage())->get('array'); 114 $error_code=$e->getCode(); 115 $this->sendError($error_data,$error_code); 108 116 } 109 117 /** … … 138 146 ) 139 147 )); 140 141 $response=$this->event->trigger('media:create', array($request['url'],$request['options']['post_id'],$request['options']['alt'])); 142 $this->sendResponse($response); 143 } 144 /** 145 * Callback that handles options api requests. 146 * 147 * @uses ValidateDataTrait::validateExtraOptions() 148 * @uses ValidateDataTrait::validateTemplate() 149 * @uses SanitizeDataTrait::sanitizeExtraOptions() 150 * @uses SanitizeDataTrait::sanitizeTemplate() 151 * @uses EventController::trigger() 152 * @return void 153 */ 154 public function templateApi() 155 { 156 //Get application\json encode data 157 $json_post = $this->getJsonFromInput(); 158 $this->checkPermission('parsing_news_api', $json_post); 159 160 $request=$this->prepareArgs($json_post, array( 161 'url'=>array( 162 'description'=>'Url of post that was taken as example of template', 163 'type'=>'string', 164 'validate_callback'=>function ($url) { 165 return wp_http_validate_url($url); 166 }, 167 'sanitize_callback'=>function ($input_url) { 168 return esc_url_raw($input_url); 169 } 170 ), 171 'extraOptions'=>array( 172 'description'=>'Extra options for automated parsing pages', 173 'type'=>'array', 174 'validate_callback'=>array($this,'validateExtraOptions'), 175 'sanitize_callback'=>array($this,'sanitizeExtraOptions') 176 ), 177 'template'=>array( 178 'description'=>'Template for automate parsing post', 179 'type'=>'array', 180 'validate_callback'=>array($this,'validateTemplate'), 181 'sanitize_callback'=>array($this,'sanitizeTemplate') 182 ) 183 )); 184 $options=array( 185 'extraOptions'=>$request['extraOptions'], 186 'template'=>$request['template'] 187 ); 188 $response=$this->event->trigger('template:create', array($request['url'],$options)); 189 190 $this->sendResponse($response); 191 } 148 try { 149 $media_id=$this->event->trigger('media:create', array($request['url'],$request['options']['post_id'],$request['options']['alt'])); 150 $this->sendResponse($this->formatter->media($media_id)->message('success', Success::text('FEATURED_IMAGE_SAVED'))->get('array')); 151 } catch (MyException $e) { 152 $this->sendErrorResponse($e); 153 } 154 } 155 192 156 /** 193 157 * Callback that handles parsing list of posts from RSS api requests. … … 216 180 )); 217 181 218 219 $url = $request['url']; 220 221 $response = $this->event->trigger('list:get', array($url)); 222 $this->sendResponse($response); 223 } 182 183 try{ 184 $response = $this->event->trigger('list:get', array($request['url'])); 185 $this->sendResponse($this->formatter->rss($response)->message('success', Success::text('RSS_LIST_PARSED'))->get('array')); 186 }catch (MyException $e){ 187 $this->sendErrorResponse($e); 188 } 189 } 190 224 191 /** 225 192 * Callback that handles parsing single page api requests and returns HTML of the page. … … 247 214 ) 248 215 )); 249 250 251 $url = $request['url']; 252 $response = $this->event->trigger('html:get', array($url)); 253 $this->sendResponse($response); 216 $request_url=$request['url']; 217 try{ 218 $html = $this->event->trigger('html:get', array($request_url)); 219 $response=array( 220 'html'=>$html, 221 'url'=>$request_url 222 ); 223 $this->sendResponse($this->formatter->rawHTML($response)->get('array')); 224 }catch (MyException $e){ 225 $this->sendErrorResponse($e); 226 } 227 254 228 } 255 229 /** … … 292 266 return preg_replace('/[^0-9]/i', '', $_id); 293 267 } 294 ) 295 )); 296 297 $response=$this->event->trigger('post:create', $request); 298 $this->sendResponse($response); 268 ), 269 'templateUrl'=>array( 270 'description'=>'Url that identifies template', 271 'type'=>'string', 272 'validate_callback'=>function ($url) { 273 return wp_http_validate_url($url); 274 }, 275 'sanitize_callback'=>function ($input_url) { 276 return esc_url_raw($input_url); 277 } 278 ), 279 )); 280 try{ 281 $response=$this->event->trigger('post:create', array($request['url'],$request['_id'],$request['templateUrl'])); 282 $this->sendResponse($this->formatter->post($response)->message('success', sprintf(Success::text('POST_SAVED'), $response['title']))->addCustomData('_id', $request['_id'])->get('array')); 283 } catch (MyException $e) { 284 $this->sendErrorResponse($e); 285 } 299 286 } 300 287 } -
news-parser/trunk/inc/Controller/EventController.php
r2265315 r2977790 2 2 namespace NewsParserPlugin\Controller; 3 3 4 use Psr\Container\ContainerInterface;5 4 use NewsParserPlugin\Interfaces\EventControllerInterface; 5 use \ContainerBuilder\Interfaces\ContainerInterface as ContainerInterface; 6 6 7 7 /** … … 16 16 class EventController implements EventControllerInterface 17 17 { 18 19 static protected $instance; 18 20 /** 19 21 * Collection of events with controllers. … … 34 36 */ 35 37 36 p ublic function __construct(ContainerInterface $DIController)38 protected function __construct(ContainerInterface $DI_container) 37 39 { 38 $this->di=$DIController; 40 $this->di=$DI_container; 41 } 42 static public function getInstance($DI_container){ 43 if(!self::$instance){ 44 self::$instance=new self($DI_container); 45 } 46 return self::$instance; 39 47 } 40 48 /** … … 88 96 } 89 97 if (!is_array($args)) { 90 throw new Exception('EventController::trigger() second argument should be an array, but '.gettype($args).' given.');98 throw new \Exception('EventController::trigger() second argument should be an array, but '.gettype($args).' given.'); 91 99 } 92 100 return $this->di->call($this->eventCollection[$action], $args); -
news-parser/trunk/inc/Controller/ListController.php
r2265315 r2977790 3 3 4 4 use NewsParserPlugin\Exception\MyException; 5 use NewsParserPlugin\Message\Success;6 5 use NewsParserPlugin\Parser\Abstracts\AbstractParseContent; 7 use NewsParserPlugin\Utils\ResponseFormatter;8 6 use NewsParserPlugin\Models\ListModel; 9 7 … … 20 18 */ 21 19 22 class ListController extends BaseController20 class ListController 23 21 { 24 22 /** … … 39 37 * @param AbstractParseContent $parser 40 38 */ 41 public function __construct(AbstractParseContent $parser , ResponseFormatter $formatter)39 public function __construct(AbstractParseContent $parser) 42 40 { 43 parent::__construct($formatter);44 41 $this->parser = $parser; 45 42 } … … 47 44 * Get formated list of posts. 48 45 * 49 * @uses NewsParserPlugin\Controller\BaseController::formatResponse50 * @uses NewsParserPlugin\Controller\BaseController::modelsFactory51 * @uses NewsParserPlugin\Utils\ResponseFormatter::message()52 * @uses NewsParserPlugin\Utils\ResponseFormatter::rss()53 * @uses NewsParserPlugin\Utils\ResponseFormatter::error()54 * @uses NewsParserPlugin\Utils\ResponseFormatter::get()55 46 * @uses NewsParserPlugin\Parser\Abstracts\AbstractParseContent::get() 56 47 * @uses NewsParserPlugin\Interfaces\ModelInterface::getAttribute() 57 48 * @param string $url Url of the RSS source. 58 * @return ResponseFormatter49 * @return array 59 50 */ 60 51 public function get($url) 61 52 { 62 try { 63 $listData = $this->parser->get($url); 64 $list = $this->listModelFactory($listData); 65 $response = $this->formatResponse->rss($list->getAttributes())->message('success', Success::text('RSS_LIST_PARSED')); 66 } catch (MyException $e) { 67 $response = $this->formatResponse->error($e->getCode())->message('error', $e->getMessage()); 68 } 69 return $response; 53 54 $listData = $this->parser->get($url); 55 $list = $this->listModelFactory($listData); 56 return $list->getAttributes(); 70 57 } 71 58 /** -
news-parser/trunk/inc/Controller/MediaController.php
r2265315 r2977790 8 8 use NewsParserPlugin\Utils\ResponseFormatter; 9 9 10 class MediaController extends BaseController 10 11 /** 12 * Class save media as post attachment 13 * 14 * PHP version 5.6 15 * 16 * 17 * @package Controller 18 * @author Evgeniy S.Zalevskiy <[email protected]> 19 * @license MIT 20 * 21 */ 22 class MediaController 11 23 { 12 public function __construct(ResponseFormatter $formatter) 13 { 14 parent::__construct($formatter); 15 } 24 16 25 /** 17 26 * Saves attached media. 18 27 * 19 * @uses NewsParserPlugin\Controller\BaseController::formatResponse20 28 * @throws MyException 21 29 * @param string $url Url of image that should be download. 22 30 * @param string $post_id Post id. 23 31 * @param string $alt Description of image. 24 * @return ResponseFormatter32 * @return int id of media 25 33 */ 26 34 public function create($url, $post_id, $alt = '') 27 35 { 28 try { 29 $post=$this->postModelsFactory($post_id); 30 if (!$post) { 31 throw new MyException(Errors::text('WRONG_POST_ID'), Errors::code('BAD_REQUEST')); 32 } 33 $media_id=$post->addPostThumbnail($url, $alt); 34 $response=$this->formatResponse->media($media_id)->message('success', Success::text('FEATURED_IMAGE_SAVED')); 35 } catch (MyException $e) { 36 $response = $this->formatResponse->error($e->getCode())->message('error', $e->getMessage()); 36 $this->addFilters(); 37 $post=$this->postModelsFactory($post_id); 38 if (!$post) { 39 throw new MyException(Errors::text('WRONG_POST_ID'), Errors::code('BAD_REQUEST')); 37 40 } 38 return $response; 41 $media_id=$post->addPostThumbnail($url, $alt); 42 return $media_id; 39 43 } 40 44 /** … … 60 64 return $this->create($url, $post_id, $alt); 61 65 } 66 public function modifyImageSideloadExtension($allowed_extensions,$file) 67 { 68 if (is_array($allowed_extensions)) array_push($allowed_extensions,'webp'); 69 return $allowed_extensions; 70 } 71 public function modifyUploadMimes($mimes) 72 { 73 if (is_array($mimes)) $mimes['webp']='image/webp'; 74 return $mimes; 75 } 76 protected function addFilters() 77 { 78 add_filter('image_sideload_extensions', array($this,'modifyImageSideloadExtension'), 10, 2); 79 add_filter('upload_mimes',array($this,'modifyUploadMimes')); 80 } 62 81 } -
news-parser/trunk/inc/Controller/PostController.php
r2265315 r2977790 1 1 <?php 2 2 3 namespace NewsParserPlugin\Controller; 3 4 … … 8 9 use NewsParserPlugin\Models\TemplateModel; 9 10 use NewsParserPlugin\Parser\Abstracts\AbstractParseContent; 10 use NewsParserPlugin\Utils\ResponseFormatter; 11 use NewsParserPlugin\Interfaces\AdapterInterface; 12 use NewsParserPlugin\Traits\FunctionAutoloadTrait; 13 use NewsParserPlugin\Interfaces\PostControllerInterface; 11 14 12 15 /** 13 16 * Class controller for post parsing. 14 17 * 15 * PHP version 5.616 *17 18 * 18 19 * @package Controller 19 * @author Evgeniy S.Zalevskiy <[email protected]>20 20 * @license MIT 21 *22 21 */ 23 class PostController extends BaseController22 class PostController implements PostControllerInterface 24 23 { 25 /** 26 * Post model 27 * 28 * @var PostModel 24 25 /** 26 * Methods to get function psr-4 like way. 27 * 28 * @method loadFunction() 29 * @method executerCallback() 30 */ 31 use FunctionAutoloadTrait; 32 /** 33 * @var PostModel Post model 29 34 */ 30 35 public $post; 31 /** 32 * Parsing extra options 33 * 34 * @var array 36 protected $beforeAdapterModifiers; 37 protected $postModifiers; 38 /** 39 * @var array $parsedData Structure: 40 * [title] - post title @string 41 * [image] - post main image url @string 42 * [body] - post content @string|@array 43 * [sourceUrl] - url of source page @string 44 * [authorId] - id of wp-post author 45 */ 46 protected $parsedData; 47 48 /** 49 * @var array Parsing extra options 35 50 */ 36 51 protected $options; 37 /** 38 * Parser object 39 * 40 * @var AbstractParseContent 52 53 /** 54 * @var AbstractParseContent Parser object 41 55 */ 42 56 protected $parser; 43 57 44 58 /** 45 * Init function 46 * 47 * @param AbstractParseContent $parser 48 * @param ResponseFormatter $formatter 49 */ 50 public function __construct(AbstractParseContent $parser, ResponseFormatter $formatter) 51 { 52 parent::__construct($formatter); 59 * Class Constructor. 60 * 61 * Initializes the class instance. 62 * 63 * @param AbstractParseContent $parser Parser instance for parsing content. 64 * @param AdapterInterface $adapter Adapter instance that converts array of body elements data. 65 * @param array $before_adapter_modifiers (optional) Associative array of modifiers to be applied before the adapter conversion. The format is as follows: 66 * [ 67 * 'option_id' => [ 68 * 'path_to_true_modifier_function', 69 * 'path_to_false_modifier_function' 70 * ], 71 * ... 72 * ] 73 * The 'option_id' is the identifier of the option. 74 * The 'path_to_true_modifier_function' is the full PSR-4 like path to the modifier function that will be applied if the 'option_id' is true. 75 * The 'path_to_false_modifier_function' is the full PSR-4 like path to the modifier function that will be applied if the 'option_id' is false. 76 * @param array $post_modifiers (optional) Associative array of modifiers to be applied after the adapter conversion. The format is the same as the before_adapter_modifiers array. 77 */ 78 79 public function __construct(AbstractParseContent $parser, AdapterInterface $adapter,array $before_adapter_modifiers=[],array $post_modifiers=[]) 80 { 81 $this->adapter = $adapter; 53 82 $this->parser = $parser; 54 } 83 $this->beforeAdapterModifiers=$before_adapter_modifiers; 84 $this->postModifiers=$post_modifiers; 85 } 86 55 87 /** 56 88 * Create post draft and return response in proper format 57 89 * 58 * @uses NewsParserPlugin\Controller\BaseController::formatResponse 59 * @param string $url of post that should be parsed and saved as draft 60 * @param string $_id front end index of post that should be parsed and saved as draft 61 * @return ResponseFormatter 62 */ 63 public function create($url, $_id) 64 { 65 try { 66 $parsed_url=parse_url($url); 67 if (!is_array($parsed_url)) { 68 throw new MyException(Errors::text('WRONG_OPTIONS_URL'), Errors::code('BAD_REQUEST')); 90 * @param string $url URL of post that should be parsed and saved as draft. 91 * @param string $_id Front-end index of post that should be parsed and saved as draft. 92 * @param string $template_url Object with parameters for WP post. 93 * @return array 94 * @throws MyException 95 */ 96 public function create($url, $_id, $template_url = false) 97 { 98 $parsed_url = parse_url($url); 99 if (!is_array($parsed_url)) { 100 throw new MyException(Errors::text('WRONG_OPTIONS_URL'), Errors::code('BAD_REQUEST')); 101 } 102 $post_options_model = $this->getPostOptionsModel($template_url); 103 $this->parsedData = $this->parser->get($url, $post_options_model->getAttributes('array')); 104 105 $this->assignAuthorId(); 106 107 // Unescaped URL 108 $this->assignSourceUrl($url); 109 $this->checkParsedData(); 110 $this->applyBeforAdapterModifiers(); 111 // Apply adapter to adapt parsed body of the post to editor or make changes according to options 112 $this->applyBodyAdapter(); 113 114 // Get post model 115 $this->post = $this->postModelsFactory(); 116 $this->createPost(); 117 118 // Apply modifiers to post according to template post options 119 $this->applyPostModifiers(); 120 121 return $this->post->getAttributes(); 122 } 123 /** 124 * Retrieves the parsed data associated with the PostController. 125 * 126 * This method returns the parsed data stored in the PostController object. 127 * 128 * @return array The parsed data associated with the PostController. 129 */ 130 131 public function getParsedData() 132 { 133 return $this->parsedData; 134 } 135 /** 136 * Updates the body array in the parsed data of the PostController. 137 * 138 * This method takes an array of body elements and updates the 'body' key in the parsed data of the PostController with the provided array. 139 * 140 * @param array $body_array The array of body elements to update the parsed data with. 141 * @return void 142 */ 143 144 public function updateParsedDataBody(array $body_array) 145 { 146 $this->parsedData['body']=$body_array; 147 } 148 /** 149 * Apply body adapter to parsed data 150 */ 151 protected function applyBodyAdapter() 152 { 153 $pre_adapted_body = \apply_filters('news_parser_filter_pre_adapter', $this->parsedData['body']); 154 $post_adapter_body = $this->adapter->convert($pre_adapted_body); 155 $this->parsedData['body'] = \apply_filters('news_parser_filter_post_adapter', $post_adapter_body); 156 } 157 /** 158 * Add modifiers to the adapter. 159 * 160 * The modifiers array should be in the following format: 161 * 162 * [ 163 * 'option_id' => [ 164 * 'path_to_true_modifier_function', 165 * 'path_to_false_modifier_function' 166 * ], 167 * ... 168 * ] 169 * 170 * The 'option_id' is the identifier of the option. 171 * The 'path_to_true_modifier_function' is the full PSR-4 like path to the modifier function that will be applied if the 'option_id' is true. 172 * The 'path_to_false_modifier_function' is the full PSR-4 like path to the modifier function that will be applied if the 'option_id' is false. If a false modifier is not provided, it can be set as null. 173 * 174 * beforOptions - modifiers will be run without options check 175 * options - modifiers will run conditional according post options state 176 * Syntax Example: 177 * $modifiers_array = [ 178 * 'beforOptions'=>['Namespace\Modifiers\Modifier'...] 179 * 'options'=>[ 180 * 'option1' => [ 181 * 'Namespace\Modifiers\TrueModifier', 182 * 'Namespace\Modifiers\FalseModifier' 183 * ], 184 * 'option2' => [ 185 * 'Namespace\Modifiers\AnotherTrueModifier', 186 * null 187 * ], 188 * ... 189 * ] 190 * ]; 191 * 192 * @return void 193 */ 194 195 protected function applyBeforAdapterModifiers() 196 { 197 //beforeAll modifiers executes before all others 198 if(array_key_exists('beforeOptions',$this->beforeAdapterModifiers)&&is_array($this->beforeAdapterModifiers['beforeOptions'])){ 199 foreach($this->beforeAdapterModifiers['beforeOptions'] as $modifier_function){ 200 $this->executerCallback($this,$modifier_function); 69 201 } 70 $parsing_options=$this->templateModelsFactory($parsed_url); 71 $parsed_data =$this->parser->get($url, $parsing_options->getAttributes('array')); 72 73 $parsed_data['authorId'] = \get_current_user_id(); 74 if (!$options=$parsing_options->getExtraOptions()) { 75 throw new MyException(Errors::text('NO_EXTRA_OPTIONS'), Errors::code('BAD_REQUEST')); 202 } 203 if(!array_key_exists('options',$this->beforeAdapterModifiers)) return null; 204 foreach ($this->beforeAdapterModifiers['options'] as $option_id=>$modifier_function){ 205 if(array_key_exists($option_id,$this->options)&&$this->options[$option_id]) 206 { 207 $this->executerCallback($this,$modifier_function[0]); 208 209 }else if($modifier_function[1]!==null){ 210 $this->executerCallback($this,$modifier_function[1]); 76 211 } 77 $this->options=$options; 78 //unescaped url 79 80 $parsed_data['sourceUrl'] = $url; 81 82 $this->post=$post= $this->postModelsFactory($parsed_data); 83 84 //Stages of post draw creating 85 $this->createDraft($post)->addSource($post)->addPostThumbnail($post); 86 87 88 $response = $this->formatResponse->post($post->getAttributes())->addCustomData('_id', $_id)->message('success', sprintf(Success::text('POST_SAVED_AS_DRAFT'), $post->title)); 89 } catch (MyException $e) { 90 $response = $this->formatResponse->error($e->getCode())->message('error', $e->getMessage())->addCustomData('_id', $_id); 91 } 92 return $response; 93 } 94 95 /** 96 * Create WP post draft 97 * 98 * @param PostModel $post 99 * @return PostController 100 */ 101 protected function createDraft(PostModel $post) 102 { 103 $post->createDraft(); 212 } 213 } 214 /** 215 * Apply post modifiers to the adapter. 216 * 217 * The `executerCallback` function is a trait that allows executing a function by given path in a PSR-4 like way. 218 * 219 * The modifiers array should be in the following format: 220 * 221 * [ 222 * 'option_id' => [ 223 * 'path_to_true_modifier_function', 224 * 'path_to_false_modifier_function' 225 * ], 226 * ... 227 * ] 228 * 229 * The 'option_id' is the identifier of the option. 230 * The 'path_to_true_modifier_function' is the full PSR-4 like path to the modifier function that will be applied if the 'option_id' is true. 231 * The 'path_to_false_modifier_function' is the full PSR-4 like path to the modifier function that will be applied if the 'option_id' is false. 232 * 233 * Syntax Example: 234 * $modifiers_array = [ 235 * 'option1' => [ 236 * 'Namespace\Modifiers\TrueModifier', 237 * 'Namespace\Modifiers\FalseModifier' 238 * ], 239 * 'option2' => [ 240 * 'Namespace\Modifiers\AnotherTrueModifier', 241 * 'Namespace\Modifiers\AnotherFalseModifier' 242 * ], 243 * ... 244 * ]; 245 * 246 * @return void 247 */ 248 249 protected function applyPostModifiers() 250 { 251 foreach ($this->postModifiers as $option_id=>$modifier_function){ 252 if(array_key_exists($option_id,$this->options)&&$this->options[$option_id]) 253 { 254 $this->executerCallback($this->post,$modifier_function[0]); 255 256 } else if ($modifier_function[1]!==null) 257 { 258 $this->executerCallback($this->post,$modifier_function[1]); 259 } 260 } 261 } 262 /** 263 * Get the post options model based on the given options ID 264 * 265 * @param string $options_id ID of the template options. 266 * @return TemplateModel 267 * @throws MyException 268 */ 269 protected function getPostOptionsModel($options_id) 270 { 271 $options_model = $this->templateModelsFactory($options_id); 272 if (!$options = $options_model->getExtraOptions()) { 273 throw new MyException(Errors::text('NO_EXTRA_OPTIONS'), Errors::code('BAD_REQUEST')); 274 } 275 $this->options = $options; 276 return $options_model; 277 } 278 279 /** 280 * Assign the current user's ID as the author ID 281 */ 282 protected function assignAuthorId() 283 { 284 $this->parsedData['authorId'] = apply_filters('news_parser_filter_author_id', \get_current_user_id()); 285 } 286 287 /** 288 * Assign the source URL to the parsed data 289 * 290 * @param string $url Source URL to assign. 291 */ 292 protected function assignSourceUrl($url) 293 { 294 $this->parsedData['sourceUrl'] = $url; 295 } 296 297 /** 298 * Create a WP post 299 */ 300 protected function createPost() 301 { 302 $this->post->createPost(); 303 } 304 305 /** 306 * Add the main image to the post 307 */ 308 protected function addPostThumbnail() 309 { 310 if ($this->options['addFeaturedMedia']) { 311 $this->post->addPostThumbnail(); 312 } 104 313 return $this; 105 314 } 106 /** 107 * Add main image to the post 108 * 109 * @param PostModel $post 110 * @return PostController 111 */ 112 protected function addPostThumbnail(PostModel $post) 113 { 114 if ($this->options['addFeaturedMedia']) { 115 $post->addPostThumbnail(); 315 316 /** 317 * Add the link to the source 318 */ 319 protected function addSource() 320 { 321 if ($this->options['addSource']) { 322 $this->post->addSource(); 116 323 } 117 324 return $this; 118 325 } 119 /** 120 * Add link to the source 121 * 122 * @param PostModel $post 123 * @return PostController 124 */ 125 protected function addSource(PostModel $post) 126 { 127 if ($this->options['addSource']) { 128 $post->addSource(); 129 } 130 return $this; 131 } 132 /** 133 * Get instance of PostModel class. 134 * 135 * @param array $data Structure: 136 * [title] - post title @string 137 * [image] - post main image url @string 138 * [body] - post content @string|@array 139 * [sourceUrl]-url of source page @string 140 * [authorId]- id of wp-post author 141 * @return PostModel 142 */ 143 protected function postModelsFactory($data) 144 { 145 return new PostModel($data); 146 } 147 /** 148 * Get instance of TemplateModel class. 149 * 150 * @param array $url Structure: 151 * [scheme] - protocol 152 * [host] - host name 153 * [path] - path to resource 154 * [fragment] - path fragment 155 * @return TemplateModel 156 */ 326 327 /** 328 * Get an instance of the PostModel class. 329 * 330 * @return PostModel 331 */ 332 protected function postModelsFactory() 333 { 334 return new PostModel($this->parsedData); 335 } 336 337 /** 338 * Get an instance of the TemplateModel class. 339 * 340 * @param array $url Structure: 341 * [scheme] - protocol 342 * [host] - host name 343 * [path] - path to resource 344 * [fragment] - path fragment 345 * @return TemplateModel 346 */ 157 347 protected function templateModelsFactory($url) 158 348 { 159 349 return new TemplateModel($url['host']); 160 350 } 351 /** 352 * Check parsed data for required fields. 353 * 354 * @throws MyException When any of the required fields are missing or empty. 355 * @return void 356 */ 357 358 protected function checkParsedData() 359 { 360 if(!array_key_exists('title',$this->parsedData)||empty($this->parsedData['title'])){ 361 throw new MyException(Errors::text('NO_TITLE'),Errors::code('INNER_ERROR')); 362 } 363 if(!array_key_exists('body',$this->parsedData)||empty($this->parsedData['body'])){ 364 throw new MyException(Errors::text('NO_BODY'),Errors::code('INNER_ERROR')); 365 } 366 if(!array_key_exists('authorId',$this->parsedData)||empty($this->parsedData['authorId'])){ 367 throw new MyException(Errors::text('NO_AUTHOR'),Errors::code('INNER_ERROR')); 368 } 369 if(!array_key_exists('sourceUrl',$this->parsedData)||empty($this->parsedData['sourceUrl'])){ 370 throw new MyException(Errors::text('NO_POST_URL'),Errors::code('INNER_ERROR')); 371 } 372 if(!array_key_exists('image',$this->parsedData)||empty($this->parsedData['image'])){ 373 if($this->options['addFeaturedMedia']){ 374 throw new MyException(Errors::text('NO_IMAGE'),Errors::code('INNER_ERROR')); 375 } 376 } 377 } 378 161 379 } -
news-parser/trunk/inc/Controller/TemplateController.php
r2265315 r2977790 3 3 4 4 use NewsParserPlugin\Exception\MyException; 5 use NewsParserPlugin\Utils\ResponseFormatter;6 5 use NewsParserPlugin\Message\Errors; 7 6 use NewsParserPlugin\Message\Success; 8 use NewsParserPlugin\Models\TemplateModel; 7 use NewsParserPlugin\Models\TemplateModelWithPostOptions as TemplateModel; 8 use NewsParserPlugin\Utils\ResponseFormatter; 9 9 10 10 /** 11 * Class TemplateController 12 * 11 13 * Class saves received options. 12 14 * 13 * PHP version 5.6 14 * 15 * 16 * @package Controller 17 * @author Evgeniy S.Zalevskiy <[email protected]> 18 * @license MIT 19 * 15 * @package NewsParserPlugin\Controller 20 16 */ 17 class TemplateController 18 { 19 protected const TEMPLATE_TABLE_NAME = NEWS_PURSER_PLUGIN_TEMPLATE_OPTIONS_NAME; 21 20 22 class TemplateController extends BaseController23 {24 25 /**26 * Init function.27 *28 */29 public function __construct(ResponseFormatter $formatter)30 {31 parent::__construct($formatter);32 }33 21 /** 34 22 * Save received options. 35 23 * 36 * @uses NewsParserPlugin\Controller\BaseController::formatResponse 37 * @uses NewsParserPlugin\Controller\BaseController::modelsFactory 38 * @uses NewsParserPlugin\Utils\ResponseFormatter::message() 39 * @uses NewsParserPlugin\Utils\ResponseFormatter::error() 40 * @uses NewsParserPlugin\Utils\ResponseFormatter::get() 41 * @uses NewsParserPlugin\Models\TemplateModel::save() 42 * @param string $url 43 * @param array $options 44 * @return ResponseFormatter 24 * @param array $options The received options. 25 * @return TemplateModel created template model. 45 26 */ 46 public function create($ url, $options)27 public function create($options) 47 28 { 48 $parsed_url=parse_url($url); 49 try { 50 if (!is_array($parsed_url)) { 51 throw new MyException(Errors::text('WRONG_OPTIONS_URL'), Errors::code('BAD_REQUEST')); 52 } 53 $TemplateModel=$this->modelsFactory($parsed_url); 54 $TemplateModel->save($options); 55 $response=$this->formatResponse->message('success', Success::text('TEMPLATE_SAVED')); 56 } catch (MyException $e) { 57 $response = $this->formatResponse->error($e->getCode())->message('error', $e->getMessage()); 29 /** 30 * @var TemplateModel $template_model 31 */ 32 $template_model = $this->modelsFactory($options); 33 $template_model->create(); 34 return $template_model->getAttributes('array'); 35 } 36 37 /** 38 * Get template by URL. 39 * 40 * @param string $url The URL of the template. 41 * @return array|false The array of template model attributes if found, false otherwise. 42 */ 43 public function get($url) 44 { 45 $template_model=$this->findByUrl($url); 46 return $template_model!==false?$template_model->getAttributes('array'):$template_model; 47 } 48 49 /** 50 * Get all template keys. 51 * 52 * @return array The array of template keys. 53 */ 54 public function templateKeys() 55 { 56 return array_keys($this->getAll()); 57 } 58 59 /** 60 * Delete template by URL. 61 * 62 * @param string $url The URL of the template to delete. 63 * @return void 64 */ 65 public function delete($url) 66 { 67 $template = $this->findByUrl($url); 68 if ($template) { 69 $template->delete(); 58 70 } 59 return $ response;71 return $this->templateKeys(); 60 72 } 61 /** 62 * Get instance of TemplateModel class. 63 * 64 * @param array $url Structure: 65 * [scheme] - protocol 66 * [host] - host name 67 * [path] - path to resource 68 * [fragment] - path fragment 69 * @return TemplateModel 70 */ 71 protected function modelsFactory($url) 73 74 /** 75 * Get all templates. 76 * 77 * @return array The array of templates. 78 */ 79 protected function getAll() 72 80 { 73 return new TemplateModel($url['host']); 81 if (!$templates = $this->getOption(self::TEMPLATE_TABLE_NAME)) { 82 return []; 83 } 84 return json_decode(json_encode($templates),true); 85 } 86 87 /** 88 * Get instance of TemplateModel class. 89 * 90 * @param array $template_options The template options. 91 * @return TemplateModel The instance of TemplateModel class. 92 */ 93 protected function modelsFactory($template_options) 94 { 95 $template_model = new TemplateModel($template_options); 96 return $template_model; 97 } 98 99 /** 100 * Find template by URL. 101 * 102 * @param string $url The URL of the template. 103 * @return TemplateModel|false The template model if found, false otherwise. 104 */ 105 protected function findByUrl($url) 106 { 107 $templates = $this->getAll(); 108 if (array_key_exists($url, $templates)) { 109 return $this->modelsFactory($templates[$url]); 110 } 111 return false; 112 } 113 114 /** 115 * Get option by key. 116 * 117 * @param string $key The option key. 118 * @return mixed The option value. 119 */ 120 protected function getOption($key) 121 { 122 return get_option($key); 74 123 } 75 124 } -
news-parser/trunk/inc/Controller/VisualConstructorController.php
r2265315 r2977790 6 6 use NewsParserPlugin\Message\Errors; 7 7 use NewsParserPlugin\Message\Success; 8 use NewsParserPlugin\Utils\ResponseFormatter;9 8 use NewsParserPlugin\Models\PostModel; 10 9 … … 21 20 */ 22 21 23 class VisualConstructorController extends BaseController22 class VisualConstructorController 24 23 { 25 24 /** … … 33 32 * 34 33 * @param AbstractParseContent $parser 35 * @param ResponseFormatter $formatter36 34 */ 37 public function __construct(AbstractParseContent $parser , ResponseFormatter $formatter)35 public function __construct(AbstractParseContent $parser) 38 36 { 39 parent::__construct($formatter);40 37 $this->parser=$parser; 41 38 } … … 43 40 * Parse raw html data of the page. 44 41 * 45 * @uses NewsParserPlugin\Controller\BaseController::formatResponse46 42 * @param string $url Url of the page. 47 43 * @param array $options Array of options. 48 * @return ResponseFormatter44 * @return array|string 49 45 */ 50 46 public function get($url, $options = array()) 51 47 { 52 try { 53 $html_data=$this->parser->get($url, $options); 54 $response=$this->formatResponse->rawHTML($html_data); 55 } catch (MyException $e) { 56 $response = $this->formatResponse->error($e->getCode())->message('error', $e->getMessage()); 57 } 58 return $response; 48 $html_data=$this->parser->get($url, $options); 49 return $html_data; 59 50 } 60 51 /** … … 63 54 * @param string $url Url of the page. 64 55 * @param array $options Array of options. 65 * @return string56 * @return array|string 66 57 */ 67 58 public function __invoke($url, $options) -
news-parser/trunk/inc/Message/Errors.php
r2265315 r2977790 21 21 return \__('Template could not be saved right now.', NEWS_PARSER_PLUGIN_SLUG); 22 22 case 'NO_TEMPLATE': 23 return \__(' Post could not be parsed, because there is no template for that kind of posts.', NEWS_PARSER_PLUGIN_SLUG);23 return \__('There is no template for that kind of posts.', NEWS_PARSER_PLUGIN_SLUG); 24 24 case 'NO_EXTRA_OPTIONS': 25 25 return \__('Post could not be parsed, because there is no parsing options for that kind of posts.', NEWS_PARSER_PLUGIN_SLUG); 26 case 'NO_POST_OPTIONS': 27 return \__('Post could not be parsed, because there is no post options for that kind of posts.', NEWS_PARSER_PLUGIN_SLUG); 26 28 case 'FILE_DOWNLOAD': 27 29 return \__('Sorry file cannot be downloaded', NEWS_PARSER_PLUGIN_SLUG); … … 39 41 return \__('Some program error has occurred', NEWS_PARSER_PLUGIN_SLUG); 40 42 case 'NO_TITLE': 41 return \__(' No Title', NEWS_PARSER_PLUGIN_SLUG);43 return \__('Parsing error.Parsed post has no "Title".', NEWS_PARSER_PLUGIN_SLUG); 42 44 case 'NO_BODY': 43 return \__('No Body', NEWS_PARSER_PLUGIN_SLUG); 45 return \__('Parsing error.Parsed post has no "Body"', NEWS_PARSER_PLUGIN_SLUG); 46 case 'NO_AUTHOR': 47 return \__('No Author ID was set to parsed post', NEWS_PARSER_PLUGIN_SLUG); 48 case 'NO_POST_URL': 49 return \__('No source URL was set to parsed post', NEWS_PARSER_PLUGIN_SLUG); 50 case 'NO_IMAGE': 51 return \__('Parsing error.No post image URL was set to parsed post', NEWS_PARSER_PLUGIN_SLUG); 44 52 case 'SETTINGS_CANNOT_BE_SAVED': 45 53 return \__('Sorry temporary settings cannot be saved', NEWS_PARSER_PLUGIN_SLUG); 46 54 case 'OPTIONS_WRONG_FORMAT': 47 55 return \__('Options could not be saved.Wrong options format.', NEWS_PARSER_PLUGIN_SLUG); 56 case 'NO_DI_DEFENITION_FILE': 57 return \__('File with class defenitions for DI container could not be found. Check file path.', NEWS_PARSER_PLUGIN_SLUG); 58 case 'DI_DEFENITION_FILE_WRONG_ORDER': 59 return \__('In dependency defenition file wrong depandency oreder.Dependencies should be placed earlier in array', NEWS_PARSER_PLUGIN_SLUG); 60 case 'NO_NEEDED_DEPENDENCY_IN_DEFENITION': 61 return \__('No needed dependency in defenition file.', NEWS_PARSER_PLUGIN_SLUG); 62 case 'WRONG_DEFENITION_FILE_FORMAT': 63 return \__('Defenition file should be array.', NEWS_PARSER_PLUGIN_SLUG); 64 case 'NO_CRON': 65 return \__('Cron is not configured', NEWS_PARSER_PLUGIN_SLUG); 66 case 'NO_RIGHTS_TO_PUBLISH': 67 return \__('You have no rights to get, create or modify this type of content.'); 68 48 69 } 49 70 } … … 53 74 case 'BAD_REQUEST': 54 75 return '400 Bad Request'; 76 case 'INNER_ERROR': 77 return '500 Inner Error'; 78 case 'UNSUPPORTED_MEDIA_TYPE'; 79 return '415 Unsupported Media Type'; 80 case 'CONTENT_NOT_FOUND': 81 return '404 Content Not Found'; 82 case 'NO_CONTENT': 83 return '204 No Content'; 55 84 } 56 85 } -
news-parser/trunk/inc/Message/Success.php
r2265315 r2977790 18 18 case 'RSS_LIST_PARSED': 19 19 return \__('XML File successfully parsed.', 'news-parser'); 20 case 'POST_SAVED _AS_DRAFT':21 return \__('Post "%s" was successfully parsed and saved as "draft"', 'news-parser');20 case 'POST_SAVED': 21 return \__('Post "%s" was successfully parsed and saved.', 'news-parser'); 22 22 case 'TEMPLATE_SAVED': 23 23 return \__('Options was saved successful.', 'news-parser'); 24 case 'TEMPLATE_EXIST': 25 return \__('You have parsing template for this RSS thread.', 'news-parser'); 24 26 case 'FEATURED_IMAGE_SAVED': 25 27 return \__('Featured image was saved and attach to the post.', 'news-parser'); 28 case 'CRON_EXIST': 29 return \__('Cron job options already exist.', 'news-parser'); 30 case 'CRON_CREATED': 31 return \__('Cron job options successfully created.', 'news-parser'); 32 case 'CRON_DELETED': 33 return \__('Cron job options successfully deleted.', 'news-parser'); 34 26 35 } 27 36 } -
news-parser/trunk/inc/Models/PostModel.php
r2265315 r2977790 33 33 * Featured image url. 34 34 * 35 * @var string 35 * @var string|false 36 36 */ 37 37 public $image; … … 45 45 * Url of source post. 46 46 * 47 * @var string 47 * @var string|false 48 48 */ 49 49 public $sourceUrl; … … 84 84 } 85 85 $this->body = $data['body']; 86 if (!isset($data['authorId']) ||empty($data['authorId'])) {86 if (!isset($data['authorId'])) { 87 87 throw new MyException(Errors::text('NO_AUTHOR'), Errors::code('BAD_REQUEST')); 88 88 } … … 118 118 } 119 119 /** 120 * Create wordpress draft gets WP post ID and change postModel status to draft 121 * 122 * @return void 123 */ 124 public function createDraft() 125 { 126 $this->ID = $this->createPostWordPress(); 127 if ($this->ID === 0) { 128 throw new MyException(Errors::text('POST_WAS_NOT_CREATED'), Errors::code('BAD_REQUEST')); 129 } 120 * Create wordpress post, gets WP post ID. 121 * 122 * @param array $post_data Array with wp post attributes https://developer.wordpress.org/reference/functions/wp_insert_post/ 123 * @return void 124 */ 125 public function createPost($post_data=[]) 126 { 127 $this->ID = $this->createPostWordPress($post_data); 130 128 $this->getPostLinksWordpress(); 131 $this->status = 'draft';129 if(array_key_exists('post_status',$post_data)) $this->status = $post_data['post_status']; 132 130 } 133 131 /** … … 196 194 public function mediaSideloadImage($file, $post_id = 0, $desc = null, $return = 'html') 197 195 { 198 return media_sideload_image($file, $post_id, $desc, $return); 196 if(function_exists('media_sideload_image')){ 197 return \media_sideload_image($file, $post_id, $desc, $return); 198 } 199 /** WordPress Administration File API */ 200 require_once ABSPATH . 'wp-admin/includes/file.php'; 201 202 /** WordPress Image Administration API */ 203 require_once ABSPATH . 'wp-admin/includes/image.php'; 204 205 /** WordPress Media Administration API */ 206 require_once ABSPATH . 'wp-admin/includes/media.php'; 207 return \media_sideload_image($file, $post_id, $desc, $return); 199 208 } 200 209 /** 201 210 * Create wordpress post 202 211 * 212 * @param array $post_user_data Array with wp post attributes https://developer.wordpress.org/reference/functions/wp_insert_post/ 203 213 * @return int Post iD 204 214 */ 205 protected function createPostWordPress() 206 { 207 $date = new \DateTime(); 208 $post_date = $date->format('Y-m-d H:i:s'); 209 $post_data = array( 215 protected function createPostWordPress($post_user_data) 216 { 217 218 $post_initial_data = array( 210 219 'post_title' => \wp_strip_all_tags($this->title), 211 220 'post_content' => $this->body, 212 'post_date' => $post_date,213 221 'post_author' => $this->authorId, 214 215 ); 222 ); 223 if(!is_array($post_user_data))$post_user_data=[]; 224 $post_data=array_merge($post_initial_data,$post_user_data); 216 225 $postId = \wp_insert_post($post_data); 217 226 if (\is_wp_error($postId)) { … … 227 236 * @param int $id post ID in WP 228 237 * @param boolean $post_thumb if image will use NewsParserPlugin\as main image of the post 229 * @return int image ID 230 */ 231 protected function attachImageToPostWordpress($image, $id, $post_thumb = false, $alt = '') 238 * @param int $max_attempt counts of downloads attempts 239 * @return WP_Error|string image ID 240 */ 241 protected function attachImageToPostWordpress($image, $id, $post_thumb = false, $alt = '',$max_attempt=3) 232 242 { 233 243 $url = $image; 234 244 $post_id = $id; 235 245 $desc = $alt?:"image"; 236 $img_id = $this->mediaSideloadImage($url, $post_id, $desc, 'id'); 246 for ($attempt = 0;$attempt<$max_attempt;$attempt++){ 247 $img_id = $this->mediaSideloadImage($url, $post_id, $desc, 'id'); 248 if(!\is_wp_error($img_id)) break; 249 } 237 250 if (\is_wp_error($img_id)) { 238 251 throw new MyException($img_id->get_error_message().' Image url:'.esc_url_raw($url), Errors::code('BAD_REQUEST')); … … 249 262 * 250 263 * @param string $update_item name of updated field 251 * @param $data new data that will be add to the field264 * @param mixed $data new data that will be add to the field 252 265 * @return void 253 266 */ -
news-parser/trunk/inc/Models/TemplateModel.php
r2265315 r2977790 7 7 8 8 /** 9 * Class operates with parsing options.9 * Class TemplateModel 10 10 * 11 * PHP version 5.611 * This class represents a model that operates with parsing options. 12 12 * 13 13 * @package Models 14 * @author Evgeniy S.Zalevskiy <[email protected]>15 14 * @license MIT 16 15 */ 17 16 17 18 18 class TemplateModel implements ModelInterface 19 19 { 20 20 /** 21 * The name of the template table. 22 */ 23 24 protected const TEMPLATE_TABLE_NAME = NEWS_PURSER_PLUGIN_TEMPLATE_OPTIONS_NAME; 25 /** 21 26 * Url of resource that will be source of the posts feed. 22 27 * … … 27 32 * Extra options 28 33 * Structure: 34 * [addSrcSetAndSizes] - bool - add sizes attribute with image sizes breakpoints 35 * [groupImagesRow] - bool - Groups images in Guttenberg group by two and arrange them in a row 29 36 * [addFeaturedMedia]- bool- Add featured media to the post. 30 37 * [addSource] -bool - Add link to the source page to th end of the post. … … 55 62 * init function 56 63 * 57 * @param string $url Url of resource that will be source of the posts feed. 58 */ 59 public function __construct($url) 60 { 61 $this->resourceUrl=$url; 62 $this->hash=sha1($this->resourceUrl); 63 if ($options=$this->get()) { 64 $this->assignOptions($options); 65 }; 64 * @param array of template optrions. 65 * [url] 66 * [template] 67 * [extraOptions] 68 */ 69 public function __construct(array $template_data) 70 { 71 if (!$this->isOptionsValid($template_data)) { 72 throw new MyException(Errors::text('OPTIONS_WRONG_FORMAT'), Errors::code('BAD_REQUEST')); 73 } 74 $this->assignOptions($template_data); 66 75 } 67 76 /** … … 72 81 * @return boolean 73 82 */ 74 public function save($options) 75 { 76 if (!isset($options['extraOptions'])||!isset($options['template'])) { 77 throw new MyException(Errors::text('OPTIONS_WRONG_FORMAT'), Errors::code('BAD_REQUEST')); 78 } 79 $data=array( 80 'extraOptions'=>$options['extraOptions'], 81 'template'=>$options['template'] 82 ); 83 $result=update_option($this->hash, $data, '', 'no'); 84 if ($result) { 85 $this->assignOptions($data); 86 } 87 return $result; 83 public function create() 84 { 85 $templates=$this->getAll(); 86 $template_data=$this->getAttributes('array'); 87 if(!is_array($templates)) $templates=[]; 88 $templates[$this->resourceUrl]=$template_data; 89 return $this->updateOptions(self::TEMPLATE_TABLE_NAME, $templates, 'no'); 90 } 91 /** 92 * Update options using wp function update_option. 93 * 94 * @param string $key The option key. 95 * @param mixed $data The option data. 96 * @param string|null $autoload Optional. Whether to load the option when WordPress starts up ('yes' or 'no'). 97 * 98 * @return bool Returns true if the options were successfully updated, false otherwise. 99 */ 100 101 public function update() 102 { 103 $templates=$this->getAll(); 104 if(array_key_exists($this->resourceUrl,$templates)){ 105 return $this->updateOptions(self::TEMPLATE_TABLE_NAME, $templates, 'no'); 106 } 107 return false; 108 } 109 /** 110 * Delete options using wp function update_option. 111 * 112 * @return bool Returns true if the options were successfully deleted, false otherwise. 113 */ 114 115 public function delete (){ 116 $templates=$this->getAll(); 117 if(array_key_exists($this->resourceUrl,$templates)){ 118 unset($templates[$this->resourceUrl]); 119 return $this->updateOptions(self::TEMPLATE_TABLE_NAME, $templates, 'no'); 120 } 121 return false; 122 } 123 protected function updateOptions($key,$data,$autoload=null) 124 { 125 return update_option($key, $data, $autoload); 88 126 } 89 127 /** … … 92 130 * @return boolean 93 131 */ 94 public function delete()95 { 96 return delete_option( $this->hash);132 public static function deleteAll() 133 { 134 return delete_option(self::TEMPLATE_TABLE_NAME); 97 135 } 98 136 /** … … 101 139 * @return false|array 102 140 */ 103 protected function get ()104 { 105 return get_option( $this->hash);141 protected function getAll() 142 { 143 return get_option(self::TEMPLATE_TABLE_NAME); 106 144 } 107 145 /** … … 122 160 { 123 161 return isset($this->extraOptions)?$this->extraOptions:false; 124 }/** 162 } 163 /** 164 * Check if the options have a valid format. 165 * 166 * @param array $options The options to validate. 167 * 168 * @return bool Returns true if the options have a valid format, false otherwise. 169 */ 170 171 protected function isOptionsValid($options) 172 { 173 if(!isset($options['extraOptions'])|| 174 !isset($options['template'])|| 175 !isset($options['url'])){ 176 return false; 177 } 178 return true; 179 } 180 /** 125 181 * Assign options to object properties. 126 182 * … … 130 186 protected function assignOptions($options) 131 187 { 188 $this->resourceUrl=$options['url']; 132 189 $this->parseTemplate=$options['template']; 133 190 $this->extraOptions=$options['extraOptions']; 134 191 } 135 192 /** 136 * Get all options in needed format. 193 * Get all options in needed format. If no options found return Exception. 137 194 * 138 195 * @throws MyException if there is no options for that url. … … 142 199 public function getAttributes($format) 143 200 { 144 if (!isset($this->extraOptions)||!isset($this->parseTemplate)) { 145 throw new MyException(Errors::text('NO_TEMPLATE'), Errors::code('BAD_REQUEST')); 146 } 201 return $this->formatAttributes($format); 202 } 203 /** 204 * Return options data in proper format. 205 * 206 * @param string $format accept array|object|json. 207 * @return array|object|string 208 */ 209 protected function formatAttributes($format) 210 { 147 211 $data=array( 212 'url'=>$this->resourceUrl, 148 213 'extraOptions'=>$this->extraOptions, 149 214 'template'=>$this->parseTemplate -
news-parser/trunk/inc/Parser/Abstracts/AbstractParseContent.php
r2265315 r2977790 6 6 use NewsParserPlugin\Utils\Pipe; 7 7 use NewsParserPlugin\Utils\Chain; 8 use NewsParserPlugin\Models\TemplateModel; 8 9 9 10 /** … … 33 34 */ 34 35 protected $options; 35 36 37 protected $url; 36 38 /** 37 39 * @param integer $cache_expiration … … 87 89 $data = $this->wpRemoteGet($url, $request_args); 88 90 if (is_wp_error($data)) { 89 throw new MyException(Errors::text('FILE_DOWNLOAD'), Errors::code('BAD_REQUEST')); 91 $error_code=$data->get_error_code(); 92 $error_message=$data->get_error_message($error_code); 93 throw new MyException(Errors::text('FILE_DOWNLOAD'), Errors::code('INNER_ERROR')); 90 94 } 91 95 $response_code= wp_remote_retrieve_response_code($data); 92 96 if ($response_code!=200) { 93 throw new MyException(Errors::text('FILE_DOWNLOAD'), Errors::code(' BAD_REQUEST'));97 throw new MyException(Errors::text('FILE_DOWNLOAD'), Errors::code('INNER_ERROR')); 94 98 } 95 99 $body=wp_remote_retrieve_body($data); … … 100 104 * 101 105 * @param string $url url of the page that should get. 102 * @param array$options Extra options that might be used by parser.106 * @param TemplateModel $options Extra options that might be used by parser. 103 107 * @return array|stdClass|string Parsed data. 104 108 */ 105 public function get($url, $options =array())109 public function get($url, $options=array()) 106 110 { 107 if (!empty($options)) { 108 $this->options=$options; 109 } 111 $this->url=$url; 112 113 $this->options=$options; 114 110 115 $data = $this->getFromCache($url); 111 116 if (gettype($data)==='string') { -
news-parser/trunk/inc/Parser/HTMLPatternParser.php
r2265315 r2977790 3 3 4 4 use NewsParserPlugin\Parser\HTMLParser; 5 use NewsParserPlugin\Interfaces\AdapterInterface;6 5 7 6 /** 8 * Parse html using pre saved template pattern.7 * Class HTMLPatternParser 9 8 * 10 * P HP version 5.69 * Parse HTML using pre-saved template pattern. 11 10 * 12 * @package Parser 13 * @author Evgeniy S.Zalevskiy <[email protected]> 14 * @license MIT 11 * @package NewsParserPlugin\Parser 15 12 */ 16 17 13 class HTMLPatternParser extends HTMLParser 18 14 { 19 15 20 /**21 * Class that provide methods that convert array body data to string for post model22 * using gutenberg editor blocks markup.23 *24 * @var AdapterInterface25 * @method convert array of body elements data.26 */27 protected $adapter;28 16 29 17 /** 30 * Init function.18 * HTMLPatternParser constructor. 31 19 * 32 * @param int eger $cache_expiration cache expiration time.20 * @param int $cache_expiration Cache expiration time in seconds. 33 21 */ 34 public function __construct( AdapterInterface $adapter,$cache_expiration = 3600)22 public function __construct($cache_expiration = 3600) 35 23 { 36 24 parent::__construct($cache_expiration); 37 $this->adapter=$adapter;38 25 } 26 39 27 /** 40 * Parse post body 28 * Parse post body. 41 29 * 42 * @uses AdapterInterface::convert() convert array of elements into string. 43 * @return string data that would be saved as post content. 30 * 31 * @return string Data that would be saved as the post content. 32 * @throws \Exception If parsing template patterns are not set. 44 33 */ 45 46 34 public function postBody() 47 35 { 48 $search_template ='';36 $search_template = ''; 49 37 if (!isset($this->options['template'])) { 50 38 throw new \Exception('Parsing template patterns should be set.'); 51 39 } 52 $template =$this->options['template'];53 40 $template = $this->options['template']; 41 54 42 foreach ($template['children'] as $child_element) { 55 // Create search template for Sunra\HtmlDomParser::find method56 // https://simplehtmldom.sourceforge.io/manual.htm How to find HTML elements? section.57 $search_template .=$child_element['searchTemplate'].',';43 // Create search template for Sunra\HtmlDomParser::find method 44 // https://simplehtmldom.sourceforge.io/manual.htm How to find HTML elements? section. 45 $search_template .= $child_element['searchTemplate'] . ','; 58 46 } 59 $search_template =substr($search_template, 0, -1);60 $container =$this->find($template['searchTemplate']);47 $search_template = substr($search_template, 0, -1); 48 $container = $this->find($template['searchTemplate']); 61 49 62 50 if (empty($container)) { 63 51 return ''; 64 52 } 65 $elements=$container[0]->find($search_template); 66 $body=$this->parseContainer($elements); 67 68 69 return $body ? $this->adapter->convert($body):''; 53 $elements = $container[0]->find($search_template); 54 $body = $this->parseContainer($elements); 55 return $body ? $body: ''; 70 56 } 57 71 58 /** 72 * Iterate over a rray of HtmlDomParser elements and parse data.59 * Iterate over an array of HtmlDomParser elements and parse data. 73 60 * 74 * @param array $elements array of HtmlDomParser elements objects 61 * @param array $elements Array of HtmlDomParser element objects. 62 * 75 63 * @return array ['tagName'=>string,'content'=>string|array] 76 64 */ 77 65 protected function parseContainer($elements) 78 66 { 79 $body =array();67 $body = array(); 80 68 foreach ($elements as $el) { 81 $el_tag=$el->tag; 82 $el_data=array( 83 'tagName'=>$el_tag, 84 ); 85 switch ($el_tag) { 86 case 'img': 87 //If element is image content element will be type of array. 88 $el_data['content']=array( 89 'alt'=>$el->alt, 90 //if lazy load attribute data-src exists take that as source of image if none take src attribute. 91 'src'=>(is_array($el->attr)&&array_key_exists('data-src', $el->attr))?$el->attr['data-src']:$el->src 92 ); 69 $el_tag = $el->tag; 70 $el_data = array( 71 'tagName' => $el_tag, 72 ); 73 switch ($el_tag) { 74 case 'img': 75 if (!$this->isImageFitToContext($el)) { 93 76 break; 94 case 'ul': 95 //if element is list content element will be type of array. 96 $el_data['content']=array(); 97 foreach ($el->find('li') as $li) { 98 $el_data['content'][]=$this->removeTags($li->innertext); 99 } 100 break; 101 case 'iframe': 102 //find youtube video ID. 103 preg_match('/youtube\.com\/embed\/([a-zA-Z0-9\_]*)/i', $el->src, $match); 104 //remove any symbols except that is allowed. 105 $el_data['content']=array_key_exists(1, $match)?$match[1]:false; 106 break; 107 default: 108 $el_data['content']=$this->removeTags(trim($el->innertext)); 77 } 78 $image_srcset = $this->parseSourceImageTag($el); 79 // If the element is an image, the content will be of type array. 80 $el_data['content'] = array( 81 'alt' => $el->alt, 82 // If the lazy load attribute data-src exists, take that as the source of the image. If none, take the src attribute. 83 'src' => $image_srcset !== false ? $this->srcSetSplit($image_srcset) : ((is_array($el->attr) && array_key_exists('data-src', $el->attr)) ? $this->srcSetSplit($el->attr['data-src']) : $el->src), 84 'srcSet' => $image_srcset!==false ? $image_srcset : '', 85 'sizes'=>'' 86 ); 87 break; 88 case 'ul': 89 // If the element is a list, the content will be of type array. 90 $el_data['content'] = array(); 91 foreach ($el->find('li') as $li) { 92 $el_data['content'][] = $this->removeTags($li->innertext); 93 } 94 break; 95 case 'iframe': 96 // Find the YouTube video ID. 97 preg_match('/youtube\.com\/embed\/([a-zA-Z0-9\_]*)/i', $el->src, $match); 98 // Remove any symbols except those that are allowed. 99 $el_data['content'] = array_key_exists(1, $match) ? $match[1] : false; 100 break; 101 default: 102 $el_data['content'] = $this->removeTags(trim($el->innertext)); 103 } 104 if (array_key_exists('content', $el_data) && $el_data['content'] !== false) { 105 $body[] = $el_data; 106 } 107 } 108 109 return $body; 110 } 111 112 /** 113 * Parse the source image tag. 114 * 115 * @param \simple_html_dom_node $image_element Image element. 116 * 117 * @return bool|string Source set attribute value, or false if not found. 118 */ 119 protected function parseSourceImageTag($image_element) 120 { 121 // Check if the element has a parent picture 122 if ($image_element->parent->tag == 'picture') { 123 // Get child elements of the picture tag 124 $children_elements = $image_element->parent->children; 125 foreach ($children_elements as $child_element) { 126 if ($child_element->tag == 'source') { 127 if (array_key_exists('srcset', $child_element->attr)) { 128 return $child_element->attr['srcset']; 129 } 130 if (array_key_exists('data-srcset', $child_element->attr)) { 131 return $child_element->attr['data-srcset']; 132 } 109 133 } 110 if ($el_data['content']!==false) { 111 $body[]=$el_data; 112 } 113 }; 114 return $body; 134 } 135 } 136 137 return false; 138 } 139 140 /** 141 * Split the srcset string and return the last element. 142 * 143 * @param string $srcSetString The srcset string. 144 * 145 * @return string The last element of the srcset array. 146 */ 147 protected function srcSetSplit($srcSetString) 148 { 149 // Split the string into an array using ',' as the separator 150 $array = explode(',', $srcSetString); 151 152 // Iterate over each element in the array 153 foreach ($array as &$element) { 154 // Remove the part of the string that is separated by a space 155 $parts = explode(' ', trim($element)); 156 $element = $parts[0]; 157 } 158 159 return end($array); 160 } 161 162 /** 163 * Check if the image fits the content based on keywords form the post title. 164 * 165 * @param \simple_html_dom_node $image_element Image element. 166 * 167 * @return bool Whether the image fits the content based on keywords. 168 */ 169 protected function isImageFitToContext($image_element) 170 { 171 $pattern = '/\b(Or|And|It|Is|Are|Was|Were|Then|There|Here|If|Could|,|\.)\b/'; 172 $replacement = ''; 173 $keywords = preg_split('/\s+/', trim(preg_replace($pattern, $replacement, $this->post['title']))); 174 $image_alt = array_key_exists('alt', $image_element->attr) ? $image_element->attr['alt'] : ''; 175 foreach ($keywords as $keyword) { 176 if (stripos($image_alt, $keyword) !== false) { 177 return true; 178 } 179 } 180 return false; 115 181 } 116 182 } -
news-parser/trunk/inc/Parser/HTMLRaw.php
r2265315 r2977790 23 23 public function __construct($cache_expiration = 600) 24 24 { 25 $this->url='http://site.com'; 25 26 parent::__construct($cache_expiration); 26 27 } … … 33 34 protected function parse($data) 34 35 { 36 37 $data=apply_filters('htmlRaw:parse',array($data,$this->url)); 38 35 39 if (is_array($this->options)&&array_key_exists('remove_scripts', $this->options)&&$this->options['remove_scripts']) { 36 40 return $this->removeScriptTags($data); -
news-parser/trunk/inc/Parser/XMLParser.php
r2265315 r2977790 39 39 * 40 40 * @param string $xml 41 * @return arrayof StdClass41 * @return object of StdClass 42 42 * 43 43 */ … … 66 66 if (!empty($errors)) { 67 67 libxml_clear_errors(); 68 throw new MyException(Errors::text('XML_PARSING'), Errors::code(' BAD_REQUEST'));68 throw new MyException(Errors::text('XML_PARSING'), Errors::code('UNSUPPORTED_MEDIA_TYPE')); 69 69 } 70 70 … … 84 84 * @param \SimpleXMLElement $data object created by simplexml_load_string() function; 85 85 * 86 * @return objectparsed data86 * @return array|array<mixed,object> parsed data 87 87 */ 88 88 protected function formatData($data) … … 218 218 * Parse image from description using regular expression 219 219 * 220 * @param $text text of description220 * @param string $text text of description 221 221 * @return string|false 222 222 */ … … 234 234 * 235 235 * @param \SimpleXMLElement $xml 236 * @return void236 * @return string|false 237 237 */ 238 238 public function parseImageMediaTag($xml) -
news-parser/trunk/inc/Traits/SanitizeDataTrait.php
r2265315 r2977790 40 40 case 'saveParsingTemplate': 41 41 case 'addSource': 42 case 'addSrcSetAndSizes': 43 case 'groupImagesRow': 42 44 //use json_decode to prevent "false" string converted to boolean true 43 45 $clean_data[$key]=boolval(json_decode($option)); … … 51 53 } 52 54 /** 53 * Sanitize template pattern array.55 * Sanitize HTML template pattern array. 54 56 * 55 57 * @param array $template ['tagName','className','searchTemplate','children'] 56 58 * @return array 57 59 */ 58 public function sanitize Template($template)60 public function sanitizeHTMLtemplate($html_template) 59 61 { 60 $clean_data=$this->sanitizeTemplateElement($ template);62 $clean_data=$this->sanitizeTemplateElement($html_template); 61 63 $clean_data['children']=array(); 62 foreach ($ template['children'] as $child) {64 foreach ($html_template['children'] as $child) { 63 65 array_push($clean_data['children'], $this->sanitizeTemplateElement($child)); 64 66 } 65 67 return $clean_data; 68 } 69 public function sanitizeTemplate($template) 70 { 71 return $clean_data=array( 72 'template'=>$this->sanitizeHTMLtemplate($template['template']), 73 'extraOptions'=>$this->sanitizeExtraOptions($template['extraOptions']), 74 'url'=>\esc_url($template['url']), 75 'postOptions'=>$this->sanitizePostOptions($template['postOptions']) 76 ); 77 } 78 protected function sanitizePostOptions($post_options){ 79 //ToDo: Implement post options sanitizing 80 return $post_options; 66 81 } 67 82 /** … … 69 84 * 70 85 * @param array $el ['tagName','className','searchTemplate','position'] 71 * @return void86 * @return array 72 87 */ 73 88 protected function sanitizeTemplateElement($el) … … 91 106 return $clean_data; 92 107 } 108 public function sanitizeInteger($value){ 109 return intval($value); 110 } 111 /** 112 * @return array 113 */ 114 public function sanitizeCronOptions($option){ 115 $clean_data=array(); 116 $clean_data['maxCronCalls']=intval($option['maxCronCalls']); 117 $clean_data['maxCronCalls']=$clean_data['maxCronCalls']>100?100:$clean_data['maxCronCalls']; 118 $clean_data['maxPostsParsed']=intval($option['maxPostsParsed']); 119 $clean_data['maxPostsParsed']=$clean_data['maxPostsParsed']>100?100:$clean_data['maxCronCalls']; 120 $clean_data['interval']=preg_replace('/[^h,o,u,r,l,y,t,w,i,c,e,d,a,k]/i','',$option['interval']); 121 return $clean_data; 122 } 93 123 } -
news-parser/trunk/inc/Traits/ValidateDataTrait.php
r2265315 r2977790 31 31 public function validateImageUrl($input_url) 32 32 { 33 $filetype=wp_check_filetype($input_url); 33 $imageFileTypes = array( 34 'jpg|jpeg' => 'image/jpeg', 35 'png' => 'image/png', 36 'gif' => 'image/gif', 37 'bmp' => 'image/bmp', 38 'svg' => 'image/svg+xml', 39 'webp' => 'image/webp', 40 'ico' => 'image/x-icon' 41 ); 42 43 $filetype=wp_check_filetype($input_url,$imageFileTypes); 34 44 $mime_type=$filetype['type']; 35 45 if (false!==strpos($mime_type, 'image')) { 36 46 return true; 37 47 } 38 return new \WP_Error(400, 'Given url is not a valid image url.URL: '.esc_url_raw($input_url));48 return new \WP_Error(400, 'Given url is not a valid image url.URL: '.esc_url_raw($input_url)); 39 49 } 40 50 /** … … 55 65 return true; 56 66 } 67 57 68 /** 58 69 * Validate structure of input extra options. … … 66 77 $extra_option_should_have_keys=array( 67 78 'addSource', 79 'groupImagesRow', 68 80 'addFeaturedMedia', 69 ' saveParsingTemplate'81 'addSrcSetAndSizes' 70 82 ); 71 83 … … 79 91 * @return true|/WP_Error 80 92 */ 81 public function validate Template($template)93 public function validateHTMLTemplate($html_template) 82 94 { 83 95 $container_should_have_keys=array( … … 89 101 $child_should_have_keys=array_slice($container_should_have_keys, 0, -2); 90 102 array_push($child_should_have_keys, 'position'); 91 if (!$this->checkArrayKeys($container_should_have_keys, $ template)) {103 if (!$this->checkArrayKeys($container_should_have_keys, $html_template)) { 92 104 return false; 93 105 } 94 if (!is_array($ template['children'])) {106 if (!is_array($html_template['children'])) { 95 107 return new \WP_Error(400, 'Template patterns array should have children section.'); 96 108 } 97 foreach ($ template['children'] as $child) {109 foreach ($html_template['children'] as $child) { 98 110 if (is_wp_error($result = $this->checkArrayKeys($child_should_have_keys, $child))) { 99 111 return $result; … … 119 131 return new \WP_Error(400, 'No needed parameters in extraOptions parsing options array.Missing keys:'.implode(',', $has_difference)); 120 132 } 133 public function validateTemplate($template){ 134 $template_should_have_keys=array( 135 'url', 136 'extraOptions', 137 'template', 138 'postOptions' 139 ); 140 if (!$this->checkArrayKeys($template_should_have_keys, $template)) { 141 return false; 142 } 143 return $this->validateExtraOptions($template['extraOptions'])&&$this->validateHTMLTemplate($template['template']); 144 } 121 145 } -
news-parser/trunk/inc/Utils/Pipe.php
r2265315 r2977790 67 67 return $this; 68 68 } 69 /** 70 * @return \NewsParserPlugin\Utils\Pipe 71 */ 69 72 protected function callFunc($function_name, $args) 70 73 { -
news-parser/trunk/inc/Utils/ResponseFormatter.php
r2265315 r2977790 1 1 <?php 2 2 namespace NewsParserPlugin\Utils; 3 3 4 4 5 /** … … 13 14 */ 14 15 15 class ResponseFormatter 16 { 16 class ResponseFormatter { 17 17 18 18 /** … … 27 27 * @var array 28 28 */ 29 protected $data=array('code'=>200,'msg'=>false); 30 /** 31 * Return new instance of ResponseFormatter 32 * 33 * @return ResponseFormatter 34 */ 35 public static function getInstance() 36 { 37 return new static(); 38 } 29 protected $data=array(); 39 30 /** 40 31 * Format answer after post draw was created … … 72 63 public function dialog($type, $data) 73 64 { 74 $this->data['d ialog']=array(65 $this->data['data']=array( 75 66 'type'=>$type, 76 'd ata'=>$data67 'dialogData'=>$data 77 68 ); 78 69 return $this; … … 125 116 126 117 if ($status=='none') { 127 $this->data['m sg']=false;118 $this->data['message']=false; 128 119 } else { 129 $this->data['m sg']=array(120 $this->data['message']=array( 130 121 131 122 'type'=>esc_html($status), … … 135 126 ); 136 127 } 128 return $this; 129 } 130 /** 131 * Template options 132 * 133 * @param string $options array of template-options 134 * @return ResponseFormatter return this for chain building 135 */ 136 public function options($options) 137 { 138 $this->data['data']=$options; 137 139 return $this; 138 140 } … … 150 152 $this->data['data'][$escaped_field_name]=$escaped_value; 151 153 return $this; 154 } 155 /** 156 * Returns status code 157 */ 158 public function getCode() 159 { 160 return $this->data['code']; 152 161 } 153 162 /** -
news-parser/trunk/news-parser.php
r2287195 r2977790 4 4 Plugin URI: https://github.com/zalevsk1y/news-parser 5 5 Description: Parse full text news from RSS Feed 6 Version: 1.0.26 Version: 2.0.0 7 7 Author: Evgeny S.Zalevskiy <[email protected]> 8 8 Author URI: https://github.com/zalevsk1y/ … … 12 12 ?> 13 13 <?php 14 namespace NewsParserPlugin;15 14 16 15 17 define('NEWS_PARSER_PLUGIN_VERSION', '1.0.2'); 16 17 define('NEWS_PARSER_PLUGIN_VERSION', '2.0.0'); 18 18 define("NEWS_PARSER_PLUGIN_SLUG", 'news-parser'); 19 19 define("NEWS_PARSER_PLUGIN_ROOT_NAMESPACE", 'NewsParserPlugin'); … … 28 28 define ("NEWS_PARSER_PLUGIN_VISUAL_CONSTRUCTOR","visual-constructor"); 29 29 define ("NEWS_PARSER_PLUGIN_PARSER_RSS","parser-rss"); 30 define ("NEWS_PURSER_PLUGIN_TEMPLATE_OPTIONS_NAME","news_parser_plugin_template_options"); 31 define ("NEWS_PURSER_PLUGIN_CRON_OPTIONS_NAME","news_parser_plugin_cron_options"); 32 define ("NEWS_PARSER_CRON_ACTION_PREFIX","news_parser_cron_"); 30 33 31 34 32 35 require 'autoload.php'; 33 36 if(\file_exists(NEWS_PARSER_PLUGIN_DIR.'vendor/autoload.php')) require NEWS_PARSER_PLUGIN_DIR.'vendor/autoload.php'; 37 require 'bootstrap.php'; 34 38 39 add_action('init','NewsParserPlugin\news_parser_init'); 35 40 36 37 38 39 $container_builder=new \DI\ContainerBuilder(); 40 $container_builder->addDefinitions(NEWS_PARSER_PLUGIN_DIR.'di-config.php'); 41 $container=$container_builder->build(); 42 $event_controller=$container->make(Controller\EventController::class,array($container)); 43 44 $event_controller->on('media:create',array(Controller\MediaController::class,'create')); 45 $event_controller->on('template:create',array(Controller\TemplateController::class,'create')); 46 $event_controller->on('list:get',array(Controller\ListController::class,'get')); 47 $event_controller->on('html:get',array(Controller\VisualConstructorController::class,'get')); 48 $event_controller->on('post:create',array(Controller\PostController::class,'create')); 49 50 Controller\AjaxController::create($event_controller); 51 52 Core\Main::start($container->get(Menu\Admin\MenuPage::class),$container->get(Utils\MenuConfig::class)); 53 54 \register_uninstall_hook(__FILE__, 'Utils\Settings::deleteSettings'); 41 42 require 'tear-down.php'; -
news-parser/trunk/public/css/about-news-parser.css
r2265315 r2977790 6 6 min-width:350px; 7 7 width:700px; 8 font-size: 1rem; 8 9 } 9 .container-about li{10 list-style:initial;10 .container-about p{ 11 font-size: 1rem; 11 12 } 12 13 .youtube-video-container{ … … 21 22 height: 100%; 22 23 } 24 .styled-list{ 25 list-style: inside; 26 } -
news-parser/trunk/public/css/frame-style.css
r2265315 r2977790 1 .mouse-over{ 2 outline: 2px dotted rgb(107, 214, 204); 3 background-color: rgba(107, 214, 204,0.5); 4 } 5 .parser-select{ 1 .mouse-over { 2 outline: rgba(107, 214, 204, 0.5) dotted 3px; 3 background-color: rgba(107, 214, 204, 0.5); 6 4 box-sizing: border-box; 7 border: 3px solid rgb(107, 214, 204); 8 background-color: rgba(107, 214, 204,0.8); 9 } 5 } 6 7 img.parser-select { 8 background-color: rgba(107, 214, 204, 0.8); 9 opacity: 50%; 10 } 11 .parser-select{ 12 box-sizing: border-box; 13 background-color:rgba(107, 214, 204, 0.8); 14 outline: rgba(107, 214, 204, 0.8) solid 3px; 15 } 16 10 17 .news-parser-youtube{ 11 18 width: 100%; -
news-parser/trunk/readme.txt
r2287195 r2977790 4 4 Author: Evgeniy Zalevskiy 5 5 Tags: scraper,parser,rss,news,autopilot 6 Requires PHP: 5.67 Requires at least: 3.5.08 Tested up to: 5.3.29 Stable tag: 1.0.26 Requires PHP: 7.2 7 Requires at least: 5.2.0 8 Tested up to: 6.3.1 9 Stable tag: 2.0.0 10 10 License: MIT 11 11 License URI: https://opensource.org/licenses/MIT … … 19 19 20 20 * Gutenberg editor support. 21 * Autopilot Function for Automatic RSS Parsing 21 22 * Visual content extractor. 22 23 * Flexible template creation system to speed up parsing. … … 25 26 == Future plans == 26 27 27 * Add auto-pilot feature.28 28 * Parsing videos from other(than YouTube) sources. 29 29 * Saving images to the Media Library . … … 45 45 Watch this short video to learn HOW TO PARSE FROM RSS with news-parser plugin: 46 46 47 https://www.youtube.com/watch?v= xrZdkV0xA0847 https://www.youtube.com/watch?v=Aiye15Cp5_8 48 48 49 49 To parse several posts, select posts and press the Parse Selected button. Wait for the data to be saved,you`ll be notified by the message at the top of the screen. The icon at the bottom of the post allows you to go on to edit or publish a saved draft.Note that parsing selected post could be done only if you created parsing template! … … 51 51 Watch this short video to learn HOW TO PARSE SEVERAL POSTS with news-parser plugin: 52 52 53 https://www.youtube.com/watch?v= 1LttLG9n4t453 https://www.youtube.com/watch?v=m85PExDeAMA 54 54 55 55 = Visual Constructor. = … … 64 64 Watch this short video to learn HOW TO USE VISUAL CONSTRUCTOR: 65 65 66 https://www.youtube.com/watch?v= gGqbRBnGeNE66 https://www.youtube.com/watch?v=0yS0ptvBpzY 67 67 68 68 = Create Parsing Template = … … 72 72 Watch this short video to learn HOW TO CREATE PARSING TEMPLATE: 73 73 74 https://www.youtube.com/watch?v= gWo2aRTGttM74 https://www.youtube.com/watch?v=0awSRLWsP 75 75 76 76 = Parse single page. = … … 80 80 Watch this short video to learn HOW TO PARSE SINGLE PAGE with news-parser plugin: 81 81 82 https://www.youtube.com/watch?v=9x56djil-b0 82 https://www.youtube.com/watch?v=Sbke_LF-TFA 83 84 = Autopilot Function for Automatic RSS Parsing = 85 86 The autopilot function is now available to automatically parse posts from an RSS feed. Please note that the wp-cron (`https://developer.wordpress.org/plugins/cron/`) is used for scheduling the autopilot function, which triggers the task scheduler only when the website is visited. If you encounter issues with this function, you can add the following option to the wp-config.php file: `define('ALTERNATE_WP_CRON', true);` 87 88 To configure the autopilot settings, follow these steps: 89 90 1. Navigate to the Autopilot tab in the menu (News Parser -> Autopilot). 91 2. In the Schedule Options, select the URL that corresponds to the RSS source from which parsing will take place. 92 3. Click on the Select button. 93 4. After the data is loaded, the following options will be available: 94 95 - Status: Determines whether the autopilot is activated for this source. 96 - Maximum Number of Posts: Sets the maximum number of posts to be parsed from this source. 97 - Maximum Number of Autopilot Runs: Specifies the maximum number of times the autopilot should run for this source. 98 - Parsing Frequency: Defines the frequency at which parsing should occur from this source. 99 100 5. Additionally, in this menu, you can delete previously saved parsing templates. 101 102 103 Watch this short video to learn HOW TO USE AUTOPILOT with news-parser plugin: 104 105 https://www.youtube.com/watch?v=Eu_5GR32nB0 83 106 84 107 == Dependencies == … … 88 111 == Bugs == 89 112 90 If you find an issue, let us know [here](https://github.com/zalevsk1y/news-parser/issues?state=open)! 113 If you find an issue, let us know [here](https://github.com/zalevsk1y/news-parser/issues?state=open) or [Discord](https://discord.gg/mxhJ9hE4) 114 115 == Contacts == 116 117 * [GitHub](https://github.com/zalevsk1y/news-parser) 118 * [Discord](https://discord.gg/mxhJ9hE4) 119 * [Instagram](https://www.instagram.com/wp_news_parser) 91 120 92 121 == Changelog == 122 123 124 = 2.0.0 - 11-10-23 125 126 * Added: Autopilot functions for automate post parsing. 127 * Added: Post options system 128 * Fix: some bugs. 93 129 94 130 = 1.0.2 - 20-04-21 = -
news-parser/trunk/template/menu/about-menu.php
r2265315 r2977790 1 1 <div class='wrap wrap-about-news-parser'> 2 2 <div class="container-about"> 3 <h 1>Welcome to News-Parser <?php echo NEWS_PARSER_PLUGIN_VERSION ?></h1>3 <h2>Welcome to News-Parser <?php echo NEWS_PARSER_PLUGIN_VERSION ?></h2> 4 4 <br> 5 5 … … 15 15 draft,which you can just publish or edit at your discretion. This makes it easy to create content for 16 16 your site.</p> 17 <h 2>Features</h2>18 <ul >17 <h3>Features</h3> 18 <ul class='styled-list'> 19 19 <li>Support of Gutenberg editor</li> 20 <li>Autopilot Function for Automatic RSS Parsing</li> 20 21 <li>Visual content extractor</li> 21 22 <li>Flexible template creation system to speed up parsing</li> 22 23 <li>Ability to parse not only from RSS XML source but also </li> 23 24 </ul> 24 <h2>Future plans</h2> 25 <ul> 26 <li>Add auto-pilot feature.</li> 25 <h3>Future plans</h3> 26 <ul class='styled-list'> 27 27 <li>Parsing videos from other(than YouTube) sources</li> 28 28 <li>Saving images to the Media Library</li> 29 29 <li>Have an idea? – Please, feel free to let me know. Let’s make News-Parser even better!</li> 30 30 </ul> 31 <h 2>Installing</h2>31 <h3>Installing</h3> 32 32 <ol> 33 33 <li>You can clone the GitHub repository: <code>https://github.com/zalevsk1y/news-parser.git</code></li> … … 36 36 </ol> 37 37 <p>This will download the latest developer copy of News-parser.</p> 38 <h2>How to use News-Parser plugin?</h2> 39 <h3>Parsing RSS.</h3> 40 <p>To parse RSS, go to the News-Parsing->Parsing RSS menu in the admin panel of your site. Enter the RSS feed address in the search bar. Click on the Parse RSS Feed button. When parsed data is fetched from the server,it will appear on your screen. You can open the visual extractor by clicking on the icon and create a template for parsing posts from this RSS source or simply select the content you are interested in and save it as a draft.</p> 41 38 <h3>How to use News-Parser plugin?</h3> 39 <h4>Parsing RSS</h4> 40 <p>To parse RSS, follow these steps in the admin panel of your website under the News Parsing -> Parsing RSS menu:</p> 41 <ul class='styled-list'> 42 <li>Enter the RSS feed address in the search bar.</li> 43 <li>Click on the "Parse RSS Feed" button.</li> 44 </ul> 45 <p>Once the parsed data is fetched from the server, it will appear on your screen. 46 You can open the visual extractor by clicking on the icon. The visual extractor allows you to create a template for parsing posts from this RSS source. 47 Alternatively, you can manually select the content you are interested in and save it as a draft. 48 In the visual editor, you'll also find several options available:</p> 49 <ul class='styled-list'> 50 <li>Categories: You can assign categories to the parsed posts. This helps organize the content and make it easier for users to navigate.</li> 51 <li>Tags: You can add tags to the parsed posts. Tags provide additional metadata to describe the content and make it more discoverable.</li> 52 <li>Publishing Options: You can choose whether the post should be published immediately after parsing or saved as a draft. This gives you control over when the content goes live on your website.</li> 53 </ul> 54 <p>After selecting the desired content, you need to click on the "Create Post" button. Once the data is processed, the post will be created. If necessary, you can continue editing the post in the built-in WordPress editor by clicking on the "Edit post" icon. This will open the saved post in the built-in editor in a separate browser tab. After saving the changes, you can check the result on your website to ensure that the post appears as intended.</p> 42 55 <p>Watch this short video to learn HOW TO PARSE FROM RSS with news-parser plugin:</p> 43 <div class="youtube-video-container "><iframe src="https://www.youtube.com/embed/xrZdkV0xA08" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>56 <div class="youtube-video-container mb-4 "><iframe src="https://www.youtube.com/embed/Aiye15Cp5_8" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div> 44 57 <p>To parse several posts, select posts and press the Parse Selected button. Wait for the data to be saved,you`ll be notified by the message at the top of the screen. The icon at the bottom of the post allows you to go on to edit or publish a saved draft.Note that parsing selected post could be done only if you created parsing template!</p> 45 58 46 59 <p>Watch this short video to learn HOW TO PARSE SEVERAL POSTS:</p> 47 <div class="youtube-video-container "><iframe src="https://www.youtube.com/embed/1LttLG9n4t4" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>60 <div class="youtube-video-container mb-4"><iframe src="https://www.youtube.com/embed/m85PExDeAMA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div> 48 61 49 <h 3>Visual Constructor.</h3>62 <h4>Visual Constructor</h4> 50 63 51 64 <p>To create a template or simply select the content you are interested in, use the visual constructor. You can open visual constructor by clicking icon at the bottom of post box. 52 65 To select content, click on the block that you need in the main window and it will be marked with a turquoise frame. When you hover over the content, the expected area will be painted in turquoise color. 53 To cancel the selection, click on the block again. Try to separate different types of content (pictures, video, text) into separate blocks. The YouTube video will be replaced with a picture of the YouTube logo. You can extrude it and this video will be inserted into your post. Parsing videos from other sources is not yet supported. Pictures are inserted into your post as a link; the exception is a featured image which is saved in your media library. 54 In the sidebar, you can change the featured image of your post. Just select the appropriate image on the left side of the designer and click the Change Image button. The last image you selected will be selected as featured image. You can also create a post without featured image. Just click on No featured image. 55 You can change the name of the post in the next submenu 'Post title'. Write your version of the post title in textaria and click the Change Title button. 66 To cancel the selection, click on the block again.</p> 67 <p>Try to separate different types of content (pictures, video, text) into separate blocks. The YouTube video will be replaced with a picture of the YouTube logo. You can extrude it and this video will be inserted into your post. Parsing videos from other sources is not yet supported. Pictures are inserted into your post as a link; the exception is a featured image which is saved in your media library. 68 In the sidebar, you can change the featured image of your post. Just select the appropriate image on the left side of the designer and click the Change Image button. The last image you selected will be selected as featured image. You can also create a post without featured image. Just click on No featured image.</p> 69 <p>You can change the name of the post in the next submenu 'Post title'. Write your version of the post title in textaria and click the Change Title button. 56 70 To add a source link, check the box labeled 'Add source link' to the post. in the 'Extra Options' submenu.</p> 57 71 58 72 <p>Watch this short video to learn HOW TO USE VISUAL CONSTRUCTOR:</p> 59 <div class="youtube-video-container "><iframe src="https://www.youtube.com/embed/gGqbRBnGeNE" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>73 <div class="youtube-video-container mb-4"><iframe src="https://www.youtube.com/embed/0yS0ptvBpzY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div> 60 74 61 <h 3>Create Parsing Template</h3>75 <h4>Create Parsing Template</h4> 62 76 <p>To save the template, it is necessary to mark the content in the main window of the visual constructor, select the 'Save parsing template that you can use in automatic parsing from this source item.' and click the Save Tempalte button. It is important to understand that individual posts even from one source can be very different, therefore parsed pages may not contain the content you need.</p> 63 77 <p>Watch this short video to learn HOW TO CREATE PARSING TEMPLATE:</p> 64 <div class="youtube-video-container "><iframe src="https://www.youtube.com/embed/gWo2aRTGttM" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>65 <h 3>Parsing single page.</h3>78 <div class="youtube-video-container mb-4"><iframe src="https://www.youtube.com/embed/0awSRLWsP-I" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div> 79 <h4>Parsing single page.</h4> 66 80 <p>To parse a single page, select News-Parsing-> Parse Page in the admin panel of your site. In the search bar, enter the site address URL and press Parse Page button. Visual constructor will open. In the visual constructor, select the content and click the Create Post Draft button. The draft will be automatically created and you can edit it in the Posts editor.If everything suits you, you can simply publish this post or edit it at your discretion.</p> 67 81 <p>Watch this short video to learn HOW TO PARSE SINGLE PAGE with news-parser plugin:</p> 68 <div class="youtube-video-container"><iframe src="https://www.youtube.com/embed/9x56djil-b0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div> 69 70 <h2>Dependencies</h2> 82 <div class="youtube-video-container mb-4"><iframe src="https://www.youtube.com/embed/Sbke_LF-TFA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div> 83 84 <h4>Autopilot Function for Automatic RSS Parsing</h4> 85 <p>The autopilot function is now available to automatically parse posts from an RSS feed. Please note that the <a href="https://developer.wordpress.org/plugins/cron/">wp-cron</a> is used for scheduling the autopilot function, which triggers the task scheduler only when the website is visited. If you encounter issues with this function, you can add the following option to the <code>wp-config.php</code> file: <code>define('ALTERNATE_WP_CRON', true);</code></p> 86 <p>To configure the autopilot settings, follow these steps:</p> 87 <ol type='1' start='1'> 88 <li>Navigate to the Autopilot tab in the menu (News Parser -> Autopilot).</li> 89 <li>In the Schedule Options, select the URL that corresponds to the RSS source from which parsing will take place.</li> 90 <li>Click on the Select button.</li> 91 <li>After the data is loaded, the following options will be available: 92 <ul class='styled-list'> 93 <li>Status: Determines whether the autopilot is activated for this source.</li> 94 <li>Maximum Number of Posts: Sets the maximum number of posts to be parsed from this source.</li> 95 <li>Maximum Number of Autopilot Runs: Specifies the maximum number of times the autopilot should run for this source.</li> 96 <li>Parsing Frequency: Defines the frequency at which parsing should occur from this source.</li> 97 </ul> 98 </li> 99 <li>Additionally, in this menu, you can delete previously saved parsing templates.</li> 100 </ol> 101 <p>Watch this short video to learn HOW TO USE AUTOPILOT with news-parser plugin.</p> 102 <div class="youtube-video-container mb-4"><iframe src="https://www.youtube.com/embed/Eu_5GR32nB0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div> 103 <h3>Dependencies</h3> 71 104 <ul> 72 105 <li>php-simple-html-dom-parser <a … … 74 107 </li> 75 108 </ul> 76 <h2>If you find an issue, let us know <a 77 href="https://github.com/zalevsk1y/news-parser/issues?state=open">here</a>!</p> 109 <p> 110 If you have any thoughts, feedback, or proposals, feel free to connect with the author: 111 </p> 112 <ul className='list-unstyled list-inline'> 113 <li class="list-inline-item"> 114 <img alt='Instagram icon' className='me-2' height="20px" src=<?php echo NEWS_PARSER_PLUGIN_URL.'/public/images/clipart1375168_d6sh2a.png'?> /> 115 <a href="https://www.instagram.com/wp_news_parser" aria-label="Instagram - Connect with the author"> 116 117 Instagram 118 </a> 119 </li> 120 <li class="list-inline-item"> 121 <img alt='Discord icon' className='me-2' height="25px" src=<?php echo NEWS_PARSER_PLUGIN_URL.'/public/images/discord-icon-43742_qoe0fc.png'?> /> 122 <a href="https://discord.gg/mxhJ9hE4" aria-label="Discord - Connect with the author"> 123 124 Discord 125 </a> 126 </li> 127 </ul> 128 78 129 </article> 79 130 -
news-parser/trunk/template/menu/parsing-rss-menu.php
r2265315 r2977790 1 1 2 <div class='wrap wrap-parsing' id="parsing-rss-app" data-lang="<?php echo get_locale(); ?>"> 2 <div class="main-parsing-container"> 3 4 <div class='wrap wrap-parsing' id="parsing-rss-app" data-lang="<?php echo get_locale(); ?>"> 5 6 </div> 7 <div class="left-main-sidebar sidebar-width" id="parser-sidebar-left"></div> 3 8 </div> 4 5 9 -
news-parser/trunk/vendor/autoload.php
r2265315 r2977790 3 3 // autoload.php @generated by Composer 4 4 5 if (PHP_VERSION_ID < 50600) { 6 if (!headers_sent()) { 7 header('HTTP/1.1 500 Internal Server Error'); 8 } 9 $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; 10 if (!ini_get('display_errors')) { 11 if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { 12 fwrite(STDERR, $err); 13 } elseif (!headers_sent()) { 14 echo $err; 15 } 16 } 17 trigger_error( 18 $err, 19 E_USER_ERROR 20 ); 21 } 22 5 23 require_once __DIR__ . '/composer/autoload_real.php'; 6 24 7 return ComposerAutoloaderInit c5537c9966d2012b1bdd902c7c2b0215::getLoader();25 return ComposerAutoloaderInit2a5deef53365ace058e7e02595992282::getLoader(); -
news-parser/trunk/vendor/composer/ClassLoader.php
r2265315 r2977790 38 38 * @author Fabien Potencier <[email protected]> 39 39 * @author Jordi Boggiano <[email protected]> 40 * @see http ://www.php-fig.org/psr/psr-0/41 * @see http ://www.php-fig.org/psr/psr-4/40 * @see https://www.php-fig.org/psr/psr-0/ 41 * @see https://www.php-fig.org/psr/psr-4/ 42 42 */ 43 43 class ClassLoader 44 44 { 45 /** @var \Closure(string):void */ 46 private static $includeFile; 47 48 /** @var string|null */ 49 private $vendorDir; 50 45 51 // PSR-4 52 /** 53 * @var array<string, array<string, int>> 54 */ 46 55 private $prefixLengthsPsr4 = array(); 56 /** 57 * @var array<string, list<string>> 58 */ 47 59 private $prefixDirsPsr4 = array(); 60 /** 61 * @var list<string> 62 */ 48 63 private $fallbackDirsPsr4 = array(); 49 64 50 65 // PSR-0 66 /** 67 * List of PSR-0 prefixes 68 * 69 * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) 70 * 71 * @var array<string, array<string, list<string>>> 72 */ 51 73 private $prefixesPsr0 = array(); 74 /** 75 * @var list<string> 76 */ 52 77 private $fallbackDirsPsr0 = array(); 53 78 79 /** @var bool */ 54 80 private $useIncludePath = false; 81 82 /** 83 * @var array<string, string> 84 */ 55 85 private $classMap = array(); 86 87 /** @var bool */ 56 88 private $classMapAuthoritative = false; 89 90 /** 91 * @var array<string, bool> 92 */ 57 93 private $missingClasses = array(); 94 95 /** @var string|null */ 58 96 private $apcuPrefix; 59 97 98 /** 99 * @var array<string, self> 100 */ 101 private static $registeredLoaders = array(); 102 103 /** 104 * @param string|null $vendorDir 105 */ 106 public function __construct($vendorDir = null) 107 { 108 $this->vendorDir = $vendorDir; 109 self::initializeIncludeClosure(); 110 } 111 112 /** 113 * @return array<string, list<string>> 114 */ 60 115 public function getPrefixes() 61 116 { 62 117 if (!empty($this->prefixesPsr0)) { 63 return call_user_func_array('array_merge', $this->prefixesPsr0);118 return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); 64 119 } 65 120 … … 67 122 } 68 123 124 /** 125 * @return array<string, list<string>> 126 */ 69 127 public function getPrefixesPsr4() 70 128 { … … 72 130 } 73 131 132 /** 133 * @return list<string> 134 */ 74 135 public function getFallbackDirs() 75 136 { … … 77 138 } 78 139 140 /** 141 * @return list<string> 142 */ 79 143 public function getFallbackDirsPsr4() 80 144 { … … 82 146 } 83 147 148 /** 149 * @return array<string, string> Array of classname => path 150 */ 84 151 public function getClassMap() 85 152 { … … 88 155 89 156 /** 90 * @param array $classMap Class to filename map 157 * @param array<string, string> $classMap Class to filename map 158 * 159 * @return void 91 160 */ 92 161 public function addClassMap(array $classMap) … … 103 172 * appending or prepending to the ones previously set for this prefix. 104 173 * 105 * @param string $prefix The prefix 106 * @param array|string $paths The PSR-0 root directories 107 * @param bool $prepend Whether to prepend the directories 174 * @param string $prefix The prefix 175 * @param list<string>|string $paths The PSR-0 root directories 176 * @param bool $prepend Whether to prepend the directories 177 * 178 * @return void 108 179 */ 109 180 public function add($prefix, $paths, $prepend = false) 110 181 { 182 $paths = (array) $paths; 111 183 if (!$prefix) { 112 184 if ($prepend) { 113 185 $this->fallbackDirsPsr0 = array_merge( 114 (array)$paths,186 $paths, 115 187 $this->fallbackDirsPsr0 116 188 ); … … 118 190 $this->fallbackDirsPsr0 = array_merge( 119 191 $this->fallbackDirsPsr0, 120 (array)$paths192 $paths 121 193 ); 122 194 } … … 127 199 $first = $prefix[0]; 128 200 if (!isset($this->prefixesPsr0[$first][$prefix])) { 129 $this->prefixesPsr0[$first][$prefix] = (array)$paths;201 $this->prefixesPsr0[$first][$prefix] = $paths; 130 202 131 203 return; … … 133 205 if ($prepend) { 134 206 $this->prefixesPsr0[$first][$prefix] = array_merge( 135 (array)$paths,207 $paths, 136 208 $this->prefixesPsr0[$first][$prefix] 137 209 ); … … 139 211 $this->prefixesPsr0[$first][$prefix] = array_merge( 140 212 $this->prefixesPsr0[$first][$prefix], 141 (array)$paths213 $paths 142 214 ); 143 215 } … … 148 220 * appending or prepending to the ones previously set for this namespace. 149 221 * 150 * @param string $prefix The prefix/namespace, with trailing '\\'151 * @param array|string $paths The PSR-4 base directories152 * @param bool $prepend Whether to prepend the directories222 * @param string $prefix The prefix/namespace, with trailing '\\' 223 * @param list<string>|string $paths The PSR-4 base directories 224 * @param bool $prepend Whether to prepend the directories 153 225 * 154 226 * @throws \InvalidArgumentException 227 * 228 * @return void 155 229 */ 156 230 public function addPsr4($prefix, $paths, $prepend = false) 157 231 { 232 $paths = (array) $paths; 158 233 if (!$prefix) { 159 234 // Register directories for the root namespace. 160 235 if ($prepend) { 161 236 $this->fallbackDirsPsr4 = array_merge( 162 (array)$paths,237 $paths, 163 238 $this->fallbackDirsPsr4 164 239 ); … … 166 241 $this->fallbackDirsPsr4 = array_merge( 167 242 $this->fallbackDirsPsr4, 168 (array)$paths243 $paths 169 244 ); 170 245 } … … 176 251 } 177 252 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 178 $this->prefixDirsPsr4[$prefix] = (array)$paths;253 $this->prefixDirsPsr4[$prefix] = $paths; 179 254 } elseif ($prepend) { 180 255 // Prepend directories for an already registered namespace. 181 256 $this->prefixDirsPsr4[$prefix] = array_merge( 182 (array)$paths,257 $paths, 183 258 $this->prefixDirsPsr4[$prefix] 184 259 ); … … 187 262 $this->prefixDirsPsr4[$prefix] = array_merge( 188 263 $this->prefixDirsPsr4[$prefix], 189 (array)$paths264 $paths 190 265 ); 191 266 } … … 196 271 * replacing any others previously set for this prefix. 197 272 * 198 * @param string $prefix The prefix 199 * @param array|string $paths The PSR-0 base directories 273 * @param string $prefix The prefix 274 * @param list<string>|string $paths The PSR-0 base directories 275 * 276 * @return void 200 277 */ 201 278 public function set($prefix, $paths) … … 212 289 * replacing any others previously set for this namespace. 213 290 * 214 * @param string $prefix The prefix/namespace, with trailing '\\'215 * @param array|string $paths The PSR-4 base directories291 * @param string $prefix The prefix/namespace, with trailing '\\' 292 * @param list<string>|string $paths The PSR-4 base directories 216 293 * 217 294 * @throws \InvalidArgumentException 295 * 296 * @return void 218 297 */ 219 298 public function setPsr4($prefix, $paths) … … 235 314 * 236 315 * @param bool $useIncludePath 316 * 317 * @return void 237 318 */ 238 319 public function setUseIncludePath($useIncludePath) … … 257 338 * 258 339 * @param bool $classMapAuthoritative 340 * 341 * @return void 259 342 */ 260 343 public function setClassMapAuthoritative($classMapAuthoritative) … … 277 360 * 278 361 * @param string|null $apcuPrefix 362 * 363 * @return void 279 364 */ 280 365 public function setApcuPrefix($apcuPrefix) … … 297 382 * 298 383 * @param bool $prepend Whether to prepend the autoloader or not 384 * 385 * @return void 299 386 */ 300 387 public function register($prepend = false) 301 388 { 302 389 spl_autoload_register(array($this, 'loadClass'), true, $prepend); 390 391 if (null === $this->vendorDir) { 392 return; 393 } 394 395 if ($prepend) { 396 self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; 397 } else { 398 unset(self::$registeredLoaders[$this->vendorDir]); 399 self::$registeredLoaders[$this->vendorDir] = $this; 400 } 303 401 } 304 402 305 403 /** 306 404 * Unregisters this instance as an autoloader. 405 * 406 * @return void 307 407 */ 308 408 public function unregister() 309 409 { 310 410 spl_autoload_unregister(array($this, 'loadClass')); 411 412 if (null !== $this->vendorDir) { 413 unset(self::$registeredLoaders[$this->vendorDir]); 414 } 311 415 } 312 416 … … 315 419 * 316 420 * @param string $class The name of the class 317 * @return bool|null True if loaded, null otherwise421 * @return true|null True if loaded, null otherwise 318 422 */ 319 423 public function loadClass($class) 320 424 { 321 425 if ($file = $this->findFile($class)) { 322 includeFile($file); 426 $includeFile = self::$includeFile; 427 $includeFile($file); 323 428 324 429 return true; 325 430 } 431 432 return null; 326 433 } 327 434 … … 368 475 } 369 476 477 /** 478 * Returns the currently registered loaders keyed by their corresponding vendor directories. 479 * 480 * @return array<string, self> 481 */ 482 public static function getRegisteredLoaders() 483 { 484 return self::$registeredLoaders; 485 } 486 487 /** 488 * @param string $class 489 * @param string $ext 490 * @return string|false 491 */ 370 492 private function findFileWithExtension($class, $ext) 371 493 { … … 433 555 return false; 434 556 } 557 558 /** 559 * @return void 560 */ 561 private static function initializeIncludeClosure() 562 { 563 if (self::$includeFile !== null) { 564 return; 565 } 566 567 /** 568 * Scope isolated include. 569 * 570 * Prevents access to $this/self from included files. 571 * 572 * @param string $file 573 * @return void 574 */ 575 self::$includeFile = \Closure::bind(static function($file) { 576 include $file; 577 }, null, null); 578 } 435 579 } 436 437 /**438 * Scope isolated include.439 *440 * Prevents access to $this/self from included files.441 */442 function includeFile($file)443 {444 include $file;445 } -
news-parser/trunk/vendor/composer/autoload_classmap.php
r2265315 r2977790 3 3 // autoload_classmap.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 8 8 return array( 9 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', 9 10 ); -
news-parser/trunk/vendor/composer/autoload_namespaces.php
r2265315 r2977790 3 3 // autoload_namespaces.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 -
news-parser/trunk/vendor/composer/autoload_psr4.php
r2265315 r2977790 3 3 // autoload_psr4.php @generated by Composer 4 4 5 $vendorDir = dirname( dirname(__FILE__));5 $vendorDir = dirname(__DIR__); 6 6 $baseDir = dirname($vendorDir); 7 7 8 8 return array( 9 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), 10 'PhpDocReader\\' => array($vendorDir . '/php-di/phpdoc-reader/src/PhpDocReader'), 11 'Invoker\\' => array($vendorDir . '/php-di/invoker/src'), 12 'Interop\\Container\\' => array($vendorDir . '/container-interop/container-interop/src/Interop/Container'), 13 'DI\\' => array($vendorDir . '/php-di/php-di/src/DI'), 9 'ContainerBuilder\\' => array($vendorDir . '/zalevsk1y/container-builder/src'), 14 10 ); -
news-parser/trunk/vendor/composer/autoload_real.php
r2265315 r2977790 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit c5537c9966d2012b1bdd902c7c2b02155 class ComposerAutoloaderInit2a5deef53365ace058e7e02595992282 6 6 { 7 7 private static $loader; … … 14 14 } 15 15 16 /** 17 * @return \Composer\Autoload\ClassLoader 18 */ 16 19 public static function getLoader() 17 20 { … … 20 23 } 21 24 22 spl_autoload_register(array('ComposerAutoloaderInitc5537c9966d2012b1bdd902c7c2b0215', 'loadClassLoader'), true, true); 23 self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 24 spl_autoload_unregister(array('ComposerAutoloaderInitc5537c9966d2012b1bdd902c7c2b0215', 'loadClassLoader')); 25 require __DIR__ . '/platform_check.php'; 25 26 26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());27 if ($useStaticLoader) {28 require_once __DIR__ . '/autoload_static.php';27 spl_autoload_register(array('ComposerAutoloaderInit2a5deef53365ace058e7e02595992282', 'loadClassLoader'), true, true); 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 29 spl_autoload_unregister(array('ComposerAutoloaderInit2a5deef53365ace058e7e02595992282', 'loadClassLoader')); 29 30 30 call_user_func(\Composer\Autoload\ComposerStaticInitc5537c9966d2012b1bdd902c7c2b0215::getInitializer($loader)); 31 } else { 32 $map = require __DIR__ . '/autoload_namespaces.php'; 33 foreach ($map as $namespace => $path) { 34 $loader->set($namespace, $path); 35 } 36 37 $map = require __DIR__ . '/autoload_psr4.php'; 38 foreach ($map as $namespace => $path) { 39 $loader->setPsr4($namespace, $path); 40 } 41 42 $classMap = require __DIR__ . '/autoload_classmap.php'; 43 if ($classMap) { 44 $loader->addClassMap($classMap); 45 } 46 } 31 require __DIR__ . '/autoload_static.php'; 32 call_user_func(\Composer\Autoload\ComposerStaticInit2a5deef53365ace058e7e02595992282::getInitializer($loader)); 47 33 48 34 $loader->register(true); 49 50 if ($useStaticLoader) {51 $includeFiles = Composer\Autoload\ComposerStaticInitc5537c9966d2012b1bdd902c7c2b0215::$files;52 } else {53 $includeFiles = require __DIR__ . '/autoload_files.php';54 }55 foreach ($includeFiles as $fileIdentifier => $file) {56 composerRequirec5537c9966d2012b1bdd902c7c2b0215($fileIdentifier, $file);57 }58 35 59 36 return $loader; 60 37 } 61 38 } 62 63 function composerRequirec5537c9966d2012b1bdd902c7c2b0215($fileIdentifier, $file)64 {65 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {66 require $file;67 68 $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;69 }70 } -
news-parser/trunk/vendor/composer/autoload_static.php
r2265315 r2977790 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit c5537c9966d2012b1bdd902c7c2b02157 class ComposerStaticInit2a5deef53365ace058e7e02595992282 8 8 { 9 public static $files = array (10 'bbf73f3db644d3dced353b837903e74c' => __DIR__ . '/..' . '/php-di/php-di/src/DI/functions.php',11 );12 13 9 public static $prefixLengthsPsr4 = array ( 14 ' P' =>10 'C' => 15 11 array ( 16 'Psr\\Container\\' => 14, 17 'PhpDocReader\\' => 13, 18 ), 19 'I' => 20 array ( 21 'Invoker\\' => 8, 22 'Interop\\Container\\' => 18, 23 ), 24 'D' => 25 array ( 26 'DI\\' => 3, 12 'ContainerBuilder\\' => 17, 27 13 ), 28 14 ); 29 15 30 16 public static $prefixDirsPsr4 = array ( 31 ' Psr\\Container\\' =>17 'ContainerBuilder\\' => 32 18 array ( 33 0 => __DIR__ . '/..' . '/psr/container/src', 34 ), 35 'PhpDocReader\\' => 36 array ( 37 0 => __DIR__ . '/..' . '/php-di/phpdoc-reader/src/PhpDocReader', 38 ), 39 'Invoker\\' => 40 array ( 41 0 => __DIR__ . '/..' . '/php-di/invoker/src', 42 ), 43 'Interop\\Container\\' => 44 array ( 45 0 => __DIR__ . '/..' . '/container-interop/container-interop/src/Interop/Container', 46 ), 47 'DI\\' => 48 array ( 49 0 => __DIR__ . '/..' . '/php-di/php-di/src/DI', 19 0 => __DIR__ . '/..' . '/zalevsk1y/container-builder/src', 50 20 ), 51 21 ); … … 61 31 ); 62 32 33 public static $classMap = array ( 34 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', 35 ); 36 63 37 public static function getInitializer(ClassLoader $loader) 64 38 { 65 39 return \Closure::bind(function () use ($loader) { 66 $loader->prefixLengthsPsr4 = ComposerStaticInitc5537c9966d2012b1bdd902c7c2b0215::$prefixLengthsPsr4; 67 $loader->prefixDirsPsr4 = ComposerStaticInitc5537c9966d2012b1bdd902c7c2b0215::$prefixDirsPsr4; 68 $loader->prefixesPsr0 = ComposerStaticInitc5537c9966d2012b1bdd902c7c2b0215::$prefixesPsr0; 40 $loader->prefixLengthsPsr4 = ComposerStaticInit2a5deef53365ace058e7e02595992282::$prefixLengthsPsr4; 41 $loader->prefixDirsPsr4 = ComposerStaticInit2a5deef53365ace058e7e02595992282::$prefixDirsPsr4; 42 $loader->prefixesPsr0 = ComposerStaticInit2a5deef53365ace058e7e02595992282::$prefixesPsr0; 43 $loader->classMap = ComposerStaticInit2a5deef53365ace058e7e02595992282::$classMap; 69 44 70 45 }, null, ClassLoader::class); -
news-parser/trunk/vendor/composer/installed.json
r2265315 r2977790 1 [ 2 { 3 "name": "caophihung94/php-simple-html-dom-parser", 4 "version": "v1.7.3", 5 "version_normalized": "1.7.3.0", 6 "source": { 7 "type": "git", 8 "url": "https://github.com/caophihung94/php-simple-html-dom-parser.git", 9 "reference": "84876d96cb39518ca2a1a5a1ac560d3531a9cc95" 1 { 2 "packages": [ 3 { 4 "name": "caophihung94/php-simple-html-dom-parser", 5 "version": "v1.7.3", 6 "version_normalized": "1.7.3.0", 7 "source": { 8 "type": "git", 9 "url": "https://github.com/caophihung94/php-simple-html-dom-parser.git", 10 "reference": "84876d96cb39518ca2a1a5a1ac560d3531a9cc95" 11 }, 12 "dist": { 13 "type": "zip", 14 "url": "https://api.github.com/repos/caophihung94/php-simple-html-dom-parser/zipball/84876d96cb39518ca2a1a5a1ac560d3531a9cc95", 15 "reference": "84876d96cb39518ca2a1a5a1ac560d3531a9cc95", 16 "shasum": "" 17 }, 18 "require": { 19 "php": ">=5.3.2" 20 }, 21 "time": "2019-02-27T11:00:03+00:00", 22 "type": "library", 23 "installation-source": "dist", 24 "autoload": { 25 "psr-0": { 26 "HungCP\\PhpSimpleHtmlDom\\HtmlDomParser": "src/" 27 } 28 }, 29 "notification-url": "https://packagist.org/downloads/", 30 "license": [ 31 "MIT" 32 ], 33 "authors": [ 34 { 35 "name": "S.C. Chen", 36 "email": "[email protected]" 37 }, 38 { 39 "name": "Cao Phi Hung", 40 "email": "[email protected]" 41 } 42 ], 43 "description": "PHP Simple HTML DOM Parser with namespace and PHP 7.3 compatible", 44 "homepage": "http://simplehtmldom.sourceforge.net/", 45 "keywords": [ 46 "Simple", 47 "dom", 48 "html", 49 "html dom parser" 50 ], 51 "support": { 52 "issues": "https://github.com/caophihung94/php-simple-html-dom-parser/issues", 53 "source": "https://github.com/caophihung94/php-simple-html-dom-parser/tree/v1.7.3" 54 }, 55 "install-path": "../caophihung94/php-simple-html-dom-parser" 10 56 }, 11 "dist": { 12 "type": "zip", 13 "url": "https://api.github.com/repos/caophihung94/php-simple-html-dom-parser/zipball/84876d96cb39518ca2a1a5a1ac560d3531a9cc95", 14 "reference": "84876d96cb39518ca2a1a5a1ac560d3531a9cc95", 15 "shasum": "" 16 }, 17 "require": { 18 "php": ">=5.3.2" 19 }, 20 "time": "2019-02-27T11:00:03+00:00", 21 "type": "library", 22 "installation-source": "dist", 23 "autoload": { 24 "psr-0": { 25 "HungCP\\PhpSimpleHtmlDom\\HtmlDomParser": "src/" 26 } 27 }, 28 "notification-url": "https://packagist.org/downloads/", 29 "license": [ 30 "MIT" 31 ], 32 "authors": [ 33 { 34 "name": "S.C. Chen", 35 "email": "[email protected]" 57 { 58 "name": "zalevsk1y/container-builder", 59 "version": "v1.0.2", 60 "version_normalized": "1.0.2.0", 61 "source": { 62 "type": "git", 63 "url": "https://github.com/zalevsk1y/container-builder.git", 64 "reference": "f7d6a7cf6bcadc8c796882b839cfe4c0b5c4837d" 36 65 }, 37 { 38 "name": "Cao Phi Hung", 39 "email": "[email protected]" 40 } 41 ], 42 "description": "PHP Simple HTML DOM Parser with namespace and PHP 7.3 compatible", 43 "homepage": "http://simplehtmldom.sourceforge.net/", 44 "keywords": [ 45 "Simple", 46 "dom", 47 "html", 48 "html dom parser" 49 ] 50 }, 51 { 52 "name": "container-interop/container-interop", 53 "version": "1.2.0", 54 "version_normalized": "1.2.0.0", 55 "source": { 56 "type": "git", 57 "url": "https://github.com/container-interop/container-interop.git", 58 "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8" 59 }, 60 "dist": { 61 "type": "zip", 62 "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8", 63 "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8", 64 "shasum": "" 65 }, 66 "require": { 67 "psr/container": "^1.0" 68 }, 69 "time": "2017-02-14T19:40:03+00:00", 70 "type": "library", 71 "installation-source": "dist", 72 "autoload": { 73 "psr-4": { 74 "Interop\\Container\\": "src/Interop/Container/" 75 } 76 }, 77 "notification-url": "https://packagist.org/downloads/", 78 "license": [ 79 "MIT" 80 ], 81 "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", 82 "homepage": "https://github.com/container-interop/container-interop", 83 "abandoned": "psr/container" 84 }, 85 { 86 "name": "php-di/invoker", 87 "version": "1.3.3", 88 "version_normalized": "1.3.3.0", 89 "source": { 90 "type": "git", 91 "url": "https://github.com/PHP-DI/Invoker.git", 92 "reference": "1f4ca63b9abc66109e53b255e465d0ddb5c2e3f7" 93 }, 94 "dist": { 95 "type": "zip", 96 "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/1f4ca63b9abc66109e53b255e465d0ddb5c2e3f7", 97 "reference": "1f4ca63b9abc66109e53b255e465d0ddb5c2e3f7", 98 "shasum": "" 99 }, 100 "require": { 101 "container-interop/container-interop": "~1.1" 102 }, 103 "require-dev": { 104 "athletic/athletic": "~0.1.8", 105 "phpunit/phpunit": "~4.5" 106 }, 107 "time": "2016-07-14T13:09:58+00:00", 108 "type": "library", 109 "installation-source": "dist", 110 "autoload": { 111 "psr-4": { 112 "Invoker\\": "src/" 113 } 114 }, 115 "notification-url": "https://packagist.org/downloads/", 116 "license": [ 117 "MIT" 118 ], 119 "description": "Generic and extensible callable invoker", 120 "homepage": "https://github.com/PHP-DI/Invoker", 121 "keywords": [ 122 "callable", 123 "dependency", 124 "dependency-injection", 125 "injection", 126 "invoke", 127 "invoker" 128 ] 129 }, 130 { 131 "name": "php-di/php-di", 132 "version": "5.4.6", 133 "version_normalized": "5.4.6.0", 134 "source": { 135 "type": "git", 136 "url": "https://github.com/PHP-DI/PHP-DI.git", 137 "reference": "3f9255659595f3e289f473778bb6c51aa72abbbd" 138 }, 139 "dist": { 140 "type": "zip", 141 "url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/3f9255659595f3e289f473778bb6c51aa72abbbd", 142 "reference": "3f9255659595f3e289f473778bb6c51aa72abbbd", 143 "shasum": "" 144 }, 145 "require": { 146 "container-interop/container-interop": "~1.2", 147 "php": ">=5.5.0", 148 "php-di/invoker": "^1.3.2", 149 "php-di/phpdoc-reader": "^2.0.1", 150 "psr/container": "~1.0" 151 }, 152 "provide": { 153 "container-interop/container-interop-implementation": "^1.0", 154 "psr/container-implementation": "^1.0" 155 }, 156 "replace": { 157 "mnapoli/php-di": "*" 158 }, 159 "require-dev": { 160 "doctrine/annotations": "~1.2", 161 "doctrine/cache": "~1.4", 162 "mnapoli/phpunit-easymock": "~0.2.0", 163 "ocramius/proxy-manager": "~1.0|~2.0", 164 "phpbench/phpbench": "@dev", 165 "phpunit/phpunit": "~4.5" 166 }, 167 "suggest": { 168 "doctrine/annotations": "Install it if you want to use annotations (version ~1.2)", 169 "doctrine/cache": "Install it if you want to use the cache (version ~1.4)", 170 "ocramius/proxy-manager": "Install it if you want to use lazy injection (version ~1.0 or ~2.0)" 171 }, 172 "time": "2017-12-03T08:20:27+00:00", 173 "type": "library", 174 "installation-source": "dist", 175 "autoload": { 176 "psr-4": { 177 "DI\\": "src/DI/" 66 "dist": { 67 "type": "zip", 68 "url": "https://api.github.com/repos/zalevsk1y/container-builder/zipball/f7d6a7cf6bcadc8c796882b839cfe4c0b5c4837d", 69 "reference": "f7d6a7cf6bcadc8c796882b839cfe4c0b5c4837d", 70 "shasum": "" 178 71 }, 179 "files": [ 180 "src/DI/functions.php" 181 ] 182 }, 183 "notification-url": "https://packagist.org/downloads/", 184 "license": [ 185 "MIT" 186 ], 187 "description": "The dependency injection container for humans", 188 "homepage": "http://php-di.org/", 189 "keywords": [ 190 "container", 191 "dependency injection", 192 "di" 193 ] 194 }, 195 { 196 "name": "php-di/phpdoc-reader", 197 "version": "2.1.1", 198 "version_normalized": "2.1.1.0", 199 "source": { 200 "type": "git", 201 "url": "https://github.com/PHP-DI/PhpDocReader.git", 202 "reference": "15678f7451c020226807f520efb867ad26fbbfcf" 203 }, 204 "dist": { 205 "type": "zip", 206 "url": "https://api.github.com/repos/PHP-DI/PhpDocReader/zipball/15678f7451c020226807f520efb867ad26fbbfcf", 207 "reference": "15678f7451c020226807f520efb867ad26fbbfcf", 208 "shasum": "" 209 }, 210 "require": { 211 "php": ">=5.4.0" 212 }, 213 "require-dev": { 214 "phpunit/phpunit": "~4.6" 215 }, 216 "time": "2019-09-26T11:24:58+00:00", 217 "type": "library", 218 "installation-source": "dist", 219 "autoload": { 220 "psr-4": { 221 "PhpDocReader\\": "src/PhpDocReader" 222 } 223 }, 224 "notification-url": "https://packagist.org/downloads/", 225 "license": [ 226 "MIT" 227 ], 228 "description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)", 229 "keywords": [ 230 "phpdoc", 231 "reflection" 232 ] 233 }, 234 { 235 "name": "psr/container", 236 "version": "1.0.0", 237 "version_normalized": "1.0.0.0", 238 "source": { 239 "type": "git", 240 "url": "https://github.com/php-fig/container.git", 241 "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" 242 }, 243 "dist": { 244 "type": "zip", 245 "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", 246 "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", 247 "shasum": "" 248 }, 249 "require": { 250 "php": ">=5.3.0" 251 }, 252 "time": "2017-02-14T16:28:37+00:00", 253 "type": "library", 254 "extra": { 255 "branch-alias": { 256 "dev-master": "1.0.x-dev" 257 } 258 }, 259 "installation-source": "dist", 260 "autoload": { 261 "psr-4": { 262 "Psr\\Container\\": "src/" 263 } 264 }, 265 "notification-url": "https://packagist.org/downloads/", 266 "license": [ 267 "MIT" 268 ], 269 "authors": [ 270 { 271 "name": "PHP-FIG", 272 "homepage": "http://www.php-fig.org/" 273 } 274 ], 275 "description": "Common Container Interface (PHP FIG PSR-11)", 276 "homepage": "https://github.com/php-fig/container", 277 "keywords": [ 278 "PSR-11", 279 "container", 280 "container-interface", 281 "container-interop", 282 "psr" 283 ] 284 } 285 ] 72 "require": { 73 "php": ">=5.6" 74 }, 75 "require-dev": { 76 "phpunit/phpunit": "5.7.2" 77 }, 78 "time": "2023-10-09T11:59:22+00:00", 79 "type": "library", 80 "installation-source": "dist", 81 "autoload": { 82 "psr-4": { 83 "ContainerBuilder\\": "src/" 84 } 85 }, 86 "notification-url": "https://packagist.org/downloads/", 87 "license": [ 88 "MIT" 89 ], 90 "authors": [ 91 { 92 "name": "Evgeny Zalevsky" 93 } 94 ], 95 "description": "Container Builder, provides a simple implementation of a Dependency Injection Container. It allows for easy management of object instances and their dependencies, allowing for more flexible and maintainable code. The module includes methods for adding definition files, retrieving instances, and calling methods on instances with specified arguments. This can help improve code organization and reduce coupling between classes, leading to a more robust and scalable application.", 96 "support": { 97 "issues": "https://github.com/zalevsk1y/container-builder/issues", 98 "source": "https://github.com/zalevsk1y/container-builder/tree/v1.0.2" 99 }, 100 "install-path": "../zalevsk1y/container-builder" 101 } 102 ], 103 "dev": true, 104 "dev-package-names": [] 105 }
Note: See TracChangeset
for help on using the changeset viewer.