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,72 @@
<?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
*/
defined('_JEXEC') or die;
use Pagebuilderck\CKModel;
use Pagebuilderck\CKFof;
class PagebuilderckModelArticles extends CKModel {
protected $context = 'pagebuilderck.articles';
public function __construct() {
parent::__construct();
}
/**
* Build an SQL query to load the list data.
*
* @return integer the item id
*/
public function getItems() {
// Create a new query object.
$db = CKFof::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('`#__content` AS a');
// Filter by search in title
$search = $this->getState('filter_search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('a.id = ' . (int) substr($search, 3));
} else {
$search = $db->Quote('%' .$search . '%');
$query->where('(' . 'a.title LIKE ' . $search . ' )');
}
}
// pagebuilderck_editor":"1
$query->where('a.attribs LIKE ' . $db->Quote('%pagebuilderck_editor":"1%') );
// Do not list the trashed items
$query->where('a.state > -1');
// Add the list ordering clause.
$orderCol = $this->state->get('filter_order');
$orderDirn = $this->state->get('filter_order_Dir');
if ($orderCol && $orderDirn) {
$query->order($orderCol . ' ' . $orderDirn);
}
$limitstart = $this->state->get('limitstart');
$limit = $this->state->get('limit');
$db->setQuery($query, $limitstart, $limit);
$items = $db->loadObjectList();
// automatically get the total number of items from the query
$total = $this->getTotal($query);
$this->state->set('limit_total', (empty($total) ? 0 : (int)$total));
return $items;
}
}

View File

@@ -0,0 +1,106 @@
<?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
*/
defined('_JEXEC') or die;
use Pagebuilderck\CKModel;
class PagebuilderckModelBrowse extends CKModel {
public function __construct() {
parent::__construct();
}
/*
* Get a list of folders and files
*/
public function getItemsList($type = 'image') {
$input = JFactory::getApplication()->input;
$type = $input->get('type', $type, 'string');
switch ($type) {
case 'video' :
$filetypes = array('.mp4', '.ogv', '.webm');
break;
case 'audio' :
$filetypes = array('.mp3', '.ogg');
break;
case 'image' :
default :
$filetypes = array('.jpg', '.jpeg', '.png', '.gif', '.tiff', '.webp');
break;
}
$folder = $input->get('folder', 'images', 'string');
$tree = new stdClass();
// look for all folder and files
$this->getSubfolder(JPATH_SITE . '/' . $folder, $tree, implode('|', $filetypes), 1);
$tree = $this->prepareList($tree);
return $tree;
}
/*
* List the subfolders and files according to the filter
*/
private function getSubfolder($folder, &$tree, $filter, $level) {
$folders = JFolder::folders($folder, '.', $recurse = false, $fullpath = true);
if (! count($folders)) return;
foreach ($folders as $f) {
// list all authorized files from the folder
$files = JFolder::files($f, $filter, $recurse = false, $fullpath = false);
$fName = JFile::makeSafe($f);
$tree->$fName = new stdClass();
$name = explode('/', $f);
$name = end($name);
$tree->$fName->name = $name;
$tree->$fName->path = $f;
$tree->$fName->files = $files;
$tree->$fName->level = $level;
// recursive loop
$this->getSubfolder($f, $tree, $filter, $level+1);
}
return;
}
/*
* Set level diff and check for depth
*/
private function prepareList($items) {
if (! $items) return $items;
$lastitem = 0;
foreach ($items as $i => $item)
{
$item->deeper = false;
$item->shallower = false;
$item->level_diff = 0;
if (isset($items->$lastitem))
{
$items->$lastitem->deeper = ($item->level > $items->$lastitem->level);
$items->$lastitem->shallower = ($item->level < $items->$lastitem->level);
$items->$lastitem->level_diff = ($items->$lastitem->level - $item->level);
}
$lastitem = $i;
$item->basepath = str_replace(JPATH_SITE, '', $item->path);
$item->basepath = str_replace('\\', '/', $item->basepath);
$item->basepath = trim($item->basepath, '/');
}
return $items;
}
}

View File

@@ -0,0 +1,103 @@
<?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
*/
defined('_JEXEC') or die;
use Pagebuilderck\CKModel;
use Pagebuilderck\CKFof;
class PagebuilderckModelCategories extends CKModel {
protected $context = 'pagebuilderck.categories';
protected $table = '#__pagebuilderck_categories';
public function __construct() {
parent::__construct();
}
/**
* Build an SQL query to load the list data.
*
* @return array of items
*/
public function getItems() {
// Create a new query object.
$db = CKFof::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('`#__pagebuilderck_categories` AS a');
// Filter by search in title
$search = $this->getState('filter_search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('a.id = ' . (int) substr($search, 3));
} else {
$search = $db->Quote('%' .$search . '%');
$query->where('(' . 'a.title LIKE ' . $search . ' )');
}
}
// filter by state if available
$state = $this->getState('filter_state');
if (! empty($state)) $query->where('a.state = ' . $state);
// Do not list the trashed items
$query->where('a.state > -1');
// Add the list ordering clause.
$orderCol = $this->state->get('filter_order');
$orderDirn = $this->state->get('filter_order_Dir');
if ($orderCol && $orderDirn) {
$query->order($orderCol . ' ' . $orderDirn);
}
$limitstart = $this->state->get('limitstart');
$limit = $this->state->get('limit');
$db->setQuery($query, $limitstart, $limit);
$items = $db->loadObjectList();
// automatically get the total number of items from the query
$total = $this->getTotal($query);
$this->state->set('limit_total', (empty($total) ? 0 : (int)$total));
return $items;
}
public function save($data) {
$id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('category.id');
$user = CKFof::getUser();
$date = JFactory::getDate();
if ($id) {
//Check the user can edit this item
$authorised = $user->authorise('core.edit', 'category.' . $id);
} else {
//Check the user can create new items in this section
$authorised = $user->authorise('core.create', 'com_pagebuilderck');
$data['created'] = $date->toSql();
}
if ($authorised !== true) {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
return false;
}
// save the date
$data['modified'] = $date->toSql();
// make a backup before save
// PagebuilderckHelper::makeBackup($this->getItem());
$storeid = CKFof::dbStore($this->table, $data);
return $storeid;
}
}

