本文整理汇总了PHP中common::NewFileIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP common::NewFileIndex方法的具体用法?PHP common::NewFileIndex怎么用?PHP common::NewFileIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common
的用法示例。
在下文中一共展示了common::NewFileIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CopyPage
/**
* Perform a page copy
*
*/
function CopyPage()
{
global $gp_index, $gp_titles, $page, $langmessage;
//existing page info
$from_title = $_POST['from_title'];
if (!isset($gp_index[$from_title])) {
message($langmessage['OOPS_TITLE']);
return false;
}
$from_index = $gp_index[$from_title];
$info = $gp_titles[$from_index];
//check the new title
$title = $_POST['title'];
$title = admin_tools::CheckPostedNewPage($title, $message);
if ($title === false) {
message($message);
return false;
}
//get the existing content
$from_file = gpFiles::PageFile($from_title);
$contents = file_get_contents($from_file);
//add to $gp_index first!
$index = common::NewFileIndex();
$gp_index[$title] = $index;
$file = gpFiles::PageFile($title);
if (!gpFiles::Save($file, $contents)) {
message($langmessage['OOPS'] . ' (File not saved)');
return false;
}
//add to gp_titles
$new_titles = array();
$new_titles[$index]['label'] = admin_tools::PostedLabel($_POST['title']);
$new_titles[$index]['type'] = $info['type'];
$gp_titles += $new_titles;
if (!admin_tools::SavePagesPHP()) {
message($langmessage['OOPS'] . ' (CP2)');
return false;
}
message($langmessage['SAVED']);
if (isset($_REQUEST['redir'])) {
$url = common::AbsoluteUrl($title, '', true, false);
$page->ajaxReplace[] = array('eval', '', 'window.setTimeout(function(){window.location="' . $url . '"},15000);');
message(sprintf($langmessage['will_redirect'], common::Link_Page($title)));
}
return $index;
}
示例2: GetPagesPHP
/**
* Set global variables ( $gp_index, $gp_titles, $gp_menu and $gpLayouts ) from _site/pages.php
*
*/
static function GetPagesPHP()
{
global $gp_index, $gp_titles, $gp_menu, $gpLayouts, $config;
$gp_index = array();
$pages = gpFiles::Get('_site/pages');
//update for < 2.0a3
if (array_key_exists('gpmenu', $pages) && array_key_exists('gptitles', $pages) && !array_key_exists('gp_titles', $pages) && !array_key_exists('gp_menu', $pages)) {
foreach ($pages['gptitles'] as $title => $info) {
$index = common::NewFileIndex();
$gp_index[$title] = $index;
$gp_titles[$index] = $info;
}
foreach ($pages['gpmenu'] as $title => $level) {
$index = $gp_index[$title];
$gp_menu[$index] = array('level' => $level);
}
return;
}
$gpLayouts = $pages['gpLayouts'];
$gp_index = $pages['gp_index'];
$gp_titles = $pages['gp_titles'];
$gp_menu = $pages['gp_menu'];
if (!is_array($gp_menu)) {
common::stop();
}
//update for 3.5,
if (!isset($gp_titles['special_gpsearch'])) {
$gp_titles['special_gpsearch'] = array();
$gp_titles['special_gpsearch']['label'] = 'Search';
$gp_titles['special_gpsearch']['type'] = 'special';
$gp_index['Search'] = 'special_gpsearch';
//may overwrite special_search settings
}
//fix the gpmenu
if (version_compare(gpFiles::$last_version, '3.0b1', '<')) {
$gp_menu = gpOutput::FixMenu($gp_menu);
// fix gp_titles for gpEasy 3.0+
// just make sure any ampersands in the label are escaped
foreach ($gp_titles as $key => $value) {
if (isset($gp_titles[$key]['label'])) {
$gp_titles[$key]['label'] = common::GetLabelIndex($key, true);
}
}
}
//title related configuration settings
if (empty($config['homepath_key'])) {
$config['homepath_key'] = key($gp_menu);
}
$config['homepath'] = common::IndexToTitle($config['homepath_key']);
}
示例3: GetPagesPHP
/**
* Set global variables ( $gp_index, $gp_titles, $gp_menu and $gpLayouts ) from _site/pages.php
*
*/
function GetPagesPHP()
{
global $gp_index, $gp_titles, $gp_menu, $dataDir, $gpLayouts;
$gp_index = array();
$pages = array();
require $dataDir . '/data/_site/pages.php';
$GLOBALS['fileModTimes']['pages.php'] = $fileModTime;
$gpLayouts = $pages['gpLayouts'];
//update for < 2.0a3
if (isset($pages['gpmenu']) && isset($pages['gptitles'])) {
//1.7b2
if (!isset($pages['gptitles']['Special_Missing'])) {
$pages['gptitles']['Special_Missing']['type'] = 'special';
$pages['gptitles']['Special_Missing']['label'] = 'Missing';
}
foreach ($pages['gptitles'] as $title => $info) {
$index = common::NewFileIndex();
$gp_index[$title] = $index;
$gp_titles[$index] = $info;
}
foreach ($pages['gpmenu'] as $title => $level) {
$index = $gp_index[$title];
$gp_menu[$index] = array('level' => $level);
}
return;
}
$gp_index = $pages['gp_index'];
$gp_titles = $pages['gp_titles'];
$gp_menu = $pages['gp_menu'];
//fix the gpmenu
if (version_compare($fileVersion, '3.0b1', '<')) {
$gp_menu = gpOutput::FixMenu($gp_menu);
// fix gp_titles for gpEasy 3.0+
// just make sure any ampersands in the label are escaped
foreach ($gp_titles as $key => $value) {
if (isset($gp_titles[$key]['label'])) {
$gp_titles[$key]['label'] = common::GetLabelIndex($key, true);
}
}
}
}
示例4: RestoreTitles
/**
* Restore $titles and return array with menu information
* @param array $titles An array of titles to be restored. After completion, it will contain only the titles that were prepared successfully
* @return array A list of restored titles that can be used for menu insertion
*
*/
function RestoreTitles(&$titles)
{
global $dataDir, $gp_index, $gp_titles;
$new_menu = array();
$new_titles = array();
foreach ($titles as $title => $empty) {
$new_title = admin_tools::CheckPostedNewPage($title, $message);
if (!$new_title) {
//message($message);
continue;
}
//add to $gp_index first for PageFile()
$index = common::NewFileIndex();
$gp_index[$new_title] = $index;
//get trash info about file
$title_info = admin_trash::GetInfo($title);
if ($title_info === false) {
unset($gp_index[$new_title]);
continue;
}
//make sure the trash file exists
$trash_file = $dataDir . '/data/_trash/' . $title_info['file'];
if (!file_exists($trash_file)) {
unset($gp_index[$new_title]);
continue;
}
//copy the trash file to the /_pages directory
$new_file = gpFiles::PageFile($new_title);
if (!copy($trash_file, $new_file)) {
unset($gp_index[$new_title]);
continue;
}
//add to $gp_titles
$gp_titles[$index] = array();
$gp_titles[$index]['label'] = $title_info['label'];
$gp_titles[$index]['type'] = $title_info['type'];
$new_menu[$index] = array();
$new_titles[$new_title] = true;
admin_trash::RestoreFile($new_title, $trash_file, $title_info);
}
$titles = $new_titles;
return $new_menu;
}
示例5: CopyPage
/**
* Perform a page copy
*
*/
function CopyPage()
{
global $gp_index, $gp_titles, $page, $langmessage;
$this->CacheSettings();
//existing page info
$from_title = $_POST['from_title'];
if (!isset($gp_index[$from_title])) {
msg($langmessage['OOPS_TITLE']);
return false;
}
$from_index = $gp_index[$from_title];
$info = $gp_titles[$from_index];
//check the new title
$title = $_POST['title'];
$title = admin_tools::CheckPostedNewPage($title, $message);
if ($title === false) {
msg($message);
return false;
}
//get the existing content
$from_file = gpFiles::PageFile($from_title);
$contents = file_get_contents($from_file);
//add to $gp_index first!
$index = common::NewFileIndex();
$gp_index[$title] = $index;
$file = gpFiles::PageFile($title);
if (!gpFiles::Save($file, $contents)) {
msg($langmessage['OOPS'] . ' (File not saved)');
return false;
}
//add to gp_titles
$new_titles = array();
$new_titles[$index]['label'] = admin_tools::PostedLabel($_POST['title']);
$new_titles[$index]['type'] = $info['type'];
$gp_titles += $new_titles;
//add to menu
$insert = array();
$insert[$index] = array();
if (!$this->SaveNew($insert)) {
$this->RestoreSettings();
return false;
}
$this->HiddenSaved($index);
return true;
}
示例6: RestoreTitles
/**
* Restore $titles and return array with menu information
* @param array $titles An array of titles to be restored. After completion, it will contain only the titles that were prepared successfully
* @return array A list of restored titles that can be used for menu insertion
*
*/
static function RestoreTitles(&$titles)
{
global $dataDir, $gp_index, $gp_titles, $config;
$new_menu = array();
$restored = array();
foreach ($titles as $trash_index) {
//get trash info about file
$title_info = admin_trash::GetInfo($trash_index);
if ($title_info === false) {
continue;
}
$new_title = admin_tools::CheckPostedNewPage($title_info['title'], $message);
if (!$new_title) {
continue;
}
//make sure the page_file exists
if (!gpFiles::Exists($title_info['page_file'])) {
continue;
}
//add to $gp_index before PageFile()
if (isset($title_info['index'])) {
$index = $title_info['index'];
$gp_index[$new_title] = $index;
} else {
$index = common::NewFileIndex();
$gp_index[$new_title] = $index;
}
// move the trash file to the /_pages directory if needed
$new_file = gpFiles::PageFile($new_title);
if (!gpFiles::Exists($new_file)) {
if (!gpFiles::Rename($title_info['page_file'], $new_file)) {
unset($gp_index[$new_title]);
continue;
}
}
//add to $gp_titles
$gp_titles[$index] = array();
$gp_titles[$index]['label'] = $title_info['label'];
$gp_titles[$index]['type'] = $title_info['type'];
$new_menu[$index] = array();
$restored[$trash_index] = $title_info;
admin_trash::RestoreFile($new_title, $new_file, $title_info);
}
$titles = $restored;
return $new_menu;
}