mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-01-04 14:50:59 +01:00
GravTrait changes in Admin
This commit is contained in:
@@ -552,6 +552,7 @@ class AdminPlugin extends Plugin
|
||||
|
||||
$this->admin = new Admin($this->grav, $this->base, $this->template, $this->route);
|
||||
|
||||
|
||||
// And store the class into DI container.
|
||||
$this->grav['admin'] = $this->admin;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace Grav\Plugin\Admin;
|
||||
|
||||
use Grav\Common\GravTrait;
|
||||
use Grav;
|
||||
use Grav\Common\GPM\GPM as GravGPM;
|
||||
use Grav\Common\GPM\Installer;
|
||||
use Grav\Common\GPM\Response;
|
||||
@@ -11,8 +11,6 @@ use Grav\Common\GPM\Common\Package;
|
||||
|
||||
class Gpm
|
||||
{
|
||||
use GravTrait;
|
||||
|
||||
// Probably should move this to Grav DI container?
|
||||
protected static $GPM;
|
||||
public static function GPM()
|
||||
@@ -140,7 +138,7 @@ class Gpm
|
||||
|
||||
foreach ($packages as $package) {
|
||||
|
||||
$location = self::getGrav()['locator']->findResource($package->package_type . '://' . $package->slug);
|
||||
$location = Grav::instance()['locator']->findResource($package->package_type . '://' . $package->slug);
|
||||
|
||||
// Check destination
|
||||
Installer::isValidDestination($location);
|
||||
@@ -168,7 +166,7 @@ class Gpm
|
||||
{
|
||||
$contents = Response::get($package->zipball_url, []);
|
||||
|
||||
$cache_dir = self::getGrav()['locator']->findResource('cache://', true);
|
||||
$cache_dir = Grav::instance()['locator']->findResource('cache://', true);
|
||||
$cache_dir = $cache_dir . DS . 'tmp/Grav-' . uniqid();
|
||||
Folder::mkdir($cache_dir);
|
||||
|
||||
|
||||
@@ -3,16 +3,15 @@ namespace Grav\Plugin;
|
||||
|
||||
use Grav\Common\Config\Config;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Plugins;
|
||||
use Grav\Common\Themes;
|
||||
use Grav\Common\Page\Page;
|
||||
use Grav\Common\Data;
|
||||
use Grav\Common\GravTrait;
|
||||
|
||||
/**
|
||||
* Class Popularity
|
||||
* @package Grav\Plugin
|
||||
*/
|
||||
class Popularity
|
||||
{
|
||||
use GravTrait;
|
||||
|
||||
/** @var Config */
|
||||
protected $config;
|
||||
protected $data_path;
|
||||
@@ -36,9 +35,9 @@ class Popularity
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = self::getGrav()['config'];
|
||||
$this->config = Grav::instance()['config'];
|
||||
|
||||
$this->data_path = self::$grav['locator']->findResource('log://popularity', true, true);
|
||||
$this->data_path = Grav::instance()['locator']->findResource('log://popularity', true, true);
|
||||
$this->daily_file = $this->data_path.'/'.self::DAILY_FILE;
|
||||
$this->monthly_file = $this->data_path.'/'.self::MONTHLY_FILE;
|
||||
$this->totals_file = $this->data_path.'/'.self::TOTALS_FILE;
|
||||
@@ -49,13 +48,13 @@ class Popularity
|
||||
public function trackHit()
|
||||
{
|
||||
// Don't track bot or crawler requests
|
||||
if (!self::getGrav()['browser']->isHuman()) {
|
||||
if (!Grav::instance()['browser']->isHuman()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var Page $page */
|
||||
$page = self::getGrav()['page'];
|
||||
$relative_url = str_replace(self::getGrav()['base_url_relative'], '', $page->url());
|
||||
$page = Grav::instance()['page'];
|
||||
$relative_url = str_replace(Grav::instance()['base_url_relative'], '', $page->url());
|
||||
|
||||
// Don't track error pages or pages that have no route
|
||||
if ($page->template() == 'error' || !$page->route()) {
|
||||
@@ -79,7 +78,7 @@ class Popularity
|
||||
$this->updateDaily();
|
||||
$this->updateMonthly();
|
||||
$this->updateTotals($page->route());
|
||||
$this->updateVisitors(self::getGrav()['uri']->ip());
|
||||
$this->updateVisitors(Grav::instance()['uri']->ip());
|
||||
|
||||
}
|
||||
|
||||
@@ -126,7 +125,7 @@ class Popularity
|
||||
$data = array();
|
||||
|
||||
foreach ($chart_data as $date => $count) {
|
||||
$labels[] = self::getGrav()['grav']['admin']->translate(['PLUGIN_ADMIN.' . strtoupper(date('D', strtotime($date)))]);
|
||||
$labels[] = Grav::instance()['grav']['admin']->translate(['PLUGIN_ADMIN.' . strtoupper(date('D', strtotime($date)))]);
|
||||
$data[] = $count;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user