示例#1
0
 /**
  * @return string
  */
 public function generate()
 {
     $element = Type::WYSIWYGElement($this->expression);
     $type = $element->parameter("data-wiki-link-type");
     $type = preg_replace('/[^#A-Za-z0-9]/', '', $type);
     return '(' . $type . '(' . $this->expression->renderedChildren . '))';
 }
示例#2
0
 /**
  * @return null|WikiLingo\Parsed
  */
 function parent()
 {
     if (isset($this->parsed->parent)) {
         return Type::Parsed($this->parsed->parent);
     }
     return null;
 }
示例#3
0
 /**
  * @param WikiLingo\Renderer $renderer
  * @param WikiLingo\Parser $parser
  * @return mixed|string
  */
 public function render($renderer, $parser)
 {
     $element = Type::Element($renderer->element(__CLASS__, 'div'));
     $parser->scripts->addCss('.center {text-align: center ! important;}');
     $element->classes[] = 'center';
     $element->staticChildren[] = $this->renderedChildren;
     $rendered = $element->render();
     return $rendered;
 }
示例#4
0
 /**
  * @return string
  */
 public function generate()
 {
     $element = Type::WYSIWYGElement($this->expression);
     $href = $element->parameter("data-href");
     if ($href != "") {
         $href .= "|";
     }
     return '[' . $href . $this->expression->renderedChildren . ']';
 }
示例#5
0
 /**
  * @return string
  */
 public function generate()
 {
     $element = Type::WYSIWYGElement($this->expression);
     $href = $element->parameter("data-href");
     $href = preg_replace('/[^#A-Za-z0-9]/', '', $href);
     if ($href != '') {
         $href .= '|';
     }
     return '((' . $href . $this->expression->renderedChildren . '))';
 }
示例#6
0
 public function __construct(WikiLingoWYSIWYG\Parser &$wikiLingoParser)
 {
     require_once 'lib/wikiLingo_tiki/WikiPluginStub.php';
     $stub = self::$bridge = new WikiPluginStub();
     Type::Events($wikiLingoParser->events)->bind(new Event\Expression\Plugin\Exists(function (Plugin &$plugin) use($wikiLingoParser, $stub) {
         if (!$plugin->exists) {
             $plugin->exists = true;
             $plugin->class = $stub;
             $wikiLingoParser->pluginInstances[$plugin->classType] = $stub;
         }
     }));
 }
 public function __construct(&$parser)
 {
     if (!$parser->wysiwyg) {
         $parser->clearTypes();
         Type::Events($parser->events)->bind(new Event\Parsed\RenderPermission(function (Parsed &$parsed) {
             if ($parsed->type == "Plugin" && $parsed->expression->type == "Illegal") {
                 $parsed->expressionPermissible = false;
             }
         }));
     }
     $this->source = "{ILLEGAL()}\n\t\t        {DIV()}\n!Header 1\n!Header 2\n\t\t        {DIV}\n{ILLEGAL}{DIV()}\n!Header 3\n{DIV}";
     $this->expected = "{ILLEGAL()}\n\t\t        {DIV()}\n!Header 1\n!Header 2\n\t\t        {DIV}\n{ILLEGAL}<div class='Div' id='Div2'><h1 id='Header-3'>Header 3</h1></div>";
 }
示例#8
0
 public function __construct(&$parser)
 {
     if ($parser != null) {
         Type::Events($parser->events)->bind(new Event\Translate(function ($value, $context) {
             switch ($value) {
                 case 'not translated':
                     return 'is translated';
             }
             return $value;
         }));
     }
     $this->source = "{T()}not translated{T}";
     $this->expected = "<span class='T' id='T1'>is translated</span>";
 }
