~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/Widget/Twitter.php

  • Committer: Dan Garner
  • Date: 2018-05-21 14:58:11 UTC
  • mfrom: (644.1.8)
  • mto: (614.1.6)
  • mto: This revision was merged to the branch mainline in revision 648.
  • Revision ID: git-v1:e7961b0ebe68a0c0bc5dd7b3abca007138b2cadd
Merge branch 'bugfix/1.8.10-pack1' into feature/r-graph

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
use Emojione\Ruleset;
26
26
use Respect\Validation\Validator as v;
27
27
use Stash\Invalidation;
 
28
use Xibo\Entity\Media;
28
29
use Xibo\Exception\XiboException;
29
30
use Xibo\Factory\ModuleFactory;
30
31
 
88
89
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/modules/xibo-text-render.js')->save();
89
90
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/modules/xibo-image-render.js')->save();
90
91
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/modules/xibo-layout-scaler.js')->save();
91
 
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/modules/emojione/emojione.sprites.svg')->save();
 
92
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/modules/emojione/emojione.sprites.png')->save();
 
93
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/modules/emojione/emojione.sprites.css')->save();
92
94
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/modules/vendor/bootstrap.min.css')->save();
93
95
        
94
96
        foreach ($this->mediaFactory->createModuleFileFromFolder($this->resourceFolder) as $media) {
95
97
            /* @var Media $media */
96
98
            $media->save();
97
99
        }
 
100
 
 
101
        // Tidy up the old SVG reference
 
102
        try {
 
103
            $oldSvg = $this->mediaFactory->createModuleFile(PROJECT_ROOT . '/modules/emojione/emojione.sprites.svg');
 
104
 
 
105
            if ($oldSvg->mediaId != null) {
 
106
                $this->getLog()->debug('Deleting old emoji svg file');
 
107
                $oldSvg->delete();
 
108
            }
 
109
        } catch (XiboException $xiboException) {
 
110
            $this->getLog()->error('Unable to delete old SVG reference during Twitter install. E = ' . $xiboException->getMessage());
 
111
            $this->getLog()->debug($xiboException->getTraceAsString());
 
112
        }
98
113
    }
99
114
 
100
115
    /**
551
566
 
552
567
        // Make an emojione client
553
568
        $emoji = new Client(new Ruleset());
554
 
        $emoji->imageType = 'svg';
 
569
        $emoji->imageType = 'png';
555
570
        $emoji->sprites = true;
556
 
        $emoji->imagePathSVGSprites = $this->getResourceUrl('emojione/emojione.sprites.svg');
 
571
        $emoji->imagePathPNG = $this->getResourceUrl('emojione/emojione.sprites.png');
557
572
 
558
573
        // Get the date format to apply
559
574
        $dateFormat = $this->getOption('dateFormat', $this->getConfig()->GetSetting('DATE_FORMAT'));
583
598
                // Maybe make this more generic?
584
599
                switch ($subClean) {
585
600
                    case 'Tweet':
586
 
                        // Get the tweet text to operate on
587
 
                        $tweetText = $tweet->full_text;
588
 
 
 
601
                        // Get the tweet text to operate on, if it is a retweet we need to take the full_text in a different way
 
602
                        if (isset($tweet->retweeted_status)){
 
603
                            $tweetText = 'RT @' . $tweet->retweeted_status->user->screen_name . ': ' . $tweet->retweeted_status->full_text;
 
604
                        }
 
605
                        else
 
606
                            $tweetText = $tweet->full_text;
 
607
                            
589
608
                        // Replace URLs with their display_url before removal
590
609
                        if (isset($tweet->entities->urls)) {
591
610
                            foreach ($tweet->entities->urls as $url) {
790
809
        $javaScript = $this->parseLibraryReferences($isPreview, $this->getRawNode('javaScript', ''));
791
810
 
792
811
        // Add our fonts.css file
793
 
        $headContent .= '<link href="' . (($isPreview) ? $this->getApp()->urlFor('library.font.css') : 'fonts.css') . '" rel="stylesheet" media="screen">
794
 
        <link href="' . $this->getResourceUrl('vendor/bootstrap.min.css')  . '" rel="stylesheet" media="screen">';
795
 
        
 
812
        $headContent .= '
 
813
            <link href="' . (($isPreview) ? $this->getApp()->urlFor('library.font.css') : 'fonts.css') . '" rel="stylesheet" media="screen">
 
814
            <link href="' . $this->getResourceUrl('vendor/bootstrap.min.css')  . '" rel="stylesheet" media="screen">
 
815
            <link href="' . $this->getResourceUrl('emojione/emojione.sprites.css')  . '" rel="stylesheet" media="screen">
 
816
        ';
 
817
 
796
818
        $backgroundColor = $this->getOption('backgroundColor');
797
819
        if ($backgroundColor != '') {
798
820
            $headContent .= '<style type="text/css">body { background-color: ' . $backgroundColor . ' }</style>';
856
878
    /** @inheritdoc */
857
879
    public function getCacheKey($displayId)
858
880
    {
859
 
        if ($this->getOption('tweetDistance', 0) > 0) {
 
881
        if ($displayId === 0 || $this->getOption('tweetDistance', 0) > 0) {
860
882
            // We use the display to fence in the tweets to our location
861
883
            return $this->getWidgetId() . '_' . $displayId;
862
884
        } else {
863
885
            // Non-display specific
864
 
            return $this->getWidgetId();
 
886
            return $this->getWidgetId(). (($displayId === 0) ? '_0' : '');
865
887
        }
866
888
    }
867
889