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(); } }