diff --git a/public_html/media/js/post-view.js b/public_html/media/js/post-view.js
index 66bedcaa..f8eeaa81 100644
--- a/public_html/media/js/post-view.js
+++ b/public_html/media/js/post-view.js
@@ -14,7 +14,7 @@ $(function()
var formDom = $('form.edit-post');
if (formDom.find('.tagit').length == 0)
{
- attachTagIt($('.tags input'));
+ attachTagIt($('input[name=tags]'));
aDom.removeClass('inactive');
formDom.find('input[type=text]:visible:eq(0)').focus();
diff --git a/src/Controllers/TagController.php b/src/Controllers/TagController.php
index eff9672e..4c819bf0 100644
--- a/src/Controllers/TagController.php
+++ b/src/Controllers/TagController.php
@@ -85,8 +85,8 @@ class TagController extends AbstractController
Api::run(
new MergeTagsJob(),
[
- JobArgs::ARG_SOURCE_TAG_NAME => InputHelper::get('source-tag'),
- JobArgs::ARG_TARGET_TAG_NAME => InputHelper::get('target-tag'),
+ JobArgs::ARG_SOURCE_TAG_NAME => trim(InputHelper::get('source-tag')),
+ JobArgs::ARG_TARGET_TAG_NAME => trim(InputHelper::get('target-tag')),
]);
Messenger::success('Tags merged successfully.');
@@ -111,8 +111,8 @@ class TagController extends AbstractController
Api::run(
new RenameTagsJob(),
[
- JobArgs::ARG_SOURCE_TAG_NAME => InputHelper::get('source-tag'),
- JobArgs::ARG_TARGET_TAG_NAME => InputHelper::get('target-tag'),
+ JobArgs::ARG_SOURCE_TAG_NAME => trim(InputHelper::get('source-tag')),
+ JobArgs::ARG_TARGET_TAG_NAME => trim(InputHelper::get('target-tag')),
]);
Messenger::success('Tag renamed successfully.');
diff --git a/src/View.php b/src/View.php
index 23c51dc0..c7c109b1 100644
--- a/src/View.php
+++ b/src/View.php
@@ -12,10 +12,10 @@ class View extends \Chibi\View
$view->render();
}
- protected function renderExternal($viewName)
+ protected function renderExternal($viewName, $context = null)
{
$view = new View($viewName);
- $view->context = $this->context;
+ $view->context = $context !== null ? $context : $this->context;
$view->assets = $this->assets;
$view->render();
}
diff --git a/src/Views/auth-login.phtml b/src/Views/auth-login.phtml
index 880ee1d8..fa3d3a0c 100644
--- a/src/Views/auth-login.phtml
+++ b/src/Views/auth-login.phtml
@@ -14,15 +14,17 @@ $this->assets->addStylesheet('auth.css');
click here to create a new one.
-
diff --git a/src/Views/input/input-basic.phtml b/src/Views/input/input-basic.phtml
new file mode 100644
index 00000000..83e86b64
--- /dev/null
+++ b/src/Views/input/input-basic.phtml
@@ -0,0 +1,36 @@
+context->type;
+$name = $this->context->name;
+$label = isset($this->context->label) ? $this->context->label . ':' : '';
+$value = isset($this->context->value) ? $this->context->value : '';
+$placeholder = isset($this->context->placeholder) ? $this->context->placeholder : '';
+$additionalInfo = isset($this->context->additionalInfo) ? $this->context->additionalInfo : '';
+$inputClass = isset($this->context->inputClass) ? $this->context->inputClass : '';
+$noAutocomplete = isset($this->context->noAutocomplete) ? true : false;
+?>
+
+
+
diff --git a/src/Views/input/input-checkboxes.phtml b/src/Views/input/input-checkboxes.phtml
new file mode 100644
index 00000000..32a636c2
--- /dev/null
+++ b/src/Views/input/input-checkboxes.phtml
@@ -0,0 +1,38 @@
+context->label) ? $this->context->label . ':' : '';
+$optionValuesDisabled = $this->context->optionValuesDisabled;
+$optionValuesEnabled = $this->context->optionValuesEnabled;
+$optionLabels = $this->context->optionLabels;
+$optionNames = $this->context->optionNames;
+$optionStates = $this->context->optionStates;
+$keys = array_keys($optionNames);
+?>
+
+
diff --git a/src/Views/input/input-file.phtml b/src/Views/input/input-file.phtml
new file mode 100644
index 00000000..eecf8d07
--- /dev/null
+++ b/src/Views/input/input-file.phtml
@@ -0,0 +1,3 @@
+context->type = 'file';
+$this->renderExternal('input-basic', $this->context);
diff --git a/src/Views/input/input-hidden.phtml b/src/Views/input/input-hidden.phtml
new file mode 100644
index 00000000..68f7a419
--- /dev/null
+++ b/src/Views/input/input-hidden.phtml
@@ -0,0 +1,6 @@
+context->name;
+$value = $this->context->value;
+?>
+
+
diff --git a/src/Views/input/input-password.phtml b/src/Views/input/input-password.phtml
new file mode 100644
index 00000000..bf1a98a7
--- /dev/null
+++ b/src/Views/input/input-password.phtml
@@ -0,0 +1,3 @@
+context->type = 'password';
+$this->renderExternal('input-basic', $this->context);
diff --git a/src/Views/input/input-radioboxes.phtml b/src/Views/input/input-radioboxes.phtml
new file mode 100644
index 00000000..94538b8b
--- /dev/null
+++ b/src/Views/input/input-radioboxes.phtml
@@ -0,0 +1,33 @@
+context->name;
+$label = isset($this->context->label) ? $this->context->label . ':' : '';
+$optionValues = $this->context->optionValues;
+$optionLabels = $this->context->optionLabels;
+$activeOptionValue = $this->context->activeOptionValue;
+$keys = array_keys($optionValues);
+?>
+
+
diff --git a/src/Views/input/input-select.phtml b/src/Views/input/input-select.phtml
new file mode 100644
index 00000000..e349e8e1
--- /dev/null
+++ b/src/Views/input/input-select.phtml
@@ -0,0 +1,28 @@
+context->name;
+$label = isset($this->context->label) ? $this->context->label . ':' : '';
+$optionValues = $this->context->optionValues;
+$optionLabels = $this->context->optionLabels;
+$activeOptionValue = isset($this->context->activeOptionValue) ? $this->context->activeOptionValue : null;
+$keys = array_keys($optionValues);
+?>
+
+
diff --git a/src/Views/input/input-text.phtml b/src/Views/input/input-text.phtml
new file mode 100644
index 00000000..dac36792
--- /dev/null
+++ b/src/Views/input/input-text.phtml
@@ -0,0 +1,3 @@
+context->type = 'text';
+$this->renderExternal('input-basic', $this->context);
diff --git a/src/Views/post/post-edit.phtml b/src/Views/post/post-edit.phtml
index f23753ee..1a88f499 100644
--- a/src/Views/post/post-edit.phtml
+++ b/src/Views/post/post-edit.phtml
@@ -12,112 +12,94 @@
id="edit-token"
value="= htmlspecialchars($this->context->transport->post->getEditToken()) ?>"/>
- context->transport->post->getUploader())))): ?>
+ context->transport->post->getUploader()))))
+ {
+ $safety = PostSafety::getAll();
-
-
+ $context = new StdClass;
+ $context->label = 'Safety';
+ $context->name = 'safety';
+ $context->optionValues = array_map(function($s) { return $s->toInteger(); }, $safety);
+ $context->optionLabels = array_map(function($s) { return ucfirst($s->toDisplayString()); }, $safety);
+ $context->activeOptionValue = $this->context->transport->post->getSafety()->toInteger();
+ $this->renderExternal('input-radioboxes', $context);
+ }
- context->transport->post->getUploader())))): ?>
+ if (Access::check(new Privilege(
+ Privilege::EditPostTags,
+ Access::getIdentity($this->context->transport->post->getUploader()))))
+ {
+ $context = new StdClass;
+ $context->label = 'Tags';
+ $context->name = 'tags';
+ $context->placeholder = 'Enter some tags…';
+ $context->value = join(',', array_map(
+ function($tag)
+ {
+ return htmlspecialchars($tag->getName());
+ },
+ $this->context->transport->post->getTags()));
+ $this->renderExternal('input-text', $context);
+ }
-
-
+ if (Access::check(new Privilege(
+ Privilege::EditPostSource,
+ Access::getIdentity($this->context->transport->post->getUploader()))))
+ {
+ $context = new StdClass;
+ $context->label = 'Source';
+ $context->name = 'source';
+ $context->value = htmlspecialchars($this->context->transport->post->getSource());
+ $this->renderExternal('input-text', $context);
+ }
- context->transport->post->getUploader())))): ?>
+ if (Access::check(new Privilege(
+ Privilege::EditPostRelations,
+ Access::getIdentity($this->context->transport->post->getUploader()))))
+ {
+ $context = new StdClass;
+ $context->label = 'Relations';
+ $context->name = 'relations';
+ $context->placeholder = 'id1,id2,…';
+ $context->value = join(',', array_map(
+ function($post)
+ {
+ return $post->getId();
+ },
+ $this->context->transport->post->getRelations()));
+ $this->renderExternal('input-text', $context);
+ }
-
-
+ if (Access::check(new Privilege(
+ Privilege::EditPostContent,
+ Access::getIdentity($this->context->transport->post->getUploader()))))
+ {
+ $context = new StdClass;
+ $context->label = 'File';
+ $context->name = 'url';
+ $context->placeholder = 'Some URL…';
+ $this->renderExternal('input-text', $context);
- context->transport->post->getUploader())))): ?>
+ $context = new StdClass;
+ $context->name = 'file';
+ $this->renderExternal('input-file', $context);
+ }
-
-
-
- context->transport->post->getUploader())))): ?>
-
-
-
-
-
-
- context->transport->post->getUploader())))): ?>
-
-
-
+ if (Access::check(new Privilege(
+ Privilege::EditPostThumb,
+ Access::getIdentity($this->context->transport->post->getUploader()))))
+ {
+ $context = new StdClass;
+ $context->name = 'thumb';
+ $context->label = 'Thumb';
+ if ($this->context->transport->post->hasCustomThumb())
+ $context->additionalInfo = '(Currently using custom thumb)';
+ $this->renderExternal('input-file', $context);
+ }
+ ?>