コード例 #1
0
 public function process()
 {
     $context = \CADB\Model\Context::instance();
     $this->layout = 'admin';
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     $this->fields = \CADB\Agreement::getFieldInfo(1);
     $g_cids = \CADB\Guide::getTaxonomy();
     foreach ($g_cids as $id) {
         $this->guide_taxonomy_terms[$id] = \CADB\Guide::getRelativeGuideTerm($id);
     }
     $this->taxonomy = $this->fields['taxonomy'];
     $taxonomy_cids = array();
     foreach ($this->fields['field'] as $fid => $f) {
         if ($f['table'] == 'agreement') {
             if ($f['type'] == 'taxonomy') {
                 $taxonomy_cids[] = $f['cid'];
             }
         }
     }
     if (count($taxonomy_cids)) {
         $this->taxonomy += \CADB\Taxonomy::getTaxonomy($taxonomy_cids);
     }
     $cids = array_keys($this->taxonomy);
     if ($cids) {
         $taxonomy_terms = \CADB\Taxonomy::getTaxonomyTerms($cids);
         foreach ($taxonomy_terms as $cid => $terms) {
             $this->taxonomy_terms[$cid] = \CADB\Taxonomy::makeTree($terms);
         }
     }
 }
コード例 #2
0
 public function process()
 {
     $this->params['output'] = 'json';
     $context = \CADB\Model\Context::instance();
     $fields = \CADB\Guide::getFieldInfo(1);
     if (!$this->params['id']) {
         $this->result = array('found' => false, 'error' => '모범단협 조항번호를 입력하세요');
     } else {
         $this->fields = array();
         foreach ($fields as $f => $v) {
             $this->fields[] = array('field' => 'f' . $f, 'subject' => $v['subject'], 'type' => $v['type'], 'multiple' => $v['multiple'] ? true : false, 'cid' => $v['cid']);
         }
         $this->standard = \CADB\Guide::getClause($this->params['id']);
         if (!$this->standard) {
             $this->result = array('found' => false, 'error' => '존재하지 않는 모범단협 조항입니다');
         } else {
             $this->result = array('found' => true);
             $terms = \CADB\Guide\DBM::getClauseTaxonomyTerms($this->standard['nid'], $this->standard['id']);
             $this->standard['taxonomy'] = [];
             if (is_array($terms)) {
                 $this->standard['taxonomy'] = [];
                 foreach ($terms as $t => $taxo) {
                     $this->standard['taxonomy'][] = array('tid' => $t, 'cid' => $taxo['cid'], 'name' => $taxo['name']);
                 }
             }
         }
     }
 }
コード例 #3
0
 public function process()
 {
     \CADB\Lib\importResource('app-field-edit');
     $context = \CADB\Model\Context::instance();
     $this->layout = 'admin';
     $this->taxonomy = \CADB\Taxonomy\DBM::getTaxonomyList();
     $this->fields = \CADB\Guide::getFieldInfo(0);
 }
