| Conditions | 8 |
| Paths | 16 |
| Total Lines | 65 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 82 | |||
| 83 | $RSSstart = '<?xml version="1.0" encoding="UTF-8"?>' . DOKU_LF; |
||
| 84 | $RSSstart .= '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" ' |
||
| 85 | $RSSstart .= 'xmlns:dc="http://purl.org/dc/elements/1.1/">' . DOKU_LF; |
||
|
|
|||
| 86 | $RSSstart .= '<title>' . $conf['title'] . ' spatial feed</title>' . DOKU_LF; |
||
| 87 | if (!empty($conf['tagline'])) { |
||
| 88 | $RSSstart .= '<subtitle>' . $conf['tagline'] . '</subtitle>' . DOKU_LF; |
||
| 89 | } |
||
| 90 | $RSSstart .= '<dc:publisher>' . $conf['title'] . '</dc:publisher>' . DOKU_LF; |
||
| 91 | $RSSstart .= '<link href="' . DOKU_URL . '" />' . DOKU_LF; |
||
| 92 | $RSSstart .= '<link href="' . ml($mediaID, '', true, '&', true) . '" rel="self" />' . DOKU_LF; |
||
| 93 | $RSSstart .= '<updated>' . date(DATE_ATOM) . '</updated>' . DOKU_LF; |
||
| 94 | $RSSstart .= '<id>' . $idTag . date("Y-m-d") . ':' . parse_url(ml($mediaID), PHP_URL_PATH) . '</id>' . DOKU_LF; |
||
| 95 | $RSSstart .= '<rights>' . $conf['license'] . '</rights>' . DOKU_LF; |
||
| 96 | |||
| 97 | $RSSend = '</feed>' . DOKU_LF; |
||
| 98 | |||
| 99 | io_createNamespace($mediaID, 'media'); |
||
| 100 | @touch(mediaFN($mediaID)); |
||
| 101 | @chmod(mediaFN($mediaID), $conf['fmode']); |
||
| 102 | $fh = fopen(mediaFN($mediaID), 'w'); |
||
| 103 | fwrite($fh, $RSSstart); |
||
| 104 | |||
| 105 | foreach ($this->spatial_idx as $idxEntry) { |
||
| 106 | // get list of id's |
||
| 107 | foreach ($idxEntry as $id) { |
||
| 108 | // for document item in the index |
||
| 109 | if (strpos($id, 'media__', 0) !== 0) { |
||
| 110 | if ($this->skipPage($id, $namespace)) { |
||
| 111 | continue; |
||
| 112 | } |
||
| 113 | |||
| 114 | $meta = p_get_metadata($id); |
||
| 115 | |||
| 116 | // $desc = p_render('xhtmlsummary', p_get_instructions($meta['description']['abstract']), $info); |
||
| 117 | $desc = strip_tags($meta['description']['abstract']); |
||
| 118 | |||
| 119 | $entry = '<entry>' . DOKU_LF; |
||
| 120 | $entry .= ' <title>' . $meta['title'] . '</title>' . DOKU_LF; |
||
| 121 | $entry .= ' <summary>' . $desc . '</summary>' . DOKU_LF; |
||
| 122 | $entry .= ' <georss:point>' . $meta['geo']['lat'] . ' ' . $meta['geo']['lon'] |
||
| 123 | . '</georss:point>' . DOKU_LF; |
||
| 124 | if ($meta['geo']['alt']) { |
||
| 125 | $entry .= ' <georss:elev>' . $meta['geo']['alt'] . '</georss:elev>' . DOKU_LF; |
||
| 126 | } |
||
| 127 | $entry .= ' <link href="' . wl($id) . '" rel="alternate" type="text/html" />' . DOKU_LF; |
||
| 128 | if (empty($meta['creator'])) { |
||
| 129 | $meta['creator'] = $conf['title']; |
||
| 130 | } |
||
| 131 | $entry .= ' <author><name>' . $meta['creator'] . '</name></author>' . DOKU_LF; |
||
| 132 | $entry .= ' <updated>' . date_iso8601($meta['date']['modified']) . '</updated>' . DOKU_LF; |
||
| 133 | $entry .= ' <published>' . date_iso8601($meta['date']['created']) . '</published>' . DOKU_LF; |
||
| 134 | $entry .= ' <id>' . $idTag . date("Y-m-d", $meta['date']['modified']) . ':' |
||
| 135 | . parse_url(wl($id), PHP_URL_PATH) . '</id>' . DOKU_LF; |
||
| 136 | $entry .= '</entry>' . DOKU_LF; |
||
| 137 | fwrite($fh, $entry); |
||
| 138 | } |
||
| 139 | } |
||
| 140 | } |
||
| 141 | |||
| 142 | fwrite($fh, $RSSend); |
||
| 143 | return fclose($fh); |
||
| 144 | } |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Create a KML sitemap. |
||
| 244 |