Ejemplo n.º 1
0
 function resource($file, $level = '', $display = 'url', $params = '')
 {
     include_once APPPATH . 'libraries/Assets.php';
     $assets = new Assets();
     if ($display === 'url') {
         return $assets->url($file, $level);
     } elseif ($display === 'file') {
         return $assets->load($file, $level, $params);
     } else {
         return $assets->url($file, $level);
     }
 }
Ejemplo n.º 2
0
 /**
  * Create an instance of this class by using a plain PHP array.
  *
  * @param array $conf   an array containing the configuration
  * settings
  * @param string $path  the path to the config file that was used
  *                      (NULL if instantiated via constructor)
  */
 function __construct($conf = array(), $path = NULL)
 {
     global $ABSOLUTE_PATH_STUDIP;
     $defaults = array('assets_root' => "{$ABSOLUTE_PATH_STUDIP}assets", 'package_path' => "{$ABSOLUTE_PATH_STUDIP}assets/squeezed", 'package_url' => \Assets::url('squeezed'), 'javascripts' => array(), 'compress' => true, 'compressor_options' => array());
     $this->settings = array_merge($defaults, $conf);
     $this->settings['config_path'] = $path ?: __FILE__;
 }
Ejemplo n.º 3
0
 function test_url_with_paramater_should_not_cycle()
 {
     $url = Assets::url('prototype.js');
     $url2 = Assets::url('prototype.js');
     $pattern = sprintf('@http://www[0-%d].example.com/public/@', Assets::NUMBER_OF_ALIASES - 1);
     $this->assertRegexp($pattern, $url);
     $this->assertEquals($url, $url2);
 }
Ejemplo n.º 4
0
 function setUp()
 {
     $this->original_assets_url = \Assets::url();
     \Assets::set_assets_url(self::ASSETS_URL);
     $this->conf = Configuration::load(TEST_FIXTURES_PATH . "squeeze/assets.yml");
     $this->rmTmpDir();
     $this->output_directory = $this->getTmpDir();
     $this->STUDIP_BASE_PATH = $GLOBALS['STUDIP_BASE_PATH'];
     $GLOBALS['STUDIP_BASE_PATH'] = realpath(dirname(__FILE__) . '/../../../../../');
 }
Ejemplo n.º 5
0
 function setUp()
 {
     $this->memo_assets_url = Assets::url();
     Assets::set_assets_url('');
 }
Ejemplo n.º 6
0
                    <ul>
                        <? foreach ($notifications as $notification) : ?>
                        <?php 
echo $notification->getLiElement();
?>
                        <? endforeach ?>
                    </ul>
                </div>
                <? if (PersonalNotifications::isAudioActivated()) : ?>
                <audio id="audio_notification" preload="none">
                    <source src="<?php 
echo Assets::url('sounds/blubb.ogg');
?>
" type="audio/ogg">
                    <source src="<?php 
echo Assets::url('sounds/blubb.mp3');
?>
" type="audio/mpeg">
                </audio>
                <? endif ?>
            </li>
            <? endif ?>
            <? if (isset($search_semester_nr)) : ?>
            <li>
                        </li>
            <? endif ?>
            <? if (Navigation::hasItem('/links')) : ?>
            <? foreach (Navigation::getItem('/links') as $nav) : ?>
                <? if ($nav->isVisible()) : ?>
                    <li <? if ($nav->isActive()) echo 'class="active"'; ?>>
                    <a
Ejemplo n.º 7
0
 /**
  * Rearranges passed parameters. Tries to detect given size, color and
  * extra icon.
  *
  * @param mixed $input    Either a relative or absolute url or an array
  * @param Array $defaults Default values for size, color and extra icon
  * @param mixed $extra    Extra icon to apply to the icon, defaults to none
  * @return Array with the guessed values
  */
 protected static function rearrange($input, $defaults = array(), $extra = false)
 {
     if (!is_array($input)) {
         $input = str_replace(Assets::url('images/'), '', $input);
         if (strpos($input, 'http') !== false) {
             return false;
         }
         $input = preg_replace('~^icons/~S', '', $input);
         $input = preg_replace('/\\.png$/S', '', $input);
         $input = explode('/', $input);
     }
     $result = array_merge(array('size' => Icon::DEFAULT_SIZE, 'color' => Icon::DEFAULT_COLOR, 'icon' => array()), $defaults);
     foreach ($input as $chunk) {
         if (is_int($chunk) || ctype_digit($chunk)) {
             $result['size'] = $chunk;
         } elseif (in_array($chunk, self::$icon_colors)) {
             $result['color'] = $chunk;
         } else {
             $result['icon'][] = $chunk;
         }
     }
     if (count($result['icon']) === 1 && $extra) {
         array_unshift($result['icon'], $extra);
     }
     $result['icon'] = join('/', $result['icon']);
     return $result;
 }
