예제 #1
0
 /**
  * _setTextRequest
  * 
  * @param   string	$key
  * @param   string	$request
  * 
  * @return  void
  **/
 protected function _setTextRequest($key, $request)
 {
     $this->mNavi->addExtra($key, $request);
     //multiple keywords is requested by dividing space
     $reqArr = Xcck_SearchUtils::splitKeywords($request);
     if (count($reqArr) === 0) {
         return;
     }
     $cri = new CriteriaCompo();
     foreach ($reqArr as $value) {
         $cri->add(new Criteria($key, Xcck_SearchUtils::makeKeyword($value), 'LIKE'));
     }
     $this->_mCriteria->add($cri);
 }
예제 #2
0
 /**
  * fetch
  * 
  * @param   string	$dirname
  * 
  * @return  void
  **/
 public function fetch($dirname)
 {
     parent::fetch();
     $request = XCube_Root::getSingleton()->mContext->mRequest;
     if (($catId = $request->getRequest('category_id')) !== null) {
         $this->mNavi->addExtra('category_id', (int) $catId);
     }
     //show all term or show only from start to end date
     $show = $request->getRequest('show') === 'all' ? false : true;
     $status = $request->getRequest('status');
     $status = $show ? 10 : (isset($status) ? (int) $status : Lenum_Status::PUBLISHED);
     //get child category's data ?
     $child = false;
     if ($request->getRequest('child') === "all") {
         $child = true;
     } elseif ($request->getRequest('child') === "single") {
         $child = false;
     }
     $this->_mCriteria = Xcck_Utils::getListCriteria($dirname, (int) $catId, $child, $this->mSort, $status, $show);
     if (($value = $request->getRequest('page_id')) !== null) {
         $this->mNavi->addExtra('page_id', $value);
         $this->_mCriteria->add(new Criteria('page_id', $value));
     }
     if (($value = $request->getRequest('title')) !== null) {
         $this->_setTextRequest('title', $value);
     }
     if (($value = $request->getRequest('p_id')) !== null) {
         $this->mNavi->addExtra('p_id', $value);
         $this->_mCriteria->add(new Criteria('p_id', $value));
     }
     if (($value = $request->getRequest('descendant')) !== null) {
         $this->mNavi->addExtra('descendant', $value);
         $this->_mCriteria->add(new Criteria('descendant', $value));
     }
     if (($value = $request->getRequest('uid')) !== null) {
         $this->mNavi->addExtra('uid', $value);
         $this->_mCriteria->add(new Criteria('uid', $value));
     }
     if (($value = $request->getRequest('maintable_id')) !== null) {
         $this->mNavi->addExtra('maintable_id', $value);
         $this->_mCriteria->add(new Criteria('maintable_id', $value));
     }
     if (($value = $request->getRequest('status')) !== null) {
         $this->mNavi->addExtra('status', $value);
         //$this->_mCriteria->add(new Criteria('status', $value));
     }
     if (($value = $request->getRequest('posttime')) !== null) {
         $this->mNavi->addExtra('posttime', $value);
         $this->_mCriteria->add(new Criteria('posttime', $value));
     }
     if (($value = $request->getRequest('updatetime')) !== null) {
         $this->mNavi->addExtra('updatetime', $value);
         $this->_mCriteria->add(new Criteria('updatetime', $value));
     }
     //Search by keyword: search all string and text field
     if (($value = $request->getRequest('keyword')) !== null) {
         $this->mNavi->addExtra('keywords', $value);
         Xcck_SearchUtils::makeSearchCriteria($this->_mCriteria, $dirname, $value);
     }
     foreach ($this->mDefinitions as $definition) {
         $value = $request->getRequest($definition->get('field_name'));
         if (isset($value) && $value !== "") {
             if ($definition->get('field_type') == Xcck_FieldType::STRING || $definition->get('field_type') == Xcck_FieldType::TEXT) {
                 $this->_setTextRequest($definition->get('field_name'), $value);
             } else {
                 $this->mNavi->addExtra($definition->get('field_name'), $value);
                 $this->_mCriteria->add(new Criteria($definition->get('field_name'), $value));
             }
         }
     }
     if (($value = $request->getRequest('show')) !== null) {
         $this->mNavi->addExtra('show', $value);
     }
     if (($value = $request->getRequest('child')) !== null) {
         $this->mNavi->addExtra('child', $value);
     }
     if (($tags = $request->getRequest('tag')) !== null) {
         $this->_setTagRequest($tags, $dirname);
     }
     //$this->_mCriteria->addSort($this->getSort(), $this->getOrder());
 }
예제 #3
0
 /**
  * _setRequest
  * 
  * @param   Xcck_DefinitionObject    $definition
  * @param   mixed[]    $request
  * 
  * @return  void
  **/
 protected function _setRequest(Xcck_DefinitionObject $definition, $request)
 {
     if (!isset($request)) {
         return;
     }
     foreach (array_keys($request) as $key) {
         if (count($request[$key]) !== 2) {
             continue;
         }
         $value = $request[$key][0];
         $cond = (int) $request[$key][1];
         //Xcck_Cond search condition
         //set criteria
         switch ($definition->get('field_type')) {
             case Xcck_FieldType::STRING:
             case Xcck_FieldType::TEXT:
             case Xcck_FieldType::URI:
                 if ($cond === Xcck_Cond::LIKE || $cond === Xcck_Cond::NOTLIKE) {
                     $reqArr = Xcck_SearchUtils::splitKeywords($value);
                     if (count($reqArr) === 0) {
                         continue 2;
                     }
                     $cri = new CriteriaCompo();
                     foreach ($reqArr as $value) {
                         $cri->add(new Criteria($definition->get('field_name'), Xcck_SearchUtils::makeKeyword($value), Xcck_Cond::getString($cond)));
                     }
                     $this->_mCriteria->add($cri);
                 } else {
                     $this->_mCriteria->add(new Criteria($definition->get('field_name'), $value, Xcck_Cond::getString($cond)));
                 }
                 break;
             case Xcck_FieldType::DATE:
                 if ($cond === Xcck_Cond::LIKE) {
                     $this->_mCriteria->add(new Criteria($definition->get('field_name'), $this->_makeUnixtime($value, 'start'), Xcck_Cond::getString(Xcck_Cond::GE)));
                     $this->_mCriteria->add(new Criteria($definition->get('field_name'), $this->_makeUnixtime($value, 'end'), Xcck_Cond::getString(Xcck_Cond::LT)));
                 } elseif ($cond === Xcck_Cond::LE) {
                     $this->_mCriteria->add(new Criteria($definition->get('field_name'), $this->_makeUnixtime($value, 'end'), Xcck_Cond::getString(Xcck_Cond::LT)));
                 } else {
                     $this->_mCriteria->add(new Criteria($definition->get('field_name'), $this->_makeUnixtime($value, 'start'), Xcck_Cond::getString($cond)));
                 }
                 break;
             default:
                 $this->_mCriteria->add(new Criteria($definition->get('field_name'), $value, Xcck_Cond::getString($cond)));
                 break;
         }
         //set page navi
         $this->mNavi->addExtra($definition->get('field_name'), $request);
         //            $this->mNavi->addExtra(sprintf('%s[%d][%d]', $definition->get('field_name'), $key, 1), $request[$key][1]);
     }
 }