Finished attributes management
This commit is contained in:
@@ -369,6 +369,9 @@ final class TheliaEvents
|
||||
const ATTRIBUTE_DELETE = "action.deleteAttribute";
|
||||
const ATTRIBUTE_UPDATE_POSITION = "action.updateAttributePosition";
|
||||
|
||||
const ATTRIBUTE_REMOVE_FROM_ALL_TEMPLATES = "action.addAttributeToAllTemplate";
|
||||
const ATTRIBUTE_ADD_TO_ALL_TEMPLATES = "action.removeAttributeFromAllTemplate";
|
||||
|
||||
const BEFORE_CREATEATTRIBUTE = "action.before_createAttribute";
|
||||
const AFTER_CREATEATTRIBUTE = "action.after_createAttribute";
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class AttributeAvailability extends BaseI18nLoop
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse'))
|
||||
new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse', 'manual', 'manual_reverse'))
|
||||
),
|
||||
'manual'
|
||||
)
|
||||
@@ -100,6 +100,12 @@ class AttributeAvailability extends BaseI18nLoop
|
||||
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case 'id':
|
||||
$search->orderById(Criteria::ASC);
|
||||
break;
|
||||
case 'id_reverse':
|
||||
$search->orderById(Criteria::DESC);
|
||||
break;
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
|
||||
@@ -106,6 +106,9 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
// The column label
|
||||
$label = $this->getParam($params, 'label');
|
||||
|
||||
// The request parameter
|
||||
$request_parameter_name = $this->getParam($params, 'request_parameter_name', 'order');
|
||||
|
||||
if ($current_order == $order) {
|
||||
$icon = 'up';
|
||||
$order_change = $reverse_order;
|
||||
@@ -121,7 +124,7 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
else
|
||||
$output = '';
|
||||
|
||||
return sprintf('%s<a href="%s">%s</a>', $output, URL::getInstance()->absoluteUrl($path, array('order' => $order_change)), $label);
|
||||
return sprintf('%s<a href="%s">%s</a>', $output, URL::getInstance()->absoluteUrl($path, array($request_parameter_name => $order_change)), $label);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,6 +112,37 @@ class Form extends AbstractSmartyPlugin
|
||||
}
|
||||
}
|
||||
|
||||
protected function assignFieldValues($template, $fieldName, $fieldValue, $fieldVars)
|
||||
{
|
||||
$template->assign("name", $fieldName);
|
||||
|
||||
$template->assign("value", $fieldValue);
|
||||
|
||||
// If Checkbox input type
|
||||
if ($fieldVars['checked'] !== null) {
|
||||
$this->renderFormFieldCheckBox($template, $formFieldView['checked']);
|
||||
}
|
||||
|
||||
$template->assign("label", $fieldVars["label"]);
|
||||
$template->assign("label_attr", $fieldVars["label_attr"]);
|
||||
|
||||
$errors = $fieldVars["errors"];
|
||||
|
||||
$template->assign("error", empty($errors) ? false : true);
|
||||
|
||||
if (! empty($errors)) {
|
||||
$this->assignFieldErrorVars($template, $errors);
|
||||
}
|
||||
|
||||
$attr = array();
|
||||
|
||||
foreach ($fieldVars["attr"] as $key => $value) {
|
||||
$attr[] = sprintf('%s="%s"', $key, $value);
|
||||
}
|
||||
|
||||
$template->assign("attr", implode(" ", $attr));
|
||||
}
|
||||
|
||||
public function renderFormField($params, $content, \Smarty_Internal_Template $template, &$repeat)
|
||||
{
|
||||
if ($repeat) {
|
||||
@@ -120,32 +151,29 @@ class Form extends AbstractSmartyPlugin
|
||||
|
||||
$template->assign("options", $formFieldView->vars);
|
||||
|
||||
$template->assign("name", $formFieldView->vars["full_name"]);
|
||||
$template->assign("value", $formFieldView->vars["value"]);
|
||||
$value = $formFieldView->vars["value"];
|
||||
/* FIXME: doesnt work. We got "This form should not contain extra fields." error.
|
||||
// We have a collection
|
||||
if (is_array($value)) {
|
||||
|
||||
// If Checkbox input type
|
||||
if ($formFieldView->vars['checked'] !== null) {
|
||||
$this->renderFormFieldCheckBox($template, $formFieldView);
|
||||
$key = $this->getParam($params, 'value_key');
|
||||
|
||||
if ($key != null) {
|
||||
|
||||
if (isset($value[$key])) {
|
||||
|
||||
$name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key);
|
||||
$val = $value[$key];
|
||||
|
||||
$this->assignFieldValues($template, $name, $val, $formFieldView->vars);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign("label", $formFieldView->vars["label"]);
|
||||
$template->assign("label_attr", $formFieldView->vars["label_attr"]);
|
||||
|
||||
$errors = $formFieldView->vars["errors"];
|
||||
|
||||
$template->assign("error", empty($errors) ? false : true);
|
||||
|
||||
if (! empty($errors)) {
|
||||
$this->assignFieldErrorVars($template, $errors);
|
||||
else {
|
||||
$this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVars["value"], $formFieldView->vars);
|
||||
}
|
||||
|
||||
$attr = array();
|
||||
|
||||
foreach ($formFieldView->vars["attr"] as $key => $value) {
|
||||
$attr[] = sprintf('%s="%s"', $key, $value);
|
||||
}
|
||||
|
||||
$template->assign("attr", implode(" ", $attr));
|
||||
*/
|
||||
$this->assignFieldValues($template, $formFieldView->vars["full_name"], $formFieldView->vars["value"], $formFieldView->vars);
|
||||
|
||||
$formFieldView->setRendered();
|
||||
} else {
|
||||
@@ -275,12 +303,12 @@ class Form extends AbstractSmartyPlugin
|
||||
* @param \Smarty_Internal_Template $template
|
||||
* @param $formFieldView
|
||||
*/
|
||||
public function renderFormFieldCheckBox(\Smarty_Internal_Template $template, $formFieldView)
|
||||
public function renderFormFieldCheckBox(\Smarty_Internal_Template $template, $isChecked)
|
||||
{
|
||||
$template->assign("value", 0);
|
||||
if ($formFieldView->vars['checked']) {
|
||||
if ($isChecked) {
|
||||
$template->assign("value", 1);
|
||||
}
|
||||
$template->assign("value", $formFieldView->vars['checked']);
|
||||
$template->assign("value", $isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
$url = URL::getInstance()->absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target')));
|
||||
|
||||
if ($target != null) $url .= '#'.$target;
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user