View File

@@ -0,0 +1,203 @@
<?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\CKModel;
use Joomla\Registry\Registry;
use Pagebuilderck\CKFof;
jimport('joomla.event.dispatcher');
class PagebuilderckModelContenttype extends CKModel {
var $_item = null;
public function __construct() {
parent::__construct();
}
/**
* Method to get the profile form.
*
* The base form is loaded from XML
*
* @param array $data An optional array of data for the form to interogate.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @return JForm A JForm object on success, false on failure
* @since 1.6
*/
public function getForm($data = array(), $loadData = true) {
// Get the form.
$form = $this->loadForm('com_pagebuilderck.contenttype', 'contenttype', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
/**
* Method to get an ojbect.
*
* @param integer The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
public function &getData($type = null) {
$app = JFactory::getApplication();
if ($this->_item === null) {
$this->_item = false;
if (empty($type)) {
$type = $app->input->get('type', '', 'string');
}
// Get a new object.
$this->_item = new stdClass();
$this->_item->type = $type;
$this->_item->htmlcode = PagebuilderckHelper::getOption('contenttype.' . $type);
$this->_item->stylecode = PagebuilderckHelper::getOption('contenttype.' . $type . '.stylecode');
}
$this->_item->htmlcode = str_replace("|URIROOT|", JUri::root(true), $this->_item->htmlcode);
return $this->_item;
}
/**
* Return ony the html code from the item
*/
/*public function getHtml($id) {
if (! $id) return '';
$data = $this->getData($id);
return isset($data->htmlcode) ? $data->htmlcode : '';
}*/
/**
* Method to save the form data.
*
* @param array The form data.
* @return mixed The user id on success, false on failure.
* @since 1.6
*/
public function save($data) {
$input = JFactory::getApplication()->input;
// $id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('contenttype.id');
$user = JFactory::getUser();
// $data['htmlcode'] = JRequest::getVar('htmlcode', '', 'post', 'string', JREQUEST_ALLOWRAW);
// $data['htmlcode'] = $data['htmlcode'] ? $data['htmlcode'] : $input->get('htmlcode', '', 'raw');
$data['htmlcode'] = str_replace(JUri::root(true), "|URIROOT|", $data['htmlcode']);
$data['stylecode'] = str_replace(JUri::root(true), "|URIROOT|", $data['stylecode']);
$type = $data['type'];
if ($type) {
//Check the user can edit this item
$authorised = $user->authorise('core.edit', 'contenttype.' . $type);
} else {
//Check the user can create new items in this section
$authorised = $user->authorise('core.create', 'com_pagebuilderck');
}
if ($authorised !== true) {
JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
return false;
}
// make a backup before save
PagebuilderckHelper::makeBackup($this->getData(), 'contenttype.' . $type);
// save the data
$id = PagebuilderckHelper::setOption('contenttype.' . $type, $data['htmlcode']);
$id = PagebuilderckHelper::setOption('contenttype.' . $type . '.stylecode', $data['stylecode']);
return $id;
}
/**
* Method to copy a record
*
* @access public
* @return boolean True on success
*/
function copy() {
$row = $this->getTable();
$cid = JFactory::getApplication()->input->get('id', '', 'array');
$pk = isset($cid[0]) ? (int) $cid[0] : null;
$data = $this->getItem($pk);
$data->id = 0;
// give the new name
$data->title .= '(copy)';
// Bind the form fields to the table
if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Make sure the record is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Store the table to the database
if (!$row->store()) {
$this->setError($row->getErrorMsg());
return false;
}
// $this->setId($row->id);
return true;
}
public function getElements() {
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select', 'a.*'
)
);
$query->from('`#__pagebuilderck_contenttypes` AS a');
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('a.id = ' . (int) substr($search, 3));
} else {
$search = $db->Quote('%' .$search . '%');
$query->where('(' . 'a.title LIKE ' . $search . ' )');
}
}
// Do not list the trashed items
$query->where('a.state > -1');
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
if ($orderCol && $orderDirn) {
$query->order($orderCol . ' ' . $orderDirn);
}
$contenttypes = $db->setQuery($query)->loadObjectList();
return $contenttypes;
}
}

View File

@@ -0,0 +1,43 @@
<?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
*/
defined('_JEXEC') or die;
use Pagebuilderck\CKModel;
class PagebuilderckModelContenttypes extends CKModel {
protected $context = 'pagebuilderck.types';
public function __construct() {
parent::__construct();
}
private $types;
public function getItems() {
if (empty($this->types)) {
// load the custom plugins
JPluginHelper::importPlugin( 'pagebuilderck' );
$items = Pagebuilderck\CKFof::triggerEvent( 'onPagebuilderckAddContentType' );
// $items = $otheritems;
$this->types = array();
if (count($items)) {
foreach ($items as $item) {
$this->types[] = $item;
}
}
}
// sort by alphabetical, by values
asort($this->types);
return $this->types;
}
}

