From: Coleman Watts Date: Wed, 24 Jun 2020 20:10:56 +0000 (-0400) Subject: Add user-facing titles for sql functions X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9cae8a07dda69c5ad1d8b64a8084c67a188cd8c8;p=civicrm-core.git Add user-facing titles for sql functions --- diff --git a/CRM/Api4/Page/Api4Explorer.php b/CRM/Api4/Page/Api4Explorer.php index 35897d051d..3daba07338 100644 --- a/CRM/Api4/Page/Api4Explorer.php +++ b/CRM/Api4/Page/Api4Explorer.php @@ -70,6 +70,7 @@ class CRM_Api4_Page_Api4Explorer extends CRM_Core_Page { if (is_subclass_of($className, '\Civi\Api4\Query\SqlFunction')) { $fns[] = [ 'name' => $className::getName(), + 'title' => $className::getTitle(), 'params' => $className::getParams(), 'category' => $className::getCategory(), ]; diff --git a/Civi/Api4/Query/SqlFunction.php b/Civi/Api4/Query/SqlFunction.php index dacf04c533..dbc245f7bf 100644 --- a/Civi/Api4/Query/SqlFunction.php +++ b/Civi/Api4/Query/SqlFunction.php @@ -206,4 +206,9 @@ abstract class SqlFunction extends SqlExpression { return static::$category; } + /** + * @return string + */ + abstract public static function getTitle(): string; + } diff --git a/Civi/Api4/Query/SqlFunctionABS.php b/Civi/Api4/Query/SqlFunctionABS.php index f626e41f27..96d682cd57 100644 --- a/Civi/Api4/Query/SqlFunctionABS.php +++ b/Civi/Api4/Query/SqlFunctionABS.php @@ -26,4 +26,11 @@ class SqlFunctionABS extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Absolute'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionAVG.php b/Civi/Api4/Query/SqlFunctionAVG.php index 9d9fcdd539..577f05afc7 100644 --- a/Civi/Api4/Query/SqlFunctionAVG.php +++ b/Civi/Api4/Query/SqlFunctionAVG.php @@ -26,4 +26,11 @@ class SqlFunctionAVG extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Average'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionCOALESCE.php b/Civi/Api4/Query/SqlFunctionCOALESCE.php index 938eb02f03..584f4374ec 100644 --- a/Civi/Api4/Query/SqlFunctionCOALESCE.php +++ b/Civi/Api4/Query/SqlFunctionCOALESCE.php @@ -25,4 +25,11 @@ class SqlFunctionCOALESCE extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Coalesce'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionCONCAT.php b/Civi/Api4/Query/SqlFunctionCONCAT.php index ff6b7b993b..5dc63348a1 100644 --- a/Civi/Api4/Query/SqlFunctionCONCAT.php +++ b/Civi/Api4/Query/SqlFunctionCONCAT.php @@ -26,4 +26,11 @@ class SqlFunctionCONCAT extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Combine'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionCOUNT.php b/Civi/Api4/Query/SqlFunctionCOUNT.php index 84bb2105fb..f149108a8d 100644 --- a/Civi/Api4/Query/SqlFunctionCOUNT.php +++ b/Civi/Api4/Query/SqlFunctionCOUNT.php @@ -27,4 +27,11 @@ class SqlFunctionCOUNT extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Count'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionCURDATE.php b/Civi/Api4/Query/SqlFunctionCURDATE.php index db3cb84415..b7687d711e 100644 --- a/Civi/Api4/Query/SqlFunctionCURDATE.php +++ b/Civi/Api4/Query/SqlFunctionCURDATE.php @@ -18,4 +18,11 @@ class SqlFunctionCURDATE extends SqlFunction { protected static $category = self::CATEGORY_DATE; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Now'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionGREATEST.php b/Civi/Api4/Query/SqlFunctionGREATEST.php index 8b2dc40122..755ab28151 100644 --- a/Civi/Api4/Query/SqlFunctionGREATEST.php +++ b/Civi/Api4/Query/SqlFunctionGREATEST.php @@ -25,4 +25,11 @@ class SqlFunctionGREATEST extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Greatest'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionGROUP_CONCAT.php b/Civi/Api4/Query/SqlFunctionGROUP_CONCAT.php index 43d548a679..869bd077bf 100644 --- a/Civi/Api4/Query/SqlFunctionGROUP_CONCAT.php +++ b/Civi/Api4/Query/SqlFunctionGROUP_CONCAT.php @@ -40,4 +40,11 @@ class SqlFunctionGROUP_CONCAT extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('List'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionISNULL.php b/Civi/Api4/Query/SqlFunctionISNULL.php index 30ab3ddae8..538ad32286 100644 --- a/Civi/Api4/Query/SqlFunctionISNULL.php +++ b/Civi/Api4/Query/SqlFunctionISNULL.php @@ -25,4 +25,11 @@ class SqlFunctionISNULL extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Is null'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionLEAST.php b/Civi/Api4/Query/SqlFunctionLEAST.php index 4c22415c12..ea246a820d 100644 --- a/Civi/Api4/Query/SqlFunctionLEAST.php +++ b/Civi/Api4/Query/SqlFunctionLEAST.php @@ -25,4 +25,11 @@ class SqlFunctionLEAST extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Least'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionLOWER.php b/Civi/Api4/Query/SqlFunctionLOWER.php index eefd0f943b..2a6b9686f5 100644 --- a/Civi/Api4/Query/SqlFunctionLOWER.php +++ b/Civi/Api4/Query/SqlFunctionLOWER.php @@ -26,4 +26,11 @@ class SqlFunctionLOWER extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Lowercase'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionMAX.php b/Civi/Api4/Query/SqlFunctionMAX.php index c40d5876aa..2116ec19f3 100644 --- a/Civi/Api4/Query/SqlFunctionMAX.php +++ b/Civi/Api4/Query/SqlFunctionMAX.php @@ -26,4 +26,11 @@ class SqlFunctionMAX extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Max'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionMIN.php b/Civi/Api4/Query/SqlFunctionMIN.php index 29c313452f..e8d4c56ebb 100644 --- a/Civi/Api4/Query/SqlFunctionMIN.php +++ b/Civi/Api4/Query/SqlFunctionMIN.php @@ -26,4 +26,11 @@ class SqlFunctionMIN extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Min'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionNULLIF.php b/Civi/Api4/Query/SqlFunctionNULLIF.php index 53e74999ca..846981c736 100644 --- a/Civi/Api4/Query/SqlFunctionNULLIF.php +++ b/Civi/Api4/Query/SqlFunctionNULLIF.php @@ -29,4 +29,11 @@ class SqlFunctionNULLIF extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Null if'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionREPLACE.php b/Civi/Api4/Query/SqlFunctionREPLACE.php index 36d5bcdfbc..d1cdef78e5 100644 --- a/Civi/Api4/Query/SqlFunctionREPLACE.php +++ b/Civi/Api4/Query/SqlFunctionREPLACE.php @@ -36,4 +36,11 @@ class SqlFunctionREPLACE extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Replace'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionROUND.php b/Civi/Api4/Query/SqlFunctionROUND.php index 29eb06c77d..4d5b2f084d 100644 --- a/Civi/Api4/Query/SqlFunctionROUND.php +++ b/Civi/Api4/Query/SqlFunctionROUND.php @@ -31,4 +31,11 @@ class SqlFunctionROUND extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Round'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionSUM.php b/Civi/Api4/Query/SqlFunctionSUM.php index 44520c3f32..b6b74ae786 100644 --- a/Civi/Api4/Query/SqlFunctionSUM.php +++ b/Civi/Api4/Query/SqlFunctionSUM.php @@ -26,4 +26,11 @@ class SqlFunctionSUM extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Sum'); + } + } diff --git a/Civi/Api4/Query/SqlFunctionUPPER.php b/Civi/Api4/Query/SqlFunctionUPPER.php index c23430365c..b9a714e2d5 100644 --- a/Civi/Api4/Query/SqlFunctionUPPER.php +++ b/Civi/Api4/Query/SqlFunctionUPPER.php @@ -26,4 +26,11 @@ class SqlFunctionUPPER extends SqlFunction { ], ]; + /** + * @return string + */ + public static function getTitle(): string { + return ts('Uppercase'); + } + }