本文整理汇总了PHP中FieldManager::fetchFieldsSchema方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldManager::fetchFieldsSchema方法的具体用法?PHP FieldManager::fetchFieldsSchema怎么用?PHP FieldManager::fetchFieldsSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldManager
的用法示例。
在下文中一共展示了FieldManager::fetchFieldsSchema方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: grab
public function grab(array &$param_pool = NULL)
{
// remove placeholder elements
unset($this->dsParamINCLUDEDELEMENTS);
// fill with all included elements if none are set
if (is_null(REST_Entries::getDatasourceParam('included_elements'))) {
// get all fields in this section
$fields = FieldManager::fetchFieldsSchema(REST_Entries::getSectionId());
// add them to the data source
foreach ($fields as $field) {
$this->dsParamINCLUDEDELEMENTS[] = $field['element_name'];
}
// also add pagination
$this->dsParamINCLUDEDELEMENTS[] = 'system:pagination';
} else {
$this->dsParamINCLUDEDELEMENTS = explode(',', REST_Entries::getDatasourceParam('included_elements'));
}
// fill the other parameters
if (!is_null(REST_Entries::getDatasourceParam('limit'))) {
$this->dsParamLIMIT = REST_Entries::getDatasourceParam('limit');
}
if (!is_null(REST_Entries::getDatasourceParam('page'))) {
$this->dsParamSTARTPAGE = REST_Entries::getDatasourceParam('page');
}
if (!is_null(REST_Entries::getDatasourceParam('sort'))) {
$this->dsParamSORT = REST_Entries::getDatasourceParam('sort');
}
if (!is_null(REST_Entries::getDatasourceParam('order'))) {
$this->dsParamORDER = REST_Entries::getDatasourceParam('order');
}
// Do grouping
if (!is_null(REST_Entries::getDatasourceParam('groupby'))) {
$field_id = FieldManager::fetchFieldIDFromElementName(REST_Entries::getDatasourceParam('groupby'), REST_Entries::getSectionId());
if ($field_id) {
$this->dsParamGROUP = $field_id;
}
}
// if API is calling a known entry, filter on System ID only
if (!is_null(REST_Entries::getEntryId())) {
$this->dsParamFILTERS['id'] = REST_Entries::getEntryId();
} elseif (REST_Entries::getDatasourceParam('filters')) {
foreach (REST_Entries::getDatasourceParam('filters') as $field_handle => $filter_value) {
$filter_value = rawurldecode($filter_value);
$field_id = FieldManager::fetchFieldIDFromElementName($field_handle, REST_Entries::getSectionId());
if (is_numeric($field_id)) {
$this->dsParamFILTERS[$field_id] = $filter_value;
}
}
}
return $this->execute($param_pool);
}
示例2: fetchFieldsSchema
/**
* Returns the Schema of this section which includes all this sections
* fields and their settings.
*
* @return array
*/
public function fetchFieldsSchema()
{
return FieldManager::fetchFieldsSchema($this->get('id'));
}
示例3: buildEntryArray
protected function buildEntryArray($entry, $sectionId)
{
$data = array();
if ($entry != null) {
$schema = \FieldManager::fetchFieldsSchema($sectionId);
foreach ($schema as $field) {
$data[$field['element_name']] = $entry->getData($field['id']);
}
}
$data['id'] = $entry->get('id');
return $data;
}
示例4: sectionsCheckFields
/**
* Checks field data foreach Entry.
*
* @param $input
*
* @return array
*/
private function sectionsCheckFields($input)
{
$output = $input;
foreach ($output as $handle => &$section) {
// skip done sections
if ($section['done'] === true) {
continue;
}
$schema = FieldManager::fetchFieldsSchema($section['id']);
if (!is_array($schema) || empty($schema)) {
continue;
}
foreach ($section['entries'] as &$entry) {
// skip done entries
if ($entry['done'] === true) {
continue;
}
$errors = array();
$entry_status = __ENTRY_OK__;
$ignore_missing_fields = $entry['action'] === SE_Permissions::ACTION_EDIT;
foreach ($schema as $field_info) {
$field_id = $field_info['id'];
$field_name = $field_info['element_name'];
$has_data = isset($entry['fields'][$field_name]);
if ($ignore_missing_fields && !$has_data) {
continue;
}
// errors were injected by other events. Don't ask ... just use it ;)
if (is_array($entry['fields'][$field_name]) && isset($entry['fields'][$field_name]['__error'])) {
$error_code = $entry['fields'][$field_name]['__error']['code'];
$error_msg = $entry['fields'][$field_name]['__error']['message'];
$entry['orig_fields'][$field_name] = $entry['fields'][$field_name]['__value'];
$entry['fields'][$field_name] = $entry['fields'][$field_name]['__value'];
} else {
/** @var $field Field */
$field = FieldManager::fetch($field_id);
$field_data = $has_data ? $entry['fields'][$field_name] : null;
$error_code = $field->checkPostFieldData($field_data, $error_msg, $entry['entry']->get('id'));
}
if ($error_code != Field::__OK__) {
$entry_status = __ENTRY_FIELD_ERROR__;
$errors[$field_id]['code'] = $error_code;
$errors[$field_id]['message'] = $error_msg;
}
}
if ($entry_status !== __ENTRY_OK__) {
$this->error = true;
$entry['done'] = true;
$this->resultEntry($entry['res_entry'], 'error');
$this->resultFields($entry['res_fields'], $entry['fields'], $errors);
}
}
}
return $output;
}