static function render($text, $type = null, $id = null, $instructions = null)
 {
     global $conf, $baseurl, $db;
     // Unfortunately dokuwiki also uses $conf
     $fs_conf = $conf;
     $conf = array();
     // Dokuwiki generates some notices
     error_reporting(E_ALL ^ E_NOTICE);
     if (!$instructions) {
         include_once BASEDIR . '/plugins/dokuwiki/inc/parser/parser.php';
     }
     require_once BASEDIR . '/plugins/dokuwiki/inc/common.php';
     require_once BASEDIR . '/plugins/dokuwiki/inc/parser/xhtml.php';
     // Create a renderer
     $Renderer = new Doku_Renderer_XHTML();
     if (!is_string($instructions) || strlen($instructions) < 1) {
         $modes = p_get_parsermodes();
         $Parser = new Doku_Parser();
         // Add the Handler
         $Parser->Handler = new Doku_Handler();
         // Add modes to parser
         foreach ($modes as $mode) {
             $Parser->addMode($mode['mode'], $mode['obj']);
         }
         $instructions = $Parser->parse($text);
         // Cache the parsed text
         if (!is_null($type) && !is_null($id)) {
             $fields = array('content' => serialize($instructions), 'type' => $type, 'topic' => $id, 'last_updated' => time());
             $keys = array('type', 'topic');
             //autoquote is always true on db class
             $db->Replace('{cache}', $fields, $keys);
         }
     } else {
         $instructions = unserialize($instructions);
     }
     $Renderer->smileys = getSmileys();
     $Renderer->entities = getEntities();
     $Renderer->acronyms = getAcronyms();
     $Renderer->interwiki = getInterwiki();
     $conf = $fs_conf;
     $conf['cachedir'] = FS_CACHE_DIR;
     // for dokuwiki
     $conf['fperm'] = 0600;
     $conf['dperm'] = 0700;
     // Loop through the instructions
     foreach ($instructions as $instruction) {
         // Execute the callback against the Renderer
         call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
     }
     $return = $Renderer->doc;
     // Display the output
     if (Get::val('histring')) {
         $words = explode(' ', Get::val('histring'));
         foreach ($words as $word) {
             $return = html_hilight($return, $word);
         }
     }
     return $return;
 }
Пример #2
0
/**
 * Prepares and prints an JavaScript array with all toolbar buttons
 *
 * @emits  TOOLBAR_DEFINE
 * @param  string $varname Name of the JS variable to fill
 * @author Andreas Gohr <*****@*****.**>
 */
