'', 'alt'=>$artrec['title'], 'end'=>'', 'new'=>false ); } else { // リンク指定 $b=preg_match("/^\w+:|\.(pdf)$/",strtolower($artrec['url'])); $a="$a, 'alt'=>$artrec['title'], 'end'=>'', 'new'=>$b ); } } $path = ""; if($artrec["siteid"] == "spinf" ){ $path = "/spinf/spinf_j"; } elseif($artrec["siteid"] == "spaf" ){ $path = "/spaf-j"; } elseif($artrec["siteid"] == "smeif" ){ $path = "/smeif-j"; } // 記事リンク return Array( 'start'=>'', 'alt'=>$artrec['title'], 'end'=>'', 'new'=>false ); } function getArticleLinkEng($artrec,$fmt) { //print_r($artrec); if($artrec['url']) { // リンク指定 if($artrec['url']=='#') { // 自動リンク無し return Array( 'start'=>'', 'alt'=>$artrec['title'], 'end'=>'', 'new'=>false ); } else { // リンク指定 $b=preg_match("/^\w+:|\.(pdf)$/",strtolower($artrec['url'])); $a="$a, 'alt'=>$artrec['title'], 'end'=>'', 'new'=>$b ); } } $path = ""; if($artrec["siteid"] == "spinf" ){ $path = "/spinf"; } elseif($artrec["siteid"] == "spaf" ){ $path = "/spaf"; } elseif($artrec["siteid"] == "smeif" ){ $path = "/smeif"; } // 記事リンク return Array( 'start'=>'', 'alt'=>$artrec['title'], 'end'=>'', 'new'=>false ); } ################################################################### # # APIを使って記事を取得 # ################################################################### function checkCategory($category){ //print_r($category); return $category[0]; } function checkCategory2($category,$pubtype){ if( $pubtype == "0" ){ if($category){ foreach( $category as $key => $val ){ if( $val == "その他"){ return true; } } } } elseif( $pubtype == "1" ){ if($category){ foreach( $category as $key => $val ){ if( $val == "講演録/議事録"){ return true; } } } } elseif( $pubtype == "2" ){ if($category){ foreach( $category as $key => $val ){ if( $val == "書籍"){ return true; } } } } elseif( $pubtype == "3" ){ if($category){ foreach( $category as $key => $val ){ if( $val == "調査報告書"){ return true; } } } } elseif( $pubtype == "4" ){ if($category){ foreach( $category as $key => $val ){ if( $val == "定期刊行物"){ return true; } } } } } function getUrlData( $url ){ $auth_str = (BASIC_AUTH_ID && BASIC_AUTH_PASSWORD) ? BASIC_AUTH_ID.':'.BASIC_AUTH_PASSWORD.'@' : ''; //$baseurl = 'http://'.$auth_str.SERVER_ADDR.$url; $baseurl = 'https://www.spf.org'.$url; //print $baseurl; $json = file_get_contents($baseurl); $output = json_decode($json); //print_r($output); return $output; } function getMtArticle( $blog_id , $form="" ){ $auth_str = (BASIC_AUTH_ID && BASIC_AUTH_PASSWORD) ? BASIC_AUTH_ID.':'.BASIC_AUTH_PASSWORD.'@' : ''; //$baseurl = 'http://'.$auth_str.'/cms/mt-data-api.cgi/v1/sites/'.$blog_id.'/entries?limit=999'; $baseurl = 'http://www.spf.org'.'/cms/mt-data-api.cgi/v1/sites/'.$blog_id.'/entries?limit=999'; //print $baseurl."
"; $search_first = false; if( $form["q"] ){ //キーワード $baseurl .= "&search=".urlencode($form["q"]); } //print $baseurl."
"; //exit; $json = file_get_contents($baseurl); $output = json_decode($json); //print $baseurl; //print "
"; if( $_SERVER['REMOTE_ADDR'] == "114.178.178.81" ){ //print_r($output); } return $output->items; } function getMtCategoryList( $blog_id , $form="" ){ $baseurl = 'http://'.SERVER_ADDR.'/cms/mt-data-api.cgi/v1/sites/'.$blog_id.'/categories'; $search_first = false; if( $form["q"] ){ //キーワード $baseurl .= "?search=".urlencode($form["q"]); } //print $baseurl."
"; $json = file_get_contents($baseurl); $output = json_decode($json); return $output->items; } //TOP JSON function getMtArticleTop( ){ $baseurl = 'http://'.SERVER_ADDR.'/mtjson.dat'; $json = file_get_contents($baseurl); $json = ereg_replace( "},]", " }]" , $json ); //$json = ereg_replace( "{ ", "" , $json ); $json = mb_convert_encoding($json,"UTF-8","auto"); $output = json_decode($json); //print_r($output); //exit; return $output; } function getMtCategories( $blog_id , $form="" ){ $baseurl = 'http://'.SERVER_ADDR.'/cms/mt-data-api.cgi/v1/sites/'.$blog_id.'/categories'; $search_first = false; if( $form["q"] ){ //キーワード $baseurl .= "?search=".urlencode($form["q"]); } //print $baseurl."
"; $json = file_get_contents($baseurl); $output = json_decode($json); return $output->items; } //カレンダーを取得 function getCalendar(){ $baseurl = 'http://'.SERVER_ADDR.'/calendar.json'; $search_first = false; $json = file_get_contents($baseurl); $output = json_decode($json); return $output; } function getProjyectsCategory( $data ){ global $list1; if( $_SERVER['REMOTE_ADDR'] == "114.178.178.81"){ //print_r($data); //print "

"; } if( $data ){ $category1 = array(); $category2 = array(); $category3 = array(); foreach($data as $key => $val ){ //print_r( $val ); //exit; $c1 = ""; $c2 = ""; $c3 = ""; $cate1 = ""; $cate2 = ""; $cate3 = ""; list($c1,$c2,$c3) = explode("/",$val["siteid"]); if(!$c2){ continue; } //print $val["siteid"]."
"; //print $cate1."|".$cate2."|".$cate3."
"; //exit; if($c1){ if( !$category1 ){ $category1[] = $c1; } else { if( !in_array($c1,$category1)){ $category1[] = $c1; } } } ////print_r($val["siteid"]); //print "
"; /* if($cate2){ if( !$category2 ){ if($category1){ $cate2_id = ""; foreach($category1 as $key => $val){ if( $val == $cate1 ){ $cate2_id = $key; break; } } } //exit; $category2[$cate2_id][] = $cate2; } else { if($category1){ $cate2_id = ""; foreach($category1 as $key => $val){ if( $val == $cate1 ){ $cate2_id = $key; break; } } } //print_r($cate1); //print "
"; if( !in_array($cate2,$category2[$cate2_id])){ $category2[$cate2_id][] = $cate2; } } } if($cate3){ if( !$category3 ){ if($category2){ $cate3_id = ""; foreach($category2 as $key => $val){ foreach($val as $k => $v){ if( $v == $cate2 ){ $cate3_id = $k; break; } } } } $category3[$cate3_id][] = $cate3; } else { if($category2){ $cate3_id = ""; foreach($category2 as $key => $val){ foreach($val as $k => $v){ if( $v == $cate2 ){ $cate3_id = $k; break; } } } } //print $cate3_id."
"; if( !in_array($cate3,$category3[$cate3_id])){ //print_r($category3[$cate3_id]); //print "

"; $category3[$cate3_id][] = $cate3; } } } */ } foreach($data as $key => $val ){ //print_r( $val ); //exit; $c1 = ""; $c2 = ""; $c3 = ""; $cate1 = ""; $cate2 = ""; $cate3 = ""; list($c1,$c2,$c3) = explode("/",$val["siteid"]); //print $val["siteid"]."
"; //print $cate1."|".$cate2."|".$cate3."
"; //exit; /* if($cate1){ if( !$category1 ){ $category1[] = $cate1; } else { if( !in_array($cate1,$category1)){ $category1[] = $cate1; } } } */ if($c2){ if( !$category2 ){ if($category1){ $cate2_id = ""; foreach($category1 as $key => $val){ if( $val == $c1 ){ $cate2_id = $key; break; } } } //exit; $category2[$cate2_id][] = $c2; } else { if($category1){ $cate2_id = ""; foreach($category1 as $key => $val){ if( $val == $c1 ){ $cate2_id = $key; break; } } } //print_r($cate1); //print "
"; if( !in_array($c2,$category2[$cate2_id])){ $category2[$cate2_id][] = $c2; } } } //print_r($category2); //print "
"; /* if($cate3){ if( !$category3 ){ if($category2){ $cate3_id = ""; foreach($category2 as $key => $val){ foreach($val as $k => $v){ if( $v == $cate2 ){ $cate3_id = $k; break; } } } } $category3[$cate3_id][] = $cate3; } else { if($category2){ $cate3_id = ""; foreach($category2 as $key => $val){ foreach($val as $k => $v){ if( $v == $cate2 ){ $cate3_id = $k; break; } } } } //print $cate3_id."
"; if( !in_array($cate3,$category3[$cate3_id])){ //print_r($category3[$cate3_id]); //print "

"; $category3[$cate3_id][] = $cate3; } } } */ } //print_r($category2); //print "
"; foreach($data as $key => $val ){ //print_r( $val ); //exit; $c1 = ""; $c2 = ""; $c3 = ""; $cate1 = ""; $cate2 = ""; $cate3 = ""; list($c1,$c2,$c3) = explode("/",$val["siteid"]); //print $val["siteid"]."
"; //print $cate1."|".$cate2."|".$cate3."
"; //exit; if($c3){ if( !$category3 ){ if($category2){ $cate3_id = ""; foreach($category2 as $kk => $vv){ foreach($vv as $k => $v){ if( $v == $c2 ){ $cate2_id = $kk; list($cate3_id , $g) = explode( ". " , $v); break; } } } } //print $cate2_id."|".$cate3_id; $category3[$cate2_id][$cate3_id][] = $c3; } else { if($category2){ $cate3_id = ""; foreach($category2 as $kk => $vv){ foreach($vv as $k => $v){ if( $v == $c2 ){ $cate2_id = $kk; list($cate3_id , $g) = explode( ". " , $v); break; } } } } //print $cate3_id."
"; if( !in_array($c3,$category3[$cate2_id][$cate3_id])){ //print_r($category3[$cate3_id]); //print "

"; $category3[$cate2_id][$cate3_id][] = $c3; } } } } //print_r($category3); /* $category_list = array(); $category_list2 = array(); $category_list3 = array(); foreach( $data as $key => $val ){ if(!$val->parent){ $category_list[$val->id] = $val->label; } else { if($category_list[$val->parent]){ $category_list2[$val->parent][$val->id] = $val->label; } else { $category_list3[$val->parent][$val->id] = $val->label; } } } return array($category_list,$category_list2,$category_list3); //print_r($category_list2); */ //print_r($category1); return array($category1,$category2,$category3); } } function getProjectsYearNew(){ $list1 = getUrlData("/projects/read_list.php"); $list2 = getUrlData("/projects/read_list2.php"); $ch = date("Y" , mktime(1,1,1,1,1,date("Y")-5)); foreach( $list1 as $key => $val ){ if( $val->releasedttm2 >= $ch ){ list($y,$m,$d) = explode( "-" , $val->releasedttm2); $y_list[$y] = $y; //print $val->releasedttm2."
"; } //print $val->releasedttm2."
"; } foreach( $list2 as $key => $val ){ if( $val->releasedttm2 >= $ch ){ list($y,$m,$d) = explode( "-" , $val->releasedttm2); $y_list[$y] = $y; } } arsort($y_list); $num = count($y_list); if( $num < 5 ){ foreach( $y_list as $key => $val ){ $year = $y_list[$key]; break; } $n=0; while( $n < 5 ){ $data_year = $year+$n*-1; $y_list[$data_year] = $data_year; $n++; } } return $y_list; } function getProjectsYearNewEng(){ $list1 = getUrlData("/projects/read_list_eng.php"); //$list2 = getUrlData("/projects/read_list_eng2.php"); $ch = date("Y" , mktime(1,1,1,1,1,date("Y")-5)); foreach( $list1 as $key => $val ){ if( $val->releasedttm2 >= $ch ){ list($y,$m,$d) = explode( "-" , $val->releasedttm2); $y_list[$y] = $y; //print $val->releasedttm2."
"; } //print $val->releasedttm2."
"; } foreach( $list2 as $key => $val ){ if( $val->releasedttm2 >= $ch ){ list($y,$m,$d) = explode( "-" , $val->releasedttm2); $y_list[$y] = $y; } } arsort($y_list); $num = count($y_list); if( $num < 5 ){ foreach( $y_list as $key => $val ){ $year = $y_list[$key]; break; } $n=0; while( $n < 5 ){ $data_year = $year+$n*-1; $y_list[$data_year] = $data_year; $n++; } } return $y_list; } function getProjectsYear(){ if( date("m") < 04 ){ $year1 = date("Y" , mktime(1,1,1,1,1,date("Y")-1)); $year2 = date("Y" , mktime(1,1,1,1,1,date("Y")-2)); $year3 = date("Y" , mktime(1,1,1,1,1,date("Y")-3)); $year4 = date("Y" , mktime(1,1,1,1,1,date("Y")-4)); $year5 = date("Y" , mktime(1,1,1,1,1,date("Y")-5)); $year_list = array( $year1 => $year1, $year2 => $year2, $year3 => $year3, $year4 => $year4, $year5 => $year5, ); } else { $year1 = date("Y" , mktime(1,1,1,1,1,date("Y"))); $year2 = date("Y" , mktime(1,1,1,1,1,date("Y")-1)); $year3 = date("Y" , mktime(1,1,1,1,1,date("Y")-2)); $year4 = date("Y" , mktime(1,1,1,1,1,date("Y")-3)); $year5 = date("Y" , mktime(1,1,1,1,1,date("Y")-4)); $year_list = array( $year1 => $year1, $year2 => $year2, $year3 => $year3, $year4 => $year4, $year5 => $year5, ); } return $year_list; } function checkProjyectCategory($category,$lang=""){ if( !$lang ){ if($category == "general" ){ return '一般'; } elseif($category == "spf" ){ return 'SPF'; } elseif($category == "spinf" ){ return '島嶼国'; } elseif($category == "sjcff" ){ return '日中'; } elseif($category == "spaf" ){ return '汎アジア'; } elseif($category == "smeif" ){ return '中東'; } elseif($category == "scef" ){ return '中欧'; } elseif($category == "sff" ){ return 'sff'; } elseif($category == "SPF" ){ return 'SPF'; } elseif($category == "一般事業" ){ return '一般事業'; } } else { if($category == "general" ){ return 'REG'; } elseif($category == "spf" ){ return 'SPF'; } elseif($category == "spinf" ){ return 'SPINF'; } elseif($category == "sjcff" ){ return 'SJCFF'; } elseif($category == "spaf" ){ return 'SPAF'; } elseif($category == "smeif" ){ return 'SMEIF'; } elseif($category == "scef" ){ return 'SPAF'; } elseif($category == "sff" ){ return 'sff'; } elseif($category == "SPF" ){ return 'SPF'; } elseif($category == "一般事業" ){ return 'REG'; } } } ################################################################### # # 年度の作成 # ################################################################### function addYearly($start , $last){ $start = $start."-04-01"; $last = $last."-04-01"; return array($start,$last); } ################################################################### # # SQLのWHERE作成 # ################################################################### function getReleasedArticleSQL($now,$tbl,$siteid=false,$langid=false,$arttype=false) { $t=$tbl?"$tbl.":''; $sql= "${t}DELID=0 AND ${t}CONFID IS NOT NULL". " AND (${t}RELEASEDTTM IS NOT NULL AND ${t}RELEASEDTTM<='$now')". " AND (${t}ENDDTTM IS NULL OR ${t}ENDDTTM>'$now')"; if($arttype) { if(is_array($arttype)) { // 配列表記 $a1=Array(); $a2=Array(); foreach($arttype as $k=>$v) { if(is_array($v)) { // 値も配列 = サブタイプ $a2[]="(${t}ARTTYPE=$k AND ${t}ARTSUBTYPE IN (".join(',',$v)."))"; } else { // 値は文字列 = タイプ $a1[]=$v; } } if($a1) { if(count($a1)==1) $a2[]="${t}ARTTYPE=$a1[0]"; else $a2[]="${t}ARTTYPE IN (".join(',',$a1).")"; } if($a2) { $sql.=" AND (".join(' AND ',$a2).")"; } unset($a1,$a2,$k,$v); } else { // 文字列表記 $sql.=" AND ${t}ARTTYPE IN ($arttype)"; } } if($siteid) { $ss=Array(); foreach(is_array($siteid)?$siteid:Explode(',',$siteid) as $s) { $ss[]="'".escsql($s)."'"; } $sql.=" AND ${t}SITEID IN (".join(',',$ss).")"; } if($langid) $sql.=" AND ${t}LANGID='".trim($langid)."'"; return $sql; } ################################################################### # # カテゴリーアイコンの表示 # ################################################################### function categoryImage($category , $lang=""){ //print $category; if( !$lang ){ if($category == "general" ){ return '一般'; } elseif($category == "spf" ){ return 'SPF'; } elseif($category == "spinf" ){ return '島嶼国'; } elseif($category == "sjcff" ){ return '日中'; } elseif($category == "spaf" ){ return '汎アジア'; } elseif($category == "smeif" ){ return '中東'; } elseif($category == "scef" ){ return '中欧'; } elseif($category == "sff" ){ return 'sff'; } elseif($category == "SPF" ){ return 'SPF'; } elseif($category == "一般事業" ){ return '一般事業'; } } elseif( $lang == "en2" ) { if($category == "笹川平和財団" ){ return 'SPF'; } elseif($category == "一般事業" ){ return 'REG'; } elseif($category == "sjcff" ){ return 'SJCFF'; } elseif($category == "general" ){ return 'REG'; } elseif($category == "spf" ){ return 'SPF'; } elseif($category == "spinf" ){ return 'SPINF'; } elseif($category == "sjcff" ){ return 'SJCFF'; } elseif($category == "spaf" ){ return 'SPAF'; } elseif($category == "smeif" ){ return 'SMEIF'; } elseif($category == "scef" ){ return 'SPAF'; } elseif($category == "sff" ){ return 'sff'; } elseif($category == "SPF" ){ return 'SPF'; } elseif($category == "一般事業" ){ return 'REG'; } } else { if($category == "general" ){ return 'REG'; } elseif($category == "spf" ){ return 'SPF'; } elseif($category == "spinf" ){ return 'SPINF'; } elseif($category == "sjcff" ){ return 'SJCFF'; } elseif($category == "spaf" ){ return 'SPAF'; } elseif($category == "smeif" ){ return 'SMEIF'; } elseif($category == "scef" ){ return 'SPAF'; } elseif($category == "sff" ){ return 'sff'; } elseif($category == "SPF" ){ return 'SPF'; } elseif($category == "一般事業" ){ return 'REG'; } } } function categoryNo($category){ if($category == "general" ){ return 1; } elseif($category == "spf" ){ return 5; } elseif($category == "spinf" ){ return 2; } elseif($category == "sjcff" or $category == "china" ){ return 3; } elseif($category == "spaf" ){ return 4; } elseif($category == "smeif" ){ return 6; } elseif($category == "scef" ){ } elseif($category == "sff" ){ } elseif($category == "SPF" ){ return 5; } elseif($category == "一般事業" ){ return 1; } elseif($category == "projects" ){ return 1; } } function categoryUrl($category,$art_id,$path){ if($category == "general" or $category == "sjcff" or $category == "spf" or $category == "SPF" or $category == "一般事業" ){ return "article_".$art_id.".html"; } elseif($category == "spinf" ){ return "/spinf_j/".$path."/article_".$art_id.".html"; } elseif($category == "spaf" ){ return "/spaf-j/".$path."/article_".$art_id.".html"; } elseif($category == "smeif" ){ return "/smeif-j/".$path."/article_".$art_id.".html"; } elseif($category == "scef" ){ return "article_".$art_id.".html"; } elseif($category == "sff" ){ return "article_".$art_id.".html"; } } function categoryUrlEn($category,$art_id,$path){ if($category == "general" or $category == "sjcff" or $category == "spf" or $category == "SPF" or $category == "一般事業" ){ return "article_".$art_id.".html"; } elseif($category == "spinf" ){ return "/spinf/".$path."/article_".$art_id.".html"; } elseif($category == "spaf" ){ return "/spaf/".$path."/article_".$art_id.".html"; } elseif($category == "smeif" ){ return "/smeif/".$path."/article_".$art_id.".html"; } elseif($category == "scef" ){ return '中欧'; } elseif($category == "sff" ){ return 'sff'; } } function categoryUrlPub($category,$art_id,$path){ if($category == "general" or $category == "sjcff" or $category == "spf" or $category == "SPF" or $category == "一般事業" ){ return "detail_".$art_id.".html"; } elseif($category == "spinf" ){ return "/spinf/spinf_j/".$path."/detail_".$art_id.".html"; } elseif($category == "spaf" ){ return "/spaf-j/".$path."/detail_".$art_id.".html"; } elseif($category == "smeif" ){ return "/smeif-j/".$path."/detail_".$art_id.".html"; } elseif($category == "scef" ){ return "detail_".$art_id.".html"; } elseif($category == "sff" ){ return "detail_".$art_id.".html"; } } function categoryUrlPubEn($category,$art_id,$path){ if($category == "general" or $category == "sjcff" or $category == "spf" or $category == "SPF" or $category == "一般事業" ){ return "detail_".$art_id.".html"; } elseif($category == "spinf" ){ return "/spinf/".$path."/detail_".$art_id.".html"; } elseif($category == "spaf" ){ return "/spaf/".$path."/detail_".$art_id.".html"; } elseif($category == "smeif" ){ return "/smeif/".$path."/detail_".$art_id.".html"; } else { return "detail_".$art_id.".html"; } } function checkPubCategoryEng($category){ if( $category == "講演録/議事録" ){ return "Regular Publicaitons"; } elseif( $category == "書籍" ){ return "Regular Overview of Conference Transcripts/Minutes"; } elseif( $category == "調査報告書" ){ return "Overview of Books"; } elseif( $category == "定期刊行物" ){ return "Overview of Survey Reports"; } elseif( $category == "その他" ){ return "Overview of Other"; } } function checkSiteId($sitename){ if( $sitename == "笹川平和財団"){ return "general"; } else { return "spf"; } } ################################################################### # # プロジェクト情報用SQL # ################################################################### //取得 function getDataProjects($langid,$con,$y,$ny="",$site_id){ $ny = $y+1; $sql="SELECT T1.*". " FROM TGUIDELINEMST T1". " WHERE T1.DELID=0 AND T1.CONFID is not null AND T1.SITEID='$site_id' AND T1.LANGID='$langid' AND T1.STARTDATE <='$y-04-01' AND (T1.ENDDATE>='$ny-04-01' OR T1.ENDDATE IS NULL )". " AND NOT EXISTS (". " SELECT * FROM TGUIDELINEMST T2". " WHERE T2.DELID=0 AND T2.CONFID is not null AND T2.ORGGLID=T1.GLID". ")". " ORDER BY T1.STARTDATE DESC ". ",T1.ENDDATE DESC"; $data = $con->getAll($sql); if( $_SERVER['REMOTE_ADDR'] == "114.178.178.81"){ //print $sql; } return $data ; } //取得 function getDataProjectsSearch($langid,$con,$y,$ny,$site_id){ $sql="SELECT T1.*". " FROM TGUIDELINEMST T1". " WHERE T1.DELID=0 AND T1.CONFID is not null AND T1.SITEID='$site_id' AND T1.LANGID='$langid' ". " AND NOT EXISTS (". " SELECT * FROM TGUIDELINEMST T2". " WHERE T2.DELID=0 AND T2.CONFID is not null AND T2.ORGGLID=T1.GLID". ")". " ORDER BY T1.STARTDATE DESC ". ",T1.ENDDATE DESC"; $data = $con->getAll($sql); return $data ; } function getDataProjectsSub($langid,$con,$q_glid,$site_id){ if( is_numeric($q_glid)){ $sql="SELECT T1.*". " FROM TGUIDELINENODE T1". " WHERE GLID=$q_glid AND UPGLNID IS NULL ". " ORDER BY T1.so ASC ". ""; $data = $con->getAll($sql); return $data ; } else { return false; } } function getDataProjectsSub2($langid,$con,$glnid,$site_id){ if( is_numeric($glnid)){ // 小分類ノード取得 $sql="SELECT GLNID,NAME FROM TGUIDELINENODE". " WHERE UPGLNID=$glnid". " ORDER BY SO"; $data = $con->getAll($sql); return $data ; } else { return false; } } function getDataProjectsMain($con,$glnid,$langid,$nowyear){ if( is_numeric($glnid)){ $sql="SELECT T1.* ". " FROM TARTICLEPROJ T1". " WHERE T1.GLNID=$glnid AND T1.DELID=0 AND T1.CONFID IS NOT NULL AND T1.LANGID='".$langid."' AND T1.GLYEAR=$nowyear ". " ORDER BY (". "SELECT MAX(GLYEAR) FROM TARTICLEPROJ T5". " WHERE T5.RELARTID=T1.RELARTID AND T5.DELID=0". ") DESC , T1.RELARTID,T1.GLYEAR DESC"; $data = $con->getAll($sql); return $data ; } } //検索時 function getDataProjectsSearchList($langid,$con,$form,$site_id){ $nowyear = date("Y"); // ガイドライン、ガイドライン項目、事業の全てが承認されているものの条件 $sqltbl="TARTICLEPROJ T1,VGUIDELINENODE T2,TGUIDELINEMST T3"; $sqlwhere="T1.DELID=0 AND T1.CONFID IS NOT NULL AND T1.LANGID='".$langid."'". " AND T1.GLYEAR<=$nowyear". " AND T2.GLNID=T1.GLNID AND T2.CONFID IS NOT NULL". " AND T3.GLID=T2.GLID AND T3.CONFID IS NOT NULL"; // 年度で絞込み if($form["fy"]==$form["ty"]) { if(is_numeric($form["fy"])) $sqlwhere.=" AND T1.GLYEAR=".$form["fy"]; } else { if(is_numeric($form["fy"])) $sqlwhere.=" AND T1.GLYEAR>=".$form["fy"]; if(is_numeric($form["ty"])) $sqlwhere.=" AND T1.GLYEAR<=".$form["ty"]; } // 助成先もしくは助成策所在地の場合は助成で絞り込み if($form["jc"]) { $sqlwhere.=" AND T1.JOSEIFLG"; // 助成先タイプで絞込み if($q_jt) { $sqlwhere.=" AND EXISTS(". "SELECT * FROM TPROJJOSEITYPE T4". " WHERE T4.ARTID=T1.ARTID AND T4.JOSEITYPE IN ($q_jt)". ")"; } // 助成先所在地で絞込み if($form["jc"]) { $q_jc = implode(",",$form["jc"]); $sqlwhere.=" AND EXISTS(". "SELECT * FROM TPROJJOSEICTRY T5". " WHERE T5.ARTID=T1.ARTID AND T5.CTRYID IN ($q_jc)". ")"; } } // 事業区分で絞込み if($form["jk"]==1) { // 自主 $sqlwhere.=" AND T1.JISYUFLG"; } elseif($form["jk"]==2) { // 助成 $sqlwhere.=" AND T1.JOSEIFLG"; } if($form["yo"]) { $tbl=Array( SYO_1=>Array('0','5000000'), SYO_2=>Array('5000000','10000000'), SYO_3=>Array('10000000','15000000'), SYO_4=>Array('15000000','20000000'), SYO_5=>Array('20000000','0') ); $a=implode(',',$form["yo"]); $r=Array(); $idx=-1; // 範囲をまとめる foreach($tbl as $k=>$v) { if(!in_array($k,$a)) continue; if($idx<0) { $idx=0; $r[$idx]=$v; } else { if($r[$idx][1]==$v[0]) { $r[$idx][1]=$v[1]; } else { $idx++; $r[$idx]=$v; } } } // SQL化 while($idx>=0) { while($idx>=0) { $v=$r[$idx]; if($v[0]=='0') $r[$idx]="T1.CURYOSAN<=$v[1]"; elseif($v[1]=='0') $r[$idx]="T1.CURYOSAN>=$v[0]"; else $r[$idx]="T1.CURYOSAN BETWEEN $v[0] AND $v[1]"; $idx--; } $sqlwhere.=" AND (".join(' OR ',$r).")"; } unset($r,$a,$tbl); } // クエリ文字列で絞込み if($form["word"]) { @require_once 'libSearch.inc'; $sql.=compileQuery($form["word"],'T1.FINDTEXT'); if($sql) $sqlwhere.=" AND $sql"; } // 基金・ガイドラインで絞込み $siteids=false; { $wheres=Array(); $exsites=Array(); // 除外サイト if( !$form["gl"] and $form["gl2"]){ return false; } // ガイドラインで絞込み if($form["gl"]) { if($form["s"]) { foreach($form["gl"] as $key => $val ){ if(is_numeric($val)){ if(!$q_gl){ $q_gl = $val; } else { $q_gl .= ",".$val; } } else { if(!$q_gl){ $q_gl = "'".$val."'"; } else { $q_gl .= ",'".$val."'"; } } } // ガイドライン指定の基金絞込みを除外する $sql="SELECT DISTINCT SITEID FROM TGUIDELINEMST". " WHERE GLID IN (". "SELECT GLID FROM TGUIDELINENODE WHERE GLNID IN ($q_gl)". ")"; $exsites=$con->getAll($sql); if($exsites){ foreach( $exsites as $key => $val ){ if( $val ){ foreach( $val as $k => $v ){ $exsites2[$k] = $v; } } } } } else { foreach($form["gl"] as $key => $val ){ if(is_numeric($val)){ if(!$q_gl){ $q_gl = $val; } else { $q_gl .= ",".$val; } } else { if(!$q_gl){ $q_gl = "'".$val."'"; } else { $q_gl .= ",'".$val."'"; } } } } if($q_gl){ $wheres[]="T2.GLNID1 IN ($q_gl)"; $wheres[]="T2.GLNID2 IN ($q_gl)"; //print_r($q_gl); } } // 基金で絞込み if(true||$site_id=='spf') { if($form["s"]) { $a=Array(); foreach($form["s"] as $v) { if($v == "scef"){ if($v&&!in_array($v,$exsites)) $a[]="'".stripslashes(htmlspecialchars("spfa"))."'"; } else { if($v&&!in_array($v,$exsites)) $a[]="'".stripslashes(htmlspecialchars($v))."'"; } } $siteids=join(',',$a); if($a) $wheres[]="T1.SITEID IN ($siteids)"; unset($a); } } else { if(!in_array($site_id,$exsites)) $wheres[]="T1.SITEID='".$site_id."'"; } if($wheres) $sqlwhere.=" AND (".join(' OR ',$wheres).")"; unset($wheres,$exsites); } $sql="SELECT T1.ARTID,T1.ORGARTID,T1.GLYEAR,T1.NUMYEARS,T1.CURYEAR,T1.TITLE , T1.releasedttm". ",T1.JISYUFLG,T1.ITAKUFLG,T1.JOSEIFLG,T1.OTHERFLG". ",T1.JISYUNAME,T1.ITAKUNAME,T1.JOSEINAME,T1.OTHERNAME ". ",T1.CURYOSAN,T1.CURYOSANDETAIL". ",T1.SITEID,TS.ARTNAME AS SITEARTNAME,TS.SHORTNAME AS SITESHORTNAME". " FROM $sqltbl,TSITE TS". " WHERE ".$sqlwhere. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID)". " ORDER BY T1.GLYEAR DESC,T1.SO "; $res=$con->getAll($sql); if(PEAR::isError($res)) { return false; }else{ return $res; } //print_r( $data ); } function engType( $type ){ $type = ereg_replace( "自主" , "Self Operated" , $type); $type = ereg_replace( "委託" , "Commissioned" , $type); $type = ereg_replace( "助成" , "Grant" , $type); $type = ereg_replace( "その他" , "Other" , $type); return $type; } //英語版の事業名の検索 function chechEngName($name,$list){ foreach( $list as $key => $val ){ if( trim($val->ja) == trim($name) ){ //print 213; return $val->en; break; } } } ################################################################### # # セミナー情報用SQL # ################################################################### // 日付範囲の判定 // $now 判定日(YYYY-MM-DD) // $startdt 期間開始日(YYYY-MM-DD もしくはヌルストリングス) // $enddt 期間終了日(YYYY-MM-DD もしくはヌルストリングス) // $eventflg イベント用フラグ 0:期間判定を行う 1:常に'期間内' -1:常に'期間後' // $endok 期間終了日を期間内とするなら true // return 0:期間内 負:期間前 正;期間後 function checkArticlePeriod($now,$startdt,$enddt,$eventflg=0,$endok=false) { if(strlen($startdt)>10) $startdt=substr($startdt,0,10); if(strlen($enddt)>10) $enddt=substr($enddt,0,10); if($startdt&&$startdt>$now) return -1; // 期間前 if($enddt) { if($endok) { if($enddt<$now) return 1; // 期間後 } else { if($enddt<=$now) return 1; // 期間後 } } return 0; // 期間中 } function checkSeminarData($y,$con){ $ny = $y+1; $tbl = 'TARTICLEEVENT'; $now = date("Y-m-d H:i:s"); $wheresql=getReleasedArticleSQL($now,'T1',$siteid,$langid,$arttype); $wheresql2="$wheresql AND T1.ARTDATE>='$y-04-01' AND T1.ARTDATE<'$ny-04-01'"; $sql="SELECT T1.* ". ",TS.NAME AS SITENAME,TS.SHORTNAME AS SITESHORTNAME,TS.ARTNAME AS SITEARTNAME". " FROM $tbl T1,TSITE TS". " WHERE ".$wheresql2. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID)". " ORDER BY T1.ARTDATE DESC,T1.ARTID DESC LIMIT 1"; //print $sql; //print $sql; $data = $con->getRow($sql); if($data){ return true; } else { return false; } //print_r( $data ); return $data; } //取得 function getDataSeminar($langid,$con,$y,$ny){ $tbl = 'TARTICLEEVENT'; $now = date("Y-m-d H:i:s"); $wheresql=getReleasedArticleSQL($now,'T1',$siteid,$langid,$arttype); $wheresql2="$wheresql AND T1.ARTDATE>='$y-04-01' AND T1.ARTDATE<'$ny-04-01'"; $sql="SELECT T1.* ". ",TS.NAME AS SITENAME,TS.SHORTNAME AS SITESHORTNAME,TS.ARTNAME AS SITEARTNAME". " FROM $tbl T1,TSITE TS". " WHERE ".$wheresql2. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID)". " ORDER BY T1.ARTDATE DESC,T1.ARTID DESC"; //print $sql; $data = $con->getAll($sql); //print_r( $data ); return $data; } function getDataSeminarTop($langid,$con,$y,$ny){ $tbl = 'TARTICLEEVENT'; $now = date("Y-m-d H:i:s"); $wheresql=getReleasedArticleSQL($now,'T1',$siteid,$langid,$arttype); $wheresql2="$wheresql AND T1.ARTDATE>='$y-04-01' AND T1.ARTDATE<'$ny-04-01'"; $sql="SELECT T1.* ". ",TS.NAME AS SITENAME,TS.SHORTNAME AS SITESHORTNAME,TS.ARTNAME AS SITEARTNAME". " FROM $tbl T1,TSITE TS". " WHERE ".$wheresql2. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID)". " ORDER BY T1.ARTDATE DESC,T1.ARTID DESC LIMIT 10"; //print $sql; $data = $con->getAll($sql); //print_r( $data ); return $data; } function getDataSeminarJson($langid,$con,$y,$ny){ $tbl = 'TARTICLEEVENT'; $now = date("Y-m-d H:i:s"); $wheresql=getReleasedArticleSQL($now,'T1',$siteid,$langid,$arttype); $wheresql2="$wheresql AND T1.ARTDATE>='$y-01-01' AND T1.ARTDATE<'$y-12-31'"; $sql="SELECT T1.* ". ",TS.NAME AS SITENAME,TS.SHORTNAME AS SITESHORTNAME,TS.ARTNAME AS SITEARTNAME". " FROM $tbl T1,TSITE TS". " WHERE ".$wheresql2. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID)". " ORDER BY T1.ARTDATE DESC,T1.ARTID DESC"; //print $sql; $data = $con->getAll($sql); //print_r( $data ); return $data; } ################################################################### # # メディア用SQL # ################################################################### //取得 function getDataMedia($langid,$con,$y,$ny){ //記事タイプ $arttype[2][0] = 4; $tbl = 'TARTICLENEWS'; $now = date("Y-m-d H:i:s"); $wheresql=getReleasedArticleSQL($now,'T1',$siteid,$langid,$arttype); $wheresql2="$wheresql AND T1.ARTDATE>='$y-04-01' AND T1.ARTDATE<'$ny-04-01'"; $sql="SELECT T1.* ". ",TS.NAME AS SITENAME,TS.SHORTNAME AS SITESHORTNAME,TS.ARTNAME AS SITEARTNAME". " FROM $tbl T1,TSITE TS". " WHERE ".$wheresql2. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID)". " ORDER BY T1.ARTDATE DESC,T1.ARTID DESC"; //print $sql; $data = $con->getAll($sql); //print_r( $data ); return $data; } function getDataMediaTop($langid,$con,$y,$ny){ $y = 2008; //記事タイプ $arttype[2][0] = 4; $tbl = 'TARTICLENEWS'; $now = date("Y-m-d H:i:s"); $wheresql=getReleasedArticleSQL($now,'T1',$siteid,$langid,$arttype); $wheresql2="$wheresql AND T1.ARTDATE>='$y-04-01' AND T1.ARTDATE<'$ny-04-01'"; $sql="SELECT T1.* ". ",TS.NAME AS SITENAME,TS.SHORTNAME AS SITESHORTNAME,TS.ARTNAME AS SITEARTNAME". " FROM $tbl T1,TSITE TS". " WHERE ".$wheresql2. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID)". " ORDER BY T1.ARTDATE DESC,T1.ARTID DESC"; //print $sql; $data = $con->getAll($sql); //print_r( $data ); return $data; } ################################################################### # # 新着情報用SQL # ################################################################### //カウント function getCountNews($lang,$con,$y,$ny){ $tbl='TARTICLENEWS'; $wheresql2=" T1.LANGID = '".$lang."' AND T1.ARTDATE>='$y-04-01' AND T1.ARTDATE<'$ny-04-01'"; $sql="SELECT COUNT(*) FROM $tbl T1 WHERE ".$wheresql2; $num = $con->getOne( $sql ); return $num; } function checkYearNewsData($y,$list){ $ny = $y+1; if( $list ){ foreach( $list as $key => $val ){ if($val["releasedttm"]>=$y.'-04-01' and $val["releasedttm"]<$ny.'-04-01'){ return true; } } } } //取得 function getDataNews($langid,$con,$y,$ny){ //記事タイプ $arttype = ""; $tbl = 'TARTICLENEWS'; $now = date("Y-m-d H:i:s"); $wheresql=getReleasedArticleSQL($now,'T1',$siteid,$langid,$arttype); $wheresql2="$wheresql AND T1.ARTDATE>='$y-04-01' AND T1.ARTDATE<'$ny-04-01'"; $sql="SELECT T1.* ". ",TS.NAME AS SITENAME,TS.SHORTNAME AS SITESHORTNAME,TS.ARTNAME AS SITEARTNAME". " FROM $tbl T1,TSITE TS". " WHERE ".$wheresql2. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID)". " ORDER BY T1.ARTDATE DESC,T1.ARTID DESC"; //print $sql; $data = $con->getAll($sql); //print_r( $data ); //print count($data); return $data; } function getDataNewsTop($langid,$con,$y,$ny){ //記事タイプ $arttype = ""; $tbl = 'TARTICLENEWS'; $now = date("Y-m-d H:i:s"); $wheresql=getReleasedArticleSQL($now,'T1',$siteid,$langid,$arttype); $wheresql2="$wheresql AND T1.ARTDATE>='$y-04-01' AND T1.ARTDATE<'$ny-04-01'"; $sql="SELECT T1.* ". ",TS.NAME AS SITENAME,TS.SHORTNAME AS SITESHORTNAME,TS.ARTNAME AS SITEARTNAME". " FROM $tbl T1,TSITE TS". " WHERE ".$wheresql2. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID)". " ORDER BY T1.ARTDATE DESC,T1.ARTID DESC LIMIT 10"; //print $sql; $data = $con->getAll($sql); //print_r( $data ); return $data; } ################################################################### # # 出版物用SQL # ################################################################### //カウント function getCountPublication($lang,$con,$y,$ny){ $tbl='TARTICLEBASE'; $wheresql2=" T1.LANGID = '".$lang."' AND T1.ARTDATE>='$y-04-01' AND T1.ARTDATE<'$ny-04-01' "; $sql="SELECT COUNT(*) FROM $tbl T1 WHERE ".$wheresql2; $num = $con->getOne( $sql ); return $num; } function getArticleListColsSQL($tbl) { $t=$tbl?"$tbl.":''; return "${t}ARTID,${t}SITEID,${t}LANGID,${t}ARTTYPE,${t}ARTSUBTYPE,${t}ARTDATE,${t}TITLE,${t}URL,${t}THUMBID"; } //取得 function getDataPublication($lang,$con,$y,$ny,$pubtype=""){ $tbl='TARTICLEBASE'; $wheresql2=" T1.LANGID = '".$lang."' AND T1.ARTDATE>='$y-04-01' AND T1.ARTDATE<'$ny-04-01' AND T1.CONFID is not NULL AND T1.DELID=0 "; if( is_numeric($pubtype)){ $wheresql2 .=" AND T1.PUBTYPE = '".$pubtype."' "; } $sql="SELECT COUNT(*) FROM $tbl T1 WHERE ".$wheresql2; $sql="SELECT ". "T1.*". ",TS.NAME AS SITENAME,TS.SHORTNAME AS SITESHORTNAME,TS.ARTNAME AS SITEARTNAME". " FROM TARTICLEPUBLISH T1,TSITE TS". " WHERE ".$wheresql2. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID) AND T1.siteid NOT IN ('general','spf','sjcff') AND T1.artid != 9013 ". " ORDER BY T1.ARTDATE DESC,T1.ARTID"; $data = $con->getAll($sql); if( $_SERVER['REMOTE_ADDR'] == "114.178.178.81"){ //print $sql; } /* } else { $tbl='TARTICLEBASE'; $wheresql2=" T1.LANGID = '".$lang."' AND T1.ARTDATE>='$y-04-01' AND T1.ARTDATE<'$ny-04-01' AND T1.siteid != 'scef' "; if( is_numeric($pubtype)){ $wheresql2 .=" AND T1.PUBTYPE = '".$pubtype."' "; } $sql="SELECT COUNT(*) FROM $tbl T1 WHERE ".$wheresql2; $sql="SELECT ". "T1.*". ",TS.NAME AS SITENAME,TS.SHORTNAME AS SITESHORTNAME,TS.ARTNAME AS SITEARTNAME". " FROM TARTICLEPUBLISH T1,TSITE TS". " WHERE ".$wheresql2. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID) AND T1.siteid NOT IN ('general','spf','sjcff') AND T1.artid != 9013 ". " ORDER BY T1.ARTDATE DESC,T1.ARTID"; $data = $con->getAll($sql); } */ //print $sql; //print_r( $data ); return $data; } function getDataPublicationSearch($lang,$con,$form,$site_id){ $now = date("Y-m-d"); // 掲載中の出版物条件 $sqltbl="TARTICLEPUBLISH T1"; $sqlwhere=getReleasedArticleSQL($now,'T1',false,$lang); // タイプで絞込み $types=false; if($form["t"]) { $a=array(); foreach($form["t"] as $key => $v) { if( is_numeric($v)){ $a[$key] = $v; } } $types = implode(",",$a); if($types) $sqlwhere.=" AND T1.PUBTYPE IN ($types)"; unset($a); } // 基金で絞込み $siteids=false; if($site_id=='spf') { if($form["s"]) { $a2=array(); foreach($form["s"] as $key => $v) { if( $v ){ $a2[$key] = "'".$v."'"; } } if($a2){ $siteids=implode(',',$a2); if($a2) $sqlwhere.=" AND T1.SITEID IN ($siteids)"; unset($a2); } else { $siteids='all'; } unset($a); } } else { $sqlwhere.=" AND T1.SITEID='".$site_id."'"; } //AND T1.siteid != 'scef' if( is_numeric($form["fy"])){ $q_fy=$form["fy"]; // 年From } if( is_numeric($form["ty"])){ $q_ty=$form["ty"]; // 年To } // 年で絞込み if($q_fy) $sqlwhere.=" AND T1.ARTDATE>='$q_fy-01-01'"; if($q_ty) $sqlwhere.=" AND T1.ARTDATE<'".($q_ty+1)."-01-01'"; $q_q=$form['q']; // 検索クエリ // クエリ文字列で絞込み if($q_q) { include_once 'libSearch.inc'; $sql.=compileQuery($q_q,'T1.FINDTEXT'); if($sql) $sqlwhere.=" AND $sql"; } $sql="SELECT T1.ARTID,T1.ORGARTID,T1.ARTDATE,T1.ARTDATESTR". ",T1.PUBTYPE,T1.TITLE,T1.AUTHOR,T1.PRICESTR,T1.BIKOU". ",T1.SITEID,TS.ARTNAME AS SITEARTNAME,TS.SHORTNAME AS SITESHORTNAME". " FROM $sqltbl,TSITE TS". " WHERE ".$sqlwhere. " AND (TS.SITEID=T1.SITEID AND TS.LANGID=T1.LANGID) AND T1.siteid NOT IN ('general','spf','sjcff','scef') AND T1.artid != 9013". " ORDER BY T1.ARTDATE DESC,T1.ARTID DESC"; $data=$con->getAll($sql); //$data = $con->getAll($sql); //print $sql; //print_r( $data ); //exit; return $data; } //英語版判定 function checkEngPubType($type){ if($type == "笹川平和財団"){ return "SPF"; } else { return "Regular"; } } function imageAdd($image_id,$img_php_dir,$img_dir,$size){ global $recnum; //print_r($recnum); global $con; $sql = " SELECT * FROM timageobj WHERE imgid = '".$image_id."' "; $data = $con->getRow($sql); //ファイル名を作成 $nm=$image_id*1; $nm.=substr(md5("obj:$image_id"),0,6); $nm.=".".$data["ext"]; if( file_exists(HOME_DIR.$img_dir.$nm)){ print ""; } else { if( file_exists(HOME_DIR."sasakawa_admin/dbfiles/".$nm)){ @copy(HOME_DIR."sasakawa_admin/dbfiles/".$nm,HOME_DIR.$img_dir.$nm); if( file_exists(HOME_DIR.$img_dir.$nm)){ print ""; } } } } //ページャー function pagerList($max_page,$now_page,$url,$form=""){ //print $max_page."|".$now_page."|".$url; global $pager; echo $pager->doIt($max_page*10); /* $url = ""; $url = explode("?",$_SERVER['REQUEST_URI']); if( $form ){ foreach( $form as $key => $val ){ if( $key != "page" ){ if( is_array($val)){ foreach($val as $k => $v ){ $ops .= "&".$key."[]=".$v; } } else { $ops .= "&".$key."=".$val; } } } } //print $ops; echo "