本文整理汇总了PHP中ModuleBuilderController::setup方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleBuilderController::setup方法的具体用法?PHP ModuleBuilderController::setup怎么用?PHP ModuleBuilderController::setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleBuilderController
的用法示例。
在下文中一共展示了ModuleBuilderController::setup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_custom_field
function set_custom_field($session, $module_name, $type, $properties, $add_to_layout)
{
global $current_user;
global $beanList, $beanFiles;
global $custom_field_meta;
$error = new SoapError();
$request_arr = array('action' => 'SaveField', 'is_update' => 'true', 'module' => 'ModuleBuilder', 'view_module' => $module_name, 'view_package' => 'studio');
// ERROR CHECKING
if (!validate_authenticated($session)) {
$error->set_error('invalid_login');
return $error->get_soap_array();
}
if (!is_admin($current_user)) {
$error->set_error('no_admin');
return $error->get_soap_array();
}
if (empty($beanList[$module_name])) {
$error->set_error('no_module');
return $error->get_soap_array();
}
if (empty($custom_field_meta[$type])) {
$error->set_error('custom_field_type_not_supported');
return $error->get_soap_array();
}
$new_properties = array();
foreach ($properties as $value) {
$new_properties[$value['name']] = $value['value'];
}
foreach ($custom_field_meta[$type] as $property) {
if (!isset($new_properties[$property])) {
$error->set_error('custom_field_property_not_supplied');
return $error->get_soap_array();
}
$request_arr[$property] = $new_properties[$property];
}
// $request_arr should now contain all the necessary information to create a custom field
// merge $request_arr with $_POST/$_REQUEST, where the action_saveField() method expects them
$_REQUEST = array_merge($_REQUEST, $request_arr);
$_POST = array_merge($_POST, $request_arr);
require_once 'modules/ModuleBuilder/controller.php';
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php';
$mbc = new ModuleBuilderController();
$mbc->setup();
$mbc->action_SaveField();
// add the field to the given module's EditView and DetailView layouts
if ($add_to_layout == 1) {
$layout_properties = array('name' => $new_properties['name'], 'label' => $new_properties['label']);
if (isset($new_properties['customCode'])) {
$layout_properties['customCode'] = $new_properties['customCode'];
}
if (isset($new_properties['customLabel'])) {
$layout_properties['customLabel'] = $new_properties['customLabel'];
}
// add the field to the DetailView
$parser = ParserFactory::getParser('layoutview', FALSE);
$parser->init($module_name, 'DetailView', FALSE);
$parser->_addField($layout_properties);
$parser->writeWorkingFile();
$parser->handleSave();
unset($parser);
// add the field to the EditView
$parser = ParserFactory::getParser('layoutview', FALSE);
$parser->init($module_name, 'EditView', FALSE);
$parser->_addField($layout_properties);
$parser->writeWorkingFile();
$parser->handleSave();
}
return $error->get_soap_array();
}