/**
  * Method to instantiate the view.
  *
  * @param Model             $model     The model object.
  * @param Container         $container DI Container.
  * @param array             $config    View config.
  * @param \SplPriorityQueue $paths     Paths queue.
  */
 public function __construct(Model $model = null, Container $container = null, $config = array(), \SplPriorityQueue $paths = null)
 {
     parent::__construct($model, $container, $config, $paths);
     if (!$this->toolbarConfig) {
         $this->toolbarConfig = ArrayHelper::getValue($config, 'toolbar', array());
     }
 }
 /**
  * Render the profiler log data, and echo it..
  *
  * @param   string   $namespace The JProfiler instance ID. Default is the core profiler "Application".
  * @param   boolean  $asString  Return as string.
  *
  * @return  string
  */
 public static function render($namespace = 'Windwalker', $asString = false)
 {
     $app = Container::getInstance()->get('app');
     if ($namespace == 'core' || !$namespace) {
         $namespace = 'Application';
     }
     if (isset(self::$profiler[$namespace])) {
         $_PROFILER = self::$profiler[$namespace];
         $buffer = $_PROFILER->getBuffer();
         $buffer = implode("\n<br />\n", $buffer);
     } else {
         $buffer = $app->getUserState('windwalker.system.profiler.' . $namespace, array());
         $buffer = $buffer ? implode("\n<br />\n", $buffer) : '';
     }
     $buffer = $buffer ? $buffer : 'No Profiler data.';
     // Get last page logs
     $state_buffer = ArrayHelper::getValue(self::$stateBuffer, $namespace);
     if ($state_buffer) {
         $state_buffer = implode("\n<br />\n", $state_buffer);
         $buffer = $state_buffer . "\n<br />---------<br />\n" . $buffer;
     }
     // Render
     $buffer = "<pre><h3>WindWalker Debug [namespace: {$namespace}]: </h3>" . $buffer . '</pre>';
     $app->setUserState('windwalker.system.profiler.' . $namespace, '');
     if ($asString) {
         return $buffer;
     }
     echo $buffer;
     return '';
 }
 /**
  * Method to get a form object.
  *
  * @param   string    $name    The name of the form.
  * @param   string    $source  The form source. Can be XML string if file flag is set to false.
  * @param   array     $options Optional array of options for the form creation.
  * @param   boolean   $clear   Optional argument to force load a new form.
  * @param   string    $xpath   An optional xpath to search for the fields.
  *
  * @throws \Exception
  * @return  mixed  JForm object on success, False on error.
  *
  * @see     JForm
  */
 protected function loadForm($name, $source = null, $options = array(), $clear = false, $xpath = null)
 {
     // Handle the optional arguments.
     $options['control'] = ArrayHelper::getValue($options, 'control', false);
     // Create a signature hash.
     $hash = sha1($source . serialize($options));
     // Check if we can use a previously loaded form.
     if (isset($this->forms[$hash]) && !$clear) {
         return $this->forms[$hash];
     }
     // Set Form paths
     static $formLoaded;
     if (!$formLoaded) {
         // Get the form.
         // Register the paths for the form
         $paths = new \SplPriorityQueue();
         $paths->insert(JPATH_COMPONENT . '/model/form', 'normal');
         $paths->insert(JPATH_COMPONENT . '/model/field', 'normal');
         $paths->insert(JPATH_COMPONENT . '/model/rule', 'normal');
         // Legacy support to be removed in 4.0.
         $paths->insert(JPATH_COMPONENT . '/models/forms', 'normal');
         $paths->insert(JPATH_COMPONENT . '/models/fields', 'normal');
         $paths->insert(JPATH_COMPONENT . '/models/rules', 'normal');
         \JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
         \JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
         \JForm::addRulePath(JPATH_COMPONENT . '/models/rules');
         \JForm::addFormPath(JPATH_COMPONENT . '/model/form');
         \JForm::addFieldPath(JPATH_COMPONENT . '/model/field');
         \JForm::addRulePath(JPATH_COMPONENT . '/model/rule');
         // Set Form paths for Windwalker
         \JForm::addFormPath(JPATH_COMPONENT . '/model/form/' . strtolower($this->getName()));
         \JForm::addFieldPath(JPATH_COMPONENT . '/model/field/' . strtolower($this->getName()));
         \JForm::addRulePath(JPATH_COMPONENT . '/model/rule/' . strtolower($this->getName()));
         $formLoaded = true;
     }
     try {
         $form = \JForm::getInstance($name, $source, $options, false, $xpath);
         if (isset($options['load_data']) && $options['load_data']) {
             // Get the data for the form.
             $data = $this->loadFormData();
         } else {
             $data = array();
         }
         // Allow for additional modification of the form, and events to be triggered.
         // We pass the data because plugins may require it.
         $this->preprocessForm($form, $data);
         // Load the data into the form after the plugins have operated.
         $form->bind($data);
     } catch (\Exception $e) {
         throw $e;
     }
     // Store the form for later.
     $this->forms[$hash] = $form;
     return $form;
 }
 /**
  * Instantiate the controller.
  *
  * @param   \JInput           $input   The input object.
  * @param   \JApplicationCms  $app     The application object.
  * @param   array             $config  Alternative config.
  */
 public function __construct(\JInput $input = null, \JApplicationCms $app = null, $config = array())
 {
     parent::__construct($input, $app, $config);
     // Guess the item view as the context.
     $this->viewList = $this->viewList ?: ArrayHelper::getValue($config, 'view_list', $this->getName());
     // Guess the list view as the plural of the item view.
     $this->viewItem = $this->viewItem ?: ArrayHelper::getValue($config, 'view_item');
     if (empty($this->viewItem)) {
         $inflector = Inflector::getInstance();
         $this->viewItem = $inflector->toSingular($this->viewList);
     }
 }
    /**
     * The link to open modal.
     *
     * @param   string  $title    Modal title.
     * @param   string  $selector Modal select ID.
     * @param   array   $option   Modal params.
     *
     * @return  string  Link body text.
     */
    public static function modalLink($title, $selector, $option = array())
    {
        $tag = ArrayHelper::getValue($option, 'tag', 'a');
        $id = isset($option['id']) ? " id=\"{$option['id']}\"" : " id=\"{$selector}_link\"";
        $class = isset($option['class']) ? " class=\"{$option['class']} cursor-pointer\"" : ' class="cursor-pointer"';
        $onclick = isset($option['onclick']) ? " onclick=\"{$option['onclick']}\"" : '';
        $icon = ArrayHelper::getValue($option, 'icon', '');
        $button = <<<HTML
<{$tag} data-toggle="modal" data-target="#{$selector}"{$id}{$class}{$onclick}>
\t<i class="{$icon}" title="{$title}"></i>
\t{$title}
</{$tag}>
HTML;
        return $button;
    }
 /**
  * Constructor
  *
  * @param   array              $config    An array of configuration options (name, state, dbo, table_path, ignore_request).
  * @param   JoomlaContainer    $container Service container.
  * @param   \JRegistry         $state     The model state.
  * @param   \JDatabaseDriver   $db        The database adapter.
  */
 public function __construct($config = array(), JoomlaContainer $container = null, \JRegistry $state = null, \JDatabaseDriver $db = null)
 {
     parent::__construct($config, $container, $state, $db);
     if (!$this->reorderConditions) {
         $this->reorderConditions = ArrayHelper::getValue($config, 'reorder_conditions', array('catid'));
     }
     // Guess the item view as the context.
     if (empty($this->viewItem)) {
         $this->viewItem = $this->getName();
     }
     // Guess the list view as the plural of the item view.
     if (empty($this->viewList)) {
         $inflector = Inflector::getInstance();
         $this->viewList = $inflector->toPlural($this->viewItem);
     }
 }
 /**
  * Constructor
  *
  * @param   array              $config    An array of configuration options (name, state, dbo, table_path, ignore_request).
  * @param   JoomlaContainer    $container Service container.
  * @param   \JRegistry         $state     The model state.
  * @param   \JDatabaseDriver   $db        The database adapter.
  */
 public function __construct($config = array(), JoomlaContainer $container = null, \JRegistry $state = null, \JDatabaseDriver $db = null)
 {
     // These need before parent constructor.
     $this->orderCol = $this->orderCol ?: ArrayHelper::getValue($config, 'order_column', null);
     // This block should be remove after 3.0, use allowFields instead
     if (!$this->filterFields) {
         $this->filterFields = ArrayHelper::getValue($config, 'filter_fields', array());
         $this->filterFields[] = '*';
     }
     if (!$this->allowFields) {
         $this->allowFields = ArrayHelper::getValue($config, 'allow_fields', array());
         $this->allowFields[] = '*';
     }
     $this->prefix = $this->getPrefix($config);
     $this->option = 'com_' . $this->prefix;
     // Guess name for container
     $this->name = $this->name ?: ArrayHelper::getValue($config, 'name', $this->getName());
     $this->container = $container ?: $this->getContainer();
     $this->container->registerServiceProvider(new GridProvider($this->name, $this));
     $this->configureTables();
     parent::__construct($config, $container, $state, $db);
     // Guess the item view as the context.
     $this->viewList = $this->viewList ?: ArrayHelper::getValue($config, 'view_list', $this->getName());
     // Guess the list view as the plural of the item view.
     $this->viewItem = $this->viewItem ?: ArrayHelper::getValue($config, 'view_item');
     if (empty($this->viewItem)) {
         $inflector = Inflector::getInstance();
         $this->viewItem = $inflector->toSingular($this->viewList);
     }
 }