示例#9
0
 /**
  * @param WikiLingo\Renderer $renderer
  * @param WikiLingo\Parser $parser
  * @return string
  */
 public function render($renderer, $parser)
 {
     $tagType = 'h' . $this->count;
     $children = '';
     foreach ($this->parsed->children as $child) {
         $children .= $parser->renderer->render($child);
     }
     if ($this->pointer) {
         $tagType = 'a';
         $children = strip_tags($children);
     }
     $element = Type::Element($renderer->element(__CLASS__, $tagType));
     $element->staticChildren[] = $children;
     if (isset($this->modifier)) {
         $element->detailedAttributes['data-modifier'] = $this->modifier;
         //TODO: add in js to make expandable
         switch ($this->modifier) {
             case 'toggle':
                 $helper = Type::Helper($renderer->helper('a'));
                 $helper->staticChildren[] = '[+]';
                 $helper->attributes['href'] = '#';
                 $element->staticChildren[] = $helper->render();
                 break;
             case 'hidden':
                 $helper = Type::Helper($renderer->helper('a'));
                 $helper->staticChildren[] = '[-]';
                 $helper->attributes['href'] = '#';
                 $element->staticChildren[] = $helper->render();
                 break;
         }
     }
     if ($this->id == null || $this->block->variableContext != null) {
         $id = trim(preg_replace("/[^0-9a-zA-Z_]+/", "-", trim(strip_tags($children))), '-');
         $id = $parser->events->triggerExpressionBlockTypeHeaderIdLookup($id, $this);
         $this->id = $id;
         if (!isset(self::$ids[$id])) {
             self::$ids[$id] = 1;
         } else {
             $this->id .= self::$ids[$id];
             self::$ids[$id]++;
         }
     }
     if ($this->pointer) {
         $element->attributes['href'] = '#' . urlencode($this->id);
     } else {
         $element->attributes['id'] = $this->id;
     }
     $header = $element->render();
     return $header;
 }
示例#10
0
 public function __construct(&$parser)
 {
     if (!$parser->wysiwyg) {
         Type::Events($parser->events)->bind(new Event\Parsed\RenderPermission(function (Parsed &$parsed) {
             if ($parsed->type == "Plugin" && $parsed->expression->type == "Illegal") {
                 $parsed->expressionPermissible = false;
             }
         }))->bind(new Event\Parsed\RenderBlocked(function (Parsed &$parsed, &$return) {
             $return = '';
         }));
     }
     $this->source = "{ILLEGAL()}\n                {DIV()}\n!Header 1\n!Header 2\n                {DIV}\n{ILLEGAL}";
     $this->expected = "";
 }
 public function __construct(&$parser)
 {
     if ($parser != null) {
         Type::Events($parser->events)->bind(new Event\Expression\Variable\Context(function (WikiLingo\Expression\Plugin $plugin) {
             $type = $plugin->parameter('type');
             switch ($type) {
                 case 'lookup':
                     return array(array("variable" => "value 1"), array("variable" => "value 2"));
             }
             return array();
         }));
     }
     $this->source = "{TEMPLATE(type=`lookup`)}%variable%{TEMPLATE}";
     $this->expected = "<span>value 1</span><span>value 2</span>";
 }
 /**
  * @return string
  */
 public function generate()
 {
     $this->parsed->isBlock = true;
     $items = array();
     $item = '';
     foreach ($this->children as $descriptionList) {
         $expression = Type::WYSIWYGElement($descriptionList->expression);
         switch ($expression->name) {
             case "dd":
                 $item .= ':' . $expression->renderedChildren;
                 $items[] = $item;
             case "dt":
                 $item = "\n;" . $expression->renderedChildren;
         }
     }
     return implode('', $items);
 }
 public function __construct(&$parser)
 {
     $parser->events->WikiLingoEventExpressionVariableContext = array();
     if ($parser != null) {
         Type::Events($parser->events)->bind(new Event\Expression\Variable\Context(function (WikiLingo\Expression\Plugin $plugin) {
             $type = $plugin->parameter('type');
             switch ($type) {
                 case 'parent':
                     return array(array("name" => "first parent"), array("name" => "second parent"));
                 case 'child':
                     return array(array("name" => "first child"));
             }
             return null;
         }));
     }
     $this->source = "{TEMPLATE(type=`parent`)}\n%name%\n{TEMPLATE(type=`child`)}\n%name%\n{TEMPLATE}\n{TEMPLATE}";
     $this->expected = "<br/>" . "<span>first parent</span><br/>" . "<br/>" . "<span>first child</span><br/>" . "<br/>" . "<br/>" . "<span>second parent</span><br/>" . "<br/>" . "<span>first child</span><br/>" . "<br/>";
 }
