namespace Syltaen;
class BoutiqueOrderProcessor extends DataProcessor
{
/**
* Process the content
*
* @param [type] $content
* @return void
*/
public function process($data)
{
$this->data = $data;
$this->userData = $this->controller->user->loadEverything()->loadBoutique()->getOne();
$this->cart = new Cart();
$this->data["show_ecole_pp_check"] = $this->userData->type == "ecole";
// Act based on the recieved data
if (!empty($_POST)) {
$this->post($_POST);
} else {
$this->get();
}
return $this->data;
}
// ==================================================
// > GET
// ==================================================
/**
* Context for the rendering
*
* @return void
*/
Arguments
"Trying to get property 'type' of non-object"
namespace Syltaen;
class BoutiqueOrderProcessor extends DataProcessor
{
/**
* Process the content
*
* @param [type] $content
* @return void
*/
public function process($data)
{
$this->data = $data;
$this->userData = $this->controller->user->loadEverything()->loadBoutique()->getOne();
$this->cart = new Cart();
$this->data["show_ecole_pp_check"] = $this->userData->type == "ecole";
// Act based on the recieved data
if (!empty($_POST)) {
$this->post($_POST);
} else {
$this->get();
}
return $this->data;
}
// ==================================================
// > GET
// ==================================================
/**
* Context for the rendering
*
* @return void
*/
/**
* Handle content for the user's password reset
*
* @param array $c
* @return void
*/
private function user_password(&$c)
{
$c = (new UserPasswordResetProcessor($this->controller))->process($c);
}
/**
* Handle content for the boutique orders
*
* @param array $c
* @return void
*/
private function boutique_order(&$c)
{
$c = (new BoutiqueOrderProcessor($this->controller))->process($c);
}
/**
* Handle content for the boutique orders
*
* @param array $c
* @return void
*/
private function defined_order(&$c)
{
$c = (new BoutiqueDefinedOrderProcessor($this->controller))->process($c);
}
/**
* Handle content for the boutique orders
*
* @param array $c
* @return void
*/
private function dashboard_challenges(&$c)
* @return void
*/
public function process($content)
{
// Run the correct mehtod by looking at the acf_fc_layout
switch ($content["acf_fc_layout"]) {
// Add custom layout-method routes here
// Ex:
// case "name-of-the-layout-1":
// case "name-of-the-layout-2":
// static::nameOfTheMethod($content);
// break;
// By default : convert - into _ and use the result as a method name
default:
$method = str_replace("-", "_", $content["acf_fc_layout"]);
if (method_exists(static::class, $method)) {
$this->{$method}($content);
}
}
return $content;
}
// =============================================================================
// > DEPRECIATED
// =============================================================================
/**
* Handle data for the "2 columns" content type
*
* @param [type] $c
* @return void
*/
private function txt_2col(&$c)
{
$c["class"] = "align-".$c["valign"];
$c["txt_1_class"] = "gr-".substr($c['proportions'], 0, 1);
$c["txt_2_class"] = "gr-".substr($c['proportions'], 2, 1);
return false;
}
/**
* Process each item of an array and return the result array
*
* @param mixed $item
* @return mixed
*/
public function processEach($raw)
{
$proccessed = [];
if (empty($raw)) return [];
foreach ((array) $raw as $i=>$rawItem) {
$this->pointer = $i;
$item = $this->process($rawItem);
// Only include the result if it is valid
if ($item) {
$proccessed[] = $item;
}
}
return $proccessed;
}
}
<?php
namespace Syltaen;
class SectionsProcessor extends DataProcessor
{
/**
* Processing of each section
*/
public function process($section)
{
if ($this->shouldHide($section)) return false;
$this->addAttributes($section);
$this->addClasses($section);
$section["content"] = (new ContentsProcessor($this->controller))->processEach($section["content"]);
return $section;
}
/**
* Process a section's parameters
*
* @param array $s The section data
* @return void
*/
private function addClasses(&$s)
{
$s["classes"] = ["site-section"];
// ========== PADDING ========== //
if ($s["padding_top"] != "no") $s["classes"][] = $s["padding_top"] . "-padding-top";
if ($s["padding_bottom"] != "no") $s["classes"][] = $s["padding_bottom"] . "-padding-bottom";
if ($s["padding_top_sm"] != "unset") $s["classes"][] = $s["padding_top_sm"] . "-padding-top-sm";
if ($s["padding_bottom_sm"] != "unset") $s["classes"][] = $s["padding_bottom_sm"] . "-padding-bottom-sm";
if ($s["padding_top_xs"] != "unset") $s["classes"][] = $s["padding_top_xs"] . "-padding-top-xs";
return false;
}
/**
* Process each item of an array and return the result array
*
* @param mixed $item
* @return mixed
*/
public function processEach($raw)
{
$proccessed = [];
if (empty($raw)) return [];
foreach ((array) $raw as $i=>$rawItem) {
$this->pointer = $i;
$item = $this->process($rawItem);
// Only include the result if it is valid
if ($item) {
$proccessed[] = $item;
}
}
return $proccessed;
}
}
class PageController extends BaseController
{
/**
* Populate $this->data
*
* @param bool $spacial_page
*/
public function __construct($args = [])
{
parent::__construct($args);
$this->addData([
// intro
"intro_content" => "",
"intro_bg",
"intro_grad" => false,
"(img:url) intro_badge",
// content
"@sections" => (new SectionsProcessor($this))->processEach(Data::get("sections")),
// permissions
"login_required",
"login_required_redirect",
"role_required",
"role_required_list",
"role_required_redirect"
]);
// Permissions check
$this->redirectNotAllowed();
// Bare content template
if (Data::get("bare-content")) $this->setupBareContent();
}
/**
* Setup data to be used in a bare-contnet template
// Clear obsolete flash data
if (!$same_session_page) {
Data::goToNextSessionPage();
}
// Class method call
if (is_string($resp)) {
// Extracts method
$method = false;
if (preg_match('/(.*)::(.*)/', $resp, $keys)) {
$resp = $keys[1];
$method = $keys[2];
}
// Add namespace to class
$classname = "Syltaen\\$resp";
// Instanciate the class with the arguments
$class = new $classname($args);
// Lauch mehtod if any
if ($method) {
$class->$method();
}
}
// Closure function call
if (is_callable($resp)) {
$resp($args);
}
exit;
}
// ==================================================
// > RULES
// ==================================================
public static function any($resp, $args = [])
{
* @param boolean $resp
* @param array $args
* @return boolean
*/
public static function is($condition, $resp = false, $args = null, $prefix = "is_")
{
$conditions = (array) $condition;
foreach ($conditions as $condition) {
$argument = null;
if (preg_match('/(.*):(.*)/', $condition, $parts)) {
$condition = $parts[1];
$argument = $parts[2];
}
$condition = $prefix . $condition;
if ($condition($argument)) {
if ($resp) {
static::respond($resp, $args);
}
return true;
};
}
return false;
}
/**
* Website is in maintenance mode
*
* @param boolean $resp
* @return void
*/
public static function maintenance($resp = false)
{
if (Data::get("maintenance_mode", "option") && !current_user_can("administrator")) {
static::respond($resp);
}
}
// ==================================================
// > API
// ==================================================
Route::custom("api", "ApiController", ["method", "target", "mode"]);
// ==================================================
// > NINJA FORM PREVIEW
// ==================================================
Route::query("nf_preview_form", "SpecialPageController::ninjaFormPreview");
// ==================================================
// > HOMEPAGE
// ==================================================
Route::is(["home", "front_page"], "HomeController::render");
// ==================================================
// > PAGES
// ==================================================
Route::is("page:".DashboardController::SLUG, "DashboardController::render");
Route::is("page", "PageController::render");
// ==================================================
// > 404
// ==================================================
Route::is("404", "SpecialPageController::error404");
}
break;
}
}
if ( ! $template ) {
$template = get_index_template();
}
/**
* Filters the path of the current template before including it.
*
* @since 3.0.0
*
* @param string $template The path of the template to include.
*/
$template = apply_filters( 'template_include', $template );
if ( $template ) {
include $template;
} elseif ( current_user_can( 'switch_themes' ) ) {
$theme = wp_get_theme();
if ( $theme->errors() ) {
wp_die( $theme->errors() );
}
}
return;
}
Arguments
"/var/www/vhosts/bewapp.hungryminds.host/httpdocs/wp-content/themes/syltaen/index.php"
<?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( ! isset( $wp_did_header ) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once __DIR__ . '/wp-load.php';
// Set up the WordPress query.
wp();
// Load the theme template.
require_once ABSPATH . WPINC . '/template-loader.php';
}
Arguments
"/var/www/vhosts/bewapp.hungryminds.host/httpdocs/wp-includes/template-loader.php"
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define( 'WP_USE_THEMES', true );
/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';
Arguments
"/var/www/vhosts/bewapp.hungryminds.host/httpdocs/wp-blog-header.php"