/** * Initialises the _savestate variable * * @param integer $defaultSaveState The default value for the savestate * * @return void */ public function populateSavestate($defaultSaveState = -999) { if (is_null($this->_savestate)) { $savestate = $this->input->getInt('savestate', $defaultSaveState); if ($savestate == -999) { $savestate = true; } $this->savestate($savestate); } }
public function saveConfiguration() { $rawInput = $this->getState('rawinput', array()); $newFileExtension = trim(F0FInput::getVar('fileextensions', '', $rawInput)); $newExcludeFolders = trim(F0FInput::getVar('exludefolders', '', $rawInput)); $newExcludeFiles = trim(F0FInput::getVar('exludefiles', '', $rawInput)); $newMinExecTime = trim(F0FInput::getInt('mintime', '', $rawInput)); $newMaxExecTime = trim(F0FInput::getInt('maxtime', '', $rawInput)); $newRuntimeBias = trim(F0FInput::getInt('runtimebias', '', $rawInput)); $protectedKeys = $this->aeconfig->getProtectedKeys(); $this->aeconfig->resetProtectedKeys(); $this->aeconfig->set('akeeba.basic.file_extensions', join('|', $this->getTextInputAsArray($newFileExtension))); $this->aeconfig->set('akeeba.basic.exclude_folders', join('|', $this->getTextInputAsArray($newExcludeFolders, '/'))); $this->aeconfig->set('akeeba.basic.exclude_files', join('|', $this->getTextInputAsArray($newExcludeFiles, '/'))); $this->aeconfig->set('akeeba.tuning.min_exec_time', $newMinExecTime); $this->aeconfig->set('akeeba.tuning.max_exec_time', $newMaxExecTime); $this->aeconfig->set('akeeba.tuning.run_time_bias', $newRuntimeBias); \Akeeba\Engine\Platform::getInstance()->save_configuration(); $this->aeconfig->setProtectedKeys($protectedKeys); }
protected function getOptions() { $options = array(); $this->value = array(); // The selected values // Deduce table name from conventional names $input = new F0FInput(); $component_prefix = ucfirst(str_replace('com_', '', $input->getString('option'))); $view_prefix = ucfirst($input->getString('view')); // Deduce name of the relation $relation_name = @F0FInflector::pluralize($this->element['name']); // todo remove silence operator // Create a relation's model instance $relation_model = F0FModel::getTmpInstance(ucfirst($relation_name), $component_prefix . 'Model'); // Get the name of key and title field $table = $relation_model->getTable(); $key_field = $table->getKeyName(); $value_field = $table->getColumnAlias('title'); // List all items from the referred table foreach ($relation_model->getItemList(true) as $value) { $options[] = JHtmlSelect::option($value->{$key_field}, $value->{$value_field}); } // Don't load selected values if item is new if ($id = $input->getInt('id')) { // Create an instance of the correct table and load this item $table = F0FTable::getInstance($view_prefix, $component_prefix . 'Table'); // Load the instance of this item, based on ID query parameter $table->load($id); // Get the relation $relation = $table->getRelations()->getMultiple($relation_name); // Add existent relation as default selected values on list foreach ($relation as $item) { $this->value[] = $item->getId(); } } return $options; }
/** * Modify the query to filter list objects by n:n relation. * * @param F0FModel $model The model on which operate. * @param JDatabaseQuery $query The query to alter. */ public function onAfterBuildQuery(&$model, &$query) { $input = new F0FInput(); $db = $model->getDbo(); // Retrieve the relations configuration for this table $table = $model->getTable(); $key = $table->getConfigProviderKey() . '.relations'; $relations = $table->getConfigProvider()->get($key, array()); // For each multiple type relation add the filter query foreach ($relations as $relation) { if ($relation['type'] == 'multiple') { // Get complete relation fields $relation = array_merge(array('itemName' => $relation['itemName']), $table->getRelations()->getRelation($relation['itemName'], $relation['type'])); // Model only save $table->getKnownFields as state, so we look into the input $filter_name = $relation['itemName']; $model_filter_value = $input->getInt($filter_name); // Build the conditions based on relation configuration if (!empty($model_filter_value)) { $query->innerJoin(sprintf('%1$s ON %1$s.%2$s = %3$s.%4$s', $db->qn($relation['pivotTable']), $db->qn($relation['ourPivotKey']), $db->qn($table->getTableName()), $db->qn($relation['localKey']))); $query->where(sprintf('%s.%s = %s', $db->qn($relation['pivotTable']), $db->qn($relation['theirPivotKey']), $model_filter_value)); } } } }
/** * Gets a URL suffix with the Itemid parameter. If it's not the front-end of the site, or if * there is no Itemid set it returns an empty string. * * @return string The &Itemid=123 URL suffix, or an empty string if Itemid is not applicable */ public function getItemidURLSuffix() { if (F0FPlatform::getInstance()->isFrontend() && $this->input->getCmd('Itemid', 0) != 0) { return '&Itemid=' . $this->input->getInt('Itemid', 0); } else { return ''; } }
/** * renderRouting * * @return string HTML */ public static function renderRoutingTags() { $formToken = JFactory::getSession()->getFormToken(); $input = new F0FInput(); $Itemid = $input->getInt('Itemid', 0); $lang = EParameter::getLanguageSef(); $output = array(); if ($formToken) { $output[] = '<input type="hidden" id="XTtoken" name="' . $formToken . '" value="1" />'; } if ($Itemid) { $output[] = '<input type="hidden" id="XTItemid" name="Itemid" value="' . $Itemid . '" />'; } if ($lang) { $output[] = '<input type="hidden" id="XTlang" name="lang" value="' . $lang . '" />'; } return implode("\n", $output); }
/** * Obtain a request token from Twitter * * @return string */ public function getRequestTokenUrl() { $input = new F0FInput(); $itemid = $input->getInt('Itemid'); $oauth_callback = 'index.php?option=com_autotweet&view=userchannels'; if ($itemid) { $oauth_callback .= '&Itemid=' . $itemid; } $oauth_callback = RouteHelp::getInstance()->getAbsoluteUrl($oauth_callback); // Send request for a request token $this->_twitter->request('POST', $this->_twitter->url('oauth/request_token', ''), array()); if ($this->_twitter->response['code'] == 200) { // Get and store the request token $response = $this->_twitter->extract_params($this->_twitter->response['response']); $session = JFactory::getSession(); $session->set('authtoken', $response['oauth_token']); $session->set('authsecret', $response['oauth_token_secret']); // State is now 1 $session->set('twitter-authstate', 1); // Redirect the user to Twitter to authorize $url = $this->_twitter->url('oauth/authorize', '') . '?oauth_token=' . $response['oauth_token']; return $url; } return false; }
/** * Obtain a request token from Twitter * * @return string */ public function getRequestTokenUrl() { $input = new F0FInput(); $itemid = $input->getInt('Itemid'); $oauth_callback = 'index.php?option=com_autotweet&view=userchannels'; if ($itemid) { $oauth_callback .= '&Itemid=' . $itemid; } $oauth_callback = RouteHelp::getInstance()->getAbsoluteUrl($oauth_callback); $this->_linkedin->setCallbackUrl($oauth_callback); $response = $this->_linkedin->retrieveTokenRequest(); if ($response['info']['http_code'] == 200) { // Get and store the request token $session = JFactory::getSession(); $session->set('oauth_token', $response['linkedin']['oauth_token']); $session->set('oauth_token_secret', $response['linkedin']['oauth_token_secret']); // State is now 1 $session->set('linkedin-authstate', 1); // Redirect the user to Twitter to authorize $url = $response['linkedin']['xoauth_request_auth_url'] . '?oauth_token=' . $response['linkedin']['oauth_token']; return $url; } return false; }