View File

@@ -0,0 +1,100 @@
<?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\CKModel;
use Joomla\Registry\Registry;
use Pagebuilderck\CKFof;
class PagebuilderckModelElement extends CKModel {
protected $table = '#__pagebuilderck_elements';
var $item = null;
public function __construct() {
parent::__construct();
}
/**
* Method to get an ojbect.
*
* @param integer The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($id = 0) {
if (empty($this->item)) {
$id = $this->input->get('id', $id, 'int');
$this->item = CKFof::dbLoad($this->table, $id);
}
// transform params to JRegistry object
if (isset($this->item->params)) $this->item->params = new JRegistry($this->item->params);
$this->item->htmlcode = str_replace("|URIROOT|", JUri::root(true), $this->item->htmlcode);
return $this->item;
}
/**
* Return ony the html code from the item
*/
public function getHtml($id) {
if (! $id) return '';
$data = $this->getItem($id);
return isset($data->htmlcode) ? $data->htmlcode : '';
}
/**
* Method to save the form data.
*
* @param array The form data.
* @return mixed The user id on success, false on failure.
* @since 1.6
*/
public function save($data) {
$id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('page.id');
$user = CKFof::getUser();
if (isset($data['options']) && is_array($data['options']))
{
$registry = new Registry;
$registry->loadArray($data['options']);
$data['params'] = (string) $registry;
}
if ($id) {
//Check the user can edit this item
$authorised = $user->authorise('core.edit', 'element.' . $id);
} else {
//Check the user can create new items in this section
$authorised = $user->authorise('core.create', 'com_pagebuilderck');
}
if ($authorised !== true) {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
return false;
}
// make a backup before save
PagebuilderckHelper::makeBackup($this->getItem(), 'myelements');
$return = CKFof::dbStore($this->table, $data);
return $return;
}
public function getElements() {
$model = CKFof::getModel('elements');
return $model->getItems();
}
}

View File

@@ -0,0 +1,111 @@
<?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
*/
defined('_JEXEC') or die;
use Pagebuilderck\CKModel;
use Pagebuilderck\CKFof;
class PagebuilderckModelElements extends CKModel {
protected $context = 'pagebuilderck.elements';
public function __construct() {
parent::__construct();
}
/**
* Build an SQL query to load the list data.
*
*/
public function getItems() {
// Create a new query object.
$db = CKFof::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('`#__pagebuilderck_elements` AS a');
// Filter by search in title
$search = $this->getState('filter_search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('a.id = ' . (int) substr($search, 3));
} else if (stripos($search, 'type:') === 0) {
$query->where('a.type = "' . (string) substr($search, 5) . '"');
} else {
$search = $db->Quote('%' .$search . '%');
$query->where('(' . 'a.title LIKE ' . $search . ' )');
}
}
// Do not list the trashed items
$query->where('a.state > -1');
// Add the list ordering clause.
$orderCol = $this->state->get('filter_order');
$orderDirn = $this->state->get('filter_order_Dir');
if ($orderCol && $orderDirn) {
$query->order($orderCol . ' ' . $orderDirn);
}
$limitstart = $this->state->get('limitstart');
$limit = $this->state->get('limit');
$db->setQuery($query, $limitstart, $limit);
$items = $db->loadObjectList();
// automatically get the total number of items from the query
$total = $this->getTotal($query);
$this->state->set('limit_total', (empty($total) ? 0 : (int)$total));
return $items;
}
public function ajaxSave($title, $type, $html, $id = 0) {
// security check
CKFof::checkAjaxToken();
$item = CKfof::dbLoad('#__pagebuilderck_elements', (int)$id);
$item->title = $title;
$item->type = $type;
$item->htmlcode = $html;
$return = CKFof::dbStore('#__pagebuilderck_elements', $item);
if (! $return) return false;
return $return;
}
public function loadHtml($id = 0) {
if ($id == 0) return false;
$item = CKfof::dbLoad('#__pagebuilderck_elements', (int)$id);
return $item->htmlcode;
}
public function saveOrder($ordering) {
// security check
CKFof::checkAjaxToken();
// update ordering values
foreach ( $ordering as $id => $order )
{
$item = CKfof::dbLoad('#__pagebuilderck_elements', (int)$id);
if ($item->ordering != $order)
{
$item->ordering = $order;
if (! CKFof::dbStore('#__pagebuilderck_elements', $item)) {
return false;
}
}
}
return true;
}
}

View File