コード例 #4
0
 public function process()
 {
     $this->params['output'] = 'json';
     $context = \CADB\Model\Context::instance();
     $fields = \CADB\Agreement::getFieldInfo(1);
     $this->fields['standard'] = array();
     $this->fields['article'] = array();
     foreach ($fields['field'] as $f => $v) {
         if ($v['table'] == 'agreement') {
             $this->fields['article'][] = array('field' => 'f' . $f, 'subject' => $v['subject'], 'type' => $v['type'], 'multiple' => $v['multiple'] ? true : false, 'cid' => $v['cid']);
         }
     }
     if ($this->params['q'] && !mb_detect_encoding($this->params['q'], 'UTF-8', true)) {
         $this->params['q'] = mb_convert_encoding($this->params['q'], 'utf-8', 'euckr');
     }
     foreach ($this->params as $k => $v) {
         if (preg_match("/^[ao]{1}[0-9]+\$/i", $k)) {
             $args[$k] = $v;
         }
     }
     if ($this->params['nid']) {
         $this->articles = \CADB\Agreement::getAgreement($this->params['nid'], $this->params['did'] ? $this->params['did'] : 0, $this->params['q'], $args);
         if (\CADB\Privilege::checkAgreement($this->articles)) {
             $this->articles['owner'] = 1;
         } else {
             $this->articles['owner'] = 0;
         }
         if ($this->articles) {
             $this->result = array('found' => true);
         } else {
             $this->result = array('found' => false, 'error' => '존재하지 않는 단협입니다.');
         }
     } else {
         if (!$this->params['page']) {
             $this->params['page'] = 1;
         }
         $this->standard = array();
         if ($this->params['mode'] == 'init') {
             $nid = \CADB\Guide::getCurrent($this->params['nid'] ? $this->params['nid'] : 1);
             $taxonomys = \CADB\Guide::getTaxonomy($nid);
             foreach ($this->params as $k => $v) {
                 if (preg_match("/^a[0-9]+\$/i", $k) && in_array((int) substr($k, 1), $taxonomys)) {
                     $g_args[$k] = $v;
                 }
             }
             $this->standard = \CADB\Guide::getList($this->params['q'], $g_args);
             $this->result['standard'] = array('q' => $this->params['q'], 'taxonomy' => $args, 'count' => @count($this->standard) > 0 ? @count($this->standard) : 0);
         }
         $total_cnt = \CADB\Agreement::totalCnt($this->params['q'], $args);
         $total_page = (int) (($total_cnt - 1) / ($this->params['limit'] ? $this->params['limit'] : 20)) + 1;
         if ($total_cnt && $this->params['page'] <= $total_page) {
             $this->articles = \CADB\Agreement::getList($this->params['q'], $this->params['page'], $this->params['limit'] ? $this->params['limit'] : 20, $args);
             $this->result['articles'] = array('total_cnt' => $total_cnt, 'total_page' => $total_page, 'page' => $this->params['page'], 'count' => @count($this->articles));
         } else {
             $this->result['articles'] = array('total_cnt' => $total_cnt, 'total_page' => $total_page, 'page' => $this->params['page'], 'count' => 0, 'error' => '검색결과가 없습니다.');
         }
     }
 }
コード例 #5
0
 public static function getClauses($nid)
 {
     $dbm = \CADB\DBM::instance();
     $que = "SELECT id,parent,idx,subject FROM {guide_clause} WHERE nid = " . $nid . " ORDER BY parent ASC, idx ASC";
     $_clauses = array();
     while ($row = $dbm->getFetchArray($que)) {
         $clauses[] = \CADB\Guide::fetchGuideClause($row);
     }
     return $clauses;
 }
コード例 #6
0
 public function process()
 {
     $context = \CADB\Model\Context::instance();
     if (!$this->params['nid']) {
         Error('단체협약서 번호를 입력하세요.');
     }
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     $this->fields = \CADB\Agreement::getFieldInfo(1);
     $this->articles = \CADB\Agreement::getAgreement($this->params['nid'], $this->params['did'] ? $this->params['did'] : 0);
     if (!$this->articles) {
         Error('존재하지 않는 단체협약입니다.');
     }
     if (\CADB\Privilege::checkAgreement($this->articles) == false) {
         Error('접근 권한이 없습니다.');
     }
     $g_cids = \CADB\Guide::getTaxonomy();
     foreach ($g_cids as $id) {
         $this->guide_taxonomy_terms[$id] = \CADB\Guide::getRelativeGuideTerm($id);
     }
     $this->taxonomy = $this->fields['taxonomy'];
     $taxonomy_cids = array();
     foreach ($this->fields['field'] as $fid => $f) {
         if ($f['table'] == 'agreement') {
             if ($f['type'] == 'taxonomy') {
                 $taxonomy_cids[] = $f['cid'];
             }
         }
     }
     if (count($taxonomy_cids)) {
         $this->taxonomy += \CADB\Taxonomy::getTaxonomy($taxonomy_cids);
     }
     $cids = array_keys($this->taxonomy);
     if ($cids) {
         $taxonomy_terms = \CADB\Taxonomy::getTaxonomyTerms($cids);
         foreach ($taxonomy_terms as $cid => $terms) {
             $this->taxonomy_terms[$cid] = \CADB\Taxonomy::makeTree($terms);
         }
     }
     /*		ob_start();
     		$theme_html_file = "";
     		if($this->themes) {
     			$theme_html_file = CADB_PATH."/themes/".$this->themes."/articles/pdf.html.php";
     			if($theme_html_file && file_exists($theme_html_file)) {
     				include $theme_html_file;
     			} else {
     				include dirname(__FILE__)."/pdf.html.php";
     			}
     		} else {
     			include dirname(__FILE__)."/pdf.html.php";
     		}
     		$content = ob_get_contents();
     		ob_end_clean(); */
 }
