Example #1
0
 /**
  * Returns an htmlpage displaying all displayable attributes.
  *
  * @param array $record The record to display.
  * @param Node $node The node for which a viewPage is displayed.
  * @param bool $renderbox Render this action in a renderbox or just output the HTML
  *
  * @return string The html page with a reaonly view of relevant fields.
  */
 public function viewPage($record, $node, $renderbox = true)
 {
     $ui = $this->getUi();
     if (is_object($ui)) {
         $params = $node->getDefaultActionParams();
         $tab = $node->getActiveTab();
         $innerform = $this->viewForm($record, 'view');
         $params['activeTab'] = $tab;
         $params['header'] = $this->invoke('viewHeader', $record);
         $params['title'] = $node->actionTitle($this->m_action, $record);
         $params['content'] = $node->tabulate('view', $innerform);
         $params['formstart'] = $this->getFormStart($record);
         $params['buttons'] = $this->getFormButtons($record);
         $params['formend'] = '</form>';
         $output = $ui->renderAction('view', $params);
         if (!$renderbox) {
             return $output;
         }
         $this->getPage()->setTitle(Tools::atktext('app_shorttitle') . ' - ' . $node->actionTitle($this->m_action, $record));
         $vars = array('title' => $node->actionTitle($this->m_action, $record), 'content' => $output);
         $total = $ui->renderBox($vars, $this->m_boxTemplate);
         return $total;
     } else {
         Tools::atkerror('ui object error');
     }
 }
Example #2
0
 /**
  * Get an instance of the columnconfig class.
  *
  * @param Node $node
  * @param string $id
  * @param bool $forceNew force new instance?
  *
  * @return ColumnConfig An instance of the columnconfig class
  */
 public static function getConfig($node, $id = null, $forceNew = false)
 {
     static $s_instances = [];
     $sm = SessionManager::getInstance();
     if ($id == null) {
         $id = $node->atkNodeUri();
     }
     if (!isset($s_instances[$id]) || $forceNew) {
         $cc = new self();
         $s_instances[$id] = $cc;
         $cc->setNode($node);
         $colcfg = $sm != null ? $sm->pageVar('atkcolcfg_' . $id) : null;
         if (!is_array($colcfg) || $forceNew) {
             // create new
             Tools::atkdebug('New colconfig initialising');
             $cc->init();
         } else {
             // inherit old config from session.
             Tools::atkdebug('Resuming colconfig from session');
             $cc->m_colcfg =& $colcfg;
         }
         // See if there are any url params which influence this colcfg.
         $cc->doUrlCommands();
     }
     if ($sm != null) {
         $sm->pageVar('atkcolcfg_' . $id, $s_instances[$id]->m_colcfg);
     }
     return $s_instances[$id];
 }
Example #3
0
 /**
  * Notify the listener of any action on a record.
  *
  * This method is called by the framework for each action called on a
  * node. Depending on the actionfilter passed in the constructor, the
  * call is forwarded to the actionPerformed($action, $record) method.
  *
  * @param string $trigger The trigger being performed
  * @param array $record The record on which the trigger is performed
  * @param string $mode The mode (add/update)
  *
  * @return bool Result of operation.
  */
 public function notify($trigger, &$record, $mode = null)
 {
     if (method_exists($this, $trigger)) {
         Tools::atkdebug('Call listener ' . get_class($this) . " for trigger {$trigger} on " . $this->m_node->atkNodeUri() . ' (' . $this->m_node->primaryKey($record) . ')');
         return $this->{$trigger}($record, $mode);
     } else {
         return true;
     }
 }
Example #4
0
 /**
  * Adds a filter on the instance of the searchnode.
  *
  * @param string $filter The fieldname you want to filter OR a SQL where
  *                       clause expression.
  * @param string $value Required value. (Ommit this parameter if you pass
  *                       an SQL expression for $filter.)
  */
 public function addSearchFilter($filter, $value = '')
 {
     if (!$this->m_searchnodeInstance) {
         $this->createSearchNodeInstance();
     }
     $this->m_searchnodeInstance->addFilter($filter, $value);
 }
