コード例 #1
0
ファイル: Node.php プロジェクト: sintattica/atk
 /**
  * Get the active sections.
  *
  * @param string $tab The currently active tab
  * @param string $mode The current mode ("edit", "add", etc.)
  *
  * @return array active Sections
  */
 public function getActiveSections($tab, $mode)
 {
     $activeSections = [];
     if (is_array($this->m_sectionList[$mode])) {
         foreach ($this->m_sectionList[$mode] as $section) {
             if (substr($section, 0, strlen($tab)) == $tab) {
                 $sectionName = 'section_' . str_replace('.', '_', $section);
                 $key = array('nodetype' => $this->atkNodeUri(), 'section' => $sectionName);
                 $defaultOpen = in_array($section, $this->m_default_expanded_sections);
                 if (State::get($key, $defaultOpen ? 'opened' : 'closed') != 'closed') {
                     $activeSections[] = $section;
                 }
             }
         }
     }
     return $activeSections;
 }
コード例 #2
0
ファイル: ViewEditBase.php プロジェクト: sintattica/atk
 /**
  * Create the clickable label for the section.
  *
  * @param array $field
  * @param string $mode
  *
  * @return string Html
  */
 public function getSectionControl($field, $mode)
 {
     // label
     $label = self::getSectionLabel($this->m_node, $field['name']);
     // our name
     list($tab, $section) = explode('.', $field['name']);
     $name = "section_{$tab}_{$section}";
     $url = Tools::partial_url($this->m_node->atkNodeUri(), $mode, 'sectionstate', array('atksectionname' => $name));
     // create onclick statement.
     $onClick = " onClick=\"javascript:handleSectionToggle(this,null,'{$url}'); return false;\"";
     $initClass = 'openedSection';
     //if the section is not active, we close it on load.
     $default = in_array($field['name'], $this->m_node->getActiveSections($tab, $mode)) ? 'opened' : 'closed';
     $sectionstate = State::get(array('nodetype' => $this->m_node->atkNodeUri(), 'section' => $name), $default);
     if ($sectionstate == 'closed') {
         $initClass = 'closedSection';
         $page = $this->getPage();
         $page->register_scriptcode("addClosedSection('{$name}');");
     }
     // create the clickable link
     return '<span class="atksectionwr"><a href="javascript:void(0)" id="' . $name . '" class="atksection ' . $initClass . '"' . $onClick . '>' . $label . '</a></span>';
 }