示例#8
0
<?php

/**
 * Part of Windwalker project.
 *
 * @copyright  Copyright (C) 2011 - 2014 SMS Taiwan, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */
use Windwalker\Helper\ArrayHelper;
defined('JPATH_BASE') or die;
$data = $displayData['view'];
$textPrefix = $data->view->option ?: 'LIB_WINDWALKER';
$task = ArrayHelper::getValue($displayData, 'task_prefix', '');
?>

<div class="modal hide fade" id="batchModal">
	<div class="modal-header">
		<button type="button" role="presentation" class="close" data-dismiss="modal">x</button>
		<h3><?php 
echo JText::_($textPrefix . '_BATCH_OPTIONS');
?>
</h3>
	</div>

	<div class="modal-body form-horizontal">
		<p>
			<?php 
echo JText::_($textPrefix . '_BATCH_TIP');
?>
		</p>
 /**
  * Instantiate the controller.
  *
  * @param   \JInput          $input  The input object.
  * @param   \JApplicationCms $app    The application object.
  * @param   array            $config The config object.
  */
 public function __construct(\JInput $input = null, \JApplicationCms $app = null, $config = array())
 {
     parent::__construct($input, $app, $config);
     $this->key = $this->key ?: ArrayHelper::getValue($config, 'key');
     $this->urlVar = $this->urlVar ?: ArrayHelper::getValue($config, 'urlVar');
 }
 /**
  * Add JS file to document.
  *
  * @param string $file    The css file name(with subfolder) to add.
  * @param string $name    The instance name, also means component subfolder name,
  *                        default is the name of this instance.
  * @param array  $attribs The link attributes in html element.
  *
  * @return AssetManager Return self to support chaining.
  */
 public function addJS($file, $name = null, $attribs = array())
 {
     $doc = $this->getDoc();
     if ($doc->getType() != 'html') {
         return $this;
     }
     // Use absolute URL
     if (strpos($file, 'http') === 0 || strpos($file, '//') === 0) {
         $url = $file;
         $sum = null;
     } else {
         $filePath = $this->findFile($file, 'js', $name);
         if (!$filePath) {
             $this->alert(sprintf('JS file: %s not found.', $file));
             return $this;
         }
         $sum = $filePath['sum'];
         $url = \JUri::root(true) . '/' . $filePath['file'];
     }
     $type = ArrayHelper::getValue($attribs, 'type', 'text/javascript');
     $defer = ArrayHelper::getValue($attribs, 'defer');
     $async = ArrayHelper::getValue($attribs, 'async');
     unset($attribs['type']);
     unset($attribs['media']);
     if ($this->jquery) {
         \JHtml::_('jquery.framework', $this->mootools);
     }
     $doc->addScriptVersion($url, $sum, $type, $defer, $async);
     return $this;
 }
