diff --git a/application/admin/command/Addon.php b/application/admin/command/Addon.php index e331367d..aa55f3be 100644 --- a/application/admin/command/Addon.php +++ b/application/admin/command/Addon.php @@ -15,7 +15,6 @@ use think\exception\PDOException; class Addon extends Command { - protected function configure() { $this @@ -80,7 +79,6 @@ class Addon extends Command $createTableSql = $result[0]['Create Table']; } } catch (PDOException $e) { - } $data = [ @@ -235,7 +233,8 @@ class Addon extends Command $zip->open($addonFile, \ZipArchive::CREATE | \ZipArchive::OVERWRITE); $files = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($addonDir), \RecursiveIteratorIterator::LEAVES_ONLY + new \RecursiveDirectoryIterator($addonDir), + \RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $name => $file) { @@ -251,7 +250,7 @@ class Addon extends Command $output->info("Package Successed!"); break; - default : + default: break; } } @@ -315,5 +314,4 @@ class Addon extends Command { return __DIR__ . '/Addon/stubs/' . $name . '.stub'; } - } diff --git a/application/admin/command/Api.php b/application/admin/command/Api.php index 2eb2b24d..45effb45 100644 --- a/application/admin/command/Api.php +++ b/application/admin/command/Api.php @@ -12,7 +12,6 @@ use think\Exception; class Api extends Command { - protected function configure() { $site = Config::get('site'); @@ -84,7 +83,8 @@ class Api extends Command $controllerDir = $moduleDir . Config::get('url_controller_layer') . DS; $files = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($controllerDir), \RecursiveIteratorIterator::LEAVES_ONLY + new \RecursiveDirectoryIterator($controllerDir), + \RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $name => $file) { @@ -150,7 +150,7 @@ class Api extends Command //Append the token's value to the name of the namespace $namespace .= $token[1]; - } else if ($token === ';') { + } elseif ($token === ';') { //If the token is the semicolon, then we're done with the namespace declaration $getting_namespace = false; @@ -175,5 +175,4 @@ class Api extends Command //Build the fully-qualified class name and return it return $namespace ? $namespace . '\\' . $class : $class; } - } diff --git a/application/admin/command/Api/library/Builder.php b/application/admin/command/Api/library/Builder.php index d51eeadb..1ca2921f 100755 --- a/application/admin/command/Api/library/Builder.php +++ b/application/admin/command/Api/library/Builder.php @@ -36,16 +36,27 @@ class Builder protected function extractAnnotations() { - $st_output = []; foreach ($this->classes as $class) { $classAnnotation = Extractor::getClassAnnotations($class); // 如果忽略 if (isset($classAnnotation['ApiInternal'])) { continue; } - $st_output[] = Extractor::getAllClassAnnotations($class); + Extractor::getClassMethodAnnotations($class); } - return end($st_output); + $allClassAnnotation = Extractor::getAllClassAnnotations(); + $allClassMethodAnnotation = Extractor::getAllClassMethodAnnotations(); + +// foreach ($allClassMethodAnnotation as $className => &$methods) { +// foreach ($methods as &$method) { +// //权重判断 +// if ($method && !isset($method['ApiWeigh']) && isset($allClassAnnotation[$className]['ApiWeigh'])) { +// $method['ApiWeigh'] = $allClassAnnotation[$className]['ApiWeigh']; +// } +// } +// } +// unset($methods); + return [$allClassAnnotation, $allClassMethodAnnotation]; } protected function generateHeadersTemplate($docs) @@ -148,12 +159,19 @@ class Builder public function parse() { - $annotations = $this->extractAnnotations(); + list($allClassAnnotations, $allClassMethodAnnotations) = $this->extractAnnotations(); + $sectorArr = []; + foreach ($allClassAnnotations as $index => $allClassAnnotation) { + $sector = isset($allClassAnnotation['ApiSector']) ? $allClassAnnotation['ApiSector'][0] : $allClassAnnotation['ApiTitle'][0]; + $sectorArr[$sector] = isset($allClassAnnotation['ApiWeigh']) ? $allClassAnnotation['ApiWeigh'][0] : 0; + } + arsort($sectorArr); $counter = 0; $section = null; + $weigh = 0; $docslist = []; - foreach ($annotations as $class => $methods) { + foreach ($allClassMethodAnnotations as $class => $methods) { foreach ($methods as $name => $docs) { if (isset($docs['ApiSector'][0])) { $section = is_array($docs['ApiSector'][0]) ? $docs['ApiSector'][0]['data'] : $docs['ApiSector'][0]; @@ -163,25 +181,36 @@ class Builder if (0 === count($docs)) { continue; } - - $docslist[$section][] = [ + $docslist[$section][$name] = [ 'id' => $counter, 'method' => is_array($docs['ApiMethod'][0]) ? $docs['ApiMethod'][0]['data'] : $docs['ApiMethod'][0], 'method_label' => $this->generateBadgeForMethod($docs), 'section' => $section, 'route' => is_array($docs['ApiRoute'][0]) ? $docs['ApiRoute'][0]['data'] : $docs['ApiRoute'][0], - 'title' => is_array($docs['ApiTitle'][0]) ? $docs['ApiTitle'][0]['data'] : $docs['ApiTitle'][0], + 'title' => is_array($docs['ApiTitle'][0]) ? $docs['ApiTitle'][0]['data'] : $docs['ApiTitle'][0], 'summary' => is_array($docs['ApiSummary'][0]) ? $docs['ApiSummary'][0]['data'] : $docs['ApiSummary'][0], 'body' => isset($docs['ApiBody'][0]) ? is_array($docs['ApiBody'][0]) ? $docs['ApiBody'][0]['data'] : $docs['ApiBody'][0] : '', 'headerslist' => $this->generateHeadersTemplate($docs), 'paramslist' => $this->generateParamsTemplate($docs), 'returnheaderslist' => $this->generateReturnHeadersTemplate($docs), 'returnparamslist' => $this->generateReturnParamsTemplate($docs), + 'weigh' => is_array($docs['ApiWeigh'][0]) ? $docs['ApiWeigh'][0]['data'] : $docs['ApiWeigh'][0], 'return' => isset($docs['ApiReturn']) ? is_array($docs['ApiReturn'][0]) ? $docs['ApiReturn'][0]['data'] : $docs['ApiReturn'][0] : '', ]; $counter++; } } + + //重建排序 + foreach ($docslist as $index => &$methods) { + $methodSectorArr = []; + foreach ($methods as $name => $method) { + $methodSectorArr[$name] = isset($method['weigh']) ? $method['weigh'] : 0; + } + arsort($methodSectorArr); + $methods = array_merge(array_flip(array_keys($methodSectorArr)), $methods); + } + $docslist = array_merge(array_flip(array_keys($sectorArr)), $docslist); return $docslist; } @@ -203,5 +232,4 @@ class Builder return $this->view->display(file_get_contents($template), array_merge($vars, ['docslist' => $docslist])); } - } diff --git a/application/admin/command/Api/library/Extractor.php b/application/admin/command/Api/library/Extractor.php index bbee48fe..de46d1f1 100644 --- a/application/admin/command/Api/library/Extractor.php +++ b/application/admin/command/Api/library/Extractor.php @@ -20,6 +20,10 @@ class Extractor */ private static $annotationCache; + private static $classAnnotationCache; + + private static $classMethodAnnotationCache; + /** * Indicates that annotations should has strict behavior, 'false' by default * @var boolean @@ -63,27 +67,43 @@ class Extractor * Gets all anotations with pattern @SomeAnnotation() from a given class * * @param string $className class name to get annotations - * @return array self::$annotationCache all annotated elements + * @return array self::$classAnnotationCache all annotated elements */ public static function getClassAnnotations($className) { - if (!isset(self::$annotationCache[$className])) { + if (!isset(self::$classAnnotationCache[$className])) { $class = new \ReflectionClass($className); - self::$annotationCache[$className] = self::parseAnnotations($class->getDocComment()); + self::$classAnnotationCache[$className] = self::parseAnnotations($class->getDocComment()); } - return self::$annotationCache[$className]; + return self::$classAnnotationCache[$className]; } - public static function getAllClassAnnotations($className) + /** + * 获取类所有方法的属性配置 + * @param $className + * @return mixed + * @throws \ReflectionException + */ + public static function getClassMethodAnnotations($className) { $class = new \ReflectionClass($className); foreach ($class->getMethods() as $object) { - self::$annotationCache['annotations'][$className][$object->name] = self::getMethodAnnotations($className, $object->name); + self::$classMethodAnnotationCache[$className][$object->name] = self::getMethodAnnotations($className, $object->name); } - return self::$annotationCache['annotations']; + return self::$classMethodAnnotationCache[$className]; + } + + public static function getAllClassAnnotations() + { + return self::$classAnnotationCache; + } + + public static function getAllClassMethodAnnotations() + { + return self::$classMethodAnnotationCache; } /** @@ -181,14 +201,14 @@ class Extractor preg_match_all("/\*[\s]+(.*)(\\r\\n|\\r|\\n)/U", str_replace('/**', '', $docblockMethod), $methodArr); preg_match_all("/\*[\s]+(.*)(\\r\\n|\\r|\\n)/U", str_replace('/**', '', $dockblockClass), $classArr); - $methodTitle = isset($methodArr[1]) && isset($methodArr[1][0]) ? $methodArr[1][0] : ''; - $classTitle = isset($classArr[1]) && isset($classArr[1][0]) ? $classArr[1][0] : ''; - if (!isset($methodAnnotations['ApiMethod'])) { $methodAnnotations['ApiMethod'] = ['get']; } + if (!isset($methodAnnotations['ApiWeigh'])) { + $methodAnnotations['ApiWeigh'] = [0]; + } if (!isset($methodAnnotations['ApiSummary'])) { - $methodAnnotations['ApiSummary'] = [$methodTitle]; + $methodAnnotations['ApiSummary'] = $methodAnnotations['ApiTitle']; } if ($methodAnnotations) { @@ -210,9 +230,6 @@ class Extractor } } } - if (!isset($methodAnnotations['ApiTitle'])) { - $methodAnnotations['ApiTitle'] = [$methodTitle]; - } if (!isset($methodAnnotations['ApiRoute'])) { $urlArr = []; $className = $class->getName(); @@ -231,7 +248,7 @@ class Extractor $methodAnnotations['ApiRoute'] = [implode('/', $urlArr)]; } if (!isset($methodAnnotations['ApiSector'])) { - $methodAnnotations['ApiSector'] = isset($classAnnotations['ApiSector']) ? $classAnnotations['ApiSector'] : [$classTitle]; + $methodAnnotations['ApiSector'] = isset($classAnnotations['ApiSector']) ? $classAnnotations['ApiSector'] : $classAnnotations['ApiTitle']; } if (!isset($methodAnnotations['ApiParams'])) { $params = self::parseCustomAnnotations($docblockMethod, 'param'); @@ -292,7 +309,7 @@ class Extractor $argsParts = trim($matches['args'][$i]); if ($name == 'ApiReturn') { $value = $argsParts; - } else if ($matches['args'][$i] != '') { + } elseif ($matches['args'][$i] != '') { $argsParts = preg_replace("/\{(\w+)\}/", '#$1#', $argsParts); $value = self::parseArgs($argsParts); if (is_string($value)) { @@ -307,6 +324,11 @@ class Extractor if (stripos($docblock, '@ApiInternal') !== false) { $annotations['ApiInternal'] = [true]; } + if (!isset($annotations['ApiTitle'])) { + preg_match_all("/\*[\s]+(.*)(\\r\\n|\\r|\\n)/U", str_replace('/**', '', $docblock), $matchArr); + $title = isset($matchArr[1]) && isset($matchArr[1][0]) ? $matchArr[1][0] : ''; + $annotations['ApiTitle'] = [$title]; + } return $annotations; } @@ -354,7 +376,9 @@ class Extractor // close delimiter if ($c !== $nextDelimiter) { throw new Exception(sprintf( - "Parse Error: enclosing error -> expected: [%s], given: [%s]", $nextDelimiter, $c + "Parse Error: enclosing error -> expected: [%s], given: [%s]", + $nextDelimiter, + $c )); } @@ -362,7 +386,8 @@ class Extractor if ($i < $len) { if (',' !== substr($content, $i, 1) && '\\' !== $prev_c) { throw new Exception(sprintf( - "Parse Error: missing comma separator near: ...%s<--", substr($content, ($i - 10), $i) + "Parse Error: missing comma separator near: ...%s<--", + substr($content, ($i - 10), $i) )); } } @@ -387,7 +412,9 @@ class Extractor // it means that the string was not enclosed, so it is parsing error. if ($composing === true && !empty($prevDelimiter) && !empty($nextDelimiter)) { throw new Exception(sprintf( - "Parse Error: enclosing error -> expected: [%s], given: [%s]", $nextDelimiter, $c + "Parse Error: enclosing error -> expected: [%s], given: [%s]", + $nextDelimiter, + $c )); } @@ -416,7 +443,8 @@ class Extractor // if the string is composing yet means that the structure of var. never was enclosed with '}' if ($subComposing) { throw new Exception(sprintf( - "Parse Error: Composite variable is not enclosed correctly. near: ...%s'", $subc + "Parse Error: Composite variable is not enclosed correctly. near: ...%s'", + $subc )); } @@ -479,5 +507,4 @@ class Extractor return $val; } - } diff --git a/application/admin/command/Api/template/index.html b/application/admin/command/Api/template/index.html index b439c23b..b86effea 100755 --- a/application/admin/command/Api/template/index.html +++ b/application/admin/command/Api/template/index.html @@ -92,6 +92,9 @@ padding-left:0px; } } + .label-primary { + background-color: #248aff; + } @@ -547,6 +550,9 @@ contentType: false, processData: false, headers: headers, + xhrFields: { + withCredentials: true + }, success: function (data, textStatus, xhr) { if (typeof data === 'object') { var str = JSON.stringify(data, null, 2); diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index fdf0997b..8ce00df9 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -15,7 +15,6 @@ use think\Loader; class Crud extends Command { - protected $stubList = []; /** @@ -93,7 +92,7 @@ class Crud extends Command /** * 保留字段 */ - protected $reservedField = ['admin_id', 'createtime', 'updatetime']; + protected $reservedField = ['admin_id']; /** * 排除字段 @@ -111,6 +110,24 @@ class Crud extends Command */ protected $headingFilterField = 'status'; + /** + * 添加时间字段 + * @var string + */ + protected $createTimeField = 'createtime'; + + /** + * 更新时间字段 + * @var string + */ + protected $updateTimeField = 'updatetime'; + + /** + * 软删除时间字段 + * @var string + */ + protected $deleteTimeField = 'deletetime'; + /** * 编辑器的Class */ @@ -118,7 +135,7 @@ class Crud extends Command /** * langList的key最长字节数 - */ + */ protected $fieldMaxLen = 0; protected function configure() @@ -215,32 +232,47 @@ class Crud extends Command $headingfilterfield = $input->getOption('headingfilterfield'); //编辑器Class $editorclass = $input->getOption('editorclass'); - if ($setcheckboxsuffix) + if ($setcheckboxsuffix) { $this->setCheckboxSuffix = $setcheckboxsuffix; - if ($enumradiosuffix) + } + if ($enumradiosuffix) { $this->enumRadioSuffix = $enumradiosuffix; - if ($imagefield) + } + if ($imagefield) { $this->imageField = $imagefield; - if ($filefield) + } + if ($filefield) { $this->fileField = $filefield; - if ($intdatesuffix) + } + if ($intdatesuffix) { $this->intDateSuffix = $intdatesuffix; - if ($switchsuffix) + } + if ($switchsuffix) { $this->switchSuffix = $switchsuffix; - if ($citysuffix) + } + if ($citysuffix) { $this->citySuffix = $citysuffix; - if ($selectpagesuffix) + } + if ($selectpagesuffix) { $this->selectpageSuffix = $selectpagesuffix; - if ($selectpagessuffix) + } + if ($selectpagessuffix) { $this->selectpagesSuffix = $selectpagessuffix; - if ($ignoreFields) + } + if ($ignoreFields) { $this->ignoreFields = $ignoreFields; - if ($editorclass) + } + if ($editorclass) { $this->editorClass = $editorclass; - if ($sortfield) + } + if ($sortfield) { $this->sortField = $sortfield; - if ($headingfilterfield) + } + if ($headingfilterfield) { $this->headingFilterField = $headingfilterfield; + } + + $this->reservedField = array_merge($this->reservedField, [$this->createTimeField, $this->updateTimeField, $this->deleteTimeField]); $dbname = Config::get('database.database'); $prefix = Config::get('database.prefix'); @@ -254,11 +286,11 @@ class Crud extends Command $modelName = $table = stripos($table, $prefix) === 0 ? substr($table, strlen($prefix)) : $table; $modelTableType = 'table'; $modelTableTypeName = $modelTableName = $modelName; - $modelTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$modelTableName}'", [], TRUE); + $modelTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$modelTableName}'", [], true); if (!$modelTableInfo) { $modelTableType = 'name'; $modelTableName = $prefix . $modelName; - $modelTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$modelTableName}'", [], TRUE); + $modelTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$modelTableName}'", [], true); if (!$modelTableInfo) { throw new Exception("table not found"); } @@ -275,11 +307,11 @@ class Crud extends Command $relationName = stripos($relationTable, $prefix) === 0 ? substr($relationTable, strlen($prefix)) : $relationTable; $relationTableType = 'table'; $relationTableTypeName = $relationTableName = $relationName; - $relationTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$relationTableName}'", [], TRUE); + $relationTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$relationTableName}'", [], true); if (!$relationTableInfo) { $relationTableType = 'name'; $relationTableName = $prefix . $relationName; - $relationTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$relationTableName}'", [], TRUE); + $relationTableInfo = Db::query("SHOW TABLE STATUS LIKE '{$relationTableName}'", [], true); if (!$relationTableInfo) { throw new Exception("relation table not found"); } @@ -338,6 +370,7 @@ class Crud extends Command $addFile = $viewDir . 'add.html'; $editFile = $viewDir . 'edit.html'; $indexFile = $viewDir . 'index.html'; + $recyclebinFile = $viewDir . 'recyclebin.html'; $langFile = $adminPath . 'lang' . DS . Lang::detect() . DS . $controllerBaseName . '.php'; //是否为删除模式 @@ -355,12 +388,13 @@ class Crud extends Command } } foreach ($readyFiles as $k => $v) { - if (file_exists($v)) + if (file_exists($v)) { unlink($v); + } //删除空文件夹 if ($v == $modelFile) { $this->removeEmptyBaseDir($v, $modelArr); - } else if ($v == $validateFile) { + } elseif ($v == $validateFile) { $this->removeEmptyBaseDir($v, $validateArr); } else { $this->removeEmptyBaseDir($v, $controllerArr); @@ -434,7 +468,7 @@ class Crud extends Command $langList = []; $field = 'id'; $order = 'id'; - $priDefined = FALSE; + $priDefined = false; $priKey = ''; $relationPrimaryKey = ''; foreach ($columnList as $k => $v) { @@ -484,6 +518,7 @@ class Crud extends Command $appendAttrList = []; $controllerAssignList = []; $headingHtml = '{:build_heading()}'; + $recyclebinHtml = ''; //循环所有字段,开始构造视图的HTML和JS信息 foreach ($columnList as $k => $v) { @@ -506,7 +541,7 @@ class Crud extends Command $langList[] = $this->getLangItem($field, $v['COLUMN_COMMENT']); } $inputType = ''; - //createtime和updatetime是保留字段不能修改和添加 + //保留字段不能修改和添加 if ($v['COLUMN_KEY'] != 'PRI' && !in_array($field, $this->reservedField) && !in_array($field, $this->ignoreFields)) { $inputType = $this->getFieldType($v); @@ -534,7 +569,7 @@ class Crud extends Command $this->getEnum($getEnumArr, $controllerAssignList, $field, $itemArr, $v['DATA_TYPE'] == 'set' ? 'multiple' : 'select'); - $itemArr = $this->getLangArray($itemArr, FALSE); + $itemArr = $this->getLangArray($itemArr, false); //添加一个获取器 $this->getAttr($getAttrArr, $field, $v['DATA_TYPE'] == 'set' ? 'multiple' : 'select'); if ($v['DATA_TYPE'] == 'set') { @@ -543,28 +578,29 @@ class Crud extends Command $this->appendAttr($appendAttrList, $field); $formAddElement = $this->getReplacedStub('html/select', ['field' => $field, 'fieldName' => $fieldName, 'fieldList' => $this->getFieldListName($field), 'attrStr' => Form::attributes($attrArr), 'selectedValue' => $defaultValue]); $formEditElement = $this->getReplacedStub('html/select', ['field' => $field, 'fieldName' => $fieldName, 'fieldList' => $this->getFieldListName($field), 'attrStr' => Form::attributes($attrArr), 'selectedValue' => "\$row.{$field}"]); - } else if ($inputType == 'datetime') { + } elseif ($inputType == 'datetime') { $cssClassArr[] = 'datetimepicker'; $attrArr['class'] = implode(' ', $cssClassArr); $format = "YYYY-MM-DD HH:mm:ss"; $phpFormat = "Y-m-d H:i:s"; $fieldFunc = ''; switch ($v['DATA_TYPE']) { - case 'year'; + case 'year': $format = "YYYY"; $phpFormat = 'Y'; break; - case 'date'; + case 'date': $format = "YYYY-MM-DD"; $phpFormat = 'Y-m-d'; break; - case 'time'; + case 'time': $format = "HH:mm:ss"; $phpFormat = 'H:i:s'; break; - case 'timestamp'; + case 'timestamp': $fieldFunc = 'datetime'; - case 'datetime'; + // no break + case 'datetime': $format = "YYYY-MM-DD HH:mm:ss"; $phpFormat = 'Y-m-d H:i:s'; break; @@ -581,13 +617,13 @@ class Crud extends Command $fieldFunc = $fieldFunc ? "|{$fieldFunc}" : ""; $formAddElement = Form::text($fieldName, $defaultDateTime, $attrArr); $formEditElement = Form::text($fieldName, "{\$row.{$field}{$fieldFunc}}", $attrArr); - } else if ($inputType == 'checkbox' || $inputType == 'radio') { + } elseif ($inputType == 'checkbox' || $inputType == 'radio') { unset($attrArr['data-rule']); $fieldName = $inputType == 'checkbox' ? $fieldName .= "[]" : $fieldName; $attrArr['name'] = "row[{$fieldName}]"; $this->getEnum($getEnumArr, $controllerAssignList, $field, $itemArr, $inputType); - $itemArr = $this->getLangArray($itemArr, FALSE); + $itemArr = $this->getLangArray($itemArr, false); //添加一个获取器 $this->getAttr($getAttrArr, $field, $inputType); if ($inputType == 'checkbox') { @@ -598,13 +634,13 @@ class Crud extends Command $formAddElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldList' => $this->getFieldListName($field), 'attrStr' => Form::attributes($attrArr), 'selectedValue' => $defaultValue]); $formEditElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldList' => $this->getFieldListName($field), 'attrStr' => Form::attributes($attrArr), 'selectedValue' => "\$row.{$field}"]); - } else if ($inputType == 'textarea') { + } elseif ($inputType == 'textarea') { $cssClassArr[] = $this->isMatchSuffix($field, $this->editorSuffix) ? $this->editorClass : ''; $attrArr['class'] = implode(' ', $cssClassArr); $attrArr['rows'] = 5; $formAddElement = Form::textarea($fieldName, $defaultValue, $attrArr); $formEditElement = Form::textarea($fieldName, $editValue, $attrArr); - } else if ($inputType == 'switch') { + } elseif ($inputType == 'switch') { unset($attrArr['data-rule']); if ($defaultValue === '1' || $defaultValue === 'Y') { $yes = $defaultValue; @@ -619,7 +655,7 @@ class Crud extends Command $stateNoClass = 'fa-flip-horizontal text-gray'; $formAddElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldYes' => $yes, 'fieldNo' => $no, 'attrStr' => Form::attributes($attrArr), 'fieldValue' => $defaultValue, 'fieldSwitchClass' => $defaultValue == $no ? $stateNoClass : '']); $formEditElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldYes' => $yes, 'fieldNo' => $no, 'attrStr' => Form::attributes($attrArr), 'fieldValue' => "{\$row.{$field}}", 'fieldSwitchClass' => "{eq name=\"\$row.{$field}\" value=\"{$no}\"}fa-flip-horizontal text-gray{/eq}"]); - } else if ($inputType == 'citypicker') { + } elseif ($inputType == 'citypicker') { $attrArr['class'] = implode(' ', $cssClassArr); $attrArr['data-toggle'] = "city-picker"; $formAddElement = sprintf("