本文整理汇总了PHP中StringUtils类的典型用法代码示例。如果您正苦于以下问题:PHP StringUtils类的具体用法?PHP StringUtils怎么用?PHP StringUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _xmodule
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;
}
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:29,代码来源:EditCmsBuilder.php
示例2: select
/**
* @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();
}
}
开发者ID:google-code-backups,项目名称:zeybux,代码行数:34,代码来源:xxx-AdherentSoldeManager.php
示例3: asVarName
public static function asVarName($input)
{
$input = StringUtils::toAlphaNum($input, array('-', '_', '.', ':'));
$input = self::camelize($input);
$input[0] = strtolower($input[0]);
return $input;
}
开发者ID:payin7-payments,项目名称:payin7-prestashop,代码行数:7,代码来源:inflector.php
示例4: Render
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');
}
开发者ID:BCDevExchange,项目名称:WORKPLAN,代码行数:32,代码来源:phpgen_admin.php
示例5: formatLogEntry
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();
}
开发者ID:Rikuforever,项目名称:wiki,代码行数:34,代码来源:LogFormatter.php
示例6: getPageContent
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;
}
开发者ID:webel3,项目名称:ch.bfh.bti7054.w2014.q.wew,代码行数:31,代码来源:CartView.php
示例7: onAddCommentsFormDiv
/**
* 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;
}
开发者ID:renoirb,项目名称:mediawiki-1,代码行数:35,代码来源:SectionComments.php
示例8: formatLogEntry
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;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:27,代码来源:LogFormatter.php
示例9: testEndsWith
/**
* 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', ''));
}
开发者ID:schwaen,项目名称:stdlib,代码行数:10,代码来源:StringUtilsTest.php
示例10: xmodule
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;
}
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:28,代码来源:SectionCmsBuilder.php
示例11: showThumbnails
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;
}
开发者ID:wb-crowdfusion,项目名称:crowdfusion-advanced-media,代码行数:31,代码来源:MediaFilterer.php
示例12: tagize
public static function tagize($string)
{
$string = StringUtils::removeAccents($string);
$string = strtolower($string);
$string = str_replace(' ', '_', $string);
return $string;
}
开发者ID:noose,项目名称:Planeta,代码行数:7,代码来源:Tag.php
示例13: create
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);
}
开发者ID:mbcraft,项目名称:frozen,代码行数:7,代码来源:Form.class.php
示例14: __construct
protected function __construct()
{
$this->array = ArrayUtils::instance();
$this->file = FileUtils::instance();
$this->object = ObjectUtils::instance();
$this->string = StringUtils::instance();
}
开发者ID:patxi1980,项目名称:utilities,代码行数:7,代码来源:Utils.php
示例15: pre
/**
* 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>';
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:17,代码来源:CoreTagHooks.php
示例16: executeRequest
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.
}
开发者ID:mbcraft,项目名称:frozen,代码行数:31,代码来源:DatabasePagesEngine.class.php
示例17: handleRequestInMain
/**
* 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");
}
}
}
开发者ID:webel3,项目名称:ch.bfh.bti7054.w2014.q.wew,代码行数:37,代码来源:RegisterController.php
示例18: evaluateCompiled
/**
* 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);
}
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:33,代码来源:CLDRPluralRuleEvaluator.php
示例19: parseItem
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;
}
开发者ID:noose,项目名称:Planeta,代码行数:27,代码来源:refresh.php
示例20: execute
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;
}
开发者ID:wjamn,项目名称:mediawiki-extensions-ExternalData,代码行数:59,代码来源:ED_GetData.php
注:本文中的StringUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论