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


PHP PerchUtil::strip_file_name方法代码示例

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


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

示例1: rtrim

		<?php 
if ($CurrentUser->has_priv('content.pages.edit')) {
    echo '<li class="fin selected"><a href="' . PERCH_LOGINPATH . '/core/apps/content/page/edit/?id=' . PerchUtil::html($Page->id()) . '" class="icon setting">' . PerchLang::get('Page Options') . '</a></li>';
}
if ($Page->pagePath() != '*') {
    $view_page_url = rtrim($Settings->get('siteURL')->val(), '/') . $Page->pagePath();
    echo '<li class="fin">';
    echo '<a href="' . PerchUtil::html($view_page_url) . '" class="icon page assist">' . PerchLang::get('View Page') . '</a>';
    echo '</li>';
}
?>
    </ul>
    
    <?php 
if ($details['pageSubpagePath'] == '') {
    $details['pageSubpagePath'] = PerchUtil::strip_file_name($Page->pagePath());
}
$Pages->find_site_path();
if (!PERCH_RUNWAY && !file_exists(PerchUtil::file_path(PERCH_SITEPATH . $details['pageSubpagePath']))) {
    $Alert->set('error', PerchLang::get('Subpage folder does not exist'));
    $Alert->output();
    PerchUtil::debug(PerchUtil::file_path(PERCH_SITEPATH . $details['pageSubpagePath']));
}
?>

    
    <form method="post" action="<?php 
echo PerchUtil::html($Form->action());
?>
" class="magnetic-save-bar">
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:30,代码来源:page.edit.post.php

