Пример #1
0
 /**
  * Admin page displays records and the actions that can be performed on
  * them (edit, delete) in a Treeview.
  *
  * @param ActionHandler $handler The action handler object
  */
 public function adminPage($handler)
 {
     global $g_maxlevel;
     $ui = $this->getUi();
     $content = '';
     $adminHeader = $handler->invoke('adminHeader');
     if ($adminHeader != '') {
         $content .= $adminHeader . '<br><br>';
     }
     Tools::atkdebug('Entering treeview page.');
     $t = $this->buildTree();
     $this->m_tree[0]['level'] = 0;
     $this->m_tree[0]['id'] = '';
     $this->m_tree[0]['expand'] = $this->hasFlag(self::NF_TREE_AUTO_EXPAND) ? 1 : 0;
     $this->m_tree[0]['colapse'] = 0;
     $this->m_tree[0]['isleaf'] = 1;
     $this->m_tree[0]['label'] = '';
     $this->treeToArray($t->m_tree);
     $g_maxlevel = $g_maxlevel + 2;
     $width = $g_maxlevel * 16 + 600;
     $content .= '<table border="0" cellspacing=0 cellpadding=0 cols=' . ($g_maxlevel + 2) . ' width=' . $width . ">\n";
     if (!$this->hasFlag(self::NF_NO_ADD) && $this->hasFlag(self::NF_ADD_LINK) && $this->allowed('add')) {
         $addurl = Config::getGlobal('dispatcher') . '?atknodeuri=' . $this->atkNodeUri() . '&atkaction=add&atkfilter=' . rawurlencode($this->m_parent . '.' . $this->m_primaryKey[0] . "='0'");
         if (Tools::atktext('txt_link_' . Tools::getNodeType($this->m_type) . '_add', $this->m_module, '', '', '', true) != '') {
             // specific text
             $label = Tools::atktext('link_' . Tools::getNodeType($this->m_type) . '_add', $this->m_module);
         } else {
             // generic text
             $label = Tools::atktext(Tools::getNodeType($this->m_type), $this->m_module) . ' ' . Tools::atktext('add', 'atk');
         }
         $content .= Tools::href($addurl, $label, SessionManager::SESSION_NESTED) . '<br><br>';
     }
     $content .= $this->GraphTreeRender();
     $content .= '</table><br>';
     $adminFooter = $handler->invoke('adminFooter');
     if ($adminFooter != '') {
         $content .= '<br>' . $adminFooter;
     }
     Tools::atkdebug('Generated treeview');
     return $ui->renderBox(array('title' => Tools::atktext('title_' . $this->m_type . '_tree', $this->m_module), 'content' => $content));
 }
Пример #2
0
 /**
  * Sets the node for this handler. Implicitly sets the
  * import node too!
  *
  * @param Node $node node instance
  *
  * @see setImportNode
  */
 public function setNode($node)
 {
     parent::setNode($node);
     $this->setImportNode($node);
 }
Пример #3
0
 /**
  * Get the atkActionHandler object for a certain action.
  *
  * The default implementation returns a default handler for the action,
  * but derived classes may override this to return a custom handler.
  *
  * @param string $action The action for which the handler is retrieved.
  *
  * @return ActionHandler The action handler.
  */
 public function getHandler($action)
 {
     Tools::atkdebug('self::getHandler(); action: ' . $action);
     //check if a handler exists registered including the module name
     $atk = Atk::getInstance();
     $handler = $atk->atkGetNodeHandler($this->atkNodeUri(), $action);
     // The node handler might return a class, then we need to instantiate the handler
     if (is_string($handler) && class_exists($handler)) {
         $handler = new $handler();
     }
     // The node handler might return a function as nodehandler. We cannot
     // return a function so we ignore this option.
     //       this would probably only work fine when using PHP5, but's better then nothing?
     //       or why support functions at all?!
     // handler object
     if ($handler != null && is_subclass_of($handler, 'ActionHandler')) {
         Tools::atkdebug('self::getHandler: Using existing ActionHandler ' . get_class($handler) . " class for '" . $action . "'");
         $handler->setNode($this);
         $handler->setAction($action);
     } else {
         $handler = ActionHandler::getDefaultHandler($action);
         $handler->setNode($this);
         $handler->setPostvars($this->m_postvars);
         $handler->setAction($action);
         //If we use a default handler we need to register it to this node
         //because we might call it a second time.
         Tools::atkdebug('self::getHandler: Register default ActionHandler for ' . $this->m_type . " action: '" . $action . "'");
         $atk->atkRegisterNodeHandler($this->m_type, $action, $handler);
     }
     return $handler;
 }
Пример #4
0
 /**
  * Constructor.
  *
  * @return AddHandler
  */
 public function __construct()
 {
     parent::__construct();
     $this->setReturnBehaviour(self::ATK_ACTION_BACK);
 }