function assets_url($path = null)
{
    return Assets::url($path);
}
Ejemplo n.º 9
0
 function pathToURL($path)
 {
     return \Assets::url($path);
 }
Ejemplo n.º 10
0
function get_flash_player ($document_id, $filename, $type) {
    global $auth;
    // width of image in pixels
    if (is_object($auth) && $auth->auth['xres']) {
        // 50% of x-resolution maximal
        $max_width = floor($auth->auth['xres'] / 4);
    } else {
        $max_width = 400;
    }
    $width = $max_width;
    $height = round($width * 0.75);
    if ($width > 200) {
        $flash_config = $GLOBALS['FLASHPLAYER_DEFAULT_CONFIG_MAX'];
    } else {
        $flash_config = $GLOBALS['FLASHPLAYER_DEFAULT_CONFIG_MIN'];
    }
    $cfg = Config::GetInstance();
    $DOCUMENTS_EMBEDD_FLASH_MOVIES = $cfg->getValue('DOCUMENTS_EMBEDD_FLASH_MOVIES');
    if ($DOCUMENTS_EMBEDD_FLASH_MOVIES == 'autoplay') {
        $flash_config .= '&amp;autoplay=1&amp;autoload=1';
    } else if ($DOCUMENTS_EMBEDD_FLASH_MOVIES == 'autoload') {
        $flash_config .= '&amp;autoload=1';
    }
    // we need the absolute url if the player is delivered from a different base
    $movie_url = GetDownloadLink($document_id, $filename, $type, 'force');
    $flash_object  = "\n<object type=\"application/x-shockwave-flash\" id=\"FlashPlayer\" data=\"".Assets::url()."flash/player_flv.swf\" width=\"$width\" height=\"$height\">\n";
    $flash_object .= "<param name=\"movie\" value=\"".Assets::url()."flash/player_flv.swf\">\n";
    $flash_object .= '<param name="allowFullScreen" value="true">' . "\n";
    $flash_object .= "<param name=\"FlashVars\" value=\"flv=" . urlencode($movie_url) . $flash_config . "\">\n";
    $flash_object .= "<embed src=\"".Assets::url()."flash/player_flv.swf\" movie=\"{$movie_url}\" type=\"application/x-shockwave-flash\" FlashVars=\"flv=".urlencode($movie_url).$flash_config."\">\n";
    $flash_object .= "</object>\n";

    return array('player' => $flash_object, 'width' => $width, 'height' => $height);
}
Ejemplo n.º 11
0
 /**
  * Stud.IP markup for images, audio, video and flash-films
  */
 protected static function markupMedia($markup, $matches)
 {
     $tag = $matches[1];
     $params = explode(":", $matches[2]);
     $url = $matches[3];
     $whitespace = $matches[4];
     foreach ($params as $key => $param) {
         if ($param) {
             if (is_numeric($param)) {
                 $width = $param;
             } elseif (in_array($param, words("left center right"))) {
                 $position = $param;
             } elseif ($key === 0 && $param[0] === "=") {
                 $title = substr($param, 1);
             } elseif ($key < count($params) - 1) {
                 $virtual_url = $param . ":" . $params[$key + 1];
                 if (isURL($virtual_url)) {
                     $link = $virtual_url;
                 }
             }
         }
     }
     $format_strings = array('img' => '<img src="%s" style="%s" title="%s" alt="%s">', 'audio' => '<audio src="%s" style="%s" title="%s" alt="%s" controls></audio>', 'video' => '<video src="%s" style="%s" title="%s" alt="%s" controls></video>');
     $url = TransformInternalLinks($url);
     $pu = @parse_url($url);
     if (($pu['scheme'] == 'http' || $pu['scheme'] == 'https') && ($pu['host'] == $_SERVER['HTTP_HOST'] || $pu['host'] . ':' . $pu['port'] == $_SERVER['HTTP_HOST']) && strpos($pu['path'], $GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP']) === 0) {
         $intern = true;
         $checkpath = urldecode(substr($pu['path'], strlen($GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP'])));
         if (strpos($checkpath, '../') === false) {
             list($pu['first_target']) = explode('/', $checkpath);
         } else {
             $pu['first_target'] = false;
         }
     }
     $LOAD_EXTERNAL_MEDIA = Config::GetInstance()->getValue('LOAD_EXTERNAL_MEDIA');
     if ($intern && !in_array($pu['first_target'], array('sendfile.php', 'download', 'assets', 'pictures')) && !($pu['first_target'] === 'dispatch.php' && strpos($pu['path'], 'dispatch.php/document/download') !== false)) {
         return $matches[0];
     } elseif ((!$LOAD_EXTERNAL_MEDIA || $LOAD_EXTERNAL_MEDIA === 'deny') && !$intern) {
         return $matches[0];
     }
     //Mediaproxy?
     if (!$intern && $LOAD_EXTERNAL_MEDIA === "proxy" && Seminar_Session::is_current_session_authenticated()) {
         $media_url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'dispatch.php/media_proxy?url=' . urlencode(decodeHTML(idna_link($url)));
     } else {
         $media_url = idna_link($url);
     }
     if ($tag === "flash") {
         $width = $width ? $width : 200;
         $height = round($width * 0.75);
         $flash_config = $width > 200 ? $GLOBALS['FLASHPLAYER_DEFAULT_CONFIG_MAX'] : $GLOBALS['FLASHPLAYER_DEFAULT_CONFIG_MIN'];
         $media = '<object type="application/x-shockwave-flash" id="FlashPlayer" data="' . Assets::url() . 'flash/player_flv.swf" width="' . $width . '" height="' . $height . '">
                     <param name="movie" value="' . Assets::url() . 'flash/player_flv.swf">
                     <param name="allowFullScreen" value="true">
                     <param name="FlashVars" value="flv=' . urlencode(decodeHTML($media_url)) . '&amp;startimage=' . $link . $flash_config . '">
                     <embed src="' . Assets::url() . 'flash/player_flv.swf" movie="$media_url" type="application/x-shockwave-flash" FlashVars="flv=' . urlencode(decodeHTML($media_url)) . '&amp;startimage=' . $link . $flash_config . '">
                     </object>';
     } else {
         $media = sprintf($format_strings[$tag], $media_url, isset($width) ? "width: " . $width . "px;" : "", $title, $title);
     }
     if ($tag === 'audio') {
         $random_id = 'audio-' . substr(md5(uniqid('audio', true)), -8);
         $media = str_replace('<audio ', '<audio id="' . $random_id . '" onerror="STUDIP.Audio.handle(this);" ', $media);
     }
     if ($link && $tag === "img") {
         $media = sprintf('<a href="%s"%s>%s</a>', $link, !isLinkIntern($link) ? ' target="_blank"' : "", $media);
     }
     if ($position) {
         $media = '<div style="text-align: ' . $position . '">' . $media . '</div>';
     }
     $media .= $whitespace;
     return $media;
 }
Ejemplo n.º 12
0
 /**
  * This function computes the public path to the given source by using default
  * dir and ext if not specified by the source. If source is not an absolute
  * URL, the assets url is incorporated.
  *
  * @ignore
  */
 private function compute_public_path($source, $dir, $ext)
 {
     # add extension if not present
     if ('' == substr(strrchr($source, "."), 1)) {
         $source .= ".{$ext}";
     }
     # if source is not absolute
     if (FALSE === strpos($source, ':')) {
         # add dir if url does not contain a path
         if ('/' !== $source[0]) {
             $source = "{$dir}/{$source}";
         }
         # consider asset host
         $source = Assets::url(ltrim($source, '/'));
     }
     return $source;
 }