Permalink
Browse files

Merge remote-tracking branch 'origin/9.1'

  • Loading branch information...
michelerota committed Jun 13, 2018
2 parents 93938de + 062c982 commit 731bb30b75b51b8f142949071731fb38cca9c18c
@@ -66,7 +66,7 @@ public function add($attrib, $tab = '')
$tab = $attrib;
}
if ( ! in_array($tab, $this->m_tabsList)) {
if (!in_array($tab, $this->m_tabsList)) {
$this->m_tabsList[] = $tab;
}
$this->m_attribsList[$attrib] = $tab;
@@ -129,10 +129,10 @@ public function store($db, $record, $mode)
global $g_stickyurl;
$key = str_replace('.', '_', 'atktabbedpane_'.$this->getOwnerInstance()->atkNodeUri().'_'.$this->fieldName());
$value = Tools::atkArrayNvl($record, $this->fieldName());
if ( ! is_array($g_stickyurl)) {
if (!is_array($g_stickyurl)) {
$g_stickyurl = [];
}
if ( ! array_key_exists($key, $g_stickyurl)) {
if (!array_key_exists($key, $g_stickyurl)) {
$g_stickyurl[] = $key;
}
$GLOBALS[$key] = $value;
@@ -166,7 +166,7 @@ public function isAttributeSingleOnTab($name)
{
$result = false;
if ( ! $this->hasFlag(self::AF_TABBEDPANE_NO_AUTO_HIDE_LABEL)) {
if (!$this->hasFlag(self::AF_TABBEDPANE_NO_AUTO_HIDE_LABEL)) {
$tab = $this->m_attribsList[$name];
$friquency = array_count_values(array_values($this->m_attribsList));
$result = ($friquency[$tab] == 1);
@@ -198,7 +198,7 @@ public function _addToEditArray($mode, &$arr, &$defaults, &$error, $fieldprefix)
/* hide - nothing to do with tabbedpane, must be render on higher level */
if (($mode == 'edit' && $p_attrib->hasFlag(self::AF_HIDE_EDIT)) || ($mode == 'add' && $p_attrib->hasFlag(self::AF_HIDE_ADD))) {
/* when adding, there's nothing to hide... */
if ($mode == 'edit' || ($mode == 'add' && ! $p_attrib->isEmpty($defaults))) {
if ($mode == 'edit' || ($mode == 'add' && !$p_attrib->isEmpty($defaults))) {
$arr['hide'][] = $p_attrib->hide($defaults, $fieldprefix, $mode);
}
} /* edit */ else {
@@ -230,6 +230,50 @@ public function _addToEditArray($mode, &$arr, &$defaults, &$error, $fieldprefix)
return $fields;
}
public function _addToViewArray($mode, &$arr, &$defaults, &$error)
{
$node = $this->m_ownerInstance;
$fields = [];
//collecting output from attributes
foreach ($this->m_attribsList as $name => $tab) {
$p_attrib = $node->getAttribute($name);
if (is_object($p_attrib)) {
/* hide - nothing to do with tabbedpane, must be render on higher level */
if ($mode == 'view' && $p_attrib->hasFlag(self::AF_HIDE_VIEW)) {
$arr['hide'][] = $p_attrib->hide($defaults, '', $mode);
} /* view */ else {
$entry = array(
'name' => $p_attrib->m_name,
'obligatory' => $p_attrib->hasFlag(self::AF_OBLIGATORY),
'attribute' => $p_attrib);
$entry['id'] = $p_attrib->getHtmlId('');
/* label? */
$entry['label'] = $p_attrib->getLabel($defaults, $mode);
// on which tab? - from tabbedpane properties
$entry['tabs'] = $tab;
//on which sections?
$entry['sections'] = $p_attrib->getSections();
/* the actual edit contents */
$entry['html'] = $p_attrib->getView($mode, $defaults);
$arr['fields'][] = $entry;
$fields['fields'][] = $entry;
}
} else {
Tools::atkerror("Attribute $name not found!");
}
}
/* check for errors */
$fields['error'] = $defaults['atkerror'];
return $fields;
}
public function edit($record, $fieldprefix, $mode)
{
$node = $this->m_ownerInstance;
@@ -279,9 +323,9 @@ public function edit($record, $fieldprefix, $mode)
}
/* does the field have a label? */
if ((isset($field['label']) && $field['label'] !== 'AF_NO_LABEL') && ! $this->isAttributeSingleOnTab(
if ((isset($field['label']) && $field['label'] !== 'AF_NO_LABEL') && !$this->isAttributeSingleOnTab(
$field['name']
) || ! isset($field['label'])) {
) || !isset($field['label'])) {
if ($field['label'] == '') {
$tplfield['label'] = '';
} else {
@@ -330,74 +374,105 @@ public function edit($record, $fieldprefix, $mode)
return $content;
}
/**
* Display a tabbed pane with attributes.
*
* @param array $record Array with fields
* @param string $mode The mode
*
* @return string html code
*/
public function display($record, $mode)
{
// get active tab
$active_tab = $this->getDefaultTab();
$node = $this->m_ownerInstance;
$arr = ['hide' => []];
//get data
$data = $this->_addToViewArray($mode, $arr, $record, $record['atkerror']);
// Handle fields
// load images
$reqimg = "<span class='required'></span>";
/* display the edit fields */
$fields = [];
$tab = '';
$tab = $this->getDefaultTab();
$node = $this->m_ownerInstance;
$ui = $node->getUi();
for ($i = 0, $_i = Tools::count($data['fields']); $i < $_i; ++$i) {
$field = &$data['fields'][$i];
$tplfield = [];
// For all attributes we use the display() function to display the
// attributes current value. This may be overridden by supplying
// an <attributename>_display function in the derived classes.
foreach ($this->m_attribsList as $name => $tab) {
$p_attrib = $node->getAttribute($name);
if (is_object($p_attrib)) {
$tplfield = [];
if ( ! $p_attrib->hasFlag(self::AF_HIDE_VIEW)) {
$fieldtab = $this->m_attribsList[$name];
$tplfield['class'] = "tabbedPaneAttr tabbedPaneTab{$fieldtab}";
$tplfield['rowid'] = 'tabbedPaneAttr_'.Tools::getUniqueId('anonymousattribrows'); // The id of the containing row
$tplfield['tab'] = $tplfield['class']; // for backwards compatibility
$tplfield['initial_on_tab'] = ($fieldtab == $active_tab);
// An <attributename>_display function may be provided in a derived
// class to display an attribute. If it exists we will use that method
// else we will just use the attribute's display method.
$funcname = $p_attrib->m_name.'_display';
if (method_exists($node, $funcname)) {
$editsrc = $node->$funcname($record, 'view');
} else {
$editsrc = $p_attrib->display($record, 'view');
}
$tplfield['tab'] = $field['tabs'];
$tplfield['full'] = $editsrc;
$tplfield['widget'] = $editsrc; // in view mode, widget and full are equal
// The Label of the attribute (can be suppressed with self::AF_NOLABEL or self::AF_BLANKLABEL)
// For each attribute, a txt_<attributename> must be provided in the language files.
if ( ! $p_attrib->hasFlag(self::AF_NOLABEL) && ! $this->isAttributeSingleOnTab($name)) {
if ($p_attrib->hasFlag(self::AF_BLANKLABEL)) {
$tplfield['label'] = '';
} else {
$tplfield['label'] = $p_attrib->label();
}
} else {
// Make the rest fill up the entire line
$tplfield['initial_on_tab'] = $tplfield['tab'] == $tab;
$tplfield['class'] = "tabbedPaneAttr tabbedPaneTab{$field['tabs']}";
/** @var Attribute $attr */
$attr = $field['attribute'];
// Check if there are attributes initially hidden on this tabbedpane
if ($attr->isInitialHidden()) {
$tplfield['class'] .= ' atkAttrRowHidden';
}
$tplfield['rowid'] = 'tabbedPaneAttr_'.($field['id'] != '' ? $field['id'] : Tools::getUniqueId(
'anonymousattribrows'
)); // The id of the containing row
/* check for separator */
if ($field['html'] == '-' && $i > 0 && $data['fields'][$i - 1]['html'] != '-') {
$tplfield['line'] = '<hr>';
} /* double separator, ignore */ elseif ($field['html'] == '-') {
} /* only full HTML */ elseif (isset($field['line'])) {
$tplfield['line'] = $field['line'];
} /* edit field */ else {
if ($field['attribute']->m_ownerInstance->getNumbering()) {
ViewEditBase::_addNumbering($field, $tplfield, $i);
}
/* does the field have a label? */
if ((isset($field['label']) && $field['label'] !== 'AF_NO_LABEL') && !$this->isAttributeSingleOnTab(
$field['name']
) || !isset($field['label'])) {
if ($field['label'] == '') {
$tplfield['label'] = '';
$tplfield['line'] = $tplfield['full'];
} else {
$tplfield['label'] = $field['label'];
if (isset($field['error']) && $field['error']) {
$tplfield['error'] = $field['error'];
}
}
$fields[] = $tplfield;
} else {
$tplfield['label'] = 'AF_NO_LABEL';
}
} else {
Tools::atkerror("Attribute $name not found!");
/* obligatory indicator */
if ($field['obligatory']) {
$tplfield['obligatory'] = $reqimg;
}
/* html source */
$tplfield['widget'] = $field['html'];
$editsrc = $field['html'];
$tplfield['htmlid'] = $field['id'];
$tplfield['id'] = str_replace('.', '_', $node->atkNodeUri().'_'.$field['id']);
$tplfield['full'] = $editsrc;
}
$fields[] = $tplfield; // make field available in numeric array
$params[$field['name']] = $tplfield; // make field available in associative array
}
$innerform = $ui->render($node->getTemplate('view', $record, $tab), ['fields' => $fields]);
return $this->tabulate('view', $innerform, '', $active_tab);
$ui = $node->getUi();
$result = '';
foreach ($arr['hide'] as $hidden) {
$result .= $hidden;
}
$params['activeTab'] = $tab;
$params['panename'] = $this->m_name;
$params['fields'] = $fields; // add all fields as an numeric array.
$result .= $ui->render('tabbedviewform.tpl', $params);
$content = $this->tabulate($mode, $result, '', $tab);
return $content;
}
/**
View
@@ -11,7 +11,7 @@
class Atk
{
const VERSION = 'v9.1.8-dev';
const VERSION = 'v9.1.9-dev';
public $g_nodes = [];
public $g_nodesClasses = [];
@@ -11,7 +11,7 @@
*
* @author Peter C. Verhage <peter@ibuildings.nl>
*/
class EditCopyHandler extends ActionHandler
class EditcopyHandler extends ActionHandler
{
/**
* The action method.
@@ -201,7 +201,9 @@ public function _getInitHtml()
$params['formstart'] = '<form id="entryform" name="entryform" enctype="multipart/form-data" action="'.$action.'" method="post" class="form-horizontal">';
$params['formstart'] .= $sm->formState();
$params['formstart'] .= '<input type="hidden" name="phase" value="process"/>';
$params['buttons'][] = Tools::atkButton(Tools::atktext('cancel', 'atk'), '', SessionManager::SESSION_BACK);
if ($sm->atkLevel() > 0) {
$params['buttons'][] = Tools::atkButton(Tools::atktext('cancel', 'atk'), '', SessionManager::SESSION_BACK);
}
$params['buttons'][] = '<input class="btn btn-primary" type="submit" value="'.Tools::atktext('export', 'atk').'"/>';
$params['buttons'][] = '<input id="export_save_button" style="display:none;" value="'.Tools::atktext('save_export_selection',
'atk').'" name="save_export" class="btn" type="submit" /> ';
@@ -15,7 +15,7 @@
*
* @author Lineke Kerckhoffs-Willems <lineke@ibuildings.nl>
*/
class MultiSelectHandler extends AdminHandler
class MultiselectHandler extends AdminHandler
{
/**
* The action handler method.
@@ -2,7 +2,7 @@
namespace Sintattica\Atk\Handlers;
class MultiUpdateHandler extends ActionHandler
class MultiupdateHandler extends ActionHandler
{
/**
* The action handler method.
@@ -595,6 +595,8 @@
'tplcompilecheck' => Config::env('TPL_COMPILE_CHECK', 1),
'tplforcecompile' => Config::env('TPL_FORCE_COMPILE', 0),
'smarty_file_perms' => 0775,
/****************** MISCELLANEOUS CONFIGURATION OPTIONS ********************/
/*
@@ -0,0 +1,24 @@
<div id="{$panename}_editform" style="width:100%;">
{if isset($errors) && $errors}
<div class="error">
{$errortitle}
{foreach from=$errors item=error}
<br>
{$error.label}: {$error.message} {if isset($error.tablink)} ({atktext id="error_tab"} {$error.tablink}){/if}
{/foreach}
</div>
{/if}
{foreach from=$fields item=field}
<div {if $field.rowid != ""} id="{$field.rowid}"{/if}{if !$field.initial_on_tab} style="display: none"{/if} class="row form-group {$field.class}">
{if $field.label!=="AF_NO_LABEL"}
<label for="{$field.htmlid}" class="col-sm-3 col-md-2 control-label{if isset($field.error)} errorlabel{/if}">
{if $field.label!=""}
{$field.label} {if isset($field.obligatory)}{$field.obligatory}{/if}
{/if}
</label>
{/if}
<div class="{if $field.label!=="AF_NO_LABEL"}col-sm-9 col-md-10{else}col-md-12{/if}" id="{$field.id}">{$field.full}</div>
</div>
{/foreach}
</div>
View
@@ -0,0 +1,18 @@
<?php
namespace Sintattica\Atk\Ui;
use Sintattica\Atk\Core\Config;
use Smarty as SmartyBase;
class Smarty extends SmartyBase
{
public $_file_perms;
public function __construct()
{
parent::__construct();
$this->_file_perms = Config::getGlobal('smarty_file_perms');
}
}
@@ -4,7 +4,6 @@
use Sintattica\Atk\Core\Tools;
use Sintattica\Atk\Core\Config;
use Smarty;
/**
* Wrapper class for the Smarty template engine.
@@ -15,7 +14,8 @@ class SmartyProvider
/**
* Get the Smarty instance.
*
* @return \Smarty The one and only instance.
* @return Smarty The one and only instance.
* @throws \Exception
*/
public static function getInstance()
{
@@ -33,8 +33,8 @@ public static function getInstance()
$s_smarty->setTemplateDir(Config::getGlobal('template_dir')); // name of directory for templates
$s_smarty->autoload_filters = []; // indicates which filters will be auto-loaded
$s_smarty->setCompileDir($tplcompiledir); // name of directory for compiled templates
$s_smarty->setForceCompile(Config::getGlobal('tplforcecompile')); // force templates to compile every time,
$s_smarty->addPluginsDir(__DIR__.'/plugins');
$s_smarty->setForceCompile(Config::getGlobal('tplforcecompile')); // force templates to compile every time
$s_smarty->addPluginsDir([__DIR__.'/plugins']);
Tools::atkdebug('Instantiated new Smarty');
}
Oops, something went wrong.

0 comments on commit 731bb30

Please sign in to comment.