Example #5
0
 /**
  * Get the access denied page.
  *
  * @return string the HTML code of the access denied page
  */
 public function _getAccessDeniedPage()
 {
     $ui = $this->m_node->getUi();
     $content = '<br><br>' . Tools::atktext('error_node_action_access_denied', '', $this->m_node->getType()) . '<br><br><br>';
     $blocks = [$ui->renderBox(['title' => Tools::atktext('access_denied'), 'content' => $content])];
     return $ui->render('actionpage.tpl', ['blocks' => $blocks, 'title' => Tools::atktext('access_denied')]);
 }
Example #6
0
 function __construct($nodeUri)
 {
     parent::__construct($nodeUri);
     $this->add(new ManyToOneRelation('user_id', Attribute::AF_PRIMARY, 'auth.users'));
     $this->add(new ManyToOneRelation('group_id', Attribute::AF_PRIMARY, 'auth.groups'));
     $this->setTable('Users_Groups');
 }
Example #7
0
 public function __construct($nodeUri, $flags = 0)
 {
     parent::__construct($nodeUri, $flags);
     $this->setTable('testbed_M2MNode');
     $this->setSecurityAlias($this->getModule() . '.playground');
     $this->add(new Attribute('playground_id', Attribute::AF_PRIMARY));
     $this->add(new Attribute('remotetable_id', Attribute::AF_PRIMARY));
 }
Example #8
0
 function __construct($nodeUri)
 {
     parent::__construct($nodeUri, Node::NF_ADD_LINK | Node::NF_EDITAFTERADD | Node::NF_IMPORT);
     $this->setTable('TestNode');
     $this->add(new Attribute('id', Attribute::AF_AUTOKEY));
     $this->add(new Attribute('name', Attribute::AF_OBLIGATORY));
     $this->add(new TextAttribute('description'));
     $this->setDescriptorTemplate('[name]');
 }
Example #9
0
 public function __construct($nodeUri, $flags = 0)
 {
     parent::__construct($nodeUri, $flags);
     $this->setTable('testbed_O2ONode');
     $this->setSecurityAlias($this->getModule() . '.playground');
     $this->add(new Attribute('id', Attribute::AF_AUTOKEY));
     $this->add(new Attribute('playground_id'));
     $this->add(new Attribute('o2o_name'));
 }
Example #10
0
 /**
  * Gets all the current identifiers and returns them in an array.
  *
  * @return array The identifiers
  */
 public function getIdentifiers()
 {
     $identifiers = [];
     $identifiers[] = $this->m_node->atkNodeUri() . 'cache';
     if ($this->m_node->m_cacheidentifiers) {
         $this->_formatIdentifiers($this->m_node->m_cacheidentifiers, $identifiers);
     }
     $this->_formatIdentifiers($this->m_cacheidentifiers, $identifiers);
     return $identifiers;
 }
Example #11
0
 public function __construct($nodeUri, $flags = 0)
 {
     parent::__construct($nodeUri, $flags);
     $this->setTable('testbed_O2MNode2');
     $this->setSecurityAlias($this->getModule() . '.playground');
     $this->setDescriptorTemplate('[o2mName]');
     $this->add(new Attribute('id', Attribute::AF_AUTOKEY));
     $this->add(new Attribute('playground_id'));
     $this->add(new ListAttribute('o2mName', Attribute::AF_SEARCHABLE, ['test1', 'test']));
 }
Example #12
0
 /**
  * Check if the relation is empty.
  *
  * @param array $record The record to check
  *
  * @return bool true if a destination record is present. False if not.
  */
 public function isEmpty($record)
 {
     if ($this->createDestination() && isset($record[$this->fieldName()][$this->m_destInstance->primaryKeyField()])) {
         return empty($record[$this->fieldName()][$this->m_destInstance->primaryKeyField()]);
     } else {
         if ($this->createDestination() && isset($record[$this->fieldName()])) {
             return empty($record[$this->fieldName()]);
         }
     }
     return true;
     // always empty if error.
 }
