Пример #1
0
 /**
  * configures instance upon construct
  * @param \Altamira\JsWriter\JsWriterAbstract $jsWriter
  */
 protected function configure(\Altamira\JsWriter\JsWriterAbstract $jsWriter)
 {
     $confInstance = \Altamira\Config::getInstance();
     $file = $confInstance['altamira.root'] . $confInstance['altamira.typeconfigpath'];
     $config = \parse_ini_file($file, true);
     $libConfig = $config[strtolower($jsWriter->getLibrary())];
     $type = static::TYPE;
     $typeAttributes = preg_grep("/{$type}\\./i", array_keys($libConfig));
     foreach ($typeAttributes as $key) {
         $attribute = preg_replace("/{$type}\\./i", '', $key);
         $this->{$attribute} = $libConfig[$key];
     }
 }
Пример #2
0
    /**
     * @covers \Altamira\FilesRenderer::__construct
     * @covers \Altamira\FilesRenderer::handleMinify
     * @covers \Altamira\FilesRenderer::offsetSet
     * @covers \Altamira\FilesRenderer::render
     */
    public function testFilesRendererWithMin()
    {
        $files = array('foo.js', 'bar.min.js');
        $expectedResult = <<<ENDSCRIPT
<script type="text/javascript" src="foo.min.js"></script>
<script type="text/javascript" src="bar.min.js"></script>
<script type="text/javascript" src="baz.min.js"></script>

ENDSCRIPT;
        $config = \Altamira\Config::getInstance();
        $config['js.minify'] = true;
        $this->expectOutputString($expectedResult, '\\Altamira\\FilesRenderer should implement ArrayIterator, and calling next() on it should provide the next script.' . ' Providing a path should prepend that path to each file.');
        $filesRenderer = new \Altamira\FilesRenderer($files);
        $filesRenderer[2] = 'baz.js';
        do {
            $filesRenderer->render();
            $filesRenderer->next();
        } while ($filesRenderer->valid());
    }
Пример #3
0
 /**
  * Provides the appropriate path to where required CSS is stored for these charting libraries
  * @return Ambigous <string, \Altamira\Config>
  */
 public function getCSSPath()
 {
     $config = \Altamira\Config::getInstance();
     $cssPath = '';
     foreach ($this->libraries as $library => $junk) {
         switch ($library) {
             case \Altamira\JsWriter\Flot::LIBRARY:
                 break;
             case \Altamira\JsWriter\JqPlot::LIBRARY:
             default:
                 $cssPath = $config['css.jqplotpath'];
         }
     }
     return $cssPath;
 }
Пример #4
0
 /**
  * Returns an array of files required to render the chart 
  * Includes the default files, as well as any files registered by type
  * It's important to note that some methods in concrete classes will add additional files to this instance
  * @return array
  */
 public function getFiles()
 {
     $files = $this->files;
     foreach ($this->types as $type) {
         $files = array_merge($files, $type->getFiles());
     }
     $path = \Altamira\Config::getInstance()->getPluginPath($this->getLibrary());
     array_walk($files, function (&$val) use($path) {
         $val = $path . $val;
     });
     return $files;
 }