Esempio n. 1
0
 function test_for_asset_tag_helpers()
 {
     $this->testing_url_path = $this->testing_url_path == '/' ? '' : $this->testing_url_path;
     $Controller =& new MockAkActionController($this);
     $Controller->setReturnValue('urlFor', '/url/for/test');
     $asset_tag = new AssetTagHelper();
     $asset_tag->setController($Controller);
     $this->assertEqual($asset_tag->_compute_public_path('test', 'javascripts', 'js'), $this->testing_url_path . '/javascripts/test.js');
     $this->assertEqual($asset_tag->_compute_public_path('http://www.example.com/logo.png'), 'http://www.example.com/logo.png');
     $this->assertEqual($asset_tag->image_path('photo'), $this->testing_url_path . '/images/photo.png');
     $this->assertEqual($asset_tag->image_path('photo.jpg'), $this->testing_url_path . '/images/photo.jpg');
     $this->assertEqual($asset_tag->image_tag('summer_in_toronto', array('size' => '200x1000')), '<img alt="Summer in toronto" height="1000" src="' . $this->testing_url_path . '/images/summer_in_toronto.png" width="200" />');
     $this->assertEqual($asset_tag->stylesheet_path('cool'), $this->testing_url_path . '/stylesheets/cool.css');
     $this->assertEqual($asset_tag->stylesheet_path('cooler.style'), $this->testing_url_path . '/stylesheets/cooler.style');
     $this->assertEqual($asset_tag->stylesheet_link_tag('cool', array('media' => 'all')), '<link href="' . $this->testing_url_path . '/stylesheets/cool.css" media="all" rel="Stylesheet" type="text/css" />' . "\n");
     $this->assertEqual($asset_tag->stylesheet_link_tag('cool', 'cooler.style', array('media' => 'all')), '<link href="' . $this->testing_url_path . '/stylesheets/cool.css" media="all" rel="Stylesheet" type="text/css" />' . "\n" . '<link href="' . $this->testing_url_path . '/stylesheets/cooler.style" media="all" rel="Stylesheet" type="text/css" />' . "\n");
     $this->assertEqual($asset_tag->javascript_path('ajax'), $this->testing_url_path . '/javascripts/ajax.js');
     $this->assertEqual($asset_tag->javascript_path('superfx.javascript'), $this->testing_url_path . '/javascripts/superfx.javascript');
     $this->assertEqual($asset_tag->javascript_include_tag('ajax'), '<script src="' . $this->testing_url_path . '/javascripts/ajax.js" type="text/javascript"></script>' . "\n");
     $this->assertEqual($asset_tag->javascript_include_tag('ajax', 'superfx.javascript'), '<script src="' . $this->testing_url_path . '/javascripts/ajax.js" type="text/javascript"></script>' . "\n" . '<script src="' . $this->testing_url_path . '/javascripts/superfx.javascript" type="text/javascript"></script>' . "\n");
     $this->assertEqual($asset_tag->javascript_include_tag('marquesine', array('charset' => 'iso-8859-1')), '<script charset="iso-8859-1" src="' . $this->testing_url_path . '/javascripts/marquesine.js" type="text/javascript"></script>' . "\n");
     $defaults = $asset_tag->_get_javascript_included_defaults();
     $defaults_count = count($defaults);
     $this->assertTrue($defaults_count > 0);
     $asset_tag->register_javascript_include_default('akelos_fx');
     $new_defaults = $asset_tag->_get_javascript_included_defaults();
     $new_defaults_count = count($new_defaults);
     $this->assertEqual('akelos_fx', array_pop($new_defaults));
     $this->assertEqual($defaults_count + 1, $new_defaults_count);
     $asset_tag->register_javascript_include_default('another_fx');
     $this->assertTrue(strstr($asset_tag->javascript_include_tag(), '<script src="' . $this->testing_url_path . '/javascripts/another_fx.js" type="text/javascript"></script>' . "\n"));
     $asset_tag->reset_javascript_include_default();
     $this->assertEqual($defaults_count, count($asset_tag->_get_javascript_included_defaults()));
     $this->assertEqual($asset_tag->auto_discovery_link_tag(), '<link href="/url/for/test" rel="alternate" title="RSS" type="application/rss+xml" />');
 }