示例2: move_file

 public function move_file($new_location)
 {
     $new_location = PerchUtil::file_path($new_location);
     $new_location = str_replace(PERCH_LOGINPATH, '/', $new_location);
     $new_location = str_replace('\\', '/', $new_location);
     $new_location = str_replace('..', '', $new_location);
     $new_location = str_replace('//', '/', $new_location);
     $old_path = PERCH_SITEPATH . $this->pagePath();
     $new_path = PerchUtil::file_path(PERCH_SITEPATH . '/' . ltrim($new_location, '/'));
     if ($old_path != $new_path) {
         if (file_exists($old_path)) {
             if (!file_exists($new_path)) {
                 $new_dir = PerchUtil::strip_file_name($new_path);
                 if (!file_exists($new_dir)) {
                     mkdir($new_dir, 0755, true);
                 }
                 if (is_writable($new_dir)) {
                     if (rename($old_path, $new_path)) {
                         // Is it a reference to a master page? If so, update the include
                         $contents = file_get_contents($new_path);
                         $pattern = '#' . preg_quote("<?php include(str_replace('/', DIRECTORY_SEPARATOR, 'XXX')); ?>") . '#';
                         $pattern = str_replace('XXX', '([a-zA-Z/\\.-]+)', $pattern);
                         if (preg_match($pattern, $contents, $match)) {
                             $current_path = $match[1];
                             $template_dir = PERCH_TEMPLATE_PATH . '/pages';
                             $template_path = str_replace(PERCH_SITEPATH . DIRECTORY_SEPARATOR, '', PERCH_TEMPLATE_PATH) . '/pages/';
                             // normalise
                             $current_path = str_replace(DIRECTORY_SEPARATOR, '/', $current_path);
                             $template_dir = str_replace(DIRECTORY_SEPARATOR, '/', $template_dir);
                             $template_path = str_replace(DIRECTORY_SEPARATOR, '/', $template_path);
                             $parts = explode($template_path, $current_path);
                             if (PerchUtil::count($parts)) {
                                 $master_page_template = $parts[1];
                                 $Pages = new PerchContent_Pages();
                                 $a = PerchUtil::file_path($template_dir . '/' . $master_page_template);
                                 $b = PerchUtil::file_path(dirname($new_path));
                                 $new_include_path = $Pages->get_relative_path($a, $b);
                                 $new_include = '<' . '?php include(str_replace(\'/\', DIRECTORY_SEPARATOR, \'' . $new_include_path . '\')); ?' . '>';
                                 /*
                                 $new_include .= '<' . '?php /* '.PHP_EOL;
                                 $new_include .= 'Current path: '.$current_path.PHP_EOL;
                                 $new_include .= 'Template dir: '.$template_dir.PHP_EOL;
                                 $new_include .= 'Template path: '.$template_path.PHP_EOL;
                                 $new_include .= 'Master page template: '.$master_page_template.PHP_EOL;
                                 $new_include .= 'A: '.$a.PHP_EOL;
                                 $new_include .= 'B: '.$b.PHP_EOL;
                                 $new_include .= 'New include path: '.$new_include_path.PHP_EOL;
                                 $new_include .= 'Parts: '.print_r($parts, true).PHP_EOL;
                                 $new_include .= PHP_EOL.' *'.'/ ?' . '>';
                                 */
                                 file_put_contents($new_path, str_replace($match[0], $new_include, $contents));
                             }
                         } else {
                             // Else just update the Perch runtime.
                             $pattern = '#' . preg_quote("include(__Y____X__" . trim(PERCH_LOGINPATH, '/') . "__DS__runtime.php__Y__);") . '#';
                             $pattern = str_replace('__X__', '([a-zA-Z/\\.-]*)', $pattern);
                             $pattern = str_replace('__Y__', '[\'\\"]', $pattern);
                             $pattern = str_replace('__DS__', '[\\\\/]', $pattern);
                             if (preg_match($pattern, $contents, $match)) {
                                 PerchUtil::debug($match);
                                 $Pages = new PerchContent_Pages();
                                 $a = PerchUtil::file_path(PERCH_PATH . '/runtime.php');
                                 $b = PerchUtil::file_path(dirname($new_path));
                                 $new_include_path = $Pages->get_relative_path($a, $b);
                                 PerchUtil::debug('New include path: ' . $new_include_path);
                                 $new_include = "include('{$new_include_path}');";
                                 file_put_contents($new_path, str_replace($match[0], $new_include, $contents));
                             }
                         }
                         return array(true, false);
                     } else {
                         return array(false, 'The page could not be moved.');
                     }
                 } else {
                     return array(false, 'The destination folder could not be written to, so the page cannot be moved.');
                 }
             } else {
                 return array(false, 'A page file already exists at the new location.');
             }
         } else {
             return array(false, 'No page file exists at that location to move.');
         }
     } else {
         // It's ok, as the file is already where they want it to be.
         return array(true, false);
     }
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:87,代码来源:PerchContent_Page.class.php

示例3: create_without_file

 /**
  * Create a new page, either from an existing page, or just as a nav link
  *
  * @param string $data
  * @return void
  * @author Drew McLellan
  */
 public function create_without_file($data)
 {
     $create_folder = false;
     if (isset($data['create_folder'])) {
         $create_folder = $data['create_folder'];
         unset($data['create_folder']);
     }
     $link_only = false;
     // is this a URL or just local file?
     if (isset($data['file_name'])) {
         $url = parse_url($data['file_name']);
         if ($url && is_array($url) && isset($url['scheme']) && $url['scheme'] != '') {
             $link_only = true;
             $url = $data['file_name'];
             unset($data['file_name']);
         }
     }
     // Find the parent page
     $ParentPage = $this->find($data['pageParentID']);
     if ($link_only) {
         $data['pagePath'] = $url;
         $data['pageNavOnly'] = '1';
         // Insert into the DB
         $Page = $this->create($data);
         // Set its position in the tree
         if (is_object($Page)) {
             if (is_object($ParentPage)) {
                 $Page->update_tree_position($ParentPage->id());
             }
             return $Page;
         }
     } else {
         // use the file name given (if stated) or create from the title. Sans extension.
         if (isset($data['file_name'])) {
             $file_name = $data['file_name'];
             unset($data['file_name']);
         } else {
             $file_name = PerchUtil::urlify($data['pageTitle']);
         }
         $this->find_site_path();
         // Find the parent page
         $ParentPage = $this->find($data['pageParentID']);
         if (is_object($ParentPage)) {
             if (PERCH_RUNWAY) {
                 $pageSection = $ParentPage->pageSortPath();
             } else {
                 if ($ParentPage->pageSubpagePath()) {
                     $pageSection = $ParentPage->pageSubpagePath();
                 } else {
                     $pageSection = PerchUtil::strip_file_name($ParentPage->pagePath());
                 }
             }
             // Copy subpage info
             $data['pageSubpageRoles'] = $ParentPage->pageSubpageRoles();
             $data['pageSubpageTemplates'] = $ParentPage->pageSubpageTemplates();
             $parentPageID = $ParentPage->id();
             $data['pageDepth'] = $ParentPage->pageDepth() + 1;
         } else {
             $pageSection = '/';
             $parentPageID = 0;
             $data['pageParentID'] = '0';
             $data['pageDepth'] = '1';
         }
         if (!isset($data['templateID']) || $data['templateID'] == '') {
             $data['templateID'] = 0;
         }
         $dir = PERCH_SITEPATH . str_replace('/', DIRECTORY_SEPARATOR, $pageSection);
         // Get the new file path
         $new_url = $pageSection . '/' . str_replace($dir, '', $file_name);
         $r = str_replace(DIRECTORY_SEPARATOR, '/', $new_url);
         while (strpos($r, '//') !== false) {
             $r = str_replace('//', '/', $r);
         }
         $data['pagePath'] = $r;
         // Insert into the DB
         $Page = $this->create($data);
         // Set its position in the tree
         if (is_object($Page)) {
             $Page->update_tree_position($parentPageID);
             if (PERCH_RUNWAY) {
                 // Grab the template this page uses
                 $Templates = new PerchContent_PageTemplates();
                 $Template = $Templates->find($Page->templateID());
                 if (is_object($Template)) {
                     // Add to nav groups
                     if ($Template->templateNavGroups() != '') {
                         $Page->update_navgroups(explode(',', $Template->templateNavGroups()));
                     }
                     // Copy page options?
                     if ($Template->optionsPageID() != '0') {
                         $CopyPage = $this->find($Template->optionsPageID());
                         if (is_object($CopyPage)) {
                             $sql = 'INSERT INTO ' . PERCH_DB_PREFIX . 'content_regions (
//.........这里部分代码省略.........
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:101,代码来源:PerchContent_Pages.class.php


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