Exemple #1
0
 public function GetSection(&$section_num)
 {
     global $langmessage;
     if (!isset($this->file_sections[$section_num])) {
         trigger_error('invalid section number');
         return;
     }
     $curr_section_num = $section_num;
     $section_num++;
     $content = '';
     $section_data = $this->file_sections[$curr_section_num];
     //make sure section_data is an array
     $type = gettype($section_data);
     if ($type !== 'array') {
         trigger_error('$section_data is ' . $type . '. Array expected');
         return;
     }
     $section_data += array('attributes' => array(), 'type' => 'text');
     $section_data['attributes'] += array('class' => '');
     $orig_attrs = $section_data['attributes'];
     $section_data['attributes']['data-gp-section'] = $curr_section_num;
     $section_types = \gp\tool\Output\Sections::GetTypes();
     if (\gp\tool\Output::ShowEditLink() && \gp\admin\Tools::CanEdit($this->gp_index)) {
         if (isset($section_types[$section_data['type']])) {
             $title_attr = $section_types[$section_data['type']]['label'];
         } else {
             $title_attr = sprintf($langmessage['Section %s'], $curr_section_num + 1);
         }
         $attrs = array('title' => $title_attr, 'data-cmd' => 'inline_edit_generic', 'data-arg' => $section_data['type'] . '_inline_edit');
         $link = \gp\tool\Output::EditAreaLink($edit_index, $this->title, $langmessage['edit'], 'section=' . $curr_section_num, $attrs);
         $section_data['attributes']['data-gp-area-id'] = $edit_index;
         //section control links
         if ($section_data['type'] != 'wrapper_section') {
             ob_start();
             echo '<span class="nodisplay" id="ExtraEditLnks' . $edit_index . '">';
             echo $link;
             echo \gp\tool::Link($this->title, $langmessage['Manage Sections'], 'cmd=ManageSections', array('class' => 'manage_sections', 'data-cmd' => 'inline_edit_generic', 'data-arg' => 'manage_sections'));
             echo '<span class="gp_separator"></span>';
             echo \gp\tool::Link($this->title, $langmessage['rename/details'], 'cmd=renameform&index=' . urlencode($this->gp_index), 'data-cmd="gpajax"');
             echo \gp\tool::Link($this->title, $langmessage['Revision History'], 'cmd=ViewHistory', array('data-cmd' => 'gpabox'));
             echo '<span class="gp_separator"></span>';
             echo \gp\tool::Link('Admin/Menu', $langmessage['file_manager']);
             echo '</span>';
             \gp\tool\Output::$editlinks .= ob_get_clean();
         }
         $section_data['attributes']['id'] = 'ExtraEditArea' . $edit_index;
     }
     $content .= $this->SectionNode($section_data, $orig_attrs);
     if ($section_data['type'] == 'wrapper_section') {
         for ($cc = 0; $cc < $section_data['contains_sections']; $cc++) {
             $content .= $this->GetSection($section_num);
         }
     } else {
         \gp\tool\Output::$nested_edit = true;
         $content .= \gp\tool\Output\Sections::RenderSection($section_data, $curr_section_num, $this->title, $this->file_stats);
         \gp\tool\Output::$nested_edit = false;
     }
     if (!isset($section_data['nodeName'])) {
         $content .= '<div class="gpclear"></div>';
         $content .= '</div>';
     } else {
         $content .= \gp\tool\Output\Sections::EndTag($section_data['nodeName']);
     }
     return $content;
 }
Exemple #2
0
 /**
  * Preview
  *
  */
 public function PreviewText()
 {
     global $langmessage;
     echo '<h2>';
     echo \gp\tool::Link('Admin/Extra', $langmessage['theme_content']);
     echo ' &#187; ' . str_replace('_', ' ', $this->title) . '</h2>';
     echo '</h2>';
     echo '<hr/>';
     echo \gp\tool\Output\Sections::RenderSection($this->file_sections[0], 0, '', $this->file_stats);
     echo '<hr/>';
 }
Exemple #3
0
 /**
  * Save an include section
  *
  */
 public static function SectionFromPost_Include(&$existing_section, $section_num, $title, $file_stats)
 {
     global $page, $langmessage, $gp_index, $config;
     unset($existing_section['index']);
     //gadget include
     if (strpos($_POST['include'], 'gadget:') === 0) {
         $gadget = substr($_POST['include'], 7);
         if (!isset($config['gadgets'][$gadget])) {
             msg($langmessage['OOPS_TITLE']);
             return false;
         }
         $existing_section['include_type'] = 'gadget';
         $existing_section['content'] = $gadget;
         //file include
     } elseif (strpos($_POST['include'], 'file:') === 0) {
         $include_title = substr($_POST['include'], 5);
         if (!isset($gp_index[$include_title])) {
             msg($langmessage['OOPS_TITLE']);
             return false;
         }
         $existing_section['include_type'] = \gp\tool::SpecialOrAdmin($include_title);
         $existing_section['index'] = $gp_index[$include_title];
         $existing_section['content'] = $include_title;
     }
     //send replacement content
     $content = \gp\tool\Output\Sections::RenderSection($existing_section, $section_num, $title, $file_stats);
     $page->ajaxReplace[] = array('gp_include_content', '', $content);
     return true;
 }
Exemple #4
0
 public static function GetExtra($name = 'Side_Menu', $info = array())
 {
     global $dataDir, $langmessage;
     $name = str_replace(' ', '_', $name);
     $file_stats = array();
     $is_draft = false;
     $extra_content = self::ExtraContent($name, $file_stats, $is_draft);
     $wrap = self::ShowEditLink('Admin_Extra');
     if (!$wrap) {
         echo '<div>';
         echo \gp\tool\Output\Sections::RenderSection($extra_content[0], 0, '', $file_stats);
         echo '</div>';
         return;
     }
     ob_start();
     $edit_link = self::EditAreaLink($edit_index, 'Admin/Extra', $langmessage['edit'], 'cmd=edit&file=' . $name, array('title' => $name, 'data-cmd' => 'inline_edit_generic'));
     echo '<span class="nodisplay" id="ExtraEditLnks' . $edit_index . '">';
     echo $edit_link;
     echo \gp\tool::Link('Admin/Extra', $langmessage['theme_content'], '', ' class="nodisplay"');
     echo '</span>';
     self::$editlinks .= ob_get_clean();
     $attrs = array();
     $attrs['data-gp_label'] = str_replace('_', ' ', $name);
     $attrs['class'] = 'editable_area';
     $attrs['id'] = 'ExtraEditArea' . $edit_index;
     if ($is_draft) {
         $attrs['data-draft'] = 1;
     } else {
         $attrs['data-draft'] = 0;
     }
     echo '<div' . \gp\tool\Output\Sections::SectionAttributes($attrs, $extra_content[0]['type']) . '>';
     echo \gp\tool\Output\Sections::RenderSection($extra_content[0], 0, '', $file_stats);
     echo '</div>';
 }