Esempio n. 1
0
	/**
	 * Display ALL the system configuration options.
	 *
	 * @return int
	 */
	public function config() {
		// Admin-only page.
		if(!\Core\user()->checkAccess('g:admin')){
			return View::ERROR_ACCESSDENIED;
		}

		$view = $this->getView();

		$where = array();
		// If the enterprise component is installed and multisite is enabled, configurations have another layer of complexity.
		if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::GetCurrentSiteID()){
			$where['overrideable'] = '1';
		}

		$configs = ConfigModel::Find($where, null, 'key');

		$groups  = array();
		foreach ($configs as $c) {
			/** @var ConfigModel $c */
			// Export out the group for this config option.
			$el = $c->getAsFormElement();
			$gname = $el->get('group');

			if (!isset($groups[$gname])){
				$groups[$gname] = new FormGroup(
					[
						'title' => $gname,
						'name' => $gname,
						//'class' => 'collapsible collapsed'
						'class' => 'system-config-group'
					]
				);
			}

			$groups[$gname]->addElement($el);
		}


		$form = new Form();
		$form->set('callsmethod', 'AdminController::_ConfigSubmit');
		// This form gives me more trouble with its persistence....
		// @todo Implement a better option than this.
		// This hack is designed to prevent this form from using stale values from a previous page load instead of
		// pulling them from the database.
		$form->set('uniqueid', 'admin-config-' . Core::RandomHex(6));
		foreach ($groups as $g) {
			$form->addElement($g);
		}

		$form->addElement('submit', array('value' => t('STRING_SAVE')));

		$this->setTemplate('/pages/admin/config.tpl');
		$view->assign('form', $form);
		$view->assign('config_count', sizeof($configs));
	}
Esempio n. 2
0
		// As above, the exec line will trigger this catch if this check is not in place, giving false positives in the results.
		if(strrpos($m, '_') + 1 != strlen($m)){
			$matches[] = $m;

			// If this match contains _N_, then also add _0_ for 0 results and _1_ for 1 result.
			if(substr_count($m, '_N_') === 1){
				$matches[] = str_replace('_N_', '_0_', $m);
				$matches[] = str_replace('_N_', '_1_', $m);
			}
		}
	}
}

// Pull all the configuration options for this component
// These get transposed to STRING_CONFIG_config_name_blah
$configs = ConfigModel::Find(['component = ' . $configKey]);
foreach($configs as $c){
	/** @var ConfigModel $c */
	$key = \Core\i18n\I18NLoader::KeyifyString($c->get('key'));
	$matches[] = 'STRING_CONFIG_' . $key;
	$matches[] = 'MESSAGE_CONFIG_' . $key;
}

// Give me permissions!
if($comp){
	foreach($comp->getPermissions() as $key => $p){
		$key = \Core\i18n\I18NLoader::KeyifyString($key);
		$matches[] = 'STRING_PERMISSION_' . $key;
		//$matches[] = 'MESSAGE_CONFIG_' . $key;
	}
}
	private function _loadDB(){
		Core\Utilities\Logger\write_debug('Config data loading from database');
		// Clear out the cache, (if it has any)
		$this->_clearCache();

		// Get a list of config models in the system.
		// These will be the root configuration options needed for any other system.
		$fac = ConfigModel::Find();

		foreach ($fac as $config) {
			/** @var $config ConfigModel */
			$key = $config->get('key');
			$this->_cacheFromDB[$key] = $config;
			$val = $config->getValue();

			// Set the defines on any that need to be defined, (via the "mapto" attribute)
			if($config->get('mapto') && !defined($config->get('mapto'))){
				define($config->get('mapto'), $val);
			}
		}
		
		Core\Utilities\Logger\write_debug('Config data loaded from database');
	}