本文整理汇总了PHP中Phrase::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Phrase::factory方法的具体用法?PHP Phrase::factory怎么用?PHP Phrase::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phrase
的用法示例。
在下文中一共展示了Phrase::factory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_default
public static function get_default($phrase, $filter)
{
$default = Phrase::factory()->where("phrase", $phrase)->where("filter", $filter)->where_related_language(Language::get_default())->get();
if (!$default->exists()) {
$default->phrase = $default->translation = $phrase;
$default->filter = $filter;
$default->save(array(Language::get_default()));
}
return $default;
}
示例2: phrase
public function phrase($phrase, $filter)
{
$tr = $this->get_translation($phrase, $filter);
//var_dump($tr);
//die;
if ($tr) {
return $tr;
} else {
//save for curr. language
if ($this->language->id != Language::get_default()->id) {
$newphr = Phrase::factory()->where('phrase', $phrase)->where_related_language($this->language)->limit(1)->get();
$newphr->phrase = $phrase;
$newphr->filter = $filter;
$newphr->save($this->language);
}
//return default
return Phrase::get_default($phrase, $filter)->translation;
}
/* $phrase_obj = Phrase::factory()
->where("phrase", $phrase)
->where("filter", $filter)
->where_related_language($this->language)
->get();
if ($phrase_obj->exists())
{
if (trim($phrase_obj->translation) != "")
return $phrase_obj->translation;
else
return Phrase::get_default($phrase, $filter)->translation;
}
else
{
//save for curr. language
if ($this->language->id != Language::get_default()->id)
{
$newphr = new Phrase();
$newphr->phrase = $phrase;
$newphr->filter = $filter;
$newphr->save($this->language);
}
//return default
return Phrase::get_default($phrase, $filter)->translation;
}//*/
}
示例3: phrases
public function phrases($lng, $all = false)
{
$lng = (int) $lng;
$lang = Language::factory()->get_by_id($lng);
$groups = array();
$filters = Phrase::factory()->distinct()->select('filter')->get();
$i = 0;
foreach ($filters as $filter) {
$groups[$i]['name'] = $filter->filter;
$groups[$i]['phrases'] = Phrase::factory()->where('filter', $filter->filter)->where_related_language($lang)->order_by('translation')->get();
$i++;
}
$this->templatemanager->assign("groups", $groups);
//$this->templatemanager->assign("total", count($phrases->all));
$this->templatemanager->assign("language", $lang);
$this->templatemanager->assign("filters", $filters);
$this->templatemanager->show_template("translations_phrases");
}