2024.8.23
Loading...
Searching...
No Matches
Homepage Class Reference

Public Member Functions

 __construct ()
 
 getHomepagePath ()
 
 getIconsPath ()
 
 getImagesPath ()
 
 getPage ()
 
 getPageQuery ($query)
 
 getPageUrl ($query)
 
 getResourcesPath ()
 
 getResourcesUrl ()
 
 refreshAliasContent ()
 
 refreshCommonsJsContent ()
 

Data Fields

const PAGE_INDEX = 'index'
 
const PAGE_PHPINFO = 'phpinfo'
 
const PAGE_STDL_APC = 'apc.php'
 

Private Attributes

 $page
 
 $pageList
 
 $pageStdl
 

Detailed Description

Class Homepage

This class handles the homepage functionalities of the Bearsampp application. It manages the page navigation, resource paths, and content refresh operations.

Definition at line 16 of file class.homepage.php.

Constructor & Destructor Documentation

◆ __construct()

Homepage::__construct ( )

Homepage constructor. Initializes the homepage class and sets the current page based on the query parameter.

Definition at line 43 of file class.homepage.php.

44 {
45 Util::logInitClass($this);
46
48 $this->page = !empty($page) && in_array($page, $this->pageList) ? $page : self::PAGE_INDEX;
49 }
const PAGE_INDEX
static cleanGetVar($name, $type='text')
static logInitClass($classInstance)

References $page, Util\cleanGetVar(), Util\logInitClass(), and PAGE_INDEX.

Member Function Documentation

◆ getHomepagePath()

Homepage::getHomepagePath ( )

Gets the path to the homepage directory.

Returns
string The homepage directory path.

Definition at line 97 of file class.homepage.php.

98 {
99 global $bearsamppCore;
100 return $bearsamppCore->getResourcesPath(false) . '/homepage';
101 }
global $bearsamppCore

References $bearsamppCore.

Referenced by refreshAliasContent(), and refreshCommonsJsContent().

+ Here is the caller graph for this function:

◆ getIconsPath()

Homepage::getIconsPath ( )

Gets the path to the icons directory.

Returns
string The icons directory path.

Definition at line 118 of file class.homepage.php.

119 {
120 return $this->getResourcesPath(false) . '/img/icons/';
121 }

References getResourcesPath().

◆ getImagesPath()

Homepage::getImagesPath ( )

Gets the path to the images directory.

Returns
string The images directory path.

Definition at line 108 of file class.homepage.php.

109 {
110 return $this->getResourcesPath(false) . '/img/';
111 }

References getResourcesPath().

◆ getPage()

Homepage::getPage ( )

Gets the current page.

Returns
string The current page.

Definition at line 56 of file class.homepage.php.

57 {
58 return $this->page;
59 }

References $page.

◆ getPageQuery()

Homepage::getPageQuery ( $query)

Constructs the page query string based on the provided query.

Parameters
string$queryThe query string to construct.
Returns
string The constructed page query string.

Definition at line 67 of file class.homepage.php.

68 {
69 $request = '';
70 if (!empty($query) && in_array($query, $this->pageList) && $query != self::PAGE_INDEX) {
71 $request = '?p=' . $query;
72 } elseif (!empty($query) && in_array($query, $this->pageStdl)) {
73 $request = $query;
74 } elseif (!empty($query) && self::PAGE_INDEX) {
75 $request = "index.php";
76 }
77 return $request;
78 }

Referenced by getPageUrl().

+ Here is the caller graph for this function:

◆ getPageUrl()

Homepage::getPageUrl ( $query)

Constructs the full URL for the given page query.

Parameters
string$queryThe query string to construct the URL for.
Returns
string The constructed page URL.

Definition at line 86 of file class.homepage.php.

87 {
88 global $bearsamppRoot;
89 return $bearsamppRoot->getLocalUrl($this->getPageQuery($query));
90 }
global $bearsamppRoot
getPageQuery($query)

References $bearsamppRoot, and getPageQuery().

◆ getResourcesPath()

Homepage::getResourcesPath ( )

Gets the path to the resources directory.

Returns
string The resources directory path.

Definition at line 128 of file class.homepage.php.

129 {
130 global $bearsamppCore;
131 return md5(APP_TITLE);
132 }
const APP_TITLE
Definition root.php:12

References $bearsamppCore, and APP_TITLE.

Referenced by getIconsPath(), getImagesPath(), getResourcesUrl(), refreshAliasContent(), and refreshCommonsJsContent().

+ Here is the caller graph for this function:

◆ getResourcesUrl()

Homepage::getResourcesUrl ( )

Gets the URL to the resources directory.

Returns
string The resources directory URL.

Definition at line 139 of file class.homepage.php.

140 {
141 global $bearsamppRoot;
142 return $bearsamppRoot->getLocalUrl($this->getResourcesPath());
143 }

References $bearsamppRoot, and getResourcesPath().

◆ refreshAliasContent()

Homepage::refreshAliasContent ( )

Refreshes the alias content by updating the alias configuration file.

Returns
bool True if the alias content was successfully refreshed, false otherwise.

Definition at line 150 of file class.homepage.php.

151 {
152 global $bearsamppBins;
153
154 $result = $bearsamppBins->getApache()->getAliasContent(
155 $this->getResourcesPath(),
156 $this->getHomepagePath()
157 );
158
159 return file_put_contents($this->getHomepagePath() . '/alias.conf', $result) !== false;
160 }
$result
global $bearsamppBins

References $bearsamppBins, $result, getHomepagePath(), and getResourcesPath().

◆ refreshCommonsJsContent()

Homepage::refreshCommonsJsContent ( )

Refreshes the commons JavaScript content by updating the _commons.js file.

Definition at line 165 of file class.homepage.php.

166 {
167 Util::replaceInFile($this->getHomepagePath() . '/js/_commons.js', array(
168 '/^\s\surl:.*/' => ' url: "' . $this->getResourcesPath() . '/ajax.php"',
169 '/AJAX_URL.*=.*/' => 'const AJAX_URL = "' . $this->getResourcesPath() . '/ajax.php"',
170 ));
171 }
static replaceInFile($path, $replaceList)

References getHomepagePath(), getResourcesPath(), and Util\replaceInFile().

Field Documentation

◆ $page

Homepage::$page
private

Definition at line 22 of file class.homepage.php.

Referenced by __construct(), and getPage().

◆ $pageList

Homepage::$pageList
private
Initial value:
= array(
self::PAGE_INDEX,
self::PAGE_PHPINFO,
)

Definition at line 27 of file class.homepage.php.

◆ $pageStdl

Homepage::$pageStdl
private
Initial value:
= array(
self::PAGE_STDL_APC
)

Definition at line 35 of file class.homepage.php.

◆ PAGE_INDEX

const Homepage::PAGE_INDEX = 'index'

Definition at line 18 of file class.homepage.php.

Referenced by __construct().

◆ PAGE_PHPINFO

const Homepage::PAGE_PHPINFO = 'phpinfo'

Definition at line 19 of file class.homepage.php.

◆ PAGE_STDL_APC

const Homepage::PAGE_STDL_APC = 'apc.php'

Definition at line 20 of file class.homepage.php.


The documentation for this class was generated from the following file: