本文整理匯總了PHP中myEntryUtils::deepClone方法的典型用法代碼示例。如果您正苦於以下問題:PHP myEntryUtils::deepClone方法的具體用法?PHP myEntryUtils::deepClone怎麽用?PHP myEntryUtils::deepClone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類myEntryUtils
的用法示例。
在下文中一共展示了myEntryUtils::deepClone方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: deepClone
public static function deepClone(kshow $source_kshow, &$new_entries)
{
$target_kshow = $source_kshow->copy();
// will have to save to retrieve the id from the DB.
$target_kshow->save();
$target_id = $target_kshow->getId();
echo "Creating new kshow {$target_id}\n";
$special_entries = array();
$special_entries[] = $source_kshow->getShowEntryId();
$special_entries[] = $source_kshow->getIntroId();
$skin = $source_kshow->getSkinObj();
///bg_entry_id=2171&bg_entry_path=/content/entry/data/0/2/2171_100000.jpg
$bg_entry_id = $skin->get("bg_entry_id");
$special_entries[] = $bg_entry_id;
echo "special entry_ids: " . print_r($special_entries, true);
// clone the show_entry and intro
$entries = entryPeer::retrieveByPKs($special_entries);
echo "special entries count " . count($entries) . "\n";
// it's hard to assume the order - if a PK was not found, there is no placeholder
foreach ($entries as $entry) {
$new_entry = myEntryUtils::deepClone($entry, $target_id, NULL);
$new_entries[] = $new_entry;
if ($entry->getId() == $source_kshow->getShowEntryId()) {
echo "ShowEntry:\n";
$target_kshow->setShowEntryId($new_entry->getId());
} elseif ($entry->getId() == $source_kshow->getIntroId()) {
echo "Intro:\n";
$target_kshow->setIntroId($new_entry->getId());
} elseif ($entry->getId() == $bg_entry_id) {
echo "Background:\n";
$skin->set("bg_entry_id", $new_entry->getId());
$skin->set("bg_entry_path", $new_entry->getDataPath());
// replaced__getDataPath
} else {
// ERROR !
}
}
$source_thumbnail_path = $source_kshow->getThumbnailPath();
$target_kshow->setThumbnail($source_kshow->getThumbnail());
$target_thumbnail_path = $target_kshow->getThumbnailPath();
// TODO - don't copy files if poiting to templates !
$content = myContentStorage::getFSContentRootPath();
// echo ( "Background - copying file: " . $content . $source_thumbnail_path . " -> " . $content . $target_thumbnail_path ."\n");
// myContentStorage::moveFile( $content . $source_thumbnail_path , $content . $target_thumbnail_path , false , true );
self::resetKshowStats($target_kshow);
$target_kshow->save();
$c = new Criteria();
$c->add(entryPeer::KSHOW_ID, $source_kshow->getId());
// don't clope the entries that were alredt cloned
$c->add(entryPeer::ID, $special_entries, Criteria::NOT_IN);
$entries = entryPeer::doSelect($c);
foreach ($entries as $entry) {
$new_entry = myEntryUtils::deepClone($entry, $target_id, NULL);
$new_entries[] = $new_entry;
}
echo "Ended creating new kshow {$target_id}. " . count($new_entries) . " entries copied\n";
return $target_kshow;
}
示例2: executeImpl
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
{
$entry_id = $this->getP("entry_id");
$kshow_id = $this->getP("kshow_id");
list($kshow, $entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $entry_id);
if ($error_obj) {
$this->addError($error_obj);
return;
}
$kshow_id = $kshow->getId();
if ($kshow_id === kshow::SANDBOX_ID) {
$this->addError(APIErrors::SANDBOX_ALERT);
return;
}
// TODO - think what is the best way to verify the privileges - names and parameters that are initially set by the partner at
// startsession time
if (!$this->isOwnedBy($kshow, $puser_kuser->getKuserId())) {
$this->verifyPrivileges("edit", $kshow_id);
}
// user was granted explicit permissions when initiatd the ks
// this part overhere should be in a more generic place - part of the services
$multiple_roghcuts = Partner::allowMultipleRoughcuts($partner_id);
$likuser_id = $puser_kuser->getKuserId();
$isIntro = $kshow->getIntroId() == $entry->getId();
if ($multiple_roghcuts) {
// create a new entry in two cases:
// 1. the user saving the roughcut isnt the owner of the entry
// 2. the entry is an intro and the current entry is not show (probably an image or video)
if ($entry->getKuserId() != $likuser_id || $isIntro && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW) {
// TODO: add security check to whether multiple roughcuts are allowed
// create a new roughcut entry by cloning the original entry
$entry = myEntryUtils::deepClone($entry, $kshow_id, false);
$entry->setKuserId($likuser_id);
$entry->setCreatorKuserId($puser_kuser->getKuserId());
$entry->setCreatedAt(time());
$entry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW);
$entry->save();
}
}
$xml_content = "<xml><EntryID>" . $entry->getId() . "</EntryID></xml>";
if ($isIntro) {
$kshow->setIntroId($entry->getId());
} else {
$kshow->setShowEntryId($entry->getId());
$has_roughcut = $this->getP("HasRoughCut", "1", true);
if ($has_roughcut === "0") {
$kshow->setHasRoughcut(false);
$kshow->save();
$this->addMsg("saved_entry", $entry->getId());
return;
}
}
$content = $this->getP("xml");
$update_kshow = false;
if ($content != NULL) {
$version_info = array();
$version_info["KuserId"] = $puser_kuser->getKuserId();
$version_info["PuserId"] = $puser_id;
$version_info["ScreenName"] = $puser_kuser->getPuserName();
list($xml_content, $comments, $update_kshow) = myMetadataUtils::setMetadata($content, $kshow, $entry, false, $version_info);
} else {
$comments = "";
// if there is no xml - receive it from the user
$this->debug = true;
return "text/html; charset=utf-8";
}
$this->addMsg("xml", $xml_content);
$this->addMsg("saved_entry", $entry->getId());
$this->addDebug("comment", $comments);
}
示例3: execute
public function execute()
{
$this->forceSystemAuthentication();
$source_kshow_id = $this->getP("source_kshow_id");
$target_kshow_id = $this->getP("target_kshow_id");
$kuser_names = $this->getP("kuser_names");
$reset = $this->getP("reset");
if ($reset) {
$source_kshow_id = null;
$target_kshow_id = null;
$kuser_names = null;
}
$mode = 0;
// view
if ($source_kshow_id && $target_kshow_id && $kuser_names) {
$mode = 1;
// review
$list_of_kuser_names = explode(",", $kuser_names);
foreach ($list_of_kuser_names as &$name) {
$name = trim($name);
}
$source_kshow = kshowPeer::retrieveByPK($source_kshow_id);
$target_kshow = kshowPeer::retrieveByPK($target_kshow_id);
$target_partner_id = $target_kshow->getPartnerId();
$target_subp_id = $target_kshow->getSubpId();
$c = new Criteria();
// select only the kusers of the correct partner_id
$c->add(kuserPeer::SCREEN_NAME, $list_of_kuser_names, Criteria::IN);
$c->setLimit(10);
//$c->add ( kuserPeer::PARTNER_ID , $target_partner_id );
$list_of_kusers = kuserPeer::doSelect($c);
$producer = kuserPeer::retrieveByPK($target_kshow->getProducerId());
$list_of_kusers[] = $producer;
$c->add(kuserPeer::PARTNER_ID, $target_partner_id);
$list_of_valid_kusers = kuserPeer::doSelect($c);
$list_of_valid_kusers[] = $producer;
$c = new Criteria();
$c->add(entryPeer::KSHOW_ID, $source_kshow_id);
$c->add(entryPeer::TYPE, entryType::MEDIA_CLIP);
$c->add(entryPeer::STATUS, entryStatus::READY);
$entries = entryPeer::doSelectJoinAll($c);
$entry_kusers = array();
// assign each entry to a kuser
foreach ($entries as $entry) {
$place_in_array = count($entry_kusers) % count($list_of_valid_kusers);
$kuser = $list_of_valid_kusers[$place_in_array];
$entry_kusers[$entry->getId()] = $kuser->getId();
}
$clone = $this->getP("clone");
if ($clone == 'true') {
$mode = 2;
// clone
$entry_id_map = array();
// will be used to map the source->target entries
$entry_cache = array();
// will be used to cache all relevat entries
$new_entry_list = array();
$failed_entry_list = array();
foreach ($entries as $entry) {
try {
$kuser_id = $entry_kusers[$entry->getId()];
$override_fields = $entry->copy();
$override_fields->setPartnerId($target_kshow->getPartnerId());
$override_fields->setSubpId($target_kshow->getSubpId());
$override_fields->setKuserId($kuser_id);
$override_fields->setCreatorKuserId($kuser_id);
$new_entry = myEntryUtils::deepClone($entry, $target_kshow_id, $override_fields, false);
$new_entry_list[] = $new_entry;
// will help fix the metadata entries
$entry_id_map[$entry->getId()] = $new_entry->getId();
$entry_cache[$entry->getId()] = $entry;
$entry_cache[$new_entry->getId()] = $new_entry;
} catch (Exception $ex) {
$failed_entry_list[] = $entry;
}
// echo "entry [{$entry->getId()}] copied<br>"; flush();
}
// now clone the show_entry
$new_show_entry = $target_kshow->getShowEntry();
myEntryUtils::deepCloneShowEntry($source_kshow->getShowEntry(), $new_show_entry, $entry_id_map, $entry_cache);
$new_entry_list[] = $new_show_entry;
$entries = $new_entry_list;
$entry_kusers = null;
}
// echo "ended!<bR>"; flush();
}
$this->source_kshow_id = @$source_kshow_id;
$this->target_kshow_id = @$target_kshow_id;
$this->partner_id = @$target_partner_id;
$this->source_kshow = @$source_kshow;
$this->target_kshow = @$target_kshow;
$this->kuser_names = @$kuser_names;
$this->list_of_kusers = @$list_of_kusers;
$this->entries = @$entries;
$this->mode = $mode;
$this->entry_kusers = @$entry_kusers;
// echo "going to template!<bR>"; flush();
}
示例4: executeImpl
/**
* Executes addComment action, which returns a form enabling the insertion of a comment
* The request may include 1 fields: entry id.
*/
protected function executeImpl(kshow $kshow, entry &$entry)
{
$kshow_id = $kshow->getId();
if ($this->partner_id != null) {
// this part overhere should be in a more generic place - part of the services
$multiple_roghcuts = Partner::allowMultipleRoughcuts($this->partner_id);
$likuser_id = $this->getLoggedInUserId();
} else {
// is the logged-in-user is not an admin or the producer - check if show can be published
$likuser_id = $this->getLoggedInUserId();
$multiple_roghcuts = true;
}
if (!$likuser_id) {
return $this->securityViolation($kshow->getId());
}
$isIntro = $kshow->getIntroId() == $entry->getId();
if ($multiple_roghcuts) {
// create a new entry in two cases:
// 1. the user saving the roughcut isnt the owner of the entry
// 2. the entry is an intro and the current entry is not show (probably an image or video)
if ($entry->getKuserId() != $likuser_id || $isIntro && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW) {
// TODO: add security check to whether multiple roughcuts are allowed
// create a new roughcut entry by cloning the original entry
$entry = myEntryUtils::deepClone($entry, $kshow_id, false);
$entry->setKuserId($likuser_id);
$entry->setCreatorKuserId($likuser_id);
$entry->setCreatedAt(time());
$entry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW);
$entry->save();
}
}
/*
$viewer_type = myKshowUtils::getViewerType($kshow, $likuser_id);
if ( $viewer_type != KshowKuser::KSHOWKUSER_VIEWER_PRODUCER && ( ! $kshow->getCanPublish() ) )
{
// ERROR - attempting to publish a non-publishable show
return $this->securityViolation( $kshow->getId() );
}
*/
$this->xml_content = "<xml><EntryID>" . $entry->getId() . "</EntryID></xml>";
if ($isIntro) {
$kshow->setIntroId($entry->getId());
} else {
$kshow->setShowEntryId($entry->getId());
$has_roughcut = @$_REQUEST["HasRoughCut"];
if ($has_roughcut === "0") {
$kshow->setHasRoughcut(false);
$kshow->save();
return;
}
}
$content = @$_REQUEST["xml"];
$update_kshow = false;
if ($content != NULL) {
list($xml_content, $this->comments, $update_kshow) = myMetadataUtils::setMetadata($content, $kshow, $entry);
// Send an email alert to producer
if ($kshow->getProducerId() != $likuser_id) {
// don't send producer alerts when the producer is the editor
alertPeer::sendEmailIfNeeded($kshow->getProducerId(), alert::KALTURAS_PRODUCED_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $this->getUser()->getAttribute('screenname'), 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId()));
}
// TODO: efficiency: see if there is a wa to search for contributors based on some other method than full entry table scan
// Send email alerts to contributors
$c = new Criteria();
$c->add(entryPeer::KSHOW_ID, $kshow_id);
$c->add(entryPeer::KUSER_ID, $likuser_id, Criteria::NOT_EQUAL);
// the current user knows they just edited
$c->addAnd(entryPeer::KUSER_ID, $kshow->getProducerId(), Criteria::NOT_EQUAL);
// the producer knows they just edited
$c->add(entryPeer::TYPE, entryType::MEDIA_CLIP);
$c->addGroupByColumn(entryPeer::KUSER_ID);
$entries = entryPeer::doSelect($c);
$already_received_alert_array = array();
foreach ($entries as $entry) {
alertPeer::sendEmailIfNeeded($entry->getKuserId(), alert::KALTURAS_PARTOF_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $this->getUser()->getAttribute('screenname'), 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId()));
$already_received_alert_array[$entry->getKuserId()] = true;
}
// send email alert to subscribers
$c = new Criteria();
$c->add(KshowKuserPeer::KSHOW_ID, $kshow_id);
//only subsribers of this show
$c->add(KshowKuserPeer::KUSER_ID, $likuser_id, Criteria::NOT_EQUAL);
// the current user knows they just edited
$c->add(KshowKuserPeer::SUBSCRIPTION_TYPE, KshowKuser::KSHOW_SUBSCRIPTION_NORMAL);
// this table stores other relations too
$subscriptions = KshowKuserPeer::doSelect($c);
foreach ($subscriptions as $subscription) {
if (!isset($already_received_alert_array[$subscription->getKuserId()])) {
// don't send emails to subscribed users who are also contributors
alertPeer::sendEmailIfNeeded($subscription->getKuserId(), alert::KALTURAS_SUBSCRIBEDTO_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $this->getUser()->getAttribute('screenname'), 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId()));
}
}
if ($this->debug) {
return "text/html; charset=utf-8";
}
} else {
$this->comments = "";
//.........這裏部分代碼省略.........