Commit 0ae8af13 authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4532 (Potential missing lang string error)

parent 518789d1
Loading
Loading
Loading
Loading
+0 −0

File changed.

Preview suppressed by a .gitattributes entry or the file's encoding is unsupported.

+1 −1
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ class Hook_sitemap_entry_point extends Hook_sitemap_base
        } elseif (is_object($_title)) {
            $title = $_title;
        } else {
            $title = (preg_match('#^[A-Z\_]+$#', $_title) == 0) ? make_string_tempcode($_title) : do_lang_tempcode($_title);
            $title = $this->_lang_string_or_literal($_title);
        }

        if (is_null($icon)) {
+2 −2
Original line number Diff line number Diff line
@@ -271,7 +271,7 @@ class Hook_sitemap_page extends Hook_sitemap_base
                                if (is_object($_title)) {
                                    $struct['title'] = $_title;
                                } else {
                                    $struct['title'] = (preg_match('#^[A-Z\_]+$#', $_title) == 0) ? make_string_tempcode($_title) : do_lang_tempcode($_title);
                                    $struct['title'] = $this->_lang_string_or_literal($_title);
                                }
                            }
                            if (!is_null($entry_points['!'][1])) {
@@ -296,7 +296,7 @@ class Hook_sitemap_page extends Hook_sitemap_base
                                if (is_object($_title)) {
                                    $struct['title'] = $_title;
                                } else {
                                    $struct['title'] = (preg_match('#^[A-Z\_]+$#', $_title) == 0) ? make_string_tempcode($_title) : do_lang_tempcode($_title);
                                    $struct['title'] = $this->_lang_string_or_literal($_title);
                                }
                            }
                            if (!is_null($entry_points[$move_down_entry_point][1])) {
+18 −2
Original line number Diff line number Diff line
@@ -617,6 +617,22 @@ abstract class Hook_sitemap_base
        return $row;
    }

    /**
     * Take some text and process it as a language string if applicable, otherwise just convert to Tempcode.
     *
     * @param  string $_title Input string
     * @return Tempcode Output string
     */
    protected function _lang_string_or_literal($_title)
    {
        if ((preg_match('#^[A-Z\_]+$#', $_title) == 0) || (do_lang($_title, null, null, null, null, false) === null)) {
            $title = make_string_tempcode($_title);
        } else {
            $title = protect_from_escaping(do_lang($_title))/*Need to bake it in using do_lang not do_lang_tempcode as lang file may not be present when restored from cache*/;
        }
        return $title;
    }

    /**
     * Extend the node structure with added details from our row data (if we have it).
     *
@@ -635,7 +651,7 @@ abstract class Hook_sitemap_base
            if (($options & SITEMAP_GEN_LABEL_CONTENT_TYPES) == 0) {
                if ($title !== null) {
                    if (is_string($title)) {
                        $title = (preg_match('#^[A-Z\_]+$#', $title) == 0) ? make_string_tempcode($title) : do_lang_tempcode($title);
                        $title = $this->_lang_string_or_literal($title);
                    }

                    if (!$title->is_empty()) {
@@ -648,7 +664,7 @@ abstract class Hook_sitemap_base
                if (($meta_gather & SITEMAP_GATHER_DESCRIPTION) != 0) {
                    if (!isset($struct['extra_meta']['description'])) {
                        if (is_string($description)) {
                            $description = (preg_match('#^[A-Z\_]+$#', $description) == 0) ? make_string_tempcode($description) : comcode_lang_string($description);
                            $description = $this->_lang_string_or_literal($description);
                        }

                        $struct['extra_meta']['description'] = ($description === null) ? null : $description;