本文整理匯總了PHP中FabrikHelperHTML::iniRequireJS方法的典型用法代碼示例。如果您正苦於以下問題:PHP FabrikHelperHTML::iniRequireJS方法的具體用法?PHP FabrikHelperHTML::iniRequireJS怎麽用?PHP FabrikHelperHTML::iniRequireJS使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FabrikHelperHTML
的用法示例。
在下文中一共展示了FabrikHelperHTML::iniRequireJS方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: display
/**
* Display the view
*
* @param string $tpl Template
*
* @return void
*/
public function display($tpl = null)
{
// Initialise variables.
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->pluginFields = $this->get('PluginHTML');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new RuntimeException(implode("\n", $errors), 500);
}
$this->addToolbar();
FabrikAdminHelper::setViewLayout($this);
$srcs = FabrikHelperHTML::framework();
$srcs[] = 'media/com_fabrik/js/fabrik.js';
$srcs[] = 'administrator/components/com_fabrik/views/namespace.js';
$srcs[] = 'administrator/components/com_fabrik/views/pluginmanager.js';
$srcs[] = 'administrator/components/com_fabrik/views/visualization/adminvisualization.js';
$shim = array();
$dep = new stdClass();
$dep->deps = array('admin/pluginmanager');
$shim['admin/visualization/adminvisualization'] = $dep;
FabrikHelperHTML::iniRequireJS($shim);
$opts = new stdClass();
$opts->plugin = $this->item->plugin;
$js = "\n\tvar options = " . json_encode($opts) . ";\n\t\tFabrik.controller = new AdminVisualization(options);\n";
FabrikHelperHTML::script($srcs, $js);
parent::display($tpl);
}
示例2: display
/**
* Display the view
*
* @param string $tpl template
*
* @return void
*/
public function display($tpl = null)
{
// Initialise variables.
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->js = $this->get('Js');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new RuntimeException(implode("\n", $errors), 500);
}
$this->addToolbar();
FabrikAdminHelper::setViewLayout($this);
// Set up the script shim
$shim = array();
$dep = new stdClass();
$dep->deps = array('fab/fabrik');
$shim['admin/pluginmanager'] = $dep;
FabrikHelperHTML::iniRequireJS($shim);
$srcs = FabrikHelperHTML::framework();
$srcs[] = 'administrator/components/com_fabrik/views/namespace.js';
$srcs[] = 'administrator/components/com_fabrik/views/pluginmanager.js';
FabrikHelperHTML::script($srcs, $this->js);
parent::display($tpl);
}
示例3: display
/**
* Display the view
*
* @param string $tpl Template name
*
* @return void
*/
public function display($tpl = null)
{
switch ($this->getLayout()) {
case 'confirmdelete':
$this->confirmdelete();
return;
break;
case 'import':
$this->import($tpl);
return;
break;
}
// Initialise variables.
$app = JFactory::getApplication();
$input = $app->input;
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->packageOptions = $this->get('PackageOptions');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new RuntimeException(implode("\n", $errors), 500);
return false;
}
$this->table_groups = $this->get('TableGroups');
FabrikAdminHelper::setViewLayout($this);
$this->addToolbar();
FabrikAdminHelper::addSubmenu($input->getWord('view', 'lists'));
if (FabrikWorker::j3()) {
$this->sidebar = JHtmlSidebar::render();
}
FabrikHelperHTML::iniRequireJS();
parent::display($tpl);
}
示例4: shim
/**
* Ini the Fabrik requirejs framework files
*
* @return void
*/
protected function shim()
{
$shim = array();
$dep = new stdClass();
$dep->deps = array('fab/fabrik', 'fab/listfilter', 'fab/advanced-search', 'fab/encoder');
$shim['fab/list'] = $dep;
FabrikHelperHTML::iniRequireJS($shim);
}
示例5: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*/
protected function getInput()
{
$j3 = FabrikWorker::j3();
$from = $this->id . '-from';
$add = $this->id . '-add';
$remove = $this->id . '-remove';
$up = $this->id . '-up';
$down = $this->id . '-down';
$script[] = "window.addEvent('domready', function () {";
$script[] = "\tswaplist = new SwapList('{$from}', '{$this->id}','{$add}', '{$remove}', '{$up}', '{$down}');";
$script[] = "});";
FabrikHelperHTML::framework();
FabrikHelperHTML::iniRequireJS();
FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/swaplist.js', implode("\n", $script));
list($this->currentGroups, $this->currentGroupList) = $this->getCurrentGroupList();
list($this->groups, $this->groupList) = $this->getGroupList();
$str = '';
$checked = empty($this->current_groups) ? 'checked="checked"' : '';
if (empty($this->groups) && empty($this->currentGroups)) {
return JText::_('COM_FABRIK_NO_GROUPS_AVAILABLE');
} else {
if ($j3) {
$str = JText::_('COM_FABRIK_AVAILABLE_GROUPS');
$str .= '<br />' . $this->groupList;
$str .= '<button class="button btn btn-success btn-small" type="button" id="' . $this->id . '-add">';
$str .= '<i class="icon-new"></i>' . JText::_('COM_FABRIK_ADD') . '</button>';
$str .= '<br />' . JText::_('COM_FABRIK_CURRENT_GROUPS');
$str .= '<br />' . $this->currentGroupList;
$str .= '<button class="button btn btn-small" type="button" id="' . $this->id . '-up" >';
$str .= '<i class="icon-arrow-up"></i> ' . JText::_('COM_FABRIK_UP') . '</button> ';
$str .= '<button class="button btn btn-small" type="button" id="' . $this->id . '-down" >';
$str .= '<i class="icon-arrow-down"></i> ' . JText::_('COM_FABRIK_DOWN') . '</button> ';
$str .= '<button class="button btn btn-danger btn-small" type="button" id="' . $this->id . '-remove">';
$str .= '<i class="icon-delete"></i> ' . JText::_('COM_FABRIK_REMOVE');
$str .= '</button>';
} else {
$str .= '<input type="text" readonly="readonly" class="readonly" style="clear:left" size="44" value="' . JText::_('COM_FABRIK_AVAILABLE_GROUPS') . ':" />';
$str .= $this->groupList;
$str .= '<input class="button btn" type="button" id="' . $this->id . '-add" value="' . JText::_('COM_FABRIK_ADD') . '" />';
$str .= '<input type="text" readonly="readonly" class="readonly" style="clear:left" size="44" value="' . JText::_('COM_FABRIK_CURRENT_GROUPS') . ':" />';
$str .= $this->currentGroupList;
$str .= '<input class="button" type="button" value="' . JText::_('COM_FABRIK_UP') . '" id="' . $this->id . '-up" />';
$str .= '<input class="button" type="button" value="' . JText::_('COM_FABRIK_DOWN') . '" id="' . $this->id . '-down" />';
$str .= '<input class="button" type="button" value="' . JText::_('COM_FABRIK_REMOVE') . '" id="' . $this->id . '-remove"/>';
}
return $str;
}
}
示例6: display
/**
* Display
*
* @param string $tpl Template
*
* @return void
*/
public function display($tpl = null)
{
FabrikHelperHTML::framework();
FabrikHelperHTML::iniRequireJS();
$input = $this->app->input;
$model = $this->getModel('form');
$filter = JFilterInput::getInstance();
$post = $filter->clean($_POST, 'array');
if (!array_key_exists('youremail', $post)) {
FabrikHelperHTML::emailForm($model);
} else {
$to = $input->getString('email', '');
if ($this->sendMail($to)) {
$this->app->enqueueMessage(FText::_('COM_FABRIK_THIS_ITEM_HAS_BEEN_SENT_TO') . ' ' . $to, 'success');
}
FabrikHelperHTML::emailSent();
}
}
示例7: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*/
protected function getInput()
{
if (is_null($this->results)) {
$this->results = array();
}
$app = JFactory::getApplication();
$input = $app->input;
$controller = $input->get('view', $input->get('task'));
$formModel = false;
$filter = $this->getAttribute('filter');
$pluginFilters = trim($filter) == '' ? array() : explode('|', $filter);
$connection = $this->getAttribute('connection');
/*
* 27/08/2011 - changed from default table-element to id - for juser form plugin - might cause havoc
* else where but loading elements by id as default seems more robust (and is the default behaviour in f2.1
*/
$valueFormat = (string) $this->getAttribute('valueformat', 'id');
$onlyListFields = (int) $this->getAttribute('onlylistfields', 0);
$showRaw = FabrikWorker::toBoolean($this->getAttribute('raw', false), false);
$labelMethod = (string) $this->getAttribute('label_method');
$noJoins = FabrikWorker::toBoolean($this->getAttribute('nojoins', false), false);
$mode = (string) $this->getAttribute('mode', false);
$useStep = FabrikWorker::toBoolean($this->getAttribute('usestep', false), false);
switch ($controller) {
case 'validationrule':
$res = $this->_validationOptions();
break;
case 'visualization':
case 'element':
$res = $this->_elementOptions($connection);
break;
case 'listform':
case 'list':
case 'module':
case 'item':
// Menu item
$res = $this->_listOptions($controller, $valueFormat, $useStep, $onlyListFields, $showRaw, $pluginFilters, $labelMethod, $noJoins);
break;
case 'form':
$res = $this->_formOptions($valueFormat, $useStep, $onlyListFields, $showRaw, $pluginFilters, $labelMethod, $noJoins);
break;
case 'group':
$res = $this->_groupOptions($useStep, $valueFormat, $onlyListFields, $showRaw, $pluginFilters, $labelMethod, $noJoins);
break;
default:
return FText::_('The ListFields element is only usable by lists and elements');
break;
}
$return = '';
if (is_array($res)) {
$aEls = $this->_formatOptions($res, $valueFormat);
// For pk fields - we are no longer storing the key with '`' as that's mySQL specific
$this->value = str_replace('`', '', $this->value);
// Some elements were stored as names but subsequently changed to ids (need to check for old values an substitute with correct ones)
if ($valueFormat == 'id' && !is_numeric($this->value) && $this->value != '') {
if ($formModel) {
$elementModel = $formModel->getElement($this->value);
$this->value = $elementModel ? $elementModel->getId() : $this->value;
}
}
if ($mode === 'gui') {
$this->js($aEls);
$return = $this->gui();
} else {
$return = JHTML::_('select.genericlist', $aEls, $this->name, 'class="inputbox" size="1" ', 'value', 'text', $this->value, $this->id);
$return .= '<img style="margin-left:10px;display:none" id="' . $this->id . '_loader" src="components/com_fabrik/images/ajax-loader.gif" alt="' . FText::_('LOADING') . '" />';
}
}
FabrikHelperHTML::framework();
FabrikHelperHTML::iniRequireJS();
return $return;
}
示例8: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*/
protected function getInput()
{
static $fabrikelements;
if (!isset($fabrikelements)) {
$fabrikelements = array();
}
$src[] = 'administrator/components/com_fabrik/views/namespace.js';
$c = (int) @$this->form->repeatCounter;
$table = $this->element['table'];
if ($table == '') {
$table = $this->form->getValue('params.list_id');
}
$include_calculations = (int) $this->element['include_calculations'];
$published = (int) $this->element['published'];
$showintable = (int) $this->element['showintable'];
$highlightpk = (bool) JArrayHelper::getValue($this->element, 'highlightpk', false);
$mode = (string) $this->element['mode'];
if ($include_calculations != 1) {
$include_calculations = 0;
}
/*
* $$$ hugh - don't know what's going on here, except that this method is getting called twice for every element
* but first time round, $this->value is not set, so if we cache it, setting loses it's value.
* if (!array_key_exists($this->id, $fabrikelements)) {
*/
$opts = new stdClass();
if ($this->form->repeat) {
// In repeat fieldset/group
$conn = $this->element['connection'] . '-' . $this->form->repeatCounter;
$opts->table = 'jform_' . $table . '-' . $this->form->repeatCounter;
} else {
$conn = $c === false || $this->element['connection_in_repeat'] == 'false' ? $this->element['connection'] : $this->element['connection'] . '-' . $c;
$opts->table = $c === false || $this->element['connection_in_repeat'] == 'false' ? 'jform_' . $table : 'jform_' . $table . '-' . $c;
}
$opts->published = $published;
$opts->showintable = $showintable;
$opts->excludejoined = (int) $this->element['excludejoined'];
$opts->livesite = COM_FABRIK_LIVESITE;
$opts->conn = 'jform_' . $conn;
$opts->value = $this->value;
$opts->include_calculations = $include_calculations;
$opts->highlightpk = (int) $highlightpk;
$opts = json_encode($opts);
$script = array();
$script[] = "var p = new elementElement('{$this->id}', {$opts});";
$script[] = "FabrikAdmin.model.fields.element['{$this->id}'] = p;";
$script = implode("\n", $script);
$fabrikelements[$this->id] = true;
$src[] = 'administrator/components/com_fabrik/models/fields/element.js';
FabrikHelperHTML::script($src, $script);
if ($mode === 'gui') {
$return = $this->gui();
} else {
$return = parent::getInput();
$return .= '<img style="margin-left:10px;display:none" id="' . $this->id . '_loader" src="components/com_fabrik/images/ajax-loader.gif" alt="' . JText::_('COM_FABRIK_LOADING') . '" />';
}
FabrikHelperHTML::framework();
FabrikHelperHTML::iniRequireJS();
return $return;
}
示例9: getInput
//.........這裏部分代碼省略.........
$o->table_name = '';
$o->name = '';
$o->value = '';
$o->text = JText::_('COM_FABRIK_SELECT_A_TABLE_FIRST');
$res[] = $o;
}
break;
case 'listform':
case 'list':
case 'module':
case 'item':
// Menu item
if ($controller === 'item') {
$id = $this->form->getValue('request.listid');
} else {
$id = $this->form->getValue('id');
}
if (!isset($this->form->model)) {
if (!in_array($controller, array('item', 'module'))) {
// Seems to work anyway in the admin module page - so lets not raise notice
$app->enqueueMessage('Model not set in listfields field ' . $this->id, 'notice');
}
return;
}
$listModel = $this->form->model;
if ($id !== 0) {
$formModel = $listModel->getFormModel();
$valfield = $valueformat == 'tableelement' ? 'name' : 'id';
$res = $formModel->getElementOptions($useStep, $valfield, $onlylistfields, $showRaw, $pluginFilters, $labelMethod, $nojoins);
} else {
$res = array();
}
break;
case 'form':
if (!isset($this->form->model)) {
throw new RuntimeException('Model not set in listfields field ' . $this->id);
return;
}
$formModel = $this->form->model;
$valfield = $valueformat == 'tableelement' ? 'name' : 'id';
$res = $formModel->getElementOptions($useStep, $valfield, $onlylistfields, $showRaw, $pluginFilters, $labelMethod, $nojoins);
$jsres = $formModel->getElementOptions($useStep, $valfield, $onlylistfields, $showRaw, $pluginFilters, $labelMethod, $nojoins);
array_unshift($jsres, JHTML::_('select.option', '', JText::_('COM_FABRIK_PLEASE_SELECT')));
$this->js($jsres);
break;
case 'group':
$valfield = $valueformat == 'tableelement' ? 'name' : 'id';
$id = $this->form->getValue('id');
$groupModel = JModelLegacy::getInstance('Group', 'FabrikFEModel');
$groupModel->setId($id);
$formModel = $groupModel->getFormModel();
$res = $formModel->getElementOptions($useStep, $valfield, $onlylistfields, $showRaw, $pluginFilters, $labelMethod, $nojoins);
break;
default:
return JText::_('The ListFields element is only usable by lists and elements');
break;
}
$return = '';
if (is_array($res)) {
if ($controller == 'element') {
foreach ($res as $o) {
$s = new stdClass();
// Element already contains correct key
if ($controller != 'element') {
$s->value = $valueformat == 'tableelement' ? $o->table_name . '.' . $o->text : $o->value;
} else {
$s->value = $o->value;
}
$s->text = FabrikString::getShortDdLabel($o->text);
$aEls[] = $s;
}
} else {
foreach ($res as &$o) {
$o->text = FabrikString::getShortDdLabel($o->text);
}
$aEls = $res;
}
// Paul - Prepend rather than append "none" option.
array_unshift($aEls, JHTML::_('select.option', '', '-'));
// For pk fields - we are no longer storing the key with '`' as that's mySQL specific
$this->value = str_replace('`', '', $this->value);
// Some elements were stored as names but subsequently changed to ids (need to check for old values an substitute with correct ones)
if ($valueformat == 'id' && !is_numeric($this->value) && $this->value != '') {
if ($formModel) {
$elementModel = $formModel->getElement($this->value);
$this->value = $elementModel ? $elementModel->getId() : $this->value;
}
}
if ($mode === 'gui') {
$this->js($aEls);
$return = $this->gui();
} else {
$return = JHTML::_('select.genericlist', $aEls, $this->name, 'class="inputbox" size="1" ', 'value', 'text', $this->value, $this->id);
$return .= '<img style="margin-left:10px;display:none" id="' . $this->id . '_loader" src="components/com_fabrik/images/ajax-loader.gif" alt="' . JText::_('LOADING') . '" />';
}
}
FabrikHelperHTML::framework();
FabrikHelperHTML::iniRequireJS();
return $return;
}
示例10: getInput
//.........這裏部分代碼省略.........
$fieldSetId = str_replace('jform_params_', '', $modalid);
$css = '#' . $fieldSetId . ' { display: none; }';
$document->addStyleDeclaration($css);
$path = 'templates/' . $app->getTemplate() . '/images/menu/';
$str[] = '<div id="' . $modalid . '" style="display:none">';
$str[] = '<table class="adminlist ' . $this->element['class'] . ' table table-striped">';
$str[] = '<thead><tr class="row0">';
$names = array();
$attributes = $this->element->attributes();
foreach ($subForm->getFieldset($attributes->name . '_modal') as $field) {
$names[] = (string) $field->element->attributes()->name;
$str[] = '<th>' . strip_tags($field->getLabel($field->name));
$str[] = '<br /><small style="font-weight:normal">' . JText::_($field->description) . '</small>';
$str[] = '</th>';
}
if ($j3) {
$str[] = '<th><a href="#" class="add btn button btn-success"><i class="icon-plus"></i> </a></th>';
} else {
$str[] = '<th><a href="#" class="add"><img src="' . $path . '/icon-16-new.png" alt="' . JText::_('ADD') . '" /></a></th>';
}
$str[] = '</tr></thead>';
$str[] = '<tbody><tr>';
foreach ($subForm->getFieldset($attributes->name . '_modal') as $field) {
$str[] = '<td>' . $field->getInput() . '</td>';
}
$str[] = '<td>';
if ($j3) {
$str[] = '<div class="btn-group"><a class="add btn button btn-success"><i class="icon-plus"></i> </a>';
$str[] = '<a class="remove btn button btn-danger"><i class="icon-minus"></i> </a></div>';
} else {
$str[] = '<a href="#" class="add"><img src="' . $path . '/icon-16-new.png" alt="' . JText::_('ADD') . '" /></a>';
$str[] = '<a href="#" class="remove"><img src="' . $path . '/icon-16-delete.png" alt="' . JText::_('REMOVE') . '" /></a>';
}
$str[] = '</td>';
$str[] = '</tr></tbody>';
$str[] = '</table>';
$str[] = '</div>';
$form = implode("\n", $str);
static $modalrepeat;
if (!isset($modalrepeat)) {
$modalrepeat = array();
}
if (!array_key_exists($modalid, $modalrepeat)) {
$modalrepeat[$modalid] = array();
}
if (!isset($this->form->repeatCounter)) {
$this->form->repeatCounter = 0;
}
if (!array_key_exists($this->form->repeatCounter, $modalrepeat[$modalid])) {
// If loaded as js template then we don't want to repeat this again. (fabrik)
$names = json_encode($names);
$pane = str_replace('jform_params_', '', $modalid) . '-options';
$modalrepeat[$modalid][$this->form->repeatCounter] = true;
$opts = new stdClass();
$opts->j3 = $j3;
$opts = json_encode($opts);
$script = str_replace('-', '', $modalid) . " = new FabrikModalRepeat('{$modalid}', {$names}, '{$this->id}', {$opts});";
$option = $input->get('option');
if ($option === 'com_fabrik') {
FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/fabrikmodalrepeat.js', $script);
} else {
if ($j3) {
$context = strtoupper($option);
if ($context === 'COM_ADVANCEDMODULES') {
$context = 'COM_MODULES';
}
$j3pane = $context . '_' . str_replace('jform_params_', '', $modalid) . '_FIELDSET_LABEL';
if ($j32) {
$j3pane = strtoupper(str_replace('attrib-', '', $j3pane));
}
$script = "window.addEvent('domready', function() {\n\t\t\t\tvar a = jQuery(\"a:contains('{$j3pane}')\");\n\t\t\t\t\t\tif (a.length > 0) {\n\t\t\t\t\t\t\ta = a[0];\n\t\t\t\t\t\t\tvar href= a.get('href');\n\t\t\t\t\t\t\tjQuery(href)[0].destroy();\n\n\t\t\t\t\t\t\tvar accord = a.getParent('.accordion-group');\n\t\t\t\t\t\t\tif (typeOf(accord) !== 'null') {\n\t\t\t\t\t\t\t\taccord.destroy();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\ta.destroy();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t" . $script . "\n\t\t\t\t\t\t}\n\t\t\t\t\t});";
} else {
$script = "window.addEvent('domready', function() {\n\t\t\t" . $script . "\n\t\t\tif (typeOf(\$('{$pane}')) !== 'null') {\n\t\t\t \$('{$pane}').getParent().hide();\n\t\t\t}\n\t\t\t});";
}
// Wont work when rendering in admin module page
// @TODO test this now that the list and form pages are loading plugins via ajax (18/08/2012)
FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/fabrikmodalrepeat.js', $script);
}
}
if (is_array($this->value)) {
$this->value = array_shift($this->value);
}
$value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
if ($j3) {
$icon = $this->element['icon'] ? '<i class="icon-' . $this->element['icon'] . '"></i> ' : '';
$icon .= JText::_('JLIB_FORM_BUTTON_SELECT');
$str[] = '<button class="btn" id="' . $modalid . '_button" data-modal="' . $modalid . '">' . $icon . '</button>';
$str[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $value . '" />';
} else {
$str[] = '<div class="button2-left">';
$str[] = ' <div class="blank">';
$str[] = ' <a id="' . $modalid . '_button" data-modal="' . $modalid . '">' . JText::_('JLIB_FORM_BUTTON_SELECT') . '</a>';
$str[] = ' <input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $value . '" />';
$str[] = ' </div>';
$str[] = '</div>';
}
FabrikHelperHTML::framework();
FabrikHelperHTML::iniRequireJS();
return implode("\n", $str);
}
示例11: copySelectGroup
/**
* Show a view for selecting which group the element should be copied to
*
* @param string $tpl Template
*
* @return void
*/
public function copySelectGroup($tpl = null)
{
JSession::checkToken() or die('Invalid Token');
$model = $this->getModel();
$app = JFactory::getApplication();
$input = $app->input;
$model->setState('filter.cid', $input->get('cid', array(), 'array'));
$this->items = $this->get('Items');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id, name')->from('#__fabrik_groups')->order('name');
$db->setQuery($query);
$this->groups = $db->loadObjectList();
$this->addConfirmCopyToolbar();
FabrikHelperHTML::iniRequireJS();
parent::display($tpl);
}
示例12: _addJavascript
/**
* Append the form javascript into the document head
*
* @param int $listId table id
*
* @return void|boolean
*/
protected function _addJavascript($listId)
{
$pluginManager = FabrikWorker::getPluginManager();
/** @var FabrikFEModelForm $model */
$model = $this->getModel();
$aLoadedElementPlugins = array();
$jsActions = array();
$bKey = $model->jsKey();
$srcs = FabrikHelperHTML::framework();
$shim = array();
if (!defined('_JOS_FABRIK_FORMJS_INCLUDED')) {
define('_JOS_FABRIK_FORMJS_INCLUDED', 1);
FabrikHelperHTML::slimbox();
$dep = new stdClass();
$dep->deps = array('fab/element', 'lib/form_placeholder/Form.Placeholder', 'fab/encoder');
$shim['fabrik/form'] = $dep;
$deps = new stdClass();
$deps->deps = array('fab/fabrik', 'fab/element', 'fab/form-submit');
$framework['fab/elementlist'] = $deps;
$srcs[] = 'media/com_fabrik/js/lib/form_placeholder/Form.Placeholder.js';
FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/form');
FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/form-submit');
FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/element');
}
$aWYSIWYGNames = array();
// $$$ hugh - yet another one where if we =, the $groups array pointer get buggered up and it
// skips a group
$groups = $model->getGroupsHiarachy();
foreach ($groups as $groupModel) {
$elementModels = $groupModel->getPublishedElements();
foreach ($elementModels as $elementModel) {
$res = $elementModel->useEditor();
if ($res !== false && $elementModel->canUse() && $model->isEditable()) {
$aWYSIWYGNames[] = $res;
}
// Load in once the element js class files
$element = $elementModel->getElement();
if (!in_array($element->plugin, $aLoadedElementPlugins)) {
/* $$$ hugh - certain elements, like file-upload, need to load different JS files
* on a per-element basis, so as a test fix, I modified the file-upload's formJavaScriptClass to return false,
* and test for that here, so as to not add it to aLoadedElementPlugins[]. The existing 'static' tests in
* formJavascriptClass() should still prevent scripts being added twice.
*/
if ($elementModel->formJavascriptClass($srcs, '', $shim) !== false) {
$aLoadedElementPlugins[] = $element->plugin;
}
}
$eventMax = $groupModel->repeatTotal == 0 ? 1 : $groupModel->repeatTotal;
for ($c = 0; $c < $eventMax; $c++) {
$jsAct = $elementModel->getFormattedJSActions($bKey, $c);
if (!empty($jsAct)) {
$jsActions[] = $jsAct;
}
}
}
}
FabrikHelperHTML::iniRequireJS($shim);
$actions = trim(implode("\n", $jsActions));
FabrikHelperHTML::windows('a.fabrikWin');
FabrikHelperHTML::tips('.hasTip', array(), "\$('{$bKey}')");
$model->getFormCss();
$opts = $this->jsOpts();
$model->jsOpts = $opts;
$pluginManager->runPlugins('onJSOpts', $model);
$opts = json_encode($model->jsOpts);
if (!FabrikHelperHTML::inAjaxLoadedPage()) {
JText::script('COM_FABRIK_VALIDATING');
JText::script('COM_FABRIK_SUCCESS');
JText::script('COM_FABRIK_NO_REPEAT_GROUP_DATA');
JText::script('COM_FABRIK_VALIDATION_ERROR');
JText::script('COM_FABRIK_CONFIRM_DELETE_1');
}
JText::script('COM_FABRIK_FORM_SAVED');
// $$$ rob don't declare as var $bKey, but rather assign to window, as if loaded via ajax window the function is wrapped
// inside an anonymous function, and therefore $bKey wont be available as a global var in window
$script = array();
$script[] = "\t\tvar {$bKey} = Fabrik.form('{$bKey}', " . $model->getId() . ", {$opts});";
// Instantiate js objects for each element
$vstr = "\n";
$groups = $model->getGroupsHiarachy();
$script[] = "\tFabrik.blocks['{$bKey}'].addElements(";
$groupedJs = new stdClass();
foreach ($groups as $groupModel) {
$groupId = $groupModel->getGroup()->id;
$groupedJs->{$groupId} = array();
if (!$groupModel->canView('form')) {
continue;
}
$elementJs = array();
$elementModels = $groupModel->getPublishedElements();
// $$$ rob if repeatTotal is 0 we still want to add the js objects as the els are only hidden
$max = $groupModel->repeatTotal > 0 ? $groupModel->repeatTotal : 1;
foreach ($elementModels as $elementModel) {
//.........這裏部分代碼省略.........
示例13: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*/
protected function getInput()
{
static $fabrikElements;
if (!isset($fabrikElements)) {
$fabrikElements = array();
}
$src[] = 'administrator/components/com_fabrik/views/namespace.js';
$c = (int) @$this->form->repeatCounter;
$table = $this->getAttribute('table');
if ($table == '') {
$table = $this->form->getValue('params.list_id');
}
$includeCalculations = (int) $this->getAttribute('include_calculations');
$published = (int) $this->getAttribute('published');
$showInTable = (int) $this->getAttribute('showintable');
$highlightPk = FabrikWorker::toBoolean($this->getAttribute('highlightpk', false), false);
$mode = $this->getAttribute('mode');
$connection = $this->getAttribute('connection');
$connectionInRepeat = FabrikWorker::toBoolean($this->getAttribute('connection_in_repeat', true), true);
$excludeJoined = (int) $this->getAttribute('excludejoined');
if ($includeCalculations != 1) {
$includeCalculations = 0;
}
$opts = new stdClass();
if ($this->form->repeat) {
// In repeat fieldset/group
$conn = $connection . '-' . $this->form->repeatCounter;
$opts->table = 'jform_' . $table . '-' . $this->form->repeatCounter;
} else {
$conn = $c === false || !$connectionInRepeat ? $connection : $connection . '-' . $c;
$opts->table = $c === false || !$connectionInRepeat ? 'jform_' . $table : 'jform_' . $table . '-' . $c;
}
$opts->published = $published;
$opts->showintable = $showInTable;
$opts->excludejoined = $excludeJoined;
$opts->livesite = COM_FABRIK_LIVESITE;
$opts->conn = 'jform_' . $conn;
$opts->value = $this->value;
$opts->include_calculations = $includeCalculations;
$opts->highlightpk = (int) $highlightPk;
$opts = json_encode($opts);
$script = array();
$script[] = "var p = new elementElement('{$this->id}', {$opts});";
$script[] = "FabrikAdmin.model.fields.element['{$this->id}'] = p;";
$script = implode("\n", $script);
$fabrikElements[$this->id] = true;
$src[] = 'administrator/components/com_fabrik/models/fields/element.js';
FabrikHelperHTML::script($src, $script);
if ($mode === 'gui') {
$return = $this->gui();
} else {
$return = parent::getInput();
$return .= '<img style="margin-left:10px;display:none" id="' . $this->id . '_loader" src="components/com_fabrik/images/ajax-loader.gif" alt="' . FText::_('COM_FABRIK_LOADING') . '" />';
}
FabrikHelperHTML::framework();
FabrikHelperHTML::iniRequireJS();
return $return;
}
示例14: getInput
/**
* Method to get the field input markup for the editor area
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
// Initialize some field attributes.
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
$disabled = (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : '';
$columns = $this->element['cols'] ? ' cols="' . (int) $this->element['cols'] . '"' : '';
$rows = $this->element['rows'] ? ' rows="' . (int) $this->element['rows'] . '"' : '';
$required = $this->required ? ' required="required" aria-required="true"' : '';
// JS events are saved as encoded html - so we don't want to double encode them
$encoded = JArrayHelper::getValue($this->element, 'encoded', false);
if (!$encoded) {
$this->value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
}
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
$editor = '<textarea name="' . $this->name . '" id="' . $this->id . '"' . $columns . $rows . $class . $disabled . $onchange . $required . '>' . $this->value . '</textarea>';
$version = new JVersion();
if ($version->RELEASE == 2.5) {
return $editor;
}
// Joomla 3 version
$mode = $this->element['mode'] ? (string) $this->element['mode'] : 'html';
$theme = $this->element['theme'] ? (string) $this->element['theme'] : 'github';
$height = $this->element['height'] ? (string) $this->element['height'] : '200px';
$maxHeight = $this->element['max-height'] ? (string) $this->element['max-height'] : str_ireplace('px', '', $height) * 2 . 'px';
$width = $this->element['width'] ? (string) $this->element['width'] : '100';
FabrikHelperHTML::framework();
FabrikHelperHTML::iniRequireJS();
if ($mode === 'php') {
$aceMode = '{path:"ace/mode/php", inline:true}';
} else {
$aceMode = '"ace/mode/' . $mode . '"';
}
$minHeight = str_ireplace('px', '', $height);
$maxHeight = str_ireplace('px', '', $maxHeight);
/**
* In code below...
* the +/- 2 is to account for the top/bottom border of 1px each
*
* pluginmanager.js renames names/ids when you delete a preceding plugin which breaks ace
* so we need to keep ace-ids intact and avoid issues with duplicate ids by:
* adding a random string to the id where ace needs id to be kept the same; and
* save dom object for textarea so that change of id doesn't break it.
**/
$aceid = $this->id . '_' . sprintf("%06x", mt_rand(0, 0xffffff));
$script = '
window.addEvent(\'domready\', function () {
if (Fabrik.debug) {
fconsole("Fabrik editor initialising: ' . $this->id . '");
}
var field = document.id("' . $this->id . '");
var FbEditor = ace.edit("' . $aceid . '-ace");
FbEditor.setTheme("ace/theme/' . $theme . '");
FbEditor.getSession().setMode(' . $aceMode . ');
FbEditor.setValue(field.value);
FbEditor.navigateFileStart();
FbEditor.setAnimatedScroll(true);
FbEditor.setBehavioursEnabled(true);
FbEditor.setDisplayIndentGuides(true);
FbEditor.setHighlightGutterLine(true);
FbEditor.setHighlightSelectedWord(true);
FbEditor.setShowFoldWidgets(true);
FbEditor.setWrapBehavioursEnabled(true);
FbEditor.getSession().setUseWrapMode(true);
FbEditor.getSession().setTabSize(2);
FbEditor.on("blur", function () {
if (field.value !== FbEditor.getValue()) {
field.value = FbEditor.getValue();
field.fireEvent("change", field);
}
field.fireEvent("blur", field);
});
var maxlines = Math.floor((' . $maxHeight . ' - 2) / FbEditor.renderer.lineHeight);
var updateHeight = function () {
var s = FbEditor.getSession();
var r = FbEditor.renderer;
var l = s.getScreenLength();
var h = (l > maxlines ? maxlines : l)
* r.lineHeight
+ (r.$horizScroll ? r.scrollBar.getWidth() : 0)
+ 2;
h = h < ' . $minHeight . ' ? ' . $minHeight . ' : h;
c = document.id("' . $aceid . '-aceContainer").getStyle("height").toInt();
if (c !== h) {
document.id("' . $aceid . '-aceContainer").setStyle("height", h.toString() + "px");
FbEditor.resize();
}
}
updateHeight();
FbEditor.getSession().on("change", updateHeight);
});
';
$src = array('media/com_fabrik/js/lib/ace/src-min-noconflict/ace.js', 'media/com_fabrik/js/fabrik.js');
FabrikHelperHTML::script($src, $script);
//.........這裏部分代碼省略.........
示例15: getManagementJS
//.........這裏部分代碼省略.........
$labels = $this->headings;
foreach ($labels as &$l) {
$l = strip_tags($l);
}
$opts->labels = $labels;
$opts->primaryKey = $item->db_primary_key;
$opts->Itemid = $tmpItemid;
$opts->listRef = $listRef;
$opts->formid = $model->getFormModel()->getId();
$opts->canEdit = $model->canEdit() ? '1' : '0';
$opts->canView = $model->canView() ? '1' : '0';
$opts->page = JRoute::_('index.php');
$opts->isGrouped = $this->isGrouped;
$opts->toggleCols = $toggleCols;
$opts->j3 = FabrikWorker::j3();
$opts->singleOrdering = (bool) $model->singleOrdering();
// Reset data back to original settings
$this->rows = $origRows;
$formEls = array();
foreach ($elementsNotInTable as $tmpElement) {
$oo = new stdClass();
$oo->name = $tmpElement->name;
$oo->label = $tmpElement->label;
$formEls[] = $oo;
}
$opts->formels = $formEls;
$opts->fabrik_show_in_list = $input->get('fabrik_show_in_list', array(), 'array');
$opts->popup_width = $params->get('popup_width', '');
$opts->popup_height = $params->get('popup_height', '');
$xOffset = $params->get('popup_offset_x', '');
$yOffset = $params->get('popup_offset_y', '');
if ($xOffset !== '') {
$opts->popup_offset_x = (int) $xOffset;
}
if ($yOffset !== '') {
$opts->popup_offset_y = (int) $yOffset;
}
/**
* Added the $nodata object as we now weed something to pass in just to keep editLabel
* and viewLabel happy, after adding placeholder replacement to the labels for a Pro user,
* because the tooltips said we did that, which we never actually did.
*
* http://fabrikar.com/forums/index.php?threads/placeholders-in-list-links-and-labels.37726/#post-191081
*
* However, this means that using placeholders will yield funky labels for the popups, as
* this isn't per row. So we may need to not use editLabel / viewLabel here any more,
* and just use the default COM_FABRIK_VIEW/EDIT. Or add YAFO's, ::sigh::.
*
* But for now, it's too corner case to worry about!
*/
$nodata = new stdClass();
$opts->popup_edit_label = $model->editLabel($nodata);
$opts->popup_view_label = $model->viewLabel($nodata);
$opts->popup_add_label = $model->addLabel();
$opts->limitLength = $model->limitLength;
$opts->limitStart = $model->limitStart;
$opts->tmpl = $tmpl;
$opts->data = $data;
$opts->groupByOpts = new stdClass();
$opts->groupByOpts->isGrouped = (bool) $this->isGrouped;
$opts->groupByOpts->collapseOthers = (bool) $params->get('group_by_collapse_others', false);
$opts->groupByOpts->startCollapsed = (bool) $params->get('group_by_start_collapsed', false);
$opts->groupByOpts->bootstrap = FabrikWorker::j3();
// If table data starts as empty then we need the html from the row
// template otherwise we can't add a row to the table
ob_start();
$this->_row = new stdClass();
$this->_row->id = '';
$this->_row->class = 'fabrik_row';
echo $this->loadTemplate('row');
$opts->itemTemplate = ob_get_contents();
ob_end_clean();
// $$$rob if you are loading a table in a window from a form db join select record option
// then we want to know the id of the window so we can set its showSpinner() method
$opts->winid = $input->get('winid', '');
$this->jsText();
$script[] = "window.addEvent('domready', function () {";
$script[] = "\tvar list = new FbList('{$listId}',";
$script[] = "\t" . json_encode($opts);
$script[] = "\t);";
$script[] = "\tFabrik.addBlock('list_{$listRef}', list);";
// Add in plugin objects
$pluginManager->runPlugins('onLoadJavascriptInstance', $model, 'list');
$aObjs = $pluginManager->data;
if (!empty($aObjs)) {
$script[] = "list.addPlugins([\n";
$script[] = "\t" . implode(",\n ", $aObjs);
$script[] = "]);";
}
// @since 3.0 inserts content before the start of the list render (currently on f3 tmpl only)
$pluginManager->runPlugins('onGetContentBeforeList', $model, 'list');
$this->pluginBeforeList = $pluginManager->data;
$script[] = $model->filterJs;
$script[] = $this->getModel()->getElementJs($src);
// End domready wrapper
$script[] = '})';
$script = implode("\n", $script);
FabrikHelperHTML::iniRequireJS($shim);
FabrikHelperHTML::script($src, $script);
}