Example #1
0
function TransformInline($text, $markup = 2.0, $basepage = false)
{
    static $trfm;
    if (empty($trfm)) {
        $trfm = new InlineTransformer();
    }
    if ($markup < 2.0) {
        $text = ConvertOldMarkup($text, 'inline');
    }
    if ($basepage) {
        return new CacheableMarkup($trfm->parse($text), $basepage);
    }
    return $trfm->parse($text);
}
Example #2
0
function TransformInline($text, $markup = 2.0, $basepage = false)
{
    static $trfm;
    $action = $GLOBALS['request']->getArg('action');
    if (empty($trfm) or $action == 'SpellCheck') {
        $trfm = new InlineTransformer();
    }
    if ($markup < 2.0) {
        $text = ConvertOldMarkup($text, 'inline');
    }
    if ($basepage) {
        return new CacheableMarkup($trfm->parse($text), $basepage);
    }
    return $trfm->parse($text);
}
Example #3
0
 /**
  * @param $transformation
  * @return Transformer
  * @throws InvalidConfigException
  * @see transformations()
  */
 private function createTransformer($transformation)
 {
     $config = [];
     reset($transformation);
     list($config['property'], $config['column']) = each($transformation);
     if (!is_string($config['property']) || !is_string($config['column'])) {
         throw new InvalidConfigException('Data transformations is invalid. First array item must be "prop" => "col" pair');
     }
     list(, $val2) = each($transformation);
     if (is_string($val2)) {
         $config['class'] = $val2;
         list(, $params) = each($transformation);
         if (is_array($params)) {
             $config = ArrayHelper::merge($config, $params);
         } elseif ($params !== null) {
             throw new InvalidConfigException('Data transformations is invalid. If params is presented it must be array');
         }
     } elseif (is_array($val2)) {
         $config['class'] = InlineTransformer::className();
         $config = ArrayHelper::merge($config, $val2);
     }
     $config['model'] = $this;
     return \Yii::createObject($config);
 }