function getPageText($page_id = 0) { global $config; $PAGE = returnArrayWhere($config['pages'], 'page_id', $page_id); if (count($PAGE)) { return $PAGE[0]['page_text']; } else { return ''; } }
function generateCategoriesCheckboxes($selected_categs) { global $configArray; if (!is_array($selected_categs)) { $selected_categs = array(); } $level_0 = returnArrayWhere($configArray['categs'], 'parent_id', 0); //LEVEL 0 print '<ul>' . "\n"; for ($i = 0; $i < count($level_0); $i++) { $currentId = $level_0[$i]['categ_id']; $currentName = $level_0[$i]['categ_name']; $currentCheckBoxId = 'cb' . $level_0[$i]['categ_id']; $currentCheckBoxName = 'cb' . $level_0[$i]['categ_id']; if (in_array($currentId, $selected_categs)) { $isSelected = ' checked="checked"'; } else { $isSelected = ''; } print '<li>' . "\n"; //LEVEL 1 $level_1 = returnArrayWhere($configArray['categs'], 'parent_id', $currentId); //check if at least one sibling is checked $checkedSiblingsCount = 0; for ($j = 0; $j < count($level_1); $j++) { if (in_array($level_1[$j]['categ_id'], $selected_categs)) { $checkedSiblingsCount++; } } if ($checkedSiblingsCount > 0 && $checkedSiblingsCount < count($level_1)) { $isIntermediate = true; } else { $isIntermediate = false; } if (count($level_1) && $isIntermediate) { $level_0_extra_class = ' indeterminate'; } else { $level_0_extra_class = ''; } print "\t" . '<input' . $isSelected . ' class="css-checkbox' . $level_0_extra_class . '" type="checkbox" name="' . $currentCheckBoxId . '" id="' . $currentCheckBoxId . '" value="' . $currentId . '">' . "\n"; print "\t" . '<label class="css-label" for="' . $currentCheckBoxName . '">' . $currentName . '</label>' . "\n"; if (count($level_1)) { print "\t" . '<div id="plusminus_' . $currentCheckBoxName . '" class="plusminus plus"></div>' . "\n"; print "\t" . '<ul id="plusminus_content_' . $currentCheckBoxName . '" class="plusminus_content">' . "\n"; for ($j = 0; $j < count($level_1); $j++) { $currentSubId = $level_1[$j]['categ_id']; $currentSubName = $level_1[$j]['categ_name']; $currentSubCheckBoxId = 'cb' . $level_1[$j]['categ_id']; $currentSubCheckBoxName = 'cb' . $level_1[$j]['categ_id']; if (in_array($currentSubId, $selected_categs)) { $isSubSelected = ' checked="checked"'; } else { $isSubSelected = ''; } print "\t" . '<li>' . "\n"; print "\t\t" . '<input' . $isSubSelected . ' class="css-checkbox" type="checkbox" name="' . $currentSubCheckBoxName . '" id="' . $currentSubCheckBoxId . '" value="' . $currentSubId . '">' . "\n"; print "\t\t" . '<label class="css-label" for="' . $currentSubCheckBoxName . '">' . $currentSubName . '</label>' . "\n"; print "\t" . '</li>' . "\n"; } //endfor j print "\t" . '</ul>' . "\n"; } //endif level_1 print '</li>' . "\n"; } //endfor i print '</ul>' . "\n"; }