/**
  * Dispatch a nested URL
  *
  * @param $uri
  *
  * @return string
  */
 protected function _dispatchNestedUrl($uri)
 {
     // if url path is empty, return unchanged
     if (empty($uri[1])) {
         return $uri[0];
     }
     $prefix = '';
     list($path, $append) = Strings::explode('?', $uri[1], [$uri[1], null], 2);
     //Take a root link as it comes
     if (!Strings::startsWith($path, '/')) {
         $relPath = $this->_assetManager->getRelativePath();
         if (Strings::startsWith($path, '../')) {
             $max = count($relPath);
             $depth = substr_count($path, '../');
             $path = substr($path, $depth * 3);
             if ($depth > 0 && $depth < $max) {
                 $rel = array_slice($relPath, 0, $depth);
                 $prefix = implode('/', $rel);
             }
         } else {
             $prefix = implode('/', $relPath);
         }
     }
     $path = ltrim($path, '/');
     $url = $this->_assetManager->getResourceUri(Path::buildUnix($prefix, $path));
     if (empty($url)) {
         return $uri[0];
     }
     if (!empty($append)) {
         return "url('{$url}?{$append}')";
     }
     return "url('{$url}')";
 }
示例#2
0
 public function processIncludes(AssetManager $assetManager, $vendor = false)
 {
     if ($vendor) {
         $assetManager->requireCss('assets/css/ContentElements');
     } else {
         $assetManager->requireCss('assets/css/ContentElements/ObjectLists');
     }
 }
示例#3
0
文件: Panel.php 项目: fortifi/ui
 /**
  * Require Assets
  *
  * @param AssetManager $assetManager
  * @param bool         $vendor
  */
 public function processIncludes(AssetManager $assetManager, $vendor = false)
 {
     if ($vendor) {
         $assetManager->requireCss('assets/css/GlobalElements');
     } else {
         $assetManager->requireCss('assets/css/GlobalElements/Panels');
     }
 }
示例#4
0
 public function processIncludes(AssetManager $assetManager, $vendor = false)
 {
     $assetManager->requireJs('assets/vendor/params/params');
     $assetManager->requireJs('assets/vendor/jquery.tokenize/jquery.tokenize');
     $assetManager->requireCss('assets/vendor/jquery.tokenize/jquery.tokenize');
     if ($vendor) {
         $assetManager->requireJs('assets/js/ContentElements');
         $assetManager->requireCss('assets/css/ContentElements');
     } else {
         $assetManager->requireJs('assets/js/ContentElements/QueryBuilder');
         $assetManager->requireCss('assets/css/ContentElements/QueryBuilder');
         $assetManager->requireJs('assets/js/ContentElements/QueryBuilderTokenizer');
         $assetManager->requireCss('assets/css/ContentElements/QueryBuilderTokenizer');
     }
 }
 /**
  *
  */
 protected function _init()
 {
     $this->am = AssetManager::aliasType('src');
     $this->am->requireCss('css/welcome');
 }
示例#6
0
文件: FontIcon.php 项目: fortifi/ui
 protected function _processIconIncludes(AssetManager $assetManager)
 {
     $assetManager->requireCss('assets/css/GlobalElements/FontIcons');
 }
示例#7
0
 private function _render()
 {
     $am = AssetManager::aliasType('src');
     $am->requireInlineJs($this->_script());
     return $this;
 }
