/** * Tells ATK that a node exists, and what actions are available to * perform on that node. Note that registerNode() is not involved in * deciding which users can do what, only in establishing the full set * of actions that can potentially be performed on the node. * * @param string $nodeUri uri of the node * @param string $class class of the node * @param array $actions actions that can be performed on the node * @param array $tabs tabnames for which security should be handled. * Note that tabs that every user may see need not be * registered. * @param string $section */ public function registerNode($nodeUri, $class, $actions = null, $tabs = [], $section = null) { if (!is_array($tabs)) { $section = $tabs; $tabs = []; } $module = Tools::getNodeModule($nodeUri); $type = Tools::getNodeType($nodeUri); $this->g_nodesClasses[$nodeUri] = $class; if ($actions) { // prefix tabs with tab_ for ($i = 0, $_i = count($tabs); $i < $_i; ++$i) { $tabs[$i] = 'tab_' . $tabs[$i]; } if ($module == '') { $module = 'main'; } if ($section == null) { $section = $module; } $this->g_nodes[$section][$module][$type] = array_merge($actions, $tabs); } }
/** * Get the select link to select the value using a select action on the destination node. * * @param string $selname * @param string $filter * * @return string HTML-code with the select link */ public function _getSelectLink($selname, $filter) { $result = ''; // we use the current level to automatically return to this page // when we come from the select.. $sm = SessionManager::getInstance(); $atktarget = Tools::atkurlencode(Config::getGlobal('dispatcher') . '?atklevel=' . $sm->atkLevel() . '&' . $selname . '=[atkprimkey]'); $linkname = Tools::atktext('link_select_' . Tools::getNodeType($this->m_destination), $this->getOwnerInstance()->getModule(), $this->getOwnerInstance()->getType(), '', '', true); if (!$linkname) { $linkname = Tools::atktext('link_select_' . Tools::getNodeType($this->m_destination), Tools::getNodeModule($this->m_destination), Tools::getNodeType($this->m_destination), '', '', true); } if (!$linkname) { $linkname = Tools::atktext('select_a'); } $result .= Tools::href(Tools::dispatch_url($this->m_destination, 'select', ['atkfilter' => $filter, 'atktarget' => $atktarget]), $linkname, SessionManager::SESSION_NESTED, $this->m_autocomplete_saveform, 'class="atkmanytoonerelation atkmanytoonerelation-link"'); return $result; }
/** * Gets the node and the descriptor for the current item * and returns a trace of that. * * So for instance, if we were adding a grade to a student, * it would show: * Student [ Teknoman ] - Grade [ A+ ] * * @return string The descriptortrace */ public function descriptorTrace() { $sessionData =& self::getSession(); $stack = $sessionData[$this->m_namespace]['stack'][$this->atkStackID()]; $res = []; $node = null; $module = null; $nodename = null; $stackcount = count($stack); $atk = Atk::getInstance(); for ($i = 0; $i < $stackcount; ++$i) { if (isset($stack[$i]['descriptor']) || $i == $stackcount - 1) { if ($stack[$i]['atknodeuri'] != '') { $node = $atk->atkGetNode($stack[$i]['atknodeuri']); $module = Tools::getNodeModule($stack[$i]['atknodeuri']); $nodename = Tools::getNodeType($stack[$i]['atknodeuri']); } if (is_object($node)) { $ui = Ui::getInstance(); $txt = $ui->title($module, $nodename); } else { $txt = Tools::atktext($nodename, $module); } $res[] = $txt . (isset($stack[$i]['descriptor']) ? " [ {$stack[$i]['descriptor']} ] " : ''); } } return $res; }
/** * Returns the currently selected actions. * * @param array $record The record * * @return array array with selected actions */ public function getSelectedActions($record) { $selected = $record[$this->fieldName()]; $result = []; foreach ($selected as $node => $actions) { $module = Tools::getNodeModule($node); $node = Tools::getNodeType($node); $result[$module][$node] = $actions; } return $result; }