示例#11
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @throws  \Exception
  * @return  boolean  True on success, False on error.
  */
 public function save($data)
 {
     $container = $this->getContainer();
     $table = $this->getTable();
     $dispatcher = $container->get('event.dispatcher');
     if (!empty($data['tags']) && $data['tags'][0] != '') {
         $table->newTags = $data['tags'];
     }
     $key = $table->getKeyName();
     $pk = ArrayHelper::getValue($data, $key, $this->getState($this->getName() . '.id'));
     $isNew = true;
     // Include the content plugins for the on save events.
     \JPluginHelper::importPlugin('content');
     // Load the row if saving an existing record.
     if ($pk) {
         $table->load($pk);
         $isNew = false;
     }
     // Bind the data.
     $table->bind($data);
     // Prepare the row for saving
     $this->prepareTable($table);
     // Check the data.
     if (!$table->check()) {
         throw new \Exception($table->getError());
     }
     // Trigger the onContentBeforeSave event.
     $result = $dispatcher->trigger($this->eventBeforeSave, array($this->option . '.' . $this->name, $table, $isNew));
     if (in_array(false, $result, true)) {
         throw new \Exception($table->getError());
     }
     // Store the data.
     if (!$table->store()) {
         throw new \Exception($table->getError());
     }
     // Clean the cache.
     $this->cleanCache();
     // Trigger the onContentAfterSave event.
     $dispatcher->trigger($this->eventAfterSave, array($this->option . '.' . $this->name, $table, $isNew));
     $pkName = $table->getKeyName();
     if (isset($table->{$pkName})) {
         $this->state->set($this->getName() . '.id', $table->{$pkName});
     }
     $this->state->set($this->getName() . '.new', $isNew);
     $this->postSaveHook($table);
     return true;
 }