@@ -0,0 +1,164 @@
<?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\CKModel;
use Pagebuilderck\CKFof;
class PagebuilderckModelFonts extends CKModel {
protected $table = '#__pagebuilderck_fonts';
var $item = null;
function __construct() {
parent::__construct();
}
/**
* Method to get an ojbect.
*
* @param integer The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($id = 0) {
if (empty($this->item)) {
$id = $this->input->get('id', $id, 'int');
$this->item = CKFof::dbLoad($this->table, $id);
}
return $this->item;
}
/**
*
* @param type $fontname
* @param type $url
* @param type $local
* @return mixed The id on success, false on failure.
*/
public function saveFont($fontname, $url, $local, $filesize, $variants) {
$data = array();
$fontid = $this->searchExistingFont($fontname);
$data['id'] = $fontid;
$data['name'] = $fontname;
$data['url'] = $url;
$data['filesize'] = $filesize;
$data['variants'] = $variants;
$data['local'] = $local;
$data['state'] = 1;
return $this->save($data);
}
public function delete($fontname) {
$id = $this->searchExistingFont($fontname);
if (! $id) return false;
return CKFof::dbDelete($this->table, $id);
}
/**
*
* @param type $fontname
* @return int the font id or 0
*/
public function searchExistingFont($fontname) {
// Create a new query object.
$db = CKFof::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.id');
$query->from('`#__pagebuilderck_fonts` AS a');
$search = $db->Quote('%' .$fontname . '%');
$query->where('(' . 'a.name LIKE ' . $search . ' )');
$db->setQuery($query);
$result = $db->loadResult();
return (int)$result;
}
/**
* Method to save the page.
*
* @param array The form data.
* @return mixed The id on success, false on failure.
*/
public function save($data) {
$id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('font.id');
$user = CKFof::getUser();
if ($id) {
//Check the user can edit this item
$authorised = $user->authorise('core.edit', 'font.' . $id);
} else {
//Check the user can create new items in this section
$authorised = $user->authorise('core.create', 'com_pagebuilderck');
}
if ($authorised !== true) {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
return false;
}
$id = CKFof::dbStore($this->table, $data);
return $id;
}
public function getItems() {
// Create a new query object.
$db = CKFof::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('`#__pagebuilderck_fonts` AS a');
// Filter by search in title
$search = $this->getState('filter_search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('a.id = ' . (int) substr($search, 3));
} else if (stripos($search, 'type:') === 0) {
$query->where('a.type = "' . (string) substr($search, 5) . '"');
} else {
$search = $db->Quote('%' .$search . '%');
$query->where('(' . 'a.name LIKE ' . $search . ' )');
}
}
// Do not list the trashed items
$query->where('a.state > -1');
// Add the list ordering clause.
$orderCol = $this->state->get('filter_order');
$orderDirn = $this->state->get('filter_order_Dir');
if ($orderCol && $orderDirn) {
$query->order($orderCol . ' ' . $orderDirn);
}
$limitstart = $this->state->get('limitstart');
$limit = $this->state->get('limit');
$db->setQuery($query, $limitstart, $limit);
$items = $db->loadObjectList();
// automatically get the total number of items from the query
$total = $this->getTotal($query);
$this->state->set('limit_total', (empty($total) ? 0 : (int)$total));
return $items;
}
}

View File

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

View File

@@ -0,0 +1,72 @@
<?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
*/
defined('_JEXEC') or die;
use Pagebuilderck\CKModel;
use Pagebuilderck\CKFof;
class PagebuilderckModelLinks extends CKModel {
protected $context = 'pagebuilderck.links';
public function __construct() {
parent::__construct();
}
public function getMenus() {
// import model and use state to load items
JModelLegacy::addIncludePath(PAGEBUILDERCK_PATH . '/models', 'PagebuilderckModel');
// Get an instance of the generic articles model
$model = JModelLegacy::getInstance('Menus', 'PagebuilderckModel', array('ignore_request' => true));
return $model->getMenus();
}
public function getFiles() {
// load the items
require_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/ckbrowse.php';
return CKBrowse::getItemsList();
}
public function getArticleCategoriesRoot() {
$query = "SELECT id, title, alias, extension, access, 'category' as type"
. " FROM #__categories"
. " WHERE extension = 'com_content'"
. " AND level = 1"
. " ORDER BY lft ASC, title ASC"
;
$categories = CKFof::dbLoadObjectList($query);
return $categories;
}
public function getCategoriesById($parentId) {
$query = "SELECT id, title, alias, extension, lft, rgt, 'category' as type, access"
. " ,(SELECT COUNT(*) FROM #__content as a WHERE a.catid = c.id) AS counter"
. " FROM #__categories as c"
. " WHERE extension = 'com_content'"
. " AND parent_id = " . (int)$parentId
. " ORDER BY lft ASC, title ASC"
;
$categories = CKFof::dbLoadObjectList($query);
return $categories;
}
public function getArticlesByCategoryId($parentId) {
$query = "SELECT id, title, alias, catid, language, 'article' as type, access"
. " FROM #__content"
. " WHERE catid = " . (int)$parentId
. " ORDER BY title ASC"
;
$categories = CKFof::dbLoadObjectList($query);
return $categories;
}
}

View File

