本文整理匯總了PHP中Dir::ensure方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dir::ensure方法的具體用法?PHP Dir::ensure怎麽用?PHP Dir::ensure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Dir
的用法示例。
在下文中一共展示了Dir::ensure方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parseTemplate
private function parseTemplate()
{
$cachename = $this->getCacheName();
$serializedName = $cachename . '.serialized';
umask(02);
$cache = Settings::get(View::CACHE, true);
$parsed = null;
if (!$cache || !is_file($cachename) || !is_file($serializedName)) {
$phtml = file_get_contents($this->getTemplateFile());
$parser = new Phtml();
$parsed = $parser->read($phtml, $this->getTemplate());
Dir::ensure(dirname($cachename));
file_put_contents($serializedName, serialize($parsed));
$parsed->toPhp($cachename);
}
return $parsed;
}
示例2: tagCollect
protected function tagCollect($attrs, $view)
{
if (Settings::get(Settings::DEBUG, false) && Request::get('__nominify', false)) {
return self::$jsScripts;
}
Dir::ensure(Pimple::instance()->getSiteDir() . 'cache/js/');
$cacheFile = Pimple::instance()->getSiteDir() . 'cache/js/counter.tmp';
if (File::exists($cacheFile)) {
$stamp = file_get_contents($cacheFile);
} else {
$stamp = time();
file_put_contents($cacheFile, $stamp);
}
$ctrl = Pimple::instance()->getControllerInstance();
$skipLayout = 0;
if ($ctrl && $ctrl->getSkipLayout()) {
$skipLayout = 1;
}
return self::$jsScripts . sprintf('<script type="text/javascript" src="%s"></script>', Url::makeLink('pimple', 'javascript', array('view' => Pimple::instance()->getViewFile(), 'stamp' => $stamp, 'skipLayout' => $skipLayout))) . "\n";
}
示例3: css
/**
* Outputs concatenated CSS for the specified view
* @param string view | the view - optional
*/
public function css()
{
$this->setContentType('text/css; charset=utf-8;');
$this->setCache(Date::SPAN_MONTH);
require_once Pimple::instance()->getBaseDir() . 'lib/Stylesheet.php';
$cacheDir = Pimple::instance()->getSiteDir() . 'cache/css/';
Dir::ensure($cacheDir);
$templates = array();
if (!Request::get('skipLayout', false)) {
$templates[] = 'application';
}
$view = Request::get('view', false);
if ($view) {
$templates[] = $view;
}
$used = array();
$isDebug = Settings::get(Settings::DEBUG, false);
foreach ($templates as $template) {
$cacheFile = $cacheDir . $template . '.css';
echo "/* {$template} */\n";
if ($isDebug) {
$view = new View($template);
$files = $view->getInternalCssFiles();
echo "/*FILES:\n\t" . implode("\n\t", $files) . '*/' . chr(10);
foreach ($files as $file) {
if (in_array($file, $used) || String::StartsWith($file, "http://") || String::StartsWith($file, "https://")) {
continue;
}
$used[] = $file;
echo "/*FILE:" . basename($file) . '*/' . chr(10) . Stylesheet::minify($file) . chr(10);
}
} else {
Dir::ensure(dirname($cacheFile));
if (!is_file($cacheFile)) {
File::truncate($cacheFile);
$view = new View($template);
$files = $view->getInternalCssFiles();
File::append($cacheFile, "/*FILES:\n\t" . implode("\n\t", $files) . '*/' . chr(10));
foreach ($files as $file) {
if (in_array($file, $used) || String::StartsWith($file, "http://") || String::StartsWith($file, "https://")) {
continue;
}
$used[] = $file;
File::append($cacheFile, "/*FILE:" . basename($file) . '*/' . chr(10) . Stylesheet::minify($file) . chr(10));
}
}
echo file_get_contents($cacheFile);
}
}
Pimple::end();
}
示例4: define
require_once 'lib/Controller.php';
require_once 'lib/controller/PimpleController.php';
//Handlers
require_once 'lib/handlers/MessageHandler.php';
require_once 'lib/handlers/SessionHandler.php';
require_once 'lib/handlers/AccessHandler.php';
//Main class
require_once 'lib/Pimple.php';
require_once 'lib/TagLib.php';
require_once 'lib/taglib/CoreTagLib.php';
require_once 'lib/taglib/ValueTagLib.php';
require_once 'lib/taglib/BasicTagLib.php';
require_once 'lib/taglib/FormTagLib.php';
require_once 'lib/taglib/WidgetTagLib.php';
require_once 'lib/taglib/JavascriptTagLib.php';
require_once 'lib/taglib/UserTagLib.php';
require_once 'lib/taglib/JSTemplateTagLib.php';
//Add pimple lib to include path
IncludePath::instance()->addPath(Pimple::instance()->getBaseDir() . '/lib');
//Add pimple ressources lib to include path
IncludePath::instance()->addPath(Pimple::instance()->getRessource('lib/'), 1);
define('CACHEDIR', Dir::normalize(BASEDIR) . 'cache');
Dir::ensure(CACHEDIR);
Pimple::instance()->registerTagLib('c', new CoreTagLib());
Pimple::instance()->registerTagLib('val', new ValueTagLib());
Pimple::instance()->registerTagLib('p', new BasicTagLib());
Pimple::instance()->registerTagLib('user', new UserTagLib());
Pimple::instance()->registerTagLib('f', new FormTagLib());
Pimple::instance()->registerTagLib('w', new WidgetTagLib());
Pimple::instance()->registerTagLib('js', new JavascriptTagLib());
Pimple::instance()->registerTagLib('jst', new JSTemplateTagLib());
示例5: tagStylesheet
/**
* Include a style sheet
* @param boolean collect | instead of including style sheets - output them here (other args are ignored)
* @param boolean local | if false - assumes the stylesheet is found within pimple - defaults to true
* @param string path | path to stylesheet - relative to site root or pimple/www/ (see local)
*/
protected function tagStylesheet($attrs, $view)
{
if ($attrs->collect == 'true') {
if (Settings::get(Settings::DEBUG, false) && Request::get('__nominify', false)) {
return '';
}
$ctrl = Pimple::instance()->getControllerInstance();
$skipLayout = 0;
if ($ctrl && $ctrl->getSkipLayout()) {
$skipLayout = 1;
}
Dir::ensure(Pimple::instance()->getSiteDir() . 'cache/css/');
$cacheFile = Pimple::instance()->getSiteDir() . 'cache/css/counter.tmp';
if (File::exists($cacheFile)) {
$stamp = file_get_contents($cacheFile);
} else {
$stamp = time();
file_put_contents($cacheFile, $stamp);
}
return sprintf('<link href="%s" rel="stylesheet" type="text/css" />', Url::makeLink('pimple', 'css', array('view' => Pimple::instance()->getViewFile(), 'stamp' => $stamp, 'skipLayout' => $skipLayout))) . "\n";
}
if ($attrs->local == 'false') {
$base = Settings::get(Pimple::URL);
if ($view != null) {
$view->addCssFile(Pimple::instance()->getBaseDir() . 'www/' . $attrs->path);
}
} else {
if ($view != null) {
$view->addCssFile(Pimple::instance()->getSiteDir() . $attrs->path);
}
$base = Url::basePath();
}
$url = $base . $attrs->path;
if ($attrs->inline != 'true') {
if ($view == null || Settings::get(Settings::DEBUG, false) && Request::get('__nominify', false)) {
return sprintf('<link href="%s" rel="stylesheet" type="text/css" />', $url);
}
return '';
}
$path = Dir::normalize(BASEDIR) . $attrs->path;
$css = file_get_contents($path);
$css = str_replace('url(../', "url({$base}", $css);
return sprintf('<style type="text/css">%s</style>', $css);
}