예제 #1
0
    private static function restorePhrasesInWikiPage($page, $phrase)
    {
        global $smarty, $headerlib;
        $items = self::forwardLink($page)->getItems();
        $phrases = array();
        $phraseI = 0;
        foreach ($items as $item) {
            $thisText = addslashes(htmlspecialchars($item->forwardlink->text));
            $thisDate = addslashes(htmlspecialchars($item->forwardlink->date));
            $thisHref = addslashes(htmlspecialchars($item->textlink->href));
            $linkedText = addslashes(htmlspecialchars($item->textlink->text));
            $phrases[] = $thisText;
            if ($thisText == $phrase) {
                $headerlib->add_js(<<<JQ
\t\t\t\t\$(function() {
\t\t\t\t\t\$('#page-data')
\t\t\t\t\t\t.rangyRestoreSelection('{$thisText}', function(r) {
\t\t\t\t\t\t\tvar phraseLink = \$('<a>*</a>')
\t\t\t\t\t\t\t\t.attr('href', '{$thisHref}')
\t\t\t\t\t\t\t\t.attr('text', '{$thisText}')
\t\t\t\t\t\t\t\t.attr('linkedText', '{$linkedText}')
\t\t\t\t\t\t\t\t.addClass('forwardlink')
\t\t\t\t\t\t\t\t.insertBefore(r.selection[0]);

\t\t\t\t\t\t\tr.selection.addClass('ui-state-highlight');

\t\t\t\t\t\t\t\$('body,html').animate({
\t\t\t\t\t\t\t\tscrollTop: r.start.offset().top
\t\t\t\t\t\t\t});
\t\t\t\t\t\t});
\t\t\t\t});
JQ
);
            } else {
                $headerlib->add_jq_onready(<<<JQ
\t\t\t\t\tvar phraseLink = \$('<a>*</a>')
\t\t\t\t\t\t.attr('href', '{$thisHref}')
\t\t\t\t\t\t.attr('text', '{$thisText}')
\t\t\t\t\t\t.attr('linkedText', '{$linkedText}')
\t\t\t\t\t\t.addClass('forwardlink')
\t\t\t\t\t\t.insertBefore('.phraseStart{$phraseI}');

\t\t\t\t\t\$('.phrase{$phraseI}').addClass('ui-state-highlight');
JQ
);
            }
            $phraseI++;
        }
        $headerlib->add_jsfile('lib/jquery/tablesorter/jquery.tablesorter.js')->add_cssfile('lib/jquery_tiki/tablesorter/themes/tiki/style.css')->add_jq_onready(<<<JQ
\t\t\t\t\$('#page-data').trigger('rangyDone');

\t\t\t\t\$('.forwardlink')
\t\t\t\t\t.click(function() {
\t\t\t\t\t\tme = \$(this);
\t\t\t\t\t\tvar href = me.attr('href');
\t\t\t\t\t\tvar text = me.attr('text');
\t\t\t\t\t\tvar linkedText = me.attr('linkedText');

\t\t\t\t\t\tvar table = \$('<div>' +
\t\t\t\t\t\t\t'<table class="tablesorter">' +
\t\t\t\t\t\t\t\t'<thead>' +
\t\t\t\t\t\t\t\t\t'<tr>' +
\t\t\t\t\t\t\t\t\t\t'<th>' + tr('Date') + '</th>' +
\t\t\t\t\t\t\t\t\t\t'<th>' + tr('Click below to read Citing blocks') + '</th>' +
\t\t\t\t\t\t\t\t\t'</tr>' +
\t\t\t\t\t\t\t\t'</thead>' +
\t\t\t\t\t\t\t\t'<tbody>' +
\t\t\t\t\t\t\t\t\t'<tr>' +
\t\t\t\t\t\t\t\t\t\t'<td>{$thisDate}</td>' +
\t\t\t\t\t\t\t\t\t\t'<td><a href="' + href + '" class="read">Read</a></td>' +
\t\t\t\t\t\t\t\t\t'</tr>' +
\t\t\t\t\t\t\t\t'</tbody>' +
\t\t\t\t\t\t\t'</table>' +
\t\t\t\t\t\t'</div>')
\t\t\t\t\t\t\t.dialog({
\t\t\t\t\t\t\t\ttitle: text,
\t\t\t\t\t\t\t\tmodal: true
\t\t\t\t\t\t\t})
\t\t\t\t\t\t\t.tablesorter();

\t\t\t\t\t\treturn false;
\t\t\t\t\t});
JQ
);
        $phraser = new JisonParser_Phraser_Handler();
        $parsed = $smarty->getTemplateVars('parsed');
        if (!empty($parsed)) {
            $smarty->assign('parsed', $phraser->findPhrases($parsed, $phrases));
        } else {
            $previewd = $smarty->getTemplateVars('previewd');
            if (!empty($previewd)) {
                $previewd = $phraser->findPhrases($previewd, $phrases);
                $smarty->assign('previewd', $previewd);
            }
        }
    }
