protected function _xmodule() { $str = StringUtils::l("{% begin contents %}"); if (!empty($this->js)) { $str .= StringUtils::l('<script type="text/javascript">'); $str .= StringUtils::l(); if (!self::$printedFieldClasses) { $str .= StringUtils::l($this->_buildFieldClasses()); self::$printedFieldClasses = true; } $str .= StringUtils::l(); $str .= StringUtils::l(' $(document).ready(function() {'); $str .= StringUtils::l(); foreach ((array) $this->js as $line) { $str .= StringUtils::l($line); } $str .= StringUtils::l(); $str .= StringUtils::l(' });'); $str .= StringUtils::l(); $str .= StringUtils::l('</script>'); } if (!empty($this->xhtml)) { foreach ((array) $this->xhtml as $line) { $str .= StringUtils::l($line); } } $str .= StringUtils::l("{% end %}"); return $str; }
/** * @name select($pId) * @param integer * @return AdherentSoldeVO * @desc Récupère la ligne correspondant à l'id en paramètre, créé un AdherentVO contenant les informations et le renvoie */ public static function select($pId) { // Initialisation du Logger $lLogger =& Log::singleton('file', CHEMIN_FICHIER_LOGS); $lLogger->setMask(Log::MAX(LOG_LEVEL)); $lRequete = "SELECT " . AdherentManager::CHAMP_ADHERENT_NUMERO . "," . AdherentManager::CHAMP_ADHERENT_ID_COMPTE . "," . AdherentManager::CHAMP_ADHERENT_NOM . "," . AdherentManager::CHAMP_ADHERENT_PRENOM . "," . AdherentManager::CHAMP_ADHERENT_COURRIEL_PRINCIPAL . "," . AdherentManager::CHAMP_ADHERENT_COURRIEL_SECONDAIRE . "," . AdherentManager::CHAMP_ADHERENT_TELEPHONE_PRINCIPAL . "," . AdherentManager::CHAMP_ADHERENT_TELEPHONE_SECONDAIRE . "," . AdherentManager::CHAMP_ADHERENT_ADRESSE . "," . AdherentManager::CHAMP_ADHERENT_CODE_POSTAL . "," . AdherentManager::CHAMP_ADHERENT_VILLE . "," . AdherentManager::CHAMP_ADHERENT_DATE_NAISSANCE . "," . AdherentManager::CHAMP_ADHERENT_DATE_ADHESION . "," . AdherentManager::CHAMP_ADHERENT_DATE_MAJ . "," . AdherentManager::CHAMP_ADHERENT_COMMENTAIRE . " \n\t\t\t\t\tFROM " . AdherentManager::TABLE_ADHERENT . " \n\t\t\t\t\tWHERE " . AdherentManager::CHAMP_ADHERENT_ID . " = '" . StringUtils::securiser($pId) . "'"; $lLogger->log("Execution de la requete : " . $lRequete, PEAR_LOG_DEBUG); // Maj des logs $lSql = Dbutils::executerRequete($lRequete); if (mysql_num_rows($lSql) > 0) { $lLigne = mysql_fetch_assoc($lSql); $lAdherent = AdherentSoldeManager::remplirAdherent($pId, $lLigne[AdherentManager::CHAMP_ADHERENT_NUMERO], $lLigne[AdherentManager::CHAMP_ADHERENT_ID_COMPTE], $lLigne[AdherentManager::CHAMP_ADHERENT_NOM], $lLigne[AdherentManager::CHAMP_ADHERENT_PRENOM], $lLigne[AdherentManager::CHAMP_ADHERENT_COURRIEL_PRINCIPAL], $lLigne[AdherentManager::CHAMP_ADHERENT_COURRIEL_SECONDAIRE], $lLigne[AdherentManager::CHAMP_ADHERENT_TELEPHONE_PRINCIPAL], $lLigne[AdherentManager::CHAMP_ADHERENT_TELEPHONE_SECONDAIRE], $lLigne[AdherentManager::CHAMP_ADHERENT_ADRESSE], $lLigne[AdherentManager::CHAMP_ADHERENT_CODE_POSTAL], $lLigne[AdherentManager::CHAMP_ADHERENT_VILLE], $lLigne[AdherentManager::CHAMP_ADHERENT_DATE_NAISSANCE], $lLigne[AdherentManager::CHAMP_ADHERENT_DATE_ADHESION], $lLigne[AdherentManager::CHAMP_ADHERENT_DATE_MAJ], $lLigne[AdherentManager::CHAMP_ADHERENT_COMMENTAIRE]); // Ajout des modules d'accés $lListeAutorisation = AutorisationManager::selectByIdAdherent($lAdherent->getId()); $lListeModuleAll = ModuleManager::selectAll(); $lListeModule = array(); foreach ($lListeAutorisation as $lAutorisation) { if ($lListeModuleAll[$lAutorisation->getIdModule()] === NULL) { $lListeModuleAll[$lAutorisation->getIdModule()] = new ModuleVO(); } array_push($lListeModule, $lListeModuleAll[$lAutorisation->getIdModule()]); } $lAdherent->setListeModule($lListeModule); return $lAdherent; } else { return new AdherentSoldeVO(); } }
public static function asVarName($input) { $input = StringUtils::toAlphaNum($input, array('-', '_', '.', ':')); $input = self::camelize($input); $input[0] = strtolower($input[0]); return $input; }
public function Render() { include_once 'libs/smartylibs/Smarty.class.php'; $smarty = new Smarty(); $smarty->template_dir = 'components/templates'; $smarty->assign_by_ref('Page', $this); $users = $this->tableBasedGrantsManager->GetAllUsersAsJson(); $smarty->assign_by_ref('Users', $users); $localizerCaptions = $this->GetLocalizerCaptions(); $smarty->assign_by_ref('Captions', $localizerCaptions); /* $roles = $this->tableBasedGrantsManager->GetAllRolesAsJson(); $smarty->assign_by_ref('Roles', $roles); */ $headerString = 'Content-Type: text/html'; if ($this->GetContentEncoding() != null) { StringUtils::AddStr($headerString, 'charset=' . $this->GetContentEncoding(), ';'); } header($headerString); $pageInfos = GetPageInfos(); $pageListViewData = array('Pages' => array(), 'CurrentPageOptions' => array()); foreach ($pageInfos as $pageInfo) { $pageListViewData['Pages'][] = array('Caption' => $this->RenderText($pageInfo['caption']), 'Hint' => $this->RenderText($pageInfo['short_caption']), 'Href' => $pageInfo['filename'], 'GroupName' => $this->RenderText($pageInfo['group_name']), 'BeginNewGroup' => $pageInfo['add_separator']); } $pageGroups = GetPageGroups(); foreach ($pageGroups as &$pageGroup) { $pageGroup = $this->RenderText($pageGroup); } $pageListViewData['Groups'] = $pageGroups; $smarty->assign_by_ref('PageList', $pageListViewData); $authenticationViewData = $this->GetAuthenticationViewData(); $smarty->assign_by_ref('Authentication', $authenticationViewData); $smarty->display('admin_panel.tpl'); }
static function formatLogEntry($type, $action, $title, $sk, $parameters) { $msg = "lqt-log-action-{$action}"; switch ($action) { case 'merge': if ($parameters[0]) { $msg = 'lqt-log-action-merge-across'; } else { $msg = 'lqt-log-action-merge-down'; } break; case 'move': $smt = new SpecialMoveThread(); $rightsCheck = $smt->checkUserRights($parameters[1] instanceof Title ? $parameters[1] : Title::newFromText($parameters[1]), $parameters[0] instanceof Title ? $parameters[0] : Title::newFromText($parameters[0])); if ($rightsCheck === true) { $parameters[] = Message::rawParam(Linker::link(SpecialPage::getTitleFor('MoveThread', $title), wfMessage('revertmove')->text(), array(), array('dest' => $parameters[0]))); } else { $parameters[] = ''; } break; default: // Give grep a chance to find the usages: // lqt-log-action-move, lqt-log-action-split, lqt-log-action-subjectedit, // lqt-log-action-resort, lqt-log-action-signatureedit $msg = "lqt-log-action-{$action}"; break; } array_unshift($parameters, $title->getPrefixedText()); $html = wfMessage($msg, $parameters); if ($sk === null) { return StringUtils::delimiterReplace('<', '>', '', $html->inContentLanguage()->parse()); } return $html->parse(); }
public function getPageContent() { $template = $this->getTemplateEngine()->readTemplate($this->getTemplate()); $products = $this->getModel()->getProducts(); $sum = 0; $visible = CSS::HIDDEN; $empty = ""; $productsTpl = ""; if (count($products) > 0) { $visible = ""; $empty = CSS::HIDDEN; $engine = $tpl = $this->getTemplateEngine(); foreach ($products as $product) { $tpl = $engine->readTemplate(Template::CART_PRODUCT); $tpl = $engine->replaceTag("classification", $product->getClassification(), $tpl); $tpl = $engine->replaceTag("type", $product->getType(), $tpl); $tpl = $engine->replaceTag("imgname", $product->getImgname(), $tpl); $tpl = $engine->replaceTag("id", $product->getId(), $tpl); $tpl = $engine->replaceTag("name", $product->getName(), $tpl); $tpl = $engine->replaceTag("optionsList", StringUtils::arrangeOptions($product->getProperties()), $tpl); $tpl = $engine->replaceTag("price", StringUtils::formatAmount($product->getPrice()), $tpl); $sum += $product->getPrice(); $productsTpl .= $tpl; } } $template = $this->getTemplateEngine()->replaceTag("empty", $empty, $template); $template = $this->getTemplateEngine()->replaceTag("visible", $visible, $template); $template = $this->getTemplateEngine()->replaceTag("productrows", $productsTpl, $template); $template = $this->getTemplateEngine()->replaceTag("total", StringUtils::formatAmount($sum), $template); return $template; }
/** * adding the flag table to the comments form * * @global SFFormPrinter $sfgFormPrinter from SMW * @global Article $wgArticle * @param String $sHtml * @return boolean */ function onAddCommentsFormDiv(&$sHtml) { global $sfgFormPrinter, $wgArticle, $webplatformSectionCommentsSMW; $sHtml .= '<a id="comments-flag-link">' . wfMessage('comments-flag-link')->text() . '</a>'; $sHtml .= '<div id="comment-flags">'; $sFormName = $webplatformSectionCommentsSMW['form']; //$sPageName = 'Comments'; $oTitle = Title::newFromText($sFormName, SF_NS_FORM); $oArticle = new Article($oTitle, 0); $sFormDefinition = $oArticle->getContent(); $sFormDefinition = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $sFormDefinition); $aHtml = $sfgFormPrinter->formHTML($sFormDefinition, false, true, $oTitle->getArticleID(), $wgArticle->fetchContent()); //, $wgArticle->getTitle()->getArticleID(), $wgArticle->fetchContent(), $wgArticle->getTitle()->getText(), null ); $aMatches = array(); preg_match_all('#<table.*?</table>#is', $aHtml[0], $aMatches); $index = null; foreach ($aMatches[0] as $key => $value) { $bPos = strrpos($value, $webplatformSectionCommentsSMW['template'] . '['); if ($bPos !== false) { $index = $key; break; } } $sHtml .= $aMatches[0][$index]; $sHtml .= '</div>'; return true; }
static function formatLogEntry($type, $action, $title, $sk, $parameters) { switch ($action) { case 'merge': if ($parameters[0]) { $msg = 'lqt-log-action-merge-across'; } else { $msg = 'lqt-log-action-merge-down'; } break; default: $msg = 'lqt-log-action-' . $action; break; } $options = array('parseinline'); $forIRC = $sk === null; if ($forIRC) { global $wgContLang; $options['language'] = $wgContLang->getCode(); } $replacements = array_merge(array($title->getPrefixedText()), $parameters); $html = wfMsgExt($msg, $options, $replacements); if ($forIRC) { $html = StringUtils::delimiterReplace('<', '>', '', $html); } return $html; }
/** * Test for Schwaen\Stdlib\StringUtils::endsWith */ public function testEndsWith() { $this->assertEquals(false, StringUtils::endsWith('Hallo Welt', 'welt')); $this->assertEquals(true, StringUtils::endsWith('Hallo Welt', 'Welt')); $this->assertEquals(false, StringUtils::endsWith('Hallo Welt', 'Test')); $this->assertEquals(true, StringUtils::endsWith('Hallo Welt', '')); }
protected function xmodule() { $this->parseChildren(); $element = $this->globals['INPUT_ELEMENT']; $sectionType = $this->globals['INPUT_SECTIONTYPE']; if (empty($element)) { throw new Exception('XModule [' . $this->template->getName() . '] is missing POST parameter [element]'); } $str = StringUtils::l("{% set DataSource %}node-sections{% end %}"); $str .= StringUtils::l("{% begin contents %}"); if (!empty($this->js)) { $str .= StringUtils::l('<script type="text/javascript">'); $str .= StringUtils::l(); foreach ((array) $this->js as $line) { $str .= StringUtils::l($line); } $str .= StringUtils::l(); $str .= StringUtils::l("document.sectionWidgets['{$sectionType}'].initializeSection(%TempSectionID%);"); $str .= StringUtils::l('</script>'); } if (!empty($this->xhtml)) { foreach ((array) $this->xhtml as $line) { $str .= StringUtils::l($line); } } $str .= StringUtils::l("{% end %}"); return $str; }
public function showThumbnails() { $json = $this->getParameter('value'); if (empty($json)) { return ''; } $json = JSONUtils::decode($json); $thumbs = $this->getParameter('thumbnails'); $tlist = array(); if (!empty($thumbs)) { $tlist = explode(',', $thumbs); } $xmod = StringUtils::strToBool($this->getParameter('xmod')); $markup = ''; if ($xmod) { foreach ($json as $thumb) { if (!empty($list) && in_array($thumb->value, $tlist) || empty($tlist)) { $markup .= '<image id="' . $thumb->url . '" width="full"/>'; } } } else { $markup .= '<ul class="thumbnail-list">'; foreach ($json as $thumb) { if (!empty($tlist) && in_array($thumb->value, $tlist) || empty($tlist)) { $markup .= '<li><p><img src="' . $thumb->url . '" alt="' . $this->getLocal('Title') . '" /></p><p><strong>Size:</strong> ' . $thumb->value . '</p></li>'; } } $markup .= '</ul>'; } return $markup; }
public static function tagize($string) { $string = StringUtils::removeAccents($string); $string = strtolower($string); $string = str_replace(' ', '_', $string); return $string; }
public static function create($type, $name, $value = null) { list($form_class_prefix, $function_name) = explode("/", $type); $class_name = StringUtils::underscored_to_camel_case($form_class_prefix) . "FormFieldFactory"; $form_field_factory = __create_instance($class_name); $form_field_factory->{$function_name}($name, $value); }
protected function __construct() { $this->array = ArrayUtils::instance(); $this->file = FileUtils::instance(); $this->object = ObjectUtils::instance(); $this->string = StringUtils::instance(); }
/** * Core parser tag hook function for 'pre'. * Text is treated roughly as 'nowiki' wrapped in an HTML 'pre' tag; * valid HTML attributes are passed on. * * @param string $text * @param array $attribs * @param Parser $parser * @return string HTML */ public static function pre($text, $attribs, $parser) { // Backwards-compatibility hack $content = StringUtils::delimiterReplace('<nowiki>', '</nowiki>', '$1', $text, 'i'); $attribs = Sanitizer::validateTagAttributes($attribs, 'pre'); return Xml::openElement('pre', $attribs) . Xml::escapeTagsOnly($content) . '</pre>'; }
function executeRequest() { $my_path = Request::getRequestPath(); $my_name = Request::getRequestName(); $peer = new PaginePeer(); $peer->path__EQUAL($my_path); $peer->nome__EQUAL($my_name); $all_pages = $peer->find(); $my_page = $all_pages[0]; $peer_ep = new ElementiPaginaPeer(); $peer_ep->id_pagina__EQUAL($my_page->id); $all_elementi_pagina = $peer_ep->find(); /* * Carico tutti gli elementi pagina * Nel nome di un settore eventualmente ci posso mettere una descrizione * */ foreach ($all_elementi_pagina as $elem) { $categoria = $elem->categoria; $sotto_categoria = $elem->sotto_categoria; $specifica = $elem->specifica; $categoria_instance = __create_instance(StringUtils::underscored_to_camel_case($categoria) . "SectorRenderer"); $result = $categoria_instance->{$sotto_categoria}($specifica); set_sector($elem->path_settore, $result); } /* * Questi rendering popolano i vari settori a modo loro * */ //render pagina render(PageData::instance()->get("/")); //trova il layout e renderizza il tutto. }
/** * Overwrite the method from abstract PageController. * Possibility to handle requests sent to the 'shipping' page. */ public function handleRequestInMain() { // redirect the user if it's not logged in. if (isset($_SESSION[Session::USER])) { $this->redirect("mydata.php"); } // handle only POST requests if ($_SERVER["REQUEST_METHOD"] == "POST") { // create a NamedQuery, then add all given params in POST array $namedQuery = new NamedQuery($this->QUERY_INSERT_USER); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-firstname"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-lastname"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-email"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-address"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-addressnr"])); $namedQuery->addParam(QueryParam::TYPE_INTEGER, StringUtils::removeTags($_POST["name-zipcode"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-city"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-country"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::convertInSha1($_POST["name-password"])); // try to execute the query if (!CRUDService::getInstance()->executeNamedQuery($namedQuery)) { Logger::error("error registering a new user"); } else { // query was OK. // reload the user's data and store them in the session $namedQuery = new NamedQuery($this->QUERY_LOAD_USER); $namedQuery->addParam(QueryParam::TYPE_STRING, $_POST["name-email"]); $result = CRUDService::getInstance()->fetchNamedQuery($namedQuery, "User"); $_SESSION[Session::USER] = serialize($result[0]); $this->redirect("home.php"); } } }
/** * Evaluate a compiled set of rules returned by compile(). Do not allow * the user to edit the compiled form, or else PHP errors may result. */ public static function evaluateCompiled($number, array $rules) { // The compiled form is RPN, with tokens strictly delimited by // spaces, so this is a simple RPN evaluator. foreach ($rules as $i => $rule) { $stack = array(); $zero = ord('0'); $nine = ord('9'); foreach (StringUtils::explode(' ', $rule) as $token) { $ord = ord($token); if ($token === 'n') { $stack[] = $number; } elseif ($ord >= $zero && $ord <= $nine) { $stack[] = intval($token); } else { $right = array_pop($stack); $left = array_pop($stack); $result = self::doOperation($token, $left, $right); $stack[] = $result; } } if ($stack[0]) { return $i; } } // None of the provided rules match. The number belongs to caregory // 'other' which comes last. return count($rules); }
function parseItem($blog, $item, $ts) { if ($ts != 0 && $item->pubdate <= $ts) { logmsg('Zatrzymanie na wpisie: %s', StringUtils::removeAccents($item->title)); return false; } logmsg(' - Parsowanie wpisu: %s', StringUtils::removeAccents($item->title)); $post = new Post(); $post->setBlog($blog); foreach ($item->tags as $name) { $tag = TagPeer::retriveByName($name, true); if ($post->addTag($tag)) { logmsg(' - Znaleziono tag: %s', $name); } } if ($post->hasTags()) { $shortened = $post->setFullContent($item->content); $post->setLink(htmlspecialchars($item->link)); $post->setTitle($item->title); $post->setCreatedAt($item->pubdate); $post->setShortened($shortened); $post->save(); } else { logmsg(' - Nie znaleziono tagow'); } return true; }
function execute($query) { global $wgRequest, $wgOut; $wgOut->disable(); $this->setHeaders(); $page_name = $query; $title = Title::newFromText($page_name); if (is_null($title)) { return; } if (!$title->userCan('read')) { return; } $article = new Article($title); $page_text = $article->fetchContent(); // Remove <noinclude> sections and <includeonly> tags from text $page_text = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $page_text); $page_text = strtr($page_text, array('<includeonly>' => '', '</includeonly>' => '')); $orig_lines = explode("\n", $page_text); // ignore lines that are either blank or start with a semicolon $page_lines = array(); foreach ($orig_lines as $i => $line) { if ($line != '' && $line[0] != ';') { $page_lines[] = $line; } } $headers = EDUtils::getValuesFromCSVLine($page_lines[0]); $queried_headers = array(); foreach ($wgRequest->getValues() as $key => $value) { foreach ($headers as $header_index => $header_value) { $header_value = str_replace(' ', '_', $header_value); if ($key == $header_value) { $queried_headers[$header_index] = $value; } } } // include header in output $text = $page_lines[0]; foreach ($page_lines as $i => $line) { if ($i == 0) { continue; } $row_values = EDUtils::getValuesFromCSVLine($line); $found_match = true; foreach ($queried_headers as $i => $query_value) { $single_value = str_replace(' ', '_', $row_values[$i]); if ($single_value != $query_value) { $found_match = false; } } if ($found_match) { if ($text != '') { $text .= "\n"; } $text .= $line; } } print $text; }
public function SetValue($value) { if (!StringUtils::IsNullOrEmpty($value)) { $this->value = SMDateTime::Parse($value, $this->format); } else { $this->value = null; } }
function PrepareForExcel($str, $encoding) { $ret = StringUtils::EscapeString($str, $encoding); if (substr($ret, 0, 1) == "=") { $ret = "=" . substr($ret, 1); } return $ret; }
public function __toString() { $html = "<div class='crumbs'>"; $cumbsTxt = StringUtils::arrayToString($this->items, " → "); $html .= $cumbsTxt; $html .= "</div>"; return $html; }
private static function __is_notset_key($key) { if (StringUtils::starts_with($key, self::NOTSET_KEY_PREFIX)) { return true; } else { return false; } }
static function createRenderer($categoria) { if (isset(self::$renderers[$categoria])) { $renderer_name = $categoria; } $renderer_class_name = StringUtils::underscored_to_camel_case($renderer_name . "_sector_renderer"); return __create_instance($renderer_class_name); }
public function GetLink() { $parameterList = ''; foreach ($this->parameters as $name => $value) { StringUtils::AddStr($parameterList, urlencode($name) . '=' . urlencode($value), '&'); } return $this->targetPage . ($parameterList != '' ? '?' : '') . $parameterList; }
public static function SetTimeZoneIfNeed($timezoneIdentifier) { if (SystemUtils::GetPHPMinorVersion() >= 3) { if (StringUtils::IsNullOrEmpty(ini_get('date.timezone'))) { date_default_timezone_set($timezoneIdentifier); } } }
/** * @name update($pDetailOperation) * @param DetailOperationVO * @return integer * @desc Met à jour une opération */ private function update($pDetailOperation) { $pDetailOperation->setDate(StringUtils::dateTimeAujourdhuiDb()); $pDetailOperation->setIdConnexion($_SESSION[ID_CONNEXION]); $this->insertHistorique($pDetailOperation); // Ajout historique return DetailOperationManager::update($pDetailOperation); // update de l'opération }
/** * Add string to table. Returns string index * @param $str * @return integer */ public function add($str) { $str = StringUtils::toBiff8UnicodeLong($str); if (!isset($this->data[$str])) { $this->data[$str] = $this->uniqueCount++; } $this->totalCount++; return $this->data[$str]; }
public function GetValue() { $fieldValue = $this->GetDataset()->GetFieldValueByName($this->fieldName); if ($fieldValue == null) { return '<em class="pgui-null-value">NULL</em>'; } else { return StringUtils::Format('<i class="icon-download"></i> ' . '<a target="_blank" title="%s" href="%s">%s</a>', FormatDatasetFieldsTemplate($this->dataset, $this->downloadLinkHintTemplate), $this->sourcePrefix . $fieldValue . $this->sourceSuffix, $this->captions->GetMessageString('Download')); } }