Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 48a79e0

Browse files
- Changed the internal directory structure to load classes properly.
1 parent a75f9a8 commit 48a79e0

File tree

4 files changed

+52
-40
lines changed

4 files changed

+52
-40
lines changed

‎ChangeLog.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Change Log
22

3+
### 1.4.3 - 2020年04月04日
4+
- Changed the internal directory structure to load classes properly.
5+
36
### 1.4.2 - 2020年04月03日
47
- Changed the internal directory structure to support Composer class autoload.
58

‎web/include/class-map.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
return array(
3+
"PHPSimpleWebScraper\Registry" => \PHPSimpleWebScraper\Registry::$sDirPath . "/include/class/Registry.php",
34
"PHPSimpleWebScraper\Browser\Browser" => \PHPSimpleWebScraper\Registry::$sDirPath . "/include/class/Browser/Browser.php",
45
"PHPSimpleWebScraper\Browser\PhantomJSWrapper" => \PHPSimpleWebScraper\Registry::$sDirPath . "/include/class/Browser/PhantomJSWrapper.php",
56
"PHPSimpleWebScraper\Browser\ScreenCapture" => \PHPSimpleWebScraper\Registry::$sDirPath . "/include/class/Browser/ScreenCapture.php",

‎web/include/class/Registry.php‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
4+
namespace PHPSimpleWebScraper;
5+
6+
/**
7+
* Stores the basic information of the program.
8+
* @package PHPSimpleWebScraper
9+
*/
10+
class Registry {
11+
12+
const NAME = 'Simple Web Scraper';
13+
const SLUG = 'SimpleWebScraper';
14+
const SUBTITLE = 'Fetches even JavaScript generated contents.';
15+
const DESCRIPTION = 'A web page content proxy scraper, supporting JavaScript generated contents, a cross domain solution.';
16+
const PROGRAM_URI = 'https://github.com/michaeluno/php-simple-web-scraper';
17+
const VERSION = '1.4.3';
18+
const AUTHOR = 'Michael Uno';
19+
const AUTHOR_URI = 'http://en.michaeluno.jp';
20+
21+
static public $sFilePath;
22+
static public $sDirPath;
23+
static public $sTempDirPath;
24+
25+
static public function setUp( $sFilePath ) {
26+
self::$sFilePath = $sFilePath;
27+
self::$sDirPath = dirname( self::$sFilePath );
28+
self::$sTempDirPath = sys_get_temp_dir() . '/' . self::SLUG;
29+
// Includes
30+
require dirname( self::$sDirPath ) . '/vendor/autoload.php'; // composer
31+
self::registerClasses( include( self::$sDirPath . '/include/class-map.php' ) );
32+
}
33+
34+
static public function registerClasses( array $aClasses ) {
35+
self::$___aAutoLoadClasses = $aClasses + self::$___aAutoLoadClasses;
36+
spl_autoload_register( array( __CLASS__, 'replyToLoadClass' ) );
37+
}
38+
static private $___aAutoLoadClasses = array();
39+
static public function replyToLoadClass( $sCalledUnknownClassName ) {
40+
if ( ! isset( self::$___aAutoLoadClasses[ $sCalledUnknownClassName ] ) ) {
41+
return;
42+
}
43+
include( self::$___aAutoLoadClasses[ $sCalledUnknownClassName ] );
44+
}
45+
46+
}

‎web/index.php‎

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,11 @@
11
<?php
22

3-
namespace PHPSimpleWebScraper;
4-
53
// Display Errors
64
error_reporting(E_ALL);
75
ini_set('display_errors', 1);
86

9-
// Basic Information
10-
class Registry {
11-
12-
const NAME = 'Simple Web Scraper';
13-
const SLUG = 'SimpleWebScraper';
14-
const SUBTITLE = 'Fetches even JavaScript generated contents.';
15-
const DESCRIPTION = 'A web page content proxy scraper, supporting JavaScript generated contents, a cross domain solution.';
16-
const PROGRAM_URI = 'https://github.com/michaeluno/php-simple-web-scraper';
17-
const VERSION = '1.4.2';
18-
const AUTHOR = 'Michael Uno';
19-
const AUTHOR_URI = 'http://en.michaeluno.jp';
20-
21-
static public $sFilePath = __FILE__;
22-
static public $sDirPath;
23-
static public $sTempDirPath;
24-
25-
static public function setUp() {
26-
self::$sDirPath = dirname( self::$sFilePath );
27-
self::$sTempDirPath = sys_get_temp_dir() . '/' . self::SLUG;
28-
// Includes
29-
require dirname( dirname( __FILE__ ) ) . '/vendor/autoload.php'; // composer
30-
self::registerClasses( include( dirname( __FILE__ ) . '/include/class-map.php' ) );
31-
}
32-
33-
static public function registerClasses( array $aClasses ) {
34-
self::$___aAutoLoadClasses = $aClasses + self::$___aAutoLoadClasses;
35-
spl_autoload_register( array( __CLASS__, 'replyToLoadClass' ) );
36-
}
37-
static private $___aAutoLoadClasses = array();
38-
static public function replyToLoadClass( $sCalledUnknownClassName ) {
39-
if ( ! isset( self::$___aAutoLoadClasses[ $sCalledUnknownClassName ] ) ) {
40-
return;
41-
}
42-
include( self::$___aAutoLoadClasses[ $sCalledUnknownClassName ] );
43-
}
44-
45-
}
46-
Registry::setUp();
7+
require dirname( __FILE__ ) . '/include/class/Registry.php';
8+
\PHPSimpleWebScraper\Registry::setUp( __FILE__ );
479

4810
// HTTP Headers
4911
header( 'Access-Control-Allow-Origin: *' );

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /