コード例 #1
0
ファイル: Controller.php プロジェクト: ceko/concrete5-1
 public function registerViewAssets()
 {
     $al = \AssetList::getInstance();
     $v = \View::getInstance();
     $env = \Environment::get();
     $identifier = 'menuitem/' . $this->menuItem->getHandle() . '/view';
     foreach (array('CSS' => 'view.css', 'JAVASCRIPT' => 'view.js') as $t => $i) {
         $r = $env->getRecord(DIRNAME_MENU_ITEMS . '/' . $this->menuItem->getHandle() . '/' . $i, $this->menuItem->getPackageHandle());
         if ($r->exists()) {
             switch ($t) {
                 case 'CSS':
                     $asset = new CssAsset($identifier);
                     $asset->setAssetURL($r->url);
                     $asset->setAssetPath($r->file);
                     $al->registerAsset($asset);
                     $v->requireAsset('css', $identifier);
                     break;
                 case 'JAVASCRIPT':
                     $asset = new JavascriptAsset($identifier);
                     $asset->setAssetURL($r->url);
                     $asset->setAssetPath($r->file);
                     $al->registerAsset($asset);
                     $v->requireAsset('javascript', $identifier);
                     break;
             }
         }
     }
 }
コード例 #2
0
 private function registerCorePlugins(PluginManager $pluginManager)
 {
     $coreAssetDir = 'js/ckeditor4/core/';
     $vendorAssetDir = 'js/ckeditor4/vendor/';
     $assetList = \AssetList::getInstance();
     $assetList->register('javascript', 'editor/ckeditor4', $vendorAssetDir . 'ckeditor.js');
     $assetList->register('css', 'editor/ckeditor4', $coreAssetDir . 'ckeditor.css');
     $assetList->register('javascript', 'editor/ckeditor4/jquery_adapter', $vendorAssetDir . 'adapters/jquery.js');
     $assetList->registerGroup('editor/ckeditor4', array(array('javascript', 'editor/ckeditor4'), array('css', 'editor/ckeditor4'), array('javascript', 'editor/ckeditor4/jquery_adapter')));
     $assetList->register('javascript', 'editor/ckeditor4/concrete5inline', $coreAssetDir . 'concrete5inline/register.js');
     $assetList->register('css', 'editor/ckeditor4/concrete5inline', $coreAssetDir . 'concrete5inline/styles.css');
     $assetList->registerGroup('editor/ckeditor4/concrete5inline', array(array('javascript', 'editor/ckeditor4/concrete5inline'), array('css', 'editor/ckeditor4/concrete5inline')));
     $assetList->register('javascript', 'editor/ckeditor4/concrete5filemanager', $coreAssetDir . 'concrete5filemanager/register.js');
     $assetList->register('css', 'editor/ckeditor4/concrete5filemanager', $coreAssetDir . 'concrete5filemanager/styles.css');
     $assetList->registerGroup('editor/ckeditor4/concrete5filemanager', array(array('javascript', 'editor/ckeditor4/concrete5filemanager'), array('css', 'editor/ckeditor4/concrete5filemanager')));
     $assetList->register('javascript', 'editor/ckeditor4/concrete5uploadimage', $coreAssetDir . 'concrete5uploadimage/register.js');
     $assetList->registerGroup('editor/ckeditor4/concrete5uploadimage', array(array('javascript', 'editor/ckeditor4/concrete5uploadimage')));
     $assetList->register('javascript', 'editor/ckeditor4/concrete5link', $coreAssetDir . 'concrete5link/register.js');
     $assetList->registerGroup('editor/ckeditor4/concrete5link', array(array('javascript', 'editor/ckeditor4/concrete5link')));
     $assetList->register('javascript', 'editor/ckeditor4/normalizeonchange', $coreAssetDir . 'normalizeonchange/register.js');
     $assetList->registerGroup('editor/ckeditor4/normalizeonchange', array(array('javascript', 'editor/ckeditor4/normalizeonchange')));
     $assetList->register('javascript', 'editor/ckeditor4/concrete5styles', $coreAssetDir . 'concrete5styles/register.js');
     $assetList->register('css', 'editor/ckeditor4/concrete5styles', $coreAssetDir . 'concrete5styles/styles.css');
     $assetList->registerGroup('editor/ckeditor4/concrete5styles', array(array('javascript', 'editor/ckeditor4/concrete5styles'), array('css', 'editor/ckeditor4/concrete5styles')));
     $plugin = new Plugin();
     $plugin->setKey('concrete5inline');
     $plugin->setName(t('concrete5 Inline'));
     $plugin->requireAsset('editor/ckeditor4/concrete5inline');
     $pluginManager->register($plugin);
     $plugin = new Plugin();
     $plugin->setKey('concrete5filemanager');
     $plugin->setName(t('concrete5 File Browser'));
     $plugin->requireAsset('editor/ckeditor4/concrete5filemanager');
     $pluginManager->register($plugin);
     $plugin = new Plugin();
     $plugin->setKey('concrete5uploadimage');
     $plugin->setName(t('concrete5 Upload Image'));
     $plugin->requireAsset('editor/ckeditor4/concrete5uploadimage');
     $pluginManager->register($plugin);
     $plugin = new Plugin();
     $plugin->setKey('concrete5link');
     $plugin->setName(t('concrete5 Link'));
     $plugin->requireAsset('editor/ckeditor4/concrete5link');
     $pluginManager->register($plugin);
     $plugin = new Plugin();
     $plugin->setKey('normalizeonchange');
     $plugin->setName(t('Normalize On Change'));
     $plugin->requireAsset('editor/ckeditor4/normalizeonchange');
     $pluginManager->register($plugin);
     $plugin = new Plugin();
     $plugin->setKey('concrete5styles');
     $plugin->setName(t('concrete5 Styles'));
     $plugin->requireAsset('editor/ckeditor4/concrete5styles');
     $pluginManager->register($plugin);
 }