@@ -0,0 +1,126 @@
<?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
*/
defined('_JEXEC') or die;
use Pagebuilderck\CKModel;
class PagebuilderckModelMenus extends CKModel {
protected $context = 'pagebuilderck.menus';
public function __construct() {
parent::__construct();
}
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
// public function __construct($config = array()) {
// if (empty($config['filter_fields'])) {
// $config['filter_fields'] = array(
// 'id', 'a.id',
// 'name', 'a.name',
// 'state', 'a.state',
// 'published', 'a.state'
// );
// }
//
// parent::__construct($config);
// }
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*/
protected function populateState($ordering = null, $direction = null) {
// Initialise variables.
$app = JFactory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$published = $app->getUserStateFromRequest($this->context . '.filter.state', 'filter_published', '', 'string');
$this->setState('filter.state', $published);
// Load the parameters.
$params = JComponentHelper::getParams('com_pagebuilderck');
$this->setState('params', $params);
// List state information.
parent::populateState('a.id', 'asc');
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
* @return string A store id.
* @since 1.6
*/
protected function getStoreId($id = '') {
// Compile the store id.
$id.= ':' . $this->getState('filter.search');
$id.= ':' . $this->getState('filter.state');
return parent::getStoreId($id);
}
/*public function getItems() {
JModelLegacy::addIncludePath(JPATH_SITE . '/administrator/components/com_menus/models', 'MenusModel');
// Get an instance of the generic menus model
$items = JModelLegacy::getInstance('Items', 'MenusModel', array('ignore_request' => true));
$items->setState('filter.level', '1');
$items->setState('filter.menutype', 'test');
//// var_dump($items->getItems());die;
return $items;
}*/
public function getChildrenItems($menutype, $parentId) {
JModelLegacy::addIncludePath(JPATH_SITE . '/administrator/components/com_menus/models', 'MenusModel');
// Get an instance of the generic menus model
$items = JModelLegacy::getInstance('Items', 'MenusModel', array('ignore_request' => true));
if (! $parentId) $items->setState('filter.level', '1');
$items->setState('filter.menutype', $menutype);
$items->setState('filter.parent_id', $parentId);
return $items->getItems();
}
public function getMenus() {
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->qn(array('menutype', 'title')))
->from($db->qn('#__menu_types'));
// ->where($db->qn('menutype') . ' = ' . $db->q($menuType));
$menus = $db->setQuery($query)->loadObjectList();
return $menus;
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
* @since 1.6
*/
protected function getListQuery() {
}
}

View File

@@ -0,0 +1,210 @@
<?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
*/
defined('_JEXEC') or die;
use Pagebuilderck\CKModel;
use Pagebuilderck\CKFof;
class PagebuilderckModelModules extends CKModel {
protected $context = 'pagebuilderck.modules';
public function __construct() {
parent::__construct();
}
public function getItems() {
$query = $this->getListQuery();
$query->order('a.title ASC');
$query->order('a.ordering ASC');
$db = CKFof::getDbo();
$db->setQuery($query);
$items = $db->loadObjectList();
$this->translate($items);
return $items;
}
/**
* Returns an object list
*
* @param string The query
* @param int Offset
* @param int The number of records
* @return array
*/
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$query->order('a.title ASC');
// $query->order($this->_db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
$query->order('a.ordering ASC');
// $result = parent::_getList($query);
$this->translate($result);
return $result;
}
/**
* Translate a list of objects
*
* @param array The array of objects
* @return array The array of translated objects
*/
protected function translate(&$items)
{
$lang = JFactory::getLanguage();
$client = $this->getState('filter.client_id') ? 'administrator' : 'site';
foreach ($items as $item)
{
$extension = $item->module;
$source = constant('JPATH_' . strtoupper($client)) . "/modules/$extension";
$lang->load("$extension.sys", constant('JPATH_' . strtoupper($client)), null, false, true)
|| $lang->load("$extension.sys", $source, null, false, true);
$item->name = JText::_($item->name);
if (is_null($item->pages))
{
$item->pages = JText::_('JNONE');
}
elseif ($item->pages < 0)
{
$item->pages = JText::_('COM_MODULES_ASSIGNED_VARIES_EXCEPT');
}
elseif ($item->pages > 0)
{
$item->pages = JText::_('COM_MODULES_ASSIGNED_VARIES_ONLY');
}
else
{
$item->pages = JText::_('JALL');
}
}
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = CKFof::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
// $query->select(
// $this->getState(
// 'list.select',
// 'a.id, a.title, a.note, a.position, a.module, a.language,' .
// 'a.checked_out, a.checked_out_time, a.published+2*(e.enabled-1) as published, a.access, a.ordering, a.publish_up, a.publish_down'
// )
// );
$query->select('a.id, a.title, a.note, a.position, a.module, a.language, a.checked_out, a.checked_out_time, a.published+2*(e.enabled-1) as published, a.access, a.ordering, a.publish_up, a.publish_down');
$query->from($db->quoteName('#__modules') . ' AS a');
// Join over the language
$query->select('l.title AS language_title')
->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the asset groups.
$query->select('ag.title AS access_level')
->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Join over the module menus
$query->select('MIN(mm.menuid) AS pages')
->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = a.id');
// Join over the extensions
$query->select('e.name AS name')
->join('LEFT', '#__extensions AS e ON e.element = a.module')
->group(
'a.id, a.title, a.note, a.position, a.module, a.language,a.checked_out,' .
'a.checked_out_time, a.published, a.access, a.ordering,l.title, uc.name, ag.title, e.name,' .
'l.lang_code, uc.id, ag.id, mm.moduleid, e.element, a.publish_up, a.publish_down,e.enabled'
);
// Filter by access level.
if ($access = $this->getState('filter.access'))
{
$query->where('a.access = ' . (int) $access);
}
// Filter by published state
$state = $this->getState('filter.state');
$state = 1;
if (is_numeric($state))
{
$query->where('a.published = ' . (int) $state);
}
elseif ($state === '')
{
$query->where('(a.published IN (0, 1))');
}
// Filter by position
$position = $this->getState('filter.position');
if ($position && $position != 'none')
{
$query->where('a.position = ' . $db->quote($position));
}
elseif ($position == 'none')
{
$query->where('a.position = ' . $db->quote(''));
}
// Filter by module
$module = $this->getState('filter.module');
if ($module)
{
$query->where('a.module = ' . $db->quote($module));
}
// Filter by client.
$clientId = 0;
// $clientId = $this->getState('filter.client_id');
// if (is_numeric($clientId))
// {
$query->where('a.client_id = ' . (int) $clientId . ' AND e.client_id =' . (int) $clientId);
// }
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(' . 'a.title LIKE ' . $search . ' OR a.note LIKE ' . $search . ')');
}
}
// Filter on the language.
if ($language = $this->getState('filter.language'))
{
$query->where('a.language = ' . $db->quote($language));
}
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
}

