public function logar(Login $login) { $Sql = new Sql(); $sb = new StringBuilder(); $sb->append("SELECT *"); $sb->append("FROM " . T_USUARIO); $sb->append(sprintf("WHERE login_usr = %s", $login->getLoginUsr())); $sb->append(sprintf("AND senha_usr = %s", $login->getSenhaUsr())); $sb->append("AND ativo_usr = 1"); $retorno = $Sql->ExecutaSQL($sb->toString()); if (count($retorno) > 0) { global $Sess; // Dados do Usuario Logado $Sess->usuario = $retorno[0]; // Atualiza o usuário $usuario = new Usuarios(); $usuario->setCodigoUsr(toNumero($retorno[0]['codigo_usr'])); $usuario->setUltimoacessoUsr(toDateTime()); $this->alterar($usuario); // inicia Sessao $Sess->logado_sys = true; $Sess->ultimoacesso_sys = time(); return true; } return false; }
function toString() { $builder = new StringBuilder(); $builder->append($this->getHeader()); $builder->append($this->_parse()); $builder->append($this->getFooter()); return $builder->toString(); }
public function listarElogio($_prElogio) { $Sql = new Sql(); $sb = new StringBuilder(); $sb->append("SELECT *"); $sb->append("FROM " . T_ELOGIO); $sb->append(sprintf("WHERE codigo_elo = %s", toNumero($_prElogio))); return $Sql->ExecutaSQL($sb->toString()); }
public function consultaCodigo($_prCodigo) { $sb = new StringBuilder(); $Sql = new Sql(); $sb->append("SELECT *"); $sb->append("FROM " . T_AGENDA); $sb->append(sprintf("WHERE codigo_age = %s", $_prCodigo)); return $Sql->executaSQL($sb->toString()); }
public function existe(Usuarios $_prClasse) { $sb = new StringBuilder(); $Sql = new Sql(); $sb->append("SELECT 1 AS TOTAL"); $sb->append("FROM " . T_USUARIO); $sb->append("WHERE UPPER(login_usr) = " . strtoupper($_prClasse->getLoginUsr())); $retorno = $Sql->ExecutaSQL($sb->toString()); return $retorno[0]['TOTAL'] > 0 ? true : false; }
public function listarSelecao($_prSelecao = 0) { $sb = new StringBuilder(); $Sql = new Sql(); $sb->append("SELECT *"); $sb->append("FROM " . T_EMP); if ($_prSelecao > 0) { $sb->append(sprintf("WHERE codigo_emp IN (%s)", $_prSelecao)); } return $Sql->executaSQL($sb->toString()); }
public function ToString() { $builder = new StringBuilder(); $builder->append("Command: {$this->_query}\n"); $builder->append("Parameters ({$this->Parameters->Count()}): \n"); for ($i = 0; $i < $this->Parameters->Count(); $i++) { $parameter = $this->Parameters->Items($i); $builder->append("{$parameter->Name} = {$parameter->Value}"); } return $builder->toString(); }
/** * @param DC_General $dc */ public function renderPreviewView(EnvironmentInterface $environment) { /** @var EventDispatcher $eventDispatcher */ $eventDispatcher = $GLOBALS['container']['event-dispatcher']; $eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, new LoadLanguageFileEvent('avisota_message_preview')); $eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, new LoadLanguageFileEvent('orm_avisota_message')); $input = \Input::getInstance(); $messageRepository = EntityHelper::getRepository('Avisota\\Contao:Message'); $messageId = IdSerializer::fromSerialized($input->get('id') ? $input->get('id') : $input->get('pid')); $message = $messageRepository->find($messageId->getId()); if (!$message) { $environment = \Environment::getInstance(); $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent(preg_replace('#&(act=preview|id=[a-f0-9\\-]+)#', '', $environment->request))); } $modules = new \StringBuilder(); /** @var \Avisota\Contao\Message\Core\Send\SendModuleInterface $module */ foreach ($GLOBALS['AVISOTA_SEND_MODULE'] as $className) { $class = new \ReflectionClass($className); $module = $class->newInstance(); $modules->append($module->run($message)); } $context = array('message' => $message, 'modules' => $modules); $template = new \TwigTemplate('avisota/backend/preview', 'html5'); return $template->parse($context); }
public function testAppendReplace() { $sb = new StringBuilder(); $sb->append('a1'); $sb->appendReplace('a2', 'a', 'b'); $this->assertEquals('a1b2', $sb->build()); }
public static function readString(InputStream $stream) { $length = self::readShort($stream); $builder = new StringBuilder(); for ($i = 0; $i != $length; ++$i) { $builder->append(chr(self::readShort($stream))); } self::readShort($stream); return $builder->toString(); }
function formatReminder() { $builder = new StringBuilder(); if ($this->_reservation->reminder_minutes_prior != 0) { $reminder_time = $this->_reservation->start + $this->_reservation->start * 60 - $this->_reservation->reminder_minutes_prior * 60; $adjusted = Time::getAdjustedTime($reminder_time); $builder->append(sprintf("DALARM:%sT%sZ\r\n", date('Ymd', $adjusted), date('His', $adjusted))); } return $builder->toString(); }
private function step1b() { $this->step1bReplacements->rewind(); while ($this->step1bReplacements->valid()) { if ($this->sb->count() > strlen($this->step1bReplacements->key()) && $this->sb->SubStr($this->sb->count() - strlen($this->step1bReplacements->key()), strlen($this->step1bReplacements->key())) == $this->step1bReplacements->key()) { switch ($this->step1bReplacements->key()) { case "eedly": if ($this->sb->count() - strlen($this->step1bReplacements->key()) >= $this->r1) { $this->sb->Replace($this->step1bReplacements->key(), $this->step1bReplacements->current(), $this->sb->count() - strlen($this->step1bReplacements->key()), strlen($this->step1bReplacements->key())); } break; case "eed": if ($this->sb->count() - strlen($this->step1bReplacements->key()) >= $this->r1) { $this->sb->Replace($this->step1bReplacements->key(), $this->step1bReplacements->current(), $this->sb->count() - strlen($this->step1bReplacements->key()), strlen($this->step1bReplacements->key())); } break; default: if (true === $this->found) { $this->found = false; } for ($j = 0; $j < $this->sb->count() - strlen($this->step1bReplacements->key()); $j++) { if ($this->isVowel($j)) { $this->sb->Replace($this->step1bReplacements->key(), $this->step1bReplacements->current(), $this->sb->count() - strlen($this->step1bReplacements->key()), strlen($this->step1bReplacements->key())); $this->found = true; break; } } if (false === $this->found) { return; } switch ($this->sb->SubStr($this->sb->count() - 2, 2)) { case "at": $this->sb->append("e"); return; case "bl": $this->sb->append("e"); return; case "iz": $this->sb->append("e"); return; } if (in_array($this->sb->SubStr($this->sb->count() - 2, 2), $this->doubles, true)) { $this->sb->Remove($this->sb->count() - 1, 1); return; } if ($this->isShortWord()) { $this->sb->append("e"); } break; } return; } $this->step1bReplacements->next(); } }
public function listaDestinatarios($_prComunicado) { $sb = new StringBuilder(); $Sql = new Sql(); $sb->append("SELECT *"); $sb->append("FROM " . T_COMEMP); $sb->append("LEFT JOIN"); $sb->append(T_EMP); $sb->append("ON codigo_emp = empregado_coe"); $sb->append(sprintf("WHERE comunicado_coe = %s", $_prComunicado)); return $Sql->executaSQL($sb->toString()); }
public function testAppend() { $this->stringBuilder->append(' The end is near!'); $this->assertEquals('Hello § World! The end is near!', $this->stringBuilder->__toString()); }
/** * <p>Capitalizes all the delimiter separated words in a String. * Only the first letter of each word is changed. To convert the * rest of each word to lowercase at the same time, * use {@link #capitalizeFully(String, char[])}.</p> * * <p>The delimiters represent a set of characters understood to separate words. * The first string character and the first non-delimiter character after a * delimiter will be capitalized. </p> * * <p>A <code>null</code> input String returns <code>null</code>. * Capitalization uses the unicode title case, normally equivalent to * upper case.</p> * * <pre> * WordUtils.capitalize(null, *) = null * WordUtils.capitalize("", *) = "" * WordUtils.capitalize(*, new char[0]) = * * WordUtils.capitalize("i am fine", null) = "I Am Fine" * WordUtils.capitalize("i aM.fine", {'.'}) = "I aM.Fine" * </pre> * * @param string $str the string to capitalize, may be null * @param array $delimiters set of characters to determine capitalization, * <tt>null</tt> means whitespace * @return capitalized String, <code>null</code> if null String input * @see #uncapitalize(String) * @see #capitalizeFully(String) * @since 2.1 */ public static function capitalize($str, array $delimiters = array(' ')) { //$delimLen = (delimiters == null ? -1 : delimiters.length); if (is_null($str) || is_empty($str) == 0 || $delimLen == 0) { return $str; } $strLen = strlen($str); $buffer = new StringBuilder(strLen); $capitalizeNext = true; for ($i = 0; $i < $strLen; $i++) { $ch = substr($str, $i, 1); if (WordUtils::isDelimiter($ch, $delimiters)) { $buffer->append($ch); $capitalizeNext = true; } else { if ($capitalizeNext) { $buffer->append(strtoupper($ch)); $capitalizeNext = false; } else { $buffer->append(ch); } } } return $buffer->toString(); }
public function getEmptyDirective($name) { $sb = new StringBuilder(); $sb->append("class " . $name); $sb->appendLine(); $sb->append("{"); $sb->appendLine()->appendTab()->append("constructor(){"); $sb->appendLine()->appendTab2()->append("this.restrict='E';"); $sb->appendLine()->appendTab2()->append("this.templateUrl='Scripts/Directives/{$name}/{$name}.html';"); $sb->appendLine()->appendTab()->append("}"); $sb->appendLine(); $sb->appendTab()->append("static builder()"); $sb->appendTab()->append("{"); $sb->appendLine(); $sb->appendTab2()->append("return new {$name}();"); $sb->appendLine(); $sb->appendTab()->append("}"); $sb->appendLine(); $sb->append("}"); $sb->appendLine()->append("export default {$name};"); return $sb->toString(); }
private function montaAgendamento($_prAgenda) { $sb = new StringBuilder(); $sb->append("<html>"); $sb->append("<head></head>"); $sb->append("<body>"); $sb->append("Foi agendado uma entrevista com o Candidato <strong>"); $sb->append($_prAgenda['candidato_age']); $sb->append("</strong> para "); $sb->append(format_date($_prAgenda['inicio_age'])); $sb->append(" ate "); $sb->append(format_date($_prAgenda['final_age'])); $sb->append("<br><br>"); $sb->append("Observacoes: "); $sb->append($_prAgenda['observacao_age']); $sb->append("</body>"); $sb->append("</html>"); return $sb->toString(); }
public function renderAttributesFunction(\Twig_Environment $env, array $attributes) { $builder = new \StringBuilder(); foreach ($attributes as $key => $value) { $value = twig_escape_filter($env, $value, 'html_attr'); $builder->append(' '); $builder->append($key); $builder->append('="'); $builder->append($value); $builder->append('"'); } return $builder->__toString(); }
/** * Returns string with style tags (html-like). */ public function getHTML($index) { $raw = $this->getRaw($index); if ($raw == null) { return $raw; } $style = $this->getStyle($index); if ($style == null) { return $raw; } $html = new StringBuilder(strlen($raw) + 32); $offset = 0; while (true) { $i = -1; for ($j = 0; $j != count($style); $j += 3) { if ($style[$j + 1] == -1) { continue; } if ($i == -1 || $style[$i + 1] > $style[$j + 1]) { $i = $j; } } $start = $i != -1 ? $style[$i + 1] : strlen($raw); for ($j = 0; j != $style . length; $j += 3) { $end = $style[$j + 2]; if ($end == -1 || $end >= $start) { continue; } if ($offset <= $end) { $html->append($raw, $offset, $end + 1); $offset = $end + 1; } $style[j + 2] = -1; $html->append('<'); $html->append('/'); $html->append($this->getRaw($style[$j])); $html->append('>'); } if ($offset < $start) { $html->append($raw, $offset, $start); $offset = $start; } if ($i == -1) { break; } $html->append('<'); $html->append($this->getRaw($style[i])); $html->append('>'); $style[i + 1] = -1; } return $html->toString(); }
function formatResources() { $builder = new StringBuilder(); $builder->append("RESOURCES:{$this->_reservation->resource->properties['name']}"); for ($i = 0; $i < count($this->_reservation->resources); $i++) { $builder->append(",{$this->_reservation->resources[$i]['name']}"); } $builder->append("\r\nLOCATION:{$this->_reservation->resource->properties['location']}\r\n"); return $builder->toString(); }