Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/patientapps_support/modules/cms/ |
Upload File : |
<?php
namespace modules\cms;
class main extends \moduleMain {
use \modules\config\traits {
\modules\config\traits::__construct as __ConstructConfig;
}
use \modules\input\traits {
\modules\input\traits::__construct as __ConstructInput;
}
use \modules\database\traits {
\modules\database\traits::__construct as __ConstructDatabase;
}
use \modules\output\traits {
\modules\output\traits::__construct as __ConstructOutput;
}
private $model_cms = NULL;
private $editPage = FALSE;
private $pagestatus = 0;
public function __construct() {
parent::__construct(__DIR__);
$this->__ConstructConfig();
$this->__ConstructInput();
$this->__ConstructDatabase();
$this->__ConstructOutput($this->__INPUT, $this->__CONFIG);
}
public function Activate() {
hook_add('output.errordetail', [$this, '__create']);
hook_add('uri', [$this, '__checkcms']);
hook_add('email.transform', [$this, '__applyHandlebars']); // is the email using a templating system?
hook_add('menu.menu2', [$this, '__edit'], 2); // can we edit this page?
hook_add('menu.admin', [$this, '__admin_menu'], 20); // admin menu
$this->autoloadRegister('LightnCandy', __DIR__ . '/lightncandy');
$this->Register_FormatHandler('__cms', [$this, '__cms_page'], 'a CMS page');
$this->Register_FormatHandler('__cms_edit', [$this, '__cms_edit'], 'CMS page editor');
$this->Register_FormatHandler('__cms_json', [$this, '__cms_json'], 'update CMS page status');
}
public function __admin_menu(&$menu) {
$menu[] = [
'caption' => 'Email Templates',
'href' => '/admin/email',
'hint' => 'Edit Email Templates',
'icon' => '<i class="far fa-envelope"></i>',
's' => 0
];
}
private function _init() {
if (empty($this->model_cms)) {
$this->model_cms = $this->LoadModel('cms_model');
$this->model_cms->SetPages($this->loadModel('pages'));
}
}
public function __create(&$data, $http_status) {
if ($http_status->status() == 404) { // only for not-found pages
$this->_init();
$uri = $this->uri(); // without any query_string
$this->editPage = $this->model_cms->ErrorPage($data, $uri);
}
}
// only for email templates
public function __applyHandlebars(&$mailobject) {
$template = $mailobject->template();
if (empty($result) && !empty($template)) {
$this->_init();
$this->model_cms->ApplyEmailTemplate($mailobject);
}
}
// is the URL one from the cms system?
//to do: intercept email links
public function __checkcms(&$uri) {
$this->_init();
$edithash = $this->param('editpage', '');
// $this->model_cms->SetPages($this->loadModel('pages'));
$this->pagestatus = $this->model_cms->IsCmsPage($uri, $edithash);
switch($this->pagestatus) {
case 1: // view cms text
return $this->_acceptcms('__cms');
case 2: // edit text
$this->model_cms->SetPagesHistory($this->loadModel('pages_history'));
return $this->_acceptcms('__cms_edit');
// CASE 3: redirect to preview page
}
}
// a cms page has been requested.
private function _acceptcms($param) {
// set cms text
if ($this->method() == 'POST') {
$body = $this->post('body', '');
$action = strtolower(trim($this->post('s', '')));
$title = $this->post('title', '');
$result = $this->model_cms->PageSave(['s' => $action, 'body' => $body, 'title' => $title]);
$this->OutputSet('result', $result['result']);
$this->OutputSet('message', $result['message']);
$this->OutputFormat('__cms_json');
//to do: update data json to display page-saved noty.
} else {
$this->OutputFormat($param);
}
}
public function __edit(&$menu) {
if ($this->editPage) { // page not found - allow it to be created or edited
// does the page exist?
$hint = $this->pagestatus ? 'Edit Content' : 'Create Content';
$menu[] = [
'caption' => $hint,
'href' => $this->editPage,
'hint' => $hint,
'icon' => '<i class="fax-green largeicon fas fa-pen-square"></i>',
's' => 0
];
}
}
public function __cms_page($data) {
unset($data['result'], $data['message']);
$this->model_cms->ViewPage();
$this->__OUTPUT->ExportHandler($data, 'html');
}
public function __cms_edit($data) {
unset($data['result'], $data['message'], $data['template']);
// $base = $this->StaticUriModule(__DIR__);
// $this->IncludeFile($base . '/style.css');
$this->model_cms->EditPage();
$this->__OUTPUT->ExportHandler($data, 'html');
}
public function __cms_json($data) {
$data['result'] = $this->OutputGet('result');
$data['message'] = $this->OutputGet('message');
$this->__OUTPUT->ExportHandler($data, 'json');
}
}