/** * {@inheritdoc} */ public function implodeArrayAttribute(tubepress_api_media_MediaItem $item, $sourceAttributeName, $destinationAttributeName, $glue) { if (!$item->hasAttribute($sourceAttributeName)) { return; } $array = $item->getAttribute($sourceAttributeName); $formatted = implode($glue, $array); $item->setAttribute($destinationAttributeName, $formatted); }
public function __perPageSort(tubepress_api_media_MediaItem $first, tubepress_api_media_MediaItem $second) { $attributeName = self::$_perPageSortMap[$this->_perPageSortOrder]; if (!$first->hasAttribute($attributeName) || !$second->hasAttribute($attributeName)) { return 0; } $firstAttributeValue = $first->getAttribute($attributeName); $secondAttributeValue = $second->getAttribute($attributeName); switch ($this->_perPageSortOrder) { case tubepress_api_options_AcceptableValues::PER_PAGE_SORT_COMMENT_COUNT: case tubepress_api_options_AcceptableValues::PER_PAGE_SORT_NEWEST: case tubepress_api_options_AcceptableValues::PER_PAGE_SORT_DURATION: case tubepress_api_options_AcceptableValues::PER_PAGE_SORT_VIEW_COUNT: $firstAttributeValue = intval($firstAttributeValue); $secondAttributeValue = intval($secondAttributeValue); if ($firstAttributeValue == $secondAttributeValue) { return 0; } if ($firstAttributeValue < $secondAttributeValue) { return 1; } return -1; case tubepress_api_options_AcceptableValues::PER_PAGE_SORT_OLDEST: $firstAttributeValue = intval($firstAttributeValue); $secondAttributeValue = intval($secondAttributeValue); if ($firstAttributeValue == $secondAttributeValue) { return 0; } if ($firstAttributeValue < $secondAttributeValue) { return -1; } return 1; default: if ($firstAttributeValue == $secondAttributeValue) { return 0; } if ($firstAttributeValue < $secondAttributeValue) { return -1; } return 1; } }