本文整理汇总了PHP中ViewableData::__set方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewableData::__set方法的具体用法?PHP ViewableData::__set怎么用?PHP ViewableData::__set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewableData
的用法示例。
在下文中一共展示了ViewableData::__set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: translate
public function translate(SS_HTTPRequest $request)
{
$locales = "";
if (SiteTree::has_extension("Translatable")) {
$locales = Translatable::get_allowed_locales();
} else {
$locales = array("it_IT");
}
$locales_list = new ArrayList();
foreach ($locales as $key => $value) {
$obj = new ViewableData();
$obj->__set("Locale", $value);
$obj->__set("LocaleName", i18n::get_locale_name($value));
$obj->__set("Lang", i18n::get_lang_from_locale($value));
$locales_list->push($obj);
}
if ($request->isAjax()) {
if (isset($_POST["collect"])) {
foreach ($locales as $value) {
$c = new TextCollector($value);
$c->run(LanguageAdmin::$modules, true);
}
die(_t("SUCCESSFULL_COLLECT", "The text was collected."));
}
if (isset($_POST["save"])) {
$lang_array[$_POST["locale"]] = $_POST[$_POST["locale"]];
$file = $_POST["file"];
$yml_file = sfYaml::dump($lang_array);
if ($fh = fopen($file, "w")) {
fwrite($fh, $yml_file);
fclose($fh);
file_get_contents("http://{$_SERVER['HTTP_HOST']}?flush");
} else {
throw new LogicException("Cannot write language file! Please check permissions of {$langFile}");
}
die;
}
$files = $this->getFiles();
if (isset($_POST["loadfiles"])) {
// die($this->getYaml($_POST["loadfiles"]));
$this->customise(array("Translations" => $this->getYaml($_POST["loadfiles"]), "Modules" => $files, "Locales" => $locales_list));
$content = $this->renderWith('LanguageAdmin_Content');
return $content;
} else {
$this->customise(array("Modules" => $files, "Translations" => $this->getYaml($files->filter(array('Locale' => $locales_list->first()->Locale))->first()->Path), "Locales" => $locales_list, "CurrentLocale" => $locales_list->first()->LocaleName));
$content = $this->renderWith('LanguageAdmin_Content');
return $content;
}
} else {
$files = $this->getFiles();
$this->customise(array("Modules" => $files, "Translations" => $this->getYaml($files->filter(array('Locale' => $locales_list->first()->Locale))->first()->Path), "Locales" => $locales_list, "CurrentLocale" => $locales_list->first()->LocaleName));
$content = $this->renderWith($this->getViewer('translate'));
return $content;
}
}