$this->flaSample->TemporaryUploadPath = __QCUBED_UPLOAD__; $this->flaSample->ClickToView = true; // NOTICE: If we are wanting users to immediately "click to view" files that are uploaded directly to the docroot, // we MUST take security precautions to prevent users from executing arbitrary code on the system. // Precautions could be: defining / overriding our own GetWebUrl() method in QFileAsset or // limiting the "types" of files that a user could upload. We will go ahead and do this limiting here. $this->flaSample->FileAssetType = QFileAssetType::Image; // Feel free to uncomment this yourself, but note that you can pre-define the File property. // Notice how the path is an absolute path to a file. // Also notice that the file doesn't even need to be in the docroot. // $this->flaSample->File = __DOCROOT__ . __IMAGE_ASSETS__ . '/calendar.png'; // Add Styling $this->flaSample->CssClass = 'file_asset'; $this->flaSample->imgFileIcon->CssClass = 'file_asset_icon'; $this->lblMessage = new QLabel($this); $this->lblMessage->Text = 'Click on the button to change this message.'; // The "Form Submit" Button -- notice how the form is being submitted via AJAX, even though we are handling // File Uploads on the form. $this->btnButton = new QButton($this); $this->btnButton->Text = 'Click Me'; $this->btnButton->AddAction(new QClickEvent(), new QAjaxAction('btnButton_Click')); $this->btnButton->CausesValidation = true; } protected function btnButton_Click($strFormId, $strControlId, $strParameter) { $this->lblMessage->Text = 'Thanks for uploading the file: ' . $this->flaSample->FileName . ". File size: " . $this->flaSample->Size . " bytes"; } } // And now run our defined form ExampleForm::Run('ExampleForm', 'file_asset.tpl.php');
* @param $item * @return string */ public function dtgPerson_BalanceRender($item) { $val = $item->Budget - $item->Spent; if ($val < 0) { return '(' . number_format(-$val) . ')'; } else { return number_format($val); } } /** * Style the number in the column. All number columns will use the amount class. If the number is negative, make * the cell red. * * @param $item * @return mixed */ public function dtgPerson_BalanceAttributes($item) { $ret['class'] = 'amount'; $val = $item->Budget - $item->Spent; if ($val < 0) { $ret['style'] = 'color:red'; } return $ret; } } ExampleForm::Run('ExampleForm');
require __INCLUDES__ . '/examples/examples.inc.php'; // Define the Qform with all our Qcontrols class ExampleForm extends ExamplesBaseForm { // Local declarations of our Qcontrols protected $lblMessage; protected $btnButton; // Initialize our Controls during the Form Creation process protected function Form_Create() { // Define the Label $this->lblMessage = new QLabel($this); $this->lblMessage->Text = 'Click the button to change my message.'; // Define the Button $this->btnButton = new QButton($this); $this->btnButton->Text = 'Click Me!'; // Add a Click event handler to the button -- the action to run is an AjaxAction. // The AjaxAction names a PHP method (which will be run asynchronously) called "btnButton_Click" $this->btnButton->AddAction(new QClickEvent(), new QAjaxAction('btnButton_Click')); } // The "btnButton_Click" Event handler protected function btnButton_Click($strFormId, $strControlId, $strParameter) { $this->lblMessage->Text = 'Hello, world!'; } } // Run the Form we have defined // We will explicitly specify an alternate filepath for the HTML template file. Note // that this filepath is relative to the path of this PHP script. ExampleForm::Run('ExampleForm', 'some_template_file.tpl.php');