示例#1
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]);
     }
 }
示例#2
0
 /**
  * make selectbox options tag about search condition
  * 
  * @param   Xcck_DefinitionObject   $def
  * @param   int     $num
  * @param   Enum[]   $conditions    list of Xcck_Cond
  * @param   Enum     $selected    selected condition
  * 
  * @return  string
  **/
 public static function makeCondSelector(Xcck_DefinitionObject $def, $num, $conditions, $selected)
 {
     $optionTag = '<option value="%s"%s>%s</option>' . "\n";
     $html = sprintf('<select name="%s[%d][1]">', $def->getShow('field_name'), $num);
     foreach ($conditions as $cond) {
         $selectedTag = $cond === $selected ? 'selected="selected"' : null;
         $html .= sprintf($optionTag, $cond, $selectedTag, Xcck_Cond::getString($cond));
     }
     $html .= '</select>';
     return $html;
 }
示例#3
0
    /**
     * _getGMapScript
     * 
     * @param   void
     * 
     * @return  String
     **/
    protected function _getGMapScript(Xcck_DefinitionObject $field, $lat = null, $lon = null)
    {
        //[0]default latitude, [1]default longitude, [2]zoom
        $options = $field->getOptions();
        $latitude = isset($lat) ? $lat : $options[0];
        $longitude = isset($lng) ? $lng : $options[1];
        $prefix = $field->getDirname() . '_' . $field->getShow('field_name');
        return sprintf('
var %s_Latlng = new google.maps.LatLng(%s, %s);
var %s_Options = {
  zoom: %d,
  center: %s_Latlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};
var markerObj = new google.maps.Marker({ 
    position: %s_Latlng, 
    draggable: true, 
    title: "marker", 
    map: %s 
}); 

var %s_map = new google.maps.Map($("#%s_map").get(0), %s_Options);', $prefix, $latitude, $longitude, $prefix, $options[2], $prefix, $prefix, $prefix . '_map', $prefix, $prefix, $prefix);
    }