本文整理汇总了PHP中InstallerModel类的典型用法代码示例。如果您正苦于以下问题:PHP InstallerModel类的具体用法?PHP InstallerModel怎么用?PHP InstallerModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InstallerModel类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register(InputInterface $input, OutputInterface $output)
{
$app = Bootstrapper::getApplication($this->target_dir);
ob_start();
// build the record.
$data = new \JObject();
$data->name = $this->extension;
$data->type = $this->type;
$data->element = $this->extension;
$data->client_id = $input->getOption('client_id');
$data->enabled = $input->getOption('enabled');
$data->position = $input->getOption('position');
$element = $input->getOption('element');
if (strlen($element)) {
$data->element = $element;
}
// special case for plugin, naming and folder.
if ($this->type == 'plugin') {
// set the default folder for plugins only.
$data->folder = $input->getOption('folder') ? $input->getOption('folder') : 'system';
// special case for the plugins only.
if (substr($data->element, 0, 4) == 'plg_') {
$data->element = substr($data->element, 4);
}
}
if ($this->type == 'template') {
if (substr($data->name, 0, 4) == 'tpl_') {
$data->name = substr($data->name, 4);
$data->element = substr($data->element, 4);
}
}
//need to be sure that a prefix is provided for components and modules
if (($this->type == "component" || $this->type == "module") && strpos($data->element, '_') === false) {
$prefix = array_search($this->type, $this->typeMap);
$data->element = $prefix . $this->extension;
}
// get the #__extensions model and table
require_once JPATH_ADMINISTRATOR . '/components/com_installer/models/extension.php';
$model = new \InstallerModel();
$table = $model->getTable('extension', 'JTable');
// restrict on same name and type
$unique = array('name' => $data->name, 'type' => $data->type);
// does the extension exist?
if (!$table->load($unique)) {
if ($table->save($data->getProperties())) {
if (array_key_exists($this->type, $this->exceptions)) {
$this->handleExceptions($output, $app, $data, $this->type);
}
$output->writeln("<info>Your extension registered as a '{$this->type}', with extension_id: {$table->extension_id}</info>");
} else {
$output->writeln("<info>" . $table->getError() . "</info>");
}
} else {
$output->writeln("<error>{$this->extension} {$this->type}: That extension already exists.</error>");
}
ob_end_clean();
}
示例2:
/**
* Overridden constructor
* @access protected
*/
function __construct()
{
global $mainframe;
// Call the parent constructor
parent::__construct();
}
示例3:
/**
* Overridden constructor
* @access protected
*/
function __construct()
{
global $mainframe;
// Call the parent constructor
parent::__construct();
// Set state variables from the request
$this->setState('filter.string', $mainframe->getUserStateFromRequest("com_rsgallery2_com_installer.templates.string", 'filter', '', 'string'));
}
示例4:
/**
* Overridden constructor
* @access protected
*/
function __construct()
{
global $mainframe;
// Call the parent constructor
parent::__construct();
// Set state variables from the request
$this->setState('filter.string', $mainframe->getUserStateFromRequest("com_installer.languages.string", 'filter', '', 'string'));
$this->setState('filter.client', $mainframe->getUserStateFromRequest("com_installer.languages.client", 'client', -1, 'int'));
}
示例5: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
parent::populateState('name', 'asc');
}
示例6:
/**
* Overridden constructor
* @access protected
*/
function __construct()
{
global $mainframe;
// Call the parent constructor
parent::__construct();
// Set state variables from the request
$this->setState('filter.group', $mainframe->getUserStateFromRequest("com_installer.plugins.group", 'group', '', 'cmd'));
$this->setState('filter.string', $mainframe->getUserStateFromRequest("com_installer.plugins.string", 'filter', '', 'string'));
}
示例7: _populateState
/**
* Method to auto-populate the model state.
*
* This method should only be called once per instantiation and is designed
* to be called on the first call to the getState() method unless the model
* configuration flag to ignore the request is set.
*
* @since 1.6
*/
protected function _populateState()
{
// Initialise variables.
$app =& JFactory::getApplication('administrator');
// Remember the 'Install from Directory' path.
$path = $app->getUserStateFromRequest($this->_context . '.install_directory', 'install_directory', $app->getCfg('config.tmp_path'));
$this->setState('install.directory', $path);
parent::_populateState();
}
示例8: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 3.4
*/
protected function populateState($ordering = 'name', $direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.client_id', $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', null, 'int'));
$this->setState('filter.enabled', $this->getUserStateFromRequest($this->context . '.filter.enabled', 'filter_enabled', '', 'string'));
$this->setState('filter.type', $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'string'));
$this->setState('filter.folder', $this->getUserStateFromRequest($this->context . '.filter.folder', 'filter_folder', '', 'string'));
parent::populateState($ordering, $direction);
}
示例9: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
// Prepare the utf8mb4 conversion check table
$this->prepareUtf8mb4StatusTable();
parent::populateState('name', 'asc');
}
示例10: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 3.1
*/
protected function populateState($ordering = 'name', $direction = 'asc')
{
$app = JFactory::getApplication();
// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.client_id', $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', null, 'int'));
$this->setState('filter.type', $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'string'));
$this->setState('filter.folder', $this->getUserStateFromRequest($this->context . '.filter.folder', 'filter_folder', '', 'string'));
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
parent::populateState($ordering, $direction);
}
示例11: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 3.1
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$clientId = $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', '');
$this->setState('filter.client_id', $clientId);
$categoryId = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '');
$this->setState('filter.type', $categoryId);
$group = $this->getUserStateFromRequest($this->context . '.filter.group', 'filter_group', '');
$this->setState('filter.group', $group);
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
parent::populateState('name', 'asc');
}
示例12: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
// Initialise variables.
$app = JFactory::getApplication();
$filters = JRequest::getVar('filters');
if (empty($filters)) {
$data = $app->getUserState($this->context . '.data');
$filters = $data['filters'];
} else {
$app->setUserState($this->context . '.data', array('filters' => $filters));
}
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
$this->setState('filter.search', isset($filters['search']) ? $filters['search'] : '');
$this->setState('filter.status', isset($filters['status']) ? $filters['status'] : '');
$this->setState('filter.type', isset($filters['type']) ? $filters['type'] : '');
$this->setState('filter.group', isset($filters['group']) ? $filters['group'] : '');
$this->setState('filter.client_id', isset($filters['client_id']) ? $filters['client_id'] : '');
parent::populateState('name', 'asc');
}
示例13:
/**
* Overridden constructor
* @access protected
*/
function __construct()
{
// Call the parent constructor
parent::__construct();
}
示例14: _getList
/**
* Returns an object list
*
* @param string $query The query
* @param int $limitstart Offset
* @param int $limit The number of records
*
* @return array
*
* @since 3.4
*/
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$ordering = $this->getState('list.ordering');
$search = $this->getState('filter.search');
// Replace slashes so preg_match will work
$search = str_replace('/', ' ', $search);
$db = $this->getDbo();
if ($ordering == 'name' || !empty($search) && stripos($search, 'id:') !== 0) {
$db->setQuery($query);
$result = $db->loadObjectList();
$this->translate($result);
if (!empty($search) && stripos($search, 'id:') !== 0) {
foreach ($result as $i => $item) {
if (!preg_match("/{$search}/i", $item->name) && !preg_match("/{$search}/i", $item->update_site_name)) {
unset($result[$i]);
}
}
}
JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, true);
$total = count($result);
$this->cache[$this->getStoreId('getTotal')] = $total;
if ($total < $limitstart) {
$limitstart = 0;
$this->setState('list.start', 0);
}
return array_slice($result, $limitstart, $limit ? $limit : null);
}
$query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
$result = parent::_getList($query, $limitstart, $limit);
$this->translate($result);
return $result;
}