2021-11-11 11:00:48 +03:00
|
|
|
|
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
2024-01-01 01:14:38 +03:00
|
|
|
|
* MaketRandevu - MAKET Randevu Portalı
|
2021-11-11 11:00:48 +03:00
|
|
|
|
*
|
|
|
|
|
* @package EasyAppointments
|
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2021-12-18 19:43:45 +03:00
|
|
|
|
* @copyright Copyright (c) Alex Tselegidis
|
|
|
|
|
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
|
* @link https://easyappointments.org
|
2021-11-11 11:00:48 +03:00
|
|
|
|
* @since v1.4.0
|
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (!function_exists('e')) {
|
2023-03-13 10:08:43 +03:00
|
|
|
|
/**
|
|
|
|
|
* HTML escape function for templates.
|
|
|
|
|
*
|
|
|
|
|
* Use this helper function to easily escape all the outputted HTML markup.
|
|
|
|
|
*
|
|
|
|
|
* Example:
|
|
|
|
|
*
|
|
|
|
|
* <?= e($string) ?>
|
|
|
|
|
*
|
|
|
|
|
* @param mixed $string Provide anything that can be converted to a string.
|
|
|
|
|
*/
|
|
|
|
|
function e(mixed $string): string
|
|
|
|
|
{
|
2023-11-29 12:24:09 +03:00
|
|
|
|
return htmlspecialchars((string) $string, ENT_QUOTES, 'UTF-8');
|
2023-03-13 10:08:43 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (!function_exists('component')) {
|
2021-11-11 11:00:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* Render a component from the "views/components/*.php" directory.
|
|
|
|
|
*
|
|
|
|
|
* Use this helper function to easily include components into your HTML markup.
|
|
|
|
|
*
|
|
|
|
|
* Any loaded template variables will also be available at the component template, but you may also specify
|
|
|
|
|
* additional values by adding values to the $params parameter.
|
|
|
|
|
*
|
|
|
|
|
* Example:
|
|
|
|
|
*
|
2022-01-18 13:03:44 +03:00
|
|
|
|
* echo component('timezones_dropdown', ['attributes' => 'class"form-control"'], TRUE);
|
2021-11-11 11:00:48 +03:00
|
|
|
|
*
|
|
|
|
|
* @param string $component Component template file name.
|
2022-01-18 13:03:44 +03:00
|
|
|
|
* @param array $vars Additional parameters for the component.
|
2022-01-11 12:11:09 +03:00
|
|
|
|
* @param bool $return Whether to return the HTML or echo it directly.
|
|
|
|
|
*
|
2023-04-05 16:35:31 +03:00
|
|
|
|
* @return string|object Return the HTML if the $return argument is TRUE or NULL.
|
2021-11-11 11:00:48 +03:00
|
|
|
|
*/
|
2023-11-29 12:24:09 +03:00
|
|
|
|
function component(string $component, array $vars = [], bool $return = false): string|object
|
2021-11-11 11:00:48 +03:00
|
|
|
|
{
|
2021-11-17 10:41:51 +03:00
|
|
|
|
/** @var EA_Controller $CI */
|
|
|
|
|
$CI = get_instance();
|
2022-01-11 12:11:09 +03:00
|
|
|
|
|
2021-11-17 10:41:51 +03:00
|
|
|
|
return $CI->load->view('components/' . $component, $vars, $return);
|
2021-11-11 11:00:48 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-15 10:52:35 +03:00
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (!function_exists('extend')) {
|
2021-11-15 10:52:35 +03:00
|
|
|
|
/**
|
|
|
|
|
* Use this function at the top of view files to mark the layout you are extending from.
|
|
|
|
|
*
|
|
|
|
|
* @param $layout
|
|
|
|
|
*/
|
2023-03-13 11:06:18 +03:00
|
|
|
|
function extend($layout): void
|
2021-11-15 10:52:35 +03:00
|
|
|
|
{
|
|
|
|
|
config([
|
|
|
|
|
'layout' => [
|
|
|
|
|
'filename' => $layout,
|
|
|
|
|
'sections' => [],
|
2023-12-22 13:35:41 +03:00
|
|
|
|
'tmp' => [],
|
|
|
|
|
],
|
2021-11-15 10:52:35 +03:00
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (!function_exists('section')) {
|
2021-11-15 10:52:35 +03:00
|
|
|
|
/**
|
|
|
|
|
* Use this function in view files to mark the beginning and/or end of a layout section.
|
|
|
|
|
*
|
|
|
|
|
* Sections will only be used if the view file extends a layout and will be ignored otherwise.
|
|
|
|
|
*
|
|
|
|
|
* Example:
|
|
|
|
|
*
|
|
|
|
|
* <?php section('content') ?>
|
|
|
|
|
*
|
|
|
|
|
* <!-- Section Starts -->
|
|
|
|
|
*
|
|
|
|
|
* <p>This is the content of the section.</p>
|
|
|
|
|
*
|
|
|
|
|
* <!-- Section Ends -->
|
|
|
|
|
*
|
|
|
|
|
* <?php section('content') ?>
|
|
|
|
|
*
|
|
|
|
|
* @param string $name
|
|
|
|
|
*/
|
2023-03-13 11:06:18 +03:00
|
|
|
|
function section(string $name): void
|
2021-11-15 10:52:35 +03:00
|
|
|
|
{
|
|
|
|
|
$layout = config('layout');
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (array_key_exists($name, $layout['tmp'])) {
|
2022-01-11 12:11:09 +03:00
|
|
|
|
$layout['sections'][$name][] = ob_get_clean();
|
2021-11-15 10:52:35 +03:00
|
|
|
|
|
2022-01-11 12:26:49 +03:00
|
|
|
|
unset($layout['tmp'][$name]);
|
2022-01-18 13:03:44 +03:00
|
|
|
|
|
2021-11-15 10:52:35 +03:00
|
|
|
|
config(['layout' => $layout]);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (empty($layout['sections'][$name])) {
|
2022-01-11 12:26:49 +03:00
|
|
|
|
$layout['sections'][$name] = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$layout['tmp'][$name] = '';
|
2021-11-15 10:52:35 +03:00
|
|
|
|
|
|
|
|
|
config(['layout' => $layout]);
|
|
|
|
|
|
|
|
|
|
ob_start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (!function_exists('end_section')) {
|
2023-03-13 10:24:43 +03:00
|
|
|
|
/**
|
|
|
|
|
* Use this function in view files to mark the end of a layout section.
|
|
|
|
|
*
|
|
|
|
|
* Sections will only be used if the view file extends a layout and will be ignored otherwise.
|
|
|
|
|
*
|
|
|
|
|
* Example:
|
|
|
|
|
*
|
|
|
|
|
* <?php section('content') ?>
|
|
|
|
|
*
|
|
|
|
|
* <!-- Section Starts -->
|
|
|
|
|
*
|
|
|
|
|
* <p>This is the content of the section.</p>
|
|
|
|
|
*
|
|
|
|
|
* <!-- Section Ends -->
|
|
|
|
|
*
|
|
|
|
|
* <?php end_section('content') ?>
|
|
|
|
|
*
|
|
|
|
|
* @param string $name
|
|
|
|
|
*/
|
2023-03-13 11:06:18 +03:00
|
|
|
|
function end_section(string $name): void
|
2023-03-13 10:24:43 +03:00
|
|
|
|
{
|
|
|
|
|
$layout = config('layout');
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (array_key_exists($name, $layout['tmp'])) {
|
2023-03-13 10:24:43 +03:00
|
|
|
|
$layout['sections'][$name][] = ob_get_clean();
|
|
|
|
|
|
|
|
|
|
unset($layout['tmp'][$name]);
|
|
|
|
|
|
|
|
|
|
config(['layout' => $layout]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (!function_exists('slot')) {
|
2021-11-15 10:52:35 +03:00
|
|
|
|
/**
|
|
|
|
|
* Use this function in view files to mark a slot that sections can populate from within child templates.
|
|
|
|
|
*
|
|
|
|
|
* @param string $name
|
|
|
|
|
*/
|
2023-03-13 11:06:18 +03:00
|
|
|
|
function slot(string $name): void
|
2021-11-15 10:52:35 +03:00
|
|
|
|
{
|
|
|
|
|
$layout = config('layout');
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
$section = $layout['sections'][$name] ?? null;
|
2022-01-11 12:11:09 +03:00
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (!$section) {
|
2022-01-11 12:11:09 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
foreach ($section as $content) {
|
2022-01-11 12:11:09 +03:00
|
|
|
|
echo $content;
|
|
|
|
|
}
|
2021-11-15 10:52:35 +03:00
|
|
|
|
}
|
|
|
|
|
}
|