⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.78
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
psa-pear
/
pear
/
php
/
Horde
/
Prefs
/
View File Name :
CategoryManager.php
* @category Horde * @package Prefs */ /** * Class for handling a list of categories stored in a user's * preferences. * * @author Chuck Hagenbuch
* @category Horde * @package Prefs */ class Horde_Prefs_CategoryManager { /** * Get all categories. */ public static function get() { $string = $GLOBALS['prefs']->getValue('categories'); if (empty($string)) { return array(); } $categories = explode('|', $string); asort($categories); return $categories; } /** * TODO */ public static function getSelect($id, $current = null) { $categories = self::get(); $colors = self::colors(); $fgcolors = self::fgColors(); $id_html = htmlspecialchars($id); $html = '
'; if (!in_array($current, $categories) && !empty($current)) { $curr_html = htmlspecialchars($current); $html .= '
' . sprintf(Horde_Prefs_Translation::t("Use Current: %s"), $curr_html) . '
' . '
- - - - - - - - -
'; } if (!$GLOBALS['prefs']->isLocked('categories')) { $html .= '
' . Horde_Prefs_Translation::t("New Category") . "
\n" . '
- - - - - - - - -
'; } // Always add an Unfiled option. $html .= '
' : '>') . htmlspecialchars(Horde_Prefs_Translation::t("Unfiled")) . '
'; foreach ($categories as $name) { $name_html = htmlspecialchars($name); $html .= '
' : '>') . $name_html . '
'; } return $html . '
'; } /** * TODO */ public static function getJavaScript($formname, $elementname) { $prompt = addslashes(Horde_Prefs_Translation::t("Please type the new category name:")); $error = addslashes(Horde_Prefs_Translation::t("You must type a new category name.")); return <<
JAVASCRIPT; } /** * Add a new category. * * @param string $category The name of the category to add. * * @return mixed False on failure, or the new category's name. */ public static function add($category) { if ($GLOBALS['prefs']->isLocked('categories') || empty($category)) { return false; } $categories = self::get(); if (in_array($category, $categories)) { return $category; } $categories[] = $category; $GLOBALS['prefs']->setValue('categories', implode('|', $categories)); return $category; } /** * Delete a category. * * @param string $category The category to remove. * * @return boolean True on success, false on failure. */ public static function remove($category) { if ($GLOBALS['prefs']->isLocked('categories')) { return false; } $categories = self::get(); $key = array_search($category, $categories); if ($key === false) { return $key; } unset($categories[$key]); $GLOBALS['prefs']->setValue('categories', implode('|', $categories)); // Remove any color preferences for $category. $colors = self::colors(); unset($colors[$category]); self::setColors($colors); return true; } /** * Returns the color for each of the user's categories. * * @return array A list of colors, key is the category name, value is the * HTML color code. */ public static function colors() { /* Default values that can be overridden but must always be * present. */ $colors['_default_'] = '#FFFFFF'; $colors['_unfiled_'] = '#DDDDDD'; $pairs = explode('|', $GLOBALS['prefs']->getValue('category_colors')); foreach ($pairs as $pair) { if (!empty($pair)) { list($category, $color) = explode(':', $pair); $colors[$category] = $color; } } $colors[''] = $colors['_unfiled_']; return $colors; } /** * Returns the foreground color for each of the user's categories. * * @return array A list of colors, key is the category name, value is the * HTML color code. */ public static function fgColors() { $colors = self::colors(); $fgcolors = array(); foreach ($colors as $name => $color) { $fgcolors[$name] = Horde_Image::brightness($color) < 128 ? '#f6f6f6' : '#000'; } return $fgcolors; } /** * TODO */ public static function setColor($category, $color) { $colors = self::colors(); $colors[$category] = $color; self::setColors($colors); } /** * TODO */ public static function setColors($colors) { $pairs = array(); foreach ($colors as $category => $color) { if ($color[0] != '#') { $color = '#' . $color; } if (!empty($category)) { $pairs[] = $category . ':' . $color; } } $GLOBALS['prefs']->setValue('category_colors', implode('|', $pairs)); } }