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


PHP Util_Environment::normalize_path方法代码示例

本文整理汇总了PHP中Util_Environment::normalize_path方法的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment::normalize_path方法的具体用法?PHP Util_Environment::normalize_path怎么用?PHP Util_Environment::normalize_path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Util_Environment的用法示例。


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

示例1:

</code>
                <?php 
            }
            ?>
            <?php 
        }
        ?>
        </li>
        <?php 
    }
}
?>

        <li>
            <?php 
echo Util_Environment::normalize_path(WP_CONTENT_DIR);
?>
:
            <?php 
if (Util_File::is_writable_dir(WP_CONTENT_DIR)) {
    ?>
            <code><?php 
    _e('OK', 'w3-total-cache');
    ?>
</code>
            <?php 
} else {
    ?>
            <code><?php 
    _e('Not write-able', 'w3-total-cache');
    ?>
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:31,代码来源:self_test.php

示例2: rules_cache_generate_nginx

 /**
  * Generates directives for file cache dir
  *
  * @param Config  $config
  * @return string
  */
 private function rules_cache_generate_nginx($config)
 {
     $cache_root = Util_Environment::normalize_path(W3TC_CACHE_PAGE_ENHANCED_DIR);
     $cache_dir = rtrim(str_replace(Util_Environment::document_root(), '', $cache_root), '/');
     if (Util_Environment::is_wpmu()) {
         $cache_dir = preg_replace('~/w3tc.*?/~', '/w3tc.*?/', $cache_dir, 1);
     }
     $browsercache = $config->get_boolean('browsercache.enabled');
     $compression = $browsercache && $config->get_boolean('browsercache.html.compression');
     $expires = $browsercache && $config->get_boolean('browsercache.html.expires');
     $lifetime = $browsercache ? $config->get_integer('browsercache.html.lifetime') : 0;
     $cache_control = $browsercache && $config->get_boolean('browsercache.html.cache.control');
     $w3tc = $browsercache && $config->get_integer('browsercache.html.w3tc');
     $common_rules = '';
     if ($expires) {
         $common_rules .= "    expires modified " . $lifetime . "s;\n";
     }
     if ($w3tc) {
         $common_rules .= "    add_header X-Powered-By \"" . Util_Environment::w3tc_header($config) . "\";\n";
     }
     if ($expires) {
         $common_rules .= "    add_header Vary \"Accept-Encoding, Cookie\";\n";
     }
     if ($cache_control) {
         $cache_policy = $config->get_string('browsercache.html.cache.policy');
         switch ($cache_policy) {
             case 'cache':
                 $common_rules .= "    add_header Pragma \"public\";\n";
                 $common_rules .= "    add_header Cache-Control \"public\";\n";
                 break;
             case 'cache_public_maxage':
                 $common_rules .= "    add_header Pragma \"public\";\n";
                 $common_rules .= "    add_header Cache-Control \"max-age=" . $lifetime . ", public\";\n";
                 break;
             case 'cache_validation':
                 $common_rules .= "    add_header Pragma \"public\";\n";
                 $common_rules .= "    add_header Cache-Control \"public, must-revalidate, proxy-revalidate\";\n";
                 break;
             case 'cache_noproxy':
                 $common_rules .= "    add_header Pragma \"public\";\n";
                 $common_rules .= "    add_header Cache-Control \"private, must-revalidate\";\n";
                 break;
             case 'cache_maxage':
                 $common_rules .= "    add_header Pragma \"public\";\n";
                 $common_rules .= "    add_header Cache-Control \"max-age=" . $lifetime . ", public, must-revalidate, proxy-revalidate\";\n";
                 break;
             case 'no_cache':
                 $common_rules .= "    add_header Pragma \"no-cache\";\n";
                 $common_rules .= "    add_header Cache-Control \"max-age=0, private, no-store, no-cache, must-revalidate\";\n";
                 break;
         }
     }
     $rules = '';
     $rules .= W3TC_MARKER_BEGIN_PGCACHE_CACHE . "\n";
     $rules .= "location ~ " . $cache_dir . ".*html\$ {\n";
     $rules .= $common_rules;
     $rules .= "}\n";
     if ($compression) {
         $rules .= "location ~ " . $cache_dir . ".*gzip\$ {\n";
         $rules .= "    gzip off;\n";
         $rules .= "    types {}\n";
         $rules .= "    default_type text/html;\n";
         $rules .= $common_rules;
         $rules .= "    add_header Content-Encoding gzip;\n";
         $rules .= "}\n";
     }
     $rules .= W3TC_MARKER_END_PGCACHE_CACHE . "\n";
     return $rules;
 }
开发者ID:eduardodomingos,项目名称:eduardodomingos.com,代码行数:75,代码来源:PgCache_Environment.php

示例3: import_library


//.........这里部分代码省略.........
                                     $check_src = substr($check_src, 0, $qpos);
                                 }
                             }
                             if (preg_match($regexp, $check_src)) {
                                 /**
                                  * Check for already uploaded attachment
                                  */
                                 if (isset($attachments[$src])) {
                                     list($dst, $dst_url) = $attachments[$src];
                                     $result = true;
                                 } else {
                                     if ($uploads_use_yearmonth_folders) {
                                         $upload_subdir = date('Y/m', strtotime($post->post_date));
                                         $upload_dir = sprintf('%s/%s', $upload_info['basedir'], $upload_subdir);
                                         $upload_url = sprintf('%s/%s', $upload_info['baseurl'], $upload_subdir);
                                     } else {
                                         $upload_subdir = '';
                                         $upload_dir = $upload_info['basedir'];
                                         $upload_url = $upload_info['baseurl'];
                                     }
                                     $src_filename = pathinfo($src, PATHINFO_FILENAME);
                                     $src_extension = pathinfo($src, PATHINFO_EXTENSION);
                                     /**
                                      * Get available filename
                                      */
                                     for ($i = 0;; $i++) {
                                         $dst = sprintf('%s/%s%s%s', $upload_dir, $src_filename, $i ? $i : '', $src_extension ? '.' . $src_extension : '');
                                         if (!file_exists($dst)) {
                                             break;
                                         }
                                     }
                                     $dst_basename = basename($dst);
                                     $dst_url = sprintf('%s/%s', $upload_url, $dst_basename);
                                     $dst_path = ltrim(str_replace($document_root, '', Util_Environment::normalize_path($dst)), '/');
                                     if ($upload_subdir) {
                                         Util_File::mkdir($upload_subdir, 0777, $upload_info['basedir']);
                                     }
                                     $download_result = false;
                                     /**
                                      * Check if file is remote URL
                                      */
                                     if (Util_Environment::is_url($src)) {
                                         /**
                                          * Download file
                                          */
                                         if ($import_external) {
                                             $download_result = Util_Http::download($src, $dst);
                                             if (!$download_result) {
                                                 $error = 'Unable to download file';
                                             }
                                         } else {
                                             $error = 'External file import is disabled';
                                         }
                                     } else {
                                         /**
                                          * Otherwise copy file from local path
                                          */
                                         $src_path = $document_root . '/' . urldecode($src);
                                         if (file_exists($src_path)) {
                                             $download_result = @copy($src_path, $dst);
                                             if (!$download_result) {
                                                 $error = 'Unable to copy file';
                                             }
                                         } else {
                                             $error = 'Source file doesn\'t exists';
                                         }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:67,代码来源:Cdn_Core_Admin.php

示例4: get_theme_key

 /**
  * Returns theme key
  *
  * @param string  $theme_root
  * @param string  $template
  * @param string  $stylesheet
  * @return string
  */
 public static function get_theme_key($theme_root, $template, $stylesheet)
 {
     $theme_path = ltrim(str_replace(WP_CONTENT_DIR, '', Util_Environment::normalize_path($theme_root)), '/');
     return substr(md5($theme_path . $template . $stylesheet), 0, 5);
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:13,代码来源:Util_Theme.php

示例5: get_files_theme

 /**
  * Exports theme to CDN
  *
  * @return array
  */
 function get_files_theme()
 {
     /**
      * If mobile or referrer support enabled
      * we should upload whole themes directory
      */
     if ($this->_config->get_boolean('mobile.enabled') || $this->_config->get_boolean('referrer.enabled')) {
         $themes_root = get_theme_root();
     } else {
         $themes_root = get_stylesheet_directory();
     }
     $themes_root = Util_Environment::normalize_path($themes_root);
     $themes_path = ltrim(str_replace(Util_Environment::document_root(), '', $themes_root), '/');
     $files = Cdn_Util::search_files($themes_root, $themes_path, $this->_config->get_string('cdn.theme.files'));
     return $files;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:21,代码来源:Cdn_Plugin.php

示例6: realpath

 /**
  * Returns real path of given path
  *
  * @param string  $path
  * @return string
  */
 public static function realpath($path)
 {
     $path = Util_Environment::normalize_path($path);
     $parts = explode('/', $path);
     $absolutes = array();
     foreach ($parts as $part) {
         if ('.' == $part) {
             continue;
         }
         if ('..' == $part) {
             array_pop($absolutes);
         } else {
             $absolutes[] = $part;
         }
     }
     return implode('/', $absolutes);
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:23,代码来源:Util_Environment.php


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