View File

@@ -0,0 +1,117 @@
<?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
*/
defined('_JEXEC') or die;
use Pagebuilderck\CKModel;
use Pagebuilderck\CKFof;
class PagebuilderckModelModules2 extends CKModel {
protected $context = 'pagebuilderck.modules2';
public function __construct() {
parent::__construct();
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*/
protected function populateState($ordering = null, $direction = null) {
// Initialise variables.
$app = JFactory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$published = $app->getUserStateFromRequest($this->context . '.filter.state', 'filter_published', '', 'string');
$this->setState('filter.state', $published);
// Load the parameters.
$params = JComponentHelper::getParams('com_pagebuilderck');
$this->setState('params', $params);
// List state information.
parent::populateState('a.id', 'asc');
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
* @return string A store id.
* @since 1.6
*/
protected function getStoreId($id = '') {
// Compile the store id.
$id.= ':' . $this->getState('filter.search');
$id.= ':' . $this->getState('filter.state');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
* @since 1.6
*/
protected function getListQuery() {
// Create a new query object.
$db = CKFof::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select', 'a.*'
)
);
$query->from('`#__modules` AS a');
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('a.id = ' . (int) substr($search, 3));
} else {
$search = $db->Quote('%' .$search . '%');
$query->where('(' . 'a.title LIKE ' . $search . ' )');
}
}
// pagebuilderck_editor":"1
$query->where('a.module = ' . $db->Quote('mod_pagebuilderck') );
// Do not list the trashed items
$query->where('a.published > -1');
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
if ($orderCol && $orderDirn) {
$query->order($orderCol . ' ' . $orderDirn);
}
return $query;
}
public function getItems() {
$query = $this->getListQuery();
$db = CKFof::getDbo();
$db->setQuery($query);
return $db->loadObjectList();
}
}

View File

@@ -0,0 +1,116 @@
<?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;
//jimport('joomla.event.dispatcher');
use Joomla\Registry\Registry;
use Pagebuilderck\CKModel;
use Pagebuilderck\CKFof;
class PagebuilderckModelPage extends CKModel {
protected $table = '#__pagebuilderck_pages';
var $item = null;
function __construct() {
parent::__construct();
}
/**
* Method to get an ojbect.
*
* @param integer The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($id = 0) {
if (empty($this->item)) {
$id = $this->input->get('id', $id, 'int');
$this->item = CKFof::dbLoad($this->table, $id);
}
// transform params to JRegistry object
if (isset($this->item->params)) $this->item->params = new JRegistry($this->item->params);
// get the list of categories
if (isset($this->item->categories)) $this->item->categories = explode(',', $this->item->categories);
// get the list of styles
if (isset($this->item->styles)) $this->item->styles = explode(',', $this->item->styles);
$this->item->htmlcode = str_replace("|URIROOT|", JUri::root(true), $this->item->htmlcode);
return $this->item;
}
/**
* Method to save the page.
*
* @param array The form data.
* @return mixed The id on success, false on failure.
*/
public function save($data) {
$id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('page.id');
$user = CKFof::getUser();
$date = JFactory::getDate();
if (isset($data['options']) && is_array($data['options']))
{
$registry = new Registry;
$registry->loadArray($data['options']);
$data['params'] = (string) $registry;
}
if (isset($data['categories']) && is_array($data['categories']))
{
// $registry = new Registry;
// $registry->loadArray($data['categories']);
// $data['categories'] = (string) $registry;
$data['categories'] = implode(',', $data['categories']);
}
if (isset($data['styles']) && is_array($data['styles']))
{
// $registry = new Registry;
// $registry->loadArray($data['categories']);
// $data['categories'] = (string) $registry;
$data['styles'] = implode(',', $data['styles']);
}
if ($id) {
//Check the user can edit this item
$authorised = $user->authorise('core.edit', 'page.' . $id);
} else {
//Check the user can create new items in this section
$authorised = $user->authorise('core.create', 'com_pagebuilderck');
$data['created'] = $date->toSql();
}
if ($authorised !== true) {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
return false;
}
// save the date
$data['modified'] = $date->toSql();
// make a backup before save
PagebuilderckHelper::makeBackup($this->getItem());
$pageid = CKFof::dbStore($this->table, $data);
return $pageid;
}
public function getElements() {
$model = CKFof::getModel('elements');
return $model->getItems();
}
}

View File

