function render($blockContent = NULL) { if (!$this->paginator instanceof WFPaginator) { throw new WFException("No paginator assigned to WFPaginatorState " . $this->id); } if ($this->paginator->mode() == WFPaginator::MODE_FORM) { //$this->importJS(self::yuiPath() . "/yahoo-dom-event/yahoo-dom-event.js", 'YAHOO'); } $html = parent::render($blockContent); // When restoring the value, only put back the SORT KEYS and PAGE SIZE; the page num should be RESET. $button = '<input type="hidden" id="' . $this->id . '" name="' . $this->name . '" value="' . $this->paginator->paginatorState() . '" />'; $js = NULL; if ($this->paginator->mode() == WFPaginator::MODE_FORM) { // js function to set paginator to go to first page when the MODE_FORM submit button is pressed. $paginatorResetJSFunctionName = "__WFPaginatorState_gotoFirstPage_{$this->id}"; // do not go to first page if the submit button was pressed by paginator MODE_FORM $paginatorModeFormSubmissionVarName = $this->paginator->jsPaginatorStateModeFormSubmissionVarName(); $js = $this->jsStartHTML() . ' var ' . $paginatorModeFormSubmissionVarName . ' = false; function ' . $this->paginator->jsPaginatorStateModeFormGoToStateFunctionName() . '(state) { ' . $this->paginator->jsPaginatorStateModeFormSubmissionVarName() . ' = true; document.getElementById("' . $this->id . '").value = state; document.getElementById("' . $this->paginator->submitID() . '").click(); } function ' . $paginatorResetJSFunctionName . '() { if (' . $paginatorModeFormSubmissionVarName . ' == true) return; var submitID = \'' . $this->paginator->submitID() . '\'; document.getElementById("' . $this->paginator->paginatorStateParameterID() . '").value = "' . $this->paginator->paginatorState(WFPaginator::PAGINATOR_FIRST_PAGE) . '"; }'; $loader = WFYAHOO_yuiloader::sharedYuiLoader(); $loader->yuiRequire('event'); $callback = 'function() { YAHOO.util.Event.addListener("' . $this->paginator->submitID() . '", "click", ' . $paginatorResetJSFunctionName . '); }'; $js .= $loader->jsLoaderCode($callback); $js .= $this->jsEndHTML(); } return $html . $js . $button; }
/** * IMPORTANT: The subclasses should get the base class's html, then add the needed code. * All subclasses need a DOM element of the ID of the widget so that the loading bootstrapping works correctly. */ function render($blockContent = NULL) { if ($this->hidden) { return NULL; } else { // set up basic HTML $html = parent::render($blockContent); $initJSCode = $this->initJS($blockContent); if ($initJSCode) { $html .= $this->jsStartHTML() . $this->yuiloader()->jsLoaderCode("function() {\n // alert('YUI deps loaded callback for \\'{$this->id}\\' widget');\n PHOCOA.namespace('widgets.{$this->id}.yuiDelegate');\n // let widget inject JS that depends on YUI libs, and define the init function\n {$initJSCode}\n\n YAHOO.util.Event.onContentReady('{$this->initializeWaitsForID}', function() {\n if (PHOCOA.widgets.{$this->id}.yuiDelegate.widgetWillLoad)\n {\n PHOCOA.widgets.{$this->id}.yuiDelegate.widgetWillLoad();\n }\n PHOCOA.widgets.{$this->id}.init();\n if (PHOCOA.widgets.{$this->id}.yuiDelegate.widgetDidLoad)\n {\n PHOCOA.widgets.{$this->id}.yuiDelegate.widgetDidLoad(PHOCOA.runtime.getObject('{$this->id}'));\n }\n });\n};\n") . $this->jsEndHTML(); } } return $html; }