示例#8
0
 /**
  * Create the response for the given path
  *
  * @param         $path
  * @param Request $request
  *
  * @return Response
  */
 public function getResponseForPath($path, Request $request)
 {
     if (empty($path)) {
         //What resources do you expect to find with no path?
         return $this->invalidUrlResponse();
     }
     $pathInfo = pathinfo($path);
     //Every dispatch request needs an extension
     if (empty($pathInfo['extension'])) {
         return $this->invalidUrlResponse();
     }
     $response = new AssetResponse();
     //Grab the correct asset for the requesting extension
     $asset = $response->assetByExtension($pathInfo['extension']);
     //Load the options
     $options = ValueAs::arr($this->_config->getItem($pathInfo['extension'] . '_config'), null);
     if ($options !== null) {
         $asset->setOptions($options);
     }
     //Lookup the full path on the filesystem
     $dirMapper = new DirectoryMapper($this->_baseDirectory, $this->_config);
     $directory = $dirMapper->urlToPath($pathInfo['dirname']);
     $filePath = Path::build($directory, $pathInfo['basename']);
     //Do not minify files ending in .min.ext
     if (substr($pathInfo['filename'], -4) == '.min') {
         $asset->setOption('minify', false);
     }
     //If the asset does not exist on disk, return a not found error
     if ($directory === null || !file_exists($filePath)) {
         return $this->notFoundResponse($path);
     }
     //Give the asset its file content
     $asset->setContent(file_get_contents($filePath));
     if ($asset instanceof IDispatchableAsset) {
         //Set the asset manager
         $asset->setWorkingDirectory(realpath($directory));
         $asset->setAssetManager(AssetManager::buildFromUri($path));
     }
     //Create and return the response
     return $response->createResponse($asset, $request);
 }
示例#9
0
 /**
  * @group Basic Query Builder
  */
 public final function queryBuilder()
 {
     $div = Div::create([QueryBuilder::create('/querybuilder/definition', '/querybuilder/policy'), HtmlTag::create()->setTag('pre')->setId('values')])->addClass(Ui::BG_INFO, Ui::PADDING_LARGE);
     AssetManager::sourceType()->requireInlineJs("\n        \$('.query-builder').QueryBuilder();\n        \$(document).on('change.querybuilder', function(e, data) {\n          \$('#values').text(\n            JSON.stringify(data, null, 2)\n          );\n        });\n      ");
     return $div;
 }
示例#10
0
文件: Ui.php 项目: fortifi/ui
 public static function boot(AssetManager $am = null, $bootstrap = true, $jquery = true, $fontAwesome = true)
 {
     if ($am === null) {
         $am = AssetManager::vendorType('fortifi', 'ui');
     }
     static::$assetManager = $am;
     //Require Base UI
     $am->requireCss('assets/css/ui-base');
     $am->requireJs('assets/js/ui-base');
     if ($jquery) {
         //Require JQuery
         $am->requireJs('assets/vendor/jquery/2.1.4.min');
     }
     if ($bootstrap) {
         //Require Bootstrap
         $am->requireCss('assets/vendor/bootstrap/3.3.4.min');
         $am->requireJs('assets/vendor/bootstrap/3.3.4.min');
     }
     if ($fontAwesome) {
         $am->requireCss('//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css');
     }
 }
示例#11
0
 protected function _init()
 {
     $am = AssetManager::aliasType('src');
     $am->requireCss(['//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css', 'css/jquery.select2', 'css/jquery.select2-bootstrap', 'css/main']);
     $am->requireJs(['//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js', '//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js', 'js/jquery.select2.min', 'js/jquery.highlight', 'js/main']);
 }
示例#12
0
 public function testExternalResource()
 {
     $am = \Packaged\Dispatch\AssetManager::sourceType();
     $location = 'http://test.com/css.css';
     $this->assertEquals($location, $am->getResourceUri($location));
 }
示例#13
0
 protected function _processIconIncludes(AssetManager $assetManager)
 {
     $assetManager->requireCss(['assets/css/GlobalElements/Browsers/browsers16', 'assets/css/GlobalElements/Browsers/browsers32', 'assets/css/GlobalElements/Browsers/browsers64', 'assets/css/GlobalElements/Browsers/browsers128']);
 }
示例#14
0
文件: ExampleUi.php 项目: fortifi/ui
 public function __construct()
 {
     Ui::boot(AssetManager::aliasType('root'));
     AssetManager::aliasType('esrc')->requireCss('css/theme');
 }