Example #13
0
 public function __construct($nodeUri, $flags = 0)
 {
     parent::__construct($nodeUri, $flags | Node::NF_ADD_LINK);
     $this->setTable('testbed_M2ONode');
     $this->setSecurityAlias($this->getModule() . '.playground');
     $this->add(new Attribute('id', Attribute::AF_AUTOKEY));
     $this->add(new Attribute('m2o_name', Attribute::AF_FORCE_LOAD | Attribute::AF_SEARCHABLE));
     $this->add(new NumberAttribute('numeroA', Attribute::AF_TOTAL | Attribute::AF_SEARCHABLE, 2));
     $this->add(new NumberAttribute('numeroB', Attribute::AF_TOTAL | Attribute::AF_SEARCHABLE, 2));
     $this->setDescriptorTemplate('[m2o_name]');
     //  $this->setDescriptorHandler($this);
 }
Example #14
0
 function __construct($nodeUri)
 {
     parent::__construct($nodeUri, Node::NF_ADD_LINK | Node::NF_EDITAFTERADD);
     $this->add(new Attribute('id', A::AF_AUTOKEY));
     $this->add(new Attribute('name', A::AF_OBLIGATORY | A::AF_UNIQUE | A::AF_SEARCHABLE));
     $this->add(new TextAttribute('description'));
     $attr = new ShuttleRelation('users', A::AF_HIDE_LIST | A::AF_HIDE_ADD, 'auth.users_groups', 'auth.users');
     $this->add($attr);
     $attr->setLocalKey('group_id');
     $attr->setRemoteKey('user_id');
     $this->add(new ProfileAttribute('accessrights', A::AF_BLANKLABEL | A::AF_HIDE_ADD));
     $this->setTable('Groups');
     $this->setOrder('name');
     $this->setDescriptorTemplate('[name]');
 }
Example #15
0
 /**
  * Re-render / refresh the attribute with the given name.
  *
  * @param string $name attribute name
  */
 public function refreshAttribute($name)
 {
     if ($this->isInitial()) {
         return;
     }
     $offset = count($this->getNode()->getPage()->getLoadScripts());
     $error = [];
     $editArray = array('fields' => array());
     $this->m_node->getAttribute($name)->addToEditArray($this->getMode(), $editArray, $this->getRecord(), $error, $this->getFieldPrefix());
     $scriptCode = '';
     foreach ($editArray['fields'] as $field) {
         $element = str_replace('.', '_', $this->getNode()->atkNodeUri() . '_' . $field['id']);
         $value = Json::encode(Tools::atk_iconv(Tools::atkGetCharset(), 'UTF-8', $field['html']));
         // Json::encode excepts string in UTF-8
         $scriptCode .= "if (\$('{$element}')) { \$('{$element}').update({$value}); } ";
     }
     $this->getNode()->getPage()->register_loadscript($scriptCode, $offset);
 }
Example #16
0
 function __construct($nodeUri)
 {
     parent::__construct($nodeUri, Node::NF_ADD_LINK);
     $this->setTable('Users');
     $this->add(new Attribute('id', A::AF_AUTOKEY));
     $this->add(new Attribute('firstname', A::AF_FORCE_LOAD | A::AF_OBLIGATORY | A::AF_SEARCHABLE));
     $this->add(new Attribute('lastname', A::AF_FORCE_LOAD | A::AF_OBLIGATORY | A::AF_SEARCHABLE));
     $this->add(new Attribute('username', A::AF_FORCE_LOAD | A::AF_OBLIGATORY | A::AF_SEARCHABLE | A::AF_UNIQUE));
     $pwdFlags = A::AF_OBLIGATORY | A::AF_HIDE_LIST | PasswordAttribute::AF_PASSWORD_NO_VALIDATE;
     $this->add(new PasswordAttribute('passwd', $pwdFlags, true, 0, ['minalphabeticchars' => 6, 'minnumbers' => 2]));
     $this->add(new EmailAttribute('email'));
     $this->add(new BoolAttribute('disabled', A::AF_SEARCHABLE | A::AF_FORCE_LOAD));
     $attr = new ShuttleRelation('groups', A::AF_SEARCHABLE, 'auth.users_groups', 'auth.groups');
     $this->add($attr);
     $attr->setLocalKey('user_id');
     $attr->setRemoteKey('group_id');
     $this->setOrder('[table].lastname, [table].firstname');
     $this->setDescriptorTemplate('[username]');
 }
