~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/Widget/TwitterMetro.php

  • Committer: GitHub
  • Author(s): Dan Garner
  • Date: 2017-02-14 08:53:21 UTC
  • mfrom: (552.1.1)
  • Revision ID: git-v1:28b5a08b8293d0566da12863dbf2bde244f28804
Merge pull request #237 from maurofmferrao/develop

Complete conflict resolution for https://github.com/xibosignage/xibo-cms/pull/234

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/web/modules/vendor/jquery-1.11.1.min.js')->save();
88
88
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/web/modules/xibo-metro-render.js')->save();
89
89
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/web/modules/xibo-layout-scaler.js')->save();
 
90
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/web/modules/xibo-image-render.js')->save();
90
91
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/web/modules/emojione/emojione.sprites.svg')->save();
91
92
        $this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/web/modules/vendor/bootstrap.min.css')->save();
92
93
        
185
186
 
186
187
    public function validate()
187
188
    {
 
189
        // If overrideColorTemplate is false we have to define a template Id 
 
190
        if($this->getOption('overrideColorTemplate') == 0 && ( $this->getOption('colorTemplateId') == '' || $this->getOption('colorTemplateId') == null) )
 
191
            throw new \InvalidArgumentException(__('Please choose a template'));
 
192
            
188
193
        if ($this->getUseDuration() == 1 && $this->getDuration() == 0)
189
194
            throw new \InvalidArgumentException(__('Please enter a duration'));
190
195
 
242
247
        $this->setOption('resultContent', $this->getSanitizer()->getString('resultContent'));
243
248
        $this->setOption('removeRetweets', $this->getSanitizer()->getCheckbox('removeRetweets'));
244
249
        
245
 
        // Convert the colors array to string to be able to save it
246
 
        $stringColor = $this->getSanitizer()->getStringArray('color')[0];
247
 
        for ($i=1; $i < count($this->getSanitizer()->getStringArray('color')); $i++) {
248
 
            if(!empty($this->getSanitizer()->getStringArray('color')[$i]))
249
 
                $stringColor .= "|" . $this->getSanitizer()->getStringArray('color')[$i];
 
250
        if( $this->getOption('overrideColorTemplate') == 1 ){
 
251
            
 
252
            // Convert the colors array to string to be able to save it
 
253
            $stringColor = $this->getSanitizer()->getStringArray('color')[0];
 
254
            for ($i=1; $i < count($this->getSanitizer()->getStringArray('color')); $i++) {
 
255
                if(!empty($this->getSanitizer()->getStringArray('color')[$i]))
 
256
                    $stringColor .= "|" . $this->getSanitizer()->getStringArray('color')[$i];
 
257
            }
 
258
            $this->setOption('templateColours', $stringColor);
250
259
        }
251
 
        $this->setOption('templateColours', $stringColor);
252
260
    }
253
261
 
254
262
    /**
478
486
                        if (!$this->tweetHasPhoto($tweet)) {
479
487
                        
480
488
                            // Get the colors array
481
 
                            $colorArray = explode("|", $this->getOption('templateColours'));
 
489
                            if( $this->getOption('overrideColorTemplate') == 0 ) {
 
490
                                
 
491
                                $templates = $this->colorTemplatesAvailable();
 
492
                                
 
493
                                foreach ($templates as $tmplt) {
 
494
                                    if( $tmplt['id'] == $this->getOption('colorTemplateId') ){
 
495
                                        $colorArray = $tmplt['colors'];
 
496
                                    }
 
497
                                }
 
498
                                
 
499
                            } else {
 
500
                                $colorArray = explode("|", $this->getOption('templateColours'));
 
501
                            }
482
502
                            
483
503
                            // Find a random color
484
504
                            $randomNum = rand(0,count($colorArray)-1);
623
643
        $javaScriptContent = '<script type="text/javascript" src="' . $this->getResourceUrl('vendor/jquery-1.11.1.min.js') . '"></script>';
624
644
 
625
645
        // Get the colors array
626
 
        $colorArray = explode("|", $this->getOption('templateColours'));
 
646
        if( $this->getOption('overrideColorTemplate') == 0 ) {
 
647
            
 
648
            $templates = $this->colorTemplatesAvailable();
 
649
            
 
650
            foreach ($templates as $tmplt) {
 
651
                if( $tmplt['id'] == $this->getOption('colorTemplateId') ){
 
652
                    $colorArray = $tmplt['colors'];
 
653
                }
 
654
            }
 
655
            
 
656
        } else {
 
657
            $colorArray = explode("|", $this->getOption('templateColours'));
 
658
        }
627
659
        
628
660
        // Need the cycle plugin?
629
661
        if ($this->getOption('effect') != 'none')
631
663
 
632
664
        $javaScriptContent .= '<script type="text/javascript" src="' . $this->getResourceUrl('xibo-layout-scaler.js') . '"></script>';
633
665
        $javaScriptContent .= '<script type="text/javascript" src="' . $this->getResourceUrl('xibo-metro-render.js') . '"></script>';
 
666
        $javaScriptContent .= '<script type="text/javascript" src="' . $this->getResourceUrl('xibo-image-render.js') . '"></script>';
634
667
 
635
668
        $javaScriptContent .= '<script type="text/javascript">';
636
669
        $javaScriptContent .= '   var options = ' . json_encode($options) . ';';
637
670
        $javaScriptContent .= '   var items = ' . json_encode($items) . ';';
638
671
        $javaScriptContent .= '   var colors = ' . json_encode($colorArray) . ';';
639
672
        $javaScriptContent .= '   $(document).ready(function() { ';
640
 
        $javaScriptContent .= '       $("body").xiboLayoutScaler(options); $("#content").xiboMetroRender(options, items, colors); ';
 
673
        $javaScriptContent .= '       $("body").xiboLayoutScaler(options); $("#content").xiboMetroRender(options, items, colors); $("#content").find("img").xiboImageRender(options); $("#content").find(".cell").xiboImageRender(options);';
641
674
        $javaScriptContent .= '   }); ';
642
675
        $javaScriptContent .= '</script>';
643
676