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,62 @@
<?php namespace ZN\Ability;
/**
* 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\Config;
use ZN\Classes;
trait Configurable
{
/**
* Magic call static
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public static function __callStatic($method, $parameters)
{
# Class name information without a namespace.
$config = self::getOnlyClassName();
# The called method name is accepted as the first parameter.
array_unshift($parameters, $method);
# If it contains at least 2 or 3 parameters,
# it means that reconfiguration is being performed.
if( is_array($parameters[0] ?? NULL) || count($parameters) >= 2 )
{
# Settings are being reconfigured.
return Config::set($config, ...$parameters);
}
# If no reconfiguration condition is found, the current settings are returned.
return Config::get($config, ...$parameters);
}
/**
* Get all config
*
* @return array
*/
public static function all() : array
{
return Config::get(self::getOnlyClassName());
}
/**
* Protected get only class name
*/
protected static function getOnlyClassName()
{
return Classes::onlyName(__CLASS__);
}
}
@@ -0,0 +1,83 @@
<?php namespace ZN\Ability;
/**
* 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\Datatype;
use ZN\Singleton;
use ZN\Ability\Exception\InvalidContainerMethod;
use ZN\Ability\Exception\UnsupportedDriverException;
trait Container
{
/**
* Keeps class interface..
*
* @var StorageInterface
*/
protected static $container;
/**
* Magic call
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public function __call($method, $parameters)
{
return self::call($method, $parameters);
}
/**
* Magic call static
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public static function __callStatic($method, $parameters)
{
return self::call($method, $parameters);
}
/**
* Get driver
*
* @param string $class
*
* @return ZN\Singleton
*/
public static function driver(string $class)
{
$class = Datatype::divide(__CLASS__, '\\', 0, -1) . ucfirst($origin = $class);
if( ! class_exists($class) )
{
throw new UnsupportedDriverException(NULL, ['%' => $origin, '#' => __CLASS__]);
}
return Singleton::class($class); // @codeCoverageIgnore
}
/**
* Protected static call
*/
protected static function call($method, $parameters)
{
if( method_exists(self::$container, $method) )
{
return self::$container->$method(...$parameters);
}
throw new InvalidContainerMethod(NULL, ['%' => $method, '#' => __CLASS__]);
}
}
@@ -0,0 +1,128 @@
<?php namespace ZN\Ability;
/**
* 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\Base;
use ZN\Config;
use ZN\Support;
use ZN\Singleton;
use ZN\Exception\UndefinedConstException;
trait Driver
{
/**
* protected driver
*
* @var string
*/
protected $driver;
/**
* protected driver name
*
* @var string
*/
protected $selectedDriverName;
/**
* magic constructor
*
* @param string $driver = NULL
*
* @return void
*/
public function __construct(?string $driver = NULL)
{
# If parent class does not contain driver constant, the operation is stopped.
if( ! defined('static::driver') )
{
throw new UndefinedConstException('[const driver] is required to use the [Driver Ability]!'); // @codeCoverageIgnore
}
# 5.3.42|5.4.5|5.6.0[edited]
$driver = $driver ?? # driver($driver)
$this->config['driver'] ?? # class name driver
$this->getDriverNameFromDriverConstant() ?: # define config
$this->getDefaultDriverNameFromDriverConstant() ?: # define default
static::driver['options'][0] ?? // @codeCoverageIgnore
$this->setNullDefaultDriverName(); # Default driver name is NULL
# It checks whether the selected driver is a valid driver.
Support::driver(static::driver['options'], $driver);
# The selected drive stores its name.
$this->selectedDriverName = $driver;
# Drivers should be written with Pascal case notation.
$driver = ucfirst($driver);
# If the driver does not contain a namespace, it is called directly.
if( ! isset(static::driver['namespace']) )
{
$this->driver = Singleton::class($driver);
}
else
{
$this->driver = $this->createSingletonInstanceDriverClass($driver);
}
# This ability is used to trigger a method of the parent class in the __construct method.
if( isset(static::driver['construct']) )
{
$construct = static::driver['construct'];
$this->{$construct}();
}
}
/**
* Select driver
*
* @param string $driver
*
* @return self
*/
public function driver(string $driver) : self
{
return new self($driver);
}
/**
* Protected set null default driver name.
*/
protected function setNullDefaultDriverName()
{
return 'NULL';
}
/**
* Protected create singleton instance driver class.
*/
protected function createSingletonInstanceDriverClass($driver)
{
return Singleton::class(Base::suffix(static::driver['namespace'], '\\') . $driver . 'Driver');
}
/**
* Protected get driver name from driver constant.
*/
protected function getDriverNameFromDriverConstant()
{
return isset(static::driver['config']) ? Config::get(...explode(':', static::driver['config']))['driver'] : NULL;
}
/**
* Protected get default driver name from driver constant.
*/
protected function getDefaultDriverNameFromDriverConstant()
{
return isset(static::driver['default']) ? get_class_vars(static::driver['default'])['driver'] : NULL;
}
}
@@ -0,0 +1,21 @@
<?php namespace ZN\Ability\Exception;
/**
* 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\Exception;
class InvalidContainerMethod extends Exception
{
const lang =
[
'tr' => '[#::%()] yöntemi tanımlı değil!',
'en' => 'The [#::%()] method is undefined!'
];
}
@@ -0,0 +1,21 @@
<?php namespace ZN\Ability\Exception;
/**
* 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\Exception;
class InvalidFactoryMethod extends Exception
{
const lang =
[
'tr' => '[%] parametre geçersiz fabrika yöntemi içeriyor!',
'en' => '[%] parameter contains invalid factory method!'
];
}
@@ -0,0 +1,27 @@
<?php namespace ZN\Ability\Exception;
/**
* 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\Exception;
class UnsupportedDriverException extends Exception
{
/**
* Exception language settings
*
* @param string en
* @param string tr
*/
const lang =
[
'en' => '[%] driver is not a valid driver for class [#]!',
'tr' => '[%] sürücüsü [#] sınıfı için geçerli bir sürücü değil!'
];
}
@@ -0,0 +1,92 @@
<?php namespace ZN\Ability;
/**
* 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\Lang;
use ZN\ErrorHandling\Exceptions;
trait Exclusion
{
/**
* Magic constructor
*
* @param string $file = NULL
* @param string $message = NULL
* @param mixed $changed = NULL
*
* @return void
*/
public function __construct($file = NULL, $message = NULL, $changed = NULL)
{
# If the 1. parameter is set to NULL,
# the language contents defined in the exception class are used.
if( defined('static::lang') && $file === NULL )
{
# Language content is being obtained.
$content = static::lang[Lang::get()] ?? 'No Exception Lang';
# The 2.($message) parameter is assumed to be the parameter that will contain the statements to be placed.
$placement = static::lang['placement'] ?? $message;
# If there is an phrase insertion, the message is rearranged.
$message = $this->phrasePlacement($content, $placement);
}
else
{
# If the parameters are set as Lang::select(),
# this method is enabled.
if( is_scalar($data = Lang::default('ZN\CoreDefaultLanguage')::select($file, $message, $changed)) && ! empty($data) )
{
$message = $data;
}
# If 1. parameter is an exception object,
# the contents of the object's message are retrieved.
elseif( is_object($file) )
{
$message = $file->getMessage();
}
# The 1. parameter can be used directly as message content.
else
{
$message = $file;
}
}
# The constructor method of the exception class goes into effect.
parent::__construct($message);
}
/**
* Code continue
*
* @param void
*
* @return void
*
* @codeCoverageIgnore
*/
public function continue()
{
echo Exceptions::continue($this->getMessage(), $this->getFile(), $this->getLine());
}
/**
* Protected phrase placement
*/
protected function phrasePlacement($content, $placement)
{
if( is_array($placement) )
{
return str_replace(array_keys($placement), array_values($placement), $content);
}
return str_replace('%', $placement, $content);
}
}
@@ -0,0 +1,45 @@
<?php namespace ZN\Ability;
/**
* 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]
*/
trait Fabrication
{
/**
* Magic call
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public function __call($method, $parameters)
{
# It provides a way to invoke class groups of certain names as methods.
return $this->call($parameters, $method);
}
/**
* protected call
*
* @param array $parameters
* @param string $type = NULL
*
* @return mixed
*/
protected function call($parameters, $type = NULL)
{
# For example ReflectionClass
# A usage like ReflectionClass is obtained by using Reflect::class.
$class = (self::fabrication['prefix'] ?? NULL) . $type . (self::fabrication['suffix'] ?? NULL);
# It can be thought of as a factory that produces a class.
return (new $class(...$parameters));
}
}
@@ -0,0 +1,54 @@
<?php namespace ZN\Ability;
/**
* 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 Facade
{
/**
* Magic call static
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public static function __callStatic($method, $parameters)
{
return self::useClassName($method, $parameters);
}
/**
* Magic call
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public function __call($method, $parameters)
{
return self::useClassName($method, $parameters);
}
/**
* Use class name
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
protected static function useClassName($method, $parameters)
{
return Singleton::class(static::target)->$method(...$parameters);
}
}
@@ -0,0 +1,138 @@
<?php namespace ZN\Ability;
/**
* 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\Support;
use ZN\Singleton;
trait Factory
{
/**
* Magic call static
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public static function __callStatic($method, $parameters)
{
return self::call($method, $parameters);
}
/**
* Magic call
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public function __call($method, $parameters)
{
return $this->call($method, $parameters);
}
/**
* Magic call
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public static function call($method, $parameters)
{
if( ! defined('static::factory') )
{
return false;
}
$method = strtolower($originMethodName = $method);
if( ! isset(static::factory['methods'][$method]) )
{
Support::classMethod(get_called_class(), $originMethodName);
}
# The subclass and method that the method will execute is taken.
$class = static::factory['methods'][$method];
# The class to be used as factory for the library used is defined.
# However, this usage is not necessary.
$factory = static::factory['class'] ?? NULL;
if( $factory !== NULL )
{
return $factory::class($class)->$method(...$parameters); // @codeCoverageIgnore
}
# It can call the desired method of another class.
# That is, it opens the way to a mixed class design
# that consists of methods of various classes.
else
{
# Solving starts when a valid class and method information is sent.
if( ! self::isValidClassAndMethodName($class, $resolve) )
{
throw new Exception\InvalidFactoryMethod(NULL, $class);
}
# A new singleton inheritance class instance is created.
$return = self::createSingletonInstance($resolve['class'], $resolve['method'], $parameters);
# The return value $this can be sent to ensure object continuity.
if( isset($resolve['this']) )
{
$parent = get_called_class();
return new $parent;
}
# Return new instance.
return $return;
}
}
/**
* Protected create singleton instance
*/
protected static function createSingletonInstance($class, $method, $parameters)
{
return Singleton::class(self::getCalledClassNamespace() . $class)->$method(...$parameters);
}
/**
* Protected get called class namespace
*/
protected static function getCalledClassNamespace()
{
$namespace = NULL;
# The namespace is being rebuilt.
if( strstr($calledClass = get_called_class(), $separator = '\\') )
{
$namespace = explode($separator, $calledClass);
array_pop($namespace);
$namespace = implode($separator, $namespace) . $separator;
}
return $namespace;
}
/**
* Protected is valid class & method name.
*/
protected static function isValidClassAndMethodName($class, &$resolve)
{
return preg_match('/(?<class>([a-zA-Z]\w+(\\\\)*){1,})\:\:(?<method>\w+)(?<this>\:this)*/', $class ?? '', $resolve);
}
}
@@ -0,0 +1,40 @@
<?php namespace ZN\Ability;
/**
* 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]
*/
trait Functionalization
{
/**
* Magic call
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public function __call($method, $parameters)
{
# It allows a library to cluster the desired functions within it.
if( $standart = (static::functionalization[strtolower($method)] ?? NULL) )
{
return $standart(...$parameters);
}
$getParentClass = get_parent_class($this);
# The __call method of the parent class does not lose its functionality.
if( $getParentClass && method_exists($getParentClass, '__call'))
{
return parent::__call($method, $parameters);
}
return false;
}
}
@@ -0,0 +1,99 @@
<?php namespace ZN\Ability;
/**
* 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\Lang;
trait Information
{
/**
* Catch error
*
* @var mixed
*/
protected $error;
/**
* Catch success
*
* @var mixed
*/
protected $success;
/**
* Classes that incorporate this feature include a structure that can hold error messages.
*
* @param string $endOfLine = '<br>'
*
* @return mixed
*/
public function error(string $endOfLine = '<br>')
{
if( ! empty($this->error) )
{
if( is_array($this->error) )
{
return implode($endOfLine, $this->error);
}
return $this->error;
}
else
{
return false;
}
}
/**
* Classes that incorporate this feature include a structure that can hold success messages.
*
* @param string $endOfLine = '<br>'
*
* @return mixed
*/
public function success(string $endOfLine = '<br>')
{
if( empty($this->error) )
{
if( ! empty($this->success) )
{
if( is_array($this->success) )
{
return implode($endOfLine, $this->success);
}
return $this->success;
}
else
{
return Lang::default('ZN\CoreDefaultLanguage')::select('Success', 'success');
}
}
else
{
return false;
}
}
/**
* Classes that incorporate this feature include a structure that can hold error or success messages.
*
* @return mixed
*/
public function status()
{
if( $success = $this->success() )
{
return $success;
}
return $this->error();
}
}
@@ -0,0 +1,115 @@
<?php namespace ZN\Ability;
/**
* 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]
*/
trait Revolving
{
/**
* Get revolving values
*
* @var array
*/
protected $revolvings;
/**
* Magic call
*
* @param string $method
* @param array $param
*
* @return $this
*/
public function __call($method, $param)
{
# It opens the way for you to use multiple magic call methods.
if( defined('static::call') )
{
if( $return = $this->{static::call}($method, $param) )
{
return $return;
}
}
$this->$method = (count($param ?? []) > 1) ? $param : ($param[0] ?? NULL);
$this->revolvings[$method] = $this->$method;
return $this;
}
/**
* Magic call static
*
* @param string $method
* @param array $param
*
* @return self
*/
public static function __callStatic($method, $param)
{
return (new self)->__call($method, $param);
}
/**
* Default variables
*
* @param string $type = 'all'
* @param bool $self = false
*
* @return void
*/
protected function defaultVariables($type = 'all', $self = false)
{
if( $type === NULL )
{
return;
}
else if( is_array($type) )
{
foreach( $type as $key )
{
$this->$key = ($self === false ? NULL : $var);
}
}
else
{
# Gets class variables.
$vars = $this->getClassVarsByType($type);
# MDefaults all class properties null.
foreach( $vars as $key => $var )
{
$this->$key = ($self === false ? NULL : $var);
}
}
}
/**
* Protected get class vars
*/
protected function getClassVarsByType($type)
{
return $type === 'all' ? get_class_vars(get_called_class()) : $this->revolvings;
}
/**
* Default revolving variables
*
* @param void
*
* @return void
*/
protected function defaultRevolvingVariables($type = NULL)
{
# It only converts the properties that this property creates to a null value.
$this->defaultVariables($type);
}
}
@@ -0,0 +1,53 @@
<?php namespace ZN\Ability;
/**
* 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]
*/
trait Serialization
{
/**
* Magic call
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public function __call($method, $parameters)
{
# Gets lower method name.
$lowerMethodName = strtolower($method);
# Gets serialization class name.
$class = self::serialization['class'];
# Gets process type.
# If operation type data is selected, operation is continued on the value sent as parameter.
# Otherwise, the operation continues on the last value returned from the parameter being processed.
$process = (self::serialization['process'] ?? 'serial') === 'serial' ? 'data' : 'return';
# The name of the first method that holds the data to be processed.
if( $lowerMethodName === self::serialization['start'] )
{
$this->data = $parameters[0];
}
# The name of the final method to complete the process flow.
elseif( $lowerMethodName === self::serialization['end'] )
{
return $this->$process;
}
# Otherwise, the invoked other class methods are executed.
else
{
$this->$process = $class::$method($this->data, ...$parameters);
}
return $this;
}
}
@@ -0,0 +1,39 @@
<?php namespace ZN\Ability;
/**
* 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]
*/
trait Singleton
{
/**
* singleton
*
* @var self
*
* @return self
*/
protected static $singleton = NULL;
/**
* singleton
*
* @param void
*
* @return self
*/
protected static function singleton()
{
if( ! self::$singleton instanceof self )
{
self::$singleton = new self;
}
return self::$singleton;
}
}
@@ -0,0 +1,51 @@
<?php namespace ZN\Ability;
/**
* 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\Lang;
use ZN\Classes;
trait Speech
{
/**
* Magic call static
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public static function __callStatic($method, $parameters)
{
$config = self::getOnlyClassName();
array_unshift($parameters, $method);
return Lang::default('ZN\CoreDefaultLanguage')::select($config, ...$parameters);
}
/**
* Get all config
*
* @return array
*/
public static function all() : array
{
return Lang::default('ZN\CoreDefaultLanguage')::select(self::getOnlyClassName());
}
/**
* Protected get only class name
*/
protected static function getOnlyClassName()
{
return Classes::onlyName(__CLASS__);
}
}