function replaceName($str, $type) { $itms = array(); foreach( $str as $splt ) { if( $splt != null && $splt != '' ) { array_push($itms, trim($splt)); } } $ints = array(); foreach( $itms as $name ) { switch( $type ) { case 0: $cat = Category::getByName($name); if( $cat instanceof Category ) { array_push($ints, $cat->categoryid); } break; case 1: $ing = Ingredient::getByName($name); if( $ing instanceof Ingredient ) { array_push($ints, $ing->ingredientid); } break; case 2: $char = Characteristic::getByCharacteristic($name); if( $char instanceof Characteristic ) { array_push($ints, $char->characteristicid); } break; default: break; } } return $ints; }
if (!file_exists(ROOT . '/cache/rss/0.xml')) { RSSOut::stop(); } $action = $accessInfo['action']; $config = new Settings; header('Content-Type: text/xml; charset=utf-8'); if(Validator::getBool($config->useRssOut)===true) { switch($action) { case 'focus': RSSOut::refresh('focus', false); break; case 'category': requireComponent('Bloglounge.Data.Category'); $category = Category::getByName(urldecode($accessInfo['value'])); RSSOut::refresh('category', false, $category); break; default: // recent RSSOut::refresh('recent',false); break; } } else { // error $fp = fopen(ROOT . "/cache/rss/0.xml", 'r+'); $result = fread($fp, filesize(ROOT . "/cache/rss/0.xml")); fclose($fp); } ?>
<? $c = new Category(); $action = $_POST["action"]; $name = $_POST["name"]; $c->setName($name); if ($action == "save") { $insert = TRUE; $errMsg = NULL; if ($name == "") { $errMsg = Text::getText("MissingName"); $insert = FALSE; } if ($insert) { $existing = Category::getByName($name); if ($existing != NULL) { $errMsg = Text::getText("AlreadyExists"); $insert = FALSE; } } if ($insert) { $c->insert(); header("Location: categoryList.php"); exit; } else { $buttonCaption = Text::getText("Add"); include("header.php"); print "<h2>".Text::getText("AddCategory")."</h2>"; include("categoryForm.php"); include("footer.php");
function getFeedItemsQuery($searchType, $searchKeyword, $searchExtraValue,$viewDelete = false,$owner = 0) { global $db, $database, $config; $sQuery = ''; if (($searchType=='tag' || $searchType=='tag+group_category') && !Validator::is_empty($searchKeyword)) { $tagIds = array(); $tags = explode(',',$searchKeyword); if($tagResult = $db->queryAll('SELECT id FROM '.$database['prefix'].'Tags WHERE name IN ('.Func::implode_string(',',$tags).')')) { foreach($tagResult as $tagItem) array_push($tagIds, $tagItem['id']); } if (empty($tagIds)) { return array(null,0); } else { if($searchType == 'tag') { $sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND (r.type = "feed")) WHERE r.tag IN ('.implode(',',$tagIds).')'; } else if($searchType == 'tag+group_category') { $sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND (r.type = "feed" || r.type = "group_category")) WHERE r.tag IN ('.implode(',',$tagIds).')'; } } } else if ($searchType=='blogURL' && !Validator::is_empty($searchKeyword)){ $searchKeyword = UTF8::bring($searchKeyword); $searchFeedId = $searchExtraValue; if(empty($searchFeedId)) { $searchFeedId = Feed::blogURL2Id('http://'.str_replace('http://', '', $searchKeyword)); } if(!empty($searchFeedId)) { $sQuery = ' WHERE i.feed = '.$searchFeedId; } else { $sQuery = ' WHERE 1=0 '; } } else if ($searchType=='user' && !Validator::is_empty($searchKeyword)){ $searchKeyword = UTF8::bring($searchKeyword); $searchFeedId = $searchExtraValue; if(empty($searchFeedId)) { if(is_numeric($searchKeyword)) { $user = User::getById($searchKeyword); } else { $user = User::getByloginId($searchKeyword); } $searchFeedId = Feed::getIdListByOwner($user['id']); } if(!empty($searchFeedId)) { $sQuery = ' WHERE i.feed IN ('.implode(",",$searchFeedId).')'; } else { $sQuery = ' WHERE 1=0 '; } } else if ($searchType=='author' && !Validator::is_empty($searchKeyword)){ $searchKeyword = UTF8::bring($searchKeyword); if(!empty($searchKeyword)) { $sQuery = ' WHERE i.author = "' . $searchKeyword . '"'; } else { $sQuery = ' WHERE 1=0 '; } } else if ($searchType=='title+description' && !Validator::is_empty($searchKeyword)){ $searchKeyword = UTF8::bring($searchKeyword); $keyword = $db->escape($searchKeyword); $sQuery = ' WHERE i.description LIKE "%'.$keyword.'%"'; } else if ($searchType=='title' && !Validator::is_empty($searchKeyword)){ $searchKeyword = UTF8::bring($searchKeyword); $keyword = $db->escape($searchKeyword); $sQuery = ' WHERE i.title LIKE "%'.$keyword.'%"'; } else if ($searchType=='description' && !Validator::is_empty($searchKeyword)){ $searchKeyword = UTF8::bring($searchKeyword); $keyword = $db->escape($searchKeyword); $sQuery = ' WHERE i.description LIKE "%'.$keyword.'%"'; } else if ($searchType=='focus'){ $sQuery = ' WHERE i.focus = "'.$searchKeyword.'"'; } else if ($searchType=='group') { requireComponent('Bloglounge.Data.Groups'); if(!empty($searchExtraValue)) { $tagId = $db->pick('SELECT id FROM '.$database['prefix'].'Tags WHERE name="'.$db->escape(urldecode($searchExtraValue)).'"'); if($tagId) { $tagId = $tagId[0]; $sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND r.type = "group_category") '; } } if(!is_numeric($searchKeyword)) { $group = Group::getByName($searchKeyword); $searchKeyword = $group['id']; } if($searchKeyword) { $feedIds = Group::getFeedIdList($searchKeyword); $sQuery .= ' WHERE i.feed IN (' . implode(',',$feedIds) .')'; if($tagId) { $sQuery .= ' AND r.tag="'.$tagId.'"'; } } } else if ($searchType=='category') { requireComponent('Bloglounge.Data.Category'); if(is_numeric($searchKeyword)) { $category = Category::getById($searchKeyword); } else { $category = Category::getByName($searchKeyword); } if($category) { $sQuery = ' WHERE c.category = ' . $category['id']; } } else if ($searchType == 'archive' && !Validator::is_empty($searchKeyword)) { if(is_array($searchExtraValue) && array_key_exists('start',$searchExtraValue) && array_key_exists('end',$searchExtraValue)) { $tStart = $searchExtraValue['start']; $tEnd = $searchExtraValue['end'] + 86400; } else { $tStart = $searchExtraValue; $tEnd = $tStart + 86400; } $tQuery = ' WHERE i.written > '.$tStart.' AND i.written < '.$tEnd.' '; if (strpos($sQuery, 'WHERE') !== false) { $sQuery = str_replace('WHERE ', $tQuery.' AND (', $sQuery); $sQuery .= ')'; } else { $sQuery .= $tQuery; } } else { if (!Validator::is_empty($searchKeyword)) { $searchKeyword = UTF8::bring($searchKeyword); $keyword = $db->escape($searchKeyword); if(empty($searchExtraValue)) { // all : title, description, tags, permlink $sQuery = ' WHERE i.author LIKE "%'.$keyword.'%" OR i.title LIKE "%'.$keyword.'%" OR i.description LIKE "%'.$keyword.'%" OR i.tags LIKE "%'.$keyword.'%" OR i.permalink LIKE "%'.$keyword.'%"'; } else { // custom $sQuery = ' WHERE ' . $searchExtraValue; } } } // boomDownReactor, boomDownReactorLimit : 리액터가 숨기기일때 쿼리에서 제외 파트 추가 ( 특정수만큼 붐다운(비추천)한글은 제외하거나 특정기능.. if(isset($config)) { if (($config->boomDownReactor == 'hide') && ($config->boomDownReactLimit > 0)) { $bQuery = ' WHERE (i.boomDown <= '.$config->boomDownReactLimit.') '; if (strpos($sQuery, 'WHERE') !== false) { $sQuery = str_replace('WHERE ', $bQuery.' AND (', $sQuery); $sQuery .= ')'; } else { $sQuery .= $bQuery; } } } if(empty($owner)) { if($viewDelete) { // 공개된 블로그만 뽑기 + 삭제된 글 보이기 if(!isAdmin()) { $bQuery = ' WHERE (i.visibility = "d") AND (i.feedVisibility = "y") '; } else { $bQuery = ' WHERE (i.visibility = "d") '; } } else { // 공개된 블로그만 뽑기 if(!isAdmin()) { $bQuery = ' WHERE (i.visibility = "y") AND (i.feedVisibility = "y") '; } else { $bQuery = ' WHERE (i.visibility != "d") '; } } } else { if($viewDelete) { // 공개된 블로그만 뽑기 // if(!isAdmin()) { // $bQuery = ' WHERE (i.visibility = "d") AND (i.feedVisibility = "y") AND (f.owner = ' . $owner . ')'; // } else { $bQuery = ' WHERE (i.visibility = "d") AND (f.owner = ' . $owner . ')'; // } } else { // 공개된 블로그만 뽑기 // if(!isAdmin()) { // $bQuery = ' WHERE (i.visibility = "y") AND (i.feedVisibility = "y") AND (f.owner = ' . $owner . ')'; // } else { $bQuery = ' WHERE (i.visibility != "d") AND (f.owner = ' . $owner . ')'; // } } } if($viewDelete) { if(strpos($sQuery, 'Feeds f') === false ) { $bQuery = ' LEFT JOIN '.$database['prefix'].'Feeds f ON (f.id = i.feed) ' . $bQuery; } } if (strpos($sQuery, 'WHERE') !== false) { $sQuery = str_replace('WHERE ', $bQuery.' AND (', $sQuery); $sQuery .= ')'; } else { $sQuery .= $bQuery; } return $sQuery; }
function getCategoryFocus($input, $config) { global $database, $db, $skin, $event, $service, $accessInfo; // 첫페이지에만 보이기 .. if(!(empty($accessInfo['controller']) && ($accessInfo['page']==1))) { return $input; } $pluginURL = $event->pluginURL; requireComponent('LZ.PHP.Media'); switch($config['categoryType']) { case 'random': $categories = Category::getRandomList($config['categoryCount']); break; case 'custom': $categoryNames = explode(',', $config['customCategory']); $categories = array(); foreach($categoryNames as $categoryName) { $item = Category::getByName($categoryName); if($item) { array_push($categories, $item); } } break; case 'recent': default: $categories = Category::getList($config['categoryCount']); break; } $categoryCount = count($categories); // css ob_start(); ?> <style type="text/css"> table.categoryFocus { width:100%; border:1px solid #dbdbdb; } table.categoryFocus td { width:50%; vertical-align:top; } table.categoryFocus td.left { border-right:1px solid #dedede; border-bottom:1px solid #dedede;} table.categoryFocus td.right { border-bottom:1px solid #dedede; } table.categoryFocus tr.lastChild td { border-bottom:0; } table.categoryFocus .title { padding:10px; padding-top:8px; padding-bottom:5px; } table.categoryFocus .title h3 { float:left; font-size:12px; font-weight:bold; margin:0; padding:0; color:#444; } table.categoryFocus .title h3 a { color:#444; text-decoration:none; } table.categoryFocus .title h3 a:hover { text-decoration:underline; } table.categoryFocus .title .more { float:right; } table.categoryFocus ul { list-style:none; margin:0; padding:10px; background:url(<?php echo $pluginURL;?>/images/bg_title.gif) repeat-x; } table.categoryFocus ul li.detail { } table.categoryFocus ul li.detail .thumbnail { float:left; width:60px; margin-right:10px; } table.categoryFocus ul li.detail .thumbnail img { width:50px; border:1px solid #ddd; padding:2px; } table.categoryFocus ul li.detail .data { float:left; width:292px; } table.categoryFocus ul li.detail .data h3 { font-size:13px; color:#595959; font-weight:bold; margin:0; margin-bottom:4px; } table.categoryFocus ul li.detail .data h3 a { color:#595959; text-decoration:none; } table.categoryFocus ul li.detail .data h3 a:hover { text-decoration:underline; } table.categoryFocus ul li.detail .data .desc { color:#aaa; line-height:16px; font-size:11px; } table.categoryFocus ul li.detail .data_full { width:362px; } table.categoryFocus ul li.list { margin-top:6px; } table.categoryFocus ul li.list a { color:#888; text-decoration:none; font-size:11px; } table.categoryFocus ul li.list a:hover { text-decoration:underline;} .categoryFocus_shadow { height:0px; font-size:0; border-top:1px solid #f5f5f5; margin-bottom:15px; } </style> <?php $css = ob_get_contents(); ob_end_clean(); $skin->css($css); // content ob_start(); ?> <table class="categoryFocus" cellspacing="0" cellpadding="0"> <?php $end = round($categoryCount / 2); for($i=0;$i<$end;$i++) { $index = $i * 2; ?> <tr<?php echo $i==$end-1?' class="lastChild"':'';?>> <td class="left"> <?php echo printCategoryFocusView($categories, $index, $config);?> </td> <td class="right"> <?php echo printCategoryFocusView($categories, $index+1, $config);?> </td> </tr> <?php } ?> </table> <div class="categoryFocus_shadow"></div> <?php $result = ob_get_contents(); ob_end_clean(); return $input . $result; }