| Current Path : /home/atice/www/plugins/fabrik_list/copy/ |
| Current File : /home/atice/www/plugins/fabrik_list/copy/copy.php |
<?php
/**
* List Copy Row plugin
*
* @package Joomla.Plugin
* @subpackage Fabrik.list.copy
* @copyright Copyright (C) 2005-2020 Media A-Team, Inc. - All rights reserved.
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
// No direct access
defined('_JEXEC') or die('Restricted access');
// Require the abstract plugin class
require_once COM_FABRIK_FRONTEND . '/models/plugin-list.php';
/**
* Add an action button to the list to copy rows
*
* @package Joomla.Plugin
* @subpackage Fabrik.list.copy
* @since 3.0
*/
class PlgFabrik_ListCopy extends PlgFabrik_List
{
/**
* Button prefix
*
* @var string
*/
protected $buttonPrefix = 'copy';
/**
* Prep the button if needed
*
* @param array &$args Arguments
*
* @return bool;
*/
public function button(&$args)
{
parent::button($args);
return true;
}
/**
* Get the button label
*
* @return string
*/
protected function buttonLabel()
{
return FText::_($this->getParams()->get('copytable_button_label', parent::buttonLabel()));
}
/**
* Get button image
*
* @since 3.1b
*
* @return string image
*/
protected function getImageName()
{
$img = parent::getImageName();
if (FabrikWorker::j3() && $img === 'copy.png')
{
$img = 'copy';
}
return $img;
}
/**
* Get the parameter name that defines the plugins acl access
*
* @return string
*/
protected function getAclParam()
{
return 'copytable_access';
}
/**
* Can the plug-in select list rows
*
* @return bool
*/
public function canSelectRows()
{
return true;
}
/**
* Do the plug-in action
*
* @param array $opts Custom options
*
* @return bool
*/
public function process($opts = array())
{
$model = $this->getModel();
$ids = $this->app->input->get('ids', array(), 'array');
$formModel = $model->getFormModel();
return $model->copyRows($ids);
}
/**
* Get the message generated in process()
*
* @param int $c plugin render order
*
* @return string
*/
public function process_result($c)
{
$ids = $this->app->input->get('ids', array(), 'array');
return JText::sprintf('PLG_LIST_ROWS_COPIED', count($ids));
}
/**
* Return the javascript to create an instance of the class defined in formJavascriptClass
*
* @param array $args Array [0] => string table's form id to contain plugin
*
* @return bool
*/
public function onLoadJavascriptInstance($args)
{
parent::onLoadJavascriptInstance($args);
$opts = $this->getElementJSOptions();
$opts = json_encode($opts);
$this->jsInstance = "new FbListCopy($opts)";
return true;
}
/**
* Load the AMD module class name
*
* @return string
*/
public function loadJavascriptClassName_result()
{
return 'FbListCopy';
}
}