/** * On callback response, the inner HTML of the label is updated. * @param string the text value of the label */ public function setText($value) { parent::setText($value); if ($this->getActiveControl()->canUpdateClientSide()) { $this->getPage()->getCallbackClient()->update($this, $value); } }
public function createLabel($s) { if ($this->_autoLabel) { $label = new TLabel(); $label->setText($this->_headerText ? $this->_headerText : $this->_dataField); $label->setForControl($s); $this->getControls()->add($label); } }
protected function createPagerButton($buttonType, $enabled, $text, $commandName, $commandParameter) { if ($buttonType === TPagerButtonType::LinkButton) { if ($enabled) { $button = new TActiveLinkButton(); } else { $button = new TLabel(); $button->setText($text); $button->setCssClass($this->getButtonCssClass() . ' active'); return $button; } } $button->setText($text); $button->setCommandName($commandName); $button->setCommandParameter($commandParameter); $button->setCausesValidation(false); $button->setCssClass($this->getButtonCssClass()); $button->attachEventHandler('OnCallback', array($this, 'handleCallback')); $button->getAdapter()->getBaseActiveControl()->setClientSide($this->getClientSide()); return $button; }
/** * Renders the body content enclosed between the control tag. * By default, child controls and text strings will be rendered. * You can override this method to provide customized content rendering. * @param THtmlWriter the writer used for the rendering purpose */ public function renderContents($writer) { $writer->renderBeginTag('center'); $writer->addAttribute('class', 'field'); $writer->renderBeginTag('div'); $writer->renderBeginTag('table'); $writer->renderBeginTag('tr'); $writer->renderBeginTag('td'); $startTimeLabel = new TLabel(); $startTimeLabel->setText(Prado::localize("Start time")); $this->addedControl($startTimeLabel); $startTimeLabel->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $this->startTime->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $endTimeLabel = new TLabel(); $endTimeLabel->setText(Prado::localize("End time")); $this->addedControl($endTimeLabel); $endTimeLabel->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $this->endTime->render($writer); $writer->renderEndTag(); if ($this->getPlannerType() == 'Access') { $writer->renderBeginTag('td'); $pincodeLabel = new TLabel(); $pincodeLabel->setText(Prado::localize("Pin Code necessary")); $this->addedControl($pincodeLabel); $pincodeLabel->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $this->pinCode->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $exitingOnlyLabel = new TLabel(); $exitingOnlyLabel->setText(Prado::localize("Exiting only")); $this->addedControl($exitingOnlyLabel); $exitingOnlyLabel->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $this->exitingOnly->render($writer); $writer->renderEndTag(); } else { $writer->renderBeginTag('td'); $unlockingLabel = new TLabel(); $unlockingLabel->setText(Prado::localize("Unlocking")); $this->addedControl($unlockingLabel); $unlockingLabel->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $this->unlocking->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $supOpenTooLongAlarmLabel = new TLabel(); $supOpenTooLongAlarmLabel->setText(Prado::localize("Sup. 'door open too long alarm'")); $this->addedControl($supOpenTooLongAlarmLabel); $supOpenTooLongAlarmLabel->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $this->supOpenTooLongAlarm->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $supWithoutPermAlarmLabel = new TLabel(); $supWithoutPermAlarmLabel->setText(Prado::localize("Sup. 'open without permission alarm'")); $this->addedControl($supWithoutPermAlarmLabel); $supWithoutPermAlarmLabel->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $this->supWithoutPermAlarm->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $checkOnlyCompanyIDLabel = new TLabel(); $checkOnlyCompanyIDLabel->setText(Prado::localize("Check only company ID")); $this->addedControl($checkOnlyCompanyIDLabel); $checkOnlyCompanyIDLabel->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $this->checkOnlyCompanyID->render($writer); $writer->renderEndTag(); } $writer->renderBeginTag('td'); $specialRelayPlanLabel = new TLabel(); $specialRelayPlanLabel->setText(Prado::localize("Use special relay plan")); $this->addedControl($specialRelayPlanLabel); $specialRelayPlanLabel->render($writer); $writer->renderEndTag(); $writer->renderBeginTag('td'); $this->specialRelayPlan->render($writer); $writer->renderEndTag(); $writer->renderEndTag(); $writer->renderEndTag(); $writer->renderEndTag(); $writer->renderEndTag(); $arrDays = $this->getDayNames(); $date = mktime($this->getStartHourOfWeek(), 0, 0, 5, 5, 2006); $suffix = "00"; // Enable this line in case you want to show hours like 08:00 - 23:00 $writer->addAttribute('id', 'weekScheduler_top'); $writer->renderBeginTag('div'); $writer->addAttribute('class', 'spacer'); $writer->renderBeginTag('div'); $writer->renderBeginTag('span'); $writer->renderEndTag(); $writer->renderEndTag(); $writer->addAttribute('id', 'weekScheduler_dayRow'); $writer->addAttribute('class', 'days'); $writer->renderBeginTag('div'); foreach ($arrDays as $name) { $writer->renderBeginTag('div'); $writer->write($name); $writer->renderBeginTag('span'); $writer->renderEndTag(); $writer->renderEndTag(); } $writer->renderEndTag(); $writer->renderEndTag(); $writer->addAttribute('id', 'weekScheduler_content'); $writer->renderBeginTag('div'); $writer->addAttribute('id', 'weekScheduler_hours'); $writer->renderBeginTag('div'); for ($no = $this->getStartHourOfWeek(); $no <= $this->getEndHourOfWeek(); $no++) { $suffix = date("a", $date); $hour = date("g", $date); $hour = $no . ":00"; $writer->addAttribute('class', 'calendarContentTime'); $writer->renderBeginTag('div'); $writer->write($hour); /*$writer->addAttribute('class','content_hour'); $writer->renderBeginTag('span'); $writer->write($suffix); $writer->renderEndTag();*/ $writer->renderEndTag(); $date = $date + 3600; } $writer->renderEndTag(); $writer->addAttribute('id', 'weekScheduler_appointments'); $writer->renderBeginTag('div'); // Looping through the days of a week for ($no = 0; $no < 7; $no++) { $writer->addAttribute('class', 'weekScheduler_appointments_day'); $writer->renderBeginTag('div'); for ($no2 = $this->getStartHourOfWeek(); $no2 <= $this->getEndHourOfWeek(); $no2++) { $writer->addAttribute('id', "weekScheduler_appointment_hour" . $no . "_" . $no2); $writer->addAttribute('class', 'weekScheduler_appointmentHour'); $writer->renderBeginTag('div'); $writer->renderEndTag(); } $writer->renderEndTag(); } $writer->renderEndTag(); $writer->renderEndTag(); }
/** * Creates a pager button. * Depending on the button type, a TLinkButton or a TButton may be created. * If it is enabled (clickable), its command name and parameter will also be set. * Derived classes may override this method to create additional types of buttons, such as TImageButton. * @param string button type, either LinkButton or PushButton * @param boolean whether the button should be enabled * @param string caption of the button. * @param string CommandName corresponding to the OnCommand event of the button. * @param string CommandParameter corresponding to the OnCommand event of the button * @return mixed the button instance */ protected function createPagerButton($buttonType, $enabled, $text, $commandName, $commandParameter) { if ($buttonType === TPagerButtonType::LinkButton) { if ($enabled) { $button = new TLinkButton(); } else { $button = new TLabel(); $button->setText($text); return $button; } } else { if ($buttonType === TPagerButtonType::ImageButton) { $button = new TImageButton(); $button->setImageUrl($this->getPageImageUrl($text, $commandName)); } else { $button = new TButton(); } if (!$enabled) { $button->setEnabled(false); } } $button->setText($text); $button->setCommandName($commandName); $button->setCommandParameter($commandParameter); $button->setCausesValidation(false); return $button; }
/** * Creates a pager button. * Depending on the button type, a TLinkButton or a TButton may be created. * If it is enabled (clickable), its command name and parameter will also be set. * Derived classes may override this method to create additional types of buttons, such as TImageButton. * @param mixed the container pager instance of TActiveDatagridPager * @param string button type, either LinkButton or PushButton * @param boolean whether the button should be enabled * @param string caption of the button * @param string CommandName corresponding to the OnCommand event of the button * @param string CommandParameter corresponding to the OnCommand event of the button * @return mixed the button instance */ protected function createPagerButton($pager, $buttonType, $enabled, $text, $commandName, $commandParameter) { if ($buttonType === TDataGridPagerButtonType::LinkButton) { if ($enabled) { $button = new TLinkButton(); } else { $button = new TLabel(); $button->setText($text); return $button; } } else { $button = new TButton(); if (!$enabled) { $button->setEnabled(false); } } $button->setText($text); $button->setCommandName($commandName); $button->setCommandParameter($commandParameter); $button->setCausesValidation(false); return $button; }
/** * Creates a pager button. * Override parent implementation to create, depending on the button type, a TActiveLinkButton, * a TActiveButton or a TActiveImageButton may be created. * * @param string button type, either LinkButton or PushButton * @param boolean whether the button should be enabled * @param string caption of the button * @param string CommandName corresponding to the OnCommand event of the button * @param string CommandParameter corresponding to the OnCommand event of the button * @return mixed the button instance */ protected function createPagerButton($buttonType, $enabled, $text, $commandName, $commandParameter) { if ($buttonType === TPagerButtonType::LinkButton) { if ($enabled) { $button = new TActiveLinkButton(); } else { $button = new TLabel(); $button->setText($text); return $button; } } else { if ($buttonType === TPagerButtonType::ImageButton) { $button = new TActiveImageButton(); $button->setImageUrl($this->getPageImageUrl($text, $commandName)); if ($enabled) { $button->Visible = true; } else { $button->Visible = false; } } else { $button = new TActiveButton(); if (!$enabled) { $button->setEnabled(false); } } } if ($buttonType === TPagerButtonType::ImageButton) { $button->ImageUrl = $text; } $button->setText($text); $button->setCommandName($commandName); $button->setCommandParameter($commandParameter); $button->setCausesValidation(false); $button->attachEventHandler('OnCallback', array($this, 'handleCallback')); $button->getAdapter()->getBaseActiveControl()->setClientSide($this->getClientSide()); return $button; }
/** * Creates a pager button. * Depending on the button type, a TActiveLinkButton or a TActiveButton may be created. * If it is enabled (clickable), its command name and parameter will also be set. * It overrides the datagrid's original method to create active controls instead, thus * the pager will do callbacks instead of the regular postbacks. * @param mixed the container pager instance of TActiveDatagridPager * @param string button type, either LinkButton or PushButton * @param boolean whether the button should be enabled * @param string caption of the button * @param string CommandName corresponding to the OnCommand event of the button * @param string CommandParameter corresponding to the OnCommand event of the button * @return mixed the button instance */ protected function createPagerButton($pager, $buttonType, $enabled, $text, $commandName, $commandParameter) { if ($buttonType === TDataGridPagerButtonType::LinkButton) { if ($enabled) { $button = new TActiveLinkButton(); } else { $button = new TLabel(); $button->setText($text); return $button; } } else { $button = new TActiveButton(); if (!$enabled) { $button->setEnabled(false); } } $button->setText($text); $button->setCommandName($commandName); $button->setCommandParameter($commandParameter); $button->setCausesValidation(false); $button->getAdapter()->getBaseActiveControl()->setClientSide($pager->getClientSide()); return $button; }
protected function setFilter() { $cmd = $this->db->createCommand(SQL::SQL_GET_EXPORT); $cmd->bindValue(":id", $this->Request['id']); $data = $cmd->query(); $data = $data->read(); $sql = $data['sql']; $expreg = "(:\\w*_\\w*)"; $jsParams = "var param = '&id=" . $this->Request['id'] . "'"; if (preg_match_all($expreg, $sql, $catches)) { foreach ($catches[0] as $catch) { $type = explode("_", $catch); $this->catches[] = substr($catch, 1, strlen($catch) - 1); if (count($type) == 2) { $fName = $type[1]; } else { $fName = 'TBD'; } $label = new TLabel(); $label->setText($fName . ' '); $this->filtre->Controls[] = $label; switch ($type[0]) { case ':date': $date = new TActiveDatePicker(); $date->setText(''); $date->setMode('ImageButton'); $date->setID(substr($catch, 1, strlen($catch) - 1)); $date->OnCallBack = array($this, "filterChange"); $this->filtre->Controls[] = $date; $this->jsPrint .= "var {$fName} = document.getElementById('" . $date->getClientID() . "');\n"; $jsParams .= "+ '&" . substr($catch, 1, strlen($catch) - 1) . "=' + {$fName}.value"; break; case ':int': $int = new TActiveTextBox(); $int->setID(substr($catch, 1, strlen($catch) - 1)); $int->setText(0); $int->OnCallBack = array($this, "filterChange"); $this->filtre->Controls[] = $int; $this->jsPrint .= "var {$fName} = document.getElementById('" . $int->getClientID() . "');\n"; $jsParams .= "+ '&" . substr($catch, 1, strlen($catch) - 1) . "=' + {$fName}.value"; break; case ':string': $string = new TActiveTextBox(); $string->setID(substr($catch, 1, strlen($catch) - 1)); $string->setText(''); $string->setAutoPostBack(true); $string->OnCallBack = array($this, "filterChange"); $this->filtre->Controls[] = $string; $this->jsPrint .= "var {$fName} = document.getElementById('" . $string->getClientID() . "');\n"; $jsParams .= "+ '&" . substr($catch, 1, strlen($catch) - 1) . "=' + {$fName}.value"; break; } $label = new TLabel(); $label->setText(' '); $this->filtre->Controls[] = $label; } } $jsParams .= "+ '&pdf=' + document.getElementById('" . $this->pdfExport->getClientID() . "').checked"; $jsParams .= "+ '&excel=' + document.getElementById('" . $this->excelExport->getClientID() . "').checked"; $jsParams .= "+ '&csv=' + document.getElementById('" . $this->csvExport->getClientID() . "').checked"; $this->jsPrint .= $jsParams . ";\n"; $this->jsPrint .= 'window.open( "' . $this->Service->constructUrl($this->getApplication()->getService()->getRequestedPagePath()) . '&action=print" + param, target="_blank" ) ;'; }
public function testSetText() { $label = new TLabel(); $label->setText('Test'); $this->assertEquals('Test', $label->getText()); }
private function processChildren($writer) { if ($this->getNodeType() == PFTreeList::NODE_TYPE_INTERNAL_LINK) { $title = new InternalHyperLink(); $title->setToPage($this->getToPage()); $title->setGetVariables($this->getGetVariables()); $title->setAnchor($this->getAnchor()); $title->Attributes->OnClick = "toggleSub('" . $this->getID() . "')"; } elseif ($this->getNodeType() == PFTreeList::NODE_TYPE_INTERNAL_ACTIVE_LINK) { $title = new InternalHyperLink(); $title->setToPage($this->getToPage()); $title->setGetVariables($this->getGetVariables()); $title->setAnchor($this->getAnchor()); $title->Attributes->OnClick = "toggleSub('" . $this->getID() . "')"; } elseif ($this->getNodeType() == PFTreeList::NODE_TYPE_LINK) { $title = new THyperLink(); $title->setNavigateUrl($this->getToPage()); $title->Attributes->OnClick = "toggleSub('" . $this->getID() . "')"; } else { $title = new TLabel(); } $title->setCssClass($this->getTitleClass()); $title->setText($this->getTitle()); $i = 0; foreach ($this->subTree as $c) { if (!$c instanceof TWebControl) { continue; } $i++; break; } if ($i == 0) { $class = "leaf"; $fct = ""; } else { $class = $this->getDeploy() ? "node" : "nodeDeployed"; $fct = $this->getCanDeploy() ? "onClick='toggleSub(\"" . $this->getID() . "\")'" : ""; } $writer->write("<li class='{$class}' {$fct} id='" . $this->getID() . PFTreeList::SUB_ID_LI . "'>"); $title->render($writer); $writer->write("</li>"); $cssclass = $this->getCssClass() ? " class='" . $this->getCssClass() . "'" : ""; $style = $this->getDeploy() ? "block" : "none"; if ($i > 0) { $writer->write("<li style='list-style: none outside; padding-left:0px; margin-left:0px; min-height: 0px;' id='" . $this->getID() . PFTreeList::SUB_ID_UL . "'><ul {$cssclass} style='display: {$style}'>\n"); } $order = 0; foreach ($this->subTree as $c) { if (!$c instanceof TWebControl) { continue; } if ($c instanceof PFTreeList) { $c->Parent = $this; $c->setOrder($order++); $c->setCssClass($this->getCssClass()); $c->render($writer); } else { $cssclass = $this->getCssClass() ? " class='" . $this->getCssClass() . "'" : ""; $writer->write("<ul {$cssclass}><li class='leaf'>"); $c->getPage()->addParsedObject($c); $c->render($writer); $writer->write("</li></ul>\n"); } } if ($i > 0) { $writer->write("</ul></li>\n"); } }