示例#12
0
 /**
  * Gets the value of a user state variable and sets it in the session
  *
  * This is the same as the method in JApplication except that this also can optionally
  * force you back to the first page when a filter has changed
  *
  * @param   string   $key        The key of the user state variable.
  * @param   string   $request    The name of the variable passed in a request.
  * @param   string   $default    The default value for the variable if not found. Optional.
  * @param   string   $type       Filter for the variable, for valid values see {@link \JFilterInput::clean()}. Optional.
  * @param   boolean  $resetPage  If true, the limitstart in request is set to zero
  *
  * @return  array The request user state.
  */
 public function getUserStateFromRequest($key, $request, $default = null, $type = 'none', $resetPage = true)
 {
     /** @var \JApplicationCms $app */
     $app = $this->container->get('app');
     $input = $app->input;
     $oldState = $app->getUserState($key);
     $currentState = !is_null($oldState) ? $oldState : $default;
     $newState = $input->get($request, null, $type);
     /*
      * In RAD, filter & search is array with default elements,
      * so we can't directly compare them with empty value.
      * Here prepare some default value to compare them.
      */
     // Remove empty values from input, because session registry will remove empty values too.
     if ($request == 'filter' && is_array($newState)) {
         $newState = ArrayHelper::filterRecursive($newState, 'strlen');
     }
     // Add default field name '*' if we clear filter bar.
     if ($request == 'search' && '' === (string) ArrayHelper::getValue($currentState, 'field')) {
         $currentState['field'] = '*';
     }
     // Now compare them, and set start to 0 if there has any differences.
     if ($newState && $currentState != $newState && $resetPage) {
         $input->set('limitstart', 0);
     }
     // Save the new value only if it is set in this request.
     if ($newState !== null) {
         $app->setUserState($key, $newState);
     } else {
         $newState = $currentState;
     }
     return $newState;
 }
 /**
  * Method to instantiate the view.
  *
  * @param Model      $model     The model object.
  * @param Container  $container DI Container.
  * @param array      $config    View config.
  */
 public function __construct(Model $model = null, Container $container = null, $config = array())
 {
     // Setup dependencies.
     if ($model) {
         $modelName = $model->getName();
         $this->defaultModel = strtolower($modelName);
         $this->model[strtolower($modelName)] = $model;
     }
     // Prepare data
     $this->data = $this->data ?: ArrayHelper::getValue($config, 'data', new Data());
     // Prepare prefix
     $this->prefix = $this->prefix ?: ArrayHelper::getValue($config, 'prefix', $this->getPrefix());
     // Prepare option
     $this->option = $this->option ?: ArrayHelper::getValue($config, 'option', 'com_' . $this->prefix);
     // Prepare name
     $this->name = $this->name ?: ArrayHelper::getValue($config, 'name', $this->getName());
     // Prepare textPrefix
     $this->textPrefix = $this->textPrefix ?: ArrayHelper::getValue($config, 'text_prefix', $this->option);
     $this->textPrefix = strtoupper($this->textPrefix);
     $this->container = $container ?: Container::getInstance($this->option);
 }
