示例#1
0
<?php

$svc = \hypeJunction\Scraper\ScraperService::getInstance();
$site = elgg_get_site_entity();
$dataroot = elgg_get_config('dataroot');
$dir = new \Elgg\EntityDirLocator($site->guid);
$paths = elgg_get_file_list($dataroot . $dir . 'scraper_cache/resources/');
$count = count($paths);
echo elgg_view('output/longtext', ['value' => elgg_echo('admin:upgrades:scraper:move_to_db:description')]);
echo elgg_view('admin/upgrades/view', ['count' => $count, 'action' => 'action/upgrade/scraper/move_to_db']);
示例#2
0
<?php

use Elgg\EntityDirLocator;
use hypeJunction\Scraper\ScraperService;
if (get_input('upgrade_completed')) {
    $factory = new ElggUpgrade();
    $upgrade = $factory->getUpgradeFromPath('admin/upgrades/scraper/move_to_db');
    if ($upgrade instanceof ElggUpgrade) {
        $upgrade->setCompleted();
    }
    return true;
}
$svc = ScraperService::getInstance();
$site = elgg_get_site_entity();
$dataroot = elgg_get_config('dataroot');
$dir = new EntityDirLocator($site->guid);
$paths = elgg_get_file_list($dataroot . $dir . 'scraper_cache/resources/');
$original_time = microtime(true);
$time_limit = 4;
$success_count = 0;
$error_count = 0;
$response = [];
while (count($paths) > 0 && microtime(true) - $original_time < $time_limit) {
    $path = array_shift($paths);
    error_log((string) count($paths));
    $response['upgraded'][] = $path;
    $success_count++;
    $basename = pathinfo($path, PATHINFO_BASENAME);
    $file = new ElggFile();
    $file->owner_guid = $site->guid;
    $file->setFilename("scraper_cache/resources/{$basename}");