本文整理汇总了PHP中Floxim\Floxim\System\Fx::controller方法的典型用法代码示例。如果您正苦于以下问题:PHP Fx::controller方法的具体用法?PHP Fx::controller怎么用?PHP Fx::controller使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Floxim\Floxim\System\Fx
的用法示例。
在下文中一共展示了Fx::controller方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getComponentTemplates
protected function getComponentTemplates($ctr_entity)
{
$controller_name = $ctr_entity['keyword'];
$controller = fx::controller($controller_name);
$actions = $controller->getActions();
$templates = array();
foreach (array_keys($actions) as $action_code) {
$action_controller = fx::controller($controller_name . ':' . $action_code);
$action_templates = $action_controller->getAvailableTemplates();
foreach ($action_templates as $atpl) {
$templates[$atpl['full_id']] = $atpl;
}
}
return fx::collection($templates);
}
示例2: adminOffice
/**
* @return string
*/
public function adminOffice()
{
self::addAdminFiles();
if (fx::isAdmin()) {
$panel = Adminpanel::panelHtml();
$res = fx::template('@admin:back_office')->render(array('panel' => $panel));
$js_config = new FxAdmin\Configjs();
fx::page()->addJsText("\$fx.init(" . $js_config->getConfig() . ");");
} else {
$auth_form = fx::controller('user:auth_form')->render('user:auth_form');
$recover_form = fx::controller('user:recover_form', array('email' => isset($_POST['email']) ? $_POST['email'] : null))->render('user:recover_form');
$res = fx::template('@admin:authorize')->render(array('auth_form' => $auth_form, 'recover_form' => $recover_form));
}
return fx::page()->postProcess($res);
}
示例3: initController
public function initController()
{
$controller = $this->getPropInherited('controller');
$action = $this->getPropInherited('action');
if (!$controller || !$action) {
return null;
}
$ctr = fx::controller($controller . ':' . $action, $this->getPropInherited('params'));
$ctr->setParam('infoblock_id', $this['id']);
return $ctr;
}
示例4: route
public function route($url = null, $context = null)
{
$action_info = null;
if (!preg_match("~^/\\~ajax/([a-z0-9_\\.\\:\\@-]+)?~", $url, $action_info)) {
return null;
}
fx::env('ajax', true);
$c_url = fx::input()->fetchGetPost('_ajax_base_url');
if ($c_url) {
$c_url = preg_replace("~^https?://[^/]+~", '', $c_url);
$_SERVER['REQUEST_URI'] = $c_url;
$base_path = fx::router()->getPath($c_url);
if ($base_path) {
$page = $base_path->last();
fx::env('page', $page);
} else {
fx::env('page', fx::router('error')->getErrorPage());
}
$c_url = parse_url($c_url);
if (isset($c_url['query'])) {
parse_str($c_url['query'], $_GET);
}
}
// import layout template to recreate real env
fx::router('front')->importLayoutTemplate();
$page_infoblocks = fx::router('front')->getPageInfoblocks($page_id, $layout_id);
fx::page()->setInfoblocks($page_infoblocks);
$controller_params = fx::input()->fetchGetPost('_ajax_controller_params');
$c_infoblock_id = fx::input()->fetchGetPost('_ajax_infoblock_id');
if ($c_infoblock_id) {
$infoblock = fx::data('infoblock', $c_infoblock_id);
if ($infoblock) {
if ($controller_params) {
$infoblock->override(array('params' => $controller_params));
}
$res = $infoblock->render();
return $res;
}
}
$template = null;
if ($action_info && !empty($action_info[1])) {
$action = $action_info[1];
$action = explode("@", $action);
if (count($action) == 2) {
$template = $action[1];
$action = $action[0];
} else {
$action = $action[0];
}
} elseif (isset($_POST['_ajax_controller'])) {
$action = $_POST['_ajax_controller'];
} else {
return null;
}
$action = explode(":", $action);
$controller_name = $action[0];
if (preg_match("~^widget_~", $controller_name) && !isset($action[1])) {
$action[1] = 'show';
}
$action_name = $action[1];
$controller = fx::controller($controller_name . ':' . $action_name, $controller_params);
if (!$template) {
$template = fx::input()->fetchGetPost('_ajax_template');
}
if (!$template) {
$tpls = $controller->getAvailableTemplates();
if (count($tpls) > 0) {
$template = $tpls[0]['full_id'];
}
}
$res = $controller->process();
if ($template) {
$tpl = fx::template($template);
if ($tpl) {
$res = $tpl->render($res);
}
}
return $res ? $res : true;
}
示例5: suit
public function suit(System\Collection $infoblocks, $layout_id)
{
$layout = fx::data('layout', $layout_id);
$layout_ib = null;
$stub_ibs = new System\Collection();
// Collect all Infoblox without the visual part
// Find the InfoBlock-layout
foreach ($infoblocks as $ib) {
if ($ib->getVisual()->get('is_stub')) {
$stub_ibs[] = $ib;
}
if ($ib->isLayout()) {
$layout_ib = $ib;
}
}
$layout_rate = array();
$all_visual = fx::data('infoblock_visual')->getForInfoblocks($stub_ibs, false);
foreach ($all_visual as $c_vis) {
$c_layout_id = $c_vis['layout_id'];
$infoblocks->findOne('id', $c_vis['infoblock_id'])->setVisual($c_vis, $c_layout_id);
if (!isset($layout_rate[$c_layout_id])) {
$layout_rate[$c_layout_id] = 0;
}
// count how many visual blocks are defined for each layout
// later we should sort this to find correct "original" layout made by human
$layout_rate[$c_layout_id]++;
}
//$source_layout_id = $c_layout_id;
$avail_layout_ids = array_keys($layout_rate);
// temp: use first
// $source_layout_id = $avail_layout_ids[0];
$source_layout_id = end($avail_layout_ids);
if (!$layout_ib) {
$layout_ib = fx::router('front')->getLayoutInfoblock(fx::env('page'));
}
$area_map = array();
if ($layout_ib->getVisual()->get('is_stub') || !$layout_ib->getTemplate()) {
$this->adjustLayoutVisual($layout_ib, $layout_id, $source_layout_id);
$layout_visual = $layout_ib->getVisual();
$area_map = $layout_visual['area_map'];
} else {
$layout_visual = $layout_ib->getVisual();
$old_layout_template = $layout_ib->getPropInherited('visual.template', $source_layout_id);
if ($old_layout_template) {
$old_areas = fx::template($old_layout_template)->getAreas();
$new_areas = fx::template($layout_visual['template'])->getAreas();
//$tplv['real_areas'] = $test_layout_tpl->getAreas();
$area_map = $this->mapAreas($old_areas, $new_areas);
$area_map = $area_map['map'];
}
}
$layout_template_name = $layout_ib->getPropInherited('visual.template');
$layout_template = fx::template($layout_template_name);
// seems to be second call of ::getAreas(), can be cached or reused
$c_areas = $layout_template->getAreas();
$c_wrappers = array();
foreach ($infoblocks as $ib) {
$ib_visual = $ib->getVisual($layout_id);
if (!$ib_visual['is_stub']) {
continue;
}
$old_area = $ib->getPropInherited('visual.area', $source_layout_id);
// Suit record infoblock to the area where list infoblock is placed
if ($ib->getPropInherited('action') == 'record') {
$content_type = $ib->getPropInherited('controller');
$content_ibs = fx::data('infoblock')->where('page_id', $ib['page_id'])->getContentInfoblocks($content_type);
if (count($content_ibs)) {
$list_ib = $content_ibs->first();
$list_ib_vis = $list_ib->getVisual($layout_id);
if ($list_ib_vis && $list_ib_vis['area']) {
$ib_visual['area'] = $list_ib_vis['area'];
}
}
}
if (!$ib_visual['area']) {
if ($old_area && isset($area_map[$old_area])) {
$ib_visual['area'] = $area_map[$old_area];
$ib_visual['priority'] = $ib->getPropInherited('visual.priority', $source_layout_id);
} elseif (preg_match("~^grid_~", $old_area)) {
$ib_visual['area'] = $old_area;
}
}
$ib_controller = fx::controller($ib->getPropInherited('controller'), $ib->getPropInherited('params'), $ib->getPropInherited('action'));
$area_meta = isset($c_areas[$ib_visual['area']]) ? $c_areas[$ib_visual['area']] : null;
$controller_templates = $ib_controller->getAvailableTemplates($layout['keyword'], $area_meta);
$old_template = $ib->getPropInherited('visual.template', $source_layout_id);
$used_template_props = null;
foreach ($controller_templates as $c_tpl) {
if ($c_tpl['full_id'] === $old_template) {
$ib_visual['template'] = $c_tpl['full_id'];
$used_template_props = $c_tpl;
break;
}
}
if (!$ib_visual['template']) {
$that = $this;
$old_template_id = preg_replace("~^.*?:~", '', $old_template);
$controller_templates = fx::collection($controller_templates);
$controller_templates->sort(function (&$tpl) use($that, $old_template_id) {
$res = $that->compareNames($tpl['id'], $old_template_id);
//.........这里部分代码省略.........
示例6: array
<?php
use Floxim\Floxim\System\Fx as fx;
$record_templates = fx::controller($component['keyword'] . ':record')->getAvailableTemplates();
$page_config = array('actions' => array('*record' => array('name' => 'Поля ' . $component->getItemName('of'), 'check_context' => function ($page) use($component) {
$res = $page['type'] === $component['keyword'];
return $res;
}, 'scope_type' => 'infoblock_pages'), '*neighbours' => array('check_context' => function ($page) use($component) {
$res = $page['type'] === $component['keyword'];
return $res;
}, 'name' => fx::alang('Neighbour %s', 'controller_component', $component->getItemName('list')), 'settings' => array('sorting' => array('name' => 'sorting', 'label' => fx::alang('Sorting', 'controller_component'), 'type' => 'select', 'values' => array('auto' => fx::alang('Auto', 'controller_component')) + $sort_fields), 'sorting_dir' => array('name' => 'sorting_dir', 'label' => fx::alang('Order', 'controller_component'), 'type' => 'select', 'values' => array('asc' => fx::alang('Ascending', 'controller_component'), 'desc' => fx::alang('Descending', 'controller_component')), 'parent' => array('sorting' => '!=auto')), 'group_by_parent' => array('name' => 'group_by_parent', 'label' => fx::alang('Group by parent', 'controller_component'), 'type' => 'checkbox'))), 'list_infoblock' => array('disabled' => true), '*list_infoblock' => array('settings' => $is_new_infoblock && count($record_templates) > 0 ? array('create_record_ib' => array('type' => 'hidden', 'value' => true, 'label' => 'Create record infoblock')) : array(), 'install' => function ($list_ib, $ctr) {
return;
if (!$list_ib['params']['create_record_ib']) {
return;
}
$rec_ib = fx::data('infoblock')->create();
$content_type = $ctr->getContentType();
$rec_ib->set(array('site_id' => $list_ib['site_id'], 'controller' => $ctr->getControllerName(), 'action' => 'record', 'name' => $content_type . ' record', 'scope_type' => 'infoblock_pages', 'scope_infoblock_id' => $list_ib['id']));
$rec_ib->save();
}, 'delete' => function ($list_ib, $ctr) {
$rec_ib = fx::data('infoblock')->where('page_id', $list_ib['page_id'])->where('controller', $ctr->getControllerName())->where('action', 'record')->one();
if ($rec_ib) {
$rec_ib->delete();
}
})));
return $page_config;
示例7: getFormatFields
protected function getFormatFields(CompInfoblock\Entity $infoblock, $area_meta = null)
{
$i2l = $infoblock->getVisual();
$fields = array(array('label' => "Area", 'name' => 'area', 'value' => $i2l['area'], 'type' => 'hidden'));
$layout_name = fx::data('layout', $i2l['layout_id'])->get('keyword');
$controller_name = $infoblock->getPropInherited('controller');
$action_name = $infoblock->getPropInherited('action');
$area_suit = Template\Suitable::parseAreaSuitProp(isset($area_meta['suit']) ? $area_meta['suit'] : '');
$force_wrapper = $area_suit['force_wrapper'];
$default_wrapper = $area_suit['default_wrapper'];
$wrappers = array();
$c_wrapper = '';
if (!$force_wrapper) {
$wrappers[''] = fx::alang('With no wrapper', 'system');
if ($i2l['id'] || !$default_wrapper) {
$c_wrapper = $i2l['wrapper'];
} else {
$c_wrapper = $default_wrapper[0];
}
}
// Collect available wrappers
$layout_tpl = fx::template('theme.' . $layout_name);
if ($layout_tpl) {
$avail_wrappers = \Floxim\Floxim\Template\Suitable::getAvailableWrappers($layout_tpl, $area_meta);
foreach ($avail_wrappers as $avail_wrapper) {
$wrappers[$avail_wrapper['full_id']] = $avail_wrapper['name'];
}
//$wrappers = array_merge($wrappers, $avail_wrappers);
}
// Collect the available templates
$controller = fx::controller($controller_name . ':' . $action_name);
$tmps = $controller->getAvailableTemplates($layout_name, $area_meta);
if (!empty($tmps)) {
foreach ($tmps as $template) {
$templates[] = array($template['full_id'], $template['name']);
}
}
if (count($templates) == 1) {
$fields[] = array('name' => 'template', 'type' => 'hidden', 'value' => $templates[0][0]);
} else {
$fields[] = array('label' => fx::alang('Template', 'system'), 'name' => 'template', 'type' => 'select', 'values' => $templates, 'value' => $i2l['template']);
}
if ($controller_name != 'layout' && (count($wrappers) > 1 || !isset($wrappers['']))) {
$fields[] = array('label' => fx::alang('Wrapper', 'system'), 'name' => 'wrapper', 'type' => 'select', 'values' => $wrappers, 'value' => $c_wrapper);
}
return $fields;
}