Minor - format code, add function visibility

pull/2487/head
jmontoyaa 8 years ago
parent 6555d8f1f2
commit be61e5e11a
  1. 6
      main/exercise/question.class.php
  2. 24
      main/gradebook/lib/fe/catform.class.php
  3. 10
      main/gradebook/lib/fe/usertable.class.php
  4. 165
      main/inc/lib/xajax/xajaxResponse.inc.php
  5. 6
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/CourseCopyLearnpath.php
  6. 4
      src/Chamilo/ThemeBundle/Model/MenuItemModel.php

@ -2119,13 +2119,13 @@ abstract class Question
*
* @return array
*/
static function get_course_medias(
public static function get_course_medias(
$course_id,
$start = 0,
$limit = 100,
$sidx = "question",
$sord = "ASC",
$where_condition = array()
$where_condition = []
) {
$table_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
$default_where = array(
@ -2153,7 +2153,7 @@ abstract class Question
*
* @return int
*/
static function get_count_course_medias($course_id)
public static function get_count_course_medias($course_id)
{
$table_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
$result = Database::select(

@ -89,22 +89,6 @@ class CatForm extends FormValidator
//check if we are a root category
//if so, you can only choose between courses
if ($this->category_object->get_parent_id() == '0') {
$coursecat = Category::get_not_created_course_categories(
api_get_user_id()
);
if (count($coursecat) == 0) {
//$select->addoption(get_lang('CourseIndependent'),'COURSEINDEPENDENT','disabled');
} else {
//$select->addoption(get_lang('CourseIndependent'),'COURSEINDEPENDENT');
}
//only return courses that are not yet created by the teacher
if (!empty($coursecat)) {
foreach ($coursecat as $row) {
//$select->addoption($row[1],$row[0]);
}
} else {
//$select->addoption($row[1],$row[0]);
}
$this->setDefaults(
array(
'select_course' => $this->category_object->get_course_code(
@ -214,10 +198,9 @@ class CatForm extends FormValidator
$global_weight = api_get_setting('gradebook_default_weight');
$value = 100;
if (isset($global_weight)) {
$value = $global_weight;
} else {
$value = 100;
}
$this->addFloat(
@ -231,7 +214,6 @@ class CatForm extends FormValidator
);
$skillsDefaults = [];
if (api_is_platform_admin() || api_is_drh()) {
if (Skill::isToolAvailable()) {
$skillSelect = $this->addElement(
@ -401,12 +383,12 @@ class CatForm extends FormValidator
$this->addElement('submit', null, get_lang('Ok'));
}
function display()
public function display()
{
parent::display();
}
function setDefaults($defaults = array(), $filter = null)
public function setDefaults($defaults = array(), $filter = null)
{
parent::setDefaults($defaults, $filter);
}

@ -16,7 +16,7 @@ class UserTable extends SortableTable
/**
* Constructor
*/
public function __construct($userid, $evals = array(), $links = array(), $addparams = null)
public function __construct($userid, $evals = array(), $links = [], $addparams = null)
{
parent::__construct('userlist', null, null, 0);
$this->userid = $userid;
@ -41,7 +41,7 @@ class UserTable extends SortableTable
/**
* Function used by SortableTable to get total number of items in the table
*/
function get_total_number_of_items()
public function get_total_number_of_items()
{
return $this->datagen->get_total_items_count();
}
@ -85,10 +85,10 @@ class UserTable extends SortableTable
}
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
// generate the data to display
$sortable_data = array();
$sortable_data = [];
foreach ($data_array as $data) {
if ($data[2] != "") {//filter by course removed
$row = array();
if ($data[2] != '') {//filter by course removed
$row = [];
$row[] = $this->build_type_column($data[0]);
$row[] = $this->build_name_link($data[0]);
$row[] = $data[2];

@ -99,7 +99,7 @@ class xajaxResponse
* converted to HTML entities
*
*/
public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false)
public function __construct($sEncoding = XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities = false)
{
$this->setCharEncoding($sEncoding);
$this->bOutputEntities = $bOutputEntities;
@ -114,7 +114,7 @@ class xajaxResponse
*
* @param string
*/
function setCharEncoding($sEncoding)
public function setCharEncoding($sEncoding)
{
$this->sEncoding = $sEncoding;
}
@ -132,7 +132,7 @@ class xajaxResponse
* Tells the response object to output special characters intact. (default
* behavior)
*/
function outputEntitiesOff()
public function outputEntitiesOff()
{
$this->bOutputEntities = false;
}
@ -146,9 +146,9 @@ class xajaxResponse
* Cancel in the browsers's confirm dialog
* @param string the message to show in the browser's confirm dialog
*/
function addConfirmCommands($iCmdNumber, $sMessage)
public function addConfirmCommands($iCmdNumber, $sMessage)
{
$this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage);
$this->xml .= $this->_cmdXML(array("n" => "cc", "t" => $iCmdNumber), $sMessage);
}
/**
@ -161,9 +161,9 @@ class xajaxResponse
* "value", etc.)
* @param string the data you want to set the attribute to
*/
function addAssign($sTarget,$sAttribute,$sData)
public function addAssign($sTarget, $sAttribute, $sData)
{
$this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData);
$this->xml .= $this->_cmdXML(array("n" => "as", "t" => $sTarget, "p" => $sAttribute), $sData);
}
/**
@ -176,9 +176,9 @@ class xajaxResponse
* "value", etc.)
* @param string the data you want to append to the end of the attribute
*/
function addAppend($sTarget,$sAttribute,$sData)
public function addAppend($sTarget, $sAttribute, $sData)
{
$this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData);
$this->xml .= $this->_cmdXML(array("n" => "ap", "t" => $sTarget, "p" => $sAttribute), $sData);
}
/**
@ -192,9 +192,9 @@ class xajaxResponse
* @param string the data you want to prepend to the beginning of the
* attribute
*/
function addPrepend($sTarget,$sAttribute,$sData)
public function addPrepend($sTarget, $sAttribute, $sData)
{
$this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData);
$this->xml .= $this->_cmdXML(array("n" => "pp", "t" => $sTarget, "p" => $sAttribute), $sData);
}
/**
@ -209,10 +209,10 @@ class xajaxResponse
* @param string the string to replace the search string when found in the
* attribute
*/
function addReplace($sTarget,$sAttribute,$sSearch,$sData)
public function addReplace($sTarget, $sAttribute, $sSearch, $sData)
{
$sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>";
$this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta);
$this->xml .= $this->_cmdXML(array("n" => "rp", "t" => $sTarget, "p" => $sAttribute), $sDta);
}
/**
@ -224,9 +224,9 @@ class xajaxResponse
* @param string the part of the element you wish to clear ("innerHTML",
* "value", etc.)
*/
function addClear($sTarget,$sAttribute)
public function addClear($sTarget, $sAttribute)
{
$this->addAssign($sTarget,$sAttribute,'');
$this->addAssign($sTarget, $sAttribute, '');
}
/**
@ -236,9 +236,9 @@ class xajaxResponse
*
* @param string the text to be displayed in the Javascript alert box
*/
function addAlert($sMsg)
public function addAlert($sMsg)
{
$this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg);
$this->xml .= $this->_cmdXML(array("n" => "al"), $sMsg);
}
/**
@ -248,24 +248,23 @@ class xajaxResponse
*
* @param string the URL to redirect the client browser to
*/
function addRedirect($sURL)
public function addRedirect($sURL)
{
//we need to parse the query part so that the values are rawurlencode()'ed
//can't just use parse_url() cos we could be dealing with a relative URL which
// parse_url() can't deal with.
$queryStart = strpos($sURL, '?', strrpos($sURL, '/'));
if ($queryStart !== FALSE)
{
if ($queryStart !== false) {
$queryStart++;
$queryEnd = strpos($sURL, '#', $queryStart);
if ($queryEnd === FALSE)
if ($queryEnd === false) {
$queryEnd = strlen($sURL);
$queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart);
}
$queryPart = substr($sURL, $queryStart, $queryEnd - $queryStart);
$queryParts = array();
parse_str($queryPart, $queryParts);
$newQueryPart = "";
foreach($queryParts as $key => $value)
{
foreach ($queryParts as $key => $value) {
$newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output');
}
$sURL = str_replace($queryPart, $newQueryPart, $sURL);
@ -280,9 +279,9 @@ class xajaxResponse
*
* @param string contains Javascript code to be executed
*/
function addScript($sJS)
public function addScript($sJS)
{
$this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS);
$this->xml .= $this->_cmdXML(array("n" => "js"), $sJS);
}
/**
@ -293,11 +292,12 @@ class xajaxResponse
* @param string $sFunc the name of a Javascript function
* @param mixed $args,... optional arguments to pass to the Javascript function
*/
function addScriptCall() {
public function addScriptCall()
{
$arguments = func_get_args();
$sFunc = array_shift($arguments);
$sData = $this->_buildObjXml($arguments);
$this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData);
$this->xml .= $this->_cmdXML(array("n" => "jc", "t" => $sFunc), $sData);
}
/**
@ -307,9 +307,9 @@ class xajaxResponse
*
* @param string contains the id of an HTML element to be removed
*/
function addRemove($sTarget)
public function addRemove($sTarget)
{
$this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),'');
$this->xml .= $this->_cmdXML(array("n" => "rm", "t" => $sTarget), '');
}
/**
@ -323,14 +323,16 @@ class xajaxResponse
* @param string the id to be assigned to the new element
* @param string deprecated, use the addCreateInput() method instead
*/
function addCreate($sParent, $sTag, $sId, $sType="")
public function addCreate($sParent, $sTag, $sId, $sType = "")
{
if ($sType)
{
trigger_error("The \$sType parameter of addCreate has been deprecated. Use the addCreateInput() method instead.", E_USER_WARNING);
if ($sType) {
trigger_error(
"The \$sType parameter of addCreate has been deprecated. Use the addCreateInput() method instead.",
E_USER_WARNING
);
return;
}
$this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag);
$this->xml .= $this->_cmdXML(array("n" => "ce", "t" => $sParent, "p" => $sId), $sTag);
}
/**
@ -343,9 +345,9 @@ class xajaxResponse
* @param string the tag to be added
* @param string the id to be assigned to the new element
*/
function addInsert($sBefore, $sTag, $sId)
public function addInsert($sBefore, $sTag, $sId)
{
$this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag);
$this->xml .= $this->_cmdXML(array("n" => "ie", "t" => $sBefore, "p" => $sId), $sTag);
}
/**
@ -358,9 +360,9 @@ class xajaxResponse
* @param string the tag to be added
* @param string the id to be assigned to the new element
*/
function addInsertAfter($sAfter, $sTag, $sId)
public function addInsertAfter($sAfter, $sTag, $sId)
{
$this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag);
$this->xml .= $this->_cmdXML(array("n" => "ia", "t" => $sAfter, "p" => $sId), $sTag);
}
/**
@ -376,9 +378,9 @@ class xajaxResponse
* name when it is submitted
* @param string the id to be assigned to the new input
*/
function addCreateInput($sParent, $sType, $sName, $sId)
public function addCreateInput($sParent, $sType, $sName, $sId)
{
$this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName);
$this->xml .= $this->_cmdXML(array("n" => "ci", "t" => $sParent, "p" => $sId, "c" => $sType), $sName);
}
/**
@ -394,9 +396,9 @@ class xajaxResponse
* name when it is submitted
* @param string the id to be assigned to the new input
*/
function addInsertInput($sBefore, $sType, $sName, $sId)
public function addInsertInput($sBefore, $sType, $sName, $sId)
{
$this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName);
$this->xml .= $this->_cmdXML(array("n" => "ii", "t" => $sBefore, "p" => $sId, "c" => $sType), $sName);
}
/**
@ -412,9 +414,9 @@ class xajaxResponse
* name when it is submitted
* @param string the id to be assigned to the new input
*/
function addInsertInputAfter($sAfter, $sType, $sName, $sId)
public function addInsertInputAfter($sAfter, $sType, $sName, $sId)
{
$this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName);
$this->xml .= $this->_cmdXML(array("n" => "iia", "t" => $sAfter, "p" => $sId, "c" => $sType), $sName);
}
/**
@ -426,9 +428,9 @@ class xajaxResponse
* @param string the event you wish to set ("onclick", "onmouseover", etc.)
* @param string the Javascript string you want the event to invoke
*/
function addEvent($sTarget,$sEvent,$sScript)
public function addEvent($sTarget, $sEvent, $sScript)
{
$this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript);
$this->xml .= $this->_cmdXML(array("n" => "ev", "t" => $sTarget, "p" => $sEvent), $sScript);
}
/**
@ -441,9 +443,9 @@ class xajaxResponse
* @param string the name of a Javascript function that will handle the
* event. Multiple handlers can be added for the same event
*/
function addHandler($sTarget,$sEvent,$sHandler)
public function addHandler($sTarget, $sEvent, $sHandler)
{
$this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler);
$this->xml .= $this->_cmdXML(array("n" => "ah", "t" => $sTarget, "p" => $sEvent), $sHandler);
}
/**
@ -457,9 +459,9 @@ class xajaxResponse
* @param string the name of a Javascript handler function that you want to
* remove
*/
function addRemoveHandler($sTarget,$sEvent,$sHandler)
public function addRemoveHandler($sTarget, $sEvent, $sHandler)
{
$this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler);
$this->xml .= $this->_cmdXML(array("n" => "rh", "t" => $sTarget, "p" => $sEvent), $sHandler);
}
/**
@ -469,9 +471,9 @@ class xajaxResponse
*
* @param string URL of the Javascript file to include
*/
function addIncludeScript($sFileName)
public function addIncludeScript($sFileName)
{
$this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName);
$this->xml .= $this->_cmdXML(array("n" => "in"), $sFileName);
}
/**
@ -484,12 +486,13 @@ class xajaxResponse
*
* @return string response XML data
*/
function getXML()
public function getXML()
{
$sXML = "<?xml version=\"1.0\"";
if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) {
$sXML .= " encoding=\"".$this->sEncoding."\"";
$sXML .= " ?"."><xjx>" . $this->xml . "</xjx>";
}
$sXML .= " ?"."><xjx>".$this->xml."</xjx>";
return $sXML;
}
@ -506,7 +509,7 @@ class xajaxResponse
* @param string the response XML (returned from a getXML() method) to add
* to the end of this response object
*/
function loadXML($mXML)
public function loadXML($mXML)
{
if (is_a($mXML, "xajaxResponse")) {
$mXML = $mXML->getXML();
@ -527,31 +530,39 @@ class xajaxResponse
* @param string data
* @return string XML command
*/
function _cmdXML($aAttributes, $sData)
public function _cmdXML($aAttributes, $sData)
{
if ($this->bOutputEntities) {
// An adaptation for the Dokeos LMS, 22-AUG-2009.
if (function_exists('api_convert_encoding')) {
$sData = call_user_func_array('api_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
}
//if (function_exists('mb_convert_encoding')) {
$sData = call_user_func_array(
'api_convert_encoding',
array(&$sData, 'HTML-ENTITIES', $this->sEncoding)
);
} //if (function_exists('mb_convert_encoding')) {
elseif (function_exists('mb_convert_encoding')) {
//
$sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
}
else {
trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE);
} else {
trigger_error(
"The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available",
E_USER_NOTICE
);
}
}
$xml = "<cmd";
foreach($aAttributes as $sAttribute => $sValue)
foreach ($aAttributes as $sAttribute => $sValue) {
$xml .= " $sAttribute=\"$sValue\"";
if ($sData !== null && !stristr($sData,'<![CDATA['))
}
if ($sData !== null && !stristr($sData, '<![CDATA[')) {
$xml .= "><![CDATA[$sData]]></cmd>";
else if ($sData !== null)
} else {
if ($sData !== null) {
$xml .= ">$sData</cmd>";
else
} else {
$xml .= "></cmd>";
}
}
return $xml;
}
@ -565,23 +576,23 @@ class xajaxResponse
* @param mixed data structure to serialize to XML
* @return string serialized XML
*/
function _buildObjXml($var) {
if (gettype($var) == "object") $var = get_object_vars($var);
public function _buildObjXml($var)
{
if (gettype($var) == "object") {
$var = get_object_vars($var);
}
if (!is_array($var)) {
return "<![CDATA[$var]]>";
}
else {
} else {
$data = "<xjxobj>";
foreach ($var as $key => $value) {
$data .= "<e>";
$data .= "<k>" . htmlspecialchars($key) . "</k>";
$data .= "<v>" . $this->_buildObjXml($value) . "</v>";
$data .= "<k>".htmlspecialchars($key)."</k>";
$data .= "<v>".$this->_buildObjXml($value)."</v>";
$data .= "</e>";
}
$data .= "</xjxobj>";
return $data;
}
}
}// end class xajaxResponse
?>
}

@ -171,7 +171,7 @@ class CourseCopyLearnpath extends Resource
/**
* Get the items
*/
function get_items()
public function get_items()
{
return $this->items;
}
@ -179,7 +179,7 @@ class CourseCopyLearnpath extends Resource
/**
* Check if a given resource is used as an item in this chapter
*/
function has_item($resource)
public function has_item($resource)
{
foreach ($this->items as $item) {
if ($item['id'] == $resource->get_id() &&
@ -194,7 +194,7 @@ class CourseCopyLearnpath extends Resource
/**
* Show this learnpath
*/
function show()
public function show()
{
parent::show();
echo $this->name;

@ -59,7 +59,7 @@ class MenuItemModel implements MenuItemInterface
*/
protected $parent = null;
function __construct(
public function __construct(
$id,
$label,
$route,
@ -294,7 +294,7 @@ class MenuItemModel implements MenuItemInterface
public function removeChild(MenuItemInterface $child)
{
if (false !== ($key = array_search($child, $this->children))) {
unset ($this->children[$key]);
unset($this->children[$key]);
}
return $this;

Loading…
Cancel
Save