Example #17
0
 /**
  * Constructor.
  *
  * This function is called when a new atkFileEditor is instantiated.
  *
  * @param string $name The name of the node.
  * @param string $dir The directory that the fileeditor lists. If you
  *                       want to enable addition of new files, make sure
  *                       that the webserver has write access to this dir.
  *                       Only regular files (not subdirs or special files)
  *                       are listed.
  * @param string $filter A regular expression that is used to filter which
  *                       files will be shown. Example: '.txt$' lists only
  *                       txt files in the directory.
  *                       Note: This parameter is also used to validate the
  *                       filename of newly created files. This means, you
  *                       cannot create a new file called test.css if your
  *                       filter param is set to '.tpl$';
  *                       Note 2: Watch out when using $ in your regular
  *                       expression; PHP parses this, so use single quotes
  *                       or escape the dollarsign with \.
  * @param int $flags The node flags. See Node for a list of possible
  *                       flags.
  */
 public function __construct($name, $dir = '', $filter = '', $flags = 0)
 {
     parent::__construct($name, $flags | Node::NF_ADD_LINK);
     $this->m_dir = $dir;
     $this->m_basedir = $dir;
     if ($dir == '') {
         $this->m_dir = './';
     }
     // dir must have a trailing slash.
     if (substr($this->m_dir, -1) != '/') {
         $this->m_dir .= '/';
     }
     $this->m_filefilter = $filter;
     $this->m_showdirs = true;
     $this->add(new Attribute('filename', Attribute::AF_PRIMARY | Attribute::AF_SEARCHABLE));
     $this->add(new TextAttribute('filecontent', 30, Attribute::AF_HIDE_LIST));
     $this->addSecurityMap('dirchange', 'admin');
     $this->setOrder('dummy.filename');
     $this->setTable('dummy');
 }
Example #18
0
 /**
  * Check unique field combinations.
  * The function is called by the validate() method automatically. It is
  * not necessary to call this manually in a validation process.
  * Errors that are found are stored in the $record parameter.
  *
  * @param array $record The record to validate
  */
 public function validateUniqueFieldSets(&$record)
 {
     $db = $this->m_nodeObj->getDb();
     foreach ($this->m_nodeObj->m_uniqueFieldSets as $uniqueFieldSet) {
         $query = $db->createQuery();
         $query->addField('*');
         $query->addTable($this->m_nodeObj->m_table);
         $attribs = [];
         foreach ($uniqueFieldSet as $field) {
             $attrib = $this->m_nodeObj->m_attribList[$field];
             if ($attrib) {
                 $attribs[] = $attrib;
                 if (method_exists($attrib, 'createDestination') && isset($attrib->m_refKey) && is_array($attrib->m_refKey) && count($attrib->m_refKey) > 1) {
                     $attrib->createDestination();
                     foreach ($attrib->m_refKey as $refkey) {
                         $query->addCondition($query->quoteField($refkey) . " = '" . $db->escapeSQL($record[$attrib->fieldName()][$refkey]) . "'");
                     }
                 } else {
                     if (!$attrib->isNotNullInDb() && $attrib->isEmpty($record)) {
                         $query->addCondition($query->quoteField($field) . ' IS NULL');
                     } else {
                         $query->addCondition($query->quoteField($field) . " = '" . $attrib->value2db($record) . "'");
                     }
                 }
             } else {
                 Tools::atkerror("Field {$field} is mentioned in uniquefieldset but does not exist in " . $this->m_nodeObj->atkNodeUri());
             }
         }
         if ($this->m_mode != 'add') {
             $query->addCondition('NOT (' . $this->m_nodeObj->primaryKey($record) . ')');
         }
         if (count($db->getRows($query->buildSelect())) > 0) {
             Tools::atkTriggerError($record, $attribs, 'error_uniquefieldset');
         }
     }
 }
Example #19
0
 /**
  * Get the link fo a tab.
  *
  * @param Node $node The node
  * @param array $error
  *
  * @return string HTML code with link
  */
 public function getTabLink($node, $error)
 {
     if (count($node->getTabs($node->m_action)) < 2) {
         return '';
     }
     return '<a href="javascript:void(0)" onclick="showTab(\'' . $error['tab'] . '\'); return false;">' . $this->getTabLabel($node, $error['tab']) . '</a>';
 }
