function createMap() { global $database, $db; func::mkpath($this->cacheDir); if (!is_dir($this->cacheDir) || !is_writable($this->cacheDir)) return false; requireComponent('LZ.PHP.XMLStruct'); requireComponent('LZ.PHP.XMLWriter'); $case = array(); $program = array(); $xmls = new XMLStruct; $db->query("SELECT domain, program FROM {$database['prefix']}Exports WHERE status='on' ORDER BY id ASC"); // 활성화 된 플러그인 목록 while ($data = $db->fetch()) { if (!$xmls->openFile(ROOT . '/exports/'. $data->program . '/index.xml')) continue; for ($i=1; $func=$xmls->getValue("/export/binding/listener[$i]"); $i++) { $action = $xmls->getAttribute("/export/binding/listener[$i]", 'action'); if (!isset($case[$data->domain])) $case[$data->domain] = array(); if (!isset($program[$data->domain])) $program[$data->domain] = $data->program; array_push($case[$data->domain], array("program"=>$data->program, "action"=> $action, "listener"=>$func)); } } // bloglounge $xml = new XMLFile($this->cacheDir.'/export_1.xml.php'); $xml->startGroup('map'); foreach ($case as $domain=>$binders) { $xml->startGroup('event', array('domain'=>$domain, 'program'=>$program[$domain])); foreach ($binders as $bind) { $xml->write('bind', $bind['listener'], false, array('action'=>$bind['action'])); } $xml->endGroup(); } $xml->endAllGroups(); $xml->close(); return true; }
function createMap() { global $database, $db; func::mkpath($this->cacheDir); if (!is_dir($this->cacheDir) || !is_writable($this->cacheDir)) return false; requireComponent('LZ.PHP.XMLStruct'); requireComponent('LZ.PHP.XMLWriter'); $case = array(); $tags = array(); $admins = array(); $xmls = new XMLStruct; $db->query("SELECT name FROM {$database['prefix']}Plugins WHERE status='on' ORDER BY name ASC"); // 활성화 된 플러그인 목록 while ($data = $db->fetch()) { if (!$xmls->openFile(ROOT . '/plugins/'. $data->name . '/index.xml')) continue; for ($i=1; $func=$xmls->getValue("/plugin/binding/listener[$i]"); $i++) { $event = $xmls->getAttribute("/plugin/binding/listener[$i]", 'event'); if (!isset($case[$event])) $case[$event] = array(); array_push($case[$event], array("plugin"=>$data->name, "listener"=>$func)); } for ($i=1; $func=$xmls->getValue("/plugin/binding/tag[$i]"); $i++) { $event = $xmls->getAttribute("/plugin/binding/tag[$i]", 'name'); if (!isset($tags[$event])) $tags[$event] = array(); array_push($tags[$event], array("plugin"=>$data->name, "listener"=>$func)); } if ($xmls->doesExist('/plugin/binding/admin')) { foreach ($xmls->selectNodes('/plugin/binding/admin') as $admin) { $menu = isset($admin['.attributes']['menu'])?$admin['.attributes']['menu']:'plugin'; if (!isset($admins[$menu])) $admins[$menu] = array(); $textFunc = isset($admin['text'][0]['.value'])?$admin['text'][0]['.value']:''; $pageFunc = isset($admin['page'][0]['.value'])?$admin['page'][0]['.value']:''; array_push($admins[$menu], array("plugin"=>$data->name, "text"=>$textFunc,"page"=>$pageFunc)); } } } // bloglounge $xml = new XMLFile($this->cacheDir.'/1.xml.php'); $xml->startGroup('map'); foreach ($case as $event=>$binders) { $xml->startGroup('event', array('name'=>$event)); foreach ($binders as $bind) { $xml->write('bind', $bind['listener'], false, array('plugin'=>$bind['plugin'])); } $xml->endGroup(); } foreach ($tags as $event=>$binders) { $xml->startGroup('tag', array('name'=>$event)); foreach ($binders as $bind) { $xml->write('bind', $bind['listener'], false, array('plugin'=>$bind['plugin'])); } $xml->endGroup(); } $xml->endAllGroups(); $xml->close(); // admin $xml = new XMLFile($this->cacheDir.'/admin.xml.php'); $xml->startGroup('map'); foreach ($admins as $event=>$binders) { $xml->startGroup('event', array('name'=>$event)); foreach ($binders as $bind) { $xml->write('bind', $bind['text'], false, array( 'plugin'=>$bind['plugin'],'event'=>'text')); $xml->write('bind', $bind['page'], false, array('plugin'=>$bind['plugin'],'event'=>'page')); } $xml->endGroup(); } // admin $xml->endAllGroups(); $xml->close(); return true; }
function refresh($type = 'recent', $file = true, $value = array()) { global $database, $db, $service; requireComponent('LZ.PHP.XMLWriter'); $rssDir = ROOT . '/cache/rss'; func::mkpath($rssDir); if (!is_dir($rssDir) || !is_writeable($rssDir)) return false; $config = new Settings; $rssCount = $config->feeditemsOnRss; $myURL = 'http://'.$_SERVER['HTTP_HOST'].$service['path']; if($file) { if($type == 'focus') { $xml = new XMLFile($rssDir.'/1_focus.xml'); } else if($type == 'category') { $xml = new XMLFile($rssDir.'/1_category_'.$value['id'].'.xml'); } else { $xml = new XMLFile($rssDir.'/1.xml'); } } else { $xml = new XMLFile('stdout'); } $xml->startGroup('rss', array('version'=>'2.0')); switch($type) { case 'focus': $title = htmlspecialchars($config->title) . ' : ' . _t('포커스 목록'); break; case 'category': $title = htmlspecialchars($config->title) . ' : ' . _f('%1에 대한 분류 검색결과',$value['name']); break; default: $title = htmlspecialchars($config->title); break; } $xml->startGroup('channel'); $xml->write('title', $title); $xml->write('link', htmlspecialchars($myURL)); $xml->write('description', htmlspecialchars($config->description)); $xml->write('language', $config->language); $xml->write('pubDate', date("r", time())); $xml->write('generator', BLOGLOUNGE.' '.BLOGLOUNGE_VERSION.' '.BLOGLOUNGE_NAME); if (!Validator::is_empty($config->logo)) { $xml->startGroup('image'); $xml->write('title', htmlspecialchars($config->title)); $xml->write('url', htmlspecialchars($myURL.'/cache/logo/'.$config->logo)); list($width, $height) = getimagesize(ROOT.'/cache/logo/'.$config->logo); $xml->write('width', $width); $xml->write('height', $height); $xml->write('description', ''); $xml->endGroup(); } if($type == 'focus') { $result = $db->query("SELECT title, permalink, author, description, tags, written FROM {$database['prefix']}FeedItems WHERE allowRedistribute='y' AND focus='y' AND visibility = 'y' ORDER BY written DESC LIMIT 0,{$rssCount}"); } else if($type == 'category') { $result = $db->query("SELECT i.title, i.permalink, i.author, i.description, i.tags, i.written FROM {$database['prefix']}FeedItems i LEFT JOIN {$database['prefix']}CategoryRelations c ON (c.item = i.id) WHERE i.allowRedistribute='y' AND i.visibility = 'y' AND c.category = {$value['id']} ORDER BY i.written DESC LIMIT 0,{$rssCount}"); } else { $result = $db->query("SELECT title, permalink, author, description, tags, written FROM {$database['prefix']}FeedItems WHERE allowRedistribute='y' AND visibility = 'y' ORDER BY written DESC LIMIT 0,{$rssCount}"); } if ($result) { while ($item = $db->fetch()) { $xml->startGroup('item'); $item->description = str_replace('/cache/images',$myURL.'/cache/images',$item->description); $xml->write('title', htmlspecialcharS($item->title)); $xml->write('link', htmlspecialchars($item->permalink)); $xml->write('description', htmlspecialchars($item->description)); foreach (explode(',', $item->tags) as $tag) { $xml->write('category', htmlspecialchars($tag)); } $xml->write('author', htmlspecialchars($item->author)); $xml->write('guid', htmlspecialchars($item->permalink)); $xml->write('pubDate', date("r", $item->written)); $xml->endGroup(); } } $xml->endAllGroups(); $xml->close(); return true; }