
Public Member Functions | |
| getTypes () | |
| getTagsOrder ($type) | |
| getTagsFreq ($type) | |
| findTagNames ($ids) | |
| namesToIds ($nameList) | |
| makeSelectList ($type, $name, $addnone=false, $multiple=false, $nulltext='') | |
| getAdjacentByOrder ($id, $up=true) | |
| getAdjacentByFreq ($id, $up=true) | |
Static Public Member Functions | |
| static | getInstance () |
Protected Member Functions | |
| __construct () | |
Static Protected Attributes | |
| static | $instance = __CLASS__ |
Private Member Functions | |
| findTagObjects ($ids) | |
| getKeysArray ($id, $tagsArray) | |
| findAdjacent ($sub, $keys, $up) | |
Private Attributes | |
| $alltags = array() | |
| $tagsByTypeOrder = array() | |
| $typeByID = array() | |
Definition at line 20 of file aliroTagHandler.php.
| aliroTagHandler::__construct | ( | ) | [protected] |
Definition at line 26 of file aliroTagHandler.php.
References aliroDatabase::getInstance().
00026 { 00027 $this->alltags = aliroDatabase::getInstance()->doSQLget("SELECT id, ordering, frequency, published, hidden, type, name FROM #__tags ORDER BY ordering", 'stdClass', 'id'); 00028 foreach ($this->alltags as $id=>$tag) { 00029 $this->tagsByTypeOrder[$tag->type][] = $id; 00030 $this->typeByID[$id] = $tag->type; 00031 } 00032 }
| static aliroTagHandler::getInstance | ( | ) | [static] |
Definition at line 34 of file aliroTagHandler.php.
00034 { 00035 return is_object(self::$instance) ? self::$instance : (self::$instance = parent::getCachedSingleton(self::$instance)); 00036 }
| aliroTagHandler::getTypes | ( | ) |
| aliroTagHandler::getTagsOrder | ( | $ | type | ) |
Definition at line 42 of file aliroTagHandler.php.
References findTagObjects().
00042 { 00043 $ids = empty($this->tagsByTypeOrder[$type]) ? array() : $this->tagsByTypeOrder[$type]; 00044 return $this->findTagObjects($ids); 00045 }
| aliroTagHandler::getTagsFreq | ( | $ | type | ) |
Definition at line 47 of file aliroTagHandler.php.
References findTagObjects().
00047 { 00048 trigger_error('This does not work'); 00049 $ids = empty($this->tagsByTypeFreq[$type]) ? array() : $this->tagsByTypeFreq[$type]; 00050 return $this->findTagObjects($ids); 00051 }
| aliroTagHandler::findTagObjects | ( | $ | ids | ) | [private] |
Definition at line 53 of file aliroTagHandler.php.
Referenced by findTagNames(), getTagsFreq(), and getTagsOrder().
00053 { 00054 $result = array(); 00055 foreach ($ids as $id) $result[] = isset($this->alltags[$id]) ? $this->alltags[$id] : null; 00056 return $result; 00057 }
| aliroTagHandler::findTagNames | ( | $ | ids | ) |
Definition at line 59 of file aliroTagHandler.php.
References findTagObjects().
00059 { 00060 $objects = $this->findTagObjects($ids); 00061 foreach ($objects as $object) $result[] = is_object($object) ? $object->name : ''; 00062 return (isset($result)) ? $result : array(); 00063 }
| aliroTagHandler::namesToIds | ( | $ | nameList | ) |
Definition at line 65 of file aliroTagHandler.php.
References name.
00065 { 00066 $names = explode(',', $nameList); 00067 $ids = array(); 00068 foreach ($names as &$name) $name = trim($name); 00069 foreach ($this->alltags as $id=>$tag) if (in_array($tag->name, $names)) $ids[] = $id; 00070 return implode(',', $ids); 00071 }
| aliroTagHandler::makeSelectList | ( | $ | type, | |
| $ | name, | |||
| $ | addnone = false, |
|||
| $ | multiple = false, |
|||
| $ | nulltext = '' | |||
| ) |
Definition at line 73 of file aliroTagHandler.php.
00073 { 00074 if (isset($this->tagsByTypeOrder[$type])) { 00075 if ($multiple) { 00076 $multitext = 'multiple="multiple"'; 00077 if ('[]' != substr($name,-2)) $name .='[]'; 00078 } 00079 else $multitext = ''; 00080 if (empty($nulltext)) $nulltext = T_('None of these'); 00081 if ($addnone) $optionlist = <<<NULL_OPTION 00082 00083 <option value="0">$nulltext</option> 00084 00085 NULL_OPTION; 00086 00087 else $optionlist = ''; 00088 foreach ($this->tagsByTypeOrder as $sub) $optionslist .= <<<TAG_OPTION 00089 00090 <option value="{$this->alltags[$sub]->id}">{$this->alltags[$sub]->name}</option> 00091 00092 TAG_OPTION; 00093 00094 if ($optionlist) return <<<TAG_SELECT 00095 00096 <select name="$name" $multitext> 00097 $optionlist 00098 </select> 00099 00100 TAG_SELECT; 00101 00102 } 00103 return ''; 00104 }
| aliroTagHandler::getAdjacentByOrder | ( | $ | id, | |
| $ | up = true | |||
| ) |
Definition at line 106 of file aliroTagHandler.php.
References findAdjacent(), and getKeysArray().
00106 { 00107 $keys = $this->getKeysArray($id, $this->tagsByTypeOrder); 00108 $sub = array_search($id, $keys); 00109 return $this->findAdjacent($sub, $keys, $up); 00110 }
| aliroTagHandler::getAdjacentByFreq | ( | $ | id, | |
| $ | up = true | |||
| ) |
Definition at line 112 of file aliroTagHandler.php.
References findAdjacent(), and getKeysArray().
00112 { 00113 $keys = $this->getKeysArray($id, $this->tagsByTypeFreq); 00114 $sub = array_search($id, $keys); 00115 return $this->findAdjacent($sub, $keys, $up); 00116 }
| aliroTagHandler::getKeysArray | ( | $ | id, | |
| $ | tagsArray | |||
| ) | [private] |
Definition at line 118 of file aliroTagHandler.php.
Referenced by getAdjacentByFreq(), and getAdjacentByOrder().
00118 { 00119 if (!isset($this->typeByID[$id]) OR empty($tagsArray[$this->typeByID[$id]])) return array(); 00120 return array_keys($tagsArray[$this->typeByID[$id]]); 00121 }
| aliroTagHandler::findAdjacent | ( | $ | sub, | |
| $ | keys, | |||
| $ | up | |||
| ) | [private] |
Definition at line 123 of file aliroTagHandler.php.
Referenced by getAdjacentByFreq(), and getAdjacentByOrder().
00123 { 00124 $adjacent = $sub + ($up ? 1 : -1); 00125 return isset($keys[$adjacent]) ? $adjacent : 0; 00126 }
aliroTagHandler::$instance = __CLASS__ [static, protected] |
Definition at line 21 of file aliroTagHandler.php.
aliroTagHandler::$alltags = array() [private] |
Definition at line 22 of file aliroTagHandler.php.
aliroTagHandler::$tagsByTypeOrder = array() [private] |
Definition at line 23 of file aliroTagHandler.php.
aliroTagHandler::$typeByID = array() [private] |
Definition at line 24 of file aliroTagHandler.php.
1.5.5