本文整理匯總了PHP中FabrikHelperHTML::inAjaxLoadedPage方法的典型用法代碼示例。如果您正苦於以下問題:PHP FabrikHelperHTML::inAjaxLoadedPage方法的具體用法?PHP FabrikHelperHTML::inAjaxLoadedPage怎麽用?PHP FabrikHelperHTML::inAjaxLoadedPage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FabrikHelperHTML
的用法示例。
在下文中一共展示了FabrikHelperHTML::inAjaxLoadedPage方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: framework
/**
* Method to load the MooTools framework into the document head
*
* If debugging mode is on an uncompressed version of MooTools is included for easier debugging.
*
* @param string $extras MooTools file to load
* @param boolean $debug Is debugging mode on? [optional]
*
* @return void
*
* @since 11.1
*/
public static function framework($extras = false, $debug = null)
{
// $$$ rob this is to stop mootools from being re-loaded when in an ajax loaded page, as that
// resets the window events, stopping Fabriks mediator js system from working (e.g. fabrik.form.submitted will not
// fire the events added when the url initially loads.)
if (FabrikHelperHTML::inAjaxLoadedPage()) {
return;
}
static $loaded = array();
$type = $extras ? 'more' : 'core';
// Only load once
if (!empty($loaded[$type])) {
return;
}
JHtml::core($debug);
// If no debugging value is set, use the configuration setting
if ($debug === null) {
$config = JFactory::getConfig();
$debug = $config->get('debug');
}
$uncompressed = $debug ? '-uncompressed' : '';
if ($type != 'core' && empty($loaded['core'])) {
self::framework(false, $debug);
}
JHtml::_('script', 'system/mootools-' . $type . $uncompressed . '.js', false, true, false, false);
$loaded[$type] = true;
return;
}
示例2: _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) {
//.........這裏部分代碼省略.........
示例3: mootools
/**
* @deprecated use ::framework instead
*/
function mootools()
{
if (!FabrikHelperHTML::inAjaxLoadedPage()) {
//JHtml::_('behavior.framework');
//JHtml::_('behavior.framework', true);
}
}
示例4: framework
/**
*/
public function framework(){
if (!self::$framework) {
$config = JFactory::getConfig();
$debug = $config->get('debug');
//$uncompressed = $debug ? '-uncompressed' : '';
$src = array();
//loading here as well as normal J behavior call makes document.body not found for gmap element when
// rendered in the form
if (JRequest::getInt('ajax') !== 1 && JRequest::getVar('tmpl') !== 'component') {
// $src[] = 'media/system/js/mootools-core'.$uncompressed.'.js';
// $src[] = 'media/system/js/mootools-more'.$uncompressed.'.js';
}
JHtml::_('behavior.framework', true);
if (!FabrikHelperHTML::inAjaxLoadedPage()) {
JDEBUG ? JHtml::_('script', 'media/com_fabrik/js/lib/head/head.js'): JHtml::_('script', 'media/com_fabrik/js/lib/head/head.min.js');
}
$src[] = 'media/com_fabrik/js/mootools-ext.js';
$src[] = 'media/com_fabrik/js/lib/art.js';
$src[] = 'media/com_fabrik/js/icons.js';
$src[] = 'media/com_fabrik/js/icongen.js';
$src[] = 'media/com_fabrik/js/fabrik.js';
$src[] = 'media/com_fabrik/js/lib/tips/floatingtips.js';
$src[] = 'media/com_fabrik/js/window.js';
FabrikHelperHTML::styleSheet(COM_FABRIK_LIVESITE.'/media/com_fabrik/css/fabrik.css');
FabrikHelperHTML::addScriptDeclaration("head.ready(function() { Fabrik.liveSite = '".COM_FABRIK_LIVESITE."';});");
FabrikHelperHTML::script($src, true, "window.fireEvent('fabrik.framework.loaded');");
self::$framework = true;
}
}
示例5: script
/**
* wrapper for JHTML::Script()
* @param mixed, string or array of files to load
* @param string optional js to run if format=raw (as we first load the $file via Asset.Javascript()
*/
public static function script($file, $onLoad = '')
{
if (empty($file)) {
return;
}
$config = JFactory::getConfig();
$debug = $config->get('debug');
//$uncompressed = $debug ? '-uncompressed' : '';
$ext = $debug || JRequest::getInt('fabrikdebug', 0) === 1 ? '.js' : '-min.js';
$file = (array) $file;
$src = array();
foreach ($file as $f) {
if (!(stristr($f, 'http://') || stristr($f, 'https://'))) {
if (!JFile::exists(COM_FABRIK_BASE . '/' . $f)) {
continue;
}
}
if (stristr($f, 'http://') || stristr($f, 'https://')) {
$f = $f;
} else {
$compressedFile = str_replace('.js', $ext, $f);
if (JFile::exists($compressedFile)) {
$f = $compressedFile;
}
$f = COM_FABRIK_LIVESITE . $f;
}
if (JRequest::getCmd('format') == 'raw') {
$opts = trim($onLoad) !== '' ? '\'onLoad\':function(){' . $onLoad . '}' : '';
echo '<script type="text/javascript">Asset.javascript(\'' . $f . '\', {' . $opts . '});</script>';
} else {
$src[] = "'" . $f . "'";
}
}
if ($onLoad !== '' && JRequest::getCmd('format') != 'raw' && !empty($src)) {
//$onLoad = "head.ready(function() {\n " . $onLoad . "\n});\n";
//FabrikHelperHTML::addScriptDeclaration($onLoad);
if (FabrikHelperHTML::inAjaxLoadedPage()) {
$onLoad = "(function() {\n " . $onLoad . "\n //end load func \n})";
} else {
$onLoad = "(function() { head.ready(function() {\n" . $onLoad . "\n})\n})";
}
$src[] = $onLoad;
}
if (!empty($src)) {
JFactory::getDocument()->addScriptDeclaration('head.js(' . implode(",\n", array_unique($src)) . ');' . "\n");
}
}
示例6: _addJavascript
//.........這裏部分代碼省略.........
$opts->fabrik_window_id = JRequest::getVar('fabrik_window_id', '');
$opts->submitOnEnter = (bool) $params->get('submit_on_enter', false);
// For editing groups with joined data and an empty joined record (ie no joined records)
$hidden = array();
$maxRepeat = array();
$showMaxRepeats = array();
foreach ($this->groups as $g) {
$hidden[$g->id] = $g->startHidden;
$maxRepeat[$g->id] = $g->maxRepeat;
$showMaxRepeats[$g->id] = $g->showMaxRepeats;
}
$opts->hiddenGroup = $hidden;
$opts->maxRepeat = $maxRepeat;
$opts->showMaxRepeats = $showMaxRepeats;
// $$$ rob 26/04/2011 joomfish translations of password validation error messages
// $opts->lang = FabrikWorker::getJoomfishLang();
// $$$ hugh adding these so calc element can easily find joined and repeated join groups
// when it needs to add observe events ... don't ask ... LOL!
$opts->join_group_ids = array();
$opts->group_repeats = array();
$opts->group_joins_ids = array();
$groups = $model->getGroupsHiarachy();
foreach ($groups as $groupModel) {
if ($groupModel->getGroup()->is_join) {
$joinParams = new JRegistry($groupModel->getJoinModel()->getJoin()->params);
$opts->group_pk_ids[$groupModel->getGroup()->id] = FabrikString::safeColNameToArrayKey($joinParams->get('pk'));
$opts->join_group_ids[$groupModel->getGroup()->join_id] = (int) $groupModel->getGroup()->id;
$opts->group_join_ids[$groupModel->getGroup()->id] = (int) $groupModel->getGroup()->join_id;
$opts->group_repeats[$groupModel->getGroup()->id] = $groupModel->canRepeat();
$opts->group_copy_element_values[$groupModel->getGroup()->id] = $groupModel->canCopyElementValues();
}
}
$opts = json_encode($opts);
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_FORM_SAVED');
Jtext::script('COM_FABRIK_CONFIRM_DELETE');
}
// $$$ rob dont declare as var $bkey, but rather assign to window, as if loaded via ajax window the function is wrapped
// inside an anoymous function, and therefore $bkey wont be available as a global var in window
$script = array();
$script[] = "window.{$bkey} = new FbForm(" . $model->getId() . ", {$opts});";
$script[] = "if(typeOf(Fabrik) !== 'null') {";
$script[] = "Fabrik.addBlock('{$bkey}', {$bkey});";
$script[] = "}";
// Instantaite js objects for each element
$vstr = "\n";
$groups = $model->getGroupsHiarachy();
$script[] = "{$bkey}.addElements({";
$gs = array();
foreach ($groups as $groupModel) {
$showGroup = $groupModel->getParams()->get('repeat_group_show_first');
if ($showGroup == -1 || $showGroup == 2 && $model->isEditable()) {
// $$$ rob unpublished group so dont include the element js
continue;
}
$aObjs = 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) {
$element = $elementModel->getElement();
if ($element->published == 0) {
示例7: script
/**
* wrapper for JHTML::Script()
*/
function script($filename, $path = 'media/system/js/', $mootools = true)
{
static $rawmootools;
global $combine;
$app =& JFactory::getApplication();
if (FabrikHelperHTML::inAjaxLoadedPage()) {
// $$$rob TEST!!!! - this may mess up stuff
//no need to reload mootools as if this is an ajax request it has already been loaded
//FabrikHelperHTML::mootools();
static $ajaxJsFiles;
if (!is_array($ajaxJsFiles)) {
$ajaxJsFiles = array();
}
// $$$rob TEST!!!! - this may mess up stuff
//send an inline script back which will inject the javascript file into the doc head
// note your ajax call must have 'evalScripts':true set in its properties
// $$$ hugh - yeah, it messes up :) "Fatal error: Class 'FastJSON' not found"
// for instance when creating a calendar viz event ... added require_once
if (!in_array($path . $filename, $ajaxJsFiles)) {
$attribs = FastJSON::encode(JArrayHelper::toObject($attribs));
$file = $path . $filename;
if (substr($file, 0, 4) !== 'http') {
$file = COM_FABRIK_LIVESITE . $file;
}
echo "<script type=\"text/javascript\">var v = new Asset.javascript('" . $file . "', {});</script>\n";
$ajaxJsFiles[] = $path . $filename;
}
return;
}
// $$$ - hugh - something, somewhere is trying to add a blank filename
// with '/' as the directory, which ends up trying to load the main page
// as a JS file. So some defensive coding to avoid this!
// @TODO - really need to find out who is doing it tho!
if (empty($filename)) {
return;
}
FabrikHelperHTML::_getCombine();
$fbConfig =& JComponentHelper::getParams('com_fabrik');
if ($mootools) {
FabrikHelperHTML::mootools();
}
if (FabrikWorker::getMooVersion() == 1) {
$mootools = false;
}
if ($fbConfig->get('merge_js', false) && !$app->isAdmin()) {
$combine->addFile($path . $filename);
} else {
JHTML::script($filename, $path, $mootools);
}
}