本文整理汇总了PHP中Translatable::creating_from方法的典型用法代码示例。如果您正苦于以下问题:PHP Translatable::creating_from方法的具体用法?PHP Translatable::creating_from怎么用?PHP Translatable::creating_from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translatable
的用法示例。
在下文中一共展示了Translatable::creating_from方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNewItem
public function getNewItem($id, $setID = true)
{
list($dummy, $className, $parentID, $suffix) = explode('-', $id);
if (!Translatable::is_default_lang()) {
$originalItem = Translatable::get_original($className, Session::get("{$id}_originalLangID"));
if ($setID) {
$originalItem->ID = $id;
} else {
$originalItem->ID = null;
Translatable::creating_from(Session::get($id . '_originalLangID'));
}
return $originalItem;
}
$newItem = new $className();
if (!$suffix) {
$sessionTag = "NewItems." . $parentID . "." . $className;
if (Session::get($sessionTag)) {
$suffix = '-' . Session::get($sessionTag);
Session::set($sessionTag, Session::get($sessionTag) + 1);
} else {
Session::set($sessionTag, 1);
}
$id = $id . $suffix;
}
$newItem->Title = _t('CMSMain.NEW', "New ", PR_MEDIUM, '"New " followed by a className') . $className;
$newItem->URLSegment = "new-" . strtolower($className);
$newItem->ClassName = $className;
$newItem->ParentID = $parentID;
// DataObject::fieldExists only checks the current class, not the hierarchy
// This allows the CMS to set the correct sort value
if ($newItem->castingHelperPair('Sort')) {
$newItem->Sort = DB::query("SELECT MAX(Sort) FROM SiteTree WHERE ParentID = '" . Convert::raw2sql($parentID) . "'")->value() + 1;
}
if (Member::currentUser()) {
$newItem->OwnerID = Member::currentUser()->ID;
}
if ($setID) {
$newItem->ID = $id;
}
# Some modules like subsites add extra fields that need to be set when the new item is created
$this->extend('augmentNewSiteTreeItem', $newItem);
return $newItem;
}