Пример #1
0
Файл: Router.php Проект: n8b/VMN
 /**
  * Returns page handler ID
  * @return string
  */
 public function getPageHandlerId()
 {
     return hypeScraper()->config->get('pagehandler_id', 'categories');
 }
Пример #2
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;
$urls = hypeScraper()->extractor->urls($value);
if (!empty($urls)) {
    foreach ($urls as $url) {
        if ($limit > 0 && $i >= $limit) {
            continue;
        }
        $params['href'] = $url;
        echo elgg_view('output/card', $params);
        $i++;
    }
}
Пример #3
0
 /**
  * Wall post export
  *
  * @param string   $hook   "to:object"
  * @param string   $type   "entity"
  * @param stdClass $return Export object
  * @param array    $params Hook params
  * @return stdClass
  */
 public function exportWall($hook, $type, $return, $params)
 {
     if (!elgg_in_context('graph')) {
         return $return;
     }
     $entity = elgg_extract('entity', $params);
     /* @var $entity \hypeJunction\Wall\Post */
     if (!$entity instanceof ElggObject || $entity->getSubtype() !== \hypeJunction\Wall\Post::SUBTYPE) {
         return $return;
     }
     $allowed = $this->getFields($entity);
     $fields = get_input('fields') ?: $allowed;
     if (is_string($fields)) {
         $fields = string_to_tag_array($fields);
     }
     foreach ($fields as $key) {
         switch ($key) {
             case 'attachments':
                 $return->attachments = array();
                 $attachments = new \ElggBatch('elgg_get_entities_from_relationship', array('types' => 'object', 'subtypes' => get_registered_entity_types('object'), 'relationship' => 'attached', 'relationship_guid' => $entity->guid, 'inverse_relationship' => true, 'limit' => 0));
                 foreach ($attachments as $attachment) {
                     $return->attachments[] = $attachment->toObject();
                 }
                 break;
             case 'location':
                 $return->location = $entity->getLocation();
                 break;
             case 'address':
                 $return->address = $entity->address;
                 if (elgg_is_active_plugin('hypeScraper')) {
                     $return->embed = hypeScraper()->resources->get($entity->address);
                 }
                 break;
             case 'tagged_users':
                 $this->tagged_users = array();
                 $users = (array) $entity->getTaggedFriends();
                 foreach ($users as $user) {
                     if ($user instanceof \ElggUser) {
                         $this->tagged_users[] = $user->toObject();
                     }
                 }
                 break;
         }
     }
     return $return;
 }
Пример #4
0
Файл: start.php Проект: n8b/VMN
<?php

/**
 * A tool for extracting, interpreting, caching and embedding remote resources.
 * 
 * @author Ismayil Khayredinov <*****@*****.**>
 */
require_once __DIR__ . '/lib/autoloader.php';
hypeScraper()->boot();
Пример #5
0
Файл: card.php Проект: n8b/VMN
$meta = (object) $data;
$icon_url = hypeScraper()->resources->getThumbUrl($href, $handle);
$module = elgg_extract('module', $vars, 'scraper-card');
$classes = array(elgg_extract('class', $vars));
$classes[] = 'scraper-card-block';
$classes[] = 'clearfix';
if ($meta->provider_name) {
    $classes[] = 'scraper-card-' . preg_replace('/[^a-z0-9\\-]/i', '-', strtolower($meta->provider_name));
}
if ($meta->type == 'image' || $meta->type == 'photo') {
    $vars['src'] = $icon_url;
    $vars['class'] = 'sraper-card-photo';
    $img = elgg_view('output/img', $vars);
    $body = elgg_view('output/url', array('href' => $href, 'text' => $img));
} else {
    $body .= '<h3>' . $meta->title . '</h3>';
    $body .= elgg_view('output/url', array('text' => parse_url($meta->url, PHP_URL_HOST), 'href' => $meta->url, 'class' => 'scraper-card-link'));
    $body .= elgg_view('output/longtext', array('value' => elgg_get_excerpt($meta->description), 'class' => 'scraper-card-description'));
    $classes[] = 'scraper-card-has-icon';
    $icon = elgg_view('output/url', array('class' => 'scraper-card-icon-bg', 'text' => '<span></span>', 'style' => 'background-image:url(' . $icon_url . ')', 'href' => $meta->url));
    if ($meta->html && ($meta->type == 'rich' || $meta->type == 'video')) {
        $icon .= elgg_format_element('div', array('class' => 'scraper-play-button', 'data-href' => hypeScraper()->router->normalize('json', array('url' => $href, 'handle' => $handle))));
    }
}
$body = elgg_view_image_block($icon, $body, array('class' => implode(' ', array_filter($classes))));
if ($module) {
    $class = $meta->type ? " scraper-card-{$meta->type}" : '';
    echo elgg_view_module($module, false, $body, array('class' => $class));
} else {
    echo $body;
}
Пример #6
0
<?php

/**
 * View that can be used to linkify URLs, hashtags, usernames and emails
 * This can be used as an alternative to output/longtext, if you don't need
 * all the tag filtering and paragraphs
 * 
 * @uses $vars['value']           STR  Text to linkify
 * @uses $vars['parse_urls']      BOOL Disable URL linkification
 * @uses $vars['parse_hashtags']  BOOL Disable hashtag linkification
 * @uses $vars['parse_emails']    BOOL Disable email linkification
 * @uses $vars['parse_usernames'] BOOL Disable usernames linkification
 */
$value = elgg_extract('value', $vars, '');
if (elgg_extract('parse_urls', $vars, true)) {
    $value = hypeScraper()->linkify->urls($value);
}
if (elgg_extract('parse_hashtags', $vars, true)) {
    $value = hypeScraper()->linkify->hashtags($value);
}
if (elgg_extract('parse_emails', $vars, true)) {
    $value = hypeScraper()->linkify->emails($value);
}
if (elgg_extract('parse_usernames', $vars, true)) {
    $value = hypeScraper()->linkify->usernames($value);
}
echo $value;