WIP ChamiloApi adding "ChamiloApi::getConfigurationValue()" function

remotes/angel/1.11.x
jmontoyaa 8 years ago
parent a3279f9217
commit d9d1869ce2
  1. 9
      app/AppKernel.php
  2. 63
      main/admin/configure_extensions.php
  3. 12
      main/inc/global.inc.php
  4. 33
      src/Chamilo/CoreBundle/Component/Utils/ChamiloApi.php

@ -3,6 +3,7 @@
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
/**
* Class AppKernel
@ -203,5 +204,13 @@ class AppKernel extends Kernel
{
return $this->getRealRootDir().'app/config/configuration.php';
}
/**
* @param array $configuration
*/
public function setApi(array $configuration)
{
new ChamiloApi($configuration);
}
}

@ -31,7 +31,8 @@ if (isset($_POST['activeExtension'])) {
while($row = Database::fetch_array($rs)){
if(!empty($_POST['visio_host'])) {
$tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$select = "SELECT id FROM $tool_table WHERE c_id =".$row['id']." AND name='".TOOL_VISIO_CONFERENCE."'";
$select = "SELECT id FROM $tool_table
WHERE c_id =".$row['id']." AND name='".TOOL_VISIO_CONFERENCE."'";
$selectres = Database::query($select);
if (Database::num_rows($selectres)<1) {
$sql = 'INSERT INTO '.$tool_table.' SET
@ -46,9 +47,10 @@ if (isset($_POST['activeExtension'])) {
category="interaction"';
Database::query($sql);
}
$select = "SELECT id FROM $tool_table WHERE c_id =".$row['id']." AND name='".TOOL_VISIO_CLASSROOM."'";
$select = "SELECT id FROM $tool_table
WHERE c_id =".$row['id']." AND name='".TOOL_VISIO_CLASSROOM."'";
$selectres = Database::query($select);
if(Database::num_rows($selectres)<1) {
if (Database::num_rows($selectres) < 1) {
$sql = 'INSERT INTO '.$tool_table.' SET
c_id = '.$row['id'].',
name="'.TOOL_VISIO_CLASSROOM.'",
@ -90,12 +92,12 @@ if (isset($_POST['activeExtension'])) {
AND subkey="visio_use_rtmpt"';
$rs = Database::query($sql);
if(empty($message)) {
if (empty($message)) {
$message = get_lang('ServiceReconfigured');
}
break;
case 'ppt2lp' :
case 'ppt2lp':
$sql = 'UPDATE '.$tbl_settings_current.' SET
selected_value="true"
WHERE variable="service_ppt2lp"
@ -142,13 +144,10 @@ if (isset($_POST['activeExtension'])) {
WHERE variable="service_ppt2lp"
AND subkey="size"';
Database::query($sql);
break;
}
}
$listActiveServices = array();
// get the list of active services
@ -163,14 +162,11 @@ while($row = Database::fetch_array($rs)){
// javascript to handle accordion behaviour
$javascript_message = '';
if(!empty($message)){
$javascript_message =
'
$javascript_message = '
document.getElementById("message").style.display = "block";
var timer = setTimeout(hideMessage,5000);
';
var timer = setTimeout(hideMessage, 5000);';
}
$htmlHeadXtra[]= '
<script type="text/javascript">
$htmlHeadXtra[]= '<script>
var listeDiv;
var extensionsHeader = new Array();
var extensionsContent = new Array();
@ -305,56 +301,50 @@ Display::display_header($nameTool);
<div class="col-md-7">
<form method="POST" class="form-horizontal" action="<?php echo api_get_self(); ?>">
<?php
$form = new FormValidator('ppt2lp');
$form -> addElement('text', 'host', get_lang('Host'));
$form->addElement('text', 'host', get_lang('Host'));
//$form -> addElement('html','<br /><br />');
$form -> addElement('text', 'port', get_lang('Port'));
$form->addElement('text', 'port', get_lang('Port'));
//$form -> addElement('html','<br /><br />');
$form -> addElement('text', 'user', get_lang('UserOnHost'));
$form->addElement('text', 'user', get_lang('UserOnHost'));
//$form -> addElement('html','<br /><br />');
$form -> addElement('text', 'ftp_password', get_lang('FtpPassword'));
$form->addElement('text', 'ftp_password', get_lang('FtpPassword'));
//$form -> addElement('html','<br /><br />');
$form -> addElement('text', 'path_to_lzx', get_lang('PathToLzx'));
$form->addElement('text', 'path_to_lzx', get_lang('PathToLzx'));
//$form -> addElement('html','<br /><br />');
$options = ChamiloApi::getDocumentConversionSizes();
$form -> addElement('select', 'size', get_lang('SlideSize'), $options);
$form -> addElement('hidden', 'extension_code', 'ppt2lp');
$form->addElement('select', 'size', get_lang('SlideSize'), $options);
$form->addElement('hidden', 'extension_code', 'ppt2lp');
$defaults = array();
$renderer = $form -> defaultRenderer();
$renderer -> setElementTemplate('<div style="text-align:left">{label}</div><div style="text-align:left">{element}</div>');
//$form -> addElement('html','<br /><br />');
if(in_array('service_ppt2lp',$listActiveServices))
{
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate(
'<div style="text-align:left">{label}</div><div style="text-align:left">{element}</div>'
);
if (in_array('service_ppt2lp', $listActiveServices)) {
$sql = 'SELECT subkey, selected_value FROM '.$tbl_settings_current.'
WHERE variable = "service_ppt2lp"
AND subkey <> "active"';
$rs = Database::query($sql);
while($row = Database::fetch_array($rs,'ASSOC'))
{
while ($row = Database::fetch_array($rs, 'ASSOC')) {
$defaults[$row['subkey']] = $row['selected_value'];
}
$form->addButtonSave(get_lang('ReconfigureExtension'), 'activeExtension');
}
else {
} else {
$defaults['host'] = 'localhost';
$defaults['port'] = '2002';
$defaults['size'] = '720x540';
$form->addButtonSave(get_lang('ActivateExtension'), 'activeExtension');
}
$form -> setDefaults($defaults);
$form -> display();
$form->setDefaults($defaults);
$form->display();
echo '<br />';
?>
</form>
</div>
</div>
</div>
<?php
/*
<!-- EPHORUS -->
@ -497,6 +487,5 @@ Display::display_header($nameTool);
*/ ?>
</div><!-- /content -->
<?php
Display::display_footer();

@ -4,20 +4,14 @@
/**
* It is recommended that ALL Chamilo scripts include this important file.
* This script manages
* - http get, post, post_files, session, server-vars extraction into global namespace;
* (which doesn't occur anymore when servertype config setting is set to test,
* and which will disappear completely in Dokeos 1.6.1)
* - include of /conf/configuration.php;
* - include of several libraries: main_api, database, display, text, security;
* - include of /app/config/configuration.php;
* - include of several libraries: api, database, display, text, security;
* - selecting the main database;
* - include of language files.
*
* @package chamilo.include
* @todo isn't configuration.php renamed to configuration.inc.php yet?
* @todo use the $_configuration array for all the needed variables
* @todo remove the code that displays the button that links to the install page
* but use a redirect immediately. By doing so the $alreadyInstalled variable can be removed.
* @todo make it possible to enable / disable the tracking through the Chamilo config page.
*
*/
@ -53,6 +47,8 @@ if (file_exists($kernel->getConfigurationFile())) {
}
}
$kernel->setApi($_configuration);
// Ensure that _configuration is in the global scope before loading
// main_api.lib.php. This is particularly helpful for unit tests
if (!isset($GLOBALS['_configuration'])) {

@ -9,26 +9,40 @@ namespace Chamilo\CoreBundle\Component\Utils;
*/
class ChamiloApi
{
private $configuration;
private static $instance = null;
private static $configuration;
protected function __construct($configuration)
/**
* ChamiloApi constructor.
* @param $configuration
*/
public function __construct(array $configuration)
{
self::$configuration = $configuration;
}
/**
* @return array
*/
public static function getConfigurationArray()
{
$this->configuration = $configuration;
return self::$configuration;
}
/**
* @return ChamiloApi|null
* @param string $variable
* @return bool|string
*/
public function getInstance($configuration = null)
public static function getConfigurationValue($variable)
{
if (is_null(self::$instance)) {
self::$instance = new ChamiloApi($configuration);
$configuration = self::getConfigurationArray();
if (array_key_exists($variable, $configuration)) {
return $configuration[$variable];
}
return self::$instance;
return false;
}
/**
* Returns an array of resolutions that can be used for the conversion of documents to images
* @return array
@ -49,5 +63,4 @@ class ChamiloApi
);
}
}

Loading…
Cancel
Save