Skip to content
This repository was archived by the owner on May 21, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/Application.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace GodsDev\MyCMS;

use \GodsDev\Tools\Tools;
//use GodsDev\Tools\Tools;

class Application {

Expand Down
24 changes: 24 additions & 0 deletions classes/MyAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace GodsDev\MyCMS;

/**
* Parent for deployed Admin instance
*
*/
class MyAdmin extends MyCommon
{

/**
* Child may pre-populate $acceptedAttributes by addAcceptedmethod, all of them MUST be declared as protected/public variables
*
* @param \GodsDev\MyCMS\MyCMS $MyCMS
* @param array $options that overides default values within constructor
*/
public function __construct(MyCMS $MyCMS, array $options = array())
{
//nothing by default: $this->addAccepted('');
parent::__construct($MyCMS, $options);
}

}
2 changes: 1 addition & 1 deletion classes/MyCMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function __construct(array $myCmsConf = array())
*
* @param array $getArray $_GET or its equivalent
* @param array $sessionArray $_SESSION or its equivalent
* @return bool $makeInclude for testing may be set to false as mycms itself does not contain the language-XX.inc.php files
* @param bool $makeInclude for testing may be set to false as mycms itself does not contain the language-XX.inc.php files
* @return string to be used as $_SESSION['language']
*
* constant TAB_PREFIX expected
Expand Down
53 changes: 53 additions & 0 deletions classes/MyCommon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace GodsDev\MyCMS;

/**
* Generic ancestor for classes that uses MyCMS
*
*/
class MyCommon
{

use \Nette\SmartObject;

/** @var \GodsDev\MyCMS\MyCMS */
protected $MyCMS;

/** @var array */
protected $acceptedAttributes;

/**
* accepted attributes:
*/


/**
* Child may pre-populate $acceptedAttributes by addAcceptedmethod, all of them MUST be declared as protected/public variables
*
* @param \GodsDev\MyCMS\MyCMS $MyCMS
* @param array $options that overides default values within constructor
*/
public function __construct(MyCMS $MyCMS, array $options = array())
{
//nothing by default $this->addAccepted('get session');
foreach (array_merge(
array(//default values
), $options) as $optionVariable => $optionContent) {
if (in_array($optionVariable, $this->acceptedAttributes, true)) {
$this->{$optionVariable} = $optionContent;
}
}
$this->MyCMS = $MyCMS;
}

/**
*
* @param string $acceptedList space delimited
*/
protected function addAccepted($acceptedList)
{
$this->acceptedAttributes = array_merge(explode(' ', $acceptedList), $this->acceptedAttributes ? $this->acceptedAttributes : array());
}

}
36 changes: 7 additions & 29 deletions classes/MyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,34 @@
*
* The default template is `home`
*/
class MyController
class MyController extends MyCommon
{

use \Nette\SmartObject;

/** @var \GodsDev\MyCMS\MyCMS */
protected $MyCMS;

/** @var array */
protected $result;

/** @var array */
protected $acceptedAttributes;

//accepted attributes:

/**
* accepted attributes:
*/
/** @var array */
protected $get;

/** @var array */
protected $session;

/**
* Child may pre-populate $acceptedAttributes by addAcceptedmethod, all of them MUST be declared as variables
* Child may pre-populate $acceptedAttributes by addAcceptedmethod, all of them MUST be declared as protected/public variables
*
* @param \GodsDev\MyCMS\MyCMS $MyCMS
* @param array $options that overides default values within constructor
*/
public function __construct(MyCMS $MyCMS, array $options = array())
{
$this->addAccepted('get session');
foreach (array_merge(
array(//default values
), $options) as $optionVariable => $optionContent) {
if (in_array($optionVariable, $this->acceptedAttributes, true)) {
$this->{$optionVariable} = $optionContent;
}
}
$this->MyCMS = $MyCMS;
parent::__construct($MyCMS, $options);
$this->result = array("template" => "home", "context" => ($this->MyCMS->context ? $this->MyCMS->context : array()));
}

/**
*
* @param string $acceptedList space delimited
*/
protected function addAccepted($acceptedList)
{
$this->acceptedAttributes = array_merge(explode(' ', $acceptedList), $this->acceptedAttributes ? $this->acceptedAttributes : array());
}

/**
* Outputs changed $MyCMS->template and $MyCMS->context as fields of an array
*
Expand Down
28 changes: 21 additions & 7 deletions classes/ProjectCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,29 @@

namespace GodsDev\MyCMS;

use Psr\Log\LoggerInterface;

class ProjectCommon
{
{

use \Nette\SmartObject;

/**
/** @var \GodsDev\MyCMS\MyCMS */
protected $MyCMS;

/**
*
* @param \GodsDev\MyCMS\MyCMS $MyCMS
*/
public function __construct(MyCMS $MyCMS)
{
$this->MyCMS = $MyCMS;
}

/**
* Shortcut for echo'<pre>'; var_dump(); and exit;
* @param mixed variable(s) or expression to display
*/
public static function dump($var) {
public static function dump($var)
{
echo '<pre>';
foreach (func_get_args() as $arg) {
var_dump($arg);
Expand All @@ -21,7 +33,8 @@ public static function dump($var) {
}

//@todo refactor as getTexy() which returns Texy object that is initialized in this dynamic class
public static function prepareTexy() {
public static function prepareTexy()
{
global $Texy;
if (!is_object($Texy)) {
$Texy = new \Texy();
Expand All @@ -37,7 +50,8 @@ public static function prepareTexy() {
* @param string $stringOfTime
* @param string $language
*/
public static function localDate($stringOfTime, $language) {
public static function localDate($stringOfTime, $language)
{
switch ($language) {
case 'cs': return date('j.n.Y', strtotime($stringOfTime));
}
Expand Down
2 changes: 1 addition & 1 deletion classes/TableAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace GodsDev\MyCMS;

use \GodsDev\Tools\Tools;
use GodsDev\Tools\Tools;

/**
* This class facilitates administration of a database table
Expand Down
2 changes: 1 addition & 1 deletion classes/TableLister.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace GodsDev\MyCMS;

use \GodsDev\Tools\Tools;
use GodsDev\Tools\Tools;

/**
* Class that can list rows of a database table, with editable search/filter
Expand Down