コード例 #7
0
 public static function getFieldInfo($active = 1)
 {
     if (!self::$fields['field']) {
         self::$fields['field'] = \CADB\Fields::getFields(array('organize', 'agreement'), $active);
     }
     if (!self::$fields['taxonomy']) {
         $cids = \CADB\Guide::getTaxonomy(1);
         self::setTaxonomy($cids);
     }
     return self::$fields;
 }
コード例 #8
0
 public function process()
 {
     $this->params['output'] = 'json';
     $context = \CADB\Model\Context::instance();
     $fields = \CADB\Guide::getFieldInfo(1);
     if ($this->params['q'] && !mb_detect_encoding($this->params['q'], 'UTF-8', true)) {
         $this->params['q'] = mb_convert_encoding($this->params['q'], 'utf-8', 'euckr');
     }
     $nid = \CADB\Guide::getCurrent($this->params['nid'] ? $this->params['nid'] : 1);
     if ($this->params['id'] || $this->params['tid']) {
         $this->fields = array();
         foreach ($fields as $f => $v) {
             $this->fields[] = array('field' => 'f' . $f, 'subject' => $v['subject'], 'type' => $v['type'], 'multiple' => $v['multiple'] ? true : false, 'cid' => $v['cid']);
         }
         if ($this->params['id']) {
             $this->standard = \CADB\Guide::getClause($this->params['id']);
         } else {
             if ($this->params['tid']) {
                 $this->standard = \CADB\Guide::getClauseByTaxonomy($this->params['tid']);
             }
         }
         if ($this->standard) {
             $this->result = array('found' => true);
         } else {
             $this->result = array('found' => false, 'error' => '존재하지 모범단협 조항입니다.');
         }
         $this->indexes = array();
         if ($this->params['mode'] == 'init') {
             $clauses = \CADB\Guide::getClauses();
             foreach ($clauses as $i => $cl) {
                 if (!$cl['parent']) {
                     $cl['nsubs'] = 0;
                     $cl['articles'] = array();
                     $this->indexes[$i] = $cl;
                     $index_map[$cl['id']] = $i;
                 } else {
                     $idx = $index_map[$cl['parent']];
                     $this->indexes[$idx]['articles'][] = $cl;
                     $this->indexes[$idx]['nsubs']++;
                 }
             }
         }
     } else {
         $taxonomys = \CADB\Guide::getTaxonomy($nid);
         foreach ($this->params as $k => $v) {
             if (preg_match("/^a[0-9]+\$/i", $k) && in_array((int) substr($k, 1), $taxonomys)) {
                 $args[$k] = $v;
             }
         }
         $this->standard = \CADB\Guide::getList($this->params['q'], $args);
         $this->result = array('standards' => array('q' => $this->params['q'], 'taxonomy' => $args, 'count' => @count($this->standard) > 0 ? @count($this->standard) : 0));
     }
 }
