first commit

This commit is contained in:
2026-02-08 21:16:11 +01:00
commit e17b7026fd
8881 changed files with 1160453 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
// No direct access.
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
/**
* Pages list controller class.
*/
class PagebuilderckControllerArticles extends CKController {
function __construct() {
parent::__construct();
}
/**
* Proxy for getModel.
* @since 1.6
*/
public function getModel($name = 'articles', $prefix = 'PagebuilderckModel', $config = array()) {
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
return $model;
}
public function import() {
exit('import not allowed');
$app = JFactory::getApplication();
if ($importClass = PagebuilderckHelper::getParams('import')) {
$importClass->importFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=articles", $msg, 'error');
return false;
}
}
public function export() {
exit('export not allowed');
$app = JFactory::getApplication();
if ($exportClass = PagebuilderckHelper::getParams('export')) {
$exportClass->exportFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=articles", $msg, 'error');
return false;
}
}
}

View File

@@ -0,0 +1,97 @@
<?php
// No direct access
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
require_once PAGEBUILDERCK_PATH . '/helpers/ckbrowse.php';
class PagebuilderckControllerBrowse extends CKController {
function __construct() {
parent::__construct();
}
public function ajaxCreateFolder() {
// security check
CKFof::checkAjaxToken();
if (CKFof::userCan('create', 'com_media')) {
$path = $this->input->get('path', '', 'string');
$name = $this->input->get('name', '', 'string');
require_once PAGEBUILDERCK_PATH . '/helpers/ckbrowse.php';
if ($result = CKBrowse::createFolder($path, $name)) {
$msg = JText::_('CK_FOLDER_CREATED_SUCCESS');
} else {
$msg = JText::_('CK_FOLDER_CREATED_ERROR');
}
echo '{"status" : "' . ($result == false ? '0' : '1') . '", "message" : "' . $msg . '"}';
} else {
echo '{"status" : "2", "message" : "' . JText::_('CK_ERROR_USER_NO_AUTH') . '"}';
}
exit;
}
/**
* Get the file and store it on the server
*
* @return mixed, the method return
*/
public function ajaxAddPicture() {
// security check
CKFof::checkAjaxToken();
require_once PAGEBUILDERCK_PATH . '/helpers/ckbrowse.php';
CKBrowse::ajaxAddPicture();
}
public function getFiles() {
// security check
CKFof::checkAjaxToken();
$folder = $this->input->get('folder', '', 'string');
$type = $this->input->get('type', '', 'string');
$filetypes = CKBrowse::getFileTypes($type);
$files = CKBrowse::getImagesInFolder(JPATH_SITE . '/' . $folder, implode('|', $filetypes));
if ($type == 'folder') {
$pathway = str_replace('/', '</span><span class="ckfoldertreepath">', $folder);
?>
<div id="ckfoldertreelistfolderselection">
<div class="ckbutton ckbutton-primary" style="font-size:20px;padding: 10px 20px;" onclick="ckBrowseSelectFolder('<?php echo ($folder) ?>')"><i class="fas fa-check-square"></i> <?php echo JText::_('CK_SELECT_FOLDER') ?><br /><small><?php echo $pathway ?></small></div>
</div>
<?php }
if (empty($files)) {
echo JText::_('CK_NO_FILE_FOUND');
} else {
foreach($files as $file) {
$type = CKBrowse::getTypeByFilename($file);
switch ($type) {
case 'video' :
$fileicon = PAGEBUILDERCK_MEDIA_URI . '/images/file_video.png';
break;
case 'audio' :
$fileicon = PAGEBUILDERCK_MEDIA_URI . '/images/file_audio.png';
break;
case 'folder' :
case 'image' :
$fileicon = JUri::root(true) . '/' . PagebuilderckHelper::utf8_encode($folder) . '/' . PagebuilderckHelper::utf8_encode($file);
break;
default :
$fileicon = PAGEBUILDERCK_MEDIA_URI . '/images/file_generic.png';
break;
}
?>
<div class="ckfoldertreefile" data-type="<?php echo $type ?>" onclick="ckBrowseSelectFile(this)" data-path="<?php echo PagebuilderckHelper::utf8_encode($folder) ?>" data-filename="<?php echo PagebuilderckHelper::utf8_encode($file) ?>">
<img src="<?php echo $fileicon ?>" title="<?php echo PagebuilderckHelper::utf8_encode($file); ?>" loading="lazy">
<div class="ckimagetitle"><?php echo PagebuilderckHelper::utf8_encode($file); ?></div>
</div>
<?php
}
}
exit;
}
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
// No direct access.
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
/**
* Pages list controller class.
*/
class PagebuilderckControllerCategories extends CKController {
function __construct() {
parent::__construct();
}
public function save($id = 0, $task = 'save', $ajax = false) {
// Check for request forgeries.
if ($ajax === true) {
CKFof::checkAjaxToken();
} else {
CKFof::checkToken();
}
$model = $this->getModel();
// Initialise variables.
// $appendToUrl = $this->input->get('tmpl') ? '&tmpl=' . $this->input->get('tmpl') : '';
// $layout = $this->input->get('layout') == 'modal' ? '&layout=modal' : '&layout=edit';
// Get the user data.
$data = array();
$data['id'] = $this->input->get('id', $id, 'int');
$id = $data['id'];
$data['name'] = $this->input->get('name', '', 'string');
$data['description'] = '';
$data['ordering'] = 0;
$data['state'] = 1;
$data['created'] = null;
$data['created_by'] = 0;
$data['access'] = 1;
// Check for errors.
if ($data === false) {
CKFof::enqueueMessage('ERROR : NO DATA SAVED', 'warning');
// Redirect back to the edit screen.
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=categories');
return false;
}
// Attempt to save the data.
$return = $model->save($data);
// Check for errors.
if ($return === false) {
// Redirect back to the edit screen.
CKFof::enqueueMessage(JText::_('CK_ITEM_SAVED_FAILED'), 'warning');
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=categories');
return false;
}
// Redirect to the list screen.
CKFof::enqueueMessage(JText::_('CK_ITEM_SAVED_SUCCESS'));
$model->checkin($return);
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=categories');
}
}

View File

@@ -0,0 +1,196 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.page-creator.com - https://www.joomlack.fr
*/
// No direct access
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
/**
* Page controller class.
*/
class PagebuilderckControllerContenttype extends CKController {
function __construct() {
parent::__construct();
}
/**
* Method to save a user's profile data.
*
* @return void
* @since 1.6
*/
public function save($key = null, $urlVar = null) {
$app = JFactory::getApplication();
if ($app->input->get('method','', 'cmd') == 'ajax') {
// Check for request forgeries.
JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
} else {
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
}
$task = $this->getTask();
// Initialise variables.
$model = $this->getModel('Contenttype', 'PagebuilderckModel');
$appendToUrl = $app->input->get('tmpl') ? '&tmpl=' . $app->input->get('tmpl') : '';
$layout = $app->input->get('layout') == 'modal' ? '&layout=modal' : '&layout=edit';
// Get the user data.
// $data = $app->input->getArray($_POST);
$data = array();
$data['type'] = $app->input->get('type', '', 'string');
$data['htmlcode'] = $app->input->get('htmlcode', '', 'raw');
$data['stylecode'] = $app->input->get('stylecode', '', 'raw');
$type = $data['type'];
// Attempt to save the data.
$return = $model->save($data);
// Check for errors.
if ($return === false) {
// Save the data in the session.
// $app->setUserState('com_pagebuilderck.edit.contenttype.data', $data);
// Redirect back to the edit screen.
// $id = (int) $app->getUserState('com_pagebuilderck.edit.contenttype.id');
$app->enqueueMessage(JText::sprintf('Save failed', $model->getError()), 'warning');
$this->setRedirect('index.php?option=com_pagebuilderck&view=contenttype'.$layout.'&type=' . $type . $appendToUrl, false);
return false;
}
// Check in the profile.
// if ($return) {
// $model->checkin($return);
// }
// Clear the profile id from the session.
// $app->setUserState('com_pagebuilderck.edit.contenttype.id', null);
// Redirect to the list screen.
$app->enqueueMessage(JText::_('Item saved successfully'));
switch ($task)
{
case 'apply':
// Set the record data in the session.
// $this->holdEditId($context, $recordId);
// $app->setUserState($context . '.data', null);
// $model->checkout($return);
// Redirect back to the edit screen.
$this->setRedirect('index.php?option=com_pagebuilderck&view=contenttype'.$layout.'&type=' . $type . $appendToUrl, false);
break;
default:
// Clear the record id and data from the session.
// $this->releaseEditId($context, $recordId);
// $app->setUserState($context . '.data', null);
// Redirect to the list screen.
$this->setRedirect('index.php?option=com_pagebuilderck&view=contenttypes', false);
break;
}
// Flush the data from the session.
// $app->setUserState('com_pagebuilderck.edit.contenttype.data', null);
}
/**
* Method to save a user's profile data.
*
* @return void
* @since 1.6
*/
public function cancel($key = NULL) {
$this->setRedirect('index.php?option=com_pagebuilderck&view=contenttypes', false);
}
public function ajaxLoadFields() {
// security check
if (! PagebuilderckHelper::getAjaxToken()) {
exit();
}
$app = JFactory::getApplication();
$input = $app->input;
$type = $input->get('type', '', 'string');
$model = $this->getModel('Contenttype', '', array());
$item = $model->getData($type);
include_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/simple_html_dom.php';
$html = \Pagebuilderck\str_get_html($item->htmlcode);
$identifiers = array();
// find all types in the page
foreach($html->find('div.ckcontenttype') as $e) {
$identifier = $e->attr['data-type'];
$identifiers[] = str_replace($type . '.', '', $identifier);
}
echo '{"status" : "1", "identifiers" : "' . implode('|', $identifiers) . '"}';
exit;
}
public function ajaxAddField() {
// security check
if (! PagebuilderckHelper::getAjaxToken()) {
exit();
}
$app = JFactory::getApplication();
$input = $app->input;
$type = $input->get('type', '', 'string');
$identifier = $input->get('identifier', '', 'string');
$blocid = $input->get('blocid', '', 'string');
require_once(JPATH_SITE . '/plugins/pagebuilderck/' . $type . '/' . $type . 'helper.php');
$className = 'plgPagebuilderck' . ucfirst($type) . 'Helper';
$html = $className::getField($identifier);
echo str_replace('|ID|', $blocid, $html);
exit;
}
public function ajaxGetFieldPosition() {
// security check
if (! PagebuilderckHelper::getAjaxToken()) {
exit();
}
$app = JFactory::getApplication();
$input = $app->input;
$type = $input->get('type', '', 'string');
$identifier = $input->get('identifier', '', 'string');
require_once(JPATH_SITE . '/plugins/pagebuilderck/' . $type . '/' . $type . 'helper.php');
$className = 'plgPagebuilderck' . ucfirst($type) . 'Helper';
$fieldsList = $className::getFieldsList();
$arrayPosition = array_search($identifier, $fieldsList);
if ($arrayPosition === false) {
$position = -1;
} else if ($arrayPosition === 0) {
$position = 'first';
} else if ($arrayPosition === (count($fieldsList) -1)) {
$position = 'last';
} else {
$position = $fieldsList[$arrayPosition - 1];
}
echo '{"status" : "1", "position" : "' . $position . '"}';
exit;
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
// No direct access.
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
/**
* Pages list controller class.
*/
class PagebuilderckControllerContenttypes extends CKController {
function __construct() {
parent::__construct();
}
/**
* Proxy for getModel.
* @since 1.6
*/
public function getModel($name = 'element', $prefix = 'PagebuilderckModel', $config = array()) {
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
return $model;
}
public function import() {
$app = JFactory::getApplication();
if ($importClass = PagebuilderckHelper::getParams('import')) {
$importClass->importFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=elements", $msg, 'error');
return false;
}
}
public function export() {
$app = JFactory::getApplication();
if ($exportClass = PagebuilderckHelper::getParams('export')) {
$exportClass->exportFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=elements", $msg, 'error');
return false;
}
}
public function order() {
// security check
// if (! PagebuilderckHelper::getAjaxToken()) {
// exit();
// }
$app = JFactory::getApplication();
$ordering = $app->input->get('ordering', '', 'array');
$model = $this->getModel('elements');
$result = $model->saveOrder($ordering);
echo (int) $result;
exit;
}
}

View File

@@ -0,0 +1,115 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.page-creator.com - https://www.joomlack.fr
*/
// No direct access
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
/**
* Page controller class.
*/
class PagebuilderckControllerElement extends CKController {
function __construct() {
parent::__construct();
}
public function apply() {
return $this->save(0, 'apply');
}
/**
* Method to save a user's profile data.
*
* @return void
* @since 1.6
*/
public function save($id = 0, $task = 'save') {
// Check for request forgeries.
CKFof::checkToken();
$model = $this->getModel();
// Initialise variables.
$appendToUrl = $this->input->get('tmpl') ? '&tmpl=' . $this->input->get('tmpl') : '';
$layout = $this->input->get('layout') == 'modal' ? '&layout=modal' : '&layout=edit';
// Get the user data.
$data = $this->input->getArray($_POST);
$data['htmlcode'] = $this->input->get('htmlcode', '', 'raw');
$data['htmlcode'] = str_replace(JUri::root(true), "|URIROOT|", $data['htmlcode']);
// Check for errors.
if ($data === false) {
CKFof::enqueueMessage('ERROR : NO DATA SAVED', 'warning');
// Redirect back to the edit screen.
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=element' . $layout . '&id=' . $id . $appendToUrl);
return false;
}
// Attempt to save the data.
$return = $model->save($data);
// Check for errors.
if ($return === false) {
// Redirect back to the edit screen.
CKFof::enqueueMessage(JText::_('CK_ITEM_SAVED_FAILED'), 'warning');
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=element' . $layout . '&id=' . $id . $appendToUrl);
return false;
}
// Redirect to the list screen.
CKFof::enqueueMessage(JText::_('CK_ITEM_SAVED_SUCCESS'));
switch ($task)
{
case 'apply':
// Redirect back to the edit screen.
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=element' . $layout . '&id=' . $return . $appendToUrl);
break;
default:
// Redirect to the list screen.
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=elements');
break;
}
}
/**
* copy an existing element
* @return void
*/
function copy() {
// Check for request forgeries.
CKFof::checkToken();
$this->redirect = PAGEBUILDERCK_ADMIN_URL . '&view=elements';
parent::copy();
}
function cancel() {
//Redirect back to list
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=elements');
}
/**
* copy an existing element
* @return void
*/
function delete() {
// Check for request forgeries.
CKFof::checkToken();
$this->redirect = PAGEBUILDERCK_ADMIN_URL . '&view=elements';
parent::delete();
}
}

View File

@@ -0,0 +1,58 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
// No direct access.
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
/**
* Pages list controller class.
*/
class PagebuilderckControllerElements extends CKController {
function __construct() {
parent::__construct();
}
public function import() {
$app = JFactory::getApplication();
if ($importClass = PagebuilderckHelper::getParams('importelement')) {
$importClass->importFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=elements", $msg, 'error');
return false;
}
}
public function export() {
exit('export not allowed');
$app = JFactory::getApplication();
if ($exportClass = PagebuilderckHelper::getParams('exportelement')) {
$exportClass->exportFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=elements", $msg, 'error');
return false;
}
}
public function order() {
// security check
CKFof::checkAjaxToken();
$ordering = $this->input->get('ordering', '', 'array');
$model = $this->getModel('elements');
$result = $model->saveOrder($ordering);
echo (int) $result;
exit;
}
}

View File

@@ -0,0 +1,209 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
// No direct access.
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
class PagebuilderckControllerFonts extends CKController {
protected $imagespath;
function __construct() {
parent::__construct();
}
/**
* Load the needed interface
*
* @return void
*/
/*public function load() {
// security check
CKFof::checkAjaxToken();
$layout = $this->input->get('layout', '', 'cmd');
if (! $layout) return;
// $this->interface = new CKInterface();
$this->imagespath = PAGEBUILDERCK_MEDIA_URI . '/images/menustyles/';
require_once(PAGEBUILDERCK_PATH . '/interfaces/' . $layout . '.php');
exit;
}*/
/**
* Save the font in the BDD and store the files locally if needed
*
* @return void
*/
public function save() {
// security check
CKFof::checkAjaxToken();
// only store the font files locally if local is 1
$local = $this->input->get('local', '', 'int');
if ($local === 1) {
$variants = $this->input->get('fontvars', '', 'string');
$url = $this->input->get('url', '', 'string');
$url = str_replace('http:', 'https:', $url);
if (! $url) {
echo '{"status" : "0", "msg" : "No url given"}';
exit;
}
$fontname = $this->input->get('fontname', '', 'string');
if (! $fontname) {
echo '{"status" : "0", "msg" : "No font name given"}';
exit;
}
$gfontFolderPath = PAGEBUILDERCK_MEDIA_PATH . '/gfonts/';
// create fonts folder
if (!JFolder::exists($gfontFolderPath)) {
if (!JFolder::create($gfontFolderPath)) {
// $msg = '<p class="errorck">' . JText::_('CK_ERROR_CREATING_FOLDER') . ' /fonts</p>';
} else {
// $msg = '<p class="successck">' . JText::_('CK_SUCCESS_CREATING_FOLDER') . ' /fonts</p>';
}
// $messages[] = $msg;
}
// check if file exists
$filePath = $gfontFolderPath . $fontname . '.css';
// get the file from url
set_time_limit(0);
if (extension_loaded('curl')) {
try {
$ch = curl_init();
$timeout = 30;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file = curl_exec($ch);
if($file === false)
{
echo '{"status" : "0", "msg" : "Curl error: ' . curl_error($ch) . '"}';
// echo 'Curl error: ' . curl_error($ch);
}
else
{
// echo 'Operation completed without any errors';
}
curl_close($ch);
} catch (Exception $e) {
// echo 'Exception : ', $e->getMessage(), "\n";
echo '{"status" : "0", "msg" : "' . $e->getMessage() . '"}';
exit;
}
} else {
try {
$file = file_get_contents(urldecode($url));
} catch (Exception $e) {
// echo 'Exception : ', $e->getMessage(), "\n";
echo '{"status" : "0", "msg" : "' . $e->getMessage() . '"}';
exit;
}
}
// store the file locally
$result = file_put_contents($filePath, $file);
if (! $result) {
echo '{"status" : "0", "file" : "", "msg" : "Error on file creation"}';
exit();
}
// download the ttf files
$filesize = 0;
preg_match_all('/url\((.*?)\)/', $file, $matches);
if (isset($matches[0]) && ! empty($matches[1])) {
if (is_array($matches[1])) {
foreach($matches[1] as $fontfile) {
try {
$ch = curl_init();
$timeout = 30;
curl_setopt($ch, CURLOPT_URL, $fontfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$ttffile = curl_exec($ch);
if($ttffile === false)
{
echo '{"status" : "0", "msg" : "Curl error: ' . curl_error($ch) . '"}';
}
else
{
// echo 'Operation completed without any errors';
}
curl_close($ch);
} catch (Exception $e) {
echo '{"status" : "0", "msg" : "' . $e->getMessage() . '"}';
exit;
}
$filename = explode('/', $fontfile);
$filename = end($filename);
$filePath = $gfontFolderPath . $filename;
$result = file_put_contents($filePath, $ttffile);
if (! $result) {
echo '{"status" : "0", "file" : "", "msg" : "Error on file creation"}';
exit();
}
$filesize += filesize($filePath);
}
}
}
$model = $this->getModel();
$result = $model->saveFont($fontname, $url, $local, $filesize, $variants);
if ($result) {
echo '{"status" : "1", "file" : "' . $fontname . '.css' . '", "filesize" : "' . $filesize . '"}';
} else {
echo '{"status" : "0", "file" : "' . $fontname . '.css' . '", "filesize" : "' . $filesize . '"}';
}
} else {
$model = $this->getModel();
$result = $model->saveFont($fontname, $url, $local, $filesize, $variants);
if ($result) {
echo '{"status" : "1", "file" : "", "filesize" : ""}';
} else {
echo '{"status" : "0", "file" : "", "filesize" : ""}';
}
}
exit;
}
public function delete() {
// security check
CKFof::checkAjaxToken();
$fontname = $this->input->get('fontname', '', 'string');
$fontname = str_replace(' ', '+', $fontname);
$model = $this->getModel();
$result = $model->delete($fontname);
if ($result) {
echo '{"status" : "1", "msg" : ""}';
} else {
echo '{"status" : "0", "msg" : "' . $result . '"}';
}
exit;
}
}

View File

@@ -0,0 +1 @@
<html><body></body></html>

View File

@@ -0,0 +1,42 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
// No direct access.
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
class PagebuilderckControllerInterface extends CKController {
protected $imagespath;
function __construct() {
parent::__construct();
}
/**
* Load the needed interface
*
* @return void
*/
public function load() {
// security check
CKFof::checkAjaxToken();
$layout = $this->input->get('layout', '', 'cmd');
if (! $layout) return;
// $this->interface = new CKInterface();
$this->imagespath = PAGEBUILDERCK_MEDIA_URI . '/images/menustyles/';
require_once(PAGEBUILDERCK_PATH . '/interfaces/' . $layout . '.php');
exit;
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
// No direct access.
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
class PagebuilderckControllerLibrary extends CKController {
function __construct() {
parent::__construct();
}
/**
* Load the needed interface
*
* @return void
*/
public function load() {
// security check
CKFof::checkAjaxToken();
$page = $this->input->get('path', '', 'string');
if (! $page) return;
$section = explode('/', $page);
$section = $section[0];
// $this->interface = new CKInterface();
$file = PAGEBUILDERCK_PATH . '/libraries/' . $page;
$content = file_get_contents($file);
$json = json_decode($content);
if (! isset($json->htmlcode)) echo 'error';
// replace vars to allow data to be moved from another server
$htmlcode = $json->htmlcode;
$htmlcode = str_replace("|URIROOT|", JUri::root(true), $htmlcode);
$htmlcode = str_replace("|URIBASE|", PAGEBUILDERCK_URI_ROOT, $htmlcode);
$htmlcode = str_replace("|PBCK_COMPONENT|", "components/com_pagebuilderck", $htmlcode);
$htmlcode = str_replace("|PBCK_ADMIN_COMPONENT|", "administrator/components/com_pagebuilderck", $htmlcode);
$htmlcode = str_replace("|IMPORTFOLDER|", 'administrator/components/com_pagebuilderck/libraries/' . $section, $htmlcode);
echo $htmlcode;
exit;
}
}

View File

@@ -0,0 +1,91 @@
<?php
// No direct access
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
$com_path = JPATH_SITE . '/components/com_content/';
JLoader::register('ContentHelperRoute', $com_path . 'helpers/route.php');
class PagebuilderckControllerLinks extends CKController {
function __construct() {
parent::__construct();
}
/**
* Load the articles and categories list
*
* @return json
*/
public function ajaxShowArticles() {
// security check
CKFof::checkAjaxToken();
$parentId = $this->input->get('parentid', 0, 'int');
$model = $this->getModel();
// $model = $this->getModel('Links', '', array());
$categories = $model->getCategoriesById($parentId);
$articles = $model->getArticlesByCategoryId($parentId);
$items = array_merge($categories, $articles);
?>
<div class="cksubfolder">
<?php
// Access filter
$access = !JComponentHelper::getParams('com_content')->get('show_noauth');
$authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
foreach ($items as $item) {
$Itemid = ''; //test
$hasChild = isset($item->rgt) &&
( (int)$item->rgt - (int)$item->lft > 1
|| $item->counter > 0
) ? true : false; // faire count articles
$icon = isset($item->rgt) ? 'folder' : 'file';
// check if category or article
if ($item->type == 'article') {
$item->slug = $item->id . ':' . $item->alias;
if ($access || in_array($item->access, $authorised))
{
// We know that user has the privilege to view the article
$item->link = ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language);
} else {
continue;
}
} else {
if ($access || in_array($item->access, $authorised))
{
$item->link = ContentHelperRoute::getCategoryRoute($item->id);
} else {
continue;
}
}
?>
<div class="ckfoldertree parent">
<div class="ckfoldertreetoggler <?php if (! $hasChild) { echo 'empty'; } ?>" onclick="ckLinksArticlesToggleTreeSub(this, <?php echo $item->id ?>)" ></div>
<div class="ckfoldertreename hasTip" title="<?php echo $item->link ?>" onclick="ckSetLinksArticlesUrl('<?php echo $item->link ?>')"><span class="icon-<?php echo $icon ?>"></span><?php echo $item->title; ?>
<?php if (isset($item->counter)) { ?><div class="ckfoldertreecount"><?php echo $item->counter ?></div><?php } ?>
</div>
</div>
<?php
}
?>
</div>
<?php
exit;
}
private function getCategories($parentId) {
}
private function getArticles($parentId) {
$query = "SELECT id, title, alias, catid"
. " FROM #__content"
. " WHERE catid = " . (int)$parentId
. " ORDER BY title ASC"
;
$articles = CKFof::dbLoadObjectList($query);
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
// No direct access.
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
/**
* Pages list controller class.
*/
class PagebuilderckControllerModules2 extends CKController {
function __construct() {
parent::__construct();
}
/**
* Proxy for getModel.
* @since 1.6
*/
public function getModel($name = 'modules2', $prefix = 'PagebuilderckModel', $config = array()) {
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
return $model;
}
public function import() {
exit('import not allowed');
$app = JFactory::getApplication();
if ($importClass = PagebuilderckHelper::getParams('import')) {
$importClass->importFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=modules2", $msg, 'error');
return false;
}
}
public function export() {
exit('export not allowed');
$app = JFactory::getApplication();
if ($exportClass = PagebuilderckHelper::getParams('export')) {
$exportClass->exportFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=modules2", $msg, 'error');
return false;
}
}
}

View File

@@ -0,0 +1,139 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.page-creator.com - https://www.joomlack.fr
*/
// No direct access
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
/**
* Page controller class.
*/
class PagebuilderckControllerPage extends CKController {
function __construct() {
parent::__construct();
}
public function apply() {
return $this->save(0, 'apply');
}
public function ajaxSave($id = 0, $task = 'save') {
$this->save($id, $task, true);
exit;
}
/**
* Method to save a page
*
* @return void
*/
public function save($id = 0, $task = 'save', $ajax = false) {
// Check for request forgeries.
if ($ajax === true) {
CKFof::checkAjaxToken();
} else {
CKFof::checkToken();
}
$model = $this->getModel();
// Initialise variables.
$appendToUrl = $this->input->get('tmpl') ? '&tmpl=' . $this->input->get('tmpl') : '';
$layout = $this->input->get('layout') == 'modal' ? '&layout=modal' : '&layout=edit';
// Get the user data.
$data = array();
$data['id'] = $this->input->get('id', $id, 'int');
$id = $data['id'];
$data['title'] = $this->input->get('title', '', 'string');
$data['alias'] = '';
$data['ordering'] = 0;
$data['state'] = 1;
$data['created'] = null;
// $data['created'] = '0000-00-00 00:00:00';
$data['catid'] = '';
$data['created_by'] = 0;
$data['params'] = $this->input->get('params', '', 'string');
$data['access'] = 1;
$data['options'] = $this->input->get('options', array(), 'array');
$data['htmlcode'] = $this->input->get('htmlcode', '', 'raw');
$data['htmlcode'] = str_replace(JUri::root(true), "|URIROOT|", $data['htmlcode']);
$data['categories'] = $this->input->get('categories', array(), 'array');
$data['styles'] = $this->input->get('styles', array(), 'array');
// Check for errors.
if ($data === false) {
CKFof::enqueueMessage('ERROR : NO DATA SAVED', 'warning');
// Redirect back to the edit screen.
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=page'.$layout.'&id=' . $id . $appendToUrl);
return false;
}
// Attempt to save the data.
$return = $model->save($data);
// Check for errors.
if ($return === false) {
// Redirect back to the edit screen.
CKFof::enqueueMessage(JText::_('CK_ITEM_SAVED_FAILED'), 'warning');
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=page' . $layout . '&id=' . $id . $appendToUrl);
return false;
}
// Redirect to the list screen.
CKFof::enqueueMessage(JText::_('CK_ITEM_SAVED_SUCCESS'));
$model->checkin($return);
switch ($task)
{
case 'apply':
// Redirect back to the edit screen.
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=page' . $layout . '&id=' . $return . $appendToUrl);
break;
default:
// Redirect to the list screen.
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=pages', false);
break;
}
}
/**
* copy an existing page
* @return void
*/
function copy() {
// security check
CKFof::checkToken();
$model = $this->getModel();
$input = JFactory::getApplication()->input;
$cid = $this->input->get('cid', '', 'array');
$id = (int) $cid[0];
if (!$model->copy($id)) {
$msg = JText::_('CK_COPY_ERROR');
$type = 'error';
} else {
$msg = JText::_('CK_COPY_SUCCESS');
$type = 'message';
}
CKFof::redirect('index.php?option=com_pagebuilderck', $msg, $type);
}
function cancel() {
$this->getModel()->checkin($this->input->get('id', 0, 'int'));
//Redirect back to list
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=pages');
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
// No direct access.
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
/**
* Pages list controller class.
*/
class PagebuilderckControllerPages extends CKController {
function __construct() {
parent::__construct();
}
public function import() {
$app = JFactory::getApplication();
if ($importClass = PagebuilderckHelper::getParams('import')) {
$importClass->importFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=pages", $msg, 'error');
return false;
}
}
public function export() {
$app = JFactory::getApplication();
if ($exportClass = PagebuilderckHelper::getParams('export')) {
$exportClass->exportFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=pages", $msg, 'error');
return false;
}
}
function checkin() {
$this->getModel()->checkin($this->input->get('id', 0, 'int'));
//Redirect back to list
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=pages');
}
}

View File

@@ -0,0 +1,98 @@
<?php
// No direct access
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKfile;
use Pagebuilderck\CKfolder;
use Pagebuilderck\CKFof;
class PagebuilderckControllerPixabay extends CKController {
function __construct() {
parent::__construct();
}
/**
* Upload the image
*
* @return json : result = boolean on success, file = the image filename
*/
public function upload() {
// security check
CKFof::checkAjaxToken();
$url = $this->input->get('image_url', '', 'url');
// $url = 'https://pixabay.com/get/57e6d04b4b5bb114a6da837ec32f2a7f1038dbed5b59724e7c_1280.jpg';
$destFolder = JPATH_ROOT . '/images/pixabay/';
$fileName = basename($url);
$filePath = $destFolder . $fileName;
// create the destination folder if not exists
if (! file_exists($destFolder)) {
$result = CKFolder::create($destFolder);
if (! $result) {
echo '{"status" : "0", "file" : "", "message" : "Error on folder creation"}';
exit();
}
}
// get the file from url
set_time_limit(0);
try {
$file = file_get_contents(urldecode($url));
} catch (Exception $e) {
echo 'Exception : ', $e->getMessage(), "\n";
exit;
}
if (! $file && extension_loaded('curl')) {
$ch = curl_init();
$timeout = 30;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file = curl_exec($ch);
curl_close($ch);
}
if (file_exists($filePath)) {
$result = true;
} else {
// store the file locally
$result = file_put_contents($filePath, $file);
if (! $result) {
echo '{"status" : "0", "file" : "", "message" : "Error on file creation"}';
exit();
}
$fileArray = array(
"name" => $fileName
,"type" => "image/png"
,"tmp_name" => $filePath
,"error" => 0
,"size" => filesize($filePath)
,"filepath" => $destFolder
);
// Trigger the onContentBeforeSave event.
$fileObj = new JObject($fileArray);
$result = CKFof::triggerEvent('onContentBeforeSave', array('com_media.file', &$fileObj, true));
if (in_array(false, $result, true))
{
// There are some errors in the plugins
echo '{"status" : "0", "message" : "' . JText::plural('COM_MEDIA_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)) . '"}';
exit;
}
}
echo '{"status" : "1", "file" : "' . 'images/pixabay/' . $fileName . '"}';
exit;
}
}

View File

@@ -0,0 +1,137 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.page-creator.com - https://www.joomlack.fr
*/
// No direct access
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
/**
* Page controller class.
*/
class PagebuilderckControllerStyle extends CKController {
function __construct() {
parent::__construct();
}
public function apply() {
return $this->save(0, 'apply');
}
public function ajaxSave($id = 0, $task = 'save') {
$this->save($id, $task, true);
exit;
}
/**
* Method to save a page
*
* @return void
*/
public function save($id = 0, $task = 'save', $ajax = false) {
// Check for request forgeries.
if ($ajax === true) {
CKFof::checkAjaxToken();
} else {
CKFof::checkToken();
}
$model = $this->getModel();
// Initialise variables.
$appendToUrl = $this->input->get('tmpl') ? '&tmpl=' . $this->input->get('tmpl') : '';
$layout = $this->input->get('layout') == 'modal' ? '&layout=modal' : '&layout=edit';
// Get the user data.
$data = array();
$data['id'] = $this->input->get('id', $id, 'int');
$id = $data['id'];
$data['title'] = $this->input->get('title', '', 'string');
$data['alias'] = '';
$data['ordering'] = 0;
$data['state'] = 1;
$data['created'] = null;
// $data['created'] = '0000-00-00 00:00:00';
$data['catid'] = '';
$data['created_by'] = 0;
// $data['params'] = $this->input->get('params', '', 'string');
$data['access'] = 1;
// $data['options'] = $this->input->get('options', array(), 'array');
$data['htmlcode'] = $this->input->get('htmlcode', '', 'raw');
$data['htmlcode'] = str_replace(JUri::root(true), "|URIROOT|", $data['htmlcode']);
// Check for errors.
if ($data === false) {
CKFof::enqueueMessage('ERROR : NO DATA SAVED', 'warning');
// Redirect back to the edit screen.
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=style'.$layout.'&id=' . $id . $appendToUrl);
return false;
}
// Attempt to save the data.
$return = $model->save($data);
// Check for errors.
if ($return === false) {
// Redirect back to the edit screen.
CKFof::enqueueMessage(JText::_('CK_ITEM_SAVED_FAILED'), 'warning');
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=style' . $layout . '&id=' . $id . $appendToUrl);
return false;
}
// Redirect to the list screen.
CKFof::enqueueMessage(JText::_('CK_ITEM_SAVED_SUCCESS'));
$model->checkin($return);
switch ($task)
{
case 'apply':
// Redirect back to the edit screen.
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=style' . $layout . '&id=' . $return . $appendToUrl);
break;
default:
// Redirect to the list screen.
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=styles', false);
break;
}
}
/**
* copy an existing style
* @return void
*/
function copy() {
// security check
CKFof::checkToken();
$model = $this->getModel();
$input = JFactory::getApplication()->input;
$cid = $this->input->get('cid', '', 'array');
$id = (int) $cid[0];
if (!$model->copy($id)) {
$msg = JText::_('CK_COPY_ERROR');
$type = 'error';
} else {
$msg = JText::_('CK_COPY_SUCCESS');
$type = 'message';
}
CKFof::redirect('index.php?option=com_pagebuilderck&view=styles', $msg, $type);
}
function cancel() {
$this->getModel()->checkin($this->input->get('id', 0, 'int'));
//Redirect back to list
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=styles');
}
}

View File

@@ -0,0 +1,69 @@
<?php
/**
* @name Page Builder CK
* @package com_pagebuilderck
* @copyright Copyright (C) 2015. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
// No direct access.
defined('_JEXEC') or die;
use Pagebuilderck\CKController;
use Pagebuilderck\CKFof;
/**
* Pages list controller class.
*/
class PagebuilderckControllerStyles extends CKController {
function __construct() {
parent::__construct();
}
public function import() {
$app = JFactory::getApplication();
if ($importClass = PagebuilderckHelper::getParams('import')) {
$importClass->importFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=pages", $msg, 'error');
return false;
}
}
public function export() {
$app = JFactory::getApplication();
if ($exportClass = PagebuilderckHelper::getParams('export')) {
$exportClass->exportFile();
} else {
$msg = JText::_('CK_PAGEBUILDERCK_PARAMS_NOT_FOUND');
$app->redirect("index.php?option=com_pagebuilderck&view=pages", $msg, 'error');
return false;
}
}
function checkin() {
$this->getModel()->checkin($this->input->get('id', 0, 'int'));
//Redirect back to list
CKFof::redirect(PAGEBUILDERCK_ADMIN_URL . '&view=pages');
}
public function load() {
CKFof::checkAjaxToken();
$model = $this->getModel();
$cid = $this->input->get('styles', '', 'array');
if (empty($cid)) {
echo '';
} else {
// Attempt to save the data.
$styles = $model->getStyles($cid);
foreach($styles as $style) {
echo $style->stylecode;
}
}
exit;
}
}