+@endsection
+
+@section('scripts')
+ {scripts}
@endsection
\ No newline at end of file
diff --git a/src/Yuga/Models/Console/temps/scaffold/delete.temp b/src/Yuga/Models/Console/temps/scaffold/delete.temp
new file mode 100644
index 0000000..8feb0b8
--- /dev/null
+++ b/src/Yuga/Models/Console/temps/scaffold/delete.temp
@@ -0,0 +1,20 @@
+@extends('layouts.app')
+
+@section('content')
+
Delete
+
+
Are you sure you want to delete this?
+
+
{title}
+
+
+ {form}
+
+
+
+
+@endsection
\ No newline at end of file
diff --git a/src/Yuga/Models/Console/temps/scaffold/details.temp b/src/Yuga/Models/Console/temps/scaffold/details.temp
index 85bdf70..097e078 100644
--- a/src/Yuga/Models/Console/temps/scaffold/details.temp
+++ b/src/Yuga/Models/Console/temps/scaffold/details.temp
@@ -6,9 +6,9 @@
{title}
-
+
{form}
-
+
Edit |
diff --git a/src/Yuga/Route/Exceptions/NotFoundHttpControllerException.php b/src/Yuga/Route/Exceptions/NotFoundHttpControllerException.php
new file mode 100644
index 0000000..b6825c2
--- /dev/null
+++ b/src/Yuga/Route/Exceptions/NotFoundHttpControllerException.php
@@ -0,0 +1,7 @@
+handleException(new NotFoundHttpException($message, 404));
+ $this->handleException(new NotFoundHttpMethodException($message, 404));
}
} else {
$message = sprintf('Controller: "%s" not found', $controller);
- $this->handleException(new NotFoundHttpException($message, 404));
+ $this->handleException(new NotFoundHttpControllerException($message, 404));
}
}
diff --git a/src/Yuga/Route/Router/Route.php b/src/Yuga/Route/Router/Route.php
index b8e8e37..fad1174 100755
--- a/src/Yuga/Route/Router/Route.php
+++ b/src/Yuga/Route/Router/Route.php
@@ -13,7 +13,9 @@
use Yuga\Http\Middleware\IMiddleware;
use Yuga\Route\Exceptions\HttpException;
use Yuga\Route\Exceptions\NotFoundHttpException;
+use Yuga\Route\Exceptions\NotFoundHttpMethodException;
use Yuga\Http\Middleware\MiddleWare as RouteMiddleware;
+use Yuga\Route\Exceptions\NotFoundHttpControllerException;
use Yuga\Database\Elegant\Exceptions\ModelNotFoundException;
abstract class Route implements IRoute
@@ -62,13 +64,19 @@ abstract class Route implements IRoute
protected function loadClass($name)
{
-
- // if (is_string($name)) {
- if (class_exists($name) === false) {
- throw new NotFoundHttpException(sprintf('Class "%s" does not exist', $name), 404);
+ $exception = NotFoundHttpException::class;
+ if (env('DEBUG_MODE_SETTINGS', '{"controller_missing": true, "method_missing": true}') != null) {
+ $debugSettings = json_decode(env('DEBUG_MODE_SETTINGS', '{"controller_missing": true, "method_missing": true}'), true);
+ if (isset($debugSettings['controller_missing'])) {
+ if ($debugSettings['controller_missing'] === true) {
+ $exception = NotFoundHttpControllerException::class;
+ }
}
- return Application::getInstance()->resolve($name);
-
+ }
+ if (class_exists($name) === false) {
+ throw new $exception(sprintf('Class "%s" does not exist', $name), 404);
+ }
+ return Application::getInstance()->resolve($name);
}
protected function instantiated($callback, $request = null)
@@ -212,7 +220,17 @@ public function renderRoute(Request $request)
if (method_exists($class, $method) === false) {
- throw new NotFoundHttpException(sprintf('Method "%s" does not exist in class "%s"', $method, $className), 404);
+ $exception = NotFoundHttpException::class;
+ if (env('DEBUG_MODE_SETTINGS', '{"controller_missing": true, "method_missing": true}') != null) {
+ $debugSettings = json_decode(env('DEBUG_MODE_SETTINGS', '{"controller_missing": true, "method_missing": true}'), true);
+
+ if (isset($debugSettings['method_missing'])) {
+ if ($debugSettings['method_missing'] === true) {
+ $exception = NotFoundHttpMethodException::class;
+ }
+ }
+ }
+ throw new $exception(sprintf('Method "%s" does not exist in class "%s"', $method, $className), 404);
}
$parameters = $this->getParameters();
diff --git a/src/Yuga/Scaffold/Scaffold.php b/src/Yuga/Scaffold/Scaffold.php
index 126d1a8..f291fd1 100644
--- a/src/Yuga/Scaffold/Scaffold.php
+++ b/src/Yuga/Scaffold/Scaffold.php
@@ -51,6 +51,7 @@ class Scaffold extends Types
self::TYPE_MULTILINESTRING => 'string',
self::TYPE_MULTIPOLYGON => 'string',
self::TYPE_GEOMETRYCOLLECTION => 'string',
+ self::TYPE_EDITOR => 'longtext',
];
public static function getMethod($type)
diff --git a/src/Yuga/Scaffold/Types.php b/src/Yuga/Scaffold/Types.php
index c850720..7cd99ae 100644
--- a/src/Yuga/Scaffold/Types.php
+++ b/src/Yuga/Scaffold/Types.php
@@ -50,6 +50,7 @@ class Types
const TYPE_HIDDEN = 'HIDDEN';
const TYPE_FILE = 'FILE';
const TYPE_RANGE = 'RANGE';
+ const TYPE_EDITOR = 'EDITOR';
public static $INPUT_TYPES = [
self::TYPE_EMAIL => 'email',
@@ -98,5 +99,6 @@ class Types
self::TYPE_MULTILINESTRING => 'text',
self::TYPE_MULTIPOLYGON => 'text',
self::TYPE_GEOMETRYCOLLECTION => 'text',
+ self::TYPE_EDITOR => 'editor',
];
}
\ No newline at end of file
diff --git a/src/Yuga/Session/Session.php b/src/Yuga/Session/Session.php
index 599ebc1..8a06595 100755
--- a/src/Yuga/Session/Session.php
+++ b/src/Yuga/Session/Session.php
@@ -86,6 +86,11 @@ public static function exists($name)
return (isset($_SESSION[$name])) ? true : false;
}
+ public static function has($name)
+ {
+ return self::exists($name);
+ }
+
public static function delete($name)
{
if (self::exists($name)) {
diff --git a/src/Yuga/Views/Widgets/Html/Html.php b/src/Yuga/Views/Widgets/Html/Html.php
index 4bb3f2e..fc8a98b 100755
--- a/src/Yuga/Views/Widgets/Html/Html.php
+++ b/src/Yuga/Views/Widgets/Html/Html.php
@@ -1,4 +1,5 @@
tag = $tag;
$this->closingType = static::CLOSE_TYPE_TAG;
+
+ if (!static::$instance) {
+ static::$instance = $this;
+ }
+ }
+
+ /**
+ * Return a static instance of the Element
+ *
+ * @param null
+ *
+ * @return static
+ */
+ public static function getInstance()
+ {
+ return static::$instance;
}
/**
@@ -76,6 +96,13 @@ public function addAttribute($name, $value = '')
return $this;
}
+ public function addParentAttribute($name, $value = '')
+ {
+ $this->parent->addAttribute($name, $value);
+
+ return $this;
+ }
+
/**
* @param array $attributes
* @return static $this
@@ -89,6 +116,34 @@ public function setAttributes(array $attributes)
return $this;
}
+ /**
+ * @param array $attributes
+ * @return static $this
+ */
+ public function addAttributes(array $attributes)
+ {
+ return $this->setAttributes($attributes);
+ }
+
+ /**
+ * @param array $attributes
+ * @return static $this
+ */
+ public function setParentAttributes(array $attributes)
+ {
+ $this->parent->setAttributes($attributes);
+ return $this;
+ }
+
+ /**
+ * @param array $attributes
+ * @return static $this
+ */
+ public function addParentAttributes(array $attributes)
+ {
+ return $this->setParentAttributes($attributes);
+ }
+
public function attr($name, $value = '', $replace = true)
{
if ($replace === true) {
@@ -153,6 +208,12 @@ protected function render()
$html = $after;
$output .= ($html instanceof static) ? $html->render() : $html;
}
+
+ $parent = $this->getParent();
+
+ if ($parent) {
+ $output = $parent->addInnerHtml($output)->render();
+ }
return $output;
}
@@ -174,6 +235,18 @@ public function addClass($class)
return $this;
}
+ /**
+ * Add class
+ * @param string $class
+ * @return static
+ */
+ public function addParentClass($class)
+ {
+ foreach (explode(" ", $class) as $cls)
+ $this->parent->addAttribute('class', $cls);
+ return $this;
+ }
+
/**
* @return string $closingType
*/
@@ -277,4 +350,43 @@ public function findItemByAttribute($element, $name, $value, $strict = false)
return null;
}
+
+ /**
+ * Set parent html
+ *
+ * @param Html|string|null $parent
+ * @param array $attributes
+ * @return static
+ */
+ public function setParent($parent = null, array $attributes = [])
+ {
+ if ($parent) {
+ if ($parent instanceof static) {
+ $this->parent = $parent->setAttributes($attributes);
+ } else {
+ $this->parent = (new self($parent))->setAttributes($attributes);
+ }
+ }
+
+
+ return $this;
+ }
+
+ /**
+ * Get parent html
+ * @return Html|null
+ */
+ public function getParent()
+ {
+ return $this->parent;
+ }
+
+ /**
+ * Add a parent to an html Element
+ */
+ public function addParent($element)
+ {
+ $this->setParent($element);
+ return $this->parent;
+ }
}
\ No newline at end of file
diff --git a/src/Yuga/Views/Widgets/Html/HtmlButton.php b/src/Yuga/Views/Widgets/Html/HtmlButton.php
index 772fdca..91464c5 100644
--- a/src/Yuga/Views/Widgets/Html/HtmlButton.php
+++ b/src/Yuga/Views/Widgets/Html/HtmlButton.php
@@ -58,12 +58,23 @@ public function addInputAttribute($name)
*/
public function isClicked()
{
- $value = $this->getValue();
+ $value = $this->getValue();
+
+ // echo '
';
+ // print_r($this->getParent());
+ // die();
return $value !== null && $value !== [];
}
public function getValue()
{
- return count($value = $this->getAttribute('value')) > 0 ? $value[0] : null;
+ $value = $this->getAttribute('value');
+ return $value ? $value[0] : null;
+ }
+
+ public function getName()
+ {
+ $name = $this->getAttribute('name');
+ return $name ? $name[0] : null;
}
}
\ No newline at end of file
diff --git a/src/Yuga/Views/Widgets/Html/HtmlForm.php b/src/Yuga/Views/Widgets/Html/HtmlForm.php
index 8672d8b..777a652 100755
--- a/src/Yuga/Views/Widgets/Html/HtmlForm.php
+++ b/src/Yuga/Views/Widgets/Html/HtmlForm.php
@@ -88,6 +88,14 @@ public function input($name, $type = 'text', $value = null, $saveValue = true)
return (new HtmlInput($type, $name, $value))->id($name);
}
+ /**
+ * Add a submit button
+ *
+ * @param string $name
+ * @param string $type
+ * @param string|null $value
+ * @param bool $saveValue
+ */
public function submitButton($name, $type = 'submit', $value = null, $saveValue = true)
{
if ($saveValue && ($value === null && input()->get($name) !== null || request()->getMethod() !== 'get')) {
@@ -144,8 +152,12 @@ public function __toString(): string
$this->fireFormEvents($this);
}
if ($this->make === true) {
- $this->buildForm();
- }
+ // $this->buildOutput();
+ $this->buildFormWithTable();
+ }
+ // else {
+ // $this->buildOutput('div');
+ // }
return parent::__toString();
} catch (\Throwable $e) {
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}: {$e->getLine()}", E_USER_ERROR);
@@ -256,7 +268,24 @@ public function addSelect($name, $label, $data = null, $value = null)
return $control;
}
- protected function buildForm()
+ public function buildOutput($formParent = 'table')
+ {
+ if ($formParent == 'table')
+ return $this->buildFormWithTable();
+ else
+ return $this->buildFormWithParent($formParent);
+ }
+
+ protected function buildFormWithParent(?string $formParent = null)
+ {
+ foreach ($this->controls as $name => $controlObject) {
+ $this->append($controlObject['control']);
+ }
+
+ return $this;
+ }
+
+ protected function buildFormWithTable()
{
$layout = '';
diff --git a/src/Yuga/Views/Widgets/Html/HtmlInput.php b/src/Yuga/Views/Widgets/Html/HtmlInput.php
index d1b8fbe..8f40178 100755
--- a/src/Yuga/Views/Widgets/Html/HtmlInput.php
+++ b/src/Yuga/Views/Widgets/Html/HtmlInput.php
@@ -64,7 +64,7 @@ public function isRequired()
public function multiple()
{
- return $this->addInputAttribute('required');
+ return $this->addInputAttribute('multiple');
}
public function maxLength($maxLength)
diff --git a/src/Yuga/Views/Widgets/Xml/XmlElement.php b/src/Yuga/Views/Widgets/Xml/XmlElement.php
index 87aafec..e991b8d 100755
--- a/src/Yuga/Views/Widgets/Xml/XmlElement.php
+++ b/src/Yuga/Views/Widgets/Xml/XmlElement.php
@@ -61,6 +61,7 @@ public function getParent()
public function setParent($parent)
{
$this->parent = $parent;
+ return $this;
}
public function addChild(IXmlNode $node)