示例#14
0
 /**
  * Configure the toolbar button set.
  *
  * @param   array   $buttonSet Customize button set.
  * @param   object  $canDo     Access object.
  *
  * @return  array
  */
 protected function configureToolbar($buttonSet = array(), $canDo = null)
 {
     $component = $this->container->get('component');
     $canDo = $canDo ?: $component->getActions($this->viewItem);
     $state = $this->data->state ?: new Registry();
     $grid = $this->data->grid;
     $filterState = $state->get('filter', array());
     return array('add' => array('handler' => 'addNew', 'args' => array($this->viewItem . '.edit.add'), 'access' => 'core.create', 'priority' => 1000), 'edit' => array('handler' => 'editList', 'args' => array($this->viewItem . '.edit.edit'), 'access' => 'core.edit', 'priority' => 900), 'duplicate' => array('handler' => 'duplicate', 'args' => array($this->viewList . '.batch.copy'), 'access' => 'core.create', 'priority' => 800), 'publish' => array('handler' => 'publish', 'args' => array($this->viewList . '.state.publish'), 'access' => 'core.edit.state', 'priority' => 700), 'unpublish' => array('handler' => 'unpublish', 'args' => array($this->viewList . '.state.unpublish'), 'access' => 'core.create', 'priority' => 600), 'checkin' => array('handler' => 'checkin', 'args' => array($this->viewList . '.check.checkin'), 'access' => 'core.create', 'priority' => 500), 'delete' => array('handler' => 'deleteList', 'args' => array($this->viewList . '.state.delete', 'JTOOLBAR_DELETE', 'LIB_WINDWALKER_TOOLBAR_CONFIRM_DELETE'), 'access' => ArrayHelper::getValue($filterState, $this->viewItem . '.' . $grid->config->get('field.state', 'state')) == -2 && $canDo->get('core.delete'), 'priority' => 400), 'trash' => array('handler' => 'trash', 'args' => array($this->viewList . '.state.trash'), 'access' => ArrayHelper::getValue($filterState, $this->viewItem . '.' . $grid->config->get('field.state', 'state')) != -2 && $canDo->get('core.edit.state'), 'priority' => 300), 'batch' => array('handler' => 'modal', 'access' => 'core.edit', 'priority' => 200), 'preferences' => array('handler' => 'preferences', 'access' => 'core.edit', 'priority' => 100));
 }
 /**
  * Register all buttons.
  *
  * @return  void
  */
 public function registerButtons()
 {
     $buttons = $this->buttonSet;
     $queue = new \SplPriorityQueue();
     foreach ($buttons as $name => $button) {
         $priority = isset($priority) ? ArrayHelper::getValue($button, 'priority', $priority + 10) : 9999;
         $queue->insert($name, $priority);
     }
     foreach ($queue as $name) {
         $this->register($name, $buttons[$name]);
     }
 }
示例#16
0
 /**
  * A download function to hide real file path. When call this function, will start download instantly.
  *
  * This function should call when view has not executed yet, if header sended,
  *  the file which downloaded will error, because download by stream will
  *  contain header in this file.
  *
  * @param   string  $path     The file system path with filename & type.
  * @param   boolean $absolute Absolute URL or not.
  * @param   boolean $stream   Use stream or redirect to download.
  * @param   array   $option   Some download options.
  *
  * @return  string
  */
 public static function download($path, $absolute = false, $stream = false, $option = array())
 {
     $test = self::$isTest;
     static::$headerBuffer = array();
     if ($stream) {
         if (!$absolute) {
             $path = JPATH_ROOT . '/' . $path;
         }
         if (!is_file($path)) {
             return $test ?: die;
         }
         $file = pathinfo($path);
         $filesize = filesize($path) + ArrayHelper::getValue($option, 'size_offset', 0);
         ini_set('memory_limit', ArrayHelper::getValue($option, 'memory_limit', '1540M'));
         // Set Header
         static::header('Content-Type: application/octet-stream');
         static::header('Cache-Control: no-store, no-cache, must-revalidate');
         static::header('Cache-Control: pre-check=0, post-check=0, max-age=0');
         static::header('Content-Transfer-Encoding: binary');
         static::header('Content-Encoding: none');
         static::header('Content-type: application/force-download');
         static::header('Content-length: ' . $filesize);
         static::header('Content-Disposition: attachment; filename="' . $file['basename'] . '"');
         $handle = fopen($path, 'rb');
         $chunksize = 1 * (1024 * 1024);
         // Start Download File by Stream
         while (!feof($handle)) {
             $buffer = fread($handle, $chunksize);
             echo $buffer;
             $test or ob_flush();
             $test or flush();
         }
         fclose($handle);
         $test or jexit();
     } else {
         if (!$absolute) {
             $path = \JURI::root() . $path;
         }
         // Redirect it.
         $app = Container::getInstance()->get('app');
         $test or $app->redirect($path);
         return $path;
     }
 }
