本文整理汇总了PHP中ilObjMediaObject::duplicate方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjMediaObject::duplicate方法的具体用法?PHP ilObjMediaObject::duplicate怎么用?PHP ilObjMediaObject::duplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjMediaObject
的用法示例。
在下文中一共展示了ilObjMediaObject::duplicate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newMobCopies
/**
* Replaces media objects with copies
*/
function newMobCopies($temp_dom)
{
// Get question IDs
$path = "//MediaObject/MediaAlias";
$xpc = xpath_new_context($temp_dom);
$res =& xpath_eval($xpc, $path);
$q_ids = array();
include_once "./Services/Link/classes/class.ilInternalLink.php";
for ($i = 0; $i < count($res->nodeset); $i++) {
$or_id = $res->nodeset[$i]->get_attribute("OriginId");
$inst_id = ilInternalLink::_extractInstOfTarget($or_id);
$mob_id = ilInternalLink::_extractObjIdOfTarget($or_id);
if (!($inst_id > 0)) {
if ($mob_id > 0) {
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$media_object = new ilObjMediaObject($mob_id);
// now copy this question and change reference to
// new question id
$new_mob = $media_object->duplicate();
$res->nodeset[$i]->set_attribute("OriginId", "il__mob_" . $new_mob->getId());
}
}
}
}
示例2: clonePool
/**
* Clones all data of a given room sharing pool to a new one.
*
* @param ilObjRoomSharing $a_pool
* @param ilObjRoomSharing $a_new_pool
*
* @return bool true if cloning was successful
*/
public static function clonePool(ilObjRoomSharing $a_pool, ilObjRoomSharing $a_new_pool)
{
// Pool main properties
$rooms_agreement_file_id = $a_pool->getRoomsAgreementFileId();
$cloned_rooms_agreement_file_id = "0";
if (ilRoomSharingNumericUtils::isPositiveNumber($rooms_agreement_file_id)) {
$rooms_agreement_file = new ilObjMediaObject($rooms_agreement_file_id);
$cloned_agreement_file = $rooms_agreement_file->duplicate();
$cloned_rooms_agreement_file_id = $cloned_agreement_file->getId();
}
$a_new_pool->setOnline($a_pool->isOnline());
$a_new_pool->setMaxBookTime($a_pool->getMaxBookTime());
$a_new_pool->setRoomsAgreementFileId($cloned_rooms_agreement_file_id);
$a_new_pool->update();
// Other database related information
$db = new ilRoomSharingDatabase($a_pool->getPoolId());
$clone_db = new ilRoomSharingDatabase($a_new_pool->getPoolId());
// Booking attributes
$all_booking_attributes = $db->getAllBookingAttributes();
foreach ($all_booking_attributes as $booking_attribute) {
$clone_db->insertBookingAttribute($booking_attribute['name']);
}
// Room attributes
$all_room_attributes = $db->getAllRoomAttributes();
$room_attrs_id_mapping = array();
foreach ($all_room_attributes as $room_attribute) {
$id_of_cloned_attribute = $clone_db->insertRoomAttribute($room_attribute['name']);
$room_attrs_id_mapping[$room_attribute['id']] = $id_of_cloned_attribute;
}
// Floorplans
$all_floorplan_ids = $db->getAllFloorplanIds();
// Key is original id and value the new one
$floorplans_ids_mapping = array();
foreach ($all_floorplan_ids as $floorplan_id) {
if (ilRoomSharingNumericUtils::isPositiveNumber($floorplan_id)) {
$floorplan = new ilObjMediaObject($floorplan_id);
$cloned_floorplan = $floorplan->duplicate();
$clone_db->insertFloorplan($cloned_floorplan->getId());
$floorplans_ids_mapping[$floorplan_id] = $cloned_floorplan->getId();
}
}
// Rooms
$all_rooms = $db->getAllRooms();
foreach ($all_rooms as $room) {
// Critical: should be the floorplan_id the building_id or the file_id?
// building_id is actually used..
$mapped_floorplan_id = $floorplans_ids_mapping[$room['file_id']];
$flooplan_id_to_set = "0";
if (ilRoomSharingNumericUtils::isPositiveNumber($mapped_floorplan_id)) {
$flooplan_id_to_set = $mapped_floorplan_id;
}
$cloned_room_id = $clone_db->insertRoom($room['name'], $room['type'], $room['min_alloc'], $room['max_alloc'], $flooplan_id_to_set, $room['building_id']);
// Room attribute assignments
$room_attributes = $db->getAttributesForRoom($room['id']);
foreach ($room_attributes as $room_attribute) {
$mapped_attr_id = $room_attrs_id_mapping[$room_attribute['id']];
if (ilRoomSharingNumericUtils::isPositiveNumber($mapped_attr_id)) {
$clone_db->insertAttributeForRoom($cloned_room_id, $mapped_attr_id, $room_attribute['count']);
}
}
}
// Privileges
$classes = $db->getClasses();
// Key is original id and value the new one
$mapped_classes_ids = array();
foreach ($classes as $class) {
$cloned_class_id = $clone_db->insertClass($class['name'], $class['description'], $class['role_id'], $class['priority'], $class['id']);
$mapped_classes_ids[$class['id']] = $cloned_class_id;
}
foreach ($mapped_classes_ids as $class_id => $cloned_class_id) {
$users_ids_for_class = $db->getUsersForClass($class_id);
foreach ($users_ids_for_class as $user_id) {
$clone_db->assignUserToClass($cloned_class_id, $user_id);
}
}
}
示例3: copyTreeContent
/**
* Copy tree content
*
* @param
* @return
*/
function copyTreeContent($a_new_obj, $a_target_parent, $a_source_parent)
{
include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php";
include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php";
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
// get all chapters of root lm
$nodes = $this->getTree()->getChilds($a_source_parent);
foreach ($nodes as $node) {
$item = new ilMediaPoolItem();
$item->setType($node["type"]);
switch ($node["type"]) {
case "mob":
$mob_id = ilMediaPoolItem::lookupForeignId($node["child"]);
$mob = new ilObjMediaObject($mob_id);
$new_mob = $mob->duplicate();
$item->setForeignId($new_mob->getId());
$item->setTitle($new_mob->getTitle());
$item->create();
break;
case "pg":
$item->setTitle($node["title"]);
$item->create();
$page = new ilMediaPoolPage($node["child"]);
$new_page = new ilMediaPoolPage();
$new_page->setId($item->getId());
$new_page->create();
// todo: make mobs being copied
$new_page->setXMLContent($page->copyXMLContent(true));
$new_page->buildDom();
$new_page->update();
break;
case "fold":
$item->setTitle($node["title"]);
$item->create();
break;
}
// insert item into tree
$a_new_obj->insertInTree($item->getId(), $a_target_parent);
// handle childs
$this->copyTreeContent($a_new_obj, $item->getId(), $node["child"]);
}
}
示例4: copyItems
/**
* Copy items
*
* @param
* @return
*/
function copyItems($a_new_obj)
{
global $ilUser;
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
foreach ($this->readItems(true) as $item) {
// copy media object
$mob_id = $item["mob_id"];
$mob = new ilObjMediaObject($mob_id);
$new_mob = $mob->duplicate();
// copy news item
// create new media cast item
include_once "./Services/News/classes/class.ilNewsItem.php";
$mc_item = new ilNewsItem();
$mc_item->setMobId($new_mob->getId());
$mc_item->setContentType(NEWS_AUDIO);
$mc_item->setContextObjId($a_new_obj->getId());
$mc_item->setContextObjType($a_new_obj->getType());
$mc_item->setUserId($ilUser->getId());
$mc_item->setPlaytime($item["playtime"]);
$mc_item->setTitle($item["title"]);
$mc_item->setContent($item["content"]);
$mc_item->setVisibility($item["visibility"]);
$mc_item->create();
}
}