function display_picture($filename, $size = 'big', $target_size = null, $title = 'Click to display original image')
{
    $image_url = image_url($filename, $size);
    $target_image_url = image_url($filename, $target_size, true);
    $absolute_url = absolute_link($target_image_url, true);
    $image_options = empty($title) ? null : array('title' => $title, 'alt' => $title);
    return '<figure class="picture"><a title="' . __($title) . '" href="' . $absolute_url . '" itemprop="contentUrl">' . image_tag($image_url, $image_options) . '</a></figure><div class="picture_right"></div>';
}
$use_keys = in_array('keys', $format);
$text_html = in_array('html', $format);
$add_gpx_track = in_array('track', $format);
$add_all_fields = in_array('full', $format);
$add_conditions = $add_all_fields || in_array('cond', $format);
$add_text = !in_array('notext', $format);
if (!isset($items) && $nb_results > 0) {
    $items = $pager->getResults('array', ESC_RAW);
    $items = Language::parseListItems($items, c2cTools::module2model($module));
} elseif ($nb_results == 0) {
    $items = array();
    $totalItems = $startIndex = $count = $hasPreviousPage = $hasNextPage = 0;
}
if (isset($pager)) {
    $totalItems = $pager->getNbResults();
    $startIndex = $pager->getMaxPerPage() * ($pager->getPage() - 1) + 1;
    $count = min($pager->getMaxPerPage(), $pager->getNbResults() - ($pager->getPage() - 1) * $pager->getMaxPerPage());
    $hasPreviousPage = $pager->getPage() != 1;
    $hasNextPage = $pager->getPage() != $pager->getLastPage() && $nb_results;
}
// compute prev and next uris
if ($hasPreviousPage || $hasNextPage) {
    $uri = _addUrlParameters(_getBaseUri(), array('page'));
    $uri .= _getSeparator($uri) . 'page=';
}
$features = array();
foreach ($items as $item) {
    $features[] = json_decode(get_partial($module . '/jsonlist_body', array('item' => $item, 'use_keys' => $use_keys, 'text_html' => $text_html, 'add_gpx_track' => $add_gpx_track, 'add_conditions' => $add_conditions, 'add_all_fields' => $add_all_fields, 'add_text' => $add_text)));
}
echo json_encode(array('type' => 'FeatureCollection', 'metadata' => array('totalItems' => $totalItems, 'nbItems' => $count, 'startIndex' => $startIndex, 'currentPage' => sfContext::getInstance()->getRequest()->getUri(), 'nextPage' => $hasNextPage ? absolute_link(url_for($uri . $pager->getNextPage())) : null, 'previousPage' => $hasPreviousPage ? absolute_link(url_for($uri . $pager->getPreviousPage())) : null, 'baseLanguage' => __('meta_language'), 'generated' => date(DATE_RFC2822)), 'features' => $features), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
Example #3
0
    $pager_navigation = pager_navigation($pager);
    echo $pager_navigation;
    echo pager_nb_results($pager);
    echo '<div class="clearer"></div>';
    foreach ($items as $item) {
        ?>
    <div class="thumb_data">
    <div class="thumb_data_img">
    <?php 
        $i18n_item = $item['ImageI18n'][0];
        $title = $i18n_item['name'];
        $filename = $item['filename'];
        $image_type = $item['image_type'];
        $thumb_url = image_url($filename, 'small');
        $image_route = '@document_by_id_lang_slug?module=images&id=' . $item['id'] . '&lang=' . $i18n_item['culture'] . '&slug=' . make_slug($i18n_item['name']);
        echo link_to(image_tag($thumb_url, array('class' => 'img', 'alt' => $title)), $mobile_version ? $image_route : absolute_link(image_url($filename, 'big', true), true), array('title' => $title, 'data-lightbox' => 'document_images', 'class' => 'view_big', 'id' => 'lightbox_' . $item['id'] . '_' . $image_type));
        ?>
    <div class="image_license <?php 
        echo 'license_' . $image_type;
        ?>
"></div>
    </div>
    <?php 
        echo $title . '<br />';
        echo link_to(__('Details'), $image_route);
        if (!empty($item['nb_comments'])) {
            echo ' - ' . picto_tag('action_comment', __('nb_comments'), array('style' => 'margin-bottom:-4px')) . ' (' . link_to($item['nb_comments'], '@document_comment?module=images&id=' . $item['id'] . '&lang=' . $i18n_item['culture']) . ')';
        }
        ?>
    </div>
<?php 
Example #4
0
function absolute_link_to($name, $url = null, $html_options = null)
{
    $url = absolute_link($url);
    return link_to($name, $url, $html_options);
}
<?php

if (!isset($use_keys)) {
    $use_keys = false;
}
foreach ($parkings as $parking) {
    $i18n = $parking['ParkingI18n'][0];
    $url = $use_keys ? array() : array('url' => absolute_link(url_for('@document_by_id_lang_slug?module=parkings&id=' . $parking['id'] . '&lang=' . $i18n['culture'] . '&slug=' . make_slug($i18n['name']))));
    $a[] = array_merge(array('id' => $parking['id'], 'name' => $i18n->getRaw('name')), $url);
}
if (isset($a)) {
    krsort($a);
    echo json_encode(array_values($a));
} else {
    echo '[]';
}
function jsonlist_url($item, $module, $prefix = null)
{
    return absolute_link(url_for("@document_by_id_lang_slug?module={$module}&id=" . $item['id'] . '&lang=' . $item['culture'] . '&slug=' . make_slug(isset($prefix) ? $prefix . '-' . $item['name'] : $item['name'])));
}
    $caption = $image['name'];
    $slug = make_slug($image['name']);
    $lang = $image['culture'];
    $image_id = $image['id'];
    $image_type = $image['image_type'];
    $tag_attributes = array('alt' => $caption);
    foreach (array('width', 'height', 'file_size') as $prop) {
        if (isset($image[$prop]) && check_not_empty($image[$prop])) {
            $tag_attributes['data-' . $prop] = $image[$prop];
        }
    }
    $image_tag = image_tag(image_url($image['filename'], 'small'), $tag_attributes);
    $view_details = link_to('details', "@document_by_id_lang_slug?module=images&id={$image_id}&lang={$lang}&slug={$slug}", array('class' => 'view_details', 'title' => __('View image details')));
    $view_original = link_to('original', absolute_link(image_url($image['filename'], null, true), true), array('class' => 'view_original', 'title' => __('View original image')));
    $edit_image = link_to('edit', "@document_edit?module=images&id={$image_id}&lang={$lang}", array('class' => 'edit_image', 'title' => __('edit_tab_help')));
    if ($user_can_dissociate) {
        $type = c2cTools::Module2Letter($module_name) . 'i';
        $strict = (int) ($type == 'ii');
        $link = '@default?module=documents&action=removeAssociation&main_' . $type . '_id=' . $document_id . '&linked_id=' . $image_id . '&type=' . $type . '&strict=' . $strict . '&reload=1';
        $remove_association = link_to('unlink', $link, array('class' => 'unlink', 'confirm' => __("Are you sure you want to unlink image %1% named \"%2%\" ?", array('%1%' => $image_id, '%2%' => $caption)), 'title' => __('Unlink this association')));
    } else {
        $remove_association = '';
    }
    $view_big = link_to($image_tag, $mobile_version ? "@document_by_id_lang_slug?module=images&id={$image_id}&lang={$lang}&slug={$slug}" : absolute_link(image_url($image['filename'], 'big', true), true), array('title' => $caption, 'data-lightbox' => 'document_images', 'class' => 'view_big', 'id' => 'lightbox_' . $image_id . '_' . $image_type));
    echo '<div class="image" id="image_id_' . $image_id . '">' . $view_big;
    if (!$mobile_version) {
        echo '<div class="image_actions">' . $view_details . $view_original . $edit_image . $remove_association . '</div>';
    }
    echo '<div class="image_license license_' . $image_type . '"></div></div>';
}
echo '</div>';
Example #8
0
<?php

use_helper('Link', 'MyImage');
$feedItem = new sfGeoFeedItem();
$i18n = $item['ImageI18n'][0];
$feedItem->setTitle($i18n['name']);
$id = $item['id'];
$lang = $i18n['culture'];
$feedItem->setLink("@document_by_id_lang_slug?module=images&id={$id}&lang={$lang}&slug=" . make_slug($i18n['name']));
$feedItem->setUniqueId(sfRouting::getInstance()->getCurrentInternalUri() . '_' . $id);
$feedItem->setAuthorName($item['creator']);
$feedItem->setPubdate(strtotime($item['creation_date']));
$data = array();
$data[] = absolute_link(image_url($item['filename'], 'small', true), true);
$feedItem->setDescription(implode(' - ', $data));
$feedItem->setLongitude($item['lon']);
$feedItem->setLatitude($item['lat']);
$feed->addItem($feedItem);
<?php

if (!isset($use_keys)) {
    $use_keys = false;
}
$at = array('dc' => 'country', 'dd' => 'admin_limits', 'dr' => 'range', 'dv' => 'valley_area');
foreach ($geoassociations as $geo_id => $geoP) {
    $i18n = $geoP['AreaI18n'][0];
    $url = $use_keys ? array() : array('url' => absolute_link(url_for("@document_by_id_lang_slug?module=areas&id={$geo_id}&lang=" . $i18n['culture'] . '&slug=' . make_slug($i18n['name']))));
    $a[$geoP['type'] . $geo_id] = array_merge(array('id' => $geo_id, 'name' => $i18n->getRaw('name'), 'type' => $at[$geoP['type']]), $url);
}
if (isset($a)) {
    krsort($a);
    echo json_encode(array_values($a));
} else {
    echo '[]';
}