Exemplo n.º 1
0
 /**
  * Display category tree with input checkboxes for forms
  * 
  * @param string $form_field form field name
  * @param array $selected_categories Categories that should be already selected
  * @param int $columns number of columns to display
  * @param bool $enable_parents Can parent categoires be select
  * @param bool $show_hidden Show hidden categories
  */
 public static function form_tree($form_field, array $selected_categories = array(), $columns = 1, $enable_parents = FALSE, $show_hidden = FALSE)
 {
     $category_data = self::get_category_tree_data(FALSE, $show_hidden);
     $html = '';
     // Validate columns
     $columns = (int) $columns;
     if ($columns == 0) {
         $columns = 1;
     }
     $categories_total = count($category_data);
     // Format categories for column display.
     // Column number
     $this_col = 1;
     // Maximum number of elements per column
     $maxper_col = round($categories_total / $columns);
     // start the first column
     $html .= "\n" . '<ul class="category-column category-column-' . $this_col . '" id="category-column-' . $this_col . '">' . "\n";
     $i = 1;
     // Element Count
     foreach ($category_data as $category) {
         // Display parent category.
         $html .= "\n\t" . '<li title="' . $category['category_description'] . '">';
         $html .= "\n\t\t" . category::display_category_checkbox($category, $selected_categories, $form_field, $enable_parents) . "\n";
         // Display child categories.
         if (count($category['children']) > 0) {
             $html .= "\t\t<ul>";
             foreach ($category['children'] as $child) {
                 $html .= "\n\t\t\t" . '<li title="' . $child['category_description'] . '">' . "\n";
                 $html .= category::display_category_checkbox($child, $selected_categories, $form_field, $enable_parents);
                 $html .= "\n\t\t\t" . '</li>' . "\r\n";
             }
             $html .= "\t\t" . '</ul>' . "\r\n";
         }
         $html .= "\t</li>\n";
         // If this is the last element of a column, close the UL
         if ($i % $maxper_col == 0 and $i > 0 or $i == $categories_total) {
             $html .= "</ul>\n";
             $this_col++;
             if ($i < $categories_total) {
                 $html .= '<ul class="category-column category-column-' . $this_col . '" id="category-column-' . $this_col . '">';
             }
         }
         $i++;
     }
     return $html;
 }
Exemplo n.º 2
0
 /**
  * Display category tree with input checkboxes.
  */
 public static function tree($categories, array $selected_categories, $form_field, $columns = 1, $enable_parents = FALSE)
 {
     $html = '';
     // Validate columns
     $columns = (int) $columns;
     if ($columns == 0) {
         $columns = 1;
     }
     $categories_total = $categories->count();
     // Format categories for column display.
     $this_col = 1;
     // column number
     $maxper_col = round($categories_total / $columns);
     // Maximum number of elements per column
     $i = 1;
     // Element Count
     foreach ($categories as $category) {
         // If this is the first element of a column, start a new UL
         if ($i == 1) {
             $html .= '<ul id="category-column-' . $this_col . '">';
         }
         // Display parent category.
         $html .= '<li>';
         $html .= category::display_category_checkbox($category, $selected_categories, $form_field, $enable_parents);
         // Display child categories.
         if ($category->children->count() > 0) {
             $html .= '<ul>';
             foreach ($category->children as $child) {
                 $html .= '<li>';
                 $html .= category::display_category_checkbox($child, $selected_categories, $form_field, $enable_parents);
             }
             $html .= '</ul>';
         }
         $i++;
         // If this is the last element of a column, close the UL
         if ($i > $maxper_col || $i == $categories_total) {
             $html .= '</ul>';
             $i = 1;
             $this_col++;
         }
     }
     return $html;
 }