コード例 #9
0
 public function process()
 {
     $context = \CADB\Model\Context::instance();
     \CADB\Lib\importResource('app-guide-edit');
     $this->layout = 'admin';
     if (!$this->params['nid']) {
         \CADB\Lib\Error('모범단체협약서 번호를 입력하세요.');
     }
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     $this->fields = \CADB\Guide::getFieldInfo(1);
     $this->guide = \CADB\Guide\DBM::getGuide($this->params['nid']);
     if (!$this->guide) {
         \CADB\Lib\Error('존재하지않는 모범단체협약서입니다.');
     }
     $this->taxonomylist = \CADB\Taxonomy\DBM::getTaxonomyList();
     $taxonomys = \CADB\Guide\DBM::getTaxonomy($this->guide['cid']);
     $this->taxonomy = \CADB\Taxonomy::getTaxonomy($taxonomys);
     $taxonomy_terms = \CADB\Taxonomy::getTaxonomyTerms($taxonomys);
     foreach ($taxonomy_terms as $c => $taxo) {
         foreach ($taxo as $t => $term) {
             $this->taxonomy_terms[$c][$term['parent']][$t] = $term;
         }
     }
     $this->current_taxonomys = $taxonomys;
     $clauses = \CADB\Guide\DBM::getClauses($this->params['nid']);
     $c = 0;
     foreach ($clauses as $i => $cl) {
         if (!$c) {
             $this->preamble = \CADB\Guide::getClause($cl['id']);
         }
         if (!$cl['parent']) {
             $cl['nsubs'] = 0;
             $cl['articles'] = array();
             $this->indexes[$i] = $cl;
             $index_map[$cl['id']] = $i;
         } else {
             $idx = $index_map[$cl['parent']];
             $this->indexes[$idx]['articles'][] = $cl;
             $this->indexes[$idx]['nsubs']++;
         }
         $c++;
     }
     if ($this->preamble) {
         $this->preamble['terms'] = \CADB\Guide\DBM::getClauseTerms($this->guide['vid'], $this->preamble['id']);
     }
 }
コード例 #10
0
 private function makeItem($item)
 {
     switch ($item['option']) {
         case 'taxonomy':
             $cids = \CADB\Guide::getTaxonomy();
             $taxonomy = \CADB\Taxonomy::getTaxonomy($item['id']);
             $item['name'] = $taxonomy[$item['id']]['subject'];
             if (in_array($item['id'], $cids)) {
                 $taxonomy_terms = \CADB\Guide::getRelativeGuideTerm($item['id']);
             } else {
                 $taxonomy_terms = \CADB\Taxonomy::getTaxonomyTerms($item['id']);
             }
             $item['options'] = array();
             $taxonomy_list = \CADB\Taxonomy::makeTree($taxonomy_terms[$item['id']]);
             foreach ($taxonomy_list as $term) {
                 $item['options'][] = array('name' => $term['name'], 'depth' => $term['depth'], 'parent' => $term['parent'], 'nsubs' => $term['nsubs'], 'value' => $term['tid']);
             }
             break;
         case 'field':
             if (!$fields) {
                 $fields = \CADB\Fields::getFields('all');
             }
             if ($fields[$item['id']]) {
                 $item['name'] = $fields[$item['id']]['subject'];
                 switch ($fields[$item['id']]['type']) {
                     case 'taxonomy':
                         $taxonomy_terms = \CADB\Taxonomy::getTaxonomyTerms($fields[$item['id']]['cid']);
                         $item['options'] = array();
                         $taxonomy_list = \CADB\Taxonomy::makeTree($taxonomy_terms[$fields[$item['id']]['cid']]);
                         foreach ($taxonomy_list as $term) {
                             $item['options'][] = array('name' => $term['name'], 'depth' => $term['depth'], 'parent' => $term['parent'], 'nsubs' => $term['nsubs'], 'value' => $term['tid']);
                         }
                         break;
                     case 'int':
                         if ($fields[$item['id']]['table'] == 'organize') {
                         }
                         break;
                     default:
                         break;
                 }
                 $item['multiple'] = $fields[$item['id']]['multiple'];
             }
             break;
     }
     return $item;
 }
コード例 #11
0
 private function validateClause()
 {
     if ($this->params['mode'] != 'add') {
         if (!$this->params['id']) {
             \CADB\RespondJson::ResultPage(array(-1, '모범단협 조항번호를 지정하세요'));
         }
         $this->clause = \CADB\Guide::getClause($this->params['id']);
         if (!$this->clause) {
             \CADB\RespondJson::ResultPage(array(-1, '존재하지 않는 모범단협 조항번호입니다'));
         }
     }
     if ($this->params['mode'] != 'delete') {
         if (!$this->params['subject']) {
             \CADB\RespondJson::ResultPage(array(-2, '모범단협 조항제목을 입력하세요'));
         }
     }
 }
