/** * * @param type $sql * @param array $columns An array in the form Alias => Column or just Column * @return type */ function replaceSelect($sql, $columns) { if (is_string($sql)) { $parsed = parseSelect($sql); } else { $parsed = $sql; } // Set a prefix for new selects. if (isset($parsed['Star'])) { $px = $parsed['Star'] . '.'; } else { $px = ''; } $select = $parsed['Select']; $newSelect = array(); foreach ($columns as $index => $value) { if (is_numeric($index)) { $alias = $value; } else { $alias = $index; } if (isset($select[$value])) { $newSelect[$alias] = $select[$value]; } else { $newSelect[$alias] = $px . $value; } } $parsed['Select'] = $newSelect; if (is_string($sql)) { return selectString($parsed); } else { return $parsed; } }
public function getSepcSetting($v, $modelid) { $tmp = array(); if ($v['FieldInputPicker'] == 'upload') { $tmp['formtype'] = 'image'; $tmp['setting'] = array('size' => '50', 'defaultvalue' => '', 'show_type' => '1', 'upload_maxsize' => '1024', 'upload_allowext' => 'jpg|jpeg|gif|png|bmp', 'watermark' => '0', 'isselectimage' => '1', 'images_width' => '', 'images_height' => ''); return $tmp; } if ($v['FieldInputPicker'] == 'upload_attach') { $tmp['formtype'] = 'downfiles'; $tmp['setting'] = array('upload_allowext' => 'zip|rar|doc|xls|txt|jpg|gif|pdf|ppt', 'isselectimage' => '1', 'upload_number' => '10', 'downloadlink' => '1', 'downloadtype' => '1'); return $tmp; } if ($v['FieldType'] == 'contentlink') { $tmp['formtype'] = 'omnipotent'; $tmp['setting'] = array('formtext' => "<input name='info[" . $v['FieldName'] . "]' id='" . $v['FieldName'] . "' value='{FIELD_VALUE}' style='50'>\n <div>\n <input type='button' value=\"添加相关\" onclick=\"omnipotent('selectid','?m=content&c=content&a=public_relation&modelid=" . $modelid . "&relation_var=" . $v['FieldName'] . "&type=id','添加相关',1)\" class=\"button\" style=\"width:66px;\">\n </div>", 'fieldtype' => 'varchar'); $tmp['isomnipotent'] = 0; return $tmp; } if ($v['FieldInputPicker'] == 'content') { if (false === strpos(strtolower($v['FieldName']), "id")) { $type = 'title'; } else { $type = 'id'; } $tmp['formtype'] = 'omnipotent'; $tmp['setting'] = array('formtext' => "<input name='info[{$v['FieldName']}]' id='{$v['FieldName']}' value='{FIELD_VALUE}' style='50'>\n <div>\n <input type='button' value=\"添加相关\" onclick=\"omnipotent('selectid','?m=content&c=content&a=public_relation&modelid={$modelid}&relation_var={$v['FieldName']}&type={$type}','添加相关',1)\" class=\"button\" style=\"width:66px;\">\n </div>", 'fieldtype' => 'varchar'); $tmp['isomnipotent'] = 0; return $tmp; } if ($v['FieldInput'] == 'select' || $v['FieldInput'] == 'checkbox' || $v['FieldInputPicker'] == 'dsn_content') { if (!empty($v['FieldDefaultValue'])) { $default = parseSelectDefault($v['FieldDefaultValue']); } if (!empty($v['FieldDescription']) || false !== strpos($v['FieldDescription'], '<value>')) { $default = parseSelect($v['FieldDescription']); } $tmp['setting'] = array('fieldtype' => 'varchar', 'minnumber' => '1', 'width' => '80', 'size' => '1', 'defaultvalue' => '', 'outputtype' => '1'); if (!empty($default)) { $tmp['setting']['options'] = $default; } if ($v['FieldInput'] == 'select') { $tmp['setting']['boxtype'] = 'select'; } else { if ($v['FieldInput'] == 'checkbox') { $tmp['setting']['boxtype'] = 'checkbox'; } else { $tmp['setting']['boxtype'] = 'select'; } } if ($v['FieldInputPicker'] == 'dsn_content') { $tmp['formtype'] = 'box'; } else { $tmp['formtype'] = $this->field2formtype[$v['FieldInput']]; } return $tmp; } }