Index: trunk/extensions/ArchiveLinks/SpecialModifyBlacklist.php |
— | — | @@ -1,94 +0,0 @@ |
2 | | -<?php |
3 | | -if ( !defined( 'MEDIAWIKI' ) ) { |
4 | | - echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
5 | | - die( 1 ); |
6 | | -} |
7 | | - |
8 | | -class SpecialModifyBlacklist extends SpecialPage { |
9 | | - function __construct() { |
10 | | - parent::__construct( 'ModifyBlacklist' ); |
11 | | - |
12 | | - } |
13 | | - |
14 | | - public function execute ( $par ) { |
15 | | - global $wgOut, $wgRequest; |
16 | | - $this->setHeaders(); |
17 | | - $this->outputHeader(); |
18 | | - |
19 | | - $wgOut->addWikiText( wfMsg( 'archivelinks-modify-blacklist-desc' ) ); |
20 | | - |
21 | | - $wgOut->addHTML( |
22 | | - HTML::openElement('form', array( 'method' => 'post', 'action' => SpecialPage::getTitleFor( 'ModifyBlacklist' )->getLocalUrl() )) . |
23 | | - HTML::openElement('fieldset') . |
24 | | - HTML::element( 'legend', null, wfMsg( 'ModifyBlacklist' ) ) . |
25 | | - //HTML::hidden( 'title', SpecialPage::getTitleFor( 'ArchiveBlacklist' )->getPrefixedText() ) . |
26 | | - HTML::openElement('table') . |
27 | | - HTML::openElement('tr') . |
28 | | - HTML::openElement('td') . |
29 | | - wfMsg( 'archivelinks-modify-blacklist-blacklist-or-whitelist-field-label' ) . |
30 | | - HTML::closeElement('td') . |
31 | | - HTML::openElement('td') . |
32 | | - HTML::element( 'input', array( 'name' => 'bl_blacklist-whitelist', 'type' => 'radio', 'value' => 'blacklist' ) ) . |
33 | | - ' ' . |
34 | | - wfMsg( 'archivelinks-modify-blacklist-blacklist-field-label' ) . |
35 | | - HTML::closeElement('td') . |
36 | | - HTML::closeElement('tr') . |
37 | | - HTML::openElement('tr') . |
38 | | - HTML::openElement('td') . |
39 | | - HTML::closeElement('td') . |
40 | | - HTML::openElement('td') . |
41 | | - HTML::element( 'input', array( 'name' => 'bl_blacklist-whitelist', 'type' => 'radio', 'value' => 'whitelist' ) ) . |
42 | | - ' ' . |
43 | | - wfMsg( 'archivelinks-modify-blacklist-whitelist-field-label' ) . |
44 | | - HTML::closeElement('td') . |
45 | | - HTML::closeElement('tr') . |
46 | | - HTML::openElement('tr') . |
47 | | - HTML::openElement('td') . |
48 | | - wfMsg( 'archivelinks-modify-blacklist-add-or-remove-field-label' ) . |
49 | | - HTML::closeElement('td') . |
50 | | - HTML::openElement('td') . |
51 | | - HTML::element( 'input', array( 'name' => 'bl_add-remove', 'type' => 'radio', 'value' => 'add' ) ) . |
52 | | - ' ' . |
53 | | - wfMsg( 'archivelinks-modify-blacklist-add-field-label' ) . |
54 | | - HTML::closeElement('td') . |
55 | | - HTML::closeElement('tr') . |
56 | | - HTML::openElement('tr') . |
57 | | - HTML::openElement('td') . |
58 | | - HTML::closeElement('td') . |
59 | | - HTML::openElement('td') . |
60 | | - HTML::element( 'input', array( 'name' => 'bl_add-remove', 'type' => 'radio', 'value' => 'remove' ) ) . |
61 | | - ' ' . |
62 | | - wfMsg( 'archivelinks-modify-blacklist-remove-field-label' ) . |
63 | | - HTML::closeElement('td') . |
64 | | - HTML::closeElement('tr') . |
65 | | - HTML::openElement('tr') . |
66 | | - HTML::openElement('td') . |
67 | | - HTML::element( 'label' , array( 'for' => 'bl_url' ), wfMsg( 'archivelinks-modify-blacklist-url-field-label' ) ) . |
68 | | - HTML::closeElement('td') . |
69 | | - HTML::openElement('td') . |
70 | | - HTML::element( 'input', array( 'name' => 'bl_url', 'type' => 'text', 'size' => '110' ) ) . |
71 | | - HTML::closeElement('td') . |
72 | | - HTML::closeElement('tr') . |
73 | | - HTML::openElement('tr') . |
74 | | - HTML::openElement('td') . |
75 | | - HTML::element( 'label', array( 'for' => 'bl_duration' ), wfMsg( 'archivelinks-modify-blacklist-duration-field-label' )) . |
76 | | - HTML::closeElement('td') . |
77 | | - HTML::openElement('td') . |
78 | | - HTML::element( 'input', array( 'name' => 'bl_duration', 'type' => 'text', 'size' => '60' ) ) . |
79 | | - HTML::closeElement('td') . |
80 | | - HTML::closeElement('tr') . |
81 | | - HTML::openElement('tr') . |
82 | | - HTML::openElement('td') . |
83 | | - HTML::element( 'label', array( 'for' => 'bl_reason' ), wfMsg( 'archivelinks-modify-blacklist-reason-field-label' )) . |
84 | | - HTML::closeElement('td') . |
85 | | - HTML::openElement('td') . |
86 | | - HTML::element( 'input', array( 'name' => 'bl_reason', 'type' => 'text', 'size' => '60' ) ) . |
87 | | - HTML::closeElement('td') . |
88 | | - HTML::closeElement('tr') . |
89 | | - HTML::closeElement('table') . |
90 | | - XML::submitButton( 'Blacklist URL' ) . |
91 | | - HTML::closeElement('fieldset') . |
92 | | - HTML::closeElement('form') |
93 | | - ); |
94 | | - } |
95 | | -} |
\ No newline at end of file |
Index: trunk/extensions/ArchiveLinks/Spider.php |
— | — | @@ -1,79 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * This class is for the actual spidering and will be calling wget |
5 | | - */ |
6 | | - |
7 | | -$path = getenv( 'MW_INSTALL_PATH' ); |
8 | | -if ( strval( $path ) === '' ) { |
9 | | - $path = dirname( __FILE__ ) . '/../..'; |
10 | | -} |
11 | | - |
12 | | -require_once "$path/maintenance/Maintenance.php"; |
13 | | - |
14 | | -class ArchiveLinksSpider extends Maintenance { |
15 | | - private $db_master; |
16 | | - private $db_slave; |
17 | | - private $db_result; |
18 | | - |
19 | | - public function execute() { |
20 | | - global $wgArchiveLinksConfig; |
21 | | - |
22 | | - $this->db_master = $this->getDB( DB_MASTER ); |
23 | | - $this->db_slave = $this->getDB( DB_SLAVE ); |
24 | | - $this->db_result = array(); |
25 | | - |
26 | | - if ( $wgArchiveLinksConfig['run_spider_in_loop'] ) { |
27 | | - while ( TRUE ) { |
28 | | - if ( ( $url = $this->check_queue() ) !== false ) { |
29 | | - //do stuff |
30 | | - } |
31 | | - sleep(1); |
32 | | - } |
33 | | - } else { |
34 | | - if ( ( $url = $this->check_queue() ) !== false ) { |
35 | | - //do stuff |
36 | | - } |
37 | | - } |
38 | | - return null; |
39 | | - } |
40 | | - |
41 | | - private function check_queue() { |
42 | | - $this->db_result['job-fetch'] = $this->db_slave->select( 'el_archive_queue', '*', |
43 | | - '`el_archive_queue`.`delay_time` <= ' . time() |
44 | | - . ' AND `el_archive_queue`.`in_progress` = 0' |
45 | | - . ' ORDER BY `el_archive_queue`.`queue_id` ASC' |
46 | | - . ' LIMIT 1'); |
47 | | - |
48 | | - if ( $this->db_result['job-fetch']->numRows() > 0 ) { |
49 | | - $row = $this->db_result['job-fetch']->fetchRow(); |
50 | | - |
51 | | - //Since we querried the slave to check for dups when we insterted instead of the master let's check |
52 | | - //that the job isn't in the queue twice, we don't want to archive it twice |
53 | | - $this->db_result['dup-check'] = $this->db_slave->select( 'el_archive_queue', '*', '`el_archive_queue`.`url` = "' . $row['url'] |
54 | | - . '" ORDER BY `el_archive_queue`.`queue_id` ASC' ); |
55 | | - |
56 | | - if ( $this->db_result['dup-check']->numRows() > 1 ) { |
57 | | - //keep only the original jobs and remove all duplicates |
58 | | - $this->db_result['dup-check']->fetchRow(); |
59 | | - while ( $del_row = $this->db_result['dup-check']->fetchRow() ) { |
60 | | - echo 'you have a dup '; |
61 | | - var_dump( $del_row ); |
62 | | - //this is commented for testing purposes, so I don't have to keep readding the duplicate to my test db |
63 | | - //in other words this has a giant "remove before flight" ribbon hanging from it... |
64 | | - //$this->db_master->delete( 'el_archive_queue', '`el_archive_queue`.`queue_id` = ' . $del_row['queue_id'] ); |
65 | | - } |
66 | | - |
67 | | - } |
68 | | - |
69 | | - return $row['url']; |
70 | | - } else { |
71 | | - //there are no jobs to do right now |
72 | | - return false; |
73 | | - } |
74 | | - } |
75 | | -} |
76 | | - |
77 | | -$maintClass = 'ArchiveLinksSpider'; |
78 | | -require_once RUN_MAINTENANCE_IF_MAIN; |
79 | | - |
80 | | -?> |
\ No newline at end of file |
Index: trunk/extensions/ArchiveLinks/ArchiveLinks.i18n.php |
— | — | @@ -1,23 +1,23 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * Internationalization File for Archive Links |
5 | 6 | */ |
6 | | - |
7 | 7 | $messages = array(); |
8 | 8 | |
9 | 9 | //English |
10 | | -$messages['en'] = array ( |
11 | | - 'archivelinks-cache-title' => '[cache]', |
12 | | - 'ModifyBlacklist' => 'Modify Blacklist', |
13 | | - 'archivelinks-modify-blacklist-desc' => 'This page allows you to blacklist or whitelist URLs for the ArchiveLinks extension.', |
14 | | - //'archivelinks-archive-blacklist-fieldset-label' => 'Blacklist a URL', |
15 | | - 'archivelinks-modify-blacklist-url-field-label' => 'URL to Blacklist:', |
16 | | - 'archivelinks-modify-blacklist-reason-field-label' => 'Reason for Blacklisting:', |
17 | | - 'archivelinks-modify-blacklist-add-or-remove-field-label' => 'What would you like to do?', |
18 | | - 'archivelinks-modify-blacklist-add-field-label' => 'Add', |
19 | | - 'archivelinks-modify-blacklist-remove-field-label' => 'Remove', |
20 | | - 'archivelinks-modify-blacklist-duration-field-label' => 'Expiry:', |
21 | | - 'archivelinks-modify-blacklist-whitelist-field-label' => 'Blacklist', |
22 | | - 'archivelinks-modify-blacklist-blacklist-field-label' => 'Whitelist', |
23 | | - 'archivelinks-modify-blacklist-blacklist-or-whitelist-field-label' => 'Which list would you like to modify?', |
| 10 | +$messages['en'] = array( |
| 11 | + 'archivelinks-cache-title' => 'cache', |
| 12 | + 'ModifyArchiveBlacklist' => 'Modify Blacklist', |
| 13 | + 'archivelinks-modify-blacklist-desc' => 'This page allows you to blacklist or whitelist URLs for the ArchiveLinks extension.', |
| 14 | + //'archivelinks-archive-blacklist-fieldset-label' => 'Blacklist a URL', |
| 15 | + 'archivelinks-modify-blacklist-url-field-label' => 'URL to Blacklist:', |
| 16 | + 'archivelinks-modify-blacklist-reason-field-label' => 'Reason for Blacklisting:', |
| 17 | + 'archivelinks-modify-blacklist-add-or-remove-field-label' => 'What would you like to do?', |
| 18 | + 'archivelinks-modify-blacklist-add-field-label' => 'Add', |
| 19 | + 'archivelinks-modify-blacklist-remove-field-label' => 'Remove', |
| 20 | + 'archivelinks-modify-blacklist-duration-field-label' => 'Expiry:', |
| 21 | + 'archivelinks-modify-blacklist-whitelist-field-label' => 'Blacklist', |
| 22 | + 'archivelinks-modify-blacklist-blacklist-field-label' => 'Whitelist', |
| 23 | + 'archivelinks-modify-blacklist-blacklist-or-whitelist-field-label' => 'Which list would you like to modify?', |
24 | 24 | ); |
\ No newline at end of file |
Index: trunk/extensions/ArchiveLinks/ArchiveLinks.php |
— | — | @@ -1,31 +1,32 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * This is an extension to archive preemptively archive external links so that |
5 | 6 | * in the even they go down a backup will be available. |
6 | 7 | */ |
7 | | - |
8 | 8 | if ( !defined( 'MEDIAWIKI' ) ) { |
9 | 9 | echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
10 | 10 | die( 1 ); |
11 | 11 | } |
12 | 12 | |
13 | | -error_reporting ( E_ALL | E_STRICT ); |
| 13 | +error_reporting( E_ALL | E_STRICT ); |
14 | 14 | |
15 | 15 | $path = dirname( __FILE__ ); |
16 | 16 | |
17 | | -$wgExtensionMessagesFiles['ArchiveLinks'] = "$path/ArchiveLinks.i18n.php"; |
18 | | -$wgExtensionMessagesFiles['ModifyBlacklist'] = "$path/ArchiveLinks.i18n.php"; |
| 17 | +$wgExtensionMessagesFiles['ArchiveLinks'] = "$path/ArchiveLinks.i18n.php"; |
| 18 | +$wgExtensionMessagesFiles['ModifyArchiveBlacklist'] = "$path/ArchiveLinks.i18n.php"; |
19 | 19 | |
20 | 20 | $wgAutoloadClasses['ArchiveLinks'] = "$path/ArchiveLinks.class.php"; |
21 | | -$wgAutoloadClasses['SpecialModifyBlacklist'] = "$path/SpecialModifyBlacklist.php"; |
22 | | - |
| 21 | +$wgAutoloadClasses['SpecialModifyArchiveBlacklist'] = "$path/SpecialModifyArchiveBlacklist.php"; |
| 22 | + |
23 | 23 | $wgHooks['ArticleSaveComplete'][] = 'ArchiveLinks::queueExternalLinks'; |
24 | 24 | $wgHooks['LinkerMakeExternalLink'][] = 'ArchiveLinks::rewriteLinks'; |
25 | 25 | |
26 | | -$wgSpecialPages['ModifyBlacklist'] = 'SpecialModifyBlacklist'; |
| 26 | +$wgSpecialPages['ModifyArchiveBlacklist'] = 'SpecialModifyArchiveBlacklist'; |
27 | 27 | |
28 | | -$wgArchiveLinksConfig = array ( |
29 | | - 'archive_service' => 'wikiwix', |
30 | | - 'use_multiple_archives' => false, |
31 | | - 'run_spider_in_loop' => false, |
| 28 | +$wgArchiveLinksConfig = array( |
| 29 | + 'archive_service' => 'wikiwix', |
| 30 | + 'use_multiple_archives' => false, |
| 31 | + 'run_spider_in_loop' => false, |
| 32 | + 'in_progress_ignore_delay' => 7200, |
32 | 33 | ); |
\ No newline at end of file |
Index: trunk/extensions/ArchiveLinks/SpecialModifyArchiveBlacklist.php |
— | — | @@ -0,0 +1,96 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if (!defined('MEDIAWIKI')) { |
| 5 | + echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
| 6 | + die(1); |
| 7 | +} |
| 8 | + |
| 9 | +class SpecialModifyArchiveBlacklist extends SpecialPage { |
| 10 | + |
| 11 | + function __construct() { |
| 12 | + parent::__construct('ModifyArchiveBlacklist'); |
| 13 | + } |
| 14 | + |
| 15 | + public function execute($par) { |
| 16 | + global $wgOut, $wgRequest; |
| 17 | + $this->setHeaders(); |
| 18 | + $this->outputHeader(); |
| 19 | + |
| 20 | + $wgOut->addWikiMsg('archivelinks-modify-blacklist-desc'); |
| 21 | + |
| 22 | + $wgOut->addHTML( |
| 23 | + HTML::openElement('form', array('method' => 'post', 'action' => SpecialPage::getTitleFor('ModifyBlacklist')->getLocalUrl())) . |
| 24 | + HTML::openElement('fieldset') . |
| 25 | + HTML::element('legend', null, wfMsg('ModifyBlacklist')) . |
| 26 | + //HTML::hidden( 'title', SpecialPage::getTitleFor( 'ArchiveBlacklist' )->getPrefixedText() ) . |
| 27 | + HTML::openElement('table') . |
| 28 | + HTML::openElement('tr') . |
| 29 | + HTML::openElement('td') . |
| 30 | + wfMsg('archivelinks-modify-blacklist-blacklist-or-whitelist-field-label') . |
| 31 | + HTML::closeElement('td') . |
| 32 | + HTML::openElement('td') . |
| 33 | + HTML::element('input', array('name' => 'bl_blacklist-whitelist', 'type' => 'radio', 'value' => 'blacklist')) . |
| 34 | + ' ' . |
| 35 | + wfMsg('archivelinks-modify-blacklist-blacklist-field-label') . |
| 36 | + HTML::closeElement('td') . |
| 37 | + HTML::closeElement('tr') . |
| 38 | + HTML::openElement('tr') . |
| 39 | + HTML::openElement('td') . |
| 40 | + HTML::closeElement('td') . |
| 41 | + HTML::openElement('td') . |
| 42 | + HTML::element('input', array('name' => 'bl_blacklist-whitelist', 'type' => 'radio', 'value' => 'whitelist')) . |
| 43 | + ' ' . |
| 44 | + wfMsg('archivelinks-modify-blacklist-whitelist-field-label') . |
| 45 | + HTML::closeElement('td') . |
| 46 | + HTML::closeElement('tr') . |
| 47 | + HTML::openElement('tr') . |
| 48 | + HTML::openElement('td') . |
| 49 | + wfMsg('archivelinks-modify-blacklist-add-or-remove-field-label') . |
| 50 | + HTML::closeElement('td') . |
| 51 | + HTML::openElement('td') . |
| 52 | + HTML::element('input', array('name' => 'bl_add-remove', 'type' => 'radio', 'value' => 'add')) . |
| 53 | + ' ' . |
| 54 | + wfMsg('archivelinks-modify-blacklist-add-field-label') . |
| 55 | + HTML::closeElement('td') . |
| 56 | + HTML::closeElement('tr') . |
| 57 | + HTML::openElement('tr') . |
| 58 | + HTML::openElement('td') . |
| 59 | + HTML::closeElement('td') . |
| 60 | + HTML::openElement('td') . |
| 61 | + HTML::element('input', array('name' => 'bl_add-remove', 'type' => 'radio', 'value' => 'remove')) . |
| 62 | + ' ' . |
| 63 | + wfMsg('archivelinks-modify-blacklist-remove-field-label') . |
| 64 | + HTML::closeElement('td') . |
| 65 | + HTML::closeElement('tr') . |
| 66 | + HTML::openElement('tr') . |
| 67 | + HTML::openElement('td') . |
| 68 | + HTML::element('label', array('for' => 'bl_url'), wfMsg('archivelinks-modify-blacklist-url-field-label')) . |
| 69 | + HTML::closeElement('td') . |
| 70 | + HTML::openElement('td') . |
| 71 | + HTML::element('input', array('name' => 'bl_url', 'type' => 'text', 'size' => '110')) . |
| 72 | + HTML::closeElement('td') . |
| 73 | + HTML::closeElement('tr') . |
| 74 | + HTML::openElement('tr') . |
| 75 | + HTML::openElement('td') . |
| 76 | + HTML::element('label', array('for' => 'bl_duration'), wfMsg('archivelinks-modify-blacklist-duration-field-label')) . |
| 77 | + HTML::closeElement('td') . |
| 78 | + HTML::openElement('td') . |
| 79 | + HTML::element('input', array('name' => 'bl_duration', 'type' => 'text', 'size' => '60')) . |
| 80 | + HTML::closeElement('td') . |
| 81 | + HTML::closeElement('tr') . |
| 82 | + HTML::openElement('tr') . |
| 83 | + HTML::openElement('td') . |
| 84 | + HTML::element('label', array('for' => 'bl_reason'), wfMsg('archivelinks-modify-blacklist-reason-field-label')) . |
| 85 | + HTML::closeElement('td') . |
| 86 | + HTML::openElement('td') . |
| 87 | + HTML::element('input', array('name' => 'bl_reason', 'type' => 'text', 'size' => '60')) . |
| 88 | + HTML::closeElement('td') . |
| 89 | + HTML::closeElement('tr') . |
| 90 | + HTML::closeElement('table') . |
| 91 | + XML::submitButton('Blacklist URL') . |
| 92 | + HTML::closeElement('fieldset') . |
| 93 | + HTML::closeElement('form') |
| 94 | + ); |
| 95 | + } |
| 96 | + |
| 97 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/ArchiveLinks/SpecialModifyArchiveBlacklist.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 98 | + native |
Index: trunk/extensions/ArchiveLinks/ArchiveLinks.class.php |
— | — | @@ -8,86 +8,84 @@ |
9 | 9 | } |
10 | 10 | |
11 | 11 | class ArchiveLinks { |
12 | | - public static function queueExternalLinks ( &$article ) { |
13 | | - global $wgParser; |
14 | | - $external_links = $wgParser->getOutput(); |
15 | | - $external_links = $external_links->mExternalLinks; |
16 | | - |
17 | | - $db_master = wfGetDB( DB_MASTER ); |
18 | | - $db_slave = wfGetDB( DB_SLAVE ); |
19 | | - $db_result = array(); |
20 | | - |
21 | | - $db_master->begin(); |
22 | | - |
23 | | - foreach ( $external_links as $link => $unused_value ) { |
24 | | - //$db_result['resource'] = $db_slave->select( 'el_archive_resource', '*', '`el_archive_resource`.`resource_url` = "' . $db_slave->strencode( $link ) . '"'); |
25 | | - $db_result['blacklist'] = $db_slave->select( 'el_archive_blacklist', '*', '`el_archive_blacklist`.`bl_url` = "' . $db_slave->strencode( $link ) . '"'); |
26 | | - $db_result['queue'] = $db_slave->select( 'el_archive_queue', '*', '`el_archive_queue`.`url` = "' . $db_slave->strencode( $link ) . '"' ); |
27 | | - |
28 | | - if ( $db_result['blacklist']->numRows() === 0 ) { |
29 | | - if ( $db_result['queue']->numRows() === 0 ) { |
30 | | - // this probably a first time job |
31 | | - // but we should check the logs and resource table |
32 | | - // to make sure |
33 | | - $db_master->insert( 'el_archive_queue', array ( |
34 | | - 'page_id' => $article->getID(), |
35 | | - 'url' => $link, |
36 | | - 'delay_time' => '0', |
37 | | - 'insertion_time' => time(), |
38 | | - 'in_progress' => '0', |
39 | | - )); |
40 | | - } else { |
41 | | - //this job is already in the queue, why? |
42 | | - // * most likely reason is it has already been inserted by another page |
43 | | - // * or we are checking it later because the site was down at last archival |
44 | | - // in either case we don't really need to do anything right now, so skip... |
| 12 | + public static function queueExternalLinks ( &$article ) { |
| 13 | + global $wgParser; |
| 14 | + $external_links = $wgParser->getOutput(); |
| 15 | + $external_links = $external_links->mExternalLinks; |
| 16 | + |
| 17 | + $db_master = wfGetDB( DB_MASTER ); |
| 18 | + $db_slave = wfGetDB( DB_SLAVE ); |
| 19 | + $db_result = array(); |
| 20 | + |
| 21 | + $db_master->begin(); |
| 22 | + |
| 23 | + foreach ( $external_links as $link => $unused_value ) { |
| 24 | + //$db_result['resource'] = $db_slave->select( 'el_archive_resource', '*', '`el_archive_resource`.`resource_url` = "' . $db_slave->strencode( $link ) . '"'); |
| 25 | + $db_result['blacklist'] = $db_slave->select( 'el_archive_blacklist', '*', '`el_archive_blacklist`.`bl_url` = "' . $db_slave->strencode( $link ) . '"'); |
| 26 | + $db_result['queue'] = $db_slave->select( 'el_archive_queue', '*', '`el_archive_queue`.`url` = "' . $db_slave->strencode( $link ) . '"' ); |
| 27 | + |
| 28 | + if ( $db_result['blacklist']->numRows() === 0 ) { |
| 29 | + if ( $db_result['queue']->numRows() === 0 ) { |
| 30 | + // this probably a first time job |
| 31 | + // but we should check the logs and resource table |
| 32 | + // to make sure |
| 33 | + $db_master->insert( 'el_archive_queue', array ( |
| 34 | + 'page_id' => $article->getID(), |
| 35 | + 'url' => $link, |
| 36 | + 'delay_time' => '0', |
| 37 | + 'insertion_time' => time(), |
| 38 | + 'in_progress' => '0', |
| 39 | + )); |
| 40 | + } else { |
| 41 | + //this job is already in the queue, why? |
| 42 | + // * most likely reason is it has already been inserted by another page |
| 43 | + // * or we are checking it later because the site was down at last archival |
| 44 | + // in either case we don't really need to do anything right now, so skip... |
| 45 | + } |
| 46 | + } |
45 | 47 | } |
46 | 48 | |
47 | | - } |
| 49 | + $db_master->commit(); |
| 50 | + |
| 51 | + return true; |
48 | 52 | } |
49 | | - |
50 | | - $db_master->commit(); |
51 | | - |
52 | | - return true; |
53 | | - } |
54 | | - |
55 | | - public static function rewriteLinks ( &$url, &$text, &$link, &$attributes ) { |
56 | | - if ( array_key_exists('rel', $attributes) && $attributes['rel'] === 'nofollow' ) { |
57 | | - global $wgArchiveLinksConfig; |
58 | | - if ( $wgArchiveLinksConfig['use_multiple_archives'] ) { |
59 | | - //need to add support for more than one archival service at once |
60 | | - // (a page where you can select one from a list of choices) |
61 | | - } else { |
62 | | - switch ( $wgArchiveLinksConfig['archive_service'] ) { |
63 | | - case 'local': |
64 | | - //We need to have something to figure out where the filestore is... |
65 | | - $link_to_archive = urlencode( substr_replace( $url, '', 0, 7 ) ); |
66 | | - break; |
67 | | - case 'wikiwix': |
68 | | - $link_to_archive = 'http://archive.wikiwix.com/cache/?url=' . $url; |
69 | | - break; |
70 | | - case 'webcitation': |
71 | | - $link_to_archive = 'http://webcitation.org/query?url=' . $url; |
72 | | - break; |
73 | | - case 'internet_archive': |
74 | | - default: |
75 | | - $link_to_archive = 'http://wayback.archive.org/web/*/' . $url; |
76 | | - break; |
77 | | - |
| 53 | + |
| 54 | + public static function rewriteLinks ( &$url, &$text, &$link, &$attributes ) { |
| 55 | + if ( array_key_exists('rel', $attributes) && $attributes['rel'] === 'nofollow' ) { |
| 56 | + global $wgArchiveLinksConfig; |
| 57 | + if ( $wgArchiveLinksConfig['use_multiple_archives'] ) { |
| 58 | + //need to add support for more than one archival service at once |
| 59 | + // (a page where you can select one from a list of choices) |
| 60 | + } else { |
| 61 | + switch ( $wgArchiveLinksConfig['archive_service'] ) { |
| 62 | + case 'local': |
| 63 | + //We need to have something to figure out where the filestore is... |
| 64 | + $link_to_archive = urlencode( substr_replace( $url, '', 0, 7 ) ); |
| 65 | + break; |
| 66 | + case 'wikiwix': |
| 67 | + $link_to_archive = 'http://archive.wikiwix.com/cache/?url=' . $url; |
| 68 | + break; |
| 69 | + case 'webcitation': |
| 70 | + $link_to_archive = 'http://webcitation.org/query?url=' . $url; |
| 71 | + break; |
| 72 | + case 'internet_archive': |
| 73 | + default: |
| 74 | + $link_to_archive = 'http://wayback.archive.org/web/*/' . $url; |
| 75 | + break; |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + $link = HTML::element('a', array ( 'rel' => 'nofollow', 'class' => $attributes['class'], 'href' => $url ), $text ) |
| 80 | + . HTML::openElement('sup') |
| 81 | + . HTML::openElement('small') |
| 82 | + . ' ' |
| 83 | + . HTML::element('a', array ( 'href' => $link_to_archive ), '[' . wfMsg( 'archivelinks-cache-title') . ']') |
| 84 | + . HTML::closeElement('small') |
| 85 | + . HTML::closeElement('sup'); |
| 86 | + |
| 87 | + return false; |
| 88 | + } else { |
| 89 | + return true; |
78 | 90 | } |
79 | | - } |
80 | | - |
81 | | - $link = HTML::element('a', array ( 'rel' => 'nofollow', 'class' => $attributes['class'], 'href' => $url ), $text ) |
82 | | - . HTML::openElement('sup') |
83 | | - . HTML::openElement('small') |
84 | | - . ' ' |
85 | | - . HTML::element('a', array ( 'href' => $link_to_archive ), wfMsg( 'archivelinks-cache-title') ) |
86 | | - . HTML::closeElement('small') |
87 | | - . HTML::closeElement('sup'); |
88 | | - |
89 | | - return false; |
90 | | - } else { |
91 | | - return true; |
92 | | - } |
93 | 91 | } |
94 | 92 | } |
\ No newline at end of file |