@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $url = "http://maps.googleapis.com/maps/api/geocode/json"; |
| 46 | - $url .= '?address='. urlencode($address); |
|
| 46 | + $url .= '?address='.urlencode($address); |
|
| 47 | 47 | $url .= $bounds_string; |
| 48 | 48 | $url .= '&sensor=false'; |
| 49 | 49 | $this->result = json_decode(@file_get_contents($url)); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | private function getPolygon($delta = 0) |
| 131 | 131 | { |
| 132 | - $points = array ( |
|
| 132 | + $points = array( |
|
| 133 | 133 | $this->getTopLeft($delta), |
| 134 | 134 | $this->getTopRight($delta), |
| 135 | 135 | $this->getBottomRight($delta), |
@@ -61,14 +61,14 @@ discard block |
||
| 61 | 61 | $xmlobj = new DOMDocument(); |
| 62 | 62 | @$xmlobj->loadXML($text); |
| 63 | 63 | if ($xmlobj === false) { |
| 64 | - throw new Exception("Invalid KML: ". $text); |
|
| 64 | + throw new Exception("Invalid KML: ".$text); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $this->xmlobj = $xmlobj; |
| 68 | 68 | try { |
| 69 | 69 | $geom = $this->geomFromXML(); |
| 70 | 70 | } catch (InvalidText $e) { |
| 71 | - throw new Exception("Cannot Read Geometry From KML: ". $text); |
|
| 71 | + throw new Exception("Cannot Read Geometry From KML: ".$text); |
|
| 72 | 72 | } catch (Exception $e) { |
| 73 | 73 | throw $e; |
| 74 | 74 | } |
@@ -237,21 +237,21 @@ discard block |
||
| 237 | 237 | $type = $geom->getGeomType(); |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $str = '<'.$this->nss . $type .'>'; |
|
| 240 | + $str = '<'.$this->nss.$type.'>'; |
|
| 241 | 241 | |
| 242 | 242 | if (!$geom->isEmpty()) { |
| 243 | 243 | $str .= '<'.$this->nss.'coordinates>'; |
| 244 | - $i=0; |
|
| 244 | + $i = 0; |
|
| 245 | 245 | foreach ($geom->getComponents() as $comp) { |
| 246 | 246 | if ($i != 0) $str .= ' '; |
| 247 | - $str .= $comp->getX() .','. $comp->getY(); |
|
| 247 | + $str .= $comp->getX().','.$comp->getY(); |
|
| 248 | 248 | $i++; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | $str .= '</'.$this->nss.'coordinates>'; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - $str .= '</'. $this->nss . $type .'>'; |
|
| 254 | + $str .= '</'.$this->nss.$type.'>'; |
|
| 255 | 255 | |
| 256 | 256 | return $str; |
| 257 | 257 | } |
@@ -261,13 +261,13 @@ discard block |
||
| 261 | 261 | $components = $geom->getComponents(); |
| 262 | 262 | $str = ''; |
| 263 | 263 | if (!empty($components)) { |
| 264 | - $str = '<'.$this->nss.'outerBoundaryIs>' . $this->linestringToKML($components[0], 'LinearRing') . '</'.$this->nss.'outerBoundaryIs>'; |
|
| 264 | + $str = '<'.$this->nss.'outerBoundaryIs>'.$this->linestringToKML($components[0], 'LinearRing').'</'.$this->nss.'outerBoundaryIs>'; |
|
| 265 | 265 | foreach (array_slice($components, 1) as $comp) { |
| 266 | - $str .= '<'.$this->nss.'innerBoundaryIs>' . $this->linestringToKML($comp) . '</'.$this->nss.'innerBoundaryIs>'; |
|
| 266 | + $str .= '<'.$this->nss.'innerBoundaryIs>'.$this->linestringToKML($comp).'</'.$this->nss.'innerBoundaryIs>'; |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - return '<'.$this->nss.'Polygon>'. $str .'</'.$this->nss.'Polygon>'; |
|
| 270 | + return '<'.$this->nss.'Polygon>'.$str.'</'.$this->nss.'Polygon>'; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | public function collectionToKML($geom) |
@@ -279,6 +279,6 @@ discard block |
||
| 279 | 279 | $str .= $sub_adapter->write($comp); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - return $str .'</'.$this->nss.'MultiGeometry>'; |
|
| 282 | + return $str.'</'.$this->nss.'MultiGeometry>'; |
|
| 283 | 283 | } |
| 284 | 284 | } |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | $xmlobj = new DOMDocument(); |
| 54 | 54 | @$xmlobj->loadXML($text); |
| 55 | 55 | if ($xmlobj === false) { |
| 56 | - throw new Exception("Invalid GeoRSS: ". $text); |
|
| 56 | + throw new Exception("Invalid GeoRSS: ".$text); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $this->xmlobj = $xmlobj; |
| 60 | 60 | try { |
| 61 | 61 | $geom = $this->geomFromXML(); |
| 62 | 62 | } catch (InvalidText $e) { |
| 63 | - throw new Exception("Cannot Read Geometry From GeoRSS: ". $text); |
|
| 63 | + throw new Exception("Cannot Read Geometry From GeoRSS: ".$text); |
|
| 64 | 64 | } catch (Exception $e) { |
| 65 | 65 | throw $e; |
| 66 | 66 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | $output = '<'.$this->nss.'line>'; |
| 223 | 223 | foreach ($geom->getComponents() as $k => $point) { |
| 224 | 224 | $output .= $point->getY().' '.$point->getX(); |
| 225 | - if ($k < ($geom->numGeometries() -1)) $output .= ' '; |
|
| 225 | + if ($k < ($geom->numGeometries() - 1)) $output .= ' '; |
|
| 226 | 226 | } |
| 227 | 227 | $output .= '</'.$this->nss.'line>'; |
| 228 | 228 | return $output; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $exterior_ring = $geom->exteriorRing(); |
| 235 | 235 | foreach ($exterior_ring->getComponents() as $k => $point) { |
| 236 | 236 | $output .= $point->getY().' '.$point->getX(); |
| 237 | - if ($k < ($exterior_ring->numGeometries() -1)) $output .= ' '; |
|
| 237 | + if ($k < ($exterior_ring->numGeometries() - 1)) $output .= ' '; |
|
| 238 | 238 | } |
| 239 | 239 | $output .= '</'.$this->nss.'polygon>'; |
| 240 | 240 | return $output; |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | if ($type == 'GeometryCollection') { |
| 53 | 53 | return $this->objToGeometryCollection($obj); |
| 54 | 54 | } |
| 55 | - $method = 'arrayTo' . $type; |
|
| 55 | + $method = 'arrayTo'.$type; |
|
| 56 | 56 | return $this->$method($obj->coordinates); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -17,24 +17,24 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * array of neighbouring hash character maps. |
| 19 | 19 | */ |
| 20 | - private $neighbours = array ( |
|
| 20 | + private $neighbours = array( |
|
| 21 | 21 | // north |
| 22 | - 'top' => array ( |
|
| 22 | + 'top' => array( |
|
| 23 | 23 | 'even' => 'p0r21436x8zb9dcf5h7kjnmqesgutwvy', |
| 24 | 24 | 'odd' => 'bc01fg45238967deuvhjyznpkmstqrwx' |
| 25 | 25 | ), |
| 26 | 26 | // east |
| 27 | - 'right' => array ( |
|
| 27 | + 'right' => array( |
|
| 28 | 28 | 'even' => 'bc01fg45238967deuvhjyznpkmstqrwx', |
| 29 | 29 | 'odd' => 'p0r21436x8zb9dcf5h7kjnmqesgutwvy' |
| 30 | 30 | ), |
| 31 | 31 | // west |
| 32 | - 'left' => array ( |
|
| 32 | + 'left' => array( |
|
| 33 | 33 | 'even' => '238967debc01fg45kmstqrwxuvhjyznp', |
| 34 | 34 | 'odd' => '14365h7k9dcfesgujnmqp0r2twvyx8zb' |
| 35 | 35 | ), |
| 36 | 36 | // south |
| 37 | - 'bottom' => array ( |
|
| 37 | + 'bottom' => array( |
|
| 38 | 38 | 'even' => '14365h7k9dcfesgujnmqp0r2twvyx8zb', |
| 39 | 39 | 'odd' => '238967debc01fg45kmstqrwxuvhjyznp' |
| 40 | 40 | ) |
@@ -43,24 +43,24 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * array of bordering hash character maps. |
| 45 | 45 | */ |
| 46 | - private $borders = array ( |
|
| 46 | + private $borders = array( |
|
| 47 | 47 | // north |
| 48 | - 'top' => array ( |
|
| 48 | + 'top' => array( |
|
| 49 | 49 | 'even' => 'prxz', |
| 50 | 50 | 'odd' => 'bcfguvyz' |
| 51 | 51 | ), |
| 52 | 52 | // east |
| 53 | - 'right' => array ( |
|
| 53 | + 'right' => array( |
|
| 54 | 54 | 'even' => 'bcfguvyz', |
| 55 | 55 | 'odd' => 'prxz' |
| 56 | 56 | ), |
| 57 | 57 | // west |
| 58 | - 'left' => array ( |
|
| 58 | + 'left' => array( |
|
| 59 | 59 | 'even' => '0145hjnp', |
| 60 | 60 | 'odd' => '028b' |
| 61 | 61 | ), |
| 62 | 62 | // south |
| 63 | - 'bottom' => array ( |
|
| 63 | + 'bottom' => array( |
|
| 64 | 64 | 'even' => '028b', |
| 65 | 65 | 'odd' => '0145hjnp' |
| 66 | 66 | ) |
@@ -134,27 +134,27 @@ discard block |
||
| 134 | 134 | private function encodePoint($point, $precision = null) |
| 135 | 135 | { |
| 136 | 136 | if ($precision === null) { |
| 137 | - $lap = strlen($point->y())-strpos($point->y(), "."); |
|
| 138 | - $lop = strlen($point->x())-strpos($point->x(), "."); |
|
| 139 | - $precision = pow(10, -max($lap-1, $lop-1, 0))/2; |
|
| 137 | + $lap = strlen($point->y()) - strpos($point->y(), "."); |
|
| 138 | + $lop = strlen($point->x()) - strpos($point->x(), "."); |
|
| 139 | + $precision = pow(10, -max($lap - 1, $lop - 1, 0)) / 2; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $minlat = -90; |
|
| 143 | - $maxlat = 90; |
|
| 142 | + $minlat = -90; |
|
| 143 | + $maxlat = 90; |
|
| 144 | 144 | $minlon = -180; |
| 145 | - $maxlon = 180; |
|
| 146 | - $latE = 90; |
|
| 147 | - $lonE = 180; |
|
| 145 | + $maxlon = 180; |
|
| 146 | + $latE = 90; |
|
| 147 | + $lonE = 180; |
|
| 148 | 148 | $i = 0; |
| 149 | 149 | $error = 180; |
| 150 | - $hash=''; |
|
| 151 | - while ($error>=$precision) { |
|
| 150 | + $hash = ''; |
|
| 151 | + while ($error >= $precision) { |
|
| 152 | 152 | $chr = 0; |
| 153 | - for ($b=4;$b>=0;--$b) { |
|
| 154 | - if ((1&$b) == (1&$i)) { |
|
| 153 | + for ($b = 4; $b >= 0; --$b) { |
|
| 154 | + if ((1 & $b) == (1 & $i)) { |
|
| 155 | 155 | // even char, even bit OR odd char, odd bit...a lon |
| 156 | - $next = ($minlon+$maxlon)/2; |
|
| 157 | - if ($point->x()>$next) { |
|
| 156 | + $next = ($minlon + $maxlon) / 2; |
|
| 157 | + if ($point->x() > $next) { |
|
| 158 | 158 | $chr |= pow(2, $b); |
| 159 | 159 | $minlon = $next; |
| 160 | 160 | } else { |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | $lonE /= 2; |
| 164 | 164 | } else { |
| 165 | 165 | // odd char, even bit OR even char, odd bit...a lat |
| 166 | - $next = ($minlat+$maxlat)/2; |
|
| 167 | - if ($point->y()>$next) { |
|
| 166 | + $next = ($minlat + $maxlat) / 2; |
|
| 167 | + if ($point->y() > $next) { |
|
| 168 | 168 | $chr |= pow(2, $b); |
| 169 | 169 | $minlat = $next; |
| 170 | 170 | } else { |
@@ -188,28 +188,28 @@ discard block |
||
| 188 | 188 | private function decode($hash) |
| 189 | 189 | { |
| 190 | 190 | $ll = array(); |
| 191 | - $minlat = -90; |
|
| 192 | - $maxlat = 90; |
|
| 191 | + $minlat = -90; |
|
| 192 | + $maxlat = 90; |
|
| 193 | 193 | $minlon = -180; |
| 194 | - $maxlon = 180; |
|
| 195 | - $latE = 90; |
|
| 196 | - $lonE = 180; |
|
| 197 | - for ($i=0,$c=strlen($hash);$i<$c;$i++) { |
|
| 194 | + $maxlon = 180; |
|
| 195 | + $latE = 90; |
|
| 196 | + $lonE = 180; |
|
| 197 | + for ($i = 0, $c = strlen($hash); $i < $c; $i++) { |
|
| 198 | 198 | $v = strpos($this->table, $hash[$i]); |
| 199 | - if (1&$i) { |
|
| 200 | - if (16&$v)$minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 201 | - if (8&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 202 | - if (4&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 203 | - if (2&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 204 | - if (1&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 199 | + if (1 & $i) { |
|
| 200 | + if (16 & $v)$minlat = ($minlat + $maxlat) / 2; else $maxlat = ($minlat + $maxlat) / 2; |
|
| 201 | + if (8 & $v) $minlon = ($minlon + $maxlon) / 2; else $maxlon = ($minlon + $maxlon) / 2; |
|
| 202 | + if (4 & $v) $minlat = ($minlat + $maxlat) / 2; else $maxlat = ($minlat + $maxlat) / 2; |
|
| 203 | + if (2 & $v) $minlon = ($minlon + $maxlon) / 2; else $maxlon = ($minlon + $maxlon) / 2; |
|
| 204 | + if (1 & $v) $minlat = ($minlat + $maxlat) / 2; else $maxlat = ($minlat + $maxlat) / 2; |
|
| 205 | 205 | $latE /= 8; |
| 206 | 206 | $lonE /= 4; |
| 207 | 207 | } else { |
| 208 | - if (16&$v)$minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 209 | - if (8&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 210 | - if (4&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 211 | - if (2&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
|
| 212 | - if (1&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
|
| 208 | + if (16 & $v)$minlon = ($minlon + $maxlon) / 2; else $maxlon = ($minlon + $maxlon) / 2; |
|
| 209 | + if (8 & $v) $minlat = ($minlat + $maxlat) / 2; else $maxlat = ($minlat + $maxlat) / 2; |
|
| 210 | + if (4 & $v) $minlon = ($minlon + $maxlon) / 2; else $maxlon = ($minlon + $maxlon) / 2; |
|
| 211 | + if (2 & $v) $minlat = ($minlat + $maxlat) / 2; else $maxlat = ($minlat + $maxlat) / 2; |
|
| 212 | + if (1 & $v) $minlon = ($minlon + $maxlon) / 2; else $maxlon = ($minlon + $maxlon) / 2; |
|
| 213 | 213 | $latE /= 4; |
| 214 | 214 | $lonE /= 8; |
| 215 | 215 | } |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | $ll['minlon'] = $minlon; |
| 219 | 219 | $ll['maxlat'] = $maxlat; |
| 220 | 220 | $ll['maxlon'] = $maxlon; |
| 221 | - $ll['medlat'] = round(($minlat+$maxlat)/2, max(1, -round(log10($latE)))-1); |
|
| 222 | - $ll['medlon'] = round(($minlon+$maxlon)/2, max(1, -round(log10($lonE)))-1); |
|
| 221 | + $ll['medlat'] = round(($minlat + $maxlat) / 2, max(1, -round(log10($latE))) - 1); |
|
| 222 | + $ll['medlon'] = round(($minlon + $maxlon) / 2, max(1, -round(log10($lonE))) - 1); |
|
| 223 | 223 | return $ll; |
| 224 | 224 | } |
| 225 | 225 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | public function adjacent($hash, $direction) |
| 244 | 244 | { |
| 245 | 245 | $last = substr($hash, -1); |
| 246 | - $type = (strlen($hash) % 2)? 'odd': 'even'; |
|
| 246 | + $type = (strlen($hash) % 2) ? 'odd' : 'even'; |
|
| 247 | 247 | $base = substr($hash, 0, strlen($hash) - 1); |
| 248 | 248 | if (strpos(($this->borders[$direction][$type]), $last) !== false) { |
| 249 | 249 | $base = $this->adjacent($base, $direction); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | static function getAdapterMap() |
| 95 | 95 | { |
| 96 | - return array ( |
|
| 96 | + return array( |
|
| 97 | 97 | 'wkt' => 'WKT', |
| 98 | 98 | 'ewkt' => 'EWKT', |
| 99 | 99 | 'wkb' => 'WKB', |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | // If the geometry cannot even theoretically be reduced more, then pass it back |
| 162 | 162 | if (gettype($geometry) == 'object') { |
| 163 | - $passbacks = array('Point','LineString','Polygon'); |
|
| 163 | + $passbacks = array('Point', 'LineString', 'Polygon'); |
|
| 164 | 164 | if (in_array($geometry->geometryType(), $passbacks)) { |
| 165 | 165 | return $geometry; |
| 166 | 166 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | // If it is a mutlti-geometry, check to see if it just has one member |
| 170 | 170 | // If it does, then pass the member, if not, then just pass back the geometry |
| 171 | 171 | if (gettype($geometry) == 'object') { |
| 172 | - $simple_collections = array('MultiPoint','MultiLineString','MultiPolygon'); |
|
| 172 | + $simple_collections = array('MultiPoint', 'MultiLineString', 'MultiPolygon'); |
|
| 173 | 173 | if (in_array(get_class($geometry), $passbacks)) { |
| 174 | 174 | $components = $geometry->getComponents(); |
| 175 | 175 | if (count($components) == 1) { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $geometries = array(); |
| 189 | 189 | $geom_types = array(); |
| 190 | 190 | |
| 191 | - $collections = array('MultiPoint','MultiLineString','MultiPolygon','GeometryCollection'); |
|
| 191 | + $collections = array('MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection'); |
|
| 192 | 192 | |
| 193 | 193 | foreach ($geometry as $item) { |
| 194 | 194 | if ($item) { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | // Parameters |
| 35 | 35 | $action = GETPOST('action', 'aZ09'); |
| 36 | 36 | $backtopage = GETPOST('backtopage', 'alpha'); |
| 37 | -$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
| 37 | +$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
| 38 | 38 | |
| 39 | 39 | if (empty($action)) { |
| 40 | 40 | $action = 'edit'; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | //'gemini' => 'Gemini' |
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | -$item = $formSetup->newItem('AI_API_SERVICE'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
| 73 | +$item = $formSetup->newItem('AI_API_SERVICE'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
| 74 | 74 | $item->setAsSelect($arrayofia); |
| 75 | 75 | |
| 76 | 76 | foreach ($arrayofia as $ia => $ialabel) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $item->defaultFieldValue = ''; |
| 80 | 80 | $item->cssClass = 'minwidth500';*/ |
| 81 | 81 | |
| 82 | - $item = $formSetup->newItem('AI_API_'.strtoupper($ia).'_KEY'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
| 82 | + $item = $formSetup->newItem('AI_API_'.strtoupper($ia).'_KEY'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
| 83 | 83 | $item->nameText = $langs->trans("AI_API_KEY").' ('.$ialabel.')'; |
| 84 | 84 | $item->defaultFieldValue = ''; |
| 85 | 85 | $item->cssClass = 'minwidth500'; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $ai = new Ai($db); |
| 63 | 63 | |
| 64 | 64 | // Get parameters |
| 65 | -$function = empty($jsonData['function']) ? 'textgeneration' : $jsonData['function']; // Default value. Can also be 'textgenerationemail', 'textgenerationwebpage', ... |
|
| 65 | +$function = empty($jsonData['function']) ? 'textgeneration' : $jsonData['function']; // Default value. Can also be 'textgenerationemail', 'textgenerationwebpage', ... |
|
| 66 | 66 | $instructions = dol_string_nohtmltag($jsonData['instructions'], 1, 'UTF-8'); |
| 67 | 67 | $format = empty($jsonData['format']) ? '' : $jsonData['format']; |
| 68 | 68 | |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | if (!empty($generatedContent['code']) && $generatedContent['code'] == 429) { |
| 74 | 74 | print "Quota or allowed period exceeded. Retry Later !"; |
| 75 | 75 | } elseif ($generatedContent['code'] >= 400) { |
| 76 | - print "Error : " . $generatedContent['message']; |
|
| 76 | + print "Error : ".$generatedContent['message']; |
|
| 77 | 77 | print '<br><a href="'.DOL_MAIN_URL_ROOT.'/ai/admin/setup.php">'.$langs->trans('ErrorGoToModuleSetup').'</a>'; |
| 78 | 78 | } else { |
| 79 | - print "Error returned by API call: " . $generatedContent['message']; |
|
| 79 | + print "Error returned by API call: ".$generatedContent['message']; |
|
| 80 | 80 | } |
| 81 | 81 | } else { |
| 82 | 82 | print $generatedContent; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | if ($this->apiService == 'grok') { |
| 117 | 117 | $this->apiEndpoint = 'https://api.groq.com/openai/v1/chat/completions'; |
| 118 | 118 | if ($model == 'auto') { |
| 119 | - $model = getDolGlobalString('AI_API_GROK_MODEL_TEXT', 'mixtral-8x7b-32768'); // 'llama3-8b-8192', 'gemma-7b-it' |
|
| 119 | + $model = getDolGlobalString('AI_API_GROK_MODEL_TEXT', 'mixtral-8x7b-32768'); // 'llama3-8b-8192', 'gemma-7b-it' |
|
| 120 | 120 | } |
| 121 | 121 | } elseif ($this->apiService == 'chatgpt') { |
| 122 | 122 | $this->apiEndpoint = 'https://api.openai.com/v1/chat/completions'; |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | ]); |
| 161 | 161 | |
| 162 | 162 | $headers = ([ |
| 163 | - 'Authorization: Bearer ' . $this->apiKey, |
|
| 163 | + 'Authorization: Bearer '.$this->apiKey, |
|
| 164 | 164 | 'Content-Type: application/json' |
| 165 | 165 | ]); |
| 166 | 166 | $response = getURLContent($this->apiEndpoint, 'POST', $payload, 1, $headers); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | throw new Exception('API request failed. No http received'); |
| 170 | 170 | } |
| 171 | 171 | if (!empty($response['http_code']) && $response['http_code'] != 200) { |
| 172 | - throw new Exception('API request failed with status code ' . $response['http_code']); |
|
| 172 | + throw new Exception('API request failed with status code '.$response['http_code']); |
|
| 173 | 173 | } |
| 174 | 174 | // Decode JSON response |
| 175 | 175 | $decodedResponse = json_decode($response['content'], true); |