示例#17
0
 /**
  * Build route.
  *
  * @param   array  &$data The query data to build route.
  *
  * @return  string Route url.
  */
 public static function build(&$data = array())
 {
     $menu = \JFactory::getApplication()->getMenu();
     $items = $menu->getMenu();
     $Itemid = null;
     $data['view'] = isset($data['view']) ? $data['view'] : null;
     // If itemid exists and view not, use itemid as menu item
     if (isset($data['Itemid']) && empty($data['view'])) {
         if ($item = $menu->getItem($data['Itemid'])) {
             $data['Itemid'] = $item->id;
             return $data;
         }
     }
     // Find option, view and id
     if (!empty($data['id'])) {
         foreach ($items as $item) {
             $option = ArrayHelper::getValue($item->query, 'option');
             $view = ArrayHelper::getValue($item->query, 'view');
             $id = ArrayHelper::getValue($item->query, 'id');
             if ($option == $data['option'] && $view == $data['view'] && $id == $data['id']) {
                 $data['Itemid'] = $item->id;
                 return $data;
             }
         }
     }
     // Find option and view
     if (!$Itemid && !empty($data['view'])) {
         foreach ($items as $item) {
             $option = ArrayHelper::getValue($item->query, 'option');
             $view = ArrayHelper::getValue($item->query, 'view');
             if ($option == $data['option'] && $view == $data['view']) {
                 unset($data['view']);
                 $data['Itemid'] = $item->id;
                 return $data;
             }
         }
     }
     // Find option
     if (!$Itemid && empty($data['view'])) {
         foreach ($items as $item) {
             $option = ArrayHelper::getValue($item->query, 'option');
             if ($option == $data['option']) {
                 $data['Itemid'] = $item->id;
                 return $data;
             }
         }
     }
     return $data;
 }
 /**
  * Method to test getValue
  *
  * @covers \Windwalker\Helper\ArrayHelper::getValue
  *
  * @return void
  */
 public function testGetValue()
 {
     $data = array('Caster' => 'Rule Breaker', 'Assassin' => 'Kischur Zelretch', 'Gilgamesh' => 'Gate Of Babylon');
     $result = ArrayHelper::getValue($data, 'Caster', 'n/a');
     $this->assertEquals('Rule Breaker', $result);
     $result = ArrayHelper::getValue($data, 'Assassin', 'n/a');
     $this->assertEquals('Kischur Zelretch', $result);
     $result = ArrayHelper::getValue($data, 'Gilgamesh2', 'Gate Of Babylon2');
     $this->assertEquals('Gate Of Babylon2', $result);
     $result = ArrayHelper::getValue($data, 'Gilgamesh3');
     $this->assertEquals(null, $result);
 }
示例#19
0
 /**
  * Constructor
  *
  * @param   array              $config    An array of configuration options (name, state, dbo, table_path, ignore_request).
  * @param   JoomlaContainer    $container Service container.
  * @param   Registry           $state     The model state.
  * @param   \JDatabaseDriver   $db        The database adapter.
  *
  * @throws \Exception
  */
 public function __construct($config = array(), JoomlaContainer $container = null, Registry $state = null, \JDatabaseDriver $db = null)
 {
     $this->prefix = $this->getPrefix($config);
     $this->option = 'com_' . $this->prefix;
     // Guess name
     $this->name = $this->name ?: ArrayHelper::getValue($config, 'name', $this->getName());
     // Register the paths for the form
     $this->registerTablePaths($config);
     // Set the clean cache event
     $this->eventCleanCache = $this->eventCleanCache ?: ArrayHelper::getValue($config, 'event_clean_cache', 'onContentCleanCache');
     $this->container = $container ?: $this->getContainer();
     $this->resetCache();
     parent::__construct($state, $db);
     $this->state->loadArray($config);
     // Guess the context as Option.ModelName.
     $this->context = $this->context ?: ContextHelper::fromModel($this);
     // Set the internal state marker - used to ignore setting state from the request
     if (empty($config['ignore_request'])) {
         // Protected method to auto-populate the model state.
         $this->populateState();
     }
 }