@@ -0,0 +1,110 @@
<?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
*/
defined('_JEXEC') or die;
use Pagebuilderck\CKModel;
use Pagebuilderck\CKFof;
class PagebuilderckModelPages extends CKModel {
protected $context = 'pagebuilderck.pages';
protected $table = '#__pagebuilderck_pages';
private static $prefix;
private static $name;
public function __construct() {
parent::__construct();
}
protected function populateState()
{
parent::populateState();
$config = \JFactory::getConfig();
$state = CKFof::getUserState(self::$prefix . '.' . self::$name, null);
// first request, or custom user request
if ($state === null || $this->input->get('state_request', 0, 'int') === 1) {
$this->state->set('categories', $this->input->get('categories', 0));
}
}
/**
* Build an SQL query to load the list data.
*
* @return array of items
*/
public function getItems() {
// Create a new query object.
$db = CKFof::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('`#__pagebuilderck_pages` AS a');
// Filter by search in title
$search = $this->getState('filter_search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('a.id = ' . (int) substr($search, 3));
} else {
$search = $db->Quote('%' .$search . '%');
$query->where('(' . 'a.title LIKE ' . $search . ' )');
}
}
// filter by state if available
$state = $this->getState('filter_state');
if (! empty($state)) $query->where('a.state = ' . $state);
// Do not list the trashed items
$query->where('a.state > -1');
// filter by category
if (! empty($this->getState('categories'))) {
// $query->where((int)$this->getState('categories') . ' IN (2,3)');
$query->where('FIND_IN_SET(' . (int)$this->getState('categories') . ',categories) > 0');
}
// Add the list ordering clause.
$orderCol = $this->state->get('filter_order');
$orderDirn = $this->state->get('filter_order_Dir');
if ($orderCol && $orderDirn) {
$query->order($orderCol . ' ' . $orderDirn);
}
$limitstart = $this->state->get('limitstart');
$limit = $this->state->get('limit');
$db->setQuery($query, $limitstart, $limit);
$items = $db->loadObjectList();
// automatically get the total number of items from the query
$total = $this->getTotal($query);
$this->state->set('limit_total', (empty($total) ? 0 : (int)$total));
// get the categories
// $query->join('LEFT', $db->quoteName('#__pagebuilderck_categories', 'b') . ' ON (' . $db->quoteName('b.id') . ' IN( ' . $db->quoteName('a.categories') . ')' . ')');
$categories = PagebuilderckHelper::getCategories();
foreach ($items as $item) {
$item->categoriesByName = array();
if (isset($item->categories) && ! empty($item->categories)) {
$itemCategoriesArray = explode(',', $item->categories);
foreach($itemCategoriesArray as $catid) {
$item->categoriesByName[] = $categories[$catid]->name;
}
}
}
return $items;
}
}

View File

@@ -0,0 +1,182 @@
<?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;
//jimport('joomla.event.dispatcher');
use Joomla\Registry\Registry;
use Pagebuilderck\CKModel;
use Pagebuilderck\CKFof;
class PagebuilderckModelStyle extends CKModel {
protected $table = '#__pagebuilderck_styles';
var $item = null;
private $stylecode = '';
function __construct() {
parent::__construct();
}
/**
* Method to get an ojbect.
*
* @param integer The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($id = 0) {
if (empty($this->item)) {
$id = $this->input->get('id', $id, 'int');
$this->item = CKFof::dbLoad($this->table, $id);
}
// transform params to JRegistry object
// if (isset($this->item->params)) $this->item->params = new JRegistry($this->item->params);
$this->item->htmlcode = str_replace("|URIROOT|", JUri::root(true), $this->item->htmlcode);
return $this->item;
}
/**
* Method to save the page.
*
* @param array The form data.
* @return mixed The id on success, false on failure.
*/
public function save($data) {
$id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('style.id');
$user = CKFof::getUser();
$date = JFactory::getDate();
// if (isset($data['options']) && is_array($data['options']))
// {
// $registry = new Registry;
// $registry->loadArray($data['options']);
// $data['params'] = (string) $registry;
// }
if ($id) {
//Check the user can edit this item
$authorised = $user->authorise('core.edit', 'style.' . $id);
} else {
//Check the user can create new items in this section
$authorised = $user->authorise('core.create', 'com_pagebuilderck');
$data['created'] = $date->toSql();
}
if ($authorised !== true) {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
return false;
}
// save the date
$data['modified'] = $date->toSql();
// make a backup before save
// PagebuilderckHelper::makeBackup($this->getItem());
$data['stylecode'] = $this->getStylesFromHtml($data['htmlcode']);
//var_dump($data['stylecode']);die;
$pageid = CKFof::dbStore($this->table, $data);
return $pageid;
}
public function getElements() {
$model = CKFof::getModel('elements');
return $model->getItems();
}
private function getStylesFromHtml($htmlcode) {
$regexStyle = "#<div\s[^>]*ckstyleresponsive([^\"]*)\"[^>]*>(.*)<\/div>#siU"; // replace all divs with class ckstyleresponsive
$htmlcode = preg_replace_callback($regexStyle, array($this, 'replaceResponsiveStyleTag'), $htmlcode);
$regexStyle = "#<div\s[^>]*ckstyle([^\"]*)\"[^>]*>(.*)<\/div>#siU"; // replace all divs with class ckstyle
$htmlcode = preg_replace_callback($regexStyle, array($this, 'replaceStyleTag'), $htmlcode);
$regexStyle2 = "#<style\s[^>]*ckcolumnwidth([^\"]*)\"[^>]*>(.*)<\/style>#siU"; // replace all divs with class ckcolumnwidth
$htmlcode = preg_replace_callback($regexStyle2, array($this, 'replaceResponsiveStyleTag'), $htmlcode);
return trim($this->stylecode);
}
public function replaceResponsiveStyleTag($matches) {
if (!$matches[2]) return;
$styleTag = trim($matches[2]);
$styleTag = str_replace('<style>', '', $styleTag);
$styleTag = str_replace('<style type="text/css">', '', $styleTag);
$styleTag = str_replace('</style>', '', $styleTag);
$styleTag = str_replace('&nbsp;', ' ', $styleTag);
$styleTag = str_replace('<style wfd-invisible="true">', ' ', $styleTag);
if ($styleTag) {
if (stristr($matches[1], 'ckresponsiverange4')) {
$this->responsiveStyleTags4 .= str_replace('.ckresponsiveactive[ckresponsiverange="4"] ', '', $styleTag);
$this->responsiveStyleTags4 .= str_replace('.ckresponsiveactive[ckresponsiverange*="4"] ', '', $styleTag);
} else if (stristr($matches[1], 'ckresponsiverange3')) {
$this->responsiveStyleTags3 .= str_replace('.ckresponsiveactive[ckresponsiverange="3"] ', '', $styleTag);
$this->responsiveStyleTags3 .= str_replace('.ckresponsiveactive[ckresponsiverange*="3"] ', '', $styleTag);
} else if (stristr($matches[1], 'ckresponsiverange2')) {
$this->responsiveStyleTags2 .= str_replace('.ckresponsiveactive[ckresponsiverange="2"] ', '', $styleTag);
$this->responsiveStyleTags2 .= str_replace('.ckresponsiveactive[ckresponsiverange*="2"] ', '', $styleTag);
} else if (stristr($matches[1], 'ckresponsiverange1')) {
$this->responsiveStyleTags1 .= str_replace('.ckresponsiveactive[ckresponsiverange="1"] ', '', $styleTag);
$this->responsiveStyleTags1 .= str_replace('.ckresponsiveactive[ckresponsiverange*="1"] ', '', $styleTag);
} else if (stristr($styleTag, 'ckresponsiverange="4"')) {
$this->responsiveStyleTags4 .= str_replace('[ckresponsiverange="4"] ', '', $styleTag);
$this->responsiveStyleTags4 .= str_replace('[ckresponsiverange*="4"] ', '', $styleTag);
} else if (stristr($styleTag, 'ckresponsiverange="3"')) {
$this->responsiveStyleTags3 .= str_replace('[ckresponsiverange="3"] ', '', $styleTag);
$this->responsiveStyleTags3 .= str_replace('[ckresponsiverange*="3"] ', '', $styleTag);
} else if (stristr($styleTag, 'ckresponsiverange="2"')) {
$this->responsiveStyleTags2 .= str_replace('[ckresponsiverange="2"] ', '', $styleTag);
$this->responsiveStyleTags2 .= str_replace('[ckresponsiverange*="2"] ', '', $styleTag);
} else if (stristr($styleTag, 'ckresponsiverange="1"')) {
$this->responsiveStyleTags1 .= str_replace('[ckresponsiverange="1"] ', '', $styleTag);
$this->responsiveStyleTags1 .= str_replace('[ckresponsiverange*="1"] ', '', $styleTag);
} else {
if ($styleTag) $this->stylecode .= $styleTag;
}
}
return '';
}
/*
* @param array the matching strings
*
* return the module cdoe
*/
public function replaceStyleTag($matches) {
if (!$matches[2]) return;
$styleTag = trim($matches[2]);
$styleTag = str_replace('<style>', '', $styleTag);
$styleTag = str_replace('<style type="text/css">', '', $styleTag);
$styleTag = str_replace('</style>', '', $styleTag);
$styleTag = str_replace('&nbsp;', ' ', $styleTag);
$styleTag = str_replace('<style wfd-invisible="true">', '', $styleTag);
$pagebuilderckParams = JComponentHelper::getParams('com_pagebuilderck');
// check for the image path, and fix it
if (strpos($styleTag, 'url(\'/')) {
if ((int)$pagebuilderckParams->get('image_path_fix', 0, 'int') === 1) {
$find = "# url\('/(.*?)\'\)#si"; // masque de recherche pour le tag
$styleTag = preg_replace($find, ' url(\'' . JUri::root(true) . '/$1\')' , $styleTag);
}
}
// if ($styleTag) $this->styleTags .= $styleTag;
// return '';
$this->stylecode .= $styleTag;
}
}

