예제 #1
0
/**
 * Elgg News plugin
 * @package amapnews
 */
elgg_load_library('elgg:amapnews');
$ignore_access = elgg_extract('ia', $vars, '');
if ($ignore_access) {
    // set ignore access for loading non public objexts
    $ia = elgg_get_ignore_access();
    elgg_set_ignore_access(true);
}
$guid = elgg_extract('guid', $vars, '');
$entity = get_entity($guid);
// Get the size
$size = strtolower(elgg_extract('size', $vars, ''));
$size = amapnews_getIconSize($size);
// If entity doesn't exist, return default icon
if (!$entity) {
    $url = elgg_get_simplecache_url("icons/default/{$size}.png");
    forward($url);
}
// Try and get the icon
$filehandler = new ElggFile();
$filehandler->owner_guid = $entity->owner_guid;
$filehandler->setFilename($entity->getSubtype() . "/" . $entity->guid . $size . ".jpg");
$success = false;
try {
    if ($filehandler->open("read")) {
        $contents = $filehandler->read($filehandler->getSize());
        if ($contents) {
            $success = true;
예제 #2
0
/**
 * Get entity icon URL
 * 
 * @param type $entity_guid
 * @param type $size
 * @param boolean $ignore_access: if is true, news photo will be displayed in walled garden sites
 * @return boolean
 */
function amapnews_getEntityIconUrl($entity_guid, $size = 'master', $ignore_access = false)
{
    $entity = get_entity($entity_guid);
    if (!elgg_instanceof($entity)) {
        return false;
    }
    // Get the size
    $size = amapnews_getIconSize($size);
    $icon_time = $entity->time_updated;
    $icon_url = "amapnews/photo_view/{$entity->guid}/{$size}/{$icon_time}" . ($ignore_access ? '/' . $ignore_access : '');
    return elgg_normalize_url($icon_url);
}