当前位置: 首页>>代码示例>>PHP>>正文


PHP FabrikWorker::replaceWithGlobals方法代码示例

本文整理汇总了PHP中FabrikWorker::replaceWithGlobals方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker::replaceWithGlobals方法的具体用法?PHP FabrikWorker::replaceWithGlobals怎么用?PHP FabrikWorker::replaceWithGlobals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FabrikWorker的用法示例。


在下文中一共展示了FabrikWorker::replaceWithGlobals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseMessageForPlaceHolder

 /**
  * iterates through string to replace every
  * {placeholder} with posted data
  * @param string text to parse
  * @param array data to search for placeholders (default $_REQUEST)
  * @param bool if no data found for the place holder do we keep the {...} string in the message
  * @param bool add slashed to the text?
  * @param object user to use in replaceWithUserData (defaults to logged in user)
  */
 public function parseMessageForPlaceHolder($msg, $searchData = null, $keepPlaceholders = true, $addslashes = false, $theirUser = null)
 {
     $this->_parseAddSlases = $addslashes;
     if ($msg == '' || is_array($msg) || strpos($msg, '{') === false) {
         return $msg;
     }
     $msg = str_replace(array('%7B', '%7D'), array('{', '}'), $msg);
     if (is_object($searchData)) {
         $searchData = JArrayHelper::fromObject($searchData);
     }
     //$post	= JRequest::get('post');
     //$$$ rob changed to allow request variables to be parsed as well. I have a sneaky feeling this
     // was set to post for a good reason, but I can't see why now.
     // $$$ hugh - for reasons I don't understand, merging request just doesn't seem to work
     // in some situations, so I'm adding a replaceRequest call here as a bandaid.
     // @TODO $$$ rob can you remember what those situations where? Because doing this is messing up form plugins (e.g redirect) when they do replace on getEmailData()
     // as having the line below commented in causes the request to be used before searchData.
     // FabrikWorker::replaceRequest($msg);
     $post = JRequest::get('request');
     $this->_searchData = is_null($searchData) ? $post : array_merge($post, $searchData);
     $this->_searchData['JUtility::getToken'] = JUtility::getToken();
     $msg = FabrikWorker::replaceWithUserData($msg);
     if (!is_null($theirUser)) {
         $msg = FabrikWorker::replaceWithUserData($msg, $theirUser, 'your');
     }
     $msg = FabrikWorker::replaceWithGlobals($msg);
     $msg = preg_replace("/{}/", "", $msg);
     /* replace {element name} with form data */
     $msg = preg_replace_callback("/{[^}\\s]+}/i", array($this, 'replaceWithFormData'), $msg);
     if (!$keepPlaceholders) {
         $msg = preg_replace("/{[^}\\s]+}/i", '', $msg);
     }
     return $msg;
 }
开发者ID:romuland,项目名称:khparts,代码行数:43,代码来源:parent.php

示例2: parseMessageForRowHolder

 /**
  * Iterates through string to replace every
  * {placeholder} with row data
  * (added by hugh, does the same thing as parseMessageForPlaceHolder in parent
  * class, but for rows instead of forms)
  *
  * NOTE - I can't remember why I added this way back when in 2.x, instead of using the helper function,
  * I just know there was a good reason, to do with the helper func making assumptions about something
  * (I think to do with how form data is formatted) which weren't true when rendering list data.  I have
  * a suspicion that in the intervening years, the helper func and the way we format data may now be
  * copacetic, and we could do away with this separation, and just use the normal helper func.  Might be
  * worth testing, as this code looks like it has suffered bitrot, and doesn't do a number of things the main
  * helper func now does.
  *
  * @param   string  $msg         text to parse
  * @param   array   &$row        of row data
  * @param   bool    $addSlashes  add slashes to the replaced data (default = false) set to true in fabrikcalc element
  *
  * @return  string  parsed message
  */
 public function parseMessageForRowHolder($msg, &$row, $addSlashes = false)
 {
     $this->aRow = $row;
     if (!strstr($msg, '{')) {
         return $msg;
     }
     $this->parseAddSlases = $addSlashes;
     $msg = FabrikWorker::replaceWithUserData($msg);
     $msg = FabrikWorker::replaceWithGlobals($msg);
     $msg = preg_replace("/{}/", "", $msg);
     $this->rowIdentifierAdded = false;
     /* replace {element name} with form data */
     /* $$$ hugh - testing changing the regex so we don't blow away PHP structures!  Added the \s so
      * we only match non-space chars in {}'s.  So unless you have some code like "if (blah) {foo;}", PHP
      * block level {}'s should remain unmolested.
      */
     $msg = preg_replace_callback("/{[^}\\s]+}/i", array($this, 'replaceWithRowData'), $msg);
     $lang = $this->lang->getTag();
     $lang = str_replace('-', '_', $lang);
     $msg = str_replace('{lang}', $lang, $msg);
     return $msg;
 }
开发者ID:pascal26,项目名称:fabrik,代码行数:42,代码来源:list.php


注:本文中的FabrikWorker::replaceWithGlobals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。