new pisilinux web sites

This commit is contained in:
Erkan IŞIK
2026-07-01 16:44:17 +03:00
commit b58488b586
21740 changed files with 2066209 additions and 0 deletions
@@ -0,0 +1,15 @@
<?php namespace ZN\Inclusion\Project;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
class Masterpage
{
use ViewTrait;
}
@@ -0,0 +1,119 @@
<?php namespace ZN\Inclusion\Project;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\IS;
use ZN\Base;
use ZN\Request;
class Theme
{
/**
* Active status
*
* @var string
*/
public static $active = NULL;
/**
* Match elements.
*
* @var array
*/
protected static $elements = [NULL, NULL];
/**
* Active theme.
*
* @param string $active = 'Default'
*
* @return void
*/
public static function active(string $active = 'Default')
{
self::$active = Base::suffix($active);
define('CURRENT_THEME', $active);
if( ! is_dir($themeDirectory = THEMES_DIR . self::$active) )
{
if( is_dir($externalThemeDirectory = EXTERNAL_THEMES_DIR . self::$active) )
{
$themeDirectory = $externalThemeDirectory;
}
}
define('CURRENT_THEME_DIR', $themeDirectory);
}
/**
* Match element.
*
* @param array $elements
*/
public static function matchElement(?string $inputs = NULL, ?string $attributes = NULL)
{
self::$elements = [Base::prefix($inputs, '|'), Base::prefix($attributes, '|')];
return new self;
}
/**
* Theme integration.
*
* 5.7.5.5[changed]
*
* @param string $themeName
* @param string &$data
*
* @return void
*/
public static function integration(string $themeName, string &$data)
{
$data = preg_replace_callback
(
[
'/<(link|img|script|div|a' . self::$elements[0] . ')\s.*?(href|src' . self::$elements[1] . ')\=(\"|\')(?<element>.*?)(\"|\').*?\>/i',
'/background(-image)*\s*\:\s*url\((?<element>.*?)\)/i'
],
function($selector) use ($themeName)
{
$orig = $selector[0];
$path = trim($selector['element'], '\'');
$path = preg_replace('/(\.\.\/)+/', '//', $path);
if( ! IS::url($path) && ! is_file($path) )
{
$suffix = Base::suffix($themeName) . $path;
if( is_file(THEMES_DIR . $suffix) )
{
return self::getReplacePath($path, THEMES_DIR, $suffix, $orig); // @codeCoverageIgnore
}
elseif( is_file(EXTERNAL_THEMES_DIR . $suffix) )
{
return self::getReplacePath($path, EXTERNAL_THEMES_DIR, $suffix, $orig);
}
}
return $selector[0];
}, $data
);
}
/**
* protected get replace path
*/
protected static function getReplacePath($path, $dir, $suffix, $orig)
{
return str_replace($path, Request::getBaseURL($dir) . $suffix, $orig);
}
}
@@ -0,0 +1,30 @@
<?php namespace ZN\Inclusion\Project;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Inclusion;
class View
{
use ViewTrait;
/**
* Load view.
*
* @param string $file = NULL
* @param bool $usable = false
*
* @return mixed
*/
public static function get(?string $file = NULL, $usable = false)
{
return Inclusion\View::use($file, [], $usable);
}
}
@@ -0,0 +1,164 @@
<?php namespace ZN\Inclusion\Project;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Singleton;
trait ViewTrait
{
/**
* Keep data
*
* @var array
*/
public static $data = [];
/**
* Usable view methods
*
* @var array
*/
protected static $usableViewMethods =
[
'page', 'view', 'cview', 'template', 'something'
];
/**
* Usable resources methods
*
* @var array
*/
protected static $usableResourcesMethods =
[
'script', 'style', 'font', 'theme', 'plugin'
];
/**
* Magic call static
*
* @param string $method
* @param array $parameters
*
* @return self
*/
public static function __callStatic($method, $parameters)
{
if( ($return = self::call($method, $parameters)) !== NULL )
{
return $return; // @codeCoverageIgnore
}
return new self;
}
/**
* Magic call
*
* @param string $method
* @param array $parameters
*
* @return $this
*/
public function __call($method, $parameters)
{
if( ($return = self::call($method, $parameters)) !== NULL )
{
return $return; // @codeCoverageIgnore
}
return $this;
}
/**
* Get method & parameters
*
* @param string $method
* @param array $parameters
*
* @return void
*/
protected static function call($method, $parameters)
{
# If the invoked method does not contain a parameter, it returns the current value.
if( empty($parameters) )
{
return self::$data[$method] ?? false; // @codeCoverageIgnore
}
// @codeCoverageIgnoreStart
# If the parameter of the invoked method contains a measurable value,
# a special operation is executed.
if( self::isImportMethod($parameters[0], $resolve) )
{
# The other parameters are used like the parametric array of the import method.
$getImportMethodParameters = self::getImportMethodParameters($parameters);
# If the inclusion method is one of the following 4 methods;
# [cview|page|view|something|template]
# If no data is sent to the import method,
# the second parameter of the method is set to NULL.
if( in_array($getImportMethod = $resolve['method'], self::$usableViewMethods) && ! is_array($getImportMethodParameters[0]) )
{
array_unshift($getImportMethodParameters, NULL);
}
# Getting the contents of the included file.
self::$data[$method] = $isImportMethodContent = self::getImportMethod($getImportMethod, $resolve['parameter'], $getImportMethodParameters);
}
// @codeCoverageIgnoreEnd
# If the included file is not valid or has no content,
# the parameter is assumed to be a normal value.
if( empty($isImportMethodContent) )
{
self::$data[$method] = $parameters[0];
}
# Returning NULL resumes object transfer. The return value is assumed to be $this.
return NULL;
}
/**
* Protected is import method
*/
protected static function isImportMethod($parameter, &$match)
{
return is_scalar($parameter) && preg_match
(
'/^(?<method>' . implode('|', self::$usableViewMethods + self::$usableResourcesMethods) . ')\:(?<parameter>.*)/',
$parameter ?? '',
$match
);
}
/**
* Protected get import method
*
* @codeCoverageIgnore
*/
protected static function getImportMethod($getImportMethod, $firstParameter, $getOtherParameters)
{
return Singleton::class('ZN\Import')->$getImportMethod($firstParameter, ...$getOtherParameters);
}
/**
* Protected get import method parameters
*
* @codeCoverageIgnore
*/
protected static function getImportMethodParameters($parameters)
{
return Singleton::class('ZN\DataTypes\Collection')
->data($parameters)
->removeFirst()
->addLast(true)
->get();
}
}