本文整理汇总了PHP中Media::Entries方法的典型用法代码示例。如果您正苦于以下问题:PHP Media::Entries方法的具体用法?PHP Media::Entries怎么用?PHP Media::Entries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Media
的用法示例。
在下文中一共展示了Media::Entries方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ValidateMediaXml
/**
* Validate the Media XML Provided
* @param $xmlDoc DOMDocument The Media XML
* @return bool
*/
protected function ValidateMediaXml($xmlDoc)
{
Debug::LogEntry('audit', 'Validating provided XLF', 'module', 'ValidateMediaXml');
// Compare the XML we have been given, with the XML of the existing media item OR compare as a new item
$mediaNodes = $xmlDoc->getElementsByTagName('media');
if ($mediaNodes->length > 1) {
return $this->SetError(__('Too many media nodes'));
}
$mediaNode = $mediaNodes->item(0);
// Do some basic checks regardless of whether it is an add or edit
// Check the schema version
if ($mediaNode->getAttribute('schemaVersion') != $this->schemaVersion) {
return $this->SetError(__('SchemaVersion does not match'));
}
// Check the type
if ($mediaNode->getAttribute('type') != $this->type) {
return $this->SetError(__('Media Type does not match'));
}
// Do we have a new item or an existing item
if ($this->assignedMedia) {
// An existing item
Debug::LogEntry('audit', 'An existing media entry', 'module', 'ValidateMediaXml');
// Check the ID
if ($mediaNode->getAttribute('id') != $this->mediaid) {
return $this->SetError(sprintf(__('ID does not match [%s vs %s]'), $mediaNode->getAttribute('id'), $this->mediaid));
}
// Check that the "owner" userId on the media item has not changed
if ($mediaNode->getAttribute('userId') != $this->originalUserId) {
return $this->SetError(__('UserId does not match'));
}
} else {
// A new item
Debug::LogEntry('audit', 'A new media entry', 'module', 'ValidateMediaXml');
// New media items may not have a media id on them (region media is born without an ID)
if ($this->regionSpecific == 1) {
// Create a new media id and set it on this object
$this->mediaid = md5(uniqid());
$mediaNode->setAttribute('id', $this->mediaid);
} else {
// This is library media that we want to assign or update
// We need to check that the mediaId exists and if so, store the mediaId on this media object
$mediaIdInXlf = $mediaNode->getAttribute('id');
$entries = Media::Entries(null, array('mediaId' => $mediaIdInXlf));
if (count($entries) <= 0) {
return $this->SetError(__(sprintf('MediaId %s provided in XLF does not exist.', $mediaIdInXlf)));
} else {
$this->mediaid = $mediaIdInXlf;
}
}
// The user ID should be that of the new user
$this->originalUserId = $this->user->userid;
}
// Check we have some core attributes (and set them on the media object - this gives us the new values to save)
// (we have already validated that the media id and the type are the same, we dont need to check them again)
$this->duration = $mediaNode->getAttribute('duration');
if ($this->duration == '' || !is_numeric($this->duration)) {
return $this->SetError(__('Duration not provided or not a number'));
}
if ($this->duration < 0) {
return $this->SetError(__('Cannot be less than zero'));
}
// The "core" items appear to be ok
return true;
}
示例2: LayoutRegionMediaDelete
/**
* Delete media from a region
* @return <XiboAPIResponse>
*/
public function LayoutRegionMediaDelete()
{
if (!$this->user->PageAuth('layout')) {
return $this->Error(1, 'Access Denied');
}
$layoutId = $this->GetParam('layoutId', _INT);
$regionId = $this->GetParam('regionId', _STRING);
$mediaId = $this->GetParam('mediaId', _STRING);
$lkId = $this->GetParam('lkId', _INT);
// Does the user have permissions to view this region?
if (!$this->user->LayoutAuth($layoutId)) {
return $this->Error(1, 'Access Denied');
}
// Check the user has permission
Kit::ClassLoader('region');
$region = new region();
$ownerId = $region->GetOwnerId($layoutId, $regionId);
$regionAuth = $this->user->RegionAssignmentAuth($ownerId, $layoutId, $regionId, true);
if (!$regionAuth->edit) {
return $this->Error(1, 'Access Denied');
}
// Load the media information from the provided ids
// Get the type from this media
$entry = Media::Entries(null, array('mediaId' => $mediaId));
if (count($entry) <= 0) {
return $this->SetError(__('Error getting type from a media item.'));
}
// Create a module
try {
$module = ModuleFactory::load($entry[0]->mediaType, $layoutId, $regionId, $mediaId, $lkId, null, $this->user);
} catch (Exception $e) {
return $this->Error($e->getMessage());
}
if (!$module->auth->del) {
return $this->Error(1, 'Access Denied');
}
// Delete the assignment from the region
if (!$module->ApiDeleteRegionMedia($layoutId, $regionId, $mediaId)) {
return $this->Error($module->errorMessage);
}
return $this->Respond($this->ReturnId('success', true));
}
示例3: parseLibraryReferences
/**
* Parse for any library references
* @param $isPreview bool
* @param $content string
* @return mixed The Parsed Content
*/
private function parseLibraryReferences($isPreview, $content)
{
$parsedContent = $content;
$matches = '';
preg_match_all('/\\[.*?\\]/', $content, $matches);
foreach ($matches[0] as $sub) {
// Parse out the mediaId
$mediaId = str_replace(']', '', str_replace('[', '', $sub));
// Only proceed if the content is actually an ID
if (!is_numeric($mediaId)) {
continue;
}
// Check that this mediaId exists and get some information about it
$entry = Media::Entries(null, array('mediaId' => $mediaId));
if (count($entry) <= 0) {
continue;
}
// We have a valid mediaId to substitute
$replace = $isPreview ? 'index.php?p=module&mod=image&q=Exec&method=GetResource&mediaid=' . $entry[0]->mediaId : $entry[0]->storedAs;
// Substitute the replacement we have found (it might be '')
$parsedContent = str_replace($sub, $replace, $parsedContent);
}
return $parsedContent;
}
示例4: deleteAllForUser
/**
* Delete all Media for a User
* @param int $userId
* @return bool
*/
public function deleteAllForUser($userId)
{
$media = Media::Entries(null, array('ownerid' => $userId));
foreach ($media as $item) {
/* @var Media $item */
if (!$item->Delete($item->mediaId)) {
return $this->SetError($item->GetErrorMessage());
}
}
return true;
}
示例5: MediaList
/**
* Returns an array of Media the current user has access to
*/
public function MediaList($sort_order = array('name'), $filter_by = array())
{
try {
$media = Media::Entries($sort_order, $filter_by);
$parsedMedia = array();
foreach ($media as $row) {
$mediaItem = array();
// Validate each param and add it to the array.
$mediaItem['mediaid'] = $row->mediaId;
$mediaItem['media'] = $row->name;
$mediaItem['mediatype'] = $row->mediaType;
$mediaItem['duration'] = $row->duration;
$mediaItem['ownerid'] = $row->ownerId;
$mediaItem['filesize'] = $row->fileSize;
$mediaItem['parentid'] = $row->parentId;
$mediaItem['filename'] = $row->fileName;
$mediaItem['tags'] = $row->tags;
$mediaItem['storedas'] = $row->storedAs;
$auth = $this->MediaAuth($row->mediaId, true, $row->ownerId);
if ($auth->view) {
$mediaItem['view'] = (int) $auth->view;
$mediaItem['edit'] = (int) $auth->edit;
$mediaItem['del'] = (int) $auth->del;
$mediaItem['modifyPermissions'] = (int) $auth->modifyPermissions;
$parsedMedia[] = $mediaItem;
}
}
return $parsedMedia;
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
return false;
}
}