| | 113 | /** Translates a magpie error code into a local error type |
| | 114 | * and label. |
| | 115 | * @param $error, the error to translate. |
| | 116 | * @return An array containing the error label and the local |
| | 117 | * error. |
| | 118 | */ |
| | 119 | function translateError($error) { |
| | 120 | if ($error & MAGPIE_FEED_ORIGIN_CACHE) { |
| | 121 | if ($error & MAGPIE_FEED_ORIGIN_HTTP_304) { |
| | 122 | $label = LBL_UPDATE_NOT_MODIFIED; |
| | 123 | $cls = ERROR_NOERROR; |
| | 124 | } |
| | 125 | elseif ($error & MAGPIE_FEED_ORIGIN_HTTP_TIMEOUT) { |
| | 126 | $label = LBL_UPDATE_CACHE_TIMEOUT; |
| | 127 | $cls = ERROR_WARNING; |
| | 128 | } |
| | 129 | elseif ($error & MAGPIE_FEED_ORIGIN_NOT_FETCHED) { |
| | 130 | $label = LBL_UPDATE_STATUS_CACHED; |
| | 131 | $cls = ERROR_NOERROR; |
| | 132 | } |
| | 133 | elseif ($error & MAGPIE_FEED_ORIGIN_HTTP_404) { |
| | 134 | $label = LBL_UPDATE_NOT_FOUND; |
| | 135 | $cls = ERROR_ERROR; |
| | 136 | } else { |
| | 137 | $label = $error; |
| | 138 | $cls = ERROR_ERROR; |
| | 139 | } |
| | 140 | } |
| | 141 | elseif ($error & MAGPIE_FEED_ORIGIN_HTTP_200) { |
| | 142 | $label = LBL_UPDATE_STATUS_OK; |
| | 143 | $cls = ERROR_NOERROR; |
| | 144 | } else { |
| | 145 | if (is_numeric($error)) { |
| | 146 | $label = LBL_UPDATE_STATUS_ERROR; |
| | 147 | $cls = ERROR_ERROR; |
| | 148 | } else { |
| | 149 | // shoud contain MagpieError at this point |
| | 150 | $label = $error; |
| | 151 | $cls = ERROR_ERROR; |
| | 152 | } |
| | 153 | } |
| | 154 | |
| | 155 | return array('label' => $label, 'error' => $cls); |
| | 156 | } |
| | 157 | |
| 140 | | if ($error & MAGPIE_FEED_ORIGIN_CACHE) { |
| 141 | | if ($error & MAGPIE_FEED_ORIGIN_HTTP_304) { |
| 142 | | $label = LBL_UPDATE_NOT_MODIFIED; |
| 143 | | $cls = ERROR_NOERROR; |
| 144 | | } |
| 145 | | elseif ($error & MAGPIE_FEED_ORIGIN_HTTP_TIMEOUT) { |
| 146 | | $label = LBL_UPDATE_CACHE_TIMEOUT; |
| 147 | | $cls = ERROR_WARNING; |
| 148 | | } |
| 149 | | elseif ($error & MAGPIE_FEED_ORIGIN_NOT_FETCHED) { |
| 150 | | $label = LBL_UPDATE_STATUS_CACHED; |
| 151 | | $cls = ERROR_NOERROR; |
| 152 | | } |
| 153 | | elseif ($error & MAGPIE_FEED_ORIGIN_HTTP_404) { |
| 154 | | $label = LBL_UPDATE_NOT_FOUND; |
| 155 | | $cls = ERROR_ERROR; |
| 156 | | } else { |
| 157 | | $label = $error; |
| 158 | | $cls = ERROR_ERROR; |
| 159 | | } |
| 160 | | } |
| 161 | | elseif ($error & MAGPIE_FEED_ORIGIN_HTTP_200) { |
| 162 | | $label = LBL_UPDATE_STATUS_OK; |
| 163 | | $cls = ERROR_NOERROR; |
| 164 | | } else { |
| 165 | | if (is_numeric($error)) { |
| 166 | | $label = LBL_UPDATE_STATUS_ERROR; |
| 167 | | $cls = ERROR_ERROR; |
| 168 | | } else { |
| 169 | | // shoud contain MagpieError at this point |
| 170 | | $label = $error; |
| 171 | | $cls = ERROR_ERROR; |
| 172 | | } |
| 173 | | } |
| | 210 | $tmp = parent::translateError($error); |
| | 211 | $label = $tmp['label']; |
| | 212 | $cls = $tmp['error']; |
| | 303 | class ConsoleUpdate extends Update { |
| | 304 | function ConsoleUpdate() { |
| | 305 | } |
| | 306 | |
| | 307 | function render() { |
| | 308 | parent::populate(func_get_args()); |
| | 309 | |
| | 310 | foreach($this->chans as $chan) { |
| | 311 | list ($cid, $url, $title) = $chan; |
| | 312 | |
| | 313 | $ret = update($cid); |
| | 314 | |
| | 315 | $tmp = parent::translateError($ret[0]); |
| | 316 | |
| | 317 | if(defined('CONSOLE_OUTPUT') && 1 == CONSOLE_OUTPUT) { |
| | 318 | echo $title . "\t" . $tmp['label'] . "\t" . count($ret[1]) . "\n"; |
| | 319 | } |
| | 320 | |
| | 321 | if (!hidePrivate()) { |
| | 322 | parent::cleanUp($ret[1]); |
| | 323 | } |
| | 324 | } |
| | 325 | } |
| | 326 | } |
| | 327 | |