Exemplo n.º 3
0
 /**
  * Display category tree with input checkboxes.
  */
 public static function tree($categories, $hide_children = TRUE, array $selected_categories, $form_field, $columns = 1, $enable_parents = FALSE)
 {
     $html = '';
     // Validate columns
     $columns = (int) $columns;
     if ($columns == 0) {
         $columns = 1;
     }
     $categories_total = $categories->count();
     // Format categories for column display.
     $this_col = 1;
     // column number
     $maxper_col = round($categories_total / $columns);
     // Maximum number of elements per column
     $i = 1;
     // Element Count
     foreach ($categories as $category) {
         // If this is the first element of a column, start a new UL
         if ($i == 1) {
             $html .= '<ul id="category-column-' . $this_col . '">';
         }
         // Display parent category.
         $html .= '<li title="' . $category->category_description . '">';
         $html .= category::display_category_checkbox($category, $selected_categories, $form_field, $enable_parents);
         // Visible Child Count
         $vis_child_count = 0;
         foreach ($category->children as $child) {
             // If we don't want to show a category's hidden children
             if ($hide_children == TRUE) {
                 $child_visible = $child->category_visible;
                 if ($child_visible) {
                     // Increment Visible Child count
                     ++$vis_child_count;
                 }
             } else {
                 ++$vis_child_count;
             }
         }
         // Display child categories.
         if ($category->children->count() > 0 and $vis_child_count > 0) {
             $html .= '<ul>';
             foreach ($category->children as $child) {
                 if ($hide_children) {
                     $child_visible = $child->category_visible;
                     if ($child_visible) {
                         $html .= '<li>';
                         $html .= category::display_category_checkbox($child, $selected_categories, $form_field, $enable_parents);
                     }
                 } else {
                     $html .= '<li title="' . $child->category_description . '">';
                     $html .= category::display_category_checkbox($child, $selected_categories, $form_field, $enable_parents);
                 }
             }
             $html .= '</ul>';
         }
         $i++;
         // If this is the last element of a column, close the UL
         if ($i > $maxper_col || $i == $categories_total) {
             $html .= '</ul>';
             $i = 1;
             $this_col++;
         }
     }
     return $html;
 }
Exemplo n.º 4
0
$user_categories = Kohana::config('pps.user_categories');
foreach ($categories as $category)
{
 if (in_array($category->category_title, $user_categories))
 {
   foreach ($category->children as $child)
   {
     echo '<li>'.category::display_category_checkbox($child, $selected_categories, 'incident_category').'</li>';
   }
 }
}
*/
// we display all categories
foreach ($categories as $category) {
    if ($category->category_visible) {
        echo '<li>' . category::display_category_checkbox($category, $selected_categories, 'incident_category') . '</li>';
    }
}
?>
</ul>
					</div>
				</div>
				<?php 
// Action::report_form - Runs right after the report categories
Event::run('ushahidi_action.report_form');
?>
                
                
                
                
                		<?php 
Exemplo n.º 5
0
    echo 'in ' . implode(', ', $category_titles) . ' - ';
}
// echo $pagination_stats;
?>
</h1>
<form method="GET" action="<?php 
echo url::site('reports');
?>
">
<ul style="display:none;">
<span style="font-weight: bold; display:">Filter by</span>
<?php 
// XXX just to move forward
$user_categories = array();
foreach ($user_categories as $visible_category) {
    echo '<li style="list-style: none; display: inline; padding: 0 5px">' . category::display_category_checkbox($visible_category, $selected_categories, 'c') . '</li>';
}
?>
<!--
<span style="font-weight: bold; margin-left: 1em">Borough</span>
<select name="b">
   <option value="any">Any</option>
   <option value="Queens" <?php 
if (isset($_GET['b']) and $_GET['b'] == "Queens") {
    ?>
selected="true"<?php 
}
?>
>Queens</option>
   <option value="Brooklyn" <?php 
if (isset($_GET['b']) and $_GET['b'] == "Brooklyn") {
Exemplo n.º 6
0
 /**
  * Display category tree with input checkboxes.
  * The is called "pseudo_tree" because the tree is generated based on naming convention.
  * For example "1. Category One", "1a. Category One A".
  * This is a stopgap solution for Haiti instance.
  * @todo: Category hierarchy should really be defined in the database.
  */
 public static function pseudo_tree_checkboxes(array $categories, array $selected_categories, $form_field, $columns = 1)
 {
     $html = '';
     // Validate columns
     $columns = (int) $columns;
     if ($columns == 0) {
         $columns = 1;
     }
     $categories_total = count($categories);
     // Organize categories into a hierarchical array.
     $sorted_categories = category::generate_pseudo_tree($categories);
     // Format categories for column display.
     $this_col = 1;
     // column number
     $maxper_col = round(count($sorted_categories) / $columns);
     // Maximum number of elements per column
     $i = 1;
     // Element Count
     foreach ($sorted_categories as $category) {
         // If this is the first element of a column, start a new UL
         if ($i == 1) {
             $html .= '<ul id="category-column-' . $this_col . '">';
         }
         // Display parent category.
         $html .= '<li>';
         $html .= category::display_category_checkbox($category, $selected_categories, $form_field);
         // Display child categories.
         if (!empty($category['children']) && is_array($category['children'])) {
             $html .= '<ul>';
             foreach ($category['children'] as $child_category) {
                 $html .= '<li>';
                 $html .= category::display_category_checkbox($child_category, $selected_categories, $form_field);
             }
             $html .= '</ul>';
         }
         $i++;
         // If this is the last element of a column, close the UL
         if ($i > $maxper_col || $i == $categories_total) {
             $html .= '</ul>';
             $i = 1;
             $this_col++;
         }
     }
     return $html;
 }