Scrollreveal+cat+datenews

This commit is contained in:
2019-01-07 11:43:39 +01:00
parent e4cac3d01e
commit 762a1ad170
3158 changed files with 140699 additions and 73915 deletions
@@ -0,0 +1,53 @@
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
class Apache extends Problem
{
public function __construct()
{
$this->id = 'Apache Modules';
$this->class = get_class($this);
$this->order = 1;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = true;
$this->help = 'https://learn.getgrav.org/basics/requirements#apache-requirements';
}
public function process()
{
// Perform some Apache checks
if (strpos(php_sapi_name(), 'apache') !== false && function_exists('apache_get_modules')) {
$require_apache_modules = ['mod_rewrite'];
$apache_modules = apache_get_modules();
$apache_errors = [];
$apache_success = [];
foreach ((array) $require_apache_modules as $module) {
if (in_array($module, $apache_modules)) {
$apache_success[$module] = 'module required but not enabled';
} else {
$apache_errors[$module] = 'module is not installed or enabled';
}
}
if (empty($apache_errors)) {
$this->status = true;
$this->msg = 'All modules look good!';
} else {
$this->status = false;
$this->msg = 'There were problems with required modules:';
}
$this->details = ['errors' => $apache_errors, 'success' => $apache_success];
} else {
$this->msg = 'Apache not installed, skipping...';
}
return $this;
}
}
@@ -0,0 +1,85 @@
<?php
namespace Grav\Plugin\Problems\Base;
class Problem implements \JsonSerializable
{
const LEVEL_CRITICAL = 'critical';
const LEVEL_WARNING = 'warning';
const LEVEL_NOTICE = 'notice';
protected $id;
protected $order;
protected $level;
protected $status;
protected $msg;
protected $details;
protected $help;
protected $class;
public function __contstruct($data = null)
{
if (!is_null($data)) {
$this->load($data);
}
}
public function load($data) {
$this->set_object_vars($data);
}
public function process() {
return $this;
}
public function getId() {
return $this->id;
}
public function getOrder() {
return $this->order;
}
public function getLevel() {
return $this->level;
}
public function getStatus() {
return $this->status;
}
public function getMsg() {
return $this->msg;
}
public function getDetails()
{
return $this->details;
}
public function getHelp()
{
return $this->help;
}
public function getClass()
{
return $this->class;
}
public function toArray()
{
return get_object_vars($this);
}
public function jsonSerialize()
{
$this->toArray();
}
protected function set_object_vars($object, array $vars) {
$has = get_object_vars($object);
foreach ($has as $name => $oldValue) {
$object->$name = isset($vars[$name]) ? $vars[$name] : NULL;
}
}
}
@@ -0,0 +1,119 @@
<?php
namespace Grav\Plugin\Problems\Base;
use Grav\Common\Cache;
use Grav\Common\Grav;
use RocketTheme\Toolbox\Event\Event;
class ProblemChecker
{
const PROBLEMS_PREFIX = 'problem-check-';
protected $problems = [];
protected $status_file;
public function __construct()
{
/** @var Cache $cache */
$cache = Grav::instance()['cache'];
$this->status_file = CACHE_DIR . $this::PROBLEMS_PREFIX . $cache->getKey() . '.json';
}
public function load()
{
if ($this->statusFileExists()) {
$json = file_get_contents($this->status_file);
$data = json_decode($json, true);
foreach ($data as $problem) {
$class = $problem['class'];
$this->problems[] = new $class($problem);
}
}
}
public function getStatusFile()
{
return $this->status_file;
}
public function statusFileExists()
{
return file_exists($this->status_file);
}
public function storeStatusFile()
{
$problems = $this->getProblemsSerializable();
$json = json_encode($problems);
file_put_contents($this->status_file, $json);
}
public function check($problems_dir)
{
$problems = [];
$problems_found = false;
foreach (new \DirectoryIterator($problems_dir) as $file) {
if ($file->isDot() || $file->isDir()) {
continue;
}
$classname = 'Grav\\Plugin\\Problems\\' . $file->getBasename('.php');
/** @var Problem $problem */
$problem = new $classname();
$problems[$problem->getId()] = $problem;
}
// Fire event to allow other plugins to add problems
Grav::instance()->fireEvent('onProblemsInitialized', new Event(['problems' => $problems]));
// Get the problems in order
usort($problems, function($a, $b) {
return $b->getOrder() - $a->getOrder();
});
// run the process methods in new order
foreach ($problems as $problem) {
$problem->process();
if ($problem->getStatus() === false && $problem->getLevel() === Problem::LEVEL_CRITICAL) {
$problems_found = true;
}
}
$this->problems = $problems;
return $problems_found;
}
public function getProblems()
{
if (empty($this->problems)) {
$this->check();
}
$problems = $this->problems;
// Put the failed ones first
usort($problems, function($a, $b) {
return $a->getStatus() - $b->getStatus();
});
return $problems;
}
public function getProblemsSerializable()
{
if (empty($this->problems)) {
$this->getProblems();
}
$problems = [];
foreach ($this->problems as $problem) {
$problems[] = $problem->toArray();
}
return $problems;
}
}
@@ -0,0 +1,65 @@
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
class EssentialFolders extends Problem
{
public function __construct()
{
$this->id = 'Essential Folders';
$this->class = get_class($this);
$this->order = 100;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = false;
$this->help = 'https://learn.getgrav.org/basics/folder-structure';
}
public function process()
{
$essential_folders = [
'backup' => true,
'cache' => true,
'logs' => true,
'images' => true,
'assets' => true,
'system' => false,
'user/data' => true,
'user/pages' => false,
'user/config' => false,
'user/plugins/error' => false,
'user/plugins' => false,
'user/themes' => false,
'vendor' => false,
'tmp' => true,
];
// Check for essential files & perms
$file_errors = [];
$file_success = [];
foreach ($essential_folders as $file => $check_writable) {
$file_path = ROOT_DIR . $file;
if (!file_exists($file_path)) {
$file_errors[$file_path] = 'does not exist';
} elseif ($check_writable && !is_writable($file_path)) {
$file_errors[$file_path] = 'exists but is <strong>not writeable</strong>';
} else {
$file_success[$file_path] = 'exists and is writable';
}
}
if (empty($file_errors)) {
$this->status = true;
$this->msg = 'All folders look good!';
} else {
$this->status = false;
$this->msg = 'There were problems with required folders:';
}
$this->details = ['errors' => $file_errors, 'success' => $file_success];
return $this;
}
}
@@ -0,0 +1,132 @@
<?php
namespace Grav\Plugin\Problems;
use Grav\Common\Grav;
use Grav\Plugin\Problems\Base\Problem;
class PHPModules extends Problem
{
public function __construct()
{
$this->id = 'PHP Modules';
$this->class = get_class($this);
$this->order = 101;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = false;
$this->help = 'https://learn.getgrav.org/basics/requirements#php-requirements';
}
public function process()
{
$modules_errors = [];
$modules_success = [];
// Check for PHP CURL library
$msg = "PHP Curl (Data Transfer Library) is %s installed";
if (function_exists('curl_version')) {
$modules_success['curl'] = sprintf($msg, 'successfully');
} else {
$modules_errors['curl'] = sprintf($msg, 'required but not');
}
// Check for PHP Ctype library
$msg = "PHP Ctype is %s installed";
if (function_exists('ctype_print')) {
$modules_success['ctype'] = sprintf($msg, 'successfully');
} else {
$modules_errors['ctype'] = sprintf($msg, 'required but not');
}
// Check for PHP Dom library
$msg = "PHP DOM is %s installed";
if (class_exists('DOMDocument')) {
$modules_success['dom'] = sprintf($msg, 'successfully');
} else {
$modules_errors['dom'] = sprintf($msg, 'required but not');
}
// Check for GD library
$msg = "PHP GD (Image Manipulation Library) is %s installed";
if (defined('GD_VERSION') && function_exists('gd_info')) {
$msg = $modules_success['gd'] = sprintf($msg, 'successfully');
// Extra checks for Image support
$ginfo = gd_info();
$gda = array("PNG Support", "JPEG Support", "FreeType Support", "GIF Read Support");
$gda_msg = '';
$problems_found = false;
foreach ($gda as $image_type) {
if (!$ginfo[$image_type]) {
$problems_found = true;
$gda_msg = "missing $image_type, but is ";
break;
}
}
if ($problems_found) {
$msg .= ' but missing ' . $gda_msg;
}
$modules_success['gd'] = $msg;
} else {
$modules_errors['gd'] = sprintf($msg, 'required but not');
}
// Check for PHP MbString library
$msg = "PHP Mbstring (Multibyte String Library) is %s installed";
if (extension_loaded('mbstring')) {
$modules_success['mbstring'] = sprintf($msg, 'successfully');
} else {
$modules_errors['mbstring'] = sprintf($msg, 'required but not');
}
// Check for PHP Open SSL library
$msg = "PHP OpenSSL (Secure Sockets Library) is %s installed";
if (extension_loaded('openssl') && defined('OPENSSL_VERSION_TEXT')) {
$modules_success['openssl'] = sprintf($msg, 'successfully');
} else {
$modules_errors['openssl'] = sprintf($msg, 'required but not');
}
// Check for PHP XML library
$msg = "PHP XML Library is %s installed";
if (extension_loaded('xml')) {
$modules_success['xml'] = sprintf($msg, 'successfully');
} else {
$modules_errors['xml'] = sprintf($msg, 'required but not');
}
// Check for PHP Zip library
$msg = "PHP Zip extension is %s installed";
if (extension_loaded('zip')) {
$modules_success['zip'] = sprintf($msg, 'successfully');
} else {
$modules_errors['zip'] = sprintf($msg, 'required but not');
}
// Check Exif if enabled
if (Grav::instance()['config']->get('system.media.auto_metadata_exif')) {
$msg = "PHP Exif (Exchangeable Image File Format) is %s installed";
if (extension_loaded('exif')) {
$modules_success['exif'] = sprintf($msg, 'successfully');
} else {
$modules_errors['exif'] = sprintf($msg, 'required but not');
}
}
if (empty($modules_errors)) {
$this->status = true;
$this->msg = 'All modules look good!';
} else {
$this->status = false;
$this->msg = 'There were problems with required modules:';
}
$this->details = ['errors' => $modules_errors, 'success' => $modules_success];
return $this;
}
}
@@ -0,0 +1,35 @@
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
class PHPVersion extends Problem
{
public function __construct()
{
$this->id = 'PHP Minimum Version';
$this->class = get_class($this);
$this->order = 102;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = false;
$this->help = 'https://getgrav.org/blog/raising-php-requirements-2018';
}
public function process()
{
$min_php_version = defined('GRAV_PHP_MIN') ? GRAV_PHP_MIN : '5.6.4';
$your_php_version = phpversion();
$msg = "Your PHP <strong>%s</strong> is %s than the minimum of <strong>%s</strong> required";
// Check PHP version
if (version_compare($your_php_version, $min_php_version, '<')) {
$this->msg = sprintf($msg, $your_php_version, 'less', $min_php_version);
} else {
$this->msg = sprintf($msg, $your_php_version, 'greater', $min_php_version);
$this->status = true;
}
return $this;
}
}
@@ -0,0 +1,34 @@
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
class Permissions extends Problem
{
public function __construct()
{
$this->id = 'Permissions Setup';
$this->class = get_class($this);
$this->order = -1;
$this->level = Problem::LEVEL_WARNING;
$this->status = false;
$this->help = 'https://learn.getgrav.org/troubleshooting/permissions';
}
public function process()
{
umask($umask = umask(022));
$msg = "Your default file umask is <strong>%s</strong> which %s";
if (($umask & 2) !== 2) {
$this->msg = sprintf($msg, decoct($umask), 'is potentially dangerous');
$this->status = false;
} else {
$this->msg = sprintf($msg, decoct($umask), 'looks good!');
$this->status = true;
}
return $this;
}
}