コード例 #3
0
 protected function registerInlinePlugin()
 {
     $assetList = \AssetList::getInstance();
     $assetList->register('javascript', 'editor/ckeditor/concrete5inline', 'assets/concrete5inline/register.js', array(), $this->pkgHandle);
     $assetList->register('css', 'editor/ckeditor/concrete5inline', 'assets/concrete5inline/styles.css', array(), $this->pkgHandle);
     $assetList->registerGroup('editor/ckeditor/concrete5inline', array(array('javascript', 'editor/ckeditor/concrete5inline'), array('css', 'editor/ckeditor/concrete5inline')));
     $plugin = new Plugin();
     $plugin->setKey('concrete5inline');
     $plugin->setName(t('Concrete5 Inline'));
     $plugin->requireAsset('editor/ckeditor/concrete5inline');
     Core::make('editor')->getPluginManager()->register($plugin);
 }
コード例 #4
0
ファイル: Plugin.php プロジェクト: ppiedaderawnet/concrete5
 public function requireAsset($assetType, $assetHandle = false)
 {
     $list = \AssetList::getInstance();
     if ($assetType instanceof Asset) {
         $this->requiredAssetGroup->addAsset($assetType);
     } elseif ($assetType && $assetHandle) {
         $ap = new AssetPointer($assetType, $assetHandle);
         $this->requiredAssetGroup->add($ap);
     } else {
         $r = $list->getAssetGroup($assetType);
         if (isset($r)) {
             $this->requiredAssetGroup->addGroup($r);
         } else {
             throw new \Exception(t('"%s" is not a valid asset group handle', $assetType));
         }
     }
 }
コード例 #5
0
ファイル: AssetTest.php プロジェクト: ceko/concrete5-1
 public function testPackageAssetURLs()
 {
     $al = AssetList::getInstance();
     $al->register('css', 'test-css', 'css/awesome.css');
     $al->register('javascript', 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', array('local' => false));
     $pkg = new Package();
     $pkg->pkgHandle = 'testing_package';
     $al->register('javascript', 'testing/tab', 'blocks/testing_block/js/tab.js', array('version' => '3.2.0', 'position' => Asset::ASSET_POSITION_HEADER, 'minify' => false, 'combine' => false), $pkg);
     $asset1 = $al->getAsset('css', 'test-css');
     $asset2 = $al->getAsset('javascript', 'testing/tab');
     $asset3 = $al->getAsset('javascript', 'jquery');
     $this->assertEquals('/path/to/server/concrete/css/awesome.css', $asset1->getAssetURL());
     $this->assertEquals('/path/to/server/packages/testing_package/blocks/testing_block/js/tab.js', $asset2->getAssetURL());
     $this->assertTrue($asset2->isAssetLocal());
     $this->assertFalse($asset3->isAssetLocal());
     $this->assertEquals('//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', $asset3->getAssetURL());
     // overrides test
     $al->register('javascript', 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/2.0/jquery.min.js', array('local' => false, 'version' => '2.0'));
     $asset3 = $al->getAsset('javascript', 'jquery');
     $this->assertEquals('//ajax.googleapis.com/ajax/libs/jquery/2.0/jquery.min.js', $asset3->getAssetURL());
 }
コード例 #6
0
 /**
  * @return Asset
  */
 public function getAsset()
 {
     $al = AssetList::getInstance();
     return $al->getAsset($this->assetType, $this->assetHandle);
 }