示例#14
0
 /**
  * @param $renderer
  * @param $parser
  * @return mixed|string
  * @throws \Exception
  */
 public function render($renderer, $parser)
 {
     if ($this->isElement) {
         $longTypeName = $this->parameter('data-type');
         if (!empty($longTypeName)) {
             $typeName = Type::classNameSimple($longTypeName);
             $typeClass = 'WYSIWYGWikiLingo\\SyntaxGenerator\\' . $typeName;
             if (class_exists($typeClass)) {
                 $type = new $typeClass($parser, $this);
                 $generated = $type->generate();
                 return $generated;
             } else {
                 throw new \Exception("Type '" . $typeClass . "' not found");
             }
         }
     }
     if ($this->isHelper) {
         return '';
     }
     return $this->parsed->text;
 }
示例#15
0
 public function __construct(WikiLingo\Parser &$wikiLingoParser, $bindFLP = true)
 {
     global $prefs, $page;
     $headerlib = TikiLib::lib('header');
     if ($page == null && $bindFLP) {
         throw new \Exception("Page undefined");
     }
     require_once 'lib/wikiLingo_tiki/WikiPluginBridge.php';
     $bridge = self::$bridge = new WikiPluginBridge();
     $events = Type::Events($wikiLingoParser->events);
     $events->bind(new Event\Expression\Plugin\Exists(function (Plugin &$plugin) use($wikiLingoParser, $bridge) {
         if (!$plugin->exists) {
             switch ($plugin->classType) {
                 case "WikiLingo\\Plugin\\Maketoc":
                     if (self::$toc == null) {
                         self::$toc = new WikiLingo\Plugin\Toc();
                     }
                     $plugin->exists = true;
                     $plugin->class = self::$toc;
                     $wikiLingoParser->pluginInstances[$plugin->classType] = self::$toc;
                     break;
                 default:
                     $plugin->exists = true;
                     $plugin->class = $bridge;
                     $wikiLingoParser->pluginInstances[$plugin->classType] = $bridge;
             }
         }
     }));
     if ($bindFLP) {
         //FutureLink-Protocol Events
         FLP\Events::bind(new FLP\Event\MetadataLookup(function ($linkType, &$metadata) use($page, $headerlib) {
             $metadataLookup = new WikiMetadataLookup($page);
             $metadataTemp = $metadataLookup->getPartial();
             $metadataTemp->href = TikiLib::tikiUrl('tiki-index.php') . '?page=' . $page;
             $metadataTemp->text = $metadata->text;
             $metadata = $metadataTemp;
         }));
     }
 }
 public function __construct(&$parser)
 {
     $parser->events->WikiLingoEventExpressionVariableContext = array();
     if ($parser != null) {
         Type::Events($parser->events)->bind(new Event\Expression\Variable\Context(function (WikiLingo\Expression\Plugin $plugin) {
             $type = $plugin->parameter('type');
             switch ($type) {
                 case 'lookup1':
                     return array(array("variable" => "1.1"), array("variable" => "1.2"));
                     //lookup 2 is null, thus should not be shown
                 //lookup 2 is null, thus should not be shown
                 case 'lookup2':
                     return null;
                 case 'lookup3':
                     return array(array("variable" => "3.1"), array("variable" => "3.2"));
             }
             return null;
         }));
     }
     $this->source = "{TEMPLATE(type=`lookup1`)}\n! Header %variable%\n{TEMPLATE}\n{TEMPLATE(type=`lookup2`)}\n!Header %variable%\n{TEMPLATE}\n{TEMPLATE(type=`lookup3`)}\n!header %variable%\n{TEMPLATE}";
     $this->expected = "<h1 id='Header-1-1'><span class='whitespace'> </span>Header <span>1.1</span></h1>" . "<h1 id='Header-1-2'><span class='whitespace'> </span>Header <span>1.2</span></h1>" . "<br/>" . "<br/>" . "<h1 id='header-3-1'>header <span>3.1</span></h1>" . "<h1 id='header-3-2'>header <span>3.2</span></h1>";
 }