Esempio n. 2
0
 /**
  *  Test image_tag() method
  *
  *  Test the {@link AssetTagHelper::image_tag()} method
  */
 public function testImage_tag_method()
 {
     $ath = new AssetTagHelper();
     $this->assertEquals('<img alt="Foo"' . ' src="/testprefix/images/foo.png" />' . "\n", $ath->image_tag('foo'));
     $this->assertEquals('<img alt="Bar"' . ' src="/testprefix/images/foo.png" />' . "\n", $ath->image_tag('foo', array('alt' => 'Bar')));
     $this->assertEquals('<img alt="Foo" height="45"' . ' src="/testprefix/images/foo.png"' . ' width="30" />' . "\n", $ath->image_tag('foo', array('width' => '30', 'height' => '45')));
     $this->assertEquals('<img alt="Foo" height="45"' . ' src="/testprefix/images/foo.png"' . ' width="30" />' . "\n", $ath->image_tag('foo', array('size' => '30x45')));
 }
Esempio n. 3
0
 public function __construct()
 {
     $this->javascript_default_sources = array('prototype', 'builder', 'effects', 'dragdrop', 'controls', 'slider');
     self::$asset_server = WXConfiguration::get("assets");
 }
Esempio n. 4
0
 function cssImageSizeFunc($params, &$view)
 {
     if (!isset($params['src'])) {
         return;
     }
     $src = $params['src'];
     unset($params['src']);
     return AssetTagHelper::cssImageSize($src, $params);
 }
Esempio n. 5
0
 public function test_javascript_for_current_controller()
 {
     $controller = new MockAkActionController($this);
     $controller->asset_host = AK_ASSET_HOST;
     $controller->setReturnValue('urlFor', '/url/for/test');
     $asset_tag_helper = new AssetTagHelper();
     $asset_tag_helper->setController($controller);
     $controller->setReturnValue('getControllerName', 'valid_controller');
     $controller->setReturnValue('urlFor', '/url/for/test');
     $this->assertEqual($asset_tag_helper->javascript_for_current_controller(), '<script src="' . $this->testing_url_path . '/javascripts/valid_controller.js" type="text/javascript"></script>' . "\n");
     $controller = new MockAkActionController($this);
     $controller->asset_host = AK_ASSET_HOST;
     $controller->setReturnValue('urlFor', '/url/for/test');
     $asset_tag_helper = new AssetTagHelper();
     $asset_tag_helper->setController($controller);
     $controller->setReturnValue('getControllerName', 'non_valid_controller');
     $controller->setReturnValue('urlFor', '/url/for/test');
     $this->assertEqual($asset_tag_helper->javascript_for_current_controller(), '');
 }
Esempio n. 6
0
 /**
  * download_icon - Called from a Smarty template to return a string with an icon
  * 					image link.
  *
  * @param	array	A path to a filename.
  * @return	string	An img tag with a particular image for the filetype passed.
  **/
 function download_icon($params)
 {
     $extension = NFilesystem::getExtension($params['file']);
     $icon = '/images/icons/' . $extension . '.png';
     $icon_path = DOCUMENT_ROOT . $icon;
     if (file_exists($icon_path)) {
         return AssetTagHelper::imageTag($icon, 'Download');
     } else {
         return AssetTagHelper::imageTag('/images/icons/default.png', 'Download');
     }
 }
Esempio n. 7
0
 function _embedReferencedImages($html)
 {
     $images = TextHelper::get_image_urls_from_html($html);
     $html_images = array();
     if (!empty($images)) {
         require_once AK_LIB_DIR . DS . 'AkImage.php';
         require_once AK_LIB_DIR . DS . 'AkActionView' . DS . 'helpers' . DS . 'asset_tag_helper.php';
         foreach ($images as $image) {
             $image = AssetTagHelper::_compute_public_path($image);
             $extenssion = substr($image, strrpos('.' . $image, '.'));
             $image_name = Ak::uuid();
             Ak::file_put_contents(AK_CACHE_DIR . DS . 'tmp' . DS . $image_name . $extenssion, file_get_contents($image));
             $NewImage =& new AkImage(AK_CACHE_DIR . DS . 'tmp' . DS . $image_name . $extenssion);
             $NewImage->save(AK_CACHE_DIR . DS . 'tmp' . DS . $image_name . '.png');
             $html_images[$image] = $image_name . '.png';
             Ak::file_delete(AK_CACHE_DIR . DS . 'tmp' . DS . $image_name);
         }
         $html = str_replace(array_keys($html_images), array_values($html_images), $html);
     }
     return array($html_images, $html);
 }
Esempio n. 8
0
 private function find_files($dir, $filter)
 {
     if (!is_readable($dir)) {
         return;
     }
     $tag_build = new \AssetTagHelper();
     foreach ($tag_build->iterate_dir($dir, $filter) as $file) {
         $ret[] = $file->getPathName();
     }
     return $ret;
 }