@@ -78,6 +78,9 @@ |
||
| 78 | 78 | 'maxlength' => 6)); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | + /** |
|
| 82 | + * @param string $key |
|
| 83 | + */ |
|
| 81 | 84 | function getVar($key, $format = 's') { |
| 82 | 85 | if ($format == 's' && in_array($key, array())) { |
| 83 | 86 | return call_user_func(array($this,$key)); |
@@ -73,6 +73,9 @@ |
||
| 73 | 73 | $this->hideFieldFromForm('default_currency'); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | + /** |
|
| 77 | + * @param string $key |
|
| 78 | + */ |
|
| 76 | 79 | function getVar($key, $format = 's') { |
| 77 | 80 | if ($format == 's' && in_array($key, array('rate', 'default_currency'))) { |
| 78 | 81 | return call_user_func(array($this,$key)); |
@@ -31,12 +31,12 @@ discard block |
||
| 31 | 31 | die("XOOPS root path not defined"); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobject.php"; |
|
| 34 | +include_once XOOPS_ROOT_PATH . "/modules/smartobject/class/smartobject.php"; |
|
| 35 | 35 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
| 36 | 36 | |
| 37 | 37 | class SmartobjectCurrency extends SmartObject { |
| 38 | 38 | |
| 39 | - var $_modulePlugin=false; |
|
| 39 | + var $_modulePlugin = false; |
|
| 40 | 40 | |
| 41 | 41 | function SmartobjectCurrency() { |
| 42 | 42 | $this->quickInitVar('currencyid', XOBJ_DTYPE_INT, true); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | function getVar($key, $format = 's') { |
| 77 | 77 | if ($format == 's' && in_array($key, array('rate', 'default_currency'))) { |
| 78 | - return call_user_func(array($this,$key)); |
|
| 78 | + return call_user_func(array($this, $key)); |
|
| 79 | 79 | } |
| 80 | 80 | return parent::getVar($key, $format); |
| 81 | 81 | } |
@@ -57,6 +57,9 @@ |
||
| 57 | 57 | |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | + /** |
|
| 61 | + * @param string $key |
|
| 62 | + */ |
|
| 60 | 63 | function getVar($key, $format = 's') { |
| 61 | 64 | if ($format == 's' && in_array($key, array())) { |
| 62 | 65 | return call_user_func(array($this,$key)); |
@@ -39,12 +39,6 @@ |
||
| 39 | 39 | /** |
| 40 | 40 | * Constructor |
| 41 | 41 | * |
| 42 | - * @param string $caption Caption |
|
| 43 | - * @param string $name "name" attribute |
|
| 44 | - * @param int $size Size of the field |
|
| 45 | - * @param int $maxlength Maximum length of the text |
|
| 46 | - * @param int $value Initial value of the field. |
|
| 47 | - * <b>Warning:</b> this is readable in cleartext in the page's source! |
|
| 48 | 42 | */ |
| 49 | 43 | function SmartFormSet_passwordElement($object, $key){ |
| 50 | 44 | |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | * @param int $value Initial value of the field. |
| 47 | 47 | * <b>Warning:</b> this is readable in cleartext in the page's source! |
| 48 | 48 | */ |
| 49 | - function SmartFormSet_passwordElement($object, $key){ |
|
| 49 | + function SmartFormSet_passwordElement($object, $key) { |
|
| 50 | 50 | |
| 51 | 51 | $var = $object->vars[$key]; |
| 52 | 52 | $control = $object->controls[$key]; |
@@ -11,6 +11,10 @@ |
||
| 11 | 11 | * @subpackage SmartObjectForm |
| 12 | 12 | */ |
| 13 | 13 | class SmartFormTextElement extends XoopsFormText { |
| 14 | + |
|
| 15 | + /** |
|
| 16 | + * @param string $key |
|
| 17 | + */ |
|
| 14 | 18 | function SmartFormTextElement($object, $key) { |
| 15 | 19 | $var = $object->vars[$key]; |
| 16 | 20 | |
@@ -14,12 +14,12 @@ |
||
| 14 | 14 | function SmartFormTextElement($object, $key) { |
| 15 | 15 | $var = $object->vars[$key]; |
| 16 | 16 | |
| 17 | - if(isset($object->controls[$key])){ |
|
| 17 | + if (isset($object->controls[$key])) { |
|
| 18 | 18 | $control = $object->controls[$key]; |
| 19 | 19 | $form_maxlength = isset($control['maxlength']) ? $control['maxlength'] : (isset($var['maxlength']) ? $var['maxlength'] : 255); |
| 20 | 20 | $form_size = isset($control['size']) ? $control['size'] : 50; |
| 21 | - }else{ |
|
| 22 | - $form_maxlength = 255; |
|
| 21 | + } else { |
|
| 22 | + $form_maxlength = 255; |
|
| 23 | 23 | $form_size = 50; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -42,6 +42,10 @@ discard block |
||
| 42 | 42 | var $_form_caption=false; |
| 43 | 43 | var $_submit_button_caption=false; |
| 44 | 44 | |
| 45 | + /** |
|
| 46 | + * @param SmartObject $target |
|
| 47 | + * @param boolean $form_action |
|
| 48 | + */ |
|
| 45 | 49 | function SmartobjectForm(&$target, $form_name, $form_caption, $form_action, $form_fields=null, $submit_button_caption = false, $cancel_js_action=false, $captcha=false) { |
| 46 | 50 | |
| 47 | 51 | $this->targetObject =& $target; |
@@ -88,7 +92,7 @@ discard block |
||
| 88 | 92 | * Add an element to the form |
| 89 | 93 | * |
| 90 | 94 | * @param object &$formElement reference to a {@link XoopsFormElement} |
| 91 | - * @param bool $required is this a "required" element? |
|
| 95 | + * @param string|boolean $required is this a "required" element? |
|
| 92 | 96 | */ |
| 93 | 97 | function addElement(&$formElement, $key=false, $var=false, $required='notset'){ |
| 94 | 98 | if ($key) { |
@@ -35,28 +35,28 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | var $targetObject = null; |
| 37 | 37 | var $form_fields = null; |
| 38 | - var $_cancel_js_action=false; |
|
| 39 | - var $_custom_button=false; |
|
| 40 | - var $_captcha=false; |
|
| 41 | - var $_form_name=false; |
|
| 42 | - var $_form_caption=false; |
|
| 43 | - var $_submit_button_caption=false; |
|
| 38 | + var $_cancel_js_action = false; |
|
| 39 | + var $_custom_button = false; |
|
| 40 | + var $_captcha = false; |
|
| 41 | + var $_form_name = false; |
|
| 42 | + var $_form_caption = false; |
|
| 43 | + var $_submit_button_caption = false; |
|
| 44 | 44 | |
| 45 | - function SmartobjectForm(&$target, $form_name, $form_caption, $form_action, $form_fields=null, $submit_button_caption = false, $cancel_js_action=false, $captcha=false) { |
|
| 45 | + function SmartobjectForm(&$target, $form_name, $form_caption, $form_action, $form_fields = null, $submit_button_caption = false, $cancel_js_action = false, $captcha = false) { |
|
| 46 | 46 | |
| 47 | - $this->targetObject =& $target; |
|
| 47 | + $this->targetObject = & $target; |
|
| 48 | 48 | $this->form_fields = $form_fields; |
| 49 | 49 | $this->_cancel_js_action = $cancel_js_action; |
| 50 | - $this->_captcha= $captcha; |
|
| 51 | - $this->_form_name= $form_name; |
|
| 52 | - $this->_form_caption= $form_caption; |
|
| 53 | - $this->_submit_button_caption= $submit_button_caption; |
|
| 50 | + $this->_captcha = $captcha; |
|
| 51 | + $this->_form_name = $form_name; |
|
| 52 | + $this->_form_caption = $form_caption; |
|
| 53 | + $this->_submit_button_caption = $submit_button_caption; |
|
| 54 | 54 | |
| 55 | 55 | if (!isset($form_action)) { |
| 56 | 56 | $form_action = xoops_getenv('PHP_SELF'); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - $this->XoopsForm( $form_caption, $form_name, $form_action); |
|
| 59 | + $this->XoopsForm($form_caption, $form_name, $form_action); |
|
| 60 | 60 | $this->setExtra('enctype="multipart/form-data"'); |
| 61 | 61 | |
| 62 | 62 | $this->createElements(); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $this->addElement(new XoopsFormCaptcha(), true); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - function addCustomButton($name, $caption, $onclick=false) { |
|
| 78 | + function addCustomButton($name, $caption, $onclick = false) { |
|
| 79 | 79 | $custom_button_array = array( |
| 80 | 80 | 'name' => $name, |
| 81 | 81 | 'caption' => $caption, |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param object &$formElement reference to a {@link XoopsFormElement} |
| 91 | 91 | * @param bool $required is this a "required" element? |
| 92 | 92 | */ |
| 93 | - function addElement(&$formElement, $key=false, $var=false, $required='notset'){ |
|
| 93 | + function addElement(&$formElement, $key = false, $var = false, $required = 'notset') { |
|
| 94 | 94 | if ($key) { |
| 95 | 95 | if ($this->targetObject->vars[$key]['readonly']) { |
| 96 | 96 | $formElement->setExtra('disabled="disabled"'); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | $controls = $this->targetObject->controls; |
| 115 | - if(isset($controls[$key]['js'])){ |
|
| 115 | + if (isset($controls[$key]['js'])) { |
|
| 116 | 116 | $formElement->customValidationCode[] = $controls[$key]['js']; |
| 117 | 117 | } |
| 118 | 118 | parent::AddElement($formElement, $required == 'notset' ? $var['required'] : $required); |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $member_handler = &xoops_gethandler('member'); |
| 269 | 269 | $group_list = $member_handler->getGroupList(); |
| 270 | 270 | asort($group_list); |
| 271 | - foreach($permissions as $permission) { |
|
| 271 | + foreach ($permissions as $permission) { |
|
| 272 | 272 | if ($this->targetObject->isNew()) { |
| 273 | 273 | if (isset($smartModuleConfig['def_perm_' . $permission['perm_name']])) { |
| 274 | 274 | $groups_value = $smartModuleConfig['def_perm_' . $permission['perm_name']]; |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | $button_tray = new XoopsFormElementTray('', ''); |
| 291 | 291 | $button_tray->addElement(new XoopsFormHidden('op', $form_name)); |
| 292 | - if(!$submit_button_caption){ |
|
| 292 | + if (!$submit_button_caption) { |
|
| 293 | 293 | if ($this->targetObject->isNew()) { |
| 294 | 294 | $butt_create = new XoopsFormButton('', 'create_button', _CO_SOBJECT_CREATE, 'submit'); |
| 295 | 295 | } else { |
@@ -297,14 +297,14 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | else { |
| 300 | - $butt_create = new XoopsFormButton('', 'modify_button', $submit_button_caption , 'submit'); |
|
| 300 | + $butt_create = new XoopsFormButton('', 'modify_button', $submit_button_caption, 'submit'); |
|
| 301 | 301 | } |
| 302 | 302 | $butt_create->setExtra('onclick="this.form.elements.op.value=\'' . $form_name . '\'"'); |
| 303 | 303 | $button_tray->addElement($butt_create); |
| 304 | 304 | |
| 305 | 305 | //creating custom buttons |
| 306 | 306 | if ($this->_custom_button) { |
| 307 | - foreach($this->_custom_button as $custom_button) { |
|
| 307 | + foreach ($this->_custom_button as $custom_button) { |
|
| 308 | 308 | $butt_custom = new XoopsFormButton('', $custom_button['name'], $custom_button['caption'], 'submit'); |
| 309 | 309 | if ($custom_button['onclick']) { |
| 310 | 310 | $butt_custom->setExtra('onclick="' . $custom_button['onclick'] . '"'); |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | function getControl($controlName, $key) { |
| 330 | 330 | switch ($controlName) { |
| 331 | 331 | case 'check': |
| 332 | - include_once(SMARTOBJECT_ROOT_PATH."class/form/elements/smartformcheckelement.php"); |
|
| 332 | + include_once(SMARTOBJECT_ROOT_PATH . "class/form/elements/smartformcheckelement.php"); |
|
| 333 | 333 | $control = $this->targetObject->getControl($key); |
| 334 | 334 | $controlObj = new SmartFormCheckElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key)); |
| 335 | 335 | $controlObj->addOptionArray($control['options']); |
@@ -393,36 +393,36 @@ discard block |
||
| 393 | 393 | break; |
| 394 | 394 | |
| 395 | 395 | case 'urllink': |
| 396 | - include_once(SMARTOBJECT_ROOT_PATH."class/form/elements/smartformurllinkelement.php"); |
|
| 396 | + include_once(SMARTOBJECT_ROOT_PATH . "class/form/elements/smartformurllinkelement.php"); |
|
| 397 | 397 | return new SmartFormUrlLinkElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getUrlLinkObj($key)); |
| 398 | 398 | break; |
| 399 | 399 | |
| 400 | 400 | case 'richfile': |
| 401 | - include_once(SMARTOBJECT_ROOT_PATH."class/form/elements/smartformrichfileelement.php"); |
|
| 401 | + include_once(SMARTOBJECT_ROOT_PATH . "class/form/elements/smartformrichfileelement.php"); |
|
| 402 | 402 | return new SmartFormRichFileElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getFileObj($key)); |
| 403 | 403 | break; |
| 404 | 404 | case 'section': |
| 405 | - include_once(SMARTOBJECT_ROOT_PATH."class/form/elements/smartformsection.php"); |
|
| 405 | + include_once(SMARTOBJECT_ROOT_PATH . "class/form/elements/smartformsection.php"); |
|
| 406 | 406 | return new SmartFormSection($key, $this->targetObject->vars[$key]['form_caption']); |
| 407 | 407 | break; |
| 408 | 408 | |
| 409 | 409 | |
| 410 | 410 | default: |
| 411 | - $classname = "SmartForm".ucfirst($controlName)."Element"; |
|
| 411 | + $classname = "SmartForm" . ucfirst($controlName) . "Element"; |
|
| 412 | 412 | if (!class_exists($classname)) { |
| 413 | - if (file_exists(SMARTOBJECT_ROOT_PATH."class/form/elements/".strtolower($classname).".php")) { |
|
| 414 | - include_once(SMARTOBJECT_ROOT_PATH."class/form/elements/".strtolower($classname).".php"); |
|
| 413 | + if (file_exists(SMARTOBJECT_ROOT_PATH . "class/form/elements/" . strtolower($classname) . ".php")) { |
|
| 414 | + include_once(SMARTOBJECT_ROOT_PATH . "class/form/elements/" . strtolower($classname) . ".php"); |
|
| 415 | 415 | } else { |
| 416 | 416 | // perhaps this is a control created by the module |
| 417 | 417 | $moduleName = $this->targetObject->handler->_moduleName; |
| 418 | 418 | $moduleFormElementsPath = $this->targetObject->handler->_modulePath . 'class/form/elements/'; |
| 419 | 419 | $classname = ucfirst($moduleName) . ucfirst($controlName) . "Element"; |
| 420 | - $classFileName = strtolower($classname).".php"; |
|
| 420 | + $classFileName = strtolower($classname) . ".php"; |
|
| 421 | 421 | |
| 422 | 422 | if (file_exists($moduleFormElementsPath . $classFileName)) { |
| 423 | 423 | include_once($moduleFormElementsPath . $classFileName); |
| 424 | 424 | } else { |
| 425 | - trigger_error($classname." Not found", E_USER_WARNING); |
|
| 425 | + trigger_error($classname . " Not found", E_USER_WARNING); |
|
| 426 | 426 | return new XoopsFormLabel(); //Empty object |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | |
| 464 | 464 | $value = $this->targetObject->getValueFor($key, true); |
| 465 | 465 | |
| 466 | - $editor_configs=array(); |
|
| 466 | + $editor_configs = array(); |
|
| 467 | 467 | $editor_configs["name"] = $name; |
| 468 | 468 | $editor_configs["value"] = $value; |
| 469 | 469 | if ($form_editor != 'textarea') { |
@@ -489,13 +489,13 @@ discard block |
||
| 489 | 489 | $editor = new XoopsFormEditor($caption, $form_editor, $editor_configs, $nohtml = false, $onfailure = "textarea"); |
| 490 | 490 | } else { |
| 491 | 491 | |
| 492 | - switch($form_editor) { |
|
| 492 | + switch ($form_editor) { |
|
| 493 | 493 | |
| 494 | 494 | case 'tiny' : |
| 495 | 495 | if (!$xoops22) { |
| 496 | - if ( is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/tinyeditor/formtinytextarea.php")) { |
|
| 496 | + if (is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/tinyeditor/formtinytextarea.php")) { |
|
| 497 | 497 | include_once(XOOPS_ROOT_PATH . "/class/xoopseditor/tinyeditor/formtinytextarea.php"); |
| 498 | - $editor = new XoopsFormTinyTextArea(array('caption'=> $caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'300px'),true); |
|
| 498 | + $editor = new XoopsFormTinyTextArea(array('caption'=> $caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'300px'), true); |
|
| 499 | 499 | } else { |
| 500 | 500 | if ($dhtml) { |
| 501 | 501 | $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
@@ -518,9 +518,9 @@ discard block |
||
| 518 | 518 | |
| 519 | 519 | case 'fckeditor' : |
| 520 | 520 | if (!$xoops22) { |
| 521 | - if ( is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/fckeditor/formfckeditor.php")) { |
|
| 521 | + if (is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/fckeditor/formfckeditor.php")) { |
|
| 522 | 522 | include_once(XOOPS_ROOT_PATH . "/class/xoopseditor/fckeditor/formfckeditor.php"); |
| 523 | - $editor = new XoopsFormFckeditor(array('caption'=> $caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'300px'),true); |
|
| 523 | + $editor = new XoopsFormFckeditor(array('caption'=> $caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'300px'), true); |
|
| 524 | 524 | } else { |
| 525 | 525 | if ($dhtml) { |
| 526 | 526 | $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
@@ -535,9 +535,9 @@ discard block |
||
| 535 | 535 | |
| 536 | 536 | case 'inbetween' : |
| 537 | 537 | if (!$xoops22) { |
| 538 | - if ( is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/inbetween/forminbetweentextarea.php")) { |
|
| 538 | + if (is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/inbetween/forminbetweentextarea.php")) { |
|
| 539 | 539 | include_once(XOOPS_ROOT_PATH . "/class/xoopseditor/inbetween/forminbetweentextarea.php"); |
| 540 | - $editor = new XoopsFormInbetweenTextArea(array('caption'=> $caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'300px'),true); |
|
| 540 | + $editor = new XoopsFormInbetweenTextArea(array('caption'=> $caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'300px'), true); |
|
| 541 | 541 | } else { |
| 542 | 542 | if ($dhtml) { |
| 543 | 543 | $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | |
| 553 | 553 | case 'koivi' : |
| 554 | 554 | if (!$xoops22) { |
| 555 | - if ( is_readable(XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php")) { |
|
| 555 | + if (is_readable(XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php")) { |
|
| 556 | 556 | include_once(XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php"); |
| 557 | 557 | $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px'); |
| 558 | 558 | } else { |
@@ -568,8 +568,8 @@ discard block |
||
| 568 | 568 | break; |
| 569 | 569 | |
| 570 | 570 | case "spaw": |
| 571 | - if(!$xoops22) { |
|
| 572 | - if (is_readable(XOOPS_ROOT_PATH . "/class/spaw/formspaw.php")) { |
|
| 571 | + if (!$xoops22) { |
|
| 572 | + if (is_readable(XOOPS_ROOT_PATH . "/class/spaw/formspaw.php")) { |
|
| 573 | 573 | include_once(XOOPS_ROOT_PATH . "/class/spaw/formspaw.php"); |
| 574 | 574 | $editor = new XoopsFormSpaw($caption, $name, $value); |
| 575 | 575 | } |
@@ -579,8 +579,8 @@ discard block |
||
| 579 | 579 | break; |
| 580 | 580 | |
| 581 | 581 | case "htmlarea": |
| 582 | - if(!$xoops22) { |
|
| 583 | - if ( is_readable(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php")) { |
|
| 582 | + if (!$xoops22) { |
|
| 583 | + if (is_readable(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php")) { |
|
| 584 | 584 | include_once(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php"); |
| 585 | 585 | $editor = new XoopsFormHtmlarea($caption, $name, $value); |
| 586 | 586 | } |
@@ -606,16 +606,16 @@ discard block |
||
| 606 | 606 | return $editor; |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | - function getThemeSelect($key, $var, $multiple=false) { |
|
| 609 | + function getThemeSelect($key, $var, $multiple = false) { |
|
| 610 | 610 | |
| 611 | 611 | $size = $multiple ? 5 : 1; |
| 612 | 612 | $theme_select = new XoopsFormSelect($var['form_caption'], $key, $this->targetObject->getVar($key), $size, $multiple); |
| 613 | 613 | |
| 614 | - $handle = opendir(XOOPS_THEME_PATH.'/'); |
|
| 614 | + $handle = opendir(XOOPS_THEME_PATH . '/'); |
|
| 615 | 615 | $dirlist = array(); |
| 616 | 616 | while (false !== ($file = readdir($handle))) { |
| 617 | - if (is_dir(XOOPS_THEME_PATH.'/'.$file) && !preg_match("/^[.]{1,2}$/",$file) && strtolower($file) != 'cvs') { |
|
| 618 | - $dirlist[$file]=$file; |
|
| 617 | + if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) != 'cvs') { |
|
| 618 | + $dirlist[$file] = $file; |
|
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | closedir($handle); |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | function &getElementById($keyname) { |
| 631 | 631 | foreach ($this->_elements as $eleObj) { |
| 632 | 632 | if ($eleObj->getName() == $keyname) { |
| 633 | - $ret =& $eleObj; |
|
| 633 | + $ret = & $eleObj; |
|
| 634 | 634 | break; |
| 635 | 635 | } |
| 636 | 636 | } |
@@ -644,30 +644,30 @@ discard block |
||
| 644 | 644 | */ |
| 645 | 645 | function render() |
| 646 | 646 | { |
| 647 | - $required =& $this->getRequired(); |
|
| 647 | + $required = & $this->getRequired(); |
|
| 648 | 648 | $ret = " |
| 649 | - <form name='".$this->getName()."' id='".$this->getName()."' action='".$this->getAction()."' method='".$this->getMethod()."' onsubmit='return xoopsFormValidate_".$this->getName()."(this);'".$this->getExtra()."> |
|
| 649 | + <form name='".$this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "' onsubmit='return xoopsFormValidate_" . $this->getName() . "(this);'" . $this->getExtra() . "> |
|
| 650 | 650 | <table width='100%' class='outer' cellspacing='1'> |
| 651 | - <tr><th colspan='2'>".$this->getTitle()."</th></tr> |
|
| 651 | + <tr><th colspan='2'>".$this->getTitle() . "</th></tr> |
|
| 652 | 652 | "; |
| 653 | 653 | $hidden = ''; |
| 654 | - $class ='even'; |
|
| 655 | - foreach ( $this->getElements() as $ele ) { |
|
| 654 | + $class = 'even'; |
|
| 655 | + foreach ($this->getElements() as $ele) { |
|
| 656 | 656 | if (!is_object($ele)) { |
| 657 | 657 | $ret .= $ele; |
| 658 | - } elseif ( !$ele->isHidden() ) { |
|
| 658 | + } elseif (!$ele->isHidden()) { |
|
| 659 | 659 | //$class = ( $class == 'even' ) ? 'odd' : 'even'; |
| 660 | - $ret .= "<tr id='" . $ele->getName() . "' valign='top' align='left'><td class='head'>".$ele->getCaption(); |
|
| 660 | + $ret .= "<tr id='" . $ele->getName() . "' valign='top' align='left'><td class='head'>" . $ele->getCaption(); |
|
| 661 | 661 | if ($ele->getDescription() != '') { |
| 662 | - $ret .= '<br /><br /><span style="font-weight: normal;">'.$ele->getDescription().'</span>'; |
|
| 662 | + $ret .= '<br /><br /><span style="font-weight: normal;">' . $ele->getDescription() . '</span>'; |
|
| 663 | 663 | } |
| 664 | - $ret .= "</td><td class='$class'>".$ele->render()."</td></tr>\n"; |
|
| 664 | + $ret .= "</td><td class='$class'>" . $ele->render() . "</td></tr>\n"; |
|
| 665 | 665 | } else { |
| 666 | 666 | $hidden .= $ele->render(); |
| 667 | 667 | } |
| 668 | 668 | } |
| 669 | 669 | $ret .= "</table>\n$hidden\n</form>\n"; |
| 670 | - $ret .= $this->renderValidationJS( true ); |
|
| 670 | + $ret .= $this->renderValidationJS(true); |
|
| 671 | 671 | return $ret; |
| 672 | 672 | } |
| 673 | 673 | |
@@ -677,20 +677,20 @@ discard block |
||
| 677 | 677 | * @param object &$tpl reference to a {@link Smarty} object |
| 678 | 678 | * @see Smarty |
| 679 | 679 | */ |
| 680 | - function assign(&$tpl, $smartyName=false){ |
|
| 680 | + function assign(&$tpl, $smartyName = false) { |
|
| 681 | 681 | $i = 0; |
| 682 | 682 | $elements = array(); |
| 683 | - foreach ( $this->getElements() as $ele ) { |
|
| 683 | + foreach ($this->getElements() as $ele) { |
|
| 684 | 684 | $n = ($ele->getName() != "") ? $ele->getName() : $i; |
| 685 | 685 | $elements[$n]['name'] = $ele->getName(); |
| 686 | 686 | $elements[$n]['caption'] = $ele->getCaption(); |
| 687 | 687 | $elements[$n]['body'] = $ele->render(); |
| 688 | 688 | $elements[$n]['hidden'] = $ele->isHidden(); |
| 689 | 689 | $elements[$n]['section'] = strToLower(get_class($ele)) == strToLower('SmartFormSection'); |
| 690 | - $elements[$n]['section_close'] = get_class($ele) == 'SmartFormSectionClose'; |
|
| 690 | + $elements[$n]['section_close'] = get_class($ele) == 'SmartFormSectionClose'; |
|
| 691 | 691 | $elements[$n]['hide'] = isset($this->targetObject->vars[$n]['hide']) ? $this->targetObject->vars[$n]['hide'] : false; |
| 692 | 692 | if ($ele->getDescription() != '') { |
| 693 | - $elements[$n]['description'] = $ele->getDescription(); |
|
| 693 | + $elements[$n]['description'] = $ele->getDescription(); |
|
| 694 | 694 | } |
| 695 | 695 | $i++; |
| 696 | 696 | } |
@@ -699,25 +699,25 @@ discard block |
||
| 699 | 699 | $smartyName = $this->getName(); |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - $tpl->assign($smartyName, array('title' => $this->getTitle(), 'name' => $this->getName(), 'action' => $this->getAction(), 'method' => $this->getMethod(), 'extra' => 'onsubmit="return xoopsFormValidate_'.$this->getName().'(this);"'.$this->getExtra(), 'javascript' => $js, 'elements' => $elements)); |
|
| 702 | + $tpl->assign($smartyName, array('title' => $this->getTitle(), 'name' => $this->getName(), 'action' => $this->getAction(), 'method' => $this->getMethod(), 'extra' => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '(this);"' . $this->getExtra(), 'javascript' => $js, 'elements' => $elements)); |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | |
| 706 | - function renderValidationJS( $withtags = true ) { |
|
| 706 | + function renderValidationJS($withtags = true) { |
|
| 707 | 707 | $js = ""; |
| 708 | - if ( $withtags ) { |
|
| 708 | + if ($withtags) { |
|
| 709 | 709 | $js .= "\n<!-- Start Form Validation JavaScript //-->\n<script type='text/javascript'>\n<!--//\n"; |
| 710 | 710 | } |
| 711 | - $myts =& MyTextSanitizer::getInstance(); |
|
| 711 | + $myts = & MyTextSanitizer::getInstance(); |
|
| 712 | 712 | $formname = $this->getName(); |
| 713 | 713 | $js .= "function xoopsFormValidate_{$formname}(myform) {"; |
| 714 | 714 | // First, output code to check required elements |
| 715 | 715 | $elements = $this->getRequired(); |
| 716 | - foreach ( $elements as $elt ) { |
|
| 716 | + foreach ($elements as $elt) { |
|
| 717 | 717 | $eltname = $elt->getName(); |
| 718 | - $eltcaption = trim( $elt->getCaption() ); |
|
| 719 | - $eltmsg = empty($eltcaption) ? sprintf( _FORM_ENTER, $eltname ) : sprintf( _FORM_ENTER, $eltcaption ); |
|
| 720 | - $eltmsg = str_replace('"', '\"', stripslashes( $eltmsg ) ); |
|
| 718 | + $eltcaption = trim($elt->getCaption()); |
|
| 719 | + $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); |
|
| 720 | + $eltmsg = str_replace('"', '\"', stripslashes($eltmsg)); |
|
| 721 | 721 | if (strtolower(get_class($elt)) == 'xoopsformradio') { |
| 722 | 722 | $js .= "var myOption = -1;"; |
| 723 | 723 | $js .= "for (i=myform.{$eltname}.length-1; i > -1; i--) { |
@@ -739,10 +739,10 @@ discard block |
||
| 739 | 739 | if (hasSelections == false) { |
| 740 | 740 | window.alert(\"{$eltmsg}\"); myform['{$eltname}[]'].options[0].focus(); return false; }\n"; |
| 741 | 741 | |
| 742 | - }elseif (strtolower(get_class($elt)) == 'xoopsformcheckbox' || strtolower(get_class($elt)) == 'smartformcheckelement' ) { |
|
| 742 | + }elseif (strtolower(get_class($elt)) == 'xoopsformcheckbox' || strtolower(get_class($elt)) == 'smartformcheckelement') { |
|
| 743 | 743 | $js .= "var hasSelections = false;"; |
| 744 | 744 | //sometimes, there is an implicit '[]', sometimes not |
| 745 | - if(strpos($eltname, '[') === false){ |
|
| 745 | + if (strpos($eltname, '[') === false) { |
|
| 746 | 746 | $js .= "for(var i = 0; i < myform['{$eltname}[]'].length; i++){ |
| 747 | 747 | if (myform['{$eltname}[]'][i].checked) { |
| 748 | 748 | hasSelections = true; |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | } |
| 752 | 752 | if (hasSelections == false) { |
| 753 | 753 | window.alert(\"{$eltmsg}\"); myform['{$eltname}[]'][0].focus(); return false; }\n"; |
| 754 | - }else{ |
|
| 754 | + } else { |
|
| 755 | 755 | $js .= "for(var i = 0; i < myform['{$eltname}'].length; i++){ |
| 756 | 756 | if (myform['{$eltname}'][i].checked) { |
| 757 | 757 | hasSelections = true; |
@@ -762,22 +762,22 @@ discard block |
||
| 762 | 762 | window.alert(\"{$eltmsg}\"); myform['{$eltname}'][0].focus(); return false; }\n"; |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - }else{ |
|
| 765 | + } else { |
|
| 766 | 766 | $js .= "if ( myform.{$eltname}.value == \"\" ) " |
| 767 | 767 | . "{ window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }\n"; |
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | // Now, handle custom validation code |
| 771 | - $elements = $this->getElements( true ); |
|
| 772 | - foreach ( $elements as $elt ) { |
|
| 773 | - if ( method_exists( $elt, 'renderValidationJS') && strtolower(get_class($elt)) != 'xoopsformcheckbox') { |
|
| 774 | - if ( $eltjs = $elt->renderValidationJS() ) { |
|
| 771 | + $elements = $this->getElements(true); |
|
| 772 | + foreach ($elements as $elt) { |
|
| 773 | + if (method_exists($elt, 'renderValidationJS') && strtolower(get_class($elt)) != 'xoopsformcheckbox') { |
|
| 774 | + if ($eltjs = $elt->renderValidationJS()) { |
|
| 775 | 775 | $js .= $eltjs . "\n"; |
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | } |
| 779 | 779 | $js .= "return true;\n}\n"; |
| 780 | - if ( $withtags ) { |
|
| 780 | + if ($withtags) { |
|
| 781 | 781 | $js .= "//--></script>\n<!-- End Form Vaidation JavaScript //-->\n"; |
| 782 | 782 | } |
| 783 | 783 | return $js; |
@@ -65,6 +65,9 @@ |
||
| 65 | 65 | 'method' => 'getRateList')); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | + /** |
|
| 69 | + * @param string $key |
|
| 70 | + */ |
|
| 68 | 71 | function getVar($key, $format = 's') { |
| 69 | 72 | if ($format == 's' && in_array($key, array('name', 'dirname'))) { |
| 70 | 73 | return call_user_func(array($this,$key)); |
@@ -31,12 +31,12 @@ discard block |
||
| 31 | 31 | die("XOOPS root path not defined"); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobject.php"; |
|
| 35 | -include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartplugins.php"; |
|
| 34 | +include_once XOOPS_ROOT_PATH . "/modules/smartobject/class/smartobject.php"; |
|
| 35 | +include_once XOOPS_ROOT_PATH . "/modules/smartobject/class/smartplugins.php"; |
|
| 36 | 36 | |
| 37 | 37 | class SmartobjectRating extends SmartObject { |
| 38 | 38 | |
| 39 | - var $_modulePlugin=false; |
|
| 39 | + var $_modulePlugin = false; |
|
| 40 | 40 | |
| 41 | 41 | function SmartobjectRating() { |
| 42 | 42 | $this->quickInitVar('ratingid', XOBJ_DTYPE_INT, true); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | function getVar($key, $format = 's') { |
| 69 | 69 | if ($format == 's' && in_array($key, array('name', 'dirname'))) { |
| 70 | - return call_user_func(array($this,$key)); |
|
| 70 | + return call_user_func(array($this, $key)); |
|
| 71 | 71 | } |
| 72 | 72 | return parent::getVar($key, $format); |
| 73 | 73 | } |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | class SmartobjectRatingHandler extends SmartPersistableObjectHandler { |
| 117 | 117 | |
| 118 | - var $_rateOptions=array(); |
|
| 119 | - var $_moduleList=false; |
|
| 118 | + var $_rateOptions = array(); |
|
| 119 | + var $_moduleList = false; |
|
| 120 | 120 | var $pluginsObject; |
| 121 | 121 | |
| 122 | 122 | function SmartobjectRatingHandler($db) { |
@@ -158,19 +158,19 @@ discard block |
||
| 158 | 158 | $ret['sum'] = isset($sum) ? $sum : 0; |
| 159 | 159 | return $ret; |
| 160 | 160 | } |
| 161 | - function already_rated($item, $itemid, $dirname, $uid){ |
|
| 161 | + function already_rated($item, $itemid, $dirname, $uid) { |
|
| 162 | 162 | |
| 163 | 163 | $criteria = new CriteriaCompo(); |
| 164 | - $criteria->add(new Criteria('item',$item )); |
|
| 165 | - $criteria->add(new Criteria('itemid',$itemid )); |
|
| 164 | + $criteria->add(new Criteria('item', $item)); |
|
| 165 | + $criteria->add(new Criteria('itemid', $itemid)); |
|
| 166 | 166 | $criteria->add(new Criteria('dirname', $dirname)); |
| 167 | 167 | $criteria->add(new Criteria('user.uid', $uid)); |
| 168 | 168 | |
| 169 | 169 | $ret = $this->getObjects($criteria); |
| 170 | 170 | |
| 171 | - if(!$ret){ |
|
| 171 | + if (!$ret) { |
|
| 172 | 172 | return false; |
| 173 | - }else{ |
|
| 173 | + } else { |
|
| 174 | 174 | return $ret[0]; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -129,6 +129,10 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | return $fields; |
| 131 | 131 | } |
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @param string $field |
|
| 135 | + */ |
|
| 132 | 136 | function fieldExists($field) { |
| 133 | 137 | $existingFields = $this->getExistingFieldsArray(); |
| 134 | 138 | return isset ($existingFields[$field]); |
@@ -541,7 +545,7 @@ discard block |
||
| 541 | 545 | /** |
| 542 | 546 | * Use to update a table |
| 543 | 547 | * |
| 544 | - * @param object $table {@link SmartDbTable} that will be updated |
|
| 548 | + * @param SmartDbTable $table {@link SmartDbTable} that will be updated |
|
| 545 | 549 | * |
| 546 | 550 | * @see SmartDbTable |
| 547 | 551 | * |
@@ -601,6 +605,9 @@ discard block |
||
| 601 | 605 | return $ret; |
| 602 | 606 | } |
| 603 | 607 | |
| 608 | + /** |
|
| 609 | + * @return string |
|
| 610 | + */ |
|
| 604 | 611 | function getFieldDefaultFromVar($var, $key = false) { |
| 605 | 612 | if ($var['value']) { |
| 606 | 613 | return $var['value']; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ //felix |
| 78 | 78 | var $_updatedWhere; |
| 79 | 79 | |
| 80 | - var $_existingFieldsArray=false; |
|
| 80 | + var $_existingFieldsArray = false; |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Constructor |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | function SmartDbTable($name) { |
| 89 | 89 | $this->_name = $name; |
| 90 | - $this->_data = array (); |
|
| 90 | + $this->_data = array(); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * @param string $properties properties of the field |
| 208 | 208 | * |
| 209 | 209 | */ |
| 210 | - function addAlteredField($name, $properties, $newname=false, $showerror = true) { |
|
| 210 | + function addAlteredField($name, $properties, $newname = false, $showerror = true) { |
|
| 211 | 211 | $field['name'] = $name; |
| 212 | 212 | $field['properties'] = $properties; |
| 213 | 213 | $field['showerror'] = $showerror; |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | //xoops_debug($query); |
| 327 | 327 | $ret = $xoopsDB->query($query); |
| 328 | 328 | if (!$ret) { |
| 329 | - echo " " . sprintf(_SDU_MSG_CREATE_TABLE_ERR, $this->name()) . " (" . $xoopsDB->error(). ")<br />"; |
|
| 329 | + echo " " . sprintf(_SDU_MSG_CREATE_TABLE_ERR, $this->name()) . " (" . $xoopsDB->error() . ")<br />"; |
|
| 330 | 330 | |
| 331 | 331 | } else { |
| 332 | 332 | echo " " . sprintf(_SDU_MSG_CREATE_TABLE, $this->name()) . "<br />"; |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $query = sprintf("DROP TABLE %s", $this->name()); |
| 345 | 345 | $ret = $xoopsDB->query($query); |
| 346 | 346 | if (!$ret) { |
| 347 | - echo " " . sprintf(_SDU_MSG_DROP_TABLE_ERR, $this->name()) . " (" . $xoopsDB->error(). ")<br />"; |
|
| 347 | + echo " " . sprintf(_SDU_MSG_DROP_TABLE_ERR, $this->name()) . " (" . $xoopsDB->error() . ")<br />"; |
|
| 348 | 348 | return false; |
| 349 | 349 | } else { |
| 350 | 350 | echo " " . sprintf(_SDU_MSG_DROP_TABLE, $this->name()) . "<br />"; |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | $ret = $ret && $xoopsDB->query($query); |
| 371 | 371 | if ($alteredField['showerror']) { |
| 372 | 372 | if (!$ret) { |
| 373 | - echo " " . sprintf(_SDU_MSG_CHGFIELD_ERR, $alteredField['name'], $this->name()) . " (" . $xoopsDB->error(). ")<br />"; |
|
| 373 | + echo " " . sprintf(_SDU_MSG_CHGFIELD_ERR, $alteredField['name'], $this->name()) . " (" . $xoopsDB->error() . ")<br />"; |
|
| 374 | 374 | } else { |
| 375 | 375 | echo " " . sprintf(_SDU_MSG_CHGFIELD, $alteredField['name'], $this->name()) . "<br />"; |
| 376 | 376 | } |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | $query = sprintf("UPDATE %s SET %s = %s", $this->name(), $updatedField['name'], $updatedField['value']); |
| 414 | 414 | $ret = $ret && $xoopsDB->query($query); |
| 415 | 415 | if (!$ret) { |
| 416 | - echo " " . sprintf(_SDU_MSG_UPDATE_TABLE_ERR, $this->name()) . " (" . $xoopsDB->error(). ")<br />"; |
|
| 416 | + echo " " . sprintf(_SDU_MSG_UPDATE_TABLE_ERR, $this->name()) . " (" . $xoopsDB->error() . ")<br />"; |
|
| 417 | 417 | } else { |
| 418 | 418 | echo " " . sprintf(_SDU_MSG_UPDATE_TABLE, $this->name()) . "<br />"; |
| 419 | 419 | } |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | //echo $query."<br>"; |
| 435 | 435 | $ret = $ret && $xoopsDB->query($query); |
| 436 | 436 | if (!$ret) { |
| 437 | - echo " " . sprintf(_SDU_MSG_UPDATE_TABLE_ERR, $this->name()) . " (" . $xoopsDB->error(). ")<br />"; |
|
| 437 | + echo " " . sprintf(_SDU_MSG_UPDATE_TABLE_ERR, $this->name()) . " (" . $xoopsDB->error() . ")<br />"; |
|
| 438 | 438 | } else { |
| 439 | 439 | echo " " . sprintf(_SDU_MSG_UPDATE_TABLE, $this->name()) . "<br />"; |
| 440 | 440 | } |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | $query = sprintf("ALTER TABLE %s DROP %s", $this->name(), $dropedField); |
| 455 | 455 | $ret = $ret && $xoopsDB->query($query); |
| 456 | 456 | if (!$ret) { |
| 457 | - echo " " . sprintf(_SDU_MSG_DROPFIELD_ERR, $dropedField, $this->name()) . " (" . $xoopsDB->error(). ")<br />"; |
|
| 457 | + echo " " . sprintf(_SDU_MSG_DROPFIELD_ERR, $dropedField, $this->name()) . " (" . $xoopsDB->error() . ")<br />"; |
|
| 458 | 458 | } else { |
| 459 | 459 | echo " " . sprintf(_SDU_MSG_DROPFIELD, $dropedField, $this->name()) . "<br />"; |
| 460 | 460 | } |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | function automaticUpgrade($module, $item) { |
| 590 | 590 | if (is_array($item)) { |
| 591 | - foreach($item as $v) { |
|
| 591 | + foreach ($item as $v) { |
|
| 592 | 592 | $this->upgradeObjectItem($module, $v); |
| 593 | 593 | } |
| 594 | 594 | } else { |
@@ -634,13 +634,13 @@ discard block |
||
| 634 | 634 | if (!$table->exists()) { |
| 635 | 635 | // table was never created, let's do it |
| 636 | 636 | $structure = ""; |
| 637 | - foreach($objectVars as $key=>$var) { |
|
| 637 | + foreach ($objectVars as $key=>$var) { |
|
| 638 | 638 | if ($var['persistent']) { |
| 639 | 639 | $type = $this->getFieldTypeFromVar($var); |
| 640 | 640 | if ($key == $module_handler->keyName) { |
| 641 | 641 | $extra = "auto_increment"; |
| 642 | 642 | } else { |
| 643 | - $default = $this->getFieldDefaultFromVar($var); |
|
| 643 | + $default = $this->getFieldDefaultFromVar($var); |
|
| 644 | 644 | $extra = "default '$default' |
| 645 | 645 | "; |
| 646 | 646 | } |
@@ -658,21 +658,21 @@ discard block |
||
| 658 | 658 | } |
| 659 | 659 | } else { |
| 660 | 660 | $existingFieldsArray = $table->getExistingFieldsArray(); |
| 661 | - foreach($objectVars as $key=>$var) { |
|
| 661 | + foreach ($objectVars as $key=>$var) { |
|
| 662 | 662 | if ($var['persistent']) { |
| 663 | 663 | if (!isset($existingFieldsArray[$key])) { |
| 664 | 664 | // the fiels does not exist, let's create it |
| 665 | 665 | $type = $this->getFieldTypeFromVar($var); |
| 666 | - $default = $this->getFieldDefaultFromVar($var); |
|
| 666 | + $default = $this->getFieldDefaultFromVar($var); |
|
| 667 | 667 | $table->addNewField($key, "$type not null default '$default'"); |
| 668 | 668 | } else { |
| 669 | 669 | // if field already exists, let's check if the definition is correct |
| 670 | - $definition = strtolower($existingFieldsArray[$key]); |
|
| 670 | + $definition = strtolower($existingFieldsArray[$key]); |
|
| 671 | 671 | $type = $this->getFieldTypeFromVar($var); |
| 672 | 672 | if ($key == $module_handler->keyName) { |
| 673 | 673 | $extra = "auto_increment"; |
| 674 | 674 | } else { |
| 675 | - $default = $this->getFieldDefaultFromVar($var, $key); |
|
| 675 | + $default = $this->getFieldDefaultFromVar($var, $key); |
|
| 676 | 676 | $extra = "default '$default'"; |
| 677 | 677 | } |
| 678 | 678 | $actual_definition = "$type not null $extra"; |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | } |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | - $dbVersion = smart_GetMeta('version', $dirname); |
|
| 719 | + $dbVersion = smart_GetMeta('version', $dirname); |
|
| 720 | 720 | if (!$dbVersion) { |
| 721 | 721 | $dbVersion = 0; |
| 722 | 722 | } |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | echo 'New database version : ' . $newDbVersion . '<br />'; |
| 726 | 726 | |
| 727 | 727 | if ($newDbVersion > $dbVersion) { |
| 728 | - for($i=$dbVersion+1;$i<=$newDbVersion; $i++) { |
|
| 728 | + for ($i = $dbVersion + 1; $i <= $newDbVersion; $i++) { |
|
| 729 | 729 | $upgrade_function = $dirname . '_db_upgrade_' . $i; |
| 730 | 730 | if (function_exists($upgrade_function)) { |
| 731 | 731 | $upgrade_function(); |
@@ -177,6 +177,10 @@ discard block |
||
| 177 | 177 | return implode($separator, $ret); |
| 178 | 178 | |
| 179 | 179 | } |
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * @param false|string $trimFunction |
|
| 183 | + */ |
|
| 180 | 184 | function valToCsvHelper($val, $separator, $trimFunction) { |
| 181 | 185 | if ($trimFunction) |
| 182 | 186 | $val = $trimFunction ($val); |
@@ -221,6 +225,9 @@ discard block |
||
| 221 | 225 | $this->saveExportFile($exportFileData); |
| 222 | 226 | } |
| 223 | 227 | |
| 228 | + /** |
|
| 229 | + * @param string $content |
|
| 230 | + */ |
|
| 224 | 231 | function saveExportFile($content) { |
| 225 | 232 | switch ($this->format) { |
| 226 | 233 | case 'csv': |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | var $filename; |
| 28 | 28 | var $filepath; |
| 29 | 29 | var $options; |
| 30 | - var $outputMethods=false; |
|
| 30 | + var $outputMethods = false; |
|
| 31 | 31 | var $notDisplayFields; |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param string $format format of the ouputed export. Currently only supports CSV |
| 42 | 42 | * @param array $options options of the format to be exported in |
| 43 | 43 | */ |
| 44 | - function SmartObjectExport(&$objectHandler, $criteria=null, $fields=false, $filename=false, $filepath=false, $format='csv', $options=false) { |
|
| 44 | + function SmartObjectExport(&$objectHandler, $criteria = null, $fields = false, $filename = false, $filepath = false, $format = 'csv', $options = false) { |
|
| 45 | 45 | $this->handler = $objectHandler; |
| 46 | 46 | $this->criteria = $criteria; |
| 47 | 47 | $this->fields = $fields; |
@@ -101,17 +101,17 @@ discard block |
||
| 101 | 101 | /* |
| 102 | 102 | * Set an array of fields that we don't want in export |
| 103 | 103 | */ |
| 104 | - function setNotDisplayFields($fields){ |
|
| 105 | - if(!$this->notDisplayFields){ |
|
| 106 | - if(is_array($fields)){ |
|
| 104 | + function setNotDisplayFields($fields) { |
|
| 105 | + if (!$this->notDisplayFields) { |
|
| 106 | + if (is_array($fields)) { |
|
| 107 | 107 | $this->notDisplayFields = $fields; |
| 108 | - }else{ |
|
| 108 | + } else { |
|
| 109 | 109 | $this->notDisplayFields = array($fields); |
| 110 | 110 | } |
| 111 | - }else{ |
|
| 112 | - if(is_array($fields)){ |
|
| 111 | + } else { |
|
| 112 | + if (is_array($fields)) { |
|
| 113 | 113 | $this->notDisplayFields = array_merge($this->notDisplayFields, $fields); |
| 114 | - }else{ |
|
| 114 | + } else { |
|
| 115 | 115 | $this->notDisplayFields[] = $fields; |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param string $filepath path where the file will be saved |
| 145 | 145 | * @param array $options options of the format to be exported in |
| 146 | 146 | */ |
| 147 | - function SmartExportRenderer($data, $filename=false, $filepath=false, $format='csv', $options=array('separator'=>';')) { |
|
| 147 | + function SmartExportRenderer($data, $filename = false, $filepath = false, $format = 'csv', $options = array('separator'=>';')) { |
|
| 148 | 148 | $this->data = $data; |
| 149 | 149 | $this->format = $format; |
| 150 | 150 | $this->filename = $filename; |
@@ -169,8 +169,8 @@ discard block |
||
| 169 | 169 | $trimFunction = 'trim'; |
| 170 | 170 | break; |
| 171 | 171 | } |
| 172 | - $ret = array (); |
|
| 173 | - foreach($dataArray as $key=>$field){ |
|
| 172 | + $ret = array(); |
|
| 173 | + foreach ($dataArray as $key=>$field) { |
|
| 174 | 174 | $ret[$key] = $this->valToCsvHelper($field, $separator, $trimFunction); |
| 175 | 175 | } |
| 176 | 176 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | function valToCsvHelper($val, $separator, $trimFunction) { |
| 181 | 181 | if ($trimFunction) |
| 182 | - $val = $trimFunction ($val); |
|
| 182 | + $val = $trimFunction($val); |
|
| 183 | 183 | //If there is a separator (;) or a quote (") or a linebreak in the string, we need to quote it. |
| 184 | 184 | $needQuote = FALSE; |
| 185 | 185 | do { |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $firstRow = implode($separator, $this->data['columnsHeaders']); |
| 214 | 214 | $exportFileData .= $firstRow . "\r\n"; |
| 215 | 215 | |
| 216 | - foreach($this->data['rows'] as $cols) { |
|
| 216 | + foreach ($this->data['rows'] as $cols) { |
|
| 217 | 217 | $exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n"; |
| 218 | 218 | } |
| 219 | 219 | break; |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | } else { |
| 248 | 248 | $mimeType = 'text/csv'; |
| 249 | 249 | $file = strrev($this->filename); |
| 250 | - $temp_name = strtolower(strrev(substr($file,0,strpos($file,"--"))) ); |
|
| 250 | + $temp_name = strtolower(strrev(substr($file, 0, strpos($file, "--")))); |
|
| 251 | 251 | if ($temp_name == '') { |
| 252 | 252 | $file_name = $this->filename; |
| 253 | 253 | } else { |
@@ -255,21 +255,21 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | $fullFileName = $this->filepath . stripslashes(trim($this->filename)); |
| 257 | 257 | |
| 258 | - if(ini_get('zlib.output_compression')) { |
|
| 258 | + if (ini_get('zlib.output_compression')) { |
|
| 259 | 259 | ini_set('zlib.output_compression', 'Off'); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | header("Pragma: public"); |
| 263 | 263 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
| 264 | - header("Cache-Control: private",false); |
|
| 264 | + header("Cache-Control: private", false); |
|
| 265 | 265 | header("Content-Transfer-Encoding: binary"); |
| 266 | - if(isset($mimeType)) { |
|
| 266 | + if (isset($mimeType)) { |
|
| 267 | 267 | header("Content-Type: " . $mimeType); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | header("Content-Disposition: attachment; filename=" . $file_name); |
| 271 | 271 | |
| 272 | - if(isset($mimeType) && strstr($mimeType, "text/")) { |
|
| 272 | + if (isset($mimeType) && strstr($mimeType, "text/")) { |
|
| 273 | 273 | $fp = fopen($fullFileName, "r"); |
| 274 | 274 | } |
| 275 | 275 | else { |