コード例 #12
0
 public function process()
 {
     $context = \CADB\Model\Context::instance();
     $this->layout = 'admin';
     if (!$this->params['nid']) {
         \CADB\Lib\Error('단체협약서 번호를 입력하세요.');
     }
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     $this->fields = \CADB\Agreement::getFieldInfo(1);
     $this->articles = \CADB\Agreement::getAgreement($this->params['nid'], $this->params['did'] ? $this->params['did'] : 0);
     if (!$this->articles) {
         \CADB\Lib\Error('존재하지 않는 단체협약입니다.');
     }
     if (\CADB\Privilege::checkAgreement($this->articles) == false) {
         \CADB\Lib\Error('접근 권한이 없습니다.');
     }
     $g_cids = \CADB\Guide::getTaxonomy();
     foreach ($g_cids as $id) {
         $this->guide_taxonomy_terms[$id] = \CADB\Guide::getRelativeGuideTerm($id);
     }
     $this->taxonomy = $this->fields['taxonomy'];
     $taxonomy_cids = array();
     foreach ($this->fields['field'] as $fid => $f) {
         if ($f['table'] == 'agreement') {
             if ($f['type'] == 'taxonomy') {
                 $taxonomy_cids[] = $f['cid'];
             }
         }
     }
     if (count($taxonomy_cids)) {
         $this->taxonomy += \CADB\Taxonomy::getTaxonomy($taxonomy_cids);
     }
     $cids = array_keys($this->taxonomy);
     if ($cids) {
         $taxonomy_terms = \CADB\Taxonomy::getTaxonomyTerms($cids);
         foreach ($taxonomy_terms as $cid => $terms) {
             $this->taxonomy_terms[$cid] = \CADB\Taxonomy::makeTree($terms);
         }
     }
 }
コード例 #13
0
 public function process()
 {
     $this->layout = 'admin';
     $context = \CADB\Model\Context::instance();
     if (!($rdb = $context->getProperty('service.redis'))) {
         \CADB\Lib\Error("자동완성 기능이 활성화 되어 있지 않습니다.");
     }
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     $nid = \CADB\Guide::getCurrent();
     $cids = \CADB\Guide::getTaxonomy();
     $guide_taxonomy = \CADB\Taxonomy::getTaxonomy($cids);
     $fields = \CADB\Fields\DBM::searchField('autocomplete', 1);
     $field_cids = array();
     $this->fields = array();
     if (is_array($fields)) {
         foreach ($fields as $f) {
             switch ($f['type']) {
                 case 'taxonomy':
                     $field_cids[] = $f['cid'];
                     break;
                 case 'char':
                 case 'text':
                     $this->fields[] = $f;
                     break;
             }
         }
     }
     if (count($field_cids)) {
         $field_taxonomy = \CADB\Taxonomy::getTaxonomy($field_cids);
         $this->taxonomy = array_merge($guide_taxonomy, $field_taxonomy);
     } else {
         $this->taxonomy = $guide_taxonomy;
     }
 }
