-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #467 from JohnXLivingston/feature_styling_plugins
New Styling plugin
- Loading branch information
Showing
20 changed files
with
225 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
// debugging tools / libs | ||
if (file_exists(ROOT_DIR . 'vendor/autoload.php')) { | ||
require ROOT_DIR . 'vendor/autoload.php'; | ||
} | ||
|
||
require_once(ROOT_DIR . 'lib/Common/namespace.php'); | ||
|
||
interface IStylingPluginPage | ||
{ | ||
public function PageLoad(); | ||
} | ||
|
||
class StylingPluginPage implements IStylingPluginPage | ||
{ | ||
public function PageLoad() | ||
{ | ||
$userSession = ServiceLocator::GetServer()->GetUserSession(); | ||
|
||
header('Content-type: text/css'); | ||
$factory = PluginManager::Instance()->LoadStyling(); | ||
$path = $factory->AdditionalCSS($userSession); | ||
if (empty($path)) { | ||
http_response_code(200); | ||
die(); | ||
} | ||
if (!file_exists($path)) { | ||
http_response_code(404); | ||
die(); | ||
} | ||
http_response_code(200); | ||
readfile($path); | ||
die(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
define('ROOT_DIR', '../../'); | ||
|
||
require_once(ROOT_DIR . 'Pages/StylingPluginPage.php'); | ||
|
||
$page = new StylingPluginPage(); | ||
$page->PageLoad(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
interface IStylingFactory | ||
{ | ||
/** | ||
* Returns a file path (on the server) to an additional CSS file to use. | ||
* @param UserSession $userSession | ||
* @return null|string | ||
*/ | ||
public function AdditionalCSS(UserSession $userSession); | ||
|
||
/** | ||
* You can add some CSS classes to reservations items. | ||
* Those classes can for example depends on some attributes. | ||
* @param IReservedItemView $item | ||
* @return string[] | ||
*/ | ||
public function GetReservationAdditonalCSSClasses(IReservedItemView $item); | ||
} | ||
|
||
class StylingFactory implements IStylingFactory | ||
{ | ||
public function __construct() {} | ||
|
||
/** | ||
* Returns a file path (on the server) to an additional CSS file to use. | ||
* @param UserSession $userSession | ||
* @return null|string | ||
*/ | ||
public function AdditionalCSS(UserSession $userSession) | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* You can add some CSS classes to reservations items. | ||
* Those classes can for example depends on some attributes. | ||
* @param IReservedItemView $item | ||
* @return string[] | ||
*/ | ||
public function GetReservationAdditonalCSSClasses(IReservedItemView $item) | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
require_once(ROOT_DIR . 'lib/Application/Styling/StylingFactory.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
table.reservations .reserved.mine { | ||
background-color: red; | ||
} | ||
|
||
.custom-example-class { | ||
border: 2px dotted orange; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
class StylingExample implements IStylingFactory | ||
{ | ||
/** | ||
* @var StylingFactory | ||
*/ | ||
private $factoryToDecorate; | ||
|
||
public function __construct(StylingFactory $factoryToDecorate) | ||
{ | ||
$this->factoryToDecorate = $factoryToDecorate; | ||
} | ||
|
||
public function AdditionalCSS(UserSession $userSession) | ||
{ | ||
return realpath(__DIR__ . DIRECTORY_SEPARATOR . 'StylingExample.css'); | ||
} | ||
|
||
public function GetReservationAdditonalCSSClasses(IReservedItemView $item) | ||
{ | ||
$additionalCSSClasses = $this->factoryToDecorate->GetReservationAdditonalCSSClasses($item) ?? []; | ||
|
||
if (str_starts_with($item->GetTitle(), 'Example')) { | ||
$additionalCSSClasses[] = 'custom-example-class'; | ||
} | ||
|
||
return $additionalCSSClasses; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.