Bearsampp 2025.8.29
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'

Private Attributes

 $page
 $pageList

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 17 of file class.homepage.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

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

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

37 {
38 Util::logInitClass($this);
39
41 $this->page = !empty($page) && in_array($page, $this->pageList) ? $page : self::PAGE_INDEX;
42 }
static logInitClass($classInstance)
static cleanGetVar($name, $type='text')

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

Member Function Documentation

◆ getHomepagePath()

getHomepagePath ( )

Gets the path to the homepage directory.

Returns
string The homepage directory path.

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

91 {
92 global $bearsamppCore;
93 return $bearsamppCore->getResourcesPath(false) . '/homepage';
94 }
global $bearsamppCore

References $bearsamppCore.

Referenced by refreshAliasContent(), and refreshCommonsJsContent().

◆ getIconsPath()

getIconsPath ( )

Gets the path to the icons directory.

Returns
string The icons directory path.

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

112 {
113 return $this->getResourcesPath(false) . '/img/icons/';
114 }

References getResourcesPath().

◆ getImagesPath()

getImagesPath ( )

Gets the path to the images directory.

Returns
string The images directory path.

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

102 {
103 return $this->getResourcesPath(false) . '/img/';
104 }

References getResourcesPath().

◆ getPage()

getPage ( )

Gets the current page.

Returns
string The current page.

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

50 {
51 return $this->page;
52 }

References $page.

◆ getPageQuery()

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 60 of file class.homepage.php.

61 {
62 if (empty($query)) {
63 return '';
64 }
65
66 if (in_array($query, $this->pageList)) {
67 return $query !== self::PAGE_INDEX ? '?p=' . $query : 'index.php';
68 }
69
70 return '';
71 }

Referenced by getPageUrl().

◆ getPageUrl()

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 79 of file class.homepage.php.

80 {
81 global $bearsamppRoot;
82 return $bearsamppRoot->getLocalUrl($this->getPageQuery($query));
83 }
global $bearsamppRoot
getPageQuery($query)

References $bearsamppRoot, and getPageQuery().

◆ getResourcesPath()

getResourcesPath ( )

Gets the path to the resources directory.

Returns
string The resources directory path.

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

122 {
123 global $bearsamppCore;
124 return md5(APP_TITLE);
125 }
const APP_TITLE
Definition root.php:13

References $bearsamppCore, and APP_TITLE.

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

◆ getResourcesUrl()

getResourcesUrl ( )

Gets the URL to the resources directory.

Returns
string The resources directory URL.

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

133 {
134 global $bearsamppRoot;
135 return $bearsamppRoot->getLocalUrl($this->getResourcesPath());
136 }

References $bearsamppRoot, and getResourcesPath().

◆ refreshAliasContent()

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 143 of file class.homepage.php.

144 {
145 global $bearsamppBins;
146
147 $result = $bearsamppBins->getApache()->getAliasContent(
148 $this->getResourcesPath(),
149 $this->getHomepagePath()
150 );
151
152 return file_put_contents($this->getHomepagePath() . '/alias.conf', $result) !== false;
153 }
$result
global $bearsamppBins

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

◆ refreshCommonsJsContent()

refreshCommonsJsContent ( )

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

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

159 {
160 Util::replaceInFile($this->getHomepagePath() . '/js/_commons.js', array(
161 '/^\s\surl:.*/' => ' url: "' . $this->getResourcesPath() . '/ajax.php"',
162 '/AJAX_URL.*=.*/' => 'const AJAX_URL = "' . $this->getResourcesPath() . '/ajax.php"',
163 ));
164 }
static replaceInFile($path, $replaceList)

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

Field Documentation

◆ $page

$page
private

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

Referenced by __construct(), and getPage().

◆ $pageList

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

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

◆ PAGE_INDEX

const PAGE_INDEX = 'index'

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

◆ PAGE_PHPINFO

const PAGE_PHPINFO = 'phpinfo'

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


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