Example #20
0
 /**
  * Constructor.
  *
  * @param string $type node type (by default the class name)
  * @param int $flags node flags
  *
  * @return DataNode
  */
 public function __construct($type = '', $flags = 0)
 {
     parent::__construct($type, $flags | self::NF_NO_ADD | self::NF_NO_EDIT);
     $this->setTable($this->m_type);
 }
Example #21
0
 /**
  * String representation for this attribute (PHP5 only).
  *
  * @return string attribute name prefixed with node type
  */
 public function __toString()
 {
     return $this->m_ownerInstance->atkNodeUri() . '::' . $this->fieldName();
 }
Example #22
0
 /**
  * This function returns a suitable title text for an action.
  * Example: echo $ui->title("users", "employee", "edit"); might return:
  *          'Edit an existing employee'.
  *
  * @param Node $node the node to get the title from
  * @param string $action the action that we are trying to find a title for
  * @param bool $actiononly wether or not to return a name of the node
  *                           if we couldn't find a specific title
  *
  * @return string the title for the action
  */
 public function nodeTitle($node, $action = null, $actiononly = false)
 {
     if ($node == null) {
         return '';
     }
     $nodetype = $node->m_type;
     $module = $node->m_module;
     if ($action != null) {
         $keys = array('title_' . $module . '_' . $nodetype . '_' . $action, 'title_' . $nodetype . '_' . $action, 'title_' . $action);
         $label = $node->text($keys, null, '', '', true);
     } else {
         $label = '';
     }
     if ($label == '') {
         $actionKeys = array('action_' . $module . '_' . $nodetype . '_' . $action, 'action_' . $nodetype . '_' . $action, 'action_' . $action, $action);
         if ($actiononly) {
             return $node->text($actionKeys);
         } else {
             $keys = array('title_' . $module . '_' . $nodetype, 'title_' . $nodetype, $nodetype);
             $label = $node->text($keys);
             if ($action != null) {
                 $label .= ' - ' . $node->text($actionKeys);
             }
         }
     }
     return $label;
 }
Example #23
0
 /**
  * Get tab label.
  *
  * @param Node $node
  * @param string $tab
  *
  * @return string label
  *
  * @static
  */
 public function getTabLabel($node, $tab)
 {
     $strings = array("tab_{$tab}", $tab);
     return $node->text($strings);
 }