コード例 #14
0
 public static function modify($fields, $articles, $args)
 {
     $dbm = \CADB\DBM::instance();
     self::$fields = $fields;
     $que = "SELECT * FROM {agreement_organize} WHERE nid = " . $articles['nid'] . " AND did = " . $articles['did'];
     $old_orgs = array();
     while ($row = $dbm->getFetchArray($que)) {
         $old_orgs[$row['oid']] = $row;
     }
     $que = "UPDATE {agreement} SET `subject` = ?, `content` = ?";
     $array1 = 'array("ss';
     $array2 = '$' . "args['subject'], " . '$' . "args['content']";
     foreach ($args as $k => $v) {
         if (substr($k, 0, 1) == 'f') {
             $key = (int) substr($k, 1);
             switch (self::$fields[$key]['iscolumn']) {
                 case 1:
                     $que .= ", `" . $k . "` = ?";
                     $array2 .= ', $' . "args['" . $k . "']";
                     switch (self::$fields[$key]['type']) {
                         case 'int':
                             $array1 .= 'd';
                             break;
                         default:
                             $array1 .= 's';
                             break;
                     }
                     break;
                 case 0:
                     switch (self::$fields[$key]['type']) {
                         case 'taxonomy':
                             $cid = self::$fields[$key]['cid'];
                             if (is_array($articles['f' . $key]) && count($articles['f' . $key])) {
                                 foreach ($articles['f' . $key] as $terms) {
                                     $terms['fid'] = $key;
                                     $old_terms[$cid][$terms['tid']] = $terms;
                                 }
                             }
                             if (is_array($v)) {
                                 foreach ($v as $t) {
                                     $cid = $t['cid'];
                                     $custom[$key][$t['tid']] = array('cid' => $t['cid'], 'vid' => $t['vid'], 'name' => $t['name']);
                                     $new_terms[$cid][$t['tid']] = $t;
                                     if (!$old_terms[$cid][$t['tid']]) {
                                         $taxonomy_map[$cid]['add'][$t['tid']] = array('nid' => $args['nid'], 'did' => $args['did'], 'vid' => $t['vid'], 'fid' => $key);
                                     }
                                 }
                             }
                             if (count($old_terms[$cid]) > 0) {
                                 foreach ($old_terms[$cid] as $ot => $ov) {
                                     if (!$new_terms[$cid][$ot]) {
                                         $taxonomy_map[$cid]['delete'][$ot] = $ov;
                                     }
                                 }
                             }
                             break;
                         case 'organize':
                             if (is_array($v)) {
                                 $custom[$key] = array();
                                 foreach ($v as $t) {
                                     $custom[$key][] = array('oid' => $t['oid'], 'vid' => $t['vid'] ? $t['vid'] : $t['oid'], 'owner' => $t['owner'] ? 1 : 0, 'name' => $t['name']);
                                     if ($t['oid']) {
                                         if (!$old_orgs[$t['oid']]) {
                                             $organize_map[$t['oid']] = array('oid' => $t['oid'], 'vid' => $t['vid'] ? $t['vid'] : $t['oid'], 'owner' => $t['owner'] ? 1 : 0);
                                         } else {
                                             $old_orgs[$t['oid']]['matched'] = 1;
                                             if ($old_orgs[$t['oid']]['owner'] != $t['owner']) {
                                                 $old_orgs[$t['oid']]['change_owner'] = 1;
                                                 $old_orgs[$t['oid']]['new_owner'] = $t['owner'];
                                             }
                                             if ($old_orgs[$t['oid']]['vid'] != $t['vid']) {
                                                 $old_orgs[$t['oid']]['change_vid'] = 1;
                                                 $old_orgs[$t['oid']]['new_vid'] = $t['vid'];
                                             }
                                         }
                                     }
                                 }
                             }
                             break;
                         default:
                             $custom[$key] = $v;
                             break;
                     }
                     break;
                 default:
                     break;
             }
             /* end of switch */
         }
     }
     $que .= ", `custom` = ? WHERE `nid` = ? AND `did` = ?";
     $array1 .= 'sdd",';
     $array2 .= ", serialize(" . '$' . "custom), " . '$' . "args['nid'], " . '$' . "args['did'])";
     $eval_str = '$' . "q_args = " . $array1 . $array2 . ";";
     eval($eval_str);
     $dbm->execute($que, $q_args);
     self::$log = "단체협약: " . $args['subject'] . " 을 수정했습니다.";
     self::reBuildTaxonomy($articles['nid'], $articles['did'], $taxonomy_map);
     self::reBuildOrganize($articles['nid'], $articles['did'], $organize_map, $old_orgs);
     $guide_cids = \CADB\Guide::getTaxonomy();
     foreach ($guide_cids as $cid) {
         self::reBuildGuideTaxonomy($cid, $articles['nid'], $args['guide']);
     }
     \CADB\Log::articleLog('insert', $articles['nid'], $articles['did'], self::$log);
     return $args['nid'];
 }
