assets/php/_devtools/jquery_ui_gen/jq_control.tpl.php
<?= '<?php' ?>
<?php
/**
* <?= $objJqDoc->strQcClass ?>Gen File
*
* The abstract <?= $objJqDoc->strQcClass ?>Gen class defined here is
* code-generated and contains options, events and methods scraped from the
* documentation Web site. It is not generated by the typical
* codegen process, but rather is generated periodically by the core QCubed
* team and checked in. However, the code to generate this file is
* in the assets/_core/php/_devetools/jquery_ui_gen/jq_control_gen.php file
* and you can regenerate the files if you need to.
*
* The comments in this file are taken from the api reference site, so they do
* not always make sense with regard to QCubed. They are simply provided
* as reference. Note that this is very low-level code, and does not always
* update QCubed state variables. See the <?= $objJqDoc->strQcClass ?>Base
* file, which contains code to interface between this generated file and QCubed.
*
* Because subsequent re-code generations will overwrite any changes to this
* file, you should leave this file unaltered to prevent yourself from losing
* any information or code changes. All customizations should be done by
* overriding existing or implementing new methods, properties and variables
* in the <?= $objJqDoc->strQcClass ?> class file.
*
*/
/* Custom event classes for this control */
?>
<?php foreach ($objJqDoc->events as $event) { ?>
/**
<?= jq_indent($event->description, 1, true); ?>
*/
class <?= $event->eventClassName ?> extends QJqUiEvent {
const EventName = '<?= $event->eventName ?>';
}
<?php } ?>
/* Custom "property" event classes for this control */
<?php foreach ($objJqDoc->options as $option) { ?>
<?php if ($option instanceof Event) { ?>
/**
<?= jq_indent($option->description, 1, true); ?>
*/
class <?= $option->eventClassName ?> extends QJqUiPropertyEvent {
const EventName = '<?= $option->eventName ?>';
protected $strJqProperty = '<?= $option->name ?>';
}
<?php } ?>
<?php } ?>
/**
* Generated <?= $objJqDoc->strQcClass ?>Gen class.
*
* This is the <?= $objJqDoc->strQcClass ?>Gen class which is automatically generated
* by scraping the JQuery UI documentation website. As such, it includes all the options
* as listed by the JQuery UI website, which may or may not be appropriate for QCubed. See
* the <?= $objJqDoc->strQcClass ?>Base class for any glue code to make this class more
* usable in QCubed.
*
* @see <?= $objJqDoc->strQcClass ?>Base
* @package Controls\Base
<?php foreach ($objJqDoc->options as $option) { ?>
* @property <?= $option->phpType ?> $<?= $option->propName ?>
<?= jq_indent($option->description, 1, true); ?>
*
<?php } ?>
*/
<?= $objJqDoc->strAbstract ?>class <?= $objJqDoc->strQcClass ?>Gen extends <?= $objJqDoc->strQcBaseClass ?> {
protected $strJavaScripts = __JQUERY_EFFECTS__;
protected $strStyleSheets = __JQUERY_CSS__;
<?php foreach ($objJqDoc->options as $option) { ?>
/** @var <?= $option->phpType ?> */
<?php if (!$option->defaultValue) { ?>
protected $<?= $option->varName ?>;
<?php } ?>
<?php if ($option->defaultValue) { ?>
protected $<?= $option->varName ?> = null;
<?php } ?>
<?php } ?>
/**
* Builds the option array to be sent to the widget constructor.
*
* @return array key=>value array of options
*/
protected function MakeJqOptions() {
<?php if (method_exists($objJqDoc->strQcBaseClass, 'MakeJqOptions')) { ?>
$jqOptions = parent::MakeJqOptions();
<?php } ?>
<?php if (!method_exists($objJqDoc->strQcBaseClass, 'MakeJqOptions')) { ?>
$jqOptions = null;
<?php } ?>
<?php foreach ($objJqDoc->options as $option) { ?>
if (!is_null($val = $this-><?= $option->propName ?>)) {$jqOptions['<?= $option->name ?>'] = $val;}
<?php } ?>
return $jqOptions;
}
/**
* Return the JavaScript function to call to associate the widget with the control.
*
* @return string
*/
public function GetJqSetupFunction() {
return '<?= $objJqDoc->strJqSetupFunc ?>';
}
/**
* Returns the script that attaches the JQueryUI widget to the html object.
*
* @return string
*/
public function GetEndScript() {
$strId = $this->GetJqControlId();
$jqOptions = $this->makeJqOptions();
$strFunc = $this->getJqSetupFunction();
if ($strId !== $this->ControlId && QApplication::$RequestMode == QRequestMode::Ajax) {
// If events are not attached to the actual object being drawn, then the old events will not get
// deleted during redraw. We delete the old events here. This must happen before any other event processing code.
QApplication::ExecuteControlCommand($strId, 'off', QJsPriority::High);
}
// Attach the javascript widget to the html object
if (empty($jqOptions)) {
QApplication::ExecuteControlCommand($strId, $strFunc, QJsPriority::High);
} else {
QApplication::ExecuteControlCommand($strId, $strFunc, $jqOptions, QJsPriority::High);
}
return parent::GetEndScript();
}
<?php foreach ($objJqDoc->methods as $method) { ?>
/**
* <?= str_replace("\n", "\n\t\t * ", wordwrap(trim($method->description))) ?>
<?php foreach ($method->requiredArgs as $reqArg) { ?>
<?php if ($reqArg{0} != '"') { ?>
* @param <?= $reqArg ?>
<?php } ?>
<?php } ?>
<?php foreach ($method->optionalArgs as $optArg) { ?>
* @param <?= $optArg ?>
<?php } ?>
*/
public function <?= $method->phpSignature ?> {
<?php
$args = array();
foreach ($method->requiredArgs as $reqArg) {
$args[] = $reqArg;
}
foreach ($method->optionalArgs as $optArg) {
$args[] = $optArg;
}
$strArgs = join(", ", $args);
?>
QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), <?= $strArgs; ?>, QJsPriority::Low);
}
<?php } ?>
public function __get($strName) {
switch ($strName) {
<?php foreach ($objJqDoc->options as $option) { ?>
case '<?= $option->propName ?>': return $this-><?= $option->varName ?>;
<?php } ?>
default:
try {
return parent::__get($strName);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
public function __set($strName, $mixValue) {
switch ($strName) {
<?php foreach ($objJqDoc->options as $option) { ?>
case '<?= $option->propName ?>':
<?php if (!$option->phpQType) { ?>
$this-><?= $option->varName ?> = $mixValue;
<?php if (!($option instanceof Event)) { ?>
$this->AddAttributeScript($this->getJqSetupFunction(), 'option', '<?= $option->name ?>', $mixValue);
break;
<?php } ?>
<?php } ?>
<?php if ($option->phpQType) { ?>
try {
<?php if (!($option instanceof Event)) { ?>
$this-><?= $option->varName ?> = QType::Cast($mixValue, <?= $option->phpQType ?>);
$this->AddAttributeScript($this->getJqSetupFunction(), 'option', '<?= $option->name ?>', $this-><?= $option->varName ?>);
<?php } ?>
<?php if ($option instanceof Event) { ?>
$this-><?= $option->varName ?> = new QJsClosure($mixValue, array("<?= join('","', $option->arrArgs) ?>"));
<?php } ?>
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
<?php } ?>
<?php } ?>
<?php if ($objJqDoc->hasDisabledProperty) { ?>
case 'Enabled':
$this->Disabled = !$mixValue; // Tie in standard QCubed functionality
parent::__set($strName, $mixValue);
break;
<?php } ?>
default:
try {
parent::__set($strName, $mixValue);
break;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
/**
* If this control is attachable to a codegenerated control in a ModelConnector, this function will be
* used by the ModelConnector designer dialog to display a list of options for the control.
* @return QModelConnectorParam[]
**/
public static function GetModelConnectorParams() {
return array_merge(parent::GetModelConnectorParams(), array(
<?php foreach ($objJqDoc->options as $option) { ?>
<?php if ($option->phpQType) { ?>
new QModelConnectorParam (get_called_class(), '<?= $option->propName ?>', '<?= addslashes(trim(str_replace(array("\n", "\r"), '', $option->description))) ?>', <?= $option->phpQType ?>),
<?php } ?>
<?php } ?> ));
}
}