예제 #2
0
    static function restorePhrasesInWikiPage(JisonParser_Phraser_Handler $phraser, $phrases)
    {
        global $headerlib, $smarty;
        //TODO - not sure the tablesorter js and css files need to be loaded since they are loaded in tiki-setup
        $headerlib->add_jsfile('vendor/jquery/plugins/tablesorter/js/jquery.tablesorter.js')->add_cssfile('lib/jquery_tiki/tablesorter/style.css')->add_jq_onready(<<<JQ
\t\t\t\t\$('a.forwardlinkA,a.textlinkA')
\t\t\t\t\t.css('cursor', 'pointer')
\t\t\t\t\t.click(function() {
\t\t\t\t\t\tvar me = \$(this),
\t\t\t\t\t\tmetadataHere = me.data('metadataHere'),
\t\t\t\t\t\tmetadataThere = me.data('metadataThere');

\t\t\t\t\t\tvar table = \$('<table class="tablesorter" style="width: 100%;"/>');
\t\t\t\t\t\tvar thead = \$('<thead><tr /></thead>').appendTo(table);
\t\t\t\t\t\tvar tbody = \$('<tbody><tr /></tbody>').appendTo(table);

\t\t\t\t\t\tfunction a(head, body) {
\t\t\t\t\t\t\t\$('<th />').text(head).appendTo(thead.find('tr'));

\t\t\t\t\t\t\t\$('<td />').html(body).appendTo(tbody.find('tr'));
\t\t\t\t\t\t}

\t\t\t\t\t\ta(tr('Sentence text'), metadataThere.text);
\t\t\t\t\t\ta(tr('Date Created'), metadataThere.dateOriginated);
\t\t\t\t\t\ta(tr('Date Updated Here'), metadataHere.dateLastUpdated);
\t\t\t\t\t\ta(tr('Date Updated There'), metadataThere.dateLastUpdated);
\t\t\t\t\t\ta(tr('Click below to read Citing blocks'), '<input type="submit" value="' + tr('Read') + '" />');

\t\t\t\t\t\tvar form = \$('<form method="POST" />')
\t\t\t\t\t\t\t.attr('action', metadataThere.href)
\t\t\t\t\t\t\t.append(\$('<input type="hidden" name="phrase" />').val(metadataThere.text))
\t\t\t\t\t\t\t.append(table)
\t\t\t\t\t\t\t.dialog({
\t\t\t\t\t\t\t\ttitle: tr('Linked to: ') + metadataHere.text,
\t\t\t\t\t\t\t\tmodal: true,
\t\t\t\t\t\t\t\twidth: \$(window).width() * 0.8
\t\t\t\t\t\t\t});

\t\t\t\t\t\treturn false;
\t\t\t\t\t});
JQ
, 100);
        $parsed = $smarty->getTemplateVars('parsed');
        if (!empty($parsed)) {
            $smarty->assign('parsed', $phraser->findPhrases($parsed, $phrases));
        } else {
            $previewd = $smarty->getTemplateVars('previewd');
            if (!empty($previewd)) {
                $previewd = $phraser->findPhrases($previewd, $phrases);
                $smarty->assign('previewd', $previewd);
            }
        }
    }