/**
 * @file views/default/views_counter/entity_listing_view.php
 * @brief Displays a entity in the context of views_counter plugin
 */
?>
<tr>
	<td class="guid_column align_center"><?php 
echo $vars['entity']->guid;
?>
</td>
	<td class="title_column align_center">
		<?php 
$name = $vars['entity']->name ? $vars['entity']->name : $vars['entity']->title;
?>
		<a href="<?php 
echo $vars['url'];
?>
views_counter/views_statistics/<?php 
echo $vars['entity']->guid;
?>
"><?php 
echo $name;
?>
</a>
	</td>
	<td class="counter_column align_center"><?php 
echo get_views_counter($vars['entity']->guid);
?>
</td>
</tr>
Esempio n. 2
0
/**
 * A hook that may be used by other plugins that want to get the number of views for an entity
 * 
 * @param $hook
 * @param $type
 * @param $returnvalue
 * @param $params
 */
function get_views_counter_hook($hook, $type, $returnvalue, $params)
{
    if ($params['entity']) {
        // We get the entity as a hook params instead of the entity_guid just for follow the elgg pattern of pass the entity instead of the entity_guid
        return get_views_counter($params['entity']->guid, $params['owner_guid']);
    }
}
        ?>
			<span id="views_counter" <?php 
        echo $style;
        ?>
 class="<?php 
        echo $class;
        ?>
">
			<?php 
        if (elgg_is_admin_logged_in()) {
            ?>
					<a href="<?php 
            echo $vars['url'];
            ?>
views_counter/views_statistics/<?php 
            echo $entity_guid;
            ?>
">
			<?php 
        }
        echo get_views_counter($vars['entity']->guid) . ' ' . elgg_echo('views_counter:views');
        if (elgg_is_admin_logged_in()) {
            ?>
					</a>
			<?php 
        }
        ?>
			</span>
<?php 
    }
}
namespace AU\ViewsCounter;

$entity_guid = $vars['entity'] ? $vars['entity']->guid : $vars['entity_guid'];
$entity = get_entity($entity_guid);
if (!$entity || !$vars['full_view'] && !$vars['views_counter_full_view_override']) {
    return;
}
if (elgg_get_config('views_counter_' . $entity_guid)) {
    return;
    // we've already rendered this once this page
}
elgg_set_config('views_counter_' . $entity_guid, true);
$target = elgg_get_plugin_setting('views_counter_container_id', PLUGIN_ID);
$display = elgg_get_plugin_setting('display_views_counter', PLUGIN_ID);
$classes = array('views-counter-container');
$classes[] = get_views_counter_class();
if ($target || $display == 'no') {
    $classes[] = 'hidden';
}
$classes = array_unique($classes);
$classes = array_map('trim', $classes);
$span_attr = array('class' => implode(' ', $classes), 'data-guid' => $entity->guid, 'data-target' => $target);
$content = get_views_counter($entity_guid) . ' ' . elgg_echo('views_counter:views');
if (elgg_is_admin_logged_in()) {
    $content = elgg_view('output/url', array('text' => $content, 'href' => 'admin/views_counter/stats?guid=' . $entity_guid));
}
echo '<span ' . elgg_format_attributes($span_attr) . '>' . $content . '</span>';
// Include the js code for views counter
//echo elgg_view('js/views_counter',$vars);
elgg_require_js('views_counter');