本文整理汇总了PHP中Floxim\Floxim\System\Fx::component方法的典型用法代码示例。如果您正苦于以下问题:PHP Fx::component方法的具体用法?PHP Fx::component怎么用?PHP Fx::component使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Floxim\Floxim\System\Fx
的用法示例。
在下文中一共展示了Fx::component方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTemplateRecordAtts
public function getTemplateRecordAtts($collection, $index)
{
$entity_meta = array($this->get('id'), $this->getType(false));
$linkers = null;
if (is_object($collection) && $collection->linkers) {
$linkers = $collection->linkers;
if (isset($collection->linkers[$index])) {
$linker = $linkers[$index];
$entity_meta[] = $linker['id'];
$entity_meta[] = $linker['type'];
}
}
$entity_atts = array('data-fx_entity' => $entity_meta, 'class' => 'fx_entity' . (is_object($collection) && $collection->is_sortable ? ' fx_sortable' : ''));
if (!$this->isVisible()) {
$entity_atts['class'] .= ' fx_entity_hidden' . (!$collection || count($collection) === 1 ? '_single' : '');
}
$com = $this->getComponent();
$entity_atts['data-fx_entity_name'] = fx::util()->ucfirst($com->getItemName('one'));
$is_placeholder = $this->isAdderPlaceholder();
if ($is_placeholder) {
$entity_atts['class'] .= ' fx_entity_adder_placeholder';
}
if (isset($this['_meta'])) {
$c_meta = $this['_meta'];
if ($is_placeholder) {
$c_meta['has_page'] = $this->hasPage();
$c_meta['publish'] = $this->getDefaultPublishState();
}
$entity_atts['data-fx_entity_meta'] = $c_meta;
}
// fields to edit in panel
$att_fields = array();
$forced = $this->getForcedEditableFields();
if (is_array($forced) && count($forced)) {
foreach ($forced as $field_keyword) {
$field_meta = $this->getFieldMeta($field_keyword);
if (!is_array($field_meta)) {
continue;
}
// !!! hardcode
if ($is_placeholder && $field_keyword === 'is_published') {
$field_meta['current_value'] = $this->getDefaultPublishState();
} else {
$field_meta['current_value'] = $this[$field_keyword];
}
$att_fields[] = $field_meta;
}
}
if ($linkers && $linkers->linkedBy) {
if (!$linker) {
fx::log($collection, $linkers);
return $entity_atts;
}
$linker_field = $linker->getFieldMeta($linkers->linkedBy);
$linker_collection_field = $linkers->selectField;
if (!$is_placeholder && $linker_collection_field && $linker_collection_field['params']['content_type']) {
$linker_type = $linker_collection_field['params']['content_type'];
} else {
$linker_type = $this['type'];
$linker_field['params']['conditions'] = array(array('type', $linker_type));
}
$linker_field['params']['content_type'] = $linker_type;
$linker_field['label'] = fx::alang('Select') . ' ' . mb_strtolower(fx::component($linker_type)->getItemName('add'));
if (!$linker_collection_field || !$linker_collection_field['allow_select_doubles']) {
$linker_field['params']['skip_ids'] = array();
foreach ($collection->getValues('id') as $col_id) {
if ($col_id !== $this['id']) {
$linker_field['params']['skip_ids'][] = $col_id;
}
}
}
$linker_field['current_value'] = $linker[$linkers->linkedBy];
$att_fields[] = $linker_field;
}
if (!$this['id'] && (!$this['parent_id'] || !$this['infoblock_id']) && !$this->hasPage()) {
$att_fields = array_merge($this->getStructureFields(), $att_fields);
}
foreach ($att_fields as $field_key => $field_meta) {
$field_meta['in_att'] = true;
// real field
if (isset($field_meta['id']) && isset($field_meta['content_id'])) {
$field_keyword = $field_meta['id'] . '_' . $field_meta['content_id'];
} else {
$field_keyword = $field_key;
$field_meta['id'] = $field_key;
}
$template_field = new \Floxim\Floxim\Template\Field($field_meta['current_value'], $field_meta);
$entity_atts['data-fx_force_edit_' . $field_keyword] = $template_field->__toString();
}
return $entity_atts;
}
示例2: getChildren
public function getChildren()
{
if (!isset($this->data['children'])) {
$this->data['children'] = fx::component()->find('parent_id', $this['id']);
}
return $this->data['children'];
}
示例3: getRelation
public function getRelation()
{
if (!$this['format']['linking_field']) {
return false;
}
$direct_target_field = fx::data('field', $this['format']['linking_field']);
$direct_target_component = fx::component($this['format']['linking_datatype']);
$first_type = $direct_target_component['keyword'];
if (!isset($this['format']['mm_field']) || !$this['format']['mm_field']) {
$res_rel = array(System\Finder::HAS_MANY, $first_type, $direct_target_field['keyword']);
return $res_rel;
}
$end_target_field = fx::data('field', $this['format']['mm_field']);
$end_datatype = fx::component($this['format']['mm_datatype']);
$end_type = $end_datatype['keyword'];
return array(System\Finder::MANY_MANY, $first_type, $direct_target_field['keyword'], $end_target_field->getPropName(), $end_type, $end_target_field['keyword']);
}
示例4: whereContent
public function whereContent($content_type = null, $with_parent_types = true)
{
if ($content_type) {
$com = fx::component($content_type);
if ($with_parent_types) {
$variants = $com->getChain()->getValues('keyword');
$this->where('controller', $variants);
} else {
$this->where('controller', $com['keyword']);
}
}
$this->where('action', 'list_infoblock');
return $this;
}
示例5: deleteSave
public function deleteSave($input)
{
if (!isset($input['content_type'])) {
return;
}
$content_type = $input['content_type'];
$id = isset($input['content_id']) ? $input['content_id'] : (isset($input['id']) ? $input['id'] : false);
if (!$id) {
return;
}
$content = fx::data($content_type, $id);
if (!$content) {
return;
}
$fields = array(array('name' => 'delete_confirm', 'type' => 'hidden', 'value' => 1), $this->ui->hidden('entity', 'content'), $this->ui->hidden('action', 'delete_save'), $this->ui->hidden('content_id', $content['id']), $this->ui->hidden('fx_admin', true));
if (isset($input['content_type'])) {
$fields[] = $this->ui->hidden('content_type', $input['content_type']);
}
if (isset($input['page_id'])) {
$fields[] = $this->ui->hidden('page_id', $input['page_id']);
}
/**
* check children
*/
$alert = '';
$is_linker = $content->isInstanceOf('floxim.main.linker');
if ($is_linker) {
$linked_entity = $content['content'];
$linked_com = $linked_entity->getComponent();
$alert = '<p>' . fx::alang('Only link will be removed, not %s itself', null, $linked_com->getItemName('one'));
$linked_section = $linked_entity->getPath()->copy()->reverse()->findOne(function ($i) use($linked_entity) {
return $i->isInstanceOf('floxim.nav.section') && $i['id'] !== $linked_entity['id'];
});
if ($linked_section) {
$alert .= fx::alang(', it will be available in the %s section', null, $linked_section['name']);
}
$alert .= '</p>';
//fx::log($linked_entity->getPath());
} elseif ($content->isInstanceOf('floxim.main.content')) {
$all_descendants = fx::data('content')->descendantsOf($content)->all()->group('type');
$type_parts = array();
foreach ($all_descendants as $descendants_type => $descendants) {
if ($descendants_type === 'floxim.main.linker') {
continue;
}
$descendants_com = fx::component($descendants_type);
$type_parts[] = count($descendants) . ' ' . fx::util()->getDeclensionByNumber($descendants_com['declension'], count($descendants));
}
if (count($type_parts) > 0) {
$com_name = fx::util()->ucfirst($content->getComponent()->getItemName('one'));
$alert = '<p>' . $com_name . ' содержит данные, они также будут удалены:</p>';
$alert .= '<ul><li>' . join('</li><li>', $type_parts) . '</li></ul>';
}
}
if ($alert) {
$fields[] = array('type' => 'html', 'html' => '<div class="fx_delete_alert">' . $alert . '</div>');
}
$this->response->addFields($fields);
$this->response->addFormButton(array('key' => 'save', 'class' => 'delete', 'label' => fx::alang('Delete')));
if (isset($input['delete_confirm']) && $input['delete_confirm']) {
$response = array('status' => 'ok');
$c_page = fx::env('page');
if ($c_page) {
$c_path = $c_page->getPath();
$content_in_path = $c_path->findOne('id', $content['id']);
if ($content_in_path) {
$response['reload'] = $content_in_path['parent'] ? $content_in_path['parent']['url'] : '/';
}
}
$content->delete();
return $response;
}
$component = fx::data('component', $content_type);
if ($is_linker) {
$com_name = $linked_com->getItemName('add');
} else {
$com_name = $component->getItemName('add');
}
$header = $is_linker ? fx::alang('delete_from_list') : fx::alang("Delete");
$header .= ' ' . mb_strtolower($com_name);
if ($content_name = $content['name']) {
$content_name = strip_tags($content_name);
$content_name = trim($content_name);
$header .= ' «' . $content_name . '»';
} elseif ($is_linker) {
$header .= ' ' . fx::alang('from this list');
}
$header .= "?";
$res = array('header' => $header);
return $res;
}
示例6: getTargetName
public function getTargetName()
{
$rel_target_id = $this['format']['target'];
if (!is_numeric($rel_target_id)) {
$rel_target = $rel_target_id;
} else {
$rel_target = fx::component($rel_target_id)->get('keyword');
}
return $rel_target;
}
示例7: setStatement
protected function setStatement($data)
{
$res = array();
$chain = fx::component($this->component_id)->getChain();
foreach ($chain as $level_component) {
$table_res = array();
$fields = $level_component->fields();
$field_keywords = $fields->getValues('keyword');
// while the underlying field content manually prescription
if ($level_component['keyword'] == 'floxim.main.content') {
$field_keywords = array_merge($field_keywords, array('priority', 'last_updated', 'type', 'infoblock_id', 'materialized_path', 'level'));
}
$table_name = $level_component->getContentTable();
$table_cols = $this->getColumns($table_name);
foreach ($field_keywords as $field_keyword) {
if (!in_array($field_keyword, $table_cols)) {
continue;
}
$field = $fields->findOne('keyword', $field_keyword);
// put only if the sql type of the field is not false (e.g. multilink)
if ($field && !$field->getSqlType()) {
continue;
}
//if (isset($data[$field_keyword]) ) {
if (array_key_exists($field_keyword, $data)) {
$field_val = $data[$field_keyword];
$sql_val = is_null($field_val) ? 'NULL' : "'" . fx::db()->escape($field_val) . "'";
$table_res['`' . fx::db()->escape($field_keyword) . '`'] = $sql_val;
}
}
if (count($table_res) > 0) {
$res[$table_name] = $table_res;
}
}
return $res;
}
示例8: acceptContent
public function acceptContent($params, $entity = null)
{
$params = array_merge(array('infoblock_id' => $this->getParam('infoblock_id'), 'type' => $this->getContentType()), $params);
$component = fx::component($params['type']);
$has_title = isset($params['title']);
if (!$has_title) {
$params['title'] = fx::alang('Add') . ' ' . $component->getItemName('add');
}
if (!is_null($entity)) {
$meta = isset($entity['_meta']) ? $entity['_meta'] : array();
// by default add items as children of the entity
if (!isset($params['parent_id']) && !isset($params['rel_field'])) {
$params['parent_id'] = $entity['id'];
}
if (!isset($meta['accept_content'])) {
$meta['accept_content'] = array();
}
$meta['accept_content'][] = $params;
$entity['_meta'] = $meta;
} else {
if (!isset($this->_meta['accept_content'])) {
$this->_meta['accept_content'] = array();
}
$this->_meta['accept_content'][] = $params;
}
if (isset($params['with_extensions']) && $params['with_extensions']) {
$extensions = $component->getAllChildren();
foreach ($extensions as $extension) {
$e_name = $extension->getItemName('add');
$this->acceptContent(array('title' => $has_title ? $params['title'] . ' / ' . $e_name : fx::alang('Add') . ' ' . $e_name, 'type' => $extension['keyword']), $entity);
}
}
}
示例9: deleteInfoblock
public function deleteInfoblock($input)
{
$infoblock = fx::data('infoblock', $input['id']);
if (!$infoblock) {
return;
}
$controller = $infoblock->initController();
$fields = array(array('name' => 'delete_confirm', 'type' => 'hidden'), $this->ui->hidden('id', $input['id']), $this->ui->hidden('entity', 'infoblock'), $this->ui->hidden('action', 'delete_infoblock'), $this->ui->hidden('fx_admin', true));
$ib_content = $infoblock->getOwnedContent();
if ($ib_content->length > 0) {
$fields[] = array('name' => 'content_handle', 'type' => 'hidden', 'value' => 'delete');
}
$alert = '';
if (count($ib_content)) {
$ib_content_count = count($ib_content);
$ib_content_types = $ib_content->getValues('type');
$ib_content_type_count = array();
foreach ($ib_content_types as $ib_content_type) {
if (!isset($ib_content_type_count[$ib_content_type])) {
$ib_content_type_count[$ib_content_type] = 0;
}
$ib_content_type_count[$ib_content_type]++;
}
// block contains linkers only
if (count($ib_content_type_count) === 1 && $ib_content_types[0] === 'floxim.main.linker') {
$link_word = fx::util()->getDeclensionByNumber(array('ссылку', 'ссылки', 'ссылок'), $ib_content_count);
$alert = '<p>Блок содержит ' . $ib_content_count . ' ' . $link_word . ' на другие данные. ';
$alert .= $ib_content_count == 1 ? 'Эта ссылка будет удалена' : 'Эти ссылки будут удалены';
$alert .= ', а сами данные останутся.</p>';
} else {
// $ib_content_ids = $ib_content->getValues('id');
$alert = '<p>Блок содержит ';
if (count($ib_content_type_count) === 1) {
$com = fx::component($ib_content_types[0]);
$decl = $com['declension'];
$alert .= $ib_content_count . ' ';
$alert .= fx::util()->getDeclensionByNumber(array($decl['acc']['singular'], $decl['gen']['singular'], $decl['gen']['plural']), $ib_content_count);
$alert .= '</p>';
} else {
$alert .= ' данные:</p>';
$type_parts = array();
foreach ($ib_content_type_count as $ib_content_type => $c_type_count) {
$com = fx::component($ib_content_type);
$type_parts[] = $c_type_count . ' ' . fx::util()->getDeclensionByNumber($com['declension'], $c_type_count);
}
$alert .= '<ul><li>' . join('</li><li>', $type_parts) . '</li></ul>';
}
$alert .= '<p>Эти данные будут удалены.</p>';
$ids = $ib_content->getValues('id');
$nested_query = fx::data('content')->descendantsOf($ids, false)->group('type')->select('type')->select('count(*) as cnt')->showQuery();
$nested_types = fx::db()->getResults($nested_query);
if (count($nested_types) > 0) {
$type_parts = array();
foreach ($nested_types as $c_nested_type) {
if ($c_nested_type['type'] === 'floxim.main.linker') {
continue;
}
$com = fx::component($c_nested_type['type']);
$type_parts[] = $c_nested_type['cnt'] . ' ' . fx::util()->getDeclensionByNumber($com['declension'], $c_nested_type['cnt']);
}
if (count($type_parts) > 0) {
$alert .= '<p>Также будут удалены все вложенные данные:</p>';
$alert .= '<ul><li>' . join('</li><li>', $type_parts) . '</li></ul>';
}
}
}
}
$fields[] = array('name' => 'content_alert', 'type' => 'html', 'value' => '<div class="fx_delete_alert">' . $alert . '</div>');
if ($infoblock['controller'] == 'layout' && !$infoblock['parent_infoblock_id']) {
unset($fields[0]);
$fields[] = array('type' => 'html', 'html' => fx::alang('Layouts can not be deleted', 'system'));
}
$this->response->addFields($fields);
$this->response->addFormButton(array('key' => 'save', 'label' => fx::alang('Delete'), 'class' => 'delete'));
if ($input['delete_confirm']) {
$this->response->setStatusOk();
if ($ib_content) {
if ($input['content_handle'] == 'delete') {
foreach ($ib_content as $ci) {
$ci->delete();
}
} else {
foreach ($ib_content as $ci) {
$ci->set('infoblock_id', 0)->save();
}
}
}
$controller->handleInfoblock('delete', $infoblock, $input);
$infoblock->delete();
}
if ($infoblock['name']) {
$header = fx::alang('Delete infoblock', 'system');
$header .= ' «' . $infoblock['name'] . '»';
} else {
$header = fx::alang('Delete this infoblock', 'system');
}
$header .= '?';
$header = '<span title="' . $infoblock['controller'] . ':' . $infoblock['action'] . '">' . $header . "</span>";
return array('header' => $header);
}
示例10: conditionIs
public function conditionIs($type)
{
if (!is_array($type)) {
$type = array($type);
}
$variants = array();
foreach ($type as $c_type) {
$com = fx::component($c_type);
$variants = array_merge($variants, $com->getAllVariants()->getValues('keyword'));
}
$variants = array_unique($variants);
return array('type', $variants, 'in');
}