| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/valence/administrator/components/com_itemrating/models/ |
Upload File : |
<?php
/**
* @version 2.1.6
* @package com_itemrating
* @copyright Copyright (C) 2014. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Joomunited <contact@joomunited.com> - www.joomunited.com
*/
// No direct access.
defined('_JEXEC') or die;
jimport('joomla.application.component.modeladmin');
/**
* Itemrating model.
*/
class ItemratingModelGroup extends JModelAdmin
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_ITEMRATING';
/**
* Returns a reference to the a Table object, always creating it.
*
* @param type The table type to instantiate
* @param string A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional.
* @return JTable A database object
* @since 1.6
*/
public function getTable($type = 'Group', $prefix = 'ItemratingTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to save the form data.
*
* @param array The form data.
*
* @return boolean True on success.
* @since 1.6
*/
public function save($data)
{
$data['styling']=json_encode(array("outer_border"=>"#".JFactory::getApplication()->input->getString('outer_border'),"head_background"=>"#".JFactory::getApplication()->input->getString('head_background'),"head_color"=>"#".JFactory::getApplication()->input->getString('head_color'),"item_background"=>"#".JFactory::getApplication()->input->getString('item_background'),"score_bg"=>"#".JFactory::getApplication()->input->getString('score_bg'),"link_color"=>"#".JFactory::getApplication()->input->getString('link_color'),"bar_bg"=>"#".JFactory::getApplication()->input->getString('bar_bg'),"vote_color"=>"#".JFactory::getApplication()->input->getString('vote_color'),"show_vote"=>$data['show_vote'],'score_position'=>$data['score_position'],'score_type'=>$data['score_type']));
$data['customcategory']=json_encode($data['customcategory']);
if(parent::save($data))
{
return true;
}
}
/**
* Method to get the record form.
*
* @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)
{
// Initialise variables.
$app = JFactory::getApplication();
// Get the form.
$form = $this->loadForm('com_itemrating.group', 'group', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_itemrating.edit.group.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
/**
* Method to get a single record.
*
* @param integer The id of the primary key.
*
* @return mixed Object on success, false on failure.
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk)) {
//Do any procesing on fields here if needed
}
return $item;
}
/**
* Prepare and sanitise the table prior to saving.
*
* @since 1.6
*/
protected function prepareTable($table)
{
jimport('joomla.filter.output');
if (empty($table->id)) {
// Set ordering to the last item if not set
if (@$table->ordering === '') {
$db = JFactory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__itemrating_group');
$max = $db->loadResult();
$table->ordering = $max+1;
}
}
}
}