Esempio n. 1
0
 public function testHandler()
 {
     Application::getInstance()->init();
     $h = new TwitterResourceHandler('https://api.twitter.com/1.1/statuses/home_timeline.json');
     $this->assertTrue($h->fetchData());
     $html = $h->renderHtml();
     $this->assertContains('twitter-item', $html);
 }
 public function testRenderSmallHtml()
 {
     Application::getInstance()->init();
     $h = new InstagramResourceHandler('');
     $h->style = 'small';
     $h->fetchData();
     $html = $h->renderHtml();
     $this->assertContains('instagram -small', $html);
     $this->assertContains('instagram-item__image', $html);
 }
Esempio n. 3
0
 /**
  *
  */
 public function testFunctionality()
 {
     Application::getInstance()->init();
     $w = new WeatherResourceHandler('http://weather.yahooapis.com/forecastrss?w=2124390&u=c');
     $this->assertTrue($w->fetchData());
     $this->assertEquals('Vyksa', $w->getProperty('city'));
     $html = $w->renderHtml();
     $this->assertContains('weather__today', $html);
     $this->assertContains('weather__code', $html);
 }
 public function renderHtml()
 {
     if ($this->_response) {
         $data = [];
         foreach ($this->_response as $tweet) {
             $data[] = ['userImage' => $tweet->user->profile_image_url, 'userName' => $tweet->user->name, 'created' => Date::parse($tweet->created_at)->ago(), 'text' => StrHelper::removeEmoji($tweet->text), 'source' => $tweet->source];
         }
         return Application::getInstance()->jadeEngine()->render(Application::getInstance()->getBasePath() . '/frontend/src/jade/resource/twitter.jade', ['data' => $data]);
     }
 }
Esempio n. 5
0
 /**
  * @return mixed|string
  * @throws \Exception
  */
 public function renderHtml()
 {
     $articles = $this->_feed->articles();
     $result = [];
     foreach ($articles as $i => $article) {
         if ($i >= 4) {
             break;
         }
         $result[] = $this->_getFromArticle($article);
     }
     return Application::getInstance()->jadeEngine()->render(__DIR__ . '/../../frontend/src/jade/resource/rss.jade', ['articles' => $result]);
 }
 public function renderHtml()
 {
     $media = $this->_currentUser->getFeed();
     $data = [];
     foreach ($media as $photo) {
         /** @var \Instagram\Media $photo */
         $data[] = ['image' => $photo->getLowResImage()->url, 'user' => $photo->getUser()->getUserName(), 'location' => $photo->getLocation() ? $photo->getLocation()->getName() : '', 'date' => Date::createFromTimestamp($photo->getCreatedTime())->ago(), 'caption' => $photo->getCaption() ? StrHelper::removeEmoji($photo->getCaption()->getText()) : ''];
     }
     if ($this->limit) {
         $data = array_chunk($data, $this->limit)[0];
     }
     $template = $this->style ? 'instagram_' . $this->style : 'instagram';
     return Application::getInstance()->jadeEngine()->render(__DIR__ . '/../../frontend/src/jade/resource/' . $template . '.jade', ['data' => $data]);
 }
Esempio n. 7
0
 public static function removeEmoji($data)
 {
     require_once Application::getInstance()->getBasePath() . '/php-emoji/emoji.php';
     $data = emoji_docomo_to_unified($data);
     # DoCoMo devices
     $data = emoji_kddi_to_unified($data);
     # KDDI & Au devices
     $data = emoji_softbank_to_unified($data);
     # Softbank & pre-iOS6 Apple devices
     $data = emoji_google_to_unified($data);
     # Google Android devices
     $data = emoji_unified_to_html($data);
     $data = preg_replace('/[^а-яa-z0-9 _\\-\\+\\&\\.\\,\\!@#\\$\\n\\t<>=\\/"\\(\\)\\*:]/ui', '', $data);
     return $data;
 }
Esempio n. 8
0
 public function processResources()
 {
     /* @var $p IPersistent */
     $p = Application::getInstance()->getService('IPersistent');
     $resources = $p->getAllResources();
     if ($resources) {
         /** @var \IpadSlider\Model\Resource $resource */
         foreach ($resources as $resource) {
             try {
                 echo "Get resource  - " . $resource->name . "\n";
                 $data = $resource->getSerializedData();
                 $p->changeHtml($resource, $data);
                 echo "Done \n";
             } catch (\Exception $exc) {
                 echo $exc->getMessage();
                 $p->changeHtml($resource, Application::getInstance()->jadeEngine()->render(__DIR__ . '/../frontend/src/jade/resource/error.jade', ['message' => $exc->getMessage(), 'stack' => $exc->getTraceAsString()]));
             }
         }
     }
 }
 public function renderHtml()
 {
     return Application::getInstance()->jadeEngine()->render(__DIR__ . '/../../frontend/src/jade/resource/iframe.jade', ['url' => $this->_url]);
 }
Esempio n. 10
0
<?

use Instagram\Auth;
use IpadSlider\Application;

require_once('vendor/autoload.php');

Application::getInstance()->init();

$auth = new Auth( Application::getInstance()->config('instagram') );


if ($_GET['code']) {
	echo 'Api token is <strong>' . $auth->getAccessToken( $_GET['code'] ) . '</strong>';
} else {
	$auth->authorize();
}
Esempio n. 11
0
 private function _getRss()
 {
     $service = Application::getInstance()->getService('IHttpTransport');
     /** @var IHttpTransport $service */
     return $service->getUrlContents($this->_url);
 }
Esempio n. 12
0
 public function testHandleRequest()
 {
     $request = [];
     Application::getInstance()->handleRequest($request);
 }
Esempio n. 13
0
 public function index()
 {
     echo Application::getInstance()->jadeEngine()->render($this->appPath() . '/frontend/src/jade/index.jade', ['slides' => $this->_db->getAllSlides()]);
 }
Esempio n. 14
0
<?php

/**
 * Created by PhpStorm.
 * User: marochkin_pe
 * Date: 23.10.2015
 * Time: 15:11
 */
use IpadSlider\Application;
use IpadSlider\Model\IPersistent;
use Jade\Jade;
require_once "../vendor/autoload.php";
Application::getInstance()->init();
Application::getInstance()->handleRequest($_REQUEST);
Esempio n. 15
0
 protected function appPath()
 {
     return Application::getInstance()->getBasePath();
 }
Esempio n. 16
0
<?php

/**
 * Created by PhpStorm.
 * User: marochkin_pe
 * Date: 23.10.2015
 * Time: 15:11
 */
use IpadSlider\Application;
require_once "vendor/autoload.php";
Application::getInstance()->init();
$job = new IpadSlider\Fetcher();
$job->processResources();