Your IP : 216.73.216.224


Current Path : /var/www/html/administrator/components/com_jchat/Controller/
Upload File :
Current File : /var/www/html/administrator/components/com_jchat/Controller/EmoticonsController.php

<?php
namespace JExtstore\Component\JChat\Administrator\Controller;
/**
 * @package JCHAT::EMOTICONS::administrator::components::com_jchat
 * @subpackage controllers
 * @author Joomla! Extensions Store
 * @copyright (C) 2024 - Joomla! Extensions Store
 * @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html  
 */
defined ( '_JEXEC' ) or die ( 'Restricted access' );
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Filter\InputFilter;
use Joomla\String\StringHelper;
use JExtstore\Component\JChat\Administrator\Framework\Controller as JChatController;

/**
 * Main emoticons controller manager
 * @package JCHAT::EMOTICONS::administrator::components::com_jchat
 * @subpackage controllers
 * @since 3.2
 */
class EmoticonsController extends JChatController {
	/**
	 * Set model state from session userstate
	 * 
	 * @access protected
	 * @param string $scope        	
	 * @return object
	 */
	protected function setModelState($scope = 'default', $ordering = true): object {
		$option = $this->option;
		
		$filter_order = $this->getUserStateFromRequest("$option.$scope.filter_order", 'filter_order', 'ordering', 'cmd');
		$filter_order_Dir = $this->getUserStateFromRequest("$option.$scope.filter_order_Dir", 'filter_order_Dir', 'asc', 'word');
		$filter_state = $this->getUserStateFromRequest ( "$option.$scope.filterstate", 'filter_state', null );
		
		$defaultModel = parent::setModelState($scope);
		
		// Set model state  
		$defaultModel->setState('order', $filter_order);
		$defaultModel->setState('order_dir', $filter_order_Dir);
		$defaultModel->setState('state', $filter_state );
		
		return $defaultModel;
	}
	
	/**
	 * Default listEntities
	 * 
	 * @access public
	 * @param $cachable string
	 *       	 the view output will be cached
	 * @return void
	 */
	function display($cachable = false, $urlparams = false) {
		// Set model state
		$defaultModel = $this->setModelState('emoticons');
		 
		// Parent construction and view display
		parent::display($cachable, $urlparams = false);
	}
	
	/**
	 * AS SMVC entity here we treat HTTP request and identifier map
	 * @access public
	 * @return void
	 */
	function storeEmoticon() {
		// Id entit� risposta ajax che identifica il subtask da eseguire in questo caso
		$params = json_decode($this->app->getInput()->getString('data', null));
		$userData = new \stdClass();
		
		// This model maps Remote Procedure Call
		$model = $this->getModel ();
		if(method_exists($model, $params->idtask)) {
			$filter = InputFilter::getInstance();
			if(isset($params->param->linkurl)) {
				$params->param->linkurl = $filter->clean($params->param->linkurl, 'string');
			}
			if(isset($params->param->keycode)) {
				$params->param->keycode = $filter->clean(strip_tags($params->param->keycode), 'username');
				$params->param->keycode = StringHelper::str_ireplace(array('/'), '', $params->param->keycode);
			}
			$userData = $model->{$params->idtask} ($params->param);
		}
	
		// Format response for JS client as requested
		$document = $this->app->getDocument();
		$viewType = $document->getType ();
		$coreName = $this->getName ();
	
		$view =  $this->getView ( $coreName, $viewType, '', array ('base_path' => $this->basePath ) );
		$view->display ($userData);
	}

	/**
	 * Class Constructor
	 * 
	 * @access public
	 * @return Object&
	 */
	public function __construct($config = array(), ?MVCFactoryInterface $factory = null, $app = null, $input = null) {
		parent::__construct($config, $factory, $app, $input);
		
		$this->registerTask ( 'moveorder_up', 'moveOrder' );
		$this->registerTask ( 'moveorder_down', 'moveOrder' );
	}
}