当前位置: 首页>>代码示例>>PHP>>正文


PHP Translatable::set_reading_lang方法代码示例

本文整理汇总了PHP中Translatable::set_reading_lang方法的典型用法代码示例。如果您正苦于以下问题:PHP Translatable::set_reading_lang方法的具体用法?PHP Translatable::set_reading_lang怎么用?PHP Translatable::set_reading_lang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Translatable的用法示例。


在下文中一共展示了Translatable::set_reading_lang方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: switchlanguage

    /**
     * Switch the cms language and reload the site tree
     *
     */
    function switchlanguage($lang, $donotcreate = null)
    {
        //is it's a clean switch (to an existing language deselect the current page)
        if (is_string($lang)) {
            $dontunloadPage = true;
        }
        $lang = is_string($lang) ? $lang : urldecode($this->urlParams['ID']);
        if ($lang != Translatable::default_lang()) {
            Translatable::set_reading_lang(Translatable::default_lang());
            $tree_class = $this->stat('tree_class');
            $obj = new $tree_class();
            $allIDs = $obj->getDescendantIDList();
            $allChildren = $obj->AllChildren();
            $classesMap = $allChildren->map('ID', 'ClassName');
            $titlesMap = $allChildren->map();
            Translatable::set_reading_lang($lang);
            $obj = new $tree_class();
            $languageIDs = $obj->getDescendantIDList();
            $notcreatedlist = array_diff($allIDs, $languageIDs);
            FormResponse::add("\$('addpage').getElementsByTagName('button')[0].disabled=true;");
            FormResponse::add("\$('Form_AddPageOptionsForm').getElementsByTagName('div')[1].getElementsByTagName('input')[0].disabled=true;");
            FormResponse::add("\$('Translating_Message').innerHTML = 'Translating mode - " . i18n::get_language_name($lang) . "';");
            FormResponse::add("Element.removeClassName('Translating_Message','nonTranslating');");
        } else {
            Translatable::set_reading_lang($lang);
            FormResponse::add("\$('addpage').getElementsByTagName('button')[0].disabled=false;");
            FormResponse::add("\$('Form_AddPageOptionsForm').getElementsByTagName('div')[1].getElementsByTagName('input')[0].disabled=false;");
            FormResponse::add("Element.addClassName('Translating_Message','nonTranslating');");
        }
        $obj = singleton($this->stat('tree_class'));
        $obj->markPartialTree();
        $siteTree = $obj->getChildrenAsUL("", '
					"<li id=\\"record-$child->ID\\" class=\\"" . $child->CMSTreeClasses($extraArg) . "\\">" .
					"<a href=\\"" . Director::link(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\\" " . (($child->canEdit() || $child->canAddChildren()) ? "" : "class=\\"disabled\\"") . " title=\\"' . _t('LeftAndMain.PAGETYPE') . '".$child->class."\\" >" .
					(Convert::raw2js($child->TreeTitle())) .
					"</a>"
', $this, true);
        $rootLink = $this->Link() . '0';
        $siteTree = "<li id=\"record-0\" class=\"Root nodelete\"><a href=\"{$rootLink}\">" . _t('LeftAndMain.SITECONTENT') . "</a>" . $siteTree . "</li></ul>";
        FormResponse::add("\$('sitetree').innerHTML ='" . ereg_replace("[\n]", "\\\n", $siteTree) . "';");
        FormResponse::add("SiteTree.applyTo('#sitetree');");
        if (isset($notcreatedlist)) {
            foreach ($notcreatedlist as $notcreated) {
                if ($notcreated == $donotcreate) {
                    continue;
                }
                $id = "new-{$classesMap[$notcreated]}-0-{$notcreated}";
                Session::set($id . '_originalLangID', $notcreated);
                $treeTitle = Convert::raw2js($titlesMap[$notcreated]);
                $response = <<<JS
\t\t\t\t\tvar tree = \$('sitetree');
\t\t\t\t\tvar newNode = tree.createTreeNode("{$id}", "{$treeTitle}", "{$classesMap[$notcreated]} (untranslated)");
\t\t\t\t\taddClass(newNode, 'untranslated');
\t\t\t\t\tnode = tree.getTreeNodeByIdx(0);
\t\t\t\t\tnode.open();
\t\t\t\t\tnode.appendTreeNode(newNode);
JS;
                FormResponse::add($response);
            }
        }
        if (!isset($dontunloadPage)) {
            FormResponse::add("node = \$('sitetree').getTreeNodeByIdx(0); node.selectTreeNode();");
        }
        return FormResponse::respond();
    }
开发者ID:ramziammar,项目名称:websites,代码行数:69,代码来源:CMSMain.php


注:本文中的Translatable::set_reading_lang方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。