本文整理汇总了PHP中App::themePath方法的典型用法代码示例。如果您正苦于以下问题:PHP App::themePath方法的具体用法?PHP App::themePath怎么用?PHP App::themePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::themePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getFullAssetPath
protected function _getFullAssetPath($path)
{
$filepath = preg_replace('/^' . preg_quote($this->Helper->request->webroot, '/') . '/', '', urldecode($path));
$webrootPath = WWW_ROOT . str_replace('/', DS, $filepath);
if (file_exists($webrootPath)) {
//@codingStandardsIgnoreStart
return $webrootPath;
//@codingStandardsIgnoreEnd
}
$segments = explode('/', ltrim($filepath, '/'));
if ($segments[0] === 'theme') {
$theme = $segments[1];
unset($segments[0], $segments[1]);
$themePath = App::themePath($theme) . 'webroot' . DS . implode(DS, $segments);
//@codingStandardsIgnoreStart
return $themePath;
//@codingStandardsIgnoreEnd
} else {
$plugin = Inflector::camelize($segments[0]);
if (CakePlugin::loaded($plugin)) {
unset($segments[0]);
$pluginPath = CakePlugin::path($plugin) . 'webroot' . DS . implode(DS, $segments);
//@codingStandardsIgnoreStart
return $pluginPath;
//@codingStandardsIgnoreEnd
}
}
return false;
}
示例2: getAssetFile
/**
* Builds asset file path based off url
*
* @param string $url
* @return string Absolute path for asset file
*/
static function getAssetFile($url)
{
$parts = explode('/', $url);
if ($parts[0] === 'theme') {
$file = '';
$fileFragments = explode(',', $url);
$fileNumber = count($fileFragments);
foreach ($fileFragments as $k => $fileFragment) {
$fileParts = explode('/', $fileFragment);
unset($fileParts[0], $fileParts[1]);
if ($fileNumber == $k + 1) {
$file .= urldecode(implode(DS, $fileParts));
} else {
$file .= urldecode(implode(DS, $fileParts)) . ',';
}
}
$themeName = $parts[1];
$path = Configure::read('App.www_root') . 'theme' . DS . $themeName;
if (!file_exists($path)) {
$path = App::themePath($themeName) . 'webroot';
}
return array($path, $file);
}
$plugin = Inflector::camelize($parts[0]);
if (CakePlugin::loaded($plugin)) {
unset($parts[0]);
$fileFragment = urldecode(implode(DS, $parts));
$pluginWebroot = CakePlugin::path($plugin) . 'webroot';
return array($pluginWebroot, $fileFragment);
} else {
return array(WWW_ROOT, $_GET['f']);
}
}
示例3: css
/**
* @param array $scripts to minify
* @param array $options theme
*/
public function css($scripts, $options = array())
{
if (Configure::read('debug') || Configure::read('Minify.minify') === false) {
return $this->Html->css($scripts);
}
$options = Set::merge(array('theme' => $this->_View->theme, 'plugin' => false, 'subdir' => false), $options);
extract($options);
$path = APP;
if (!empty($theme)) {
$path = App::themePath($theme);
} elseif (!empty($plugin)) {
$path = CakePlugin::pluginPath($plugin);
}
$targetDirectory = $path . DS . 'webroot' . DS . 'css' . DS;
$outputfile = $targetDirectory . $subdir . DS . 'minified-' . sha1(join(':', $scripts)) . '.css';
if (file_exists($outputfile)) {
$outputfile = str_replace($targetDirectory, '', $outputfile);
return $this->Html->css($outputfile);
}
$contents = '';
foreach ($scripts as $script) {
$file = $targetDirectory . $script;
if (!preg_match('/\\.css$/', $file)) {
$file .= '.css';
}
$contents .= file_get_contents($file);
}
$contents = Minify_CSS_Compressor::process($contents);
file_put_contents($outputfile, $contents);
return $this->Html->css($scripts);
}
示例4: getList
/**
* theme list (array)
*
* @param Controller $controller controller class object
* @return array
*/
public function getList(Controller $controller)
{
$themeList = array();
//テーマの情報を格納
$dir = realpath(App::themePath('')) . '/';
//フォルダの中を取得
$dirList = scandir($dir, 1);
//フォルダ名だけのリストをつくる
$package['snapshot'] = '';
foreach ($dirList as $d) {
if (is_dir($dir . $d) && ($d != '.' && $d != '..')) {
if (is_file($dir . $d . '/theme.json')) {
$file = file_get_contents($dir . $d . '/theme.json');
$package = json_decode($file, true);
if (is_file(App::themePath($d) . 'webroot/snapshot.jpg')) {
$package['snapshot'] = '/theme/' . $d . '/snapshot.jpg';
} elseif (is_file(App::themePath($d) . 'webroot/snapshot.png')) {
$package['snapshot'] = '/theme/' . $d . '/snapshot.png';
}
$package['key'] = $d;
$themeList[$d] = $package;
$package['snapshot'] = '';
}
}
}
ksort($themeList);
$this->ThemeList = $themeList;
return $this->ThemeList;
}
示例5: isThemeBootstrapMinCss
/**
* cssの存在チェック
*
* @param Controller $controller controller object
* @return bool
*/
public function isThemeBootstrapMinCss(Controller $controller)
{
$filePath = App::themePath($controller->theme) . 'webroot/css/bootstrap.min.css';
if (is_file(realpath($filePath))) {
return true;
}
return false;
}
示例6: _theme
protected function _theme($asset)
{
$parts = explode('/', $asset);
if ($parts[0] !== 'theme') {
return false;
}
$themeName = $parts[1];
unset($parts[0], $parts[1]);
$fileFragment = implode(DS, $parts);
$path = App::themePath($themeName) . 'webroot' . DS;
return $this->_exists($path . $fileFragment);
}
示例7: testRenderOverridenAdminFormWithTheme
/**
* testRenderOverridenAdminFormWithTheme
*/
public function testRenderOverridenAdminFormWithTheme()
{
$theme = 'Mytheme';
$this->controller->theme = $theme;
$filePath = App::themePath($theme) . 'TestApp' . DS . 'admin_edit.ctp';
$expected = '<h1>I should be displayed</h1>';
$File = new File($filePath, true, 0777);
$File->write($expected);
$File->close();
$result = $this->testAction('/admin/test_app/edit', array('return' => 'contents'));
$File->delete();
$this->assertContains($expected, trim($result));
}
示例8: test
public function test()
{
pr(App::themePath('purple'));
pr(App::path('Model'));
debug(App::paths());
pr(App::path('Component', 'DebugKit'));
debug(env('document_root'));
debug(h('fengjie ; fengjie '));
LogError('fengjie');
pr(array('fengjie', 'fengjie'));
debug(h('fengjie ; fengjie '));
pr(YEAR);
pr(HOUR);
}
示例9: getThemeLayouts
public function getThemeLayouts()
{
$themes = $this->Croogo->getThemes();
$available = array();
foreach ($themes as $theme) {
if ($theme == 'default') {
continue;
}
$path = App::themePath($theme);
$layouts = $this->_getLayouts($path);
$available[$theme] = compact('path', 'layouts');
}
return $available;
}
示例10: getThemeLayouts
public function getThemeLayouts()
{
$themes = $this->Croogo->getThemes();
$available = array();
/* Get only active Theme & filter it by Content Type */
if (Configure::read('Switcher.filterByContentType')) {
$themes = [Configure::read('Site.theme')];
}
foreach ($themes as $theme) {
if ($theme == 'default') {
continue;
}
$path = App::themePath($theme);
$layouts = $this->_getLayouts($path);
$available[$theme] = compact('path', 'layouts');
}
return $available;
}
示例11: beforeDispatch
/**
* Checks if a requested asset exists and sends it to the browser
*
* @param CakeEvent $event
* containing the request and response object
* @return CakeResponse if the client is requesting a recognized asset, null otherwise
*/
public function beforeDispatch($event)
{
$url = $event->data['request']->url;
$response = $event->data['response'];
if (strpos($url, '..') !== false || strpos($url, '.') === false) {
return;
}
if ($result = $this->_filterAsset($event)) {
$event->stopPropagation();
return $result;
}
$pathSegments = explode('.', $url);
$ext = array_pop($pathSegments);
$parts = explode('/', $url);
$assetFile = null;
if ($parts[0] === 'theme') {
$themeName = $parts[1];
unset($parts[0], $parts[1]);
$fileFragment = urldecode(implode(DS, $parts));
$path = App::themePath($themeName) . 'webroot' . DS;
if (file_exists($path . $fileFragment)) {
$assetFile = $path . $fileFragment;
}
} else {
$plugin = Inflector::camelize($parts[0]);
if (CakePlugin::loaded($plugin)) {
unset($parts[0]);
$fileFragment = urldecode(implode(DS, $parts));
$pluginWebroot = CakePlugin::path($plugin) . 'webroot' . DS;
if (file_exists($pluginWebroot . $fileFragment)) {
$assetFile = $pluginWebroot . $fileFragment;
}
}
}
if ($assetFile !== null) {
$event->stopPropagation();
$response->modified(filemtime($assetFile));
if (!$response->checkNotModified($event->data['request'])) {
$this->_deliverAsset($response, $assetFile, $ext);
}
return $response;
}
}
示例12: _getAssetFile
/**
* Builds asset file path based off url
*
* @param string $url
* @return string Absolute path for asset file
*/
protected function _getAssetFile($url)
{
$parts = explode('/', $url);
// start zuha addition
$path = App::themePath($parts[1]) . 'webroot' . DS;
$fileFragment = urldecode(implode(DS, $parts));
if (file_exists($path . $fileFragment)) {
return $path . $fileFragment;
}
// copied directly from Cake/Routing/Filter/AssetDispatcher.php
$parts = explode('/', $url);
if ($parts[0] === 'theme') {
$themeName = $parts[1];
unset($parts[0], $parts[1]);
$fileFragment = implode(DS, $parts);
$path = App::themePath($themeName) . 'webroot' . DS;
return str_replace('//', '/', $path . $fileFragment);
// and added this one fix
}
return parent::_getAssetFile($url);
}
示例13: _setupViewPaths
protected function _setupViewPaths(Controller $controller)
{
$defaultViewPaths = App::path('View');
$pos = array_search(APP . 'View' . DS, $defaultViewPaths);
if ($pos !== false) {
$viewPaths = array_splice($defaultViewPaths, 0, $pos + 1);
} else {
$viewPaths = $defaultViewPaths;
}
if ($controller->theme) {
$themePath = App::themePath($controller->theme);
$viewPaths[] = $themePath;
if ($controller->plugin) {
$viewPaths[] = $themePath . 'Plugin' . DS . $controller->plugin . DS;
}
}
if ($controller->plugin) {
$viewPaths = array_merge($viewPaths, App::path('View', $controller->plugin));
}
$viewPaths = array_merge($viewPaths, $defaultViewPaths);
return $viewPaths;
}
示例14: testFromAsset
public function testFromAsset()
{
$Asset = new CssAsset('css/default.css', $this->file, $this->path);
$result = AssetFactory::fromAsset($Asset, 'bundle');
$this->assertInstanceOf('Asset', $result);
$this->assertEquals('css/bundle.css', $result->url);
$this->assertEquals($this->path . 'css' . DS . 'bundle.css', $result->file);
$Asset = new CssAsset('css/app/bundle.css', $this->file, $this->path);
$result = AssetFactory::fromAsset($Asset, '../bundle');
$this->assertInstanceOf('Asset', $result);
$this->assertEquals('css/bundle.css', $result->url);
$this->assertEquals($this->path . 'css' . DS . 'bundle.css', $result->file);
$Asset = new CssAsset('css/default.css', $this->file, $this->path);
$result = AssetFactory::fromAsset($Asset, 'app/bundle');
$this->assertInstanceOf('Asset', $result);
$this->assertEquals('css/app/bundle.css', $result->url);
$this->assertEquals($this->path . 'css' . DS . 'app' . DS . 'bundle.css', $result->file);
$result = AssetFactory::fromAsset($Asset, '/theme/admin/css/bundle');
$this->assertInstanceOf('Asset', $result);
$this->assertEquals('theme/admin/css/bundle.css', $result->url);
$this->assertEquals(App::themePath('admin') . 'webroot' . DS . 'css' . DS . 'bundle.css', $result->file);
}
示例15: testNotModified
/**
* Tests that $response->checkNotModified() is called and bypasses
* file dispatching
*
* @return void
*/
public function testNotModified()
{
$filter = new AssetDispatcher();
Configure::write('Asset.filter', array('js' => '', 'css' => ''));
App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)));
$time = filemtime(App::themePath('TestTheme') . 'webroot' . DS . 'img' . DS . 'cake.power.gif');
$time = new DateTime('@' . $time);
$response = $this->getMock('CakeResponse', array('send', 'checkNotModified'));
$request = new CakeRequest('theme/test_theme/img/cake.power.gif');
$response->expects($this->once())->method('checkNotModified')->with($request)->will($this->returnValue(true));
$event = new CakeEvent('DispatcherTest', $this, compact('request', 'response'));
ob_start();
$this->assertSame($response, $filter->beforeDispatch($event));
ob_end_clean();
$this->assertEquals(200, $response->statusCode());
$this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->modified());
$response = $this->getMock('CakeResponse', array('_sendHeader', 'checkNotModified'));
$request = new CakeRequest('theme/test_theme/img/cake.power.gif');
$response->expects($this->once())->method('checkNotModified')->with($request)->will($this->returnValue(true));
$response->expects($this->never())->method('send');
$event = new CakeEvent('DispatcherTest', $this, compact('request', 'response'));
$this->assertSame($response, $filter->beforeDispatch($event));
$this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->modified());
}