本文整理汇总了PHP中gpFiles::PageFile方法的典型用法代码示例。如果您正苦于以下问题:PHP gpFiles::PageFile方法的具体用法?PHP gpFiles::PageFile怎么用?PHP gpFiles::PageFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gpFiles
的用法示例。
在下文中一共展示了gpFiles::PageFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SetVars
function SetVars()
{
global $gp_index, $gp_titles, $gp_menu;
if (!isset($gp_index[$this->title])) {
$this->Error_404($this->title);
return false;
}
$this->gp_index = $gp_index[$this->title];
$this->TitleInfo =& $gp_titles[$this->gp_index];
//so changes made by rename are seen
$this->label = common::GetLabel($this->title);
$this->file = gpFiles::PageFile($this->title);
if (!$this->CheckVisibility()) {
return false;
}
gpPlugin::Action('PageSetVars');
return true;
}
示例2: Child
/**
* Get The Image
*
*/
function Child($title)
{
global $dirPrefix;
$file = gpFiles::PageFile($title);
$file_sections = $file_stats = array();
ob_start();
require $file;
ob_get_clean();
if (!is_array($file_sections)) {
return;
}
//get the image
$content = section_content::Render($file_sections, $title, $file_stats);
$img_pos = strpos($content, '<img');
if ($img_pos === false) {
return;
}
$src_pos = strpos($content, 'src=', $img_pos);
if ($src_pos === false) {
return;
}
$src = substr($content, $src_pos + 4);
$quote = $src[0];
if ($quote != '"' && $quote != "'") {
return;
}
$src_pos = strpos($src, $quote, 1);
$src = substr($src, 1, $src_pos - 1);
// check for resized image, get original source if img is resized
if (strpos($src, 'image.php') !== false && strpos($src, 'img=') !== false) {
$src = $dirPrefix . '/data/_uploaded/' . urldecode(substr($src, strpos($src, 'img=') + 4));
}
$thumb_path = common::ThumbnailPath($src);
$img_pos2 = strpos($content, '>', $img_pos);
$img = substr($content, $img_pos, $img_pos2 - $img_pos + 1);
echo '<li>';
echo '<img src="' . $thumb_path . '"/>';
//echo $img;
$label = common::GetLabel($title);
echo common::Link($title, $label);
echo '</li>';
}
示例3: TitleContent
/**
* Return the formatted content of the title
*
*/
public function TitleContent($title)
{
$file = gpFiles::PageFile($title);
$file_sections = $file_stats = array();
ob_start();
require $file;
ob_get_clean();
if (!is_array($file_sections)) {
return '';
}
//prevent infinite loops
foreach ($file_sections as $key => $val) {
if ($val['type'] == 'include') {
unset($file_sections[$key]);
}
}
if (!$file_sections) {
return '';
}
$file_sections = array_values($file_sections);
return section_content::Render($file_sections, $title, $file_stats);
}
示例4: CheckPageFiles
/**
* Check page files for orphaned data files
*
*/
function CheckPageFiles()
{
global $dataDir, $gp_index;
$pages_dir = $dataDir . '/data/_pages';
$all_files = gpFiles::ReadDir($pages_dir, 'php');
foreach ($all_files as $key => $file) {
$all_files[$key] = $pages_dir . '/' . $file . '.php';
}
$page_files = array();
foreach ($gp_index as $slug => $index) {
$page_files[] = gpFiles::PageFile($slug);
}
$diff = array_diff($all_files, $page_files);
if (!count($diff)) {
return;
}
echo '<h2>Orphaned Data Files</h2>';
echo '<p>The following data files appear to be orphaned and are most likely no longer needed. Before completely removing these files, we recommend backing them up first.</p>';
echo '<table class="bordered"><tr><th>File</th></tr>';
foreach ($diff as $file) {
echo '<tr><td>' . $file . '</td></tr>';
}
echo '</table>';
}
示例5: getImageandInfo
function getImageandInfo($title)
{
global $dirPrefix;
$file = gpFiles::PageFile($title);
//check if page not special!
if (!file_exists($file)) {
return;
}
$file_sections = $file_stats = array();
ob_start();
include $file;
ob_get_clean();
if (!is_array($file_sections)) {
return;
}
//avoid error- maximum function nesting level of '250' reached
foreach ($file_sections as $key => $val) {
if ($val['type'] == 'include' or $val['type'] == 'Catalog_easy_section') {
unset($file_sections[$key]);
//dummy section instead of include
$file_sections[$key] = array('type' => 'text', 'content' => '<div><p>Lorem ipsum </p></div>', 'attributes' => array());
}
}
if (!$file_sections) {
return;
}
$file_sections = array_values($file_sections);
//get short info and datafilter
//new data-filter 1.8.1 from menu settt
$datafilter = $this->getNewdatafilter($title);
foreach ($file_sections as $sect) {
if (isset($sect['attributes'])) {
if (isset($sect['attributes']['class'])) {
//if ($sect['attributes']['class'] == "short_info"){
if (strpos($sect['attributes']['class'], 'short_info') !== false) {
$short_info = $sect['content'];
}
}
}
if (isset($sect['attributes']['data-filter'])) {
$datafilter = $sect['attributes']['data-filter'];
}
}
//end section foreach
if (!isset($datafilter)) {
$datafilter = "";
}
if (!isset($short_info)) {
$short_info = "";
}
//get the image + check abrev + check for custom page image
$custom_image = $this->getCustomPageImage($title);
$content = section_content::Render($file_sections, $title, $file_stats);
if ($this->ShortInfo == "abrev") {
$short_info = $this->GetAbrev($content, $title, $this->AbbrevL);
} elseif ($this->ShortInfo == "no") {
$short_info = "";
}
$img_flag = true;
$img_pos = strpos($content, '<img');
if ($img_pos === false) {
$img_flag = false;
// return array('',$short_info,$datafilter);
}
$src_pos = strpos($content, 'src=', $img_pos);
if ($src_pos === false) {
$img_flag = false;
// return array('',$short_info,$datafilter);
}
$src = substr($content, $src_pos + 4);
$quote = $src[0];
if ($quote != '"' && $quote != "'") {
$img_flag = false;
// return array('',$short_info,$datafilter);
}
$src_pos = strpos($src, $quote, 1);
$src = substr($src, 1, $src_pos - 1);
//$thumb_path = common::ThumbnailPath($src);
$img_pos2 = strpos($content, '>', $img_pos);
$img = substr($content, $img_pos, $img_pos2 - $img_pos + 1);
//no img on page+custom exist
if (!$img_flag and $custom_image != "") {
$src = $custom_image;
} elseif (!$img_flag) {
return array('', $short_info, $datafilter);
}
if ($custom_image != "") {
$src = $custom_image;
}
if ($this->ImageCircle) {
$a = "img-circle";
} else {
$a = "";
}
if ($this->catalog_layout == 1 or $this->catalog_layout == 4 or $this->catalog_layout == 2) {
$style = 'max-height:' . $this->ImagesizeH . 'px!important;';
} elseif ($this->catalog_layout == 0) {
$style = 'max-width:' . $this->ImagesizeW . 'px!important; ';
} elseif ($this->catalog_layout == 3 or $this->catalog_layout == 5) {
$style = "";
//.........这里部分代码省略.........
示例6: SearchPage
function SearchPage($pattern, $title, $index)
{
global $gp_menu;
$full_path = gpFiles::PageFile($title);
if (!file_exists($full_path)) {
return;
}
//search hidden?
if (!$this->search_config['search_hidden']) {
if (!isset($gp_menu[$index])) {
return;
}
}
include $full_path;
if (!isset($file_sections) || !is_array($file_sections)) {
return;
}
$content = '';
foreach ($file_sections as $section) {
if (!isset($section['content'])) {
continue;
}
if ($section['type'] == 'exec_php') {
continue;
}
$content .= $section['content'] . ' ';
}
$this->findString($content, $pattern, $title);
}
示例7: 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;
}
示例8: NewTitle
/**
* Save the content for a new page in /data/_pages/<title>
* @since 1.8a1
*
*/
public static function NewTitle($title, $section_content = false, $type = 'text')
{
// get the file for the title
if (empty($title)) {
return false;
}
$file = gpFiles::PageFile($title);
if (!$file) {
return false;
}
// organize section data
$file_sections = array();
if (is_array($section_content) && isset($section_content['type'])) {
$file_sections[0] = $section_content;
} elseif (is_array($section_content)) {
$file_sections = $section_content;
} else {
$file_sections[0] = array('type' => $type, 'content' => $section_content);
}
// add meta data
$meta_data = array('file_number' => gpFiles::NewFileNumber(), 'file_type' => $type);
return gpFiles::SaveData($file, 'file_sections', $file_sections, $meta_data);
}
示例9: SearchPage
function SearchPage($title, $index)
{
global $gp_menu, $gp_titles;
//search hidden?
if (!$this->search_hidden && !isset($gp_menu[$index])) {
return;
}
//private pages
if (!common::LoggedIn()) {
if (isset($gp_titles[$index]['vis'])) {
return;
}
}
$full_path = gpFiles::PageFile($title);
$file_sections = gpFiles::Get($full_path, 'file_sections');
if (!$file_sections) {
return;
}
$content = section_content::Render($file_sections, $title, gpFiles::$last_stats);
$label = common::GetLabel($title);
$this->FindString($content, $label, $title);
}
示例10: IncludePage
/**
* Include the content of a normal page
* @param string $requested The name of the page to include
*
*/
static function IncludePage($requested)
{
global $gp_index;
$requested = str_replace(' ', '_', $requested);
if (!isset($gp_index[$requested])) {
return '{{' . htmlspecialchars($requested) . '}}';
}
$file = gpFiles::PageFile($requested);
$file_sections = gpFiles::Get($file, 'file_sections');
if (!$file_sections) {
return '{{' . htmlspecialchars($requested) . '}}';
}
return self::Render($file_sections, self::$title, self::$meta);
}
示例11: RenameFileWorker
static function RenameFileWorker($title)
{
global $langmessage, $dataDir, $gp_index;
//use new_label or new_title
if (isset($_POST['new_title'])) {
$new_title = admin_tools::PostedSlug($_POST['new_title']);
} else {
$new_title = admin_tools::LabelToSlug($_POST['new_label']);
}
//title unchanged
if ($new_title == $title) {
return $title;
}
$special_file = false;
if (common::SpecialOrAdmin($title)) {
$special_file = true;
}
if (!admin_tools::CheckTitle($new_title, $message)) {
msg($message);
return false;
}
$old_gp_index = $gp_index;
//re-index: make the new title point to the same data index
$old_file = gpFiles::PageFile($title);
$file_index = $gp_index[$title];
unset($gp_index[$title]);
$gp_index[$new_title] = $file_index;
//rename the php file
if (!$special_file) {
$new_file = gpFiles::PageFile($new_title);
//we don't have to rename files if we're using the index naming convention. See gpFiles::PageFile() for more info
if ($new_file == $old_file) {
//if the file being renamed doesn't use the index naming convention, then we'll still need to rename it
} elseif (!rename($old_file, $new_file)) {
msg($langmessage['OOPS'] . ' (N3)');
$gp_index = $old_gp_index;
return false;
}
//gallery rename
includeFile('special/special_galleries.php');
special_galleries::RenamedGallery($title, $new_title);
}
//create a 301 redirect
if (isset($_POST['add_redirect']) && $_POST['add_redirect'] == 'add') {
includeFile('admin/admin_missing.php');
admin_missing::AddRedirect($title, $new_title);
}
gpPlugin::Action('RenameFileDone', array($file_index, $title, $new_title));
return $new_title;
}
示例12: NewTitle
/**
* Save the content for a new page in /data/_pages/<title>
* @since 1.8a1
*
*/
function NewTitle($title, $section_content = false, $type = 'text')
{
if (empty($title)) {
return false;
}
$file = gpFiles::PageFile($title);
if (!$file) {
return false;
}
$file_sections = array();
$file_sections[0] = array('type' => $type, 'content' => $section_content);
$meta_data = array('file_number' => gpFiles::NewFileNumber(), 'file_type' => $type);
return gpFiles::SaveArray($file, 'meta_data', $meta_data, 'file_sections', $file_sections);
}
示例13: 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;
}
示例14: 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;
}
示例15: NewTitle
/**
* Save the content for a new page in /data/_pages/<title>
* @since 1.8a1
*
*/
static function NewTitle($title, $section_content = false, $type = 'text')
{
if (empty($title)) {
return false;
}
$file = gpFiles::PageFile($title);
if (!$file) {
return false;
}
$file_sections = array();
if (is_array($section_content)) {
$file_sections[0] = $section_content;
} else {
$file_sections[0] = array('type' => $type, 'content' => $section_content);
}
$meta_data = array('file_number' => gpFiles::NewFileNumber(), 'file_type' => $type);
return gpFiles::SaveData($file, 'file_sections', $file_sections, $meta_data);
}