View File

@@ -0,0 +1,92 @@
<?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
*/
defined('_JEXEC') or die;
use Pagebuilderck\CKModel;
use Pagebuilderck\CKFof;
class PagebuilderckModelStyles extends CKModel {
protected $context = 'pagebuilderck.styles';
protected $table = '#__pagebuilderck_styles';
public function __construct() {
parent::__construct();
}
/**
* Build an SQL query to load the list data.
*
* @return array of items
*/
public function getItems() {
// Create a new query object.
$db = CKFof::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('`' . $this->table . '` AS a');
// Filter by search in title
$search = $this->getState('filter_search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('a.id = ' . (int) substr($search, 3));
} else {
$search = $db->Quote('%' .$search . '%');
$query->where('(' . 'a.title LIKE ' . $search . ' )');
}
}
// filter by state if available
$state = $this->getState('filter_state');
if (! empty($state)) $query->where('a.state = ' . $state);
// Do not list the trashed items
$query->where('a.state > -1');
// Add the list ordering clause.
$orderCol = $this->state->get('filter_order');
$orderDirn = $this->state->get('filter_order_Dir');
if ($orderCol && $orderDirn) {
$query->order($orderCol . ' ' . $orderDirn);
}
$limitstart = $this->state->get('limitstart');
$limit = $this->state->get('limit');
$db->setQuery($query, $limitstart, $limit);
$items = $db->loadObjectList();
// automatically get the total number of items from the query
$total = $this->getTotal($query);
$this->state->set('limit_total', (empty($total) ? 0 : (int)$total));
return $items;
}
public function getStyles($cid) {
// Create a new query object.
$db = CKFof::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('`' . $this->table . '` AS a');
$query->where('a.id in ( ' . implode(',', $cid) .')');
// Do not list the trashed items
$query->where('a.state > -1');
$db->setQuery($query);
$items = $db->loadObjectList();
return $items;
}
}