function toolbar_JSdefines($varname)
{
    global $lang;
    $menu = array();
    $evt = new Doku_Event('TOOLBAR_DEFINE', $menu);
    if ($evt->advise_before()) {
        // build button array
        $menu = array_merge($menu, array(array('type' => 'format', 'title' => $lang['qb_bold'], 'icon' => 'bold.png', 'key' => 'b', 'open' => '**', 'close' => '**', 'block' => false), array('type' => 'format', 'title' => $lang['qb_italic'], 'icon' => 'italic.png', 'key' => 'i', 'open' => '//', 'close' => '//', 'block' => false), array('type' => 'format', 'title' => $lang['qb_underl'], 'icon' => 'underline.png', 'key' => 'u', 'open' => '__', 'close' => '__', 'block' => false), array('type' => 'format', 'title' => $lang['qb_code'], 'icon' => 'mono.png', 'key' => 'c', 'open' => "''", 'close' => "''", 'block' => false), array('type' => 'format', 'title' => $lang['qb_strike'], 'icon' => 'strike.png', 'key' => 'd', 'open' => '<del>', 'close' => '</del>', 'block' => false), array('type' => 'autohead', 'title' => $lang['qb_hequal'], 'icon' => 'hequal.png', 'key' => '8', 'text' => $lang['qb_h'], 'mod' => 0, 'block' => true), array('type' => 'autohead', 'title' => $lang['qb_hminus'], 'icon' => 'hminus.png', 'key' => '9', 'text' => $lang['qb_h'], 'mod' => 1, 'block' => true), array('type' => 'autohead', 'title' => $lang['qb_hplus'], 'icon' => 'hplus.png', 'key' => '0', 'text' => $lang['qb_h'], 'mod' => -1, 'block' => true), array('type' => 'picker', 'title' => $lang['qb_hs'], 'icon' => 'h.png', 'class' => 'pk_hl', 'list' => array(array('type' => 'format', 'title' => $lang['qb_h1'], 'icon' => 'h1.png', 'key' => '1', 'open' => '====== ', 'close' => ' ======\\n'), array('type' => 'format', 'title' => $lang['qb_h2'], 'icon' => 'h2.png', 'key' => '2', 'open' => '===== ', 'close' => ' =====\\n'), array('type' => 'format', 'title' => $lang['qb_h3'], 'icon' => 'h3.png', 'key' => '3', 'open' => '==== ', 'close' => ' ====\\n'), array('type' => 'format', 'title' => $lang['qb_h4'], 'icon' => 'h4.png', 'key' => '4', 'open' => '=== ', 'close' => ' ===\\n'), array('type' => 'format', 'title' => $lang['qb_h5'], 'icon' => 'h5.png', 'key' => '5', 'open' => '== ', 'close' => ' ==\\n')), 'block' => true), array('type' => 'linkwiz', 'title' => $lang['qb_link'], 'icon' => 'link.png', 'key' => 'l', 'open' => '[[', 'close' => ']]', 'block' => false), array('type' => 'format', 'title' => $lang['qb_extlink'], 'icon' => 'linkextern.png', 'open' => '[[', 'close' => ']]', 'sample' => 'http://example.com|' . $lang['qb_extlink'], 'block' => false), array('type' => 'formatln', 'title' => $lang['qb_ol'], 'icon' => 'ol.png', 'open' => '  - ', 'close' => '', 'key' => '-', 'block' => true), array('type' => 'formatln', 'title' => $lang['qb_ul'], 'icon' => 'ul.png', 'open' => '  * ', 'close' => '', 'key' => '.', 'block' => true), array('type' => 'insert', 'title' => $lang['qb_hr'], 'icon' => 'hr.png', 'insert' => '\\n----\\n', 'block' => true), array('type' => 'mediapopup', 'title' => $lang['qb_media'], 'icon' => 'image.png', 'url' => 'lib/exe/mediamanager.php?ns=', 'name' => 'mediaselect', 'options' => 'width=750,height=500,left=20,top=20,scrollbars=yes,resizable=yes', 'block' => false), array('type' => 'picker', 'title' => $lang['qb_smileys'], 'icon' => 'smiley.png', 'list' => getSmileys(), 'icobase' => 'smileys', 'block' => false), array('type' => 'picker', 'title' => $lang['qb_chars'], 'icon' => 'chars.png', 'list' => explode(' ', 'À à Á á  â à ã Ä ä Ǎ ǎ Ă ă Å å Ā ā Ą ą Æ æ Ć ć Ç ç Č č Ĉ ĉ Ċ ċ Ð đ ð Ď ď È è É é Ê ê Ë ë Ě ě Ē ē Ė ė Ę ę Ģ ģ Ĝ ĝ Ğ ğ Ġ ġ Ĥ ĥ Ì ì Í í Î î Ï ï Ǐ ǐ Ī ī İ ı Į į Ĵ ĵ Ķ ķ Ĺ ĺ Ļ ļ Ľ ľ Ł ł Ŀ ŀ Ń ń Ñ ñ Ņ ņ Ň ň Ò ò Ó ó Ô ô Õ õ Ö ö Ǒ ǒ Ō ō Ő ő Œ œ Ø ø Ŕ ŕ Ŗ ŗ Ř ř Ś ś Ş ş Š š Ŝ ŝ Ţ ţ Ť ť Ù ù Ú ú Û û Ü ü Ǔ ǔ Ŭ ŭ Ū ū Ů ů ǖ ǘ ǚ ǜ Ų ų Ű ű Ŵ ŵ Ý ý Ÿ ÿ Ŷ ŷ Ź ź Ž ž Ż ż Þ þ ß Ħ ħ ¿ ¡ ¢ £ ¤ ¥ € ¦ § ª ¬ ¯ ° ± ÷ ‰ ¼ ½ ¾ ¹ ² ³ µ ¶ † ‡ · • º ∀ ∂ ∃ Ə ə ∅ ∇ ∈ ∉ ∋ ∏ ∑ ‾ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥ ⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ◊ ℘ ℑ ℜ ℵ ♠ ♣ ♥ ♦ α β Γ γ Δ δ ε ζ η Θ θ ι κ Λ λ μ Ξ ξ Π π ρ Σ σ Τ τ υ Φ φ χ Ψ ψ Ω ω ★ ☆ ☎ ☚ ☛ ☜ ☝ ☞ ☟ ☹ ☺ ✔ ✘ × „ “ ” ‚ ‘ ’ « » ‹ › — – … ← ↑ → ↓ ↔ ⇐ ⇑ ⇒ ⇓ ⇔ © ™ ® ′ ″ [ ] { } ~ ( ) % § $ # | @'), 'block' => false), array('type' => 'signature', 'title' => $lang['qb_sig'], 'icon' => 'sig.png', 'key' => 'y', 'block' => false)));
    }
    // end event TOOLBAR_DEFINE default action
    $evt->advise_after();
    unset($evt);
    // use JSON to build the JavaScript array
    $json = new JSON();
    print "var {$varname} = " . $json->encode($menu) . ";\n";
}
Пример #3
0
 function p_render($mode, $instructions, &$info)
 {
     if (is_null($instructions)) {
         return '';
     }
     //    msg("Memory Usage p_render start: ". memory_get_usage(), -1);
     //    require_once DOKU_INC."inc/parser/$mode.php";
     $rclass = "Doku_Renderer_{$mode}";
     if (!class_exists($rclass)) {
         trigger_error("Unable to resolve render class {$rclass}", E_USER_ERROR);
     }
     $Renderer =& new $rclass();
     #FIXME any way to check for class existance?
     $Renderer->smileys = getSmileys();
     $Renderer->entities = getEntities();
     $Renderer->latexentities = $this->_texit_conf['latexentities'];
     $Renderer->acronyms = getAcronyms();
     $Renderer->interwiki = getInterwiki();
     $Renderer->info = $info;
     // Loop through the instructions
     foreach ($instructions as $instruction) {
         // Execute the callback against the Renderer
         call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
     }
     //set info array
     $info = $Renderer->info;
     //    msg("Memory Usage p_render end: ". memory_get_usage(), -1);
     // Return the output
     return $Renderer->doc;
 }
Пример #4
0
/**
 * Renders a list of instruction to the specified output mode
 *
 * In the $info array is information from the renderer returned
 *
 * @author Harry Fuecks <*****@*****.**>
 * @author Andreas Gohr <*****@*****.**>
 */
function p_render($mode, $instructions, &$info)
{
    if (is_null($instructions)) {
        return '';
    }
    $Renderer =& p_get_renderer($mode);
    if (is_null($Renderer)) {
        return null;
    }
    $Renderer->reset();
    $Renderer->smileys = getSmileys();
    $Renderer->entities = getEntities();
    $Renderer->acronyms = getAcronyms();
    $Renderer->interwiki = getInterwiki();
    // Loop through the instructions
    foreach ($instructions as $instruction) {
        // Execute the callback against the Renderer
        call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
    }
    //set info array
    $info = $Renderer->info;
    // Post process and return the output
    $data = array($mode, &$Renderer->doc);
    trigger_event('RENDERER_CONTENT_POSTPROCESS', $data);
    return $Renderer->doc;
}
Пример #5
0
/**
 * Renders a list of instruction to the specified output mode
 *
 * In the $info array are informations from the renderer returned
 *
 * @author Harry Fuecks <*****@*****.**>
 * @author Andreas Gohr <*****@*****.**>
 */
function p_render($mode, $instructions, &$info)
{
    if (is_null($instructions)) {
        return '';
    }
    if ($mode == 'wiki') {
        msg("Renderer for {$mode} not valid", -1);
        return null;
    }
    //FIXME!! remove this line when inc/parser/wiki.php works.
    // Create the renderer
    if (!@file_exists(DOKU_INC . "inc/parser/{$mode}.php")) {
        msg("No renderer for {$mode} found", -1);
        return null;
    }
    require_once DOKU_INC . "inc/parser/{$mode}.php";
    $rclass = "Doku_Renderer_{$mode}";
    if (!class_exists($rclass)) {
        trigger_error("Unable to resolve render class {$rclass}", E_USER_WARNING);
        msg("Renderer for {$mode} not valid", -1);
        return null;
    }
    $Renderer = new $rclass();
    #FIXME any way to check for class existance?
    $Renderer->smileys = getSmileys();
    $Renderer->entities = getEntities();
    $Renderer->acronyms = getAcronyms();
    $Renderer->interwiki = getInterwiki();
    #$Renderer->badwords = getBadWords();
    // Loop through the instructions
    foreach ($instructions as $instruction) {
        // Execute the callback against the Renderer
        call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
    }
    //set info array
    $info = $Renderer->info;
    // Post process and return the output
    $data = array($mode, &$Renderer->doc);
    trigger_event('RENDERER_CONTENT_POSTPROCESS', $data);
    return $Renderer->doc;
}
Пример #6
0
 function smiley($smiley)
 {
     static $smileys;
     if (!$smileys) {
         $smileys = getSmileys();
     }
     if (array_key_exists($smiley, $this->smileys)) {
         $spath = DOKU_INC . 'lib/images/smileys/' . $smileys[$smiley];
         $name = $this->copy_media($spath, true);
         $this->doc .= $this->_media($name);
     }
 }
