public function testboolVal() { $this->assertTrue(BooleanUtil::boolVal(true)); $this->assertTrue(BooleanUtil::boolVal('true')); $this->assertTrue(BooleanUtil::boolVal(1)); $this->assertFalse(BooleanUtil::boolVal(false)); $this->assertFalse(BooleanUtil::boolVal('false')); $this->assertFalse(BooleanUtil::boolVal(0)); $this->assertFalse(BooleanUtil::boolVal('hello')); }
/** * Render A standard text input. * @return The element's content as a string. */ protected function renderControlEditable() { assert('empty($this->model->{$this->attribute}) || is_string($this->model->{$this->attribute}) || is_integer(BooleanUtil::boolIntVal($this->model->{$this->attribute}))'); $htmlOptions = array(); $htmlOptions['id'] = $this->getEditableInputId(); $htmlOptions['name'] = $this->getEditableInputName(); if ($this->getDisabledValue()) { $htmlOptions['disabled'] = $this->getDisabledValue(); if (BooleanUtil::boolVal($this->model->{$this->attribute})) { $htmlOptions['uncheckValue'] = 1; } } return $this->form->checkBox($this->model, $this->attribute, $htmlOptions); }
protected function getEditableHtmlOptions() { $htmlOptions = array(); $htmlOptions['id'] = $this->getEditableInputId(); $htmlOptions['name'] = $this->getEditableInputName(); if ($this->getDisabledValue()) { $htmlOptions['disabled'] = $this->getDisabledValue(); if (BooleanUtil::boolVal($this->model->{$this->attribute})) { $htmlOptions['uncheckValue'] = 1; } if ($htmlOptions['disabled'] == 'disabled') { $htmlOptions['labelClass'] = 'disabled'; } } return $htmlOptions; }
/** * Save layout changes including: * collapse/show * position change * removed portlets * */ public function actionSaveLayout() { $portlets = Portlet::getByLayoutIdAndUserSortedById($_POST['portletLayoutConfiguration']['uniqueLayoutId'], Yii::app()->user->userModel->id); $portletsStillOnLayout = array(); if (!empty($_POST['portletLayoutConfiguration']['portlets'])) { foreach ($_POST['portletLayoutConfiguration']['portlets'] as $key => $portletPostData) { $idParts = explode("_", $portletPostData['id']); $portlets[$idParts[1]]->column = $portletPostData['column'] + 1; $portlets[$idParts[1]]->position = $portletPostData['position'] + 1; $portlets[$idParts[1]]->collapsed = BooleanUtil::boolVal($portletPostData['collapsed']); $portlets[$idParts[1]]->save(); $portletsStillOnLayout[$idParts[1]] = $idParts[1]; } } foreach ($portlets as $portletId => $portlet) { if (!isset($portletsStillOnLayout[$portletId])) { $portlet->delete(); } } }