public function getSphinxFieldType($fieldName) { $sphinxTypes = CuePoint::getIndexFieldTypes(); if (!isset($sphinxTypes[$fieldName])) { return null; } return $sphinxTypes[$fieldName]; }
public function copyToEntry($entry, PropelPDO $con = null) { $annotation = parent::copyToEntry($entry); if ($annotation->getParentId()) { $mappedId = kObjectCopyHandler::getMappedId('Annotation', $annotation->getParentId()); if ($mappedId) { $annotation->setParentId($mappedId); } } $annotation->save(); return $annotation; }
public function postInsert(PropelPDO $con = null) { parent::postInsert($con); $userEntry = UserEntryPeer::retrieveByPK($this->getQuizUserEntryId()); if (!is_null($userEntry)) { $userEntry->addAnswerId($this->parent_id, $this->id); $userEntry->save(); } }
/** * Code to be run before updating the object in database * @param PropelPDO $con * @return bloolean */ public function preUpdate(PropelPDO $con = null) { if ($this->isCustomDataModified(AnswerCuePoint::CUSTOM_DATA_ANSWER_KEY)) { $this->setIsCorrect(in_array($this->getAnswerKey(), $this->getCorrectAnswerKeys())); } return parent::preSave($con); }
protected function reIndexCuePointEntry(CuePoint $cuePoint) { //index the entry after the cue point was added|deleted $entryId = $cuePoint->getEntryId(); $entry = entryPeer::retrieveByPK($entryId); if ($entry) { $entry->setUpdatedAt(time()); $entry->save(); $entry->indexToSearchIndex(); } }
public static function generateXml(CuePoint $cuePoint, SimpleXMLElement $scenes, SimpleXMLElement $scene = null) { if (is_null($scene) || $scene->getName() != 'scene-annotation' || !$cuePoint instanceof Annotation) { return $scene; } $objectType = self::getMetadataObjectTypeCoreValue(AnnotationMetadataObjectType::ANNOTATION); return CuePointMetadataPlugin::generateCuePointXml($scene, $objectType, $cuePoint->getId()); }
public function validateEndTime(CuePoint $cuePoint = null) { if (is_null($this->startTime) && $cuePoint && $cuePoint->getStartTime()) { $this->startTime = $cuePoint->getStartTime(); } if (is_null($this->triggeredAt) && $cuePoint && $cuePoint->getTriggeredAt()) { $this->triggeredAt = $cuePoint->getTriggeredAt(); } if ($this->startTime) { if ($this->isNull('endTime') && (!$cuePoint || is_null($cuePoint->getEndTime()))) { $this->endTime = $this->startTime; } if (!is_null($this->endTime) && $this->endTime < $this->startTime) { throw new KalturaAPIException(KalturaCuePointErrors::END_TIME_CANNOT_BE_LESS_THAN_START_TIME, $this->parentId); } } elseif ($this->triggeredAt) { if ($this->isNull('duration') && (!$cuePoint || is_null($cuePoint->getDuration()))) { $this->duration = 0; } if ($this->duration && $this->duration < 0) { throw new KalturaAPIException(KalturaCuePointErrors::END_TIME_CANNOT_BE_LESS_THAN_START_TIME, $this->parentId); } } else { if (!$this->isNull('duration') || !$this->isNull('endTime')) { throw new KalturaAPIException(KalturaCuePointErrors::END_TIME_WITHOUT_START_TIME); } } if ($cuePoint) { $dbEntry = entryPeer::retrieveByPK($cuePoint->getEntryId()); } else { $dbEntry = entryPeer::retrieveByPK($this->entryId); } if (!$dbEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $this->entryId); } if ($dbEntry->getType() != entryType::LIVE_STREAM && $dbEntry->getLengthInMsecs()) { if ($this->endTime && $dbEntry->getLengthInMsecs() < $this->endTime) { throw new KalturaAPIException(KalturaCuePointErrors::END_TIME_IS_BIGGER_THAN_ENTRY_END_TIME, $this->endTime, $dbEntry->getLengthInMsecs()); } if ($this->duration && $dbEntry->getLengthInMsecs() < $this->duration) { throw new KalturaAPIException(KalturaCuePointErrors::END_TIME_IS_BIGGER_THAN_ENTRY_END_TIME, $this->duration, $dbEntry->getLengthInMsecs()); } } }
public function __construct() { parent::__construct(); $this->applyDefaultValues(); }
public static function parseXml($objectType, SimpleXMLElement $scene, $partnerId, CuePoint $cuePoint) { $metadataElements = $scene->xpath('scene-customData'); if (!count($metadataElements)) { return $cuePoint; } foreach ($metadataElements as $metadataElement) { $metadata = null; $metadataProfile = null; if (isset($metadataElement['metadataId'])) { $metadata = MetadataPeer::retrieveByPK($metadataElement['metadataId']); } if ($metadata) { $metadataProfile = $metadata->getMetadataProfile(); } else { if (isset($metadataElement['metadataProfileId'])) { $metadataProfile = MetadataProfilePeer::retrieveByPK($metadataElement['metadataProfileId']); } elseif (isset($metadataElement['metadataProfile'])) { $metadataProfile = MetadataProfilePeer::retrieveBySystemName($metadataElement['metadataProfile']); } if ($metadataProfile) { $metadata = MetadataPeer::retrieveByObject($metadataProfile->getId(), $objectType, $cuePoint->getId()); } } if (!$metadataProfile) { continue; } if (!$metadata) { $metadata = new Metadata(); $metadata->setPartnerId($partnerId); $metadata->setMetadataProfileId($metadataProfile->getId()); $metadata->setMetadataProfileVersion($metadataProfile->getVersion()); $metadata->setObjectType($objectType); $metadata->setObjectId($cuePoint->getId()); $metadata->setStatus(KalturaMetadataStatus::VALID); foreach ($metadataElement->children() as $metadataContent) { $xmlData = $metadataContent->asXML(); $errorMessage = ''; if (kMetadataManager::validateMetadata($metadataProfile->getId(), $xmlData, $errorMessage)) { $metadata->save(); $key = $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); kFileSyncUtils::file_put_contents($key, $xmlData); kEventsManager::raiseEvent(new kObjectDataChangedEvent($metadata)); } break; } } } return $cuePoint; }
public function preInsert(PropelPDO $con = null) { $subType = $this->getSubType(); if (!isset($subType)) { $this->setSubType(ThumbCuePointSubType::SLIDE); } if ($this->getSubType() == ThumbCuePointSubType::SLIDE) { $this->setStatus(CuePointStatus::PENDING); } return parent::preInsert($con); }
public static function generateXml(CuePoint $cuePoint, SimpleXMLElement $scenes, SimpleXMLElement $scene = null) { if (is_null($scene) || $scene->getName() != 'scene-ad-cue-point' || !$cuePoint instanceof AdCuePoint) { return $scene; } $objectType = self::getMetadataObjectTypeCoreValue(AdCuePointMetadataObjectType::AD_CUE_POINT); return CuePointMetadataPlugin::generateCuePointXml($scene, $objectType, $cuePoint->getId()); }
/** * @param CuePoint $cuePoint * @param SimpleXMLElement $scene * @return SimpleXMLElement the created scene */ public static function syndicateCuePointXml(CuePoint $cuePoint, SimpleXMLElement $scene) { $scene->addAttribute('sceneId', $cuePoint->getId()); if ($cuePoint->getSystemName()) { $scene->addAttribute('systemName', kMrssManager::stringToSafeXml($cuePoint->getSystemName())); } $scene->addChild('sceneStartTime', kXml::integerToTime($cuePoint->getStartTime())); $scene->addChild('createdAt', $cuePoint->getCreatedAt(kMrssManager::FORMAT_DATETIME)); $scene->addChild('updatedAt', $cuePoint->getCreatedAt(kMrssManager::FORMAT_DATETIME)); if ($cuePoint->getPuserId()) { $scene->addChild('userId', kMrssManager::stringToSafeXml($cuePoint->getPuserId())); } if (trim($cuePoint->getTags(), " \r\n\t")) { $tags = $scene->addChild('tags'); foreach (explode(',', $cuePoint->getTags()) as $tag) { $tags->addChild('tag', kMrssManager::stringToSafeXml($tag)); } } return $scene; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param CuePoint $value A CuePoint object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(CuePoint $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param CuePoint $value A CuePoint object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(CuePoint $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) { self::$instances[$key] = $obj; kMemoryManager::registerPeer('CuePointPeer'); } } }