Пример #7
0
/**
 *
 *
 * @global string $db_url
 * @global dom $dom
 * @param boolean $parse_smileys Defaults to TRUE
 * @param boolean $filter_words Defaults to FALSE
 * @param boolean $processUsername Defaults to FALSE
 * @param boolean $processTime Defaults to FALSE
 * @param boolean $apply_filter Defaults to TRUE
 * @return array
 */
function get_all_data($parse_smileys = true, $filter_words = false, $processUsername = false, $processTime = false, $apply_filter = true)
{
    global $db_url;
    global $dom;
    $db = YDB::factory($db_url);
    $data = array();
    $data = $db->queryAll(parse_tbprefix("SELECT p.pid AS id, p.ip AS ip , p.uid AS uid ,p.uname AS uname,p.content AS post_content,p.post_time AS time,r.content AS reply_content,r.r_time AS reply_time ,u.username AS b_username FROM <post> AS p LEFT JOIN <reply> AS r ON p.pid=r.pid LEFT JOIN <sysuser> AS u ON p.uid=u.uid ORDER BY p.post_time DESC"));
    foreach ($data as &$_data) {
        if ($apply_filter && ZFramework::app()->filter_type == ConfigController::FILTER_TRIPTAGS) {
            if (strstr(ZFramework::app()->allowed_tags, 'code')) {
                $_data['post_content'] = preg_replace_callback('|<code>(.*)</code>|sU', create_function('$matches', 'return "<pre class=\'prettyprint\'>".str_replace(">","&gt;",str_replace("<","&lt;",$matches[1]))."</pre>";'), $_data['post_content']);
                $_data['reply_content'] = preg_replace_callback('|<code>(.*)</code>|sU', create_function('$matches', 'return "<pre class=\'prettyprint\'>".str_replace(">","&gt;",str_replace("<","&lt;",$matches[1]))."</pre>";'), $_data['reply_content']);
                if (!strstr(ZFramework::app()->allowed_tags, 'pre')) {
                    ZFramework::app()->allowed_tags .= "<pre>";
                }
            }
            $_data['post_content'] = strip_tags($_data['post_content'], ZFramework::app()->allowed_tags);
            $_data['reply_content'] = strip_tags($_data['reply_content'], ZFramework::app()->allowed_tags);
        } else {
            $_data['post_content'] = htmlentities($_data['post_content'], ENT_COMPAT, 'UTF-8');
            $_data['reply_content'] = htmlentities($_data['reply_content'], ENT_COMPAT, 'UTF-8');
        }
        if ($parse_smileys) {
            $dom->loadHTML($_data['post_content']);
            $_data['post_content'] = html_entity_decode(parse_smileys($_data['post_content'], SMILEYDIR, getSmileys()));
            if ($_data['reply_content']) {
                $dom->loadHTML($_data['reply_content']);
                $_data['reply_content'] = html_entity_decode(parse_smileys($_data['reply_content'], SMILEYDIR, getSmileys()));
            }
        }
        if ($filter_words) {
            $_data['post_content'] = filter_words($_data['post_content']);
        }
        if ($processUsername) {
            $_data['user'] = $_data['uname'] == ZFramework::app()->admin ? "<font color='red'>{$_data['uname']}</font>" : $_data['uname'];
        }
        if ($processTime) {
            $_data['time'] = date('m-d H:i', $_data['time'] + ZFramework::app()->timezone * 60 * 60);
            $_data['reply_time'] = date('m-d H:i', $_data['reply_time'] + ZFramework::app()->timezone * 60 * 60);
        }
    }
    return $data;
}
Пример #8
0
 /**
  * Reorders the smileys from a drag/drop event
  * Will move them from post to popup location and visa-versa
  * Will move them to new rows
  */
 public function action_smileyorder()
 {
     global $context, $txt;
     // Start off with an empty response
     $context['xml_data'] = array();
     $errors = array();
     $order = array();
     // Chances are I wear a silly ;D
     loadLanguage('Errors');
     loadLanguage('ManageSmileys');
     require_once SUBSDIR . '/Smileys.subs.php';
     // You have to be allowed to do this
     $validation_token = validateToken('admin-sort', 'post', true, false);
     $validation_session = validateSession();
     if (empty($validation_session) && $validation_token === true) {
         // Valid posting
         if (isset($_POST['order']) && $_POST['order'] == 'reorder') {
             // Get the details on the moved smile
             list(, $smile_moved) = explode('_', $_POST['moved']);
             $smile_moved = (int) $smile_moved;
             $smile_moved_details = getSmiley($smile_moved);
             // Check if we moved rows or locations
             $smile_received_location = null;
             $smile_received_row = null;
             if (!empty($_POST['received'])) {
                 $displayTypes = array('postform' => 0, 'popup' => 2);
                 list($smile_received_location, $smile_received_row) = explode('|', $_POST['received']);
                 $smile_received_location = $displayTypes[substr($smile_received_location, 7)];
             }
             // If these are not set, we are kind of lost :P
             if (isset($smile_received_location, $smile_received_row)) {
                 // Read the new ordering, remember where the moved smiley is in the stack
                 $list_order = 0;
                 $moved_key = 0;
                 $smiley_tree = array();
                 foreach ($_POST['smile'] as $smile_id) {
                     $smiley_tree[] = $smile_id;
                     // Keep track of where the moved smiley is in the sort stack
                     if ($smile_id == $smile_moved) {
                         $moved_key = $list_order;
                     }
                     $list_order++;
                 }
                 // Now get the updated row, location, order
                 $smiley = array();
                 $smiley['row'] = !isset($smile_received_row) ? $smile_moved_details['row'] : $smile_received_row;
                 $smiley['location'] = !isset($smile_received_location) ? $smile_moved_details['location'] : $smile_received_location;
                 $smiley['order'] = -1;
                 // If the node after the drop zone is in the same row/container, we use its position
                 if (isset($smiley_tree[$moved_key + 1])) {
                     $possible_after = getSmiley($smiley_tree[$moved_key - 1]);
                     if ($possible_after['row'] == $smiley['row'] && $possible_after['location'] == $smiley['location']) {
                         $smiley = getSmileyPosition($smiley['location'], $smiley_tree[$moved_key - 1]);
                     }
                 }
                 // Empty means getSmileyPosition failed and so do we
                 if (!empty($smiley)) {
                     moveSmileyPosition($smiley, $smile_moved);
                     // Done with the move, now we clean up across the containers/rows
                     $smileys = getSmileys();
                     foreach (array_keys($smileys) as $location) {
                         foreach ($smileys[$location]['rows'] as $id => $smiley_row) {
                             // Fix empty rows if any.
                             if ($id != $smiley_row[0]['row']) {
                                 updateSmileyRow($id, $smiley_row[0]['row'], $location);
                                 // Only change the first row value of the first smiley.
                                 $smileys[$location]['rows'][$id][0]['row'] = $id;
                             }
                             // Make sure the smiley order is always sequential.
                             foreach ($smiley_row as $order_id => $smiley) {
                                 if ($order_id != $smiley['order']) {
                                     updateSmileyOrder($smiley['id'], $order_id);
                                 }
                             }
                         }
                     }
                     // Clear the cache, its stale now
                     cache_put_data('parsing_smileys', null, 480);
                     cache_put_data('posting_smileys', null, 480);
                     $order[] = array('value' => $txt['smileys_moved_done']);
                 }
             }
         } else {
             $errors[] = array('value' => $txt['smileys_moved_fail']);
         }
     } else {
         if (!empty($validation_session)) {
             $errors[] = array('value' => $txt[$validation_session]);
         }
         if (empty($validation_token)) {
             $errors[] = array('value' => $txt['token_verify_fail']);
         }
     }
     // New generic token for use
     createToken('admin-sort', 'post');
     $tokens = array(array('value' => $context['admin-sort_token'], 'attributes' => array('type' => 'token')), array('value' => $context['admin-sort_token_var'], 'attributes' => array('type' => 'token_var')));
     // Return the response, whatever it is
     $context['sub_template'] = 'generic_xml';
     $context['xml_data'] = array('orders' => array('identifier' => 'order', 'children' => $order), 'tokens' => array('identifier' => 'token', 'children' => $tokens), 'errors' => array('identifier' => 'error', 'children' => $errors));
 }
