__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* @package SP Page Builder
* @author JoomShaper http://www.joomshaper.com
* @copyright Copyright (c) 2010 - 2023 JoomShaper
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
*/
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
// No direct access
defined('_JEXEC') or die('Restricted access');
/**
* Trait for managing page list
*/
trait PageTrait
{
public function pages()
{
$method = $this->getInputMethod();
$this->checkNotAllowedMethods(['DELETE'], $method);
switch ($method) {
case 'GET':
$this->getPageList();
break;
case 'PUT':
$this->savePage();
break;
case 'PATCH':
$this->applyBulkActions();
break;
case 'POST':
$this->createPage();
break;
}
}
public function getPageList()
{
$pageData = (object) [
'limit' => $this->getInput('limit', 10, 'INT'),
'offset' => $this->getInput('offset', 0, 'INT'),
'search' => $this->getInput('search', '', 'STRING'),
'sortBy' => $this->getInput('sortBy', '', 'STRING'),
'access' => $this->getInput('access', '', 'STRING'),
'category' => $this->getInput('category', 0, 'INT'),
'language' => $this->getInput('language', '', 'STRING'),
'status' => $this->getInput('status', '', 'STRING'),
];
$model = $this->getModel('Editor');
$response = $model->getPages($pageData);
$this->sendResponse($response, $response->code);
}
public function savePage()
{
$model = $this->getModel('Editor');
$id = $this->getInput('id', 0, 'INT');
$title = $this->getInput('title', '', 'STRING');
$text = $this->getInput('text', '[]', 'RAW');
$published = $this->getInput('published', 0, 'INT');
$language = $this->getInput('language', '*', 'STRING');
$catid = $this->getInput('catid', 0, 'INT');
$access = $this->getInput('access', 1, 'INT');
$attributes = $this->getInput('attribs', '', 'STRING');
$openGraphTitle = $this->getInput('og_title', '', 'STRING');
$openGraphDescription = $this->getInput('og_description', '', 'STRING');
$openGraphImage = $this->getInput('og_image', '', 'STRING');
$customCss = $this->getInput('css', '', 'RAW');
$version = SppagebuilderHelper::getVersion();
$pageCreator = $model->getPageCreator($id);
$user = Factory::getUser();
$canEdit = $user->authorise('core.edit', 'com_sppagebuilder');
$canEditOwn = $user->authorise('core.edit.own', 'com_sppagebuilder');
$canEditState = $user->authorise('core.edit.state', 'com_sppagebuilder');
$canEditPage = $canEdit || ($canEditOwn && $user->id === $pageCreator);
if (!$canEditPage) {
$this->sendResponse(['message' => Text::_('COM_SPPAGEBUILDER_EDITOR_INVALID_EDIT_ACCESS')], 403);
}
$data = (object) [
'id' => $id,
'title' => $title,
// 'content' => !empty($text) ? EditorUtils::cleanXSS($text) : '[]',
'content' => !empty($text) ? $text : '[]',
'published' => $published,
'language' => $language,
'catid' => $catid,
'access' => $access,
'attribs' => $attributes,
'og_title' => $openGraphTitle,
'og_description' => $openGraphDescription,
'og_image' => $openGraphImage,
'css' => $customCss ?? '',
'version' => $version,
'modified' => Factory::getDate()->toSql(),
'modified_by' => $user->id,
];
if (!$canEditState) {
unset($data->published);
}
try
{
$model->savePage($data);
}
catch (\Exception $e)
{
$this->sendResponse(['message' => $e->getMessage()], 500);
}
$this->sendResponse(true);
}
public function applyBulkActions()
{
$params = (object) [
'ids' => $this->getInput('ids', '', 'STRING'),
'type' => $this->getInput('type', '', 'STRING'),
'value' => $this->getInput('value', '', 'STRING')
];
$user = Factory::getUser();
$canEditState = $user->authorise('core.edit.state', 'com_sppagebuilder');
$canDelete = $user->authorise('core.delete', 'com_sppagebuilder');
$stateTypes = ['published', 'unpublished', 'check-in', 'rename'];
$deleteTypes = ['trash', 'delete'];
if (in_array($params->type, $stateTypes) && !$canEditState) {
$this->sendResponse(['message' => Text::_('COM_SPPAGEBUILDER_EDITOR_INVALID_EDIT_STATE_ACCESS')], 403);
}
if (in_array($params->type, $deleteTypes) && !$canDelete) {
$this->sendResponse(['message' => Text::_('COM_SPPAGEBUILDER_EDITOR_INVALID_DELETE_STATE')], 403);
}
$model = $this->getModel('Editor');
$response = $model->applyBulkActions($params);
$this->sendResponse($response);
}
public function createPage()
{
$title = $this->getInput('title', '', 'STRING');
$model = $this->getModel('Editor');
$data = [];
$user = Factory::getUser();
$version = SppagebuilderHelper::getVersion();
$user = Factory::getUser();
$canCreate = $user->authorise('core.create', 'com_sppagebuilder');
if (!$canCreate) {
$this->sendResponse([
'message' => Text::_('COM_SPPAGEBUILDER_EDITOR_INVALID_CREATE_ACCESS')
], 403);
}
$data = (object) [
'id' => 0,
'title' => $title,
'text' => '[]',
'css' => '',
'catid' => 0,
'language' => '*',
'access' => 1,
'created_on' => Factory::getDate()->toSql(),
'created_by' => $user->id,
'modified' => Factory::getDate()->toSql(),
'version' => $version,
];
$result = $model->createPage($data);
if (!empty($result['message'])) {
$this->sendResponse($result, 500);
}
$response = (object) [
'id' => $result
];
$this->sendResponse($response, 201);
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| AddToMenuTrait.php | File | 2.69 KB | 0664 |
|
| AddonsTrait.php | File | 6.35 KB | 0664 |
|
| AllFontsTrait.php | File | 1.32 KB | 0664 |
|
| AppConfig.php | File | 4.01 KB | 0664 |
|
| ApplicationSettingsTrait.php | File | 7.74 KB | 0664 |
|
| ExportTrait.php | File | 2 KB | 0664 |
|
| FontsTrait.php | File | 12.44 KB | 0664 |
|
| GlobalColorsTrait.php | File | 1.12 KB | 0664 |
|
| IconProvidersTrait.php | File | 928 B | 0664 |
|
| IconsListTrait.php | File | 1.39 KB | 0664 |
|
| IconsTrait.php | File | 14.71 KB | 0664 |
|
| ImportTrait.php | File | 2.48 KB | 0664 |
|
| IntegrationTrait.php | File | 4.64 KB | 0664 |
|
| LanguageTrait.php | File | 5.68 KB | 0664 |
|
| LayoutImportTrait.php | File | 2.32 KB | 0664 |
|
| Media.php | File | 17.91 KB | 0664 |
|
| MediaFolderTrait.php | File | 8.44 KB | 0664 |
|
| MenuByPageIdTrait.php | File | 952 B | 0664 |
|
| MenuListTrait.php | File | 791 B | 0664 |
|
| PageContentById.php | File | 871 B | 0664 |
|
| PageDuplicateTrait.php | File | 1.35 KB | 0664 |
|
| PageOrderTrait.php | File | 1.16 KB | 0664 |
|
| PageTemplateTrait.php | File | 3.1 KB | 0664 |
|
| PageTrait.php | File | 5.29 KB | 0664 |
|
| ParentItemsTrait.php | File | 1.01 KB | 0664 |
|
| PurgeCssTrait.php | File | 810 B | 0664 |
|
| SaveIgTokenTrait.php | File | 1.91 KB | 0664 |
|
| SavedAddonsOrderTrait.php | File | 1.19 KB | 0664 |
|
| SavedAddonsTrait.php | File | 4.06 KB | 0664 |
|
| SavedSectionsOrderTrait.php | File | 1.21 KB | 0664 |
|
| SavedSectionsTrait.php | File | 4.12 KB | 0664 |
|
| SectionLibraryTrait.php | File | 2.84 KB | 0664 |
|
| SettingsTrait.php | File | 1.07 KB | 0664 |
|
| UploadFontTrait.php | File | 5.48 KB | 0664 |
|