Beispiel #1
0
    /**
     * Save this in static var - to futher usage
     * @return array with states
     */
    public static function getCachedStates($clearCache = false)
    {
        if (empty(self::$states) || $clearCache) {
            self::$states = frameBup::_()->getTable('states')->leftJoin(frameBup::_()->getTable('countries'), 'country_id')->getAll('toe_states.id,
					toe_states.name, 
					toe_states.code, 
					toe_states.country_id, 
					toe_cry.name AS c_name,
					toe_cry.iso_code_2 AS c_iso_code_2, 
					toe_cry.iso_code_3 AS c_iso_code_3');
        }
        return self::$states;
    }
Beispiel #2
0
 /**
  * Convert to database query
  * @param mixed $data if array given - convert it into string where key - is column name, value - database value to set;
  * if key == "additionalCondition" then we will just add value to string
  * if string givven - just return it without changes
  * @param string $delim delimiter to use in query, recommended - ',', 'AND', 'OR'
  * @return string query string
  */
 public function _getQueryString($data, $delim = ',', $validate = false)
 {
     $res = '';
     if (is_array($data) && !empty($data)) {
         foreach ($data as $k => $v) {
             if (array_key_exists($k, $this->_fields) || $k == $this->_id) {
                 $val = $v;
                 if ($this->_fields[$k]->adapt['dbTo']) {
                     $val = fieldAdapterBup::_($val, $this->_fields[$k]->adapt['dbTo'], fieldAdapterBup::DB);
                 }
                 if ($validate) {
                     if (is_object($this->_fields[$k])) {
                         $objForValidation = clone $this->_fields[$k];
                         $objForValidation->setValue($val);
                         if ($errors = validatorBup::_($objForValidation)) {
                             $this->_addError($errors);
                         }
                     }
                 }
                 /*if(empty($val))
                   $val = $this->_fields[$k]->default;*/
                 switch ($this->_fields[$k]->type) {
                     case 'int':
                     case 'tinyint':
                         $res .= $k . ' = ' . (int) $val . ' ' . $delim . ' ';
                         break;
                     case 'float':
                         $res .= $k . ' = ' . (double) $val . ' ' . $delim . ' ';
                         break;
                     case 'decimal':
                         $res .= $k . ' = ' . (double) $val . ' ' . $delim . ' ';
                         break;
                     case 'free':
                         //Just set it as it is
                         $res .= $k . ' = ' . $val . ' ' . $delim . ' ';
                         break;
                     default:
                         $res .= $k . ' = \'' . $val . '\' ' . $delim . ' ';
                         break;
                 }
             } elseif ($k == 'additionalCondition') {
                 //just add some string to query
                 $res .= $v . ' ' . $delim . ' ';
             }
         }
         $res = substr($res, 0, -(strlen($delim) + 1));
     } elseif (is_string($data)) {
         $res = $data;
     }
     return $res;
 }
Beispiel #3
0
 /**
  * Function to process field params
  */
 public function processParams($tag, $id)
 {
     return '';
     if ($this->name == "params") {
         if (is_array($this->value) || is_object($this->value)) {
             $params = $this->value;
         } else {
             $params = json_decode($this->value);
         }
         $add_option = '';
         switch ($tag) {
             case 5:
                 $add_option = langBup::_('Add Checkbox');
                 $options_tag = '';
                 $image_tag = ' style="display:none"';
                 break;
             case 9:
                 $add_option = langBup::_('Add Item');
                 $options_tag = '';
                 $image_tag = ' style="display:none"';
                 break;
             case 12:
                 $add_option = langBup::_('Add Item');
                 $options_tag = '';
                 $image_tag = ' style="display:none"';
                 break;
             case 10:
                 $options_tag = '';
                 $add_option = langBup::_('Add Radio Button');
                 $image_tag = ' style="display:none"';
                 break;
             case 8:
                 $image_tag = '';
                 $options_tag = ' style="display:none"';
                 break;
             default:
                 $options_tag = ' style="display:none"';
                 $image_tag = ' style="display:none"';
                 break;
         }
         if ($tag > 0 || $id == 0) {
             $output .= '<div class="options options_tag"' . $options_tag . '>';
             $output .= '<span class="add_option">' . $add_option . '</span>';
             $output .= fieldAdapterBup::_($id, 'getExtraFieldOptions', fieldAdapterBup::STR);
             $output .= '</div>';
             $output .= '<div class="options image_tag"' . $image_tag . '>' . langBup::_('Dimensions') . ':<br />';
             $params->width ? $width = $params->width : '';
             $params->height ? $height = $params->height : '';
             $output .= langBup::_('width') . ':<br />';
             $output .= htmlBup::text('params[width]', array('value' => $width)) . '<br />';
             $output .= langBup::_('height') . ':<br />';
             $output .= htmlBup::text('params[height]', array('value' => $height)) . '<br />';
             $output .= '</div>';
         }
         if ($this->adapt['htmlParams']) {
             $output .= fieldAdapterBup::_($this, $this->adapt['htmlParams'], fieldAdapterBup::STR);
         } else {
             $output .= '<a href="javascript:void(0);" class="set_properties">' . langBup::_('Click to set field "id" and "class"') . '</a>';
             $output .= '<div class="attributes" style="display:none;">' . langBup::_('Attributes') . ':<br />';
             $output .= fieldAdapterBup::_($params, 'getFieldAttributes', fieldAdapterBup::STR);
             $output .= '</div>';
         }
         return $output;
     }
 }
Beispiel #4
0
 public static function fontsList($name, $params = array('value' => ''))
 {
     static $options = array();
     if (empty($options)) {
         // Fill them only one time per loading
         foreach (fieldAdapterBup::getFontsList() as $font) {
             $options[$font] = $font;
         }
     }
     $params['options'] = $options;
     return self::selectbox($name, $params);
 }