Example #24
0
 function __construct($nodeUri)
 {
     parent::__construct($nodeUri, Node::NF_ADD_LINK);
     $this->setTable('testbed_Playground');
     $this->add(new Attribute('id', A::AF_AUTOKEY));
     /** tab ************************/
     $tab = 'default';
     //test tabbed pane
     $this->add(new Attribute('Attribute'), $tab);
     $this->add(new BoolAttribute('BoolAttribute'), $tab);
     $this->add(new CalculatorAttribute('CalculatorAttribute', 0, '10*5'), $tab);
     $attr = new DateTimeAttribute('theDateAttribute', A::AF_SEARCHABLE);
     $attr->addOnChangeHandler('console.log("theDateTimeAttribute onchange triggered!");');
     $this->add($attr, 'default');
     // $this->add(new MultiSelectAttribute('MultiSelectAttribute', A::AF_SEARCHABLE, ['option1', 'option2', 'option3'],
     //     ['option1val', 'option2val', 'option3val']), $tab);
     $attr = new ListAttribute('theListAttribute', A::AF_SEARCHABLE, ['testo lungo della option_4', 'option_5', 'testo lungo della option_6'], [4, 5, 6]);
     $attr->setWidth('300px');
     $attr->addDependency([$this, 'theListAttributeDependency']);
     $this->add($attr, "tab2");
     $attr = new ListAttribute('theListAttribute2', A::AF_SEARCHABLE, ['testo lungo della option_4', 'option_5', 'testo lungo della option_6'], [4, 5, 6]);
     $attr->setWidth('300px');
     $this->add($attr);
     $attr = new ManyToOneRelation('FM2O', A::AF_LARGE | A::AF_SEARCHABLE, $this->getModule() . '.m2o_node');
     //attr->setWidth('300px');
     //$attr->addDestinationFilter('id = 1');
     // $attr->setAutoSearch(true);
     //$attr->addOnChangeHandler('console.log("onchange triggered!");');
     //$attr->addDependency([$this, 'theListAttributeDependency']);
     $this->add($attr);
     /*
             $attr = new MultiSelectListAttribute('theMultiSelectListAttribute', A::AF_SEARCHABLE,
                 ['testo lungo della option_4', 'option_5', 'testo lungo della option_6'], [4, 5, 6]);
             //$attr->setWidth('300px');
             $this->add($attr);
     
     
             $this->add(new TabbedPane('tabbedpane', 0, ['tab1' => ['Attribute'], 'tab2' => ['BoolAttribute', 'CalculatorAttribute', 'theListAttribute2']]));
     */
     return true;
     // ListAttribute::AF_LIST_OBLIGATORY_NULL_ITEM |
     $attr = new ListAttribute('theListAttribute2', A::AF_OBLIGATORY | A::AF_SEARCHABLE, ['testo lungo della option_4', 'option_5', 'testo lungo della option_6'], [4, 5, 6]);
     $this->add($attr, $tab);
     //$this->add(new PasswordAttribute('PasswordAttribute', PasswordAttribute::AF_PASSWORD_NO_VALIDATE, true, ['minnumbers' => 2, 'minalphabeticchars' => 6]), $tab);
     return true;
     $this->add(new OneToManyRelation('the1OneToManyRelation', A::AF_SEARCHABLE, $this->getModule() . '.o2m_node', 'playground_id'), $tab);
     $this->add(new OneToManyRelation('the2OneToManyRelation', A::AF_SEARCHABLE, $this->getModule() . '.o2m_node2', 'playground_id'), $tab);
     for ($i = 0; $i < 10; $i++) {
         $this->add(new ExpressionAttribute('ExpressionAttribute' . $i, A::AF_SEARCHABLE, 'SELECT 5', 'number'), $tab);
     }
     return;
     //$tab = 'tab_2';
     $attr = new ListAttribute('theListAttribute', ListAttribute::AF_LIST_OBLIGATORY_NULL_ITEM | A::AF_OBLIGATORY | A::AF_SEARCHABLE, ['option_1', 'option_2', 'option_3'], [1, 2, 3]);
     $attr->addDependency([$this, 'theListAttributeDependency']);
     $this->add($attr, $tab);
     return;
     $attr = new DateTimeAttribute('theDateTimeAttribute', A::AF_SEARCHABLE);
     //$attr->setEmptyValue(-1);
     $attr->setAutoSearch(true);
     $attr->addOnChangeHandler("console.log(el);");
     $this->add($attr, $tab);
     $this->add(new Attribute('Attribute'), $tab);
     $this->add(new BoolAttribute('BoolAttribute'), $tab);
     $this->add(new CalculatorAttribute('CalculatorAttribute', 0, '10*5'), $tab);
     $this->add(new CkAttribute('CkAttribute'), $tab);
     $this->add(new ColorPickerAttribute('ColorPickerAttribute'), $tab);
     $this->add(new CountryAttribute('CountryAttribute'), $tab);
     $this->add(new CreatedByAttribute('CreatedByAttribute'), $tab);
     $this->add(new CreateStampAttribute('CreateStampAttribute'), $tab);
     /** tab ************************/
     $tab = "tab_2";
     $this->add(new CurrencyAttribute('CurrencyAttribute'), $tab);
     $this->add(new DummyAttribute('DummyAttribute'), $tab);
     $this->add(new DurationAttribute('DurationAttribute'), $tab);
     $this->add(new EmailAttribute('EmailAttribute'), $tab);
     //$this->add(new ExpressionAttribute('ExpressionAttribute', 0, 'SELECT "test expression"'), $tab);
     $this->add(new IpAttribute('IpAttribute'), $tab);
     /** tab ************************/
     $tab = "tab_3";
     $this->add(new DummyAttribute('FieldSet_dummy1', A::AF_NO_LABEL, 'FieldSet_dummy1_content'), $tab);
     $this->add(new DummyAttribute('FieldSet_dummy2', A::AF_NO_LABEL, 'FieldSet_dummy2_content'), $tab);
     $this->add(new FieldSet('FieldSet', 0, '[FieldSet_dummy1] e [FieldSet_dummy2]'), $tab);
     $this->add(new FileAttribute('FileAttribute', 0, [Config::getGlobal('application_dir') . 'web/files/', '/files/']), $tab);
     $this->add(new FileWriterAttribute('FileWriterAttribute', 0, Config::getGlobal('application_dir') . 'web/files/filewriterfile.txt'), $tab);
     $this->add(new FlagAttribute('FlagAttribute', 0, ['option_with_1', 'option_with_2', 'option_with_4'], [1, 2, 4]), $tab);
     $this->add(new FormatAttribute('FormatAttribute', 0, 'AAA/##/##'), $tab);
     //TODO: FuzzySearchAttribute: test
     // $this->add(new FuzzySearchAttribute('FuzzySearchAttribute'), $tab);
     $this->add(new HiddenAttribute('HiddenAttribute'), $tab);
     $this->add(new HtmlAttribute('HtmlAttribute'), $tab);
     /** tab ************************/
     $tab = "tab_4";
     $this->add(new Attribute('LiveTextPreviewAttributeMaster'), $tab);
     $this->add(new LiveTextPreviewAttribute('LiveTextPreviewAttribute', 0, 'LiveTextPreviewAttributeMaster'), $tab);
     $this->add(new MultipleFileAttribute('MultipleFileAttribute', 0, [Config::getGlobal('application_dir') . 'web/multiplefiles/', '/multiplefiles/']), $tab);
     $this->add(new NumberAttribute('NumberAttribute', 0, 20, 2), $tab);
     $this->add(new ParserAttribute('ParserAttribute', 0, 'NumberAttribute is: [NumberAttribute]'), $tab);
     $this->add(new PasswordAttribute('PasswordAttribute'), $tab);
     $this->add(new RadioAttribute('RadioAttribute', 0, ['option_1', 'option_2', 'option_3']), $tab);
     /** tab ************************/
     $tab = "tab_5";
     $this->add(new RowCounterAttribute('RowCounterAttribute'), $tab);
     $this->add(new StateAttribute('StateAttribute'), $tab);
     $this->add(new SwitchAttribute('SwitchAttribute'), $tab);
     //TODO: TabbedPane: test
     //$this->add(new TabbedPane('TabbedPane'), $tab);
     //TODO: TagAttribute: test
     //$this->add(new TagAttribute('TagAttribute'), $tab);
     $this->add(new TextAttribute('TextAttribute'), $tab);
     $this->add(new TimeAttribute('TimeAttribute'), $tab);
     $this->add(new TimeZoneAttribute('TimeZoneAttribute'), $tab);
     $this->add(new UpdatedByAttribute('UpdatedByAttribute'), $tab);
     $this->add(new UpdateStampAttribute('UpdateStampAttribute'), $tab);
     $this->add(new UrlAttribute('UrlAttribute'), $tab);
     $this->add(new WeekdayAttribute('WeekdayAttribute'), $tab);
     /** RELATIONS **/
     /** tab ************************/
     $tab = "tab_6";
     $this->add(new OneToOneRelation('OneToOneRelation', 0, $this->getModule() . '.o2o_node', 'playground_id'), $tab);
     $rel = new ShuttleRelation('ShuttleRelation', 0, $this->getModule() . '.m2m_node', $this->getModule() . '.m2o_node');
     $rel->setLocalKey('playground_id');
     $rel->setRemoteKey('remotetable_id');
     $this->add($rel, $tab);
 }
