示例#1
0
 /**
  * Return the HTML code for the values in a given category.
  *
  * @param string  $categoryPath The identifying category path.
  * @param array   $values       The values used to populate the defautl states (optional) (default=array()).
  * @param string  $namePrefix   The path/object prefix to apply to the field name (optional) (default='').
  * @param string  $excludeList  A (string) list of IDs to exclude (optional) (default=null).
  * @param boolean $disabled     Whether or not the checkboxes are to be disabled (optional) (default=false).
  *
  * @return The resulting dropdown data.
  */
 public static function getCheckboxes_CategoryField($categoryPath, $values = array(), $namePrefix = '', $excludeList = null, $disabled = false)
 {
     if (!$categoryPath) {
         return z_exit(__f('Invalid %1$s passed to %2$s.', array('category', 'HtmlUtil::getCheckboxes_CategoryField')));
     }
     if (!$lang) {
         $lang = ZLanguage::getLanguageCode();
     }
     $cats = CategoryUtil::getSubCategoriesByPath($categoryPath, 'path', false, true, false, true, false, '', 'value');
     foreach ($cats as $k => $v) {
         $val = $k;
         $fname = $val;
         if ($namePrefix) {
             $fname = $namePrefix . '[' . $k . ']';
         }
         if (strpos($excludeList, ',' . $k . ',') === false) {
             $disp = $v['display_name'][$lang];
             if (!$disp) {
                 $disp = $v['name'];
             }
             $html .= "<input type=\"checkbox\" name=\"" . DataUtil::formatForDisplay($fname) . "\" " . ($values[$k] ? ' checked="checked" ' : '') . ($disabled ? ' disabled="disabled" ' : '') . " />&nbsp;&nbsp;&nbsp;&nbsp;" . DataUtil::formatForDisplay($disp) . "<br />";
         }
     }
     return $html;
 }