english comments added

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0_english@8278 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
mosmartin 2011-04-06 16:48:06 +00:00
parent 693e215bc1
commit 4d272994dd
219 changed files with 6407 additions and 8705 deletions

View file

@ -2,79 +2,63 @@
/**
* @class content
* @author NHN (developers@xpressengine.com)
* @brief content를 출력하는 위젯
* @brief widget to display content
* @version 0.1
**/
class content extends WidgetHandler {
/**
* @brief 위젯의 실행 부분
* @brief Widget handler
*
* ./widgets/위젯/conf/info.xml 선언한 extra_vars를 args로 받는다
* 결과를 만든후 print가 아니라 return 해주어야 한다
* Get extra_vars declared in ./widgets/widget/conf/info.xml as arguments
* After generating the result, do not print but return it.
**/
function proc($args) {
// 정렬 대상
// Targets to sort
if(!in_array($args->order_target, array('list_order','update_order'))) $args->order_target = 'list_order';
// 정렬 순서
// Sort order
if(!in_array($args->order_type, array('asc','desc'))) $args->order_type = 'asc';
// 페이지 수
// Pages
$args->page_count = (int)$args->page_count;
if(!$args->page_count) $args->page_count = 1;
// 출력된 목록 수
// The number of displayed lists
$args->list_count = (int)$args->list_count;
if(!$args->list_count) $args->list_count = 5;
// 섬네일 컬럼 수
// The number of thumbnail columns
$args->cols_list_count = (int)$args->cols_list_count;
if(!$args->cols_list_count) $args->cols_list_count = 5;
// 제목 길이 자르기
// Cut the length of the title
if(!$args->subject_cut_size) $args->subject_cut_size = 0;
// 내용 길이 자르기
// Cut the length of contents
if(!$args->content_cut_size) $args->content_cut_size = 100;
// 최근 글 표시 시간
// Display time of the latest post
if(!$args->duration_new) $args->duration_new = 12;
// 섬네일 생성 방법
// How to create thumbnails
if(!$args->thumbnail_type) $args->thumbnail_type = 'crop';
// 섬네일 가로 크기
// Horizontal size of thumbnails
if(!$args->thumbnail_width) $args->thumbnail_width = 100;
// 섬네일 세로 크기
// Vertical size of thumbnails
if(!$args->thumbnail_height) $args->thumbnail_height = 75;
// 보기 옵션
// Viewing options
$args->option_view_arr = explode(',',$args->option_view);
// markup 옵션
// markup options
if(!$args->markup_type) $args->markup_type = 'table';
// 내부적으로 쓰이는 변수 설정
// Set variables used internally
$oModuleModel = &getModel('module');
$module_srls = $args->modules_info = $args->module_srls_info = $args->mid_lists = array();
$site_module_info = Context::get('site_module_info');
// rss 인 경우 URL정리
// List URLs if a type is RSS
if($args->content_type == 'rss'){
$args->rss_urls = array();
$rss_urls = array_unique(array($args->rss_url0,$args->rss_url1,$args->rss_url2,$args->rss_url3,$args->rss_url4));
for($i=0,$c=count($rss_urls);$i<$c;$i++) {
if($rss_urls[$i]) $args->rss_urls[] = $rss_urls[$i];
}
// rss가 아닌 XE모듈일 경우 모듈 번호 정리 후 모듈 정보 구함
// Get module information after listing module_srls if the module is not RSS
} else {
// 대상 모듈이 선택되어 있지 않으면 해당 사이트의 전체 모듈을 대상으로 함
// Apply to all modules in the site if a target module is not specified
if(!$args->module_srls){
unset($obj);
$obj->site_srl = (int)$site_module_info->site_srl;
@ -89,7 +73,7 @@
}
$args->modules_info = $oModuleModel->getMidList($obj);
// 대상 모듈이 선택되어 있으면 해당 모듈만 추출
// Apply to the module only if a target module is specified
} else {
$obj->module_srls = $args->module_srls;
$output = executeQueryArray('widgets.content.getMids', $obj);
@ -107,16 +91,15 @@
}
}
}
// 아무런 모듈도 검색되지 않았다면 종료
// Exit if no module is found
if(!count($args->modules_info)) return Context::get('msg_not_founded');
$args->module_srl = implode(',',$module_srls);
}
/**
* 컨텐츠 추출, 게시글/댓글/엮인글/RSS등 다양한 요소가 있어서 method를 따로 만듬
* Method is separately made because content extraction, articles, comments, trackbacks, RSS and other elements exist
**/
// tab 형태
// tab type
if($args->tab_type == 'none' || $args->tab_type == '') {
switch($args->content_type){
case 'comment':
@ -135,7 +118,7 @@
$content_items = $this->_getDocumentItems($args);
break;
}
// tab 형태가 아닐 경우
// If not a tab type
} else {
$content_items = array();
@ -175,15 +158,14 @@
}
/**
* @brief 댓글 목록을 추출하여 contentItem으로 return
* @brief Get a list of comments and return contentItem
**/
function _getCommentItems($args) {
// CommentModel::getCommentList()를 이용하기 위한 변수 정리
// List variables to use CommentModel::getCommentList()
$obj->module_srl = $args->module_srl;
$obj->sort_index = $args->order_target;
$obj->list_count = $args->list_count * $args->page_count;
// comment 모듈의 model 객체를 받아서 getCommentList() method를 실행
// Get model object of the comment module and execute getCommentList() method
$oCommentModel = &getModel('comment');
$output = $oCommentModel->getNewestCommentList($obj);
@ -214,10 +196,9 @@
}
function _getDocumentItems($args){
// document 모듈의 model 객체를 받아서 결과를 객체화 시킴
// Get model object from the document module
$oDocumentModel = &getModel('document');
// 분류 구함
// Get categories
$obj->module_srl = $args->module_srl;
$output = executeQueryArray('widgets.content.getCategories',$obj);
if($output->toBool() && $output->data) {
@ -225,8 +206,7 @@
$category_lists[$val->module_srl][$val->category_srl] = $val;
}
}
// 글 목록을 구함
// Get a list of documents
$obj->module_srl = $args->module_srl;
$obj->category_srl = $args->category_srl;
$obj->sort_index = $args->order_target;
@ -234,8 +214,7 @@
$obj->list_count = $args->list_count * $args->page_count;
$output = executeQueryArray('widgets.content.getNewestDocuments', $obj);
if(!$output->toBool() || !$output->data) return;
// 결과가 있으면 각 문서 객체화를 시킴
// If the result exists, make each document as an object
$content_items = array();
$first_thumbnail_idx = -1;
if(count($output->data)) {
@ -280,16 +259,14 @@
$obj->module_srls = $obj->module_srl = $args->module_srl;
$obj->direct_download = 'Y';
$obj->isvalid = 'Y';
// 분류 구함
// Get categories
$output = executeQueryArray('widgets.content.getCategories',$obj);
if($output->toBool() && $output->data) {
foreach($output->data as $key => $val) {
$category_lists[$val->module_srl][$val->category_srl] = $val;
}
}
// 정해진 모듈에서 문서별 파일 목록을 구함
// Get a file list in each document on the module
$obj->list_count = $args->list_count * $args->page_count;
$files_output = executeQueryArray("file.getOneFileInDocument", $obj);
$files_count = count($files_output->data);
@ -342,8 +319,7 @@
$content_items[] = $content_item;
}
}
// 탭 형태가 아닐 경우
// If it is not a tab type
if($args->tab_type == 'none' || $args->tab_type == ''){
$items = array();
foreach($content_items as $key => $val){
@ -357,8 +333,7 @@
if($args->order_type =='asc') ksort($items);
else krsort($items);
$content_items = array_slice(array_values($items),0,$args->list_count*$args->page_count);
// 탭 형태
// Tab Type
} else {
foreach($content_items as $key=> $content_item_list){
$items = array();
@ -396,34 +371,27 @@
function _getSummary($content, $str_size = 50)
{
$content = preg_replace('!(<br[\s]*/{0,1}>[\s]*)+!is', ' ', $content);
// </p>, </div>, </li> 등의 태그를 공백 문자로 치환
// Replace tags such as </p> , </div> , </li> and others to a whitespace
$content = str_replace(array('</p>', '</div>', '</li>'), ' ', $content);
// 태그 제거
// Remove Tag
$content = preg_replace('!<([^>]*?)>!is','', $content);
// < , > , " 를 치환
// Replace tags to <, >, " and whitespace
$content = str_replace(array('&lt;','&gt;','&quot;','&nbsp;'), array('<','>','"',' '), $content);
// 연속된 공백문자 삭제
// Delete a series of whitespaces
$content = preg_replace('/ ( +)/is', ' ', $content);
// 문자열을 자름
// Truncate string
$content = trim(cut_str($content, $str_size, $tail));
// >, <, "를 다시 복구
// Replace back <, >, " to the original tags
$content = str_replace(array('<','>','"'),array('&lt;','&gt;','&quot;'), $content);
// 영문이 연결될 경우 개행이 안 되는 문제를 해결
// Fixed to a newline bug for consecutive sets of English letters
$content = preg_replace('/([a-z0-9\+:\/\.\~,\|\!\@\#\$\%\^\&\*\(\)\_]){20}/is',"$0-",$content);
return $content;
}
/**
* @brief rss 주소로 부터 내용을 받아오는 함수
* tistory 경우 원본 주소가 location 헤더를 뿜는다. (내용은 없음)이를 해결하기 위한 수정 - rss_reader 위젯과 방식 동일
* @brief function to receive contents from rss url
* For Tistory blog in Korea, the original RSS url has location header without contents. Fixed to work as same as rss_reader widget.
**/
function requestFeedContents($rss_url) {
$rss_url = str_replace('&amp;','&',Context::convertEncodingStr($rss_url));
@ -431,7 +399,7 @@
}
function _getRssItems($args){
// 날짜 형태
// Date Format
$DATE_FORMAT = $args->date_format ? $args->date_format : "Y-m-d H:i:s";
$buff = $this->requestFeedContents($args->rss_url);
@ -477,7 +445,7 @@
$content_items[] = $content_item;
}
} elseif($xml_doc->{'rdf:rdf'}) {
// rss1.0 지원 (Xml이 대소문자를 구분해야 하는데 XE의 XML파서가 전부 소문자로 바꾸는 바람에 생긴 case) by misol
// rss1.0 supported (XE's XML is case-insensitive because XML parser converts all to small letters. Fixed by misol
$rss->title = $xml_doc->{'rdf:rdf'}->channel->title->body;
$rss->link = $xml_doc->{'rdf:rdf'}->channel->link->body;
@ -511,7 +479,7 @@
$content_items[] = $content_item;
}
} elseif($xml_doc->feed && $xml_doc->feed->attrs->xmlns == 'http://www.w3.org/2005/Atom') {
// Atom 1.0 spec 지원 by misol
// Atom 1.0 spec supported by misol
$rss->title = $xml_doc->feed->title->body;
$links = $xml_doc->feed->link;
if(is_array($links)) {
@ -582,7 +550,7 @@
}
function _getTrackbackItems($args){
// 분류 구함
// Get categories
$output = executeQueryArray('widgets.content.getCategories',$obj);
if($output->toBool() && $output->data) {
foreach($output->data as $key => $val) {
@ -593,15 +561,12 @@
$obj->module_srl = $args->module_srl;
$obj->sort_index = $args->order_target;
$obj->list_count = $args->list_count * $args->page_count;
// trackback 모듈의 model 객체를 받아서 getTrackbackList() method를 실행
// Get model object from the trackback module and execute getTrackbackList() method
$oTrackbackModel = &getModel('trackback');
$output = $oTrackbackModel->getNewestTrackbackList($obj);
// 오류가 생기면 그냥 무시
// If an error occurs, just ignore it.
if(!$output->toBool() || !$output->data) return;
// 결과가 있으면 각 문서 객체화를 시킴
// If the result exists, make each document as an object
$content_items = array();
foreach($output->data as $key => $item) {
$domain = $args->module_srls_info[$item->module_srl]->domain;
@ -626,8 +591,7 @@
function _compile($args,$content_items){
$oTemplate = &TemplateHandler::getInstance();
// 위젯에 넘기기 위한 변수 설정
// Set variables for widget
$widget_info->modules_info = $args->modules_info;
$widget_info->option_view_arr = $args->option_view_arr;
$widget_info->list_count = $args->list_count;
@ -652,8 +616,7 @@
$widget_info->tab_type = $args->tab_type;
$widget_info->markup_type = $args->markup_type;
// 탭형태일경우 탭에 대한 정보를 정리하고 module_srl로 되어 있는 key값을 index로 변경
// If it is a tab type, list up tab items and change key value(module_srl) to index
if($args->tab_type != 'none' && $args->tab_type) {
$tab = array();
foreach($args->mid_lists as $module_srl => $mid){
@ -732,8 +695,7 @@
function setNickName($nick_name){
$this->add('nick_name',$nick_name);
}
// 글 작성자의 홈페이지 주소를 저장 by misol
// Save author's homepage url. By misol
function setAuthorSite($site_url){
$this->add('author_site',$site_url);
}