Пример #9
0
    function create($id, $user_title = false)
    {
        ob_start();
        $id = ltrim($id, ':');
        $id = ":{$id}";
        $namespace = getNS($id);
        epub_save_namespace($namespace);
        $mode = 'epub';
        $Renderer =& plugin_load('renderer', $mode);
        $Renderer->set_oebps();
        $Renderer->set_current_page(epub_clean_name(str_replace(':', '_', $id)) . '.html');
        $this->_renderer = $Renderer;
        if (is_null($Renderer)) {
            msg("No renderer for {$mode} found", -1);
            exit;
        }
        global $ID;
        $oldID = $ID;
        $ID = cleanID($id);
        $wiki_file = wikiFN($id);
        if (!file_exists($wiki_file)) {
            epub_push_spine(array("", ""));
            echo "{$id} not found\n";
            return false;
        }
        epub_update_progress("reading {$id}");
        $instructions = p_cached_instructions($wiki_file, false, $id);
        if (is_null($instructions)) {
            return '';
        }
        $Renderer->notoc();
        $Renderer->smileys = getSmileys();
        $Renderer->entities = getEntities();
        $Renderer->acronyms = array();
        $Renderer->interwiki = getInterwiki();
        epub_update_progress("rendering {$id},  this could take some time");
        // Loop through the instructions
        foreach ($instructions as $instruction) {
            // Execute the callback against the Renderer
            call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
        }
        $result = "";
        $result .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
        $result .= "\n<head>\n";
        $result .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>' . "\n";
        $result .= '<link rel="stylesheet"  type="text/css" href="../Styles/style.css"/>';
        epub_check_for_mathjax($result);
        $result .= "\n<title>";
        $result .= "</title>\n</head><body>\n";
        $result .= "<div class='dokuwiki'>\n";
        $info = $Renderer->info;
        $data = array($mode, &$Renderer->doc);
        trigger_event('RENDERER_CONTENT_POSTPROCESS', $data);
        $xhtml = $Renderer->doc;
        $result .= $xhtml;
        $result .= "\n</div></body></html>\n";
        $result = preg_replace_callback("/&(\\w+);/m", "epbub_entity_replace", $result);
        $result = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n]+/m", "\n", $result);
        $result = preg_replace("/^\\s+/m", "", $result);
        $result = preg_replace_callback('|<p>([\\s\\n]*)(.*?<div.*?/div>.*?)([\\s\\n])*<\\/p>|im', create_function('$matches', '$result = $matches[1] . $matches[2] . $matches[3];
											//echo "$result\\n";
											return $result;'), $result);
        ob_end_flush();
        if ($user_title) {
            $id = 'title.html';
        } else {
            $id = epub_clean_name(str_replace(':', '_', $id)) . '.html';
        }
        io_saveFile(epub_get_oebps() . "Text/{$id}", $result);
        if ($user_title) {
            epub_write_zip('Text/title.html');
            $ID = $oldID;
            return true;
        }
        $item_num = epub_write_item("Text/{$id}", "application/xhtml+xml");
        epub_push_spine(array("Text/{$id}", $item_num));
        epub_save_namespace();
        $ID = $oldID;
        return true;
    }
Пример #10
0
    /**
     * Renders a list of instruction to minimal xhtml
     *@author Myron Turner <*****@*****.**>
     */
    function _render_xhtml($text)
    {
        $mode = 'ckgedit';
        global $skip_styling;
        $skip_styling = $this->getConf('nofont_styling');
        if (!$skip_styling && $_POST['styling'] == 'no_styles') {
            $skip_styling = true;
        }
        if (strpos($text, '~~NO_STYLING~~') !== false) {
            $skip_styling = true;
        }
        $text = preg_replace_callback('/(\\[\\[\\w+>)(.*?)([\\]\\|])/ms', create_function('$matches', '  //if(preg_match("/^\\w+$/",$matches[2])) return $matches[0];
                return $matches[1] . "oIWIKIo" . $matches[2] ."cIWIKIc" . $matches[3] ;'), $text);
        global $Smilies;
        $smiley_as_text = @$this->getConf('smiley_as_text');
        if ($smiley_as_text) {
            $Smilies = array('8-)' => 'aSMILEY_1', '8-O' => 'aSMILEY_2', ':-(' => 'aSMILEY_3', ':-)' => 'aSMILEY_4', '=)' => 'aSMILEY_5', ':-/' => 'aSMILEY_6', ':-\\' => 'aSMILEY_7', ':-?' => 'aSMILEY_8', ':-D' => 'aSMILEY_9', ':-P' => 'bSMILEY_10', ':-O' => 'bSMILEY_11', ':-X' => 'bSMILEY_12', ':-|' => 'bSMILEY_13', ';-)' => 'bSMILEY_14', '^_^' => 'bSMILEY_15', ':?:' => 'bSMILEY_16', ':!:' => 'bSMILEY_17', 'LOL' => 'bSMILEY_18', 'FIXME' => 'bSMILEY_19', 'DELETEME' => 'bSMILEY_20');
            $s_values = array_values($Smilies);
            $s_values_regex = implode('|', $s_values);
            $s_keys = array_keys($Smilies);
            $s_keys = array_map(create_function('$k', 'return "(" . preg_quote($k,"/") . ")";'), $s_keys);
            $s_keys_regex = implode('|', $s_keys);
            global $haveDokuSmilies;
            $haveDokuSmilies = false;
            $text = preg_replace_callback('/(' . $s_keys_regex . ')/ms', create_function('$matches', 'global $Smilies;   
                 global $haveDokuSmilies;
                 $haveDokuSmilies = true;
                 return $Smilies[$matches[1]];'), $text);
        }
        // try default renderer first:
        $file = DOKU_INC . "inc/parser/{$mode}.php";
        if (@file_exists($file)) {
            require_once $file;
            $rclass = "Doku_Renderer_{$mode}";
            if (!class_exists($rclass)) {
                trigger_error("Unable to resolve render class {$rclass}", E_USER_WARNING);
                msg("Renderer for {$mode} not valid", -1);
                return null;
            }
            $Renderer = new $rclass();
        } else {
            // Maybe a plugin is available?
            $Renderer = plugin_load('renderer', $mode);
            if (is_null($Renderer)) {
                msg("No renderer for {$mode} found", -1);
                return null;
            }
        }
        // aimed at wrap plugin which allows multiple newlines in a cell
        $text = preg_replace_callback('#(\\|.*?)\\|.?[\\n\\r]#ms', function ($matches) {
            $matches[0] = preg_replace("#\\\\\\\\\\s*[\r\n]#ms", "  \\\\\\\\  ", $matches[0]);
            return $matches[0];
        }, $text);
        // prevents utf8 conversions of quotation marks
        $text = str_replace('"', "_ckgedit_QUOT_", $text);
        $text = preg_replace_callback('/(<code.*?>)([^<]+)(<\\/code>)/ms', create_function('$matches', '$quot =  str_replace("_ckgedit_QUOT_",\'"\',$matches[2]); 
                $quot = str_replace("\\\\ ","_ckgedit_NL",$quot); 
                $quot .= "_ckgedit_NL";                
                return $matches[1] . $quot . $matches[3];'), $text);
        $text = preg_replace_callback('/(<file.*?>)([^<]+)(<\\/file>)/ms', create_function('$matches', '$quot =  str_replace("_ckgedit_QUOT_",\'"\',$matches[2]); 
                $quot = str_replace("\\\\ ","_ckgedit_NL",$quot); 
                $quot .= "_ckgedit_NL";                
                return $matches[1] . $quot . $matches[3];'), $text);
        $text = preg_replace_callback('/(<code>|<file>)([^<]+)(<\\/code>|<\\/file>)/ms', create_function('$matches', '$matches[2] = str_replace("&lt;font","ckgeditFONTOpen",$matches[2]);
               $matches[2] = str_replace("font&gt;","ckgeditFONTClose",$matches[2]);
                return $matches[1] .$matches[2] . $matches[3]; '), $text);
        $instructions = p_get_instructions("=== header ===");
        // loads DOKU_PLUGINS array --M.T. Dec 22 2009
        $instructions = p_get_instructions($text);
        if (is_null($instructions)) {
            return '';
        }
        $Renderer->notoc();
        $Renderer->smileys = getSmileys();
        $Renderer->entities = getEntities();
        $Renderer->acronyms = array();
        $Renderer->interwiki = getInterwiki();
        // Loop through the instructions
        /*
           By-passing plugin processing was sugested and first implemented
           by Matti Lattu<*****@*****.**>
           It is a significant contribution to the functionality of ckgEdit
        */
        foreach ($instructions as $instruction) {
            if ($instruction[0] == 'plugin') {
                $Renderer->doc .= $instruction[1][3];
            } else {
                // Execute the callback against the Renderer
                call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
            }
        }
        //set info array
        $info = $Renderer->info;
        // Post process and return the output
        $data = array($mode, &$Renderer->doc);
        trigger_event('RENDERER_CONTENT_POSTPROCESS', $data);
        $xhtml = $Renderer->doc;
        if (!$skip_styling) {
            // create font styles from font plugin markup for html display
            $xhtml = preg_replace_callback('|&amp;lt;font\\s+(.*?)/([\\w ,\\-]+);;([\\(\\)),\\w,\\s\\#]+);;([\\(\\)),\\w,\\s\\#]+)&gt;(.*?)&amp;lt;/font&gt;|ms', function ($matches) {
                return '<span style = "color:' . $matches[3] . '">' . '<span style = "font-size:' . $matches[1] . '">' . '<span style = "font-family:' . $matches[2] . '">' . '<span style = "background-color:' . $matches[4] . '">' . $matches[5] . '</span></span></span></span>';
            }, $xhtml);
        }
        if (strpos($xhtml, 'oIWIKIo') !== false) {
            $xhtml = preg_replace_callback('/(.)oIWIKIo(.*?)cIWIKIc/ms', create_function('$matches', ' if(preg_match("/^\\w+$/",$matches[2]) && $matches[1] == "/")  return "/". $matches[2];
                     return $matches[0];'), $xhtml);
            $xhtml = preg_replace_callback('/>oIWIKIo(.*?)cIWIKIc(?=<\\/a>)/ms', create_function('$matches', ' return ">". $matches[1] ;'), $xhtml);
        }
        $pos = strpos($xhtml, 'MULTI_PLUGIN_OPEN');
        if ($pos !== false) {
            $xhtml = preg_replace_callback('|MULTI_PLUGIN_OPEN.*?MULTI_PLUGIN_CLOSE|ms', create_function('$matches', '$matches[0] = str_replace("//<//", "< ",$matches[0]);
                  $matches[0] = str_replace(array("oIWIKIo","cIWIKIc"),"",$matches[0]);
                  return preg_replace("/\\n/ms","<br />",$matches[0]);'), $xhtml);
            $xhtml = preg_replace('/~\\s*~\\s*MULTI_PLUGIN_OPEN~\\s*~/', "\n\n~~MULTI_PLUGIN_OPEN~~<span class='multi_p_open'>\n\n</span>\n\n", $xhtml);
            $xhtml = preg_replace('/~\\s*~\\s*MULTI_PLUGIN_CLOSE~\\s*~/', "<span class='multi_p_close'>\n\n<br /></span>\n\n~~MULTI_PLUGIN_CLOSE~~\n\n", $xhtml);
        }
        // remove empty paragraph: see _ckgedit_NPBBR_ comment above
        $xhtml = preg_replace('/<p>\\s+_ckgedit_NPBBR_\\s+<\\/p>/ms', "\n", $xhtml);
        $xhtml = str_replace('_ckgedit_NPBBR_', "<span class='np_break'>&nbsp;</span>", $xhtml);
        $xhtml = str_replace('_ckgedit_QUOT_', '&quot;', $xhtml);
        $xhtml = str_replace('_ckgedit_NL', "\n", $xhtml);
        $xhtml = str_replace('</pre>', "\n\n</pre><p>&nbsp;</p>", $xhtml);
        // inserts p before an initial codeblock to enable text entry above block
        $xhtml = preg_replace('/^<pre/', "<p>&nbsp;</p><pre", $xhtml);
        //remove empty markup remaining after removing marked-up acronyms in lists
        $xhtml = preg_replace('/<(em|b|u|i)>\\s+<\\/(em|b|u|i)>/ms', "", $xhtml);
        $xhtml = preg_replace("/col\\d+\\s+(\\w+align)/ms", "\$1", $xhtml);
        //remove col number for cell prpoerties dialog
        $xhtml = str_replace('ckgeditFONTOpen', '&amp;lt;font', $xhtml);
        // protect font markup in code blocks
        $xhtml = str_replace('ckgeditFONTClose', 'font&amp;gt;', $xhtml);
        if ($smiley_as_text) {
            if ($haveDokuSmilies) {
                $s_values = array_values($Smilies);
                $s_values_regex = implode('|', $s_values);
                $xhtml = preg_replace_callback('/(' . $s_values_regex . ')/ms', create_function('$matches', 'global $Smilies;     
                     return array_search($matches[1],$Smilies); '), $xhtml);
            }
        }
        $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
        if (strpos($ua, 'chrome') !== false) {
            $xhtml = preg_replace_callback('/(?<=<a )(href=\\".*?\\")(\\s+\\w+=\\".*?\\")(.*?)(?=>)/sm', create_function('$matches', '$ret_str = " " . trim($matches[3]) . " " . trim($matches[2])  . " " . trim($matches[1]) ;
			  return $ret_str;'), $xhtml);
        }
        return $xhtml;
    }
Пример #11
0
 function render($mode, &$renderer, $data)
 {
     list($ns, $num, $flags, $refine) = $data;
     $first = $_REQUEST['first'];
     if (!is_numeric($first)) {
         $first = 0;
     }
     // get the blog entries for our namespace
     if ($my =& plugin_load('helper', 'blog')) {
         $entries = $my->getBlog($ns);
     }
     // use tag refinements?
     if ($refine) {
         if (plugin_isdisabled('tag') || !($tag =& plugin_load('helper', 'tag'))) {
             msg($this->getLang('missing_tagplugin'), -1);
         } else {
             $entries = $tag->tagRefine($entries, $refine);
         }
     }
     // any create form overrides?
     $formpos = $this->getConf('formposition');
     if (in_array('topform', $flags)) {
         $formpos = 'top';
     } elseif (in_array('bottomform', $flags)) {
         $formpos = 'bottom';
     } elseif (in_array('noform', $flags)) {
         $formpos = 'none';
     }
     if (!$entries) {
         if (auth_quickaclcheck($ns . ':*') >= AUTH_CREATE && $mode == 'xhtml') {
             $renderer->info['cache'] = false;
             if ($formpos != 'none') {
                 $renderer->doc .= $this->_newEntryForm($ns);
             }
         }
         return true;
         // nothing to display
     }
     // slice the needed chunk of pages
     $more = count($entries) > $first + $num ? true : false;
     $entries = array_slice($entries, $first, $num);
     // load the include helper plugin
     if (plugin_isdisabled('include') || !($include =& plugin_load('helper', 'include'))) {
         msg($this->getLang('missing_includeplugin'), -1);
         return false;
     }
     if ($mode == 'xhtml') {
         // prevent caching to ensure the included pages are always fresh
         $renderer->info['cache'] = false;
         // show new entry form
         $perm_create = auth_quickaclcheck($ns . ':*') >= AUTH_CREATE;
         if ($perm_create && $formpos == 'top') {
             $renderer->doc .= $this->_newEntryForm($ns);
         }
         // current section level
         $clevel = 0;
         preg_match_all('|<div class="level(\\d)">|i', $renderer->doc, $matches, PREG_SET_ORDER);
         $n = count($matches) - 1;
         if ($n > -1) {
             $clevel = $matches[$n][1];
         }
         // close current section
         if ($clevel) {
             $renderer->doc .= '</div>' . DOKU_LF;
         }
         $renderer->doc .= '<div class="hfeed">' . DOKU_LF;
     }
     // we need our own renderer
     $include_renderer =& p_get_renderer('xhtml');
     $include_renderer->smileys = getSmileys();
     $include_renderer->entities = getEntities();
     $include_renderer->acronyms = getAcronyms();
     $include_renderer->interwiki = getInterwiki();
     // now include the blog entries
     foreach ($entries as $entry) {
         if ($mode == 'xhtml') {
             if (auth_quickaclcheck($entry['id']) >= AUTH_READ) {
                 $renderer->doc .= $this->render_XHTML($include, $include_renderer, $entry['id'], $clevel, $flags);
             }
         } elseif ($mode == 'metadata') {
             $renderer->meta['relation']['haspart'][$entry['id']] = true;
         }
     }
     if ($mode == 'xhtml') {
         // resume the section
         $renderer->doc .= '</div>' . DOKU_LF;
         if ($clevel) {
             $renderer->doc .= '<div class="level' . $clevel . '">' . DOKU_LF;
         }
         // BEGIN MODIFIED by harukasan
         if (!in_array('nofollowlink', $flags)) {
             // show older / newer entries links
             $renderer->doc .= $this->_browseEntriesLinks($more, $first, $num);
         }
         // END MODIFIED
         // show new entry form
         if ($perm_create && $formpos == 'bottom') {
             $renderer->doc .= $this->_newEntryForm($ns);
         }
     }
     return true;
 }
Пример #12
0
 /**
  * init Smileys
  * load smileys and set smily_rule and smiley_repl
  */
 function initSmileys()
 {
     $this->smileys = getSmileys();
     $tmp = array_keys($this->smileys);
     $tmp = array_map('_preg_escape', $tmp);
     $rule = implode('|', $tmp);
     $this->smiley_rule = '/(?<=\\s|^|>)(' . $rule . ')(?=\\s|<|$)/';
 }
Пример #13
0
    /**
     * Renders a list of instruction to minimal xhtml
     *@author Myron Turner <*****@*****.**>
     */
    function _render_xhtml($text)
    {
        $mode = 'fckg';
        global $Smilies;
        $smiley_as_text = @$this->getConf('smiley_as_text');
        if ($smiley_as_text) {
            $Smilies = array('8-)' => 'aSMILEY_1', '8-O' => 'aSMILEY_2', ':-(' => 'aSMILEY_3', ':-)' => 'aSMILEY_4', '=)' => 'aSMILEY_5', ':-/' => 'aSMILEY_6', ':-\\' => 'aSMILEY_7', ':-?' => 'aSMILEY_8', ':-D' => 'aSMILEY_9', ':-P' => 'bSMILEY_10', ':-O' => 'bSMILEY_11', ':-X' => 'bSMILEY_12', ':-|' => 'bSMILEY_13', ';-)' => 'bSMILEY_14', '^_^' => 'bSMILEY_15', ':?:' => 'bSMILEY_16', ':!:' => 'bSMILEY_17', 'LOL' => 'bSMILEY_18', 'FIXME' => 'bSMILEY_19', 'DELETEME' => 'bSMILEY_20');
            $s_values = array_values($Smilies);
            $s_values_regex = implode('|', $s_values);
            $s_keys = array_keys($Smilies);
            $s_keys = array_map(create_function('$k', 'return "(" . preg_quote($k,"/") . ")";'), $s_keys);
            $s_keys_regex = implode('|', $s_keys);
            global $haveDokuSmilies;
            $haveDokuSmilies = false;
            $text = preg_replace_callback('/(' . $s_keys_regex . ')/ms', create_function('$matches', 'global $Smilies;   
                 global $haveDokuSmilies;
                 $haveDokuSmilies = true;
                 return $Smilies[$matches[1]];'), $text);
        }
        // try default renderer first:
        $file = DOKU_INC . "inc/parser/{$mode}.php";
        if (@file_exists($file)) {
            require_once $file;
            $rclass = "Doku_Renderer_{$mode}";
            if (!class_exists($rclass)) {
                trigger_error("Unable to resolve render class {$rclass}", E_USER_WARNING);
                msg("Renderer for {$mode} not valid", -1);
                return null;
            }
            $Renderer = new $rclass();
        } else {
            // Maybe a plugin is available?
            $Renderer = plugin_load('renderer', $mode);
            if (is_null($Renderer)) {
                msg("No renderer for {$mode} found", -1);
                return null;
            }
        }
        // prevents utf8 conversions of quotation marks
        $text = str_replace('"', "_fckg_QUOT_", $text);
        $text = preg_replace_callback('/(<code|file.*?>)(.*?)(<\\/code>)/ms', create_function('$matches', '$quot =  str_replace("_fckg_QUOT_",\'"\',$matches[2]); 
                $quot = str_replace("\\\\ ","_fckg_NL",$quot); 
                return $matches[1] . $quot . $matches[3];'), $text);
        global $fckgLPluginPatterns;
        $fckgLPluginPatterns = array();
        $instructions = p_get_instructions("=== header ===");
        // loads DOKU_PLUGINS array --M.T. Dec 22 2009
        $installed_plugins = $this->get_plugins();
        $regexes = $installed_plugins['plugins'];
        $text = preg_replace_callback('/(' . $regexes . ')/', create_function('$matches', 'global $fckgLPluginPatterns;                                 
                 $retv =  preg_replace("/([\\{\\}\\@\\:&~\\?\\!<>])/", "$1 ", $matches[0]);            
                 $fckgLPluginPatterns[] = array($retv, $matches[0]);
                 return $retv;'), $text);
        global $fckLImmutables;
        $fckglImmutables = array();
        foreach ($installed_plugins['xcl'] as $xcl) {
            $text = preg_replace_callback('/' . $xcl . '/', create_function('$matches', 'global $fckLImmutables;
               if(preg_match("#//<//font#",$matches[0])) {
                   return str_replace("//<//", "<", $matches[0]);
               }
               $index = count($fckLImmutables);
               $fckLImmutables[] = $matches[0]; 
               return "<span id=\'imm_" . "$index\' title=\'imm_" . "$index\' >" . str_replace("//<//", "<", $matches[0]) . "</span>" ;'), $text);
        }
        global $multi_block;
        if (preg_match('/(?=MULTI_PLUGIN_OPEN)(.*?)(?<=MULTI_PLUGIN_CLOSE)/ms', $text, $matches)) {
            //file_put_contents('multi_text-2.txt',$matches[1]);
            $multi_block = $matches[1];
        }
        $instructions = p_get_instructions($text);
        if (is_null($instructions)) {
            return '';
        }
        $Renderer->notoc();
        $Renderer->smileys = getSmileys();
        $Renderer->entities = getEntities();
        $Renderer->acronyms = array();
        $Renderer->interwiki = getInterwiki();
        // Loop through the instructions
        foreach ($instructions as $instruction) {
            // Execute the callback against the Renderer
            call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
        }
        //set info array
        $info = $Renderer->info;
        // Post process and return the output
        $data = array($mode, &$Renderer->doc);
        trigger_event('RENDERER_CONTENT_POSTPROCESS', $data);
        $xhtml = $Renderer->doc;
        $pos = strpos($xhtml, 'MULTI_PLUGIN_OPEN');
        if ($pos !== false) {
            $xhtml = preg_replace('/MULTI_PLUGIN_OPEN.*?MULTI_PLUGIN_CLOSE/ms', $multi_block, $xhtml);
            $xhtml = preg_replace_callback('|MULTI_PLUGIN_OPEN.*?MULTI_PLUGIN_CLOSE|ms', create_function('$matches', '$matches[0] = str_replace("//<//", "< ",$matches[0]);
                  return preg_replace("/\\n/ms","<br />",$matches[0]);'), $xhtml);
            $xhtml = preg_replace('/~\\s*~\\s*MULTI_PLUGIN_OPEN~\\s*~/', "~ ~ MULTI_PLUGIN_OPEN~ ~\n\n<span class='multi_p_open'>\n\n</span>", $xhtml);
            $xhtml = preg_replace('/~\\s*~\\s*MULTI_PLUGIN_CLOSE~\\s*~/', "<span class='multi_p_close'>\n\n</span>\n\n~ ~ MULTI_PLUGIN_CLOSE~ ~\n", $xhtml);
        }
        // remove empty paragraph: see _fckg_NPBBR_ comment above
        $xhtml = preg_replace('/<p>\\s+_fckg_NPBBR_\\s+<\\/p>/ms', "\n", $xhtml);
        $xhtml = str_replace('_fckg_NPBBR_', "<span class='np_break'>&nbsp;</span>", $xhtml);
        $xhtml = str_replace('_fckg_QUOT_', '&quot;', $xhtml);
        $xhtml = str_replace('_fckg_NL', "\n", $xhtml);
        $xhtml = str_replace('</pre>', "\n\n</pre><p>&nbsp;</p>", $xhtml);
        // inserts p before an initial codeblock to enable text entry above block
        $xhtml = preg_replace('/^<pre/', "<p>&nbsp;</p><pre", $xhtml);
        //remove empty markup remaining after removing marked-up acronyms in lists
        $xhtml = preg_replace('/<(em|b|u|i)>\\s+<\\/(em|b|u|i)>/ms', "", $xhtml);
        if ($smiley_as_text) {
            if ($haveDokuSmilies) {
                $s_values = array_values($Smilies);
                $s_values_regex = implode('|', $s_values);
                $xhtml = preg_replace_callback('/(' . $s_values_regex . ')/ms', create_function('$matches', 'global $Smilies;     
                     return array_search($matches[1],$Smilies); '), $xhtml);
            }
        }
        $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
        if (strpos($ua, 'chrome') !== false) {
            $xhtml = preg_replace_callback('/(?<=<a )(href=\\".*?\\")(\\s+\\w+=\\".*?\\")(.*?)(?=>)/sm', create_function('$matches', '$ret_str = " " . trim($matches[3]) . " " . trim($matches[2])  . " " . trim($matches[1]) ;
			  return $ret_str;'), $xhtml);
        }
        return $xhtml;
    }
Пример #14
0
 /**
  * Allows to edit smileys order.
  */
 public function action_setorder()
 {
     global $context, $txt;
     require_once SUBSDIR . '/Smileys.subs.php';
     $context['sub_template'] = 'setorder';
     // Move smileys to another position.
     if (isset($_REQUEST['reorder'])) {
         checkSession('get');
         $_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2;
         $_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source'];
         if (empty($_GET['source'])) {
             fatal_lang_error('smiley_not_found');
         }
         $smiley = array();
         if (!empty($_GET['after'])) {
             $_GET['after'] = (int) $_GET['after'];
             $smiley = getSmileyPosition($_GET['location'], $_GET['after']);
             if (empty($smiley)) {
                 fatal_lang_error('smiley_not_found');
             }
         } else {
             $smiley['row'] = (int) $_GET['row'];
             $smiley['order'] = -1;
             $smiley['location'] = (int) $_GET['location'];
         }
         moveSmileyPosition($smiley, $_GET['source']);
     }
     $context['smileys'] = getSmileys();
     $context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move'];
     // Make sure all rows are sequential.
     foreach (array_keys($context['smileys']) as $location) {
         $context['smileys'][$location] = array('id' => $location, 'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'], 'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'], 'last_row' => count($context['smileys'][$location]['rows']), 'rows' => array_values($context['smileys'][$location]['rows']));
     }
     // Check & fix smileys that are not ordered properly in the database.
     foreach (array_keys($context['smileys']) as $location) {
         foreach ($context['smileys'][$location]['rows'] as $id => $smiley_row) {
             // Fix empty rows if any.
             if ($id != $smiley_row[0]['row']) {
                 updateSmileyRow($id, $smiley_row[0]['row'], $location);
                 // Only change the first row value of the first smiley (we don't need the others :P).
                 $context['smileys'][$location]['rows'][$id][0]['row'] = $id;
             }
             // Make sure the smiley order is always sequential.
             foreach ($smiley_row as $order_id => $smiley) {
                 if ($order_id != $smiley['order']) {
                     updateSmileyOrder($smiley['id'], $order_id);
                 }
             }
         }
     }
     cache_put_data('parsing_smileys', null, 480);
     cache_put_data('posting_smileys', null, 480);
     createToken('admin-sort');
 }
Пример #15
0
<?php

if (!defined('IN_MP')) {
    die('Access denied!');
}
$smileyString = "<table id='smileysTable' cellpadding='4'>\n";
$numPerRow = 8;
$smileyArray = array_pad(getSmileys(), ceil(count(getSmileys()) / $numPerRow) * $numPerRow, '');
$smileyArray = array_chunk($smileyArray, $numPerRow, true);
foreach ($smileyArray as $value) {
    $smileyString .= "<tr>\n";
    foreach ($value as $k => $v) {
        if ($v) {
            $smileyString .= "<td><img id='" . $k . "' src='" . SMILEYDIR . $v[0] . "' alt='{$v['3']}' title='{$v['3']}' /></td>\n";
        } else {
            $smileyString .= "<td>&nbsp;</td>";
        }
    }
    $smileyString .= "</tr>\n";
}
$smileyString .= "</table>\n";
return $smileyString;