コード例 #15
0
 public function process()
 {
     $this->params['output'] = 'json';
     $context = \CADB\Model\Context::instance();
     $fields = \CADB\Fields::getFields('all', 1);
     $this->fields = array();
     foreach ($fields as $f => $v) {
         if (!$this->fields[$v['table']]) {
             $this->fields[$v['table']] = array();
         }
         $this->fields[$v['table']][] = array('field' => 'f' . $f, 'subject' => $v['subject'], 'type' => $v['type'], 'multiple' => $v['multiple'] ? true : false, 'cid' => $v['cid']);
     }
     $this->fields['owner'][] = array('field' => 'owner', 'subject' => '운영자', 'type' => 'int', 'multiple' => false);
     $this->fields['organize'][] = array('field' => 'nid', 'subject' => '단체협약', 'type' => 'int', 'multiple' => true);
     $nid = \CADB\Guide::getCurrent($this->params['nid'] ? $this->params['nid'] : 1);
     foreach ($this->params as $k => $v) {
         if (preg_match("/^[ao]{1}[0-9]+\$/i", $k)) {
             $args[$k] = $v;
         }
     }
     if ($this->params['q'] && !mb_detect_encoding($this->params['q'], 'UTF-8', true)) {
         $this->params['q'] = mb_convert_encoding($this->params['q'], 'utf-8', 'euckr');
     }
     $this->params['page'] = 1;
     /* organize search */
     $organize_total_cnt = \CADB\Organize::totalCnt($this->params['q'], $args);
     $organize_total_page = (int) (($organize_total_cnt - 1) / ($this->params['limit'] ? $this->params['limit'] : 10)) + 1;
     if ($organize_total_cnt) {
         $this->organize = \CADB\Organize::getList($this->params['q'], 1, $this->params['limit'] ? $this->params['limit'] : 10, $args);
         for ($i = 0; $i < count($this->organize); $i++) {
             if (\CADB\Privilege::checkOrganizes($this->organize[$i])) {
                 $this->organize[$i]['owner'] = 1;
             } else {
                 $this->organize[$i]['owner'] = 0;
             }
             $this->organize[$i]['nid'] = array();
             $agreement = \CADB\Agreement::getAgreementsByOid($this->organize[$i]['oid'], $this->organize[$i]['vid']);
             if ($agreement && is_array($agreement)) {
                 foreach ($agreement as $ag) {
                     $this->organize[$i]['nid'][] = array('nid' => $ag['nid'], 'did' => $ag['did'], 'subject' => $ag['subject']);
                 }
             }
         }
         $this->result['orgs'] = array('total_cnt' => $organize_total_cnt, 'total_page' => $organize_total_page, 'count' => @count($this->organize), 'more' => $organize_total_cnt > @count($this->organize) ? 1 : 0);
     } else {
         $this->result['orgs'] = array('total_cnt' => 0, 'total_page' => 0, 'count' => 0, 'more' => 0, 'error' => '검색결과가 없습니다.');
     }
     /* standard guide */
     $taxonomys = \CADB\Guide::getTaxonomy($nid);
     foreach ($this->params as $k => $v) {
         if (preg_match("/^a[0-9]+\$/i", $k) && in_array((int) substr($k, 1), $taxonomys)) {
             $g_args[$k] = $v;
         }
     }
     $this->standard = \CADB\Guide::getList($this->params['q'], $g_args);
     $this->result['standard'] = array('q' => $this->params['q'], 'taxonomy' => $args, 'count' => @count($this->standard) > 0 ? @count($this->standard) : 0);
     /* articles */
     \CADB\Agreement::setTaxonomy($taxonomys);
     $total_cnt = \CADB\Agreement::totalCnt($this->params['q'], $args);
     $total_page = (int) (($total_cnt - 1) / ($this->params['limit'] ? $this->params['limit'] : 10)) + 1;
     if ($total_cnt) {
         $this->articles = \CADB\Agreement::getList($this->params['q'], 1, $this->params['limit'] ? $this->params['limit'] : 10, $args);
         $this->result['articles'] = array('total_cnt' => $total_cnt, 'total_page' => $total_page, 'count' => @count($this->articles), 'more' => $total_cnt > @count($this->articles) ? 1 : 0);
     } else {
         $this->result['articles'] = array('total_cnt' => 0, 'total_page' => 0, 'count' => 0, 'more' => 0, 'error' => '검색결과가 없습니다.');
     }
 }
