示例#1
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 = langCsp::_('Add Checkbox');
                 $options_tag = '';
                 $image_tag = ' style="display:none"';
                 break;
             case 9:
                 $add_option = langCsp::_('Add Item');
                 $options_tag = '';
                 $image_tag = ' style="display:none"';
                 break;
             case 12:
                 $add_option = langCsp::_('Add Item');
                 $options_tag = '';
                 $image_tag = ' style="display:none"';
                 break;
             case 10:
                 $options_tag = '';
                 $add_option = langCsp::_('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 .= fieldAdapterCsp::_($id, 'getExtraFieldOptions', fieldAdapterCsp::STR);
             $output .= '</div>';
             $output .= '<div class="options image_tag"' . $image_tag . '>' . langCsp::_('Dimensions') . ':<br />';
             $params->width ? $width = $params->width : '';
             $params->height ? $height = $params->height : '';
             $output .= langCsp::_('width') . ':<br />';
             $output .= htmlCsp::text('params[width]', array('value' => $width)) . '<br />';
             $output .= langCsp::_('height') . ':<br />';
             $output .= htmlCsp::text('params[height]', array('value' => $height)) . '<br />';
             $output .= '</div>';
         }
         if ($this->adapt['htmlParams']) {
             $output .= fieldAdapterCsp::_($this, $this->adapt['htmlParams'], fieldAdapterCsp::STR);
         } else {
             $output .= '<a href="javascript:void(0);" class="set_properties">' . langCsp::_('Click to set field "id" and "class"') . '</a>';
             $output .= '<div class="attributes" style="display:none;">' . langCsp::_('Attributes') . ':<br />';
             $output .= fieldAdapterCsp::_($params, 'getFieldAttributes', fieldAdapterCsp::STR);
             $output .= '</div>';
         }
         return $output;
     }
 }
示例#2
0
 public static function fontsList($name, $params = array('value' => ''))
 {
     static $options = array();
     if (empty($options)) {
         // Fill them only one time per loading
         foreach (fieldAdapterCsp::getFontsList() as $font) {
             $options[$font] = $font;
         }
     }
     $params['options'] = $options;
     return self::selectbox($name, $params);
 }
示例#3
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 = frameCsp::_()->getTable('states')->leftJoin(frameCsp::_()->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;
    }
示例#4
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 = fieldAdapterCsp::_($val, $this->_fields[$k]->adapt['dbTo'], fieldAdapterCsp::DB);
                 }
                 if ($validate) {
                     if (is_object($this->_fields[$k])) {
                         $objForValidation = clone $this->_fields[$k];
                         $objForValidation->setValue($val);
                         if ($errors = validatorCsp::_($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;
 }