Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First implementation for ticket #994 #1042

Open
wants to merge 1 commit into
base: 5.2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Core/Bookmarklet/NominateThisCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ public function nominate_it( $internal = true ) {
$post_ID = pressforward( 'utility.forward_tools' )->bookmarklet_to_nomination( false, $post );
}

// Sending a request to archive.org to be able to submit the URL of the source post
if( pressforward( 'utility.internet_archive' )->send_request_to_archive_dot_org( $post['guid'] ) ) {
pf_log( "The URL " . $post['guid'] . " was successfully provided to archive.org" );
}

if ( ! empty( $_POST['item_feat_img'] ) && ( $_POST['item_feat_img'] != '' ) ) {
pressforward( 'schema.feed_item' )->set_ext_as_featured( $post_ID, $_POST['item_feat_img'] );
}
Expand Down
8 changes: 8 additions & 0 deletions Core/Providers/UtilityProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Intraxia\Jaxion\Assets\ServiceProvider as ServiceProvider;

use PressForward\Core\Utility\Forward_Tools;
use PressForward\Core\Utility\Internet_Archive;
use PressForward\Core\Utility\Relate;
use PressForward\Core\Utility\Retrieval;

Expand Down Expand Up @@ -44,6 +45,13 @@ function( $container ) {
}
);

$container->share(
'utility.internet_archive',
function( $container ) {
return new Internet_Archive();
}
);

// parent::register( $container );
}
}
29 changes: 29 additions & 0 deletions Core/Utility/Internet_Archive.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: yoann
* Date: 2019-04-09
* Time: 10:08
*/

namespace PressForward\Core\Utility;


class Internet_Archive {
function __construct() {

}

/**
* @param $url The URL of a page we want to be saved on archive.org
*
* @return bool|string TRUE if successful, FALSE if not
*/
function send_request_to_archive_dot_org( $url ) {
pf_log("Send to archive.org!");
$ch = curl_init( 'https://web.archive.org/save/' . $url );
$result = curl_exec($ch);

return $result;
}
}