コード例 #16
0
 public function process()
 {
     $this->output = 'json';
     $context = \CADB\Model\Context::instance();
     if (!($rdb = $context->getProperty('service.redis'))) {
         \CADB\RespondJson::ResultPage(array(-1, '자동완성 기능이 활성화 되어 있지 않습니다.'));
     }
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     $nid = \CADB\Guide::getCurrent();
     $cids = \CADB\Guide::getTaxonomy();
     $guide_taxonomy = \CADB\Taxonomy::getTaxonomy($cids);
     $fields = \CADB\Fields\DBM::searchField('autocomplete', 1);
     $field_cids = array();
     $this->fields = array();
     if (is_array($fields)) {
         foreach ($fields as $fid => $f) {
             switch ($f['type']) {
                 case 'taxonomy':
                     $field_cids[] = $f['cid'];
                     break;
                 case 'char':
                     $this->fields[$f['table']][$fid] = $f;
                     break;
             }
         }
     }
     if (count($field_cids)) {
         $field_taxonomy = \CADB\Taxonomy::getTaxonomy($field_cids);
         $this->taxonomy = array_merge($guide_taxonomy, $field_taxonomy);
     } else {
         $this->taxonomy = $guide_taxonomy;
     }
     if (is_array($this->taxonomy) && @count($this->taxonomy)) {
         $txcids = array();
         foreach ($this->taxonomy as $cid => $tx) {
             $txcids[] = $cid;
         }
         $this->taxonomy_terms = \CADB\Taxonomy::getTaxonomyTerms($txcids);
         foreach ($this->taxonomy_terms as $cid => $taxo_terms) {
             foreach ($taxo_terms as $tid => $terms) {
                 $this->buildAutocomplete($terms['name'], $terms['name'], 20);
             }
         }
     }
     \CADB\Organize::setMode('admin');
     $total_cnt = \CADB\Organize::totalCnt('', null);
     $orgs = \CADB\Organize::getList('', -1, 0, null);
     for ($i = 0; $i < $total_cnt; $i++) {
         $row = $orgs[$i];
         if ($row['nojo']) {
             $nojo = trim($row['nojo']);
             $this->buildAutocomplete($nojo, $nojo, 15);
             $this->spaceBuildAutocomplete($nojo, $nojo, 15);
             if (preg_match("/^전국/i", $nojo)) {
                 $nojo2 = preg_replace("/^전국/i", "", trim($nojo));
                 $this->buildAutocomplete($nojo2, $nojo, 15);
                 $this->spaceBuildAutocomplete($nojo2, $nojo, 15);
             }
         }
         for ($s = 1; $s <= 4; $s++) {
             $score = 15 - $s * 3;
             if ($row['sub' . $s]) {
                 $name = trim($row['sub' . $s]);
                 $this->buildAutocomplete($name, $name, $score);
                 $this->spaceBuildAutocomplete($name, $name, $score);
             }
         }
         if (is_array($this->fields['organize'])) {
             foreach ($this->fields['organize'] as $fid => $f) {
                 if ($row['f' . $fid]) {
                     $v = explode(",", $row['f' . $fid]);
                     for ($k = 0; $k < @count($v); $k++) {
                         $name = trim($v[$k]);
                         $this->buildAutocomplete($name, $name, 1);
                         $this->spaceBuildAutocomplete($name, $name, 1);
                     }
                 }
             }
         }
     }
     if (is_array($this->fields)) {
         foreach ($this->fields as $table => $fieldlist) {
             if ($table == 'organize') {
                 continue;
             }
         }
     }
     $this->remakeRedis();
 }