Minor - format code

pull/2487/head
jmontoyaa 7 years ago
parent bef714994a
commit 2d27ed3ca2
  1. 12
      main/inc/lib/add_course.lib.inc.php
  2. 2
      main/inc/lib/course.lib.php
  3. 6
      main/inc/lib/formvalidator/Element/DateTimePicker.php
  4. 19
      main/inc/lib/sortable_table.class.php
  5. 13
      main/lp/lp_view.lib.js
  6. 24
      main/mySpace/slider.js
  7. 38
      plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php
  8. 18
      src/Chamilo/CourseBundle/Entity/CDocument.php
  9. 18
      src/Chamilo/CourseBundle/Entity/CDropboxFile.php

@ -88,7 +88,7 @@ class AddCourse
* @return int 0
* @assert (null,null) === false
*/
public static function prepare_course_repository($course_repository, $course_code)
public static function prepare_course_repository($course_repository)
{
$perm = api_get_permissions_for_new_directories();
$perm_file = api_get_permissions_for_new_files();
@ -369,15 +369,14 @@ class AddCourse
/**
* Sorts pictures by type (used?)
* @param array List of files (sthg like array(0=>array('png'=>1)))
* @param string File type
* @param string $type
* @return array The received array without files not matching type
* @assert (array(),null) === array()
*/
public static function sort_pictures($files, $type)
{
$pictures = array();
foreach ($files as $key => $value) {
$pictures = [];
foreach ($files as $value) {
if (isset($value[$type]) && $value[$type] != '') {
$pictures[][$type] = $value[$type];
}
@ -424,13 +423,8 @@ class AddCourse
$TABLESETTING = Database::get_course_table(TABLE_COURSE_SETTING);
$TABLEGRADEBOOK = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$TABLEGRADEBOOKLINK = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$visible_for_all = 1;
$visible_for_course_admin = 0;
$visible_for_platform_admin = 2;
/* Course tools */
Database::query(
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
VALUES ($course_id, 1, '".TOOL_COURSE_DESCRIPTION."','course_description/','info.gif','".self::string2binary(

@ -6409,7 +6409,7 @@ class CourseManager
{
$authorId = empty($authorId) ? api_get_user_id() : (int) $authorId;
AddCourse::prepare_course_repository($courseInfo['directory'], $courseInfo['code']);
AddCourse::prepare_course_repository($courseInfo['directory']);
AddCourse::fill_db_course(
$courseInfo['real_id'],
$courseInfo['directory'],

@ -130,9 +130,7 @@ class DateTimePicker extends HTML_QuickForm_text
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
$id = $this->getAttribute('id');
$value = $this->getValue();
if (empty($size)) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
@ -154,10 +152,6 @@ class DateTimePicker extends HTML_QuickForm_text
}
}
if (!empty($value)) {
$value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H);
}
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '

@ -369,8 +369,6 @@ class SortableTable extends HTML_Table
{
$empty_table = false;
if ($this->get_total_number_of_items() == 0) {
$cols = $this->getColCount();
//$this->setCellAttributes(1, 0, 'style="font-style: italic;text-align:center;" colspan='.$cols);
$message_empty = api_xml_http_response_encode(get_lang('TheListIsEmpty'));
$this->setCellContents(1, 0, $message_empty);
$empty_table = true;
@ -396,12 +394,9 @@ class SortableTable extends HTML_Table
</style>';
// @todo This also must be moved
// Show only navigations if there are more than 1 page
$my_pager = $this->get_pager();
$html .= '<div class="main-grid">';
if ($my_pager->numPages() > 1) {
$html .= '<div class="sub-header">';
$html .= '<div class="grid_selectbox">'.$form.'</div>';
@ -422,7 +417,6 @@ class SortableTable extends HTML_Table
// Generation of style classes must be improved. Maybe we need a a table name to create style on the fly:
// i.e: .whoisonline_table_grid_container instead of .grid_container
// where whoisonline is the table's name like drupal's template engine
$html .= '<div class="grid_container">';
if (is_array($items) && count($items) > 0) {
foreach ($items as & $row) {
@ -459,17 +453,12 @@ class SortableTable extends HTML_Table
$grid_class = array()
) {
$empty_table = false;
$total = $this->get_total_number_of_items();
if ($this->get_total_number_of_items() == 0) {
$cols = $this->getColCount();
//$this->setCellAttributes(1, 0, 'style="font-style: italic;text-align:center;" colspan='.$cols);
$message_empty = api_xml_http_response_encode(get_lang('TheListIsEmpty'));
$this->setCellContents(1, 0, $message_empty);
$empty_table = true;
}
$html = '';
if (!$empty_table) {
// If we show the pagination
if (!$hide_navigation) {
@ -640,9 +629,7 @@ class SortableTable extends HTML_Table
$pager = $this->get_pager();
$offset = $pager->getOffsetByPageId();
$from = $offset[0] - 1;
$table_data = $this->get_table_data($from, null, null, null, $sort);
$new_table_data = array();
if (is_array($table_data)) {
foreach ($table_data as $index => & $row) {
@ -740,6 +727,7 @@ class SortableTable extends HTML_Table
$param['page_nr'] = $this->page_nr;
$param['per_page'] = $this->per_page;
$param['column'] = $column;
$link = $label;
if ($sortable) {
$link = '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;';
foreach ($param as $key => & $value) {
@ -750,10 +738,7 @@ class SortableTable extends HTML_Table
if ($this->column == $column) {
$link .= $this->direction == 'ASC' ? ' &#8595;' : ' &#8593;';
}
} else {
$link = $label;
}
$this->setHeaderContents(0, $column, $link);
if (!is_null($td_attributes)) {
@ -902,6 +887,7 @@ class SortableTable extends HTML_Table
{
$this->additional_parameters = $parameters;
}
/**
* Set other tables on the same page.
* If you have other sortable tables on the page displaying this sortable
@ -926,7 +912,6 @@ class SortableTable extends HTML_Table
public function filter_data($row)
{
$url_params = $this->get_sortable_table_param_string().'&'.$this->get_additional_url_paramstring();
foreach ($this->column_filters as $column => & $function) {
$firstParam = isset($row[$column]) ? $row[$column] : 0;
$row[$column] = call_user_func($function, $firstParam, $url_params, $row);

@ -6,13 +6,14 @@
//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeid="lp_content_frame";
var iframeid = "lp_content_frame";
//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="no";
var iframehide = "no";
//var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
var FFextraHeight=32; //parseFloat(getFFVersion)>=0.1? 16 : 0; //extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight = 32;
//parseFloat(getFFVersion)>=0.1? 16 : 0; //extra height in px to add to iframe in FireFox 1.0+ browsers
function resizeIframe(frameid) {
var currentfr=document.getElementById(frameid);
@ -54,8 +55,8 @@ function readjustIframe(loadevt) {
}
if (window.addEventListener)
window.addEventListener("load", resizeCaller, false);
window.addEventListener("load", resizeCaller, false);
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller);
window.attachEvent("onload", resizeCaller);
else
window.onload=resizeCaller;
window.onload = resizeCaller;

@ -1,17 +1,6 @@
// Set the initial height
var sliderHeight = "80px";
$(document).ready(function () {
// Show the slider content
$('.slider').show();
$('.slider').each(function () {
var current = $(this);
current.attr("box_h", current.height());
});
$(".slider").css("height", sliderHeight);
});
// Set the initial slider state
var slider_state = "close";
@ -40,4 +29,15 @@ function sliderClose()
{
$(".slider").animate({"height": "0px"}, {duration: "fast" });
$(".slider").animate({"height": sliderHeight}, {duration: "fast" });
}
}
$(document).ready(function () {
// Show the slider content
$('.slider').show();
$('.slider').each(function () {
var current = $(this);
current.attr("box_h", current.height());
});
$(".slider").css("height", sliderHeight);
});

@ -31,7 +31,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
);
parent::__construct('1.0', 'Imanol Losada, Daniel Barreto', $parameters);
$this->errorMessages = array();
}
@ -80,7 +79,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
{
$extraField = new ExtraField('user');
$extraFieldHandler = $extraField->get_handler_field_info_by_field_variable('area');
$areaExists = $extraFieldHandler !== false;
if (!$areaExists) {
@ -127,7 +125,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
{
/* Drop plugin tables */
$advancedSubscriptionQueueTable = Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE);
$sql = "DROP TABLE IF EXISTS $advancedSubscriptionQueueTable; ";
Database::query($sql);
@ -154,7 +151,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
{
$self = self::create();
$wsUrl = $self->get('ws_url');
$profileCompleted = 0;
if (!empty($wsUrl)) {
$client = new SoapClient(
null,
@ -177,10 +174,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
}
} elseif (isset($params['profile_completed'])) {
$profileCompleted = (float) $params['profile_completed'];
} else {
$profileCompleted = 0;
}
$profileCompletedMin = (float) $self->get('min_profile_percentage');
if ($profileCompleted < $profileCompletedMin) {
@ -230,6 +224,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
}
$profileCompletedMin = (float) $plugin->get('min_profile_percentage');
$profileCompleted = 0;
if (is_string($wsUrl) && !empty($wsUrl)) {
$options = array(
@ -245,8 +240,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
}
} elseif (isset($params['profile_completed'])) {
$profileCompleted = (float) $params['profile_completed'];
} else {
$profileCompleted = 0;
}
if ($profileCompleted < $profileCompletedMin) {
@ -299,7 +292,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
foreach ($sessions as $session) {
$costField = $extra->get_values_by_handler_and_field_variable($session['id'], 'cost');
$userCost += $costField['value'];
$teachingHoursField = $extra->get_values_by_handler_and_field_variable($session['id'], 'teaching_hours');
$expendedTime += $teachingHoursField['value'];
}
@ -433,7 +425,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
*/
public function startSubscription($userId, $sessionId, $params)
{
$result = null;
$result = 'Params not found';
if (!empty($sessionId) && !empty($userId)) {
$plugin = self::create();
try {
@ -445,10 +437,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
} catch (Exception $e) {
$result = $e->getMessage();
}
} else {
$result = 'Params not found';
}
return $result;
}
@ -470,7 +459,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
$content,
$sessionId,
$save = false,
$fileAttachments = array()
$fileAttachments = []
) {
if (!empty($fileAttachments) &&
is_array($fileAttachments) &&
@ -547,8 +536,12 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
* @param string $sessionFieldVariable
* @return bool
*/
public function isUserInTargetGroup($userId, $sessionId, $userFieldVariable = 'area', $sessionFieldVariable = 'target')
{
public function isUserInTargetGroup(
$userId,
$sessionId,
$userFieldVariable = 'area',
$sessionFieldVariable = 'target'
) {
$extraSessionFieldValue = new ExtraFieldValue('session');
$sessionTarget = $extraSessionFieldValue->get_values_by_handler_and_field_variable(
$sessionId,
@ -582,6 +575,8 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
public function updateQueueStatus($params, $newStatus)
{
$newStatus = intval($newStatus);
$res = false;
if (isset($params['queue']['id'])) {
$where = array(
'id = ?' => intval($params['queue']['id']),
@ -605,8 +600,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
),
$where
);
} else {
$res = false;
}
return $res;
@ -920,7 +913,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
/**
* This method will call the Hook management insertHook to add Hook observer from this plugin
* @return int
*/
public function installHook()
{
@ -933,7 +925,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
/**
* This method will call the Hook management deleteHook to disable Hook observer from this plugin
* @return int
*/
public function uninstallHook()
{
@ -1028,7 +1019,6 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
'brochure',
'banner',
);
$extraSession = new ExtraFieldValue('session');
$extraField = new ExtraField('session');
// Get session fields
$fieldList = $extraField->get_all(array(
@ -1081,10 +1071,9 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
{
switch ($status) {
case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE:
$message = $this->get_lang('AdvancedSubscriptionNoQueue');
if ($isAble) {
$message = $this->get_lang('AdvancedSubscriptionNoQueueIsAble');
} else {
$message = $this->get_lang('AdvancedSubscriptionNoQueue');
}
break;
case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_START:
@ -1486,5 +1475,4 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
return $numberOfApproved;
}
}

@ -296,4 +296,22 @@ class CDocument
{
return $this->cId;
}
/**
* @return int
*/
public function getIid()
{
return $this->iid;
}
/**
* @param int $iid
* @return CDocument
*/
public function setIid($iid)
{
$this->iid = $iid;
return $this;
}
}

@ -390,4 +390,22 @@ class CDropboxFile
{
return $this->cId;
}
/**
* @return int
*/
public function getIid()
{
return $this->iid;
}
/**
* @param int $iid
* @return CDropboxFile
*/
public function setIid($iid)
{
$this->iid = $iid;
return $this;
}
}

Loading…
Cancel
Save