当前位置: 首页>>代码示例>>PHP>>正文


PHP convertSlash函数代码示例

本文整理汇总了PHP中convertSlash函数的典型用法代码示例。如果您正苦于以下问题:PHP convertSlash函数的具体用法?PHP convertSlash怎么用?PHP convertSlash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了convertSlash函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testConvertSlash

 /**
  * test convertSlash()
  *
  * @access public
  * @return void
  */
 function testConvertSlash()
 {
     $result = convertSlash('\\path\\to\\location\\');
     $expected = '\\path\\to\\location\\';
     $this->assertEqual($result, $expected);
     $result = convertSlash('/path/to/location/');
     $expected = 'path_to_location';
     $this->assertEqual($result, $expected);
 }
开发者ID:surfingtonio,项目名称:flashub.com,代码行数:15,代码来源:basics.test.php

示例2: __writeFile

    /**
     * Write a cached version of the file
     *
     * @param string $content
     * @param sting $timestamp
     * @return cached view
     * @access private
     */
    function __writeFile($content, $timestamp)
    {
        $now = time();
        if (is_numeric($timestamp)) {
            $cacheTime = $now + $timestamp;
        } else {
            $cacheTime = strtotime($timestamp, $now);
        }
        $cache = convertSlash($this->here);
        if (empty($cache)) {
            return;
        }
        $cache = $cache . '.php';
        $file = '<!--cachetime:' . $cacheTime . '--><?php';
        if (empty($this->plugin)) {
            $file .= '
			loadController(\'' . $this->view->name . '\');
			loadModels();
			';
        } else {
            $file .= '
			if (!class_exists(\'AppController\')) {
				if (file_exists(\'' . APP . 'app_controller.php\')) {
					require(\'' . APP . 'app_controller.php\');
				} else {
					require(\'' . CAKE . 'app_controller.php\');
				}
			}
			loadPluginController(\'' . $this->plugin . '\',\'' . $this->view->name . '\');
			loadPluginModels(\'' . $this->plugin . '\');
			';
        }
        $file .= '$this->controller = new ' . $this->view->name . 'Controller();
        			$this->controller->plugin = \'' . $this->plugin . '\';
        			$this->controller->_initComponents();
					$this->helpers = unserialize(\'' . serialize($this->view->helpers) . '\');
					$this->base = \'' . $this->view->base . '\';
					$this->layout = \'' . $this->view->layout . '\';
					$this->webroot = \'' . $this->view->webroot . '\';
					$this->here = \'' . $this->view->here . '\';
					$this->params = unserialize(stripslashes(\'' . addslashes(serialize($this->view->params)) . '\'));
					$this->action = unserialize(\'' . serialize($this->view->action) . '\');
					$this->data = unserialize(stripslashes(\'' . addslashes(serialize($this->view->data)) . '\'));
					$this->themeWeb = \'' . $this->view->themeWeb . '\';
					$this->plugin = \'' . $this->view->plugin . '\';
					$loadedHelpers = array();
					$loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
					foreach(array_keys($loadedHelpers) as $helper)
					{
						$replace = strtolower(substr($helper, 0, 1));
						$camelBackedHelper = preg_replace(\'/\\w/\', $replace, $helper, 1);
						${$camelBackedHelper} =& $loadedHelpers[$helper];

						if(isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers))
						{
							foreach(${$camelBackedHelper}->helpers as $subHelper)
							{
								${$camelBackedHelper}->{$subHelper} =& $loadedHelpers[$subHelper];
							}
						}
						$this->loaded[$camelBackedHelper] = (${$camelBackedHelper});
					}
					?>' . $content;
        return cache('views' . DS . $cache, $file, $timestamp);
    }
开发者ID:carriercomm,项目名称:pastebin-5,代码行数:73,代码来源:cache.php

示例3: setUri

    }
} else {
    if (empty($_GET['url'])) {
        $url = null;
    } else {
        $url = $_GET['url'];
    }
}
if (strpos($url, 'ccss/') === 0) {
    include WWW_ROOT . DS . 'css.php';
    die;
}
Configure::write('debug', DEBUG);
require CAKE . 'dispatcher.php';
if (defined('CACHE_CHECK') && CACHE_CHECK === true) {
    if (empty($uri)) {
        $uri = setUri();
    }
    $filename = CACHE . 'views' . DS . convertSlash($uri) . '.php';
    if (file_exists($filename)) {
        uses(DS . 'controller' . DS . 'component', DS . 'view' . DS . 'view');
        $v = null;
        $view = new View($v);
        $view->renderCache($filename, $TIME_START);
    } elseif (file_exists(CACHE . 'views' . DS . convertSlash($uri) . '_index.php')) {
        uses(DS . 'controller' . DS . 'component', DS . 'view' . DS . 'view');
        $v = null;
        $view = new View($v);
        $view->renderCache(CACHE . 'views' . DS . convertSlash($uri) . '_index.php', $TIME_START);
    }
}
开发者ID:hilkeros,项目名称:MMM-php-cake,代码行数:31,代码来源:bootstrap.php

示例4: element

 /**
  * Wrapper for View::renderElement();
  *
  * @param string $name Name of template file in the/app/views/elements/ folder
  * @param array $params Array of data to be made available to the for rendered view (i.e. the Element)
  * @return string View::renderElement()
  * @access public
  */
 function element($name, $params = array())
 {
     if (isset($params['cache'])) {
         $expires = '+1 day';
         $key = null;
         if (is_array($params['cache'])) {
             $expires = $params['cache']['time'];
             $key = convertSlash($params['cache']['key']);
         } elseif ($params['cache'] !== true) {
             $expires = $params['cache'];
             $key = implode('_', array_keys($params));
         }
         if ($expires) {
             $plugin = null;
             if (isset($params['plugin'])) {
                 $plugin = $params['plugin'] . '_';
             }
             $cacheFile = 'element_' . $key . '_' . $plugin . convertSlash($name);
             $cache = cache('views' . DS . $cacheFile, null, $expires);
             if (is_string($cache)) {
                 return $cache;
             } else {
                 $element = $this->renderElement($name, $params);
                 cache('views' . DS . $cacheFile, $element, $expires);
                 return $element;
             }
         }
     }
     return $this->renderElement($name, $params);
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:38,代码来源:view.php

示例5: isHome

 /**
  * Function to check if an url is our homepage.
  *
  * @return bool
  */
 public function isHome()
 {
     $here = convertSlash($this->request->here);
     $installDir = convertSlash($this->request->base);
     if ($here == Configure::read('server_id') || $here == $installDir || $here == $installDir . '_' . Configure::read('server_id') || preg_match('/pages_home/', $here)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:sh1omi,项目名称:xlrstats-web-v3,代码行数:15,代码来源:XlrFunctionsHelper.php

示例6: cached

 /**
  * Outputs cached dispatch for js, css, view cache
  *
  * @param string $url Requested URL
  * @access public
  */
 function cached($url)
 {
     if (strpos($url, 'ccss/') === 0) {
         include WWW_ROOT . DS . 'css.php';
         exit;
     }
     $folders = array('js' => 'text/javascript', 'css' => 'text/css');
     $requestPath = explode('/', $url);
     if (in_array($requestPath[0], array_keys($folders))) {
         if (file_exists(VENDORS . join(DS, $requestPath))) {
             $fileModified = filemtime(VENDORS . join(DS, $requestPath));
             header("Date: " . date("D, j M Y G:i:s ", $fileModified) . 'GMT');
             header('Content-type: ' . $folders[$requestPath[0]]);
             header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT");
             header("Cache-Control: cache");
             header("Pragma: cache");
             include VENDORS . join(DS, $requestPath);
             exit;
         }
     }
     if (Configure::read('Cache.check') === true) {
         $filename = CACHE . 'views' . DS . convertSlash($url) . '.php';
         if (!file_exists($filename)) {
             $filename = CACHE . 'views' . DS . convertSlash($url) . '_index.php';
         }
         if (file_exists($filename)) {
             uses('controller' . DS . 'component', DS . 'view' . DS . 'view');
             $v = null;
             $view = new View($v);
             $view->renderCache($filename, getMicrotime());
         }
     }
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:39,代码来源:dispatcher.php

示例7: testConvertSlash

/**
 * test convertSlash()
 *
 * @return void
 */
	public function testConvertSlash() {
		$result = convertSlash('\path\to\location\\');
		$expected = '\path\to\location\\';
		$this->assertEquals($expected, $result);

		$result = convertSlash('/path/to/location/');
		$expected = 'path_to_location';
		$this->assertEquals($expected, $result);
	}
开发者ID:hungnt88,项目名称:5stars-1,代码行数:14,代码来源:BasicsTest.php

示例8: testElementCache

 function testElementCache()
 {
     $View = new TestView($this->PostsController);
     $element = 'element_name';
     $result = $View->element($element);
     $this->assertEqual($result, $element);
     $cached = false;
     $result = $View->element($element, array('cache' => '+1 second'));
     if (file_exists(CACHE . 'views' . DS . 'element_cache_' . $element)) {
         $cached = true;
         unlink(CACHE . 'views' . DS . 'element_cache_' . $element);
     }
     $this->assertTrue($cached);
     $cached = false;
     $result = $View->element($element, array('cache' => '+1 second', 'other_param' => true, 'anotherParam' => true));
     if (file_exists(CACHE . 'views' . DS . 'element_cache_other_param_anotherParam_' . $element)) {
         $cached = true;
         unlink(CACHE . 'views' . DS . 'element_cache_other_param_anotherParam_' . $element);
     }
     $this->assertTrue($cached);
     $cached = false;
     $result = $View->element($element, array('cache' => array('time' => '+1 second', 'key' => '/whatever/here')));
     if (file_exists(CACHE . 'views' . DS . 'element_' . convertSlash('/whatever/here') . '_' . $element)) {
         $cached = true;
         unlink(CACHE . 'views' . DS . 'element_' . convertSlash('/whatever/here') . '_' . $element);
     }
     $this->assertTrue($cached);
     $cached = false;
     $result = $View->element($element, array('cache' => array('time' => '+1 second', 'key' => 'whatever_here')));
     if (file_exists(CACHE . 'views' . DS . 'element_whatever_here_' . $element)) {
         $cached = true;
         unlink(CACHE . 'views' . DS . 'element_whatever_here_' . $element);
     }
     $this->assertTrue($cached);
     $this->assertEqual($result, $element);
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:36,代码来源:view.test.php


注:本文中的convertSlash函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。