| 1 | <?php |
|---|
| 2 | function CT_textcube_Plugin_N_Skin($target) { |
|---|
| 3 | global $service, $pluginURL; |
|---|
| 4 | requireComponent("Eolin.PHP.Core"); |
|---|
| 5 | ob_start(); |
|---|
| 6 | ?> |
|---|
| 7 | <script type="text/javascript"> |
|---|
| 8 | function selectAddonTab(obj1, obj2, obj3, obj4){ |
|---|
| 9 | document.getElementById(obj1).className = "selected-tab"; |
|---|
| 10 | document.getElementById(obj2).className = "no-selected-tab"; |
|---|
| 11 | document.getElementById(obj3).className = "no-selected-tab"; |
|---|
| 12 | document.getElementById(obj4).className = "no-selected-tab"; |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | function searchAddon() { |
|---|
| 16 | var keyword = document.getElementById("searchAddonkey"); |
|---|
| 17 | var searchItem = document.getElementById("searchItem"); |
|---|
| 18 | if(keyword.value.trim() != "") |
|---|
| 19 | window.open("http://textcube.org/" + searchItem.value + "/search/" + looseURIEncode(keyword.value)); |
|---|
| 20 | return false; |
|---|
| 21 | } |
|---|
| 22 | </script> |
|---|
| 23 | <div class="Addon_center"> |
|---|
| 24 | <div class="Addon_layout_menu_tab"> |
|---|
| 25 | <ul class="Addon-tabs-box"> |
|---|
| 26 | <li id="Addon-tab-1" class="selected-tab" onclick="selectAddonTab('Addon-tab-1', 'Addon-tab-2', 'Addon-tab-3', 'Addon-tab-4');hideLayer('CT_Addon4');hideLayer('CT_Addon3');hideLayer('CT_Addon2');showLayer('CT_Addon1');">함께보기</li> |
|---|
| 27 | <li id="Addon-tab-2" class="no-selected-tab" onclick="selectAddonTab('Addon-tab-2', 'Addon-tab-1', 'Addon-tab-3', 'Addon-tab-4');hideLayer('CT_Addon4');hideLayer('CT_Addon3');hideLayer('CT_Addon1');showLayer('CT_Addon2');">플러그인</li> |
|---|
| 28 | <li id="Addon-tab-3" class="no-selected-tab" onclick="selectAddonTab('Addon-tab-3', 'Addon-tab-1', 'Addon-tab-2', 'Addon-tab-4');hideLayer('CT_Addon4');hideLayer('CT_Addon2');hideLayer('CT_Addon1');showLayer('CT_Addon3');">스킨</li> |
|---|
| 29 | <li id="Addon-tab-4" class="no-selected-tab" onclick="selectAddonTab('Addon-tab-4', 'Addon-tab-1', 'Addon-tab-2', 'Addon-tab-3');hideLayer('CT_Addon3');hideLayer('CT_Addon2');hideLayer('CT_Addon1');showLayer('CT_Addon4');">검색</li> |
|---|
| 30 | </ul> |
|---|
| 31 | </div> |
|---|
| 32 | <? |
|---|
| 33 | $target .= ob_get_contents(); |
|---|
| 34 | ob_end_clean(); |
|---|
| 35 | |
|---|
| 36 | $recentRssURLS = array('http://textcube.org/plugin/plugin/newRecentRSS?blogname=all', 'http://textcube.org/plugin/plugin/newRecentRSS?blogname=plugin', 'http://textcube.org/plugin/plugin/newRecentRSS?blogname=theme'); |
|---|
| 37 | $OL_CNT = 0; |
|---|
| 38 | foreach ($recentRssURLS as $recentRssURL){ |
|---|
| 39 | $OL_CNT++; |
|---|
| 40 | if(!is_null(getServiceSetting('TextcubePSAddon'.$OL_CNT))) { |
|---|
| 41 | $AddonEntries = unserialize(getServiceSetting('TextcubePSAddon'.$OL_CNT)); |
|---|
| 42 | $result = 0; |
|---|
| 43 | } else { |
|---|
| 44 | list($result, $feed, $xml, $AddonEntries) = CT_textcube_Plugin_N_Skin_getRemoteFeed($recentRssURL); |
|---|
| 45 | setServiceSetting('TextcubePSAddon'.$OL_CNT,serialize($AddonEntries)); |
|---|
| 46 | } |
|---|
| 47 | if ($result == 0) { |
|---|
| 48 | if (count($AddonEntries) > 0) { |
|---|
| 49 | $target .= '<ol id="CT_Addon' . $OL_CNT . '" style="display:' . ($OL_CNT == 1 ? 'block' : 'none') . ';" class="Addon_list">'.CRLF; |
|---|
| 50 | $i = 0; |
|---|
| 51 | foreach($AddonEntries as $item) { |
|---|
| 52 | $target .= '<li>'.CRLF; |
|---|
| 53 | $target .= ' <div class="previewBox" style="background: url('.$pluginURL.'/images/thumbBacground.png) center center no-repeat;">'.CRLF; |
|---|
| 54 | $target .= ' <img src="' . $item['image'] . '" onclick="window.open(\''. $item['permalink'] . '\');" border="0" width="32" height="32" />'.CRLF; |
|---|
| 55 | $target .= ' </div>'.CRLF; |
|---|
| 56 | $target .= ' <div class="entryInfo">'.CRLF; |
|---|
| 57 | $target .= ' <a href="'. $item['permalink'] . '" onclick="return openLinkInNewWindow(this);" >'.CRLF; |
|---|
| 58 | $blogName = strpos($item['permalink'], 'plugin')!== false ? 'plugin' : 'theme'; |
|---|
| 59 | $target .= ' <span class="date">' . Timestamp::formatDate($item['written']) . '</span> ' . ($OL_CNT == 1 ? '<span class="blogName">[' . ucwords($blogName) . ']</span>' : '') . '<br/>'.CRLF; |
|---|
| 60 | $target .= ' <span class="title">' . UTF8::lessenAsEm(htmlspecialchars($item['title']),33) . '</span>'.CRLF; |
|---|
| 61 | $target .= ' </a>'.CRLF; |
|---|
| 62 | $target .= ' </div>'.CRLF; |
|---|
| 63 | $target .= '</li>'.CRLF; |
|---|
| 64 | if($i>3) break; |
|---|
| 65 | else $i++; |
|---|
| 66 | } |
|---|
| 67 | $target .= '</ol>'.CRLF; |
|---|
| 68 | } else { |
|---|
| 69 | $target .= '<ol id="CT_Addon' . $OL_CNT . '" style="display:' . ($OL_CNT == 1 ? 'block' : 'none') . ';" class="Addon_list">'.CRLF; |
|---|
| 70 | $target .= ' <p style="height: 90px; padding-top: 65px; text-align: center;">'._t('데이터가 없습니다.').'</p>'; |
|---|
| 71 | $target .= '</ol>'.CRLF; |
|---|
| 72 | } |
|---|
| 73 | } else { |
|---|
| 74 | $target .= '<ol id="CT_Addon' . $OL_CNT . '" style="display:' . ($OL_CNT == 1 ? 'block' : 'none') . ';" class="Addon_list">'.CRLF; |
|---|
| 75 | $target .= ' <p style="height: 90px; padding-top: 65px; text-align: center;">'._t('데이터를 가져올 수 없습니다.').'<br />'._t('잠시 후 다시 시도해 주십시오.').'</p>'.CRLF; |
|---|
| 76 | $target .= '</ol>'.CRLF; |
|---|
| 77 | } |
|---|
| 78 | } |
|---|
| 79 | $target .= '<ol id="CT_Addon4" style="display:none;" class="Addon_list">'.CRLF; |
|---|
| 80 | $target .= ' <div class="searchBox">'.CRLF; |
|---|
| 81 | $target .= ' <select id="searchItem"><option value="plugin">플러그인</option><option value="theme">스킨</option></select>'.CRLF; |
|---|
| 82 | $target .= ' <input type="text" size="12" id="searchAddonkey" name="searchAddonkey" value="" onkeypress="if (event.keyCode == 13) { searchAddon(); return false; }" class="searchfield" />'.CRLF; |
|---|
| 83 | $target .= ' <input type="button" size="8" value="검 색" onclick="searchAddon();" class="searchbutton" />'.CRLF; |
|---|
| 84 | $target .= ' </div>'.CRLF; |
|---|
| 85 | $target .= '</ol>'.CRLF; |
|---|
| 86 | $target .= "</div>"; |
|---|
| 87 | unset($feed); |
|---|
| 88 | unset($xmls); |
|---|
| 89 | unset($AddonEntries); |
|---|
| 90 | return $target; |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | function CT_textcube_Plugin_N_Skin_getRemoteFeed($url) { |
|---|
| 94 | global $service; |
|---|
| 95 | $xml = fireEvent('GetRemoteFeed', null, $url); |
|---|
| 96 | if (empty($xml)) { |
|---|
| 97 | requireComponent('Eolin.PHP.HTTPRequest'); |
|---|
| 98 | $request = new HTTPRequest($url); |
|---|
| 99 | $request->timeout = 3; |
|---|
| 100 | if (!$request->send()) |
|---|
| 101 | return array(2, null, null, null); |
|---|
| 102 | $xml = $request->responseText; |
|---|
| 103 | } |
|---|
| 104 | $feed = array('xmlURL' => $url); |
|---|
| 105 | $xmls = new XMLStruct(); |
|---|
| 106 | if (!$xmls->open($xml, $service['encoding'])) { |
|---|
| 107 | if(preg_match_all('/<link .*?rel\s*=\s*[\'"]?alternate.*?>/i', $xml, $matches)) { |
|---|
| 108 | foreach($matches[0] as $link) { |
|---|
| 109 | $attributes = getAttributesFromString($link); |
|---|
| 110 | if(isset($attributes['href'])) { |
|---|
| 111 | $urlInfo = parse_url($url); |
|---|
| 112 | $rssInfo = parse_url($attributes['href']); |
|---|
| 113 | $rssURL = false; |
|---|
| 114 | if(isset($rssInfo['scheme']) && $rssInfo['scheme'] == 'http') |
|---|
| 115 | $rssURL = $attributes['href']; |
|---|
| 116 | else if(isset($rssInfo['path'])) { |
|---|
| 117 | if($rssInfo['path']{0} == '/') |
|---|
| 118 | $rssURL = "{$urlInfo['scheme']}://{$urlInfo['host']}{$rssInfo['path']}"; |
|---|
| 119 | else |
|---|
| 120 | $rssURL = "{$urlInfo['scheme']}://{$urlInfo['host']}".(isset($urlInfo['path']) ? rtrim($urlInfo['path'], '/') : '').'/'.$rssInfo['path']; |
|---|
| 121 | } |
|---|
| 122 | if($rssURL && $url != $rssURL) |
|---|
| 123 | return CT_textcube_Plugin_N_Skin_getRemoteFeed($rssURL); |
|---|
| 124 | } |
|---|
| 125 | } |
|---|
| 126 | } |
|---|
| 127 | return array(3, null, null, null); |
|---|
| 128 | } |
|---|
| 129 | if ($xmls->getAttribute('/rss', 'version')) { |
|---|
| 130 | $feed['blogURL'] = $xmls->getValue('/rss/channel/link'); |
|---|
| 131 | $feed['title'] = $xmls->getValue('/rss/channel/title'); |
|---|
| 132 | $feed['description'] = $xmls->getValue('/rss/channel/description'); |
|---|
| 133 | if (Validator::language($xmls->getValue('/rss/channel/language'))) |
|---|
| 134 | $feed['language'] = $xmls->getValue('/rss/channel/language'); |
|---|
| 135 | else if (Validator::language($xmls->getValue('/rss/channel/dc:language'))) |
|---|
| 136 | $feed['language'] = $xmls->getValue('/rss/channel/dc:language'); |
|---|
| 137 | else |
|---|
| 138 | $feed['language'] = 'en-US'; |
|---|
| 139 | $feed['modified'] = gmmktime(); |
|---|
| 140 | $items = array(); |
|---|
| 141 | for ($i = 0; $link = $xmls->getValue("/rss/channel/item[$i]/link"); $i++) { |
|---|
| 142 | $item = array('permalink' => rawurldecode($link)); |
|---|
| 143 | $item['title'] = $xmls->getValue("/rss/channel/item[$i]/title"); |
|---|
| 144 | $item['image'] = $xmls->getValue("/rss/channel/item[$i]/image"); |
|---|
| 145 | $item['author'] = $xmls->getValue("/rss/channel/item[$i]/author"); |
|---|
| 146 | $item['author'] = str_replace(array('(',')'), array('',''), $item['author']); |
|---|
| 147 | if ($xmls->getValue("/rss/channel/item[$i]/pubDate")) |
|---|
| 148 | $item['written'] = parseDate($xmls->getValue("/rss/channel/item[$i]/pubDate")); |
|---|
| 149 | else if ($xmls->getValue("/rss/channel/item[$i]/dc:date")) |
|---|
| 150 | $item['written'] = parseDate($xmls->getValue("/rss/channel/item[$i]/dc:date")); |
|---|
| 151 | else |
|---|
| 152 | $item['written'] = 0; |
|---|
| 153 | array_push($items, $item); |
|---|
| 154 | } |
|---|
| 155 | } else |
|---|
| 156 | return array(3, null, null, null); |
|---|
| 157 | |
|---|
| 158 | $feed['blogURL'] = POD::escapeString(UTF8::lessenAsEncoding(UTF8::correct($feed['blogURL']))); |
|---|
| 159 | $feed['title'] = POD::escapeString(UTF8::lessenAsEncoding(UTF8::correct($feed['title']))); |
|---|
| 160 | $feed['description'] = POD::escapeString(UTF8::lessenAsEncoding(UTF8::correct(stripHTML($feed['description'])))); |
|---|
| 161 | |
|---|
| 162 | return array(0, $feed, $xml, $items); |
|---|
| 163 | } |
|---|
| 164 | |
|---|
| 165 | function CT_textcube_Plugin_N_Skin_sweep($target, $mother = true) { |
|---|
| 166 | requireModel('common.setting'); |
|---|
| 167 | removeServiceSetting('TextcubePSAddon1'); |
|---|
| 168 | removeServiceSetting('TextcubePSAddon2'); |
|---|
| 169 | removeServiceSetting('TextcubePSAddon3'); |
|---|
| 170 | return $target; |
|---|
| 171 | } |
|---|
| 172 | ?> |
|---|