Example #25
0
 /**
  * Adds a node/attribute entry to the node/attribute path.
  *
  * The entry consists of the the following fields:
  * - nr,          number in the node/attribute path (>= 0)
  * - node,        reference to the node for this path entry
  * - attr,        reference to the currently selected attribute for this path entry
  * - attrs,       all searchable attributes for this node
  * - includeSelf, whatever the attribute list should contain a reference to ourselves or not
  * - selectSelf,  should the self option be selected? (only valid if includeSelf is true)
  *
  * This method will modify the $path, $includeSelf and $excludes parameters to prepare
  * them for the next call to this method.
  *
  * @param array $path reference to the current path
  * @param Node $node reference to the current node
  * @param string $attrName currently selected attribute
  * @param bool $includeSelf should we include ourselves?
  * @param array $excludes attributes to exclude
  *
  * @return Node next node
  */
 public function addNodeAndAttrEntry(&$path, $node, $attrName, &$includeSelf, &$excludes)
 {
     $attr = $node->getAttribute($attrName);
     $nr = count($path);
     $attrs = $this->getSearchableAttributes($node, $excludes);
     if (count($attrs) == 1 && !$includeSelf) {
         $attr = $attrs[0];
     }
     $selectSelf = $includeSelf && $attrName == '.';
     $entry = array('nr' => $nr, 'node' => $node, 'attrs' => $attrs, 'attr' => $attr, 'includeSelf' => $includeSelf, 'selectSelf' => $selectSelf);
     $path[] =& $entry;
     $includeSelf = is_a($attr, 'ManyToOneRelation');
     $excludes = is_a($attr, 'OneToManyRelation') ? $attr->m_refKey : [];
     if (is_a($attr, 'Relation')) {
         $attr->createDestination();
         return $attr->m_destInstance;
     }
     return;
 }