示例#17
0
    public function __construct(&$parser)
    {
        if (!$parser->wysiwyg) {
            Type::Events($parser->events)->bind(new Event\Parsed\RenderPermission(function (Parsed &$parsed) {
                if ($parsed->type == "Plugin" && $parsed->expression->type == "Permission") {
                    $allow = $parsed->expression->parametersRaw['allow'];
                    $parsed->expressionPermissible = $allow == 'true' ? true : false;
                }
            }))->bind(new Event\Parsed\RenderBlocked(function (Parsed &$parsed, &$return) {
                $return = '';
            }));
        }
        $this->source = <<<WL
{PERMISSION(allow="true")}
:)
{PERMISSION}
{PERMISSION(allow="false")}
:(
{PERMISSION}
WL;
        $this->expected = "<div class='Permission' id='Permission1'><br/>:)<br/></div><br/>";
    }
示例#18
0
 /**
  * @param WikiLingo\Renderer $renderer
  * @param WikiLingo\Parser $parser
  * @return mixed|string
  */
 public function render($renderer, $parser)
 {
     $element = Type::Element($renderer->element(__CLASS__, 'hr'));
     $element->setInline();
     return $element->render();
 }
示例#19
0
 /**
  * @return string
  */
 public function generate()
 {
     $element = Type::WYSIWYGElement($this->expression);
     return '@FLP(' . $element->parameter('data-past') . ')' . $this->expression->renderedChildren . '@)';
 }
示例#20
0
    /**
     * @param WikiLingo\Expression\Plugin $plugin
     * @param string $body
     * @param WikiLingo\Renderer $renderer
     * @param WikiLingo\Parser $parser
     * @return string
     */
    public function render(WikiLingo\Expression\Plugin &$plugin, &$body = '', &$renderer, &$parser)
    {
        $plugin->allowLineAfter = false;
        $id = $plugin->id();
        $anchors = array();
        if (!$parser->wysiwyg) {
            if (!empty($plugin->privateAttributes['titles'])) {
                //menu
                $ul = Type::Helper($renderer->helper('ul'));
                $ul->attributes['id'] = $id . '-menu';
                $i = 1;
                //anchors for sections
                foreach ($plugin->privateAttributes['titles'] as $sectionId => $title) {
                    $link = Type::Helper($renderer->helper('span'));
                    $link->attributes['href'] = $sectionId;
                    $link->attributes['onclick'] = <<<JS
\$.fn.fullpage.moveTo({$i});
return false;
JS;
                    $i++;
                    //$anchors[] = $a->attributes['data-index'] = $i++;
                    //$a->attributes['id'] = $sectionId . '-anchor';
                    $link->staticChildren[] = $title;
                    $li = Type::Helper($renderer->helper('li'));
                    $li->children[] = $link;
                    $ul->children[] = $li;
                }
                $body .= $ul->render();
                $anchorsJson = json_encode($anchors);
                Type::Scripts($parser->scripts)->addScriptLocation('~/bower_components/fullPage.js/jquery.fullPage.js')->addCssLocation('~/bower_components/fullPage.js/jquery.fullPage.css')->addScript(<<<JS
    \$(function() {
        \$.fn.fullpage({
            anchors: {$anchorsJson},
            easing: 'easeInOutQuad',
            scrollSpeed: 1100,
            menu: '#{$id}-menu'
        });
    });
JS
)->addCss(<<<CSS
#{$id}-menu {
    height: 40px;
    left: 0;
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    width: 100%;
    list-style: none outside none;
}

#{$id}-menu li {
    background-color: rgba(255, 255, 255, 0.5);
    color: #000000;
    border-radius: 10px;
    display: inline-block;
    margin: 10px;
}

#{$id}-menu li.active {
    background-color: rgba(0, 0, 0, 0.5);
    color: #FFFFFF;
}

#{$id}-menu li span {
    display: block;
    padding: 9px 18px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

CSS
);
            }
        }
        $tabs = parent::render($plugin, $body, $renderer, $parser);
        return $tabs;
    }