예제 #1
0
<?php

/**
 * View that can be used to generate previews URLs contained within a text
 *
 * @uses $vars['value']  STR Text to analyze
 * @uses $vars['limit']  INT Max number of links to display. 0 for no limit
 * @uses $vars['params'] ARR Params to pass to the embed view
 */
$value = elgg_extract('value', $vars, '');
$limit = elgg_extract('limit', $vars, 0);
$params = elgg_extract('params', $vars, array());
$i = 0;
$tokens = hypeapps_extract_tokens($value);
$urls = elgg_extract('urls', $tokens, []);
if (empty($urls)) {
    return;
}
foreach ($urls as $url) {
    if ($limit > 0 && $i >= $limit) {
        continue;
    }
    $params['href'] = $url;
    echo elgg_view('output/card', $params);
    $i++;
}
예제 #2
0
 /**
  * Extract qualifiers such as hashtags, usernames, urls, and emails
  *
  * @param string $hook   Equals 'extract:qualifiers'
  * @param string $type   Equals 'scraper'
  * @param array  $return Qualifiers
  * @param array  $params Hook params
  * @return array
  */
 public static function extractTokens($hook, $type, $return, $params)
 {
     $source = elgg_extract('source', $params);
     return hypeapps_extract_tokens($source);
 }