Example #1
0
 /**
  * Add link to manage section admin for nested section type
  *
  */
 public static function NewSectionLink($types, $img, $wrapper_class = 'gpRow', $checkbox = false)
 {
     global $dataDir, $page;
     static $fi = 0;
     $types = (array) $types;
     $text_label = self::SectionLabel($types);
     $label = '';
     if (!empty($img)) {
         $label = '<img src="' . $img . '"/>';
     }
     $label .= '<span>' . $text_label . '</span>';
     //checkbox used for new pages
     if ($checkbox) {
         if (count($types) > 1) {
             $q = array('types' => $types, 'wrapper_class' => $wrapper_class);
             $q = json_encode($q);
         } else {
             $q = $types[0];
         }
         //checked
         $checked = '';
         if (isset($_REQUEST['content_type']) && $_REQUEST['content_type'] == $q) {
             $checked = ' checked';
         } elseif (empty($_REQUEST['content_type']) && $fi === 0) {
             $checked = ' checked';
             $fi++;
         }
         $id = 'checkbox_' . md5($q);
         echo '<div>';
         echo '<input name="content_type" type="radio" value="' . htmlspecialchars($q) . '" id="' . $id . '" required ' . $checked . ' />';
         echo '<label for="' . $id . '">';
         echo $label;
         echo '</label></div>';
         return;
     }
     //links used for new sections
     $attrs = array('data-cmd' => 'AddSection', 'class' => 'preview_section');
     if (count($types) > 1) {
         $attrs['data-response'] = $page->NewNestedSection($types, $wrapper_class);
     } else {
         $attrs['data-response'] = $page->GetNewSection($types[0]);
     }
     return '<div><a ' . \gp\tool::LinkAttr($attrs, $label) . '>' . $label . '</a></div>';
 }