Example #26
0
 /**
  * This is a recursive function to copy the children from a parent.
  *
  * @todo shouldn't we recursively call copyDb here? instead of ourselves
  *
  * @param string $selector Selector
  * @param int $parent Parent ID
  * @param string $mode The mode we're in
  */
 public function copyChildren($selector, $parent = '', $mode = 'copy')
 {
     $recordset = $this->select($selector)->mode($mode)->getAllRows();
     if (count($recordset) > 0) {
         for ($i = 0; $i < count($recordset); ++$i) {
             $recordset[$i][$this->m_parent] = array('' => '', $this->m_primaryKey[0] => $parent);
             $oldrec = $recordset[$i];
             parent::copyDb($recordset[$i], $mode);
             Tools::atkdebug('Child Record added');
             $newparent = $recordset[$i][$this->m_primaryKey[0]];
             Tools::atkdebug('CopyChildren(' . $this->m_parent . '=' . $oldrec[$this->m_primaryKey[0]] . ',' . $newparent . ')');
             $this->copyChildren($this->m_table . '.' . $this->m_parent . '=' . $oldrec[$this->m_primaryKey[0]], $newparent);
         }
     } else {
         Tools::atkdebug("No records found with Selector: {$selector} - {$parent}");
     }
     return '';
 }
Example #27
0
 /**
  * Does the actual loading of the dispatch page
  * And adds it to the page for the dispatch() method to render.
  *
  * @param array $postvars The request variables for the node.
  * @param Node $node
  */
 public function loadDispatchPage($postvars, Node $node)
 {
     $node->m_postvars = $postvars;
     $node->m_action = $postvars['atkaction'];
     if (isset($postvars['atkpartial'])) {
         $node->m_partial = $postvars['atkpartial'];
     }
     $page = $node->getPage();
     $page->setTitle(Tools::atktext('app_shorttitle') . ' - ' . $node->getUi()->title($node->m_module, $node->m_type, $node->m_action));
     if ($node->allowed($node->m_action)) {
         $secMgr = SecurityManager::getInstance();
         $secMgr->logAction($node->m_type, $node->m_action);
         $node->callHandler($node->m_action);
         $id = '';
         if (isset($node->m_postvars['atkselector']) && is_array($node->m_postvars['atkselector'])) {
             $atkSelectorDecoded = [];
             foreach ($node->m_postvars['atkselector'] as $rowIndex => $selector) {
                 list($selector, $pk) = explode('=', $selector);
                 $atkSelectorDecoded[] = $pk;
                 $id = implode(',', $atkSelectorDecoded);
             }
         } else {
             list(, $id) = explode('=', Tools::atkArrayNvl($node->m_postvars, 'atkselector', '='));
         }
         $page->register_hiddenvars(array('atknodeuri' => $node->m_module . '.' . $node->m_type, 'atkselector' => str_replace("'", '', $id)));
     } else {
         $page->addContent($this->accessDeniedPage($node->getType()));
     }
 }