@@ -21,141 +21,141 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class SessionAlert |
| 23 | 23 | { |
| 24 | - private $message; |
|
| 25 | - private $title; |
|
| 26 | - private $type; |
|
| 27 | - private $closable; |
|
| 28 | - private $block; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @param string $message |
|
| 32 | - * @param string $title |
|
| 33 | - * @param string $type |
|
| 34 | - * @param bool $closable |
|
| 35 | - * @param bool $block |
|
| 36 | - */ |
|
| 37 | - public function __construct($message, $title, $type = "alert-info", $closable = true, $block = true) |
|
| 38 | - { |
|
| 39 | - $this->message = $message; |
|
| 40 | - $this->title = $title; |
|
| 41 | - $this->type = $type; |
|
| 42 | - $this->closable = $closable; |
|
| 43 | - $this->block = $block; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Shows a quick one-liner message |
|
| 48 | - * |
|
| 49 | - * @param string $message |
|
| 50 | - * @param string $type |
|
| 51 | - */ |
|
| 52 | - public static function quick($message, $type = "alert-info") |
|
| 53 | - { |
|
| 54 | - self::append(new SessionAlert($message, "", $type, true, false)); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @param SessionAlert $alert |
|
| 59 | - */ |
|
| 60 | - public static function append(SessionAlert $alert) |
|
| 61 | - { |
|
| 62 | - $data = WebRequest::getSessionAlertData(); |
|
| 63 | - $data[] = serialize($alert); |
|
| 64 | - WebRequest::setSessionAlertData($data); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Shows a quick one-liner success message |
|
| 69 | - * |
|
| 70 | - * @param string $message |
|
| 71 | - */ |
|
| 72 | - public static function success($message) |
|
| 73 | - { |
|
| 74 | - self::append(new SessionAlert($message, "", "alert-success", true, true)); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Shows a quick one-liner warning message |
|
| 79 | - * |
|
| 80 | - * @param string $message |
|
| 81 | - * @param string $title |
|
| 82 | - */ |
|
| 83 | - public static function warning($message, $title = "Warning!") |
|
| 84 | - { |
|
| 85 | - self::append(new SessionAlert($message, $title, "alert-warning", true, true)); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Shows a quick one-liner error message |
|
| 90 | - * |
|
| 91 | - * @param string $message |
|
| 92 | - * @param string $title |
|
| 93 | - */ |
|
| 94 | - public static function error($message, $title = "Error!") |
|
| 95 | - { |
|
| 96 | - self::append(new SessionAlert($message, $title, "alert-danger", true, true)); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Retrieves the alerts which have been saved to the session |
|
| 101 | - * @return array |
|
| 102 | - */ |
|
| 103 | - public static function getAlerts() |
|
| 104 | - { |
|
| 105 | - $alertData = array(); |
|
| 106 | - |
|
| 107 | - foreach (WebRequest::getSessionAlertData() as $a) { |
|
| 108 | - $alertData[] = unserialize($a); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - return $alertData; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Clears the alerts from the session |
|
| 116 | - */ |
|
| 117 | - public static function clearAlerts() |
|
| 118 | - { |
|
| 119 | - WebRequest::clearSessionAlertData(); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @return boolean |
|
| 124 | - */ |
|
| 125 | - public function isBlock() |
|
| 126 | - { |
|
| 127 | - return $this->block; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * @return boolean |
|
| 132 | - */ |
|
| 133 | - public function isClosable() |
|
| 134 | - { |
|
| 135 | - return $this->closable; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * @return string |
|
| 140 | - */ |
|
| 141 | - public function getType() |
|
| 142 | - { |
|
| 143 | - return $this->type; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @return string |
|
| 148 | - */ |
|
| 149 | - public function getTitle() |
|
| 150 | - { |
|
| 151 | - return $this->title; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @return string |
|
| 156 | - */ |
|
| 157 | - public function getMessage() |
|
| 158 | - { |
|
| 159 | - return $this->message; |
|
| 160 | - } |
|
| 24 | + private $message; |
|
| 25 | + private $title; |
|
| 26 | + private $type; |
|
| 27 | + private $closable; |
|
| 28 | + private $block; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @param string $message |
|
| 32 | + * @param string $title |
|
| 33 | + * @param string $type |
|
| 34 | + * @param bool $closable |
|
| 35 | + * @param bool $block |
|
| 36 | + */ |
|
| 37 | + public function __construct($message, $title, $type = "alert-info", $closable = true, $block = true) |
|
| 38 | + { |
|
| 39 | + $this->message = $message; |
|
| 40 | + $this->title = $title; |
|
| 41 | + $this->type = $type; |
|
| 42 | + $this->closable = $closable; |
|
| 43 | + $this->block = $block; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Shows a quick one-liner message |
|
| 48 | + * |
|
| 49 | + * @param string $message |
|
| 50 | + * @param string $type |
|
| 51 | + */ |
|
| 52 | + public static function quick($message, $type = "alert-info") |
|
| 53 | + { |
|
| 54 | + self::append(new SessionAlert($message, "", $type, true, false)); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @param SessionAlert $alert |
|
| 59 | + */ |
|
| 60 | + public static function append(SessionAlert $alert) |
|
| 61 | + { |
|
| 62 | + $data = WebRequest::getSessionAlertData(); |
|
| 63 | + $data[] = serialize($alert); |
|
| 64 | + WebRequest::setSessionAlertData($data); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Shows a quick one-liner success message |
|
| 69 | + * |
|
| 70 | + * @param string $message |
|
| 71 | + */ |
|
| 72 | + public static function success($message) |
|
| 73 | + { |
|
| 74 | + self::append(new SessionAlert($message, "", "alert-success", true, true)); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Shows a quick one-liner warning message |
|
| 79 | + * |
|
| 80 | + * @param string $message |
|
| 81 | + * @param string $title |
|
| 82 | + */ |
|
| 83 | + public static function warning($message, $title = "Warning!") |
|
| 84 | + { |
|
| 85 | + self::append(new SessionAlert($message, $title, "alert-warning", true, true)); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Shows a quick one-liner error message |
|
| 90 | + * |
|
| 91 | + * @param string $message |
|
| 92 | + * @param string $title |
|
| 93 | + */ |
|
| 94 | + public static function error($message, $title = "Error!") |
|
| 95 | + { |
|
| 96 | + self::append(new SessionAlert($message, $title, "alert-danger", true, true)); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Retrieves the alerts which have been saved to the session |
|
| 101 | + * @return array |
|
| 102 | + */ |
|
| 103 | + public static function getAlerts() |
|
| 104 | + { |
|
| 105 | + $alertData = array(); |
|
| 106 | + |
|
| 107 | + foreach (WebRequest::getSessionAlertData() as $a) { |
|
| 108 | + $alertData[] = unserialize($a); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + return $alertData; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Clears the alerts from the session |
|
| 116 | + */ |
|
| 117 | + public static function clearAlerts() |
|
| 118 | + { |
|
| 119 | + WebRequest::clearSessionAlertData(); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @return boolean |
|
| 124 | + */ |
|
| 125 | + public function isBlock() |
|
| 126 | + { |
|
| 127 | + return $this->block; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @return boolean |
|
| 132 | + */ |
|
| 133 | + public function isClosable() |
|
| 134 | + { |
|
| 135 | + return $this->closable; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * @return string |
|
| 140 | + */ |
|
| 141 | + public function getType() |
|
| 142 | + { |
|
| 143 | + return $this->type; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @return string |
|
| 148 | + */ |
|
| 149 | + public function getTitle() |
|
| 150 | + { |
|
| 151 | + return $this->title; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * @return string |
|
| 156 | + */ |
|
| 157 | + public function getMessage() |
|
| 158 | + { |
|
| 159 | + return $this->message; |
|
| 160 | + } |
|
| 161 | 161 | } |
@@ -12,21 +12,21 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class TypeAheadHelper implements ITypeAheadHelper |
| 14 | 14 | { |
| 15 | - private $definedClasses = array(); |
|
| 15 | + private $definedClasses = array(); |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @param string $class CSS class to apply this typeahead to. |
|
| 19 | - * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
| 20 | - */ |
|
| 21 | - public function defineTypeAheadSource($class, callable $generator) |
|
| 22 | - { |
|
| 23 | - $dataList = ''; |
|
| 24 | - foreach ($generator() as $dataItem) { |
|
| 25 | - $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
| 26 | - } |
|
| 27 | - $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
| 17 | + /** |
|
| 18 | + * @param string $class CSS class to apply this typeahead to. |
|
| 19 | + * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
| 20 | + */ |
|
| 21 | + public function defineTypeAheadSource($class, callable $generator) |
|
| 22 | + { |
|
| 23 | + $dataList = ''; |
|
| 24 | + foreach ($generator() as $dataItem) { |
|
| 25 | + $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
| 26 | + } |
|
| 27 | + $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
| 28 | 28 | |
| 29 | - $script = <<<JS |
|
| 29 | + $script = <<<JS |
|
| 30 | 30 | var substringMatcher = function(strs) { |
| 31 | 31 | return function findMatches(q, cb) { |
| 32 | 32 | var matches, substringRegex; |
@@ -58,32 +58,32 @@ discard block |
||
| 58 | 58 | source: substringMatcher({$dataList}) |
| 59 | 59 | }); |
| 60 | 60 | JS; |
| 61 | - $this->definedClasses[$class] = $script; |
|
| 62 | - } |
|
| 61 | + $this->definedClasses[$class] = $script; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @return string HTML fragment containing a JS block for typeaheads. |
|
| 66 | - */ |
|
| 67 | - public function getTypeAheadScriptBlock() |
|
| 68 | - { |
|
| 69 | - $jsBlocks = ''; |
|
| 64 | + /** |
|
| 65 | + * @return string HTML fragment containing a JS block for typeaheads. |
|
| 66 | + */ |
|
| 67 | + public function getTypeAheadScriptBlock() |
|
| 68 | + { |
|
| 69 | + $jsBlocks = ''; |
|
| 70 | 70 | |
| 71 | - if (count($this->definedClasses) === 0) { |
|
| 72 | - return ''; |
|
| 73 | - } |
|
| 71 | + if (count($this->definedClasses) === 0) { |
|
| 72 | + return ''; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - foreach ($this->definedClasses as $class => $js) { |
|
| 76 | - $jsBlocks = $js . "\r\n\r\n"; |
|
| 77 | - } |
|
| 75 | + foreach ($this->definedClasses as $class => $js) { |
|
| 76 | + $jsBlocks = $js . "\r\n\r\n"; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - $data = <<<HTML |
|
| 79 | + $data = <<<HTML |
|
| 80 | 80 | <script type="text/javascript"> |
| 81 | 81 | {$jsBlocks} |
| 82 | 82 | </script> |
| 83 | 83 | HTML; |
| 84 | 84 | |
| 85 | - $this->definedClasses = array(); |
|
| 85 | + $this->definedClasses = array(); |
|
| 86 | 86 | |
| 87 | - return $data; |
|
| 88 | - } |
|
| 87 | + return $data; |
|
| 88 | + } |
|
| 89 | 89 | } |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | $dataList = ''; |
| 24 | 24 | foreach ($generator() as $dataItem) { |
| 25 | - $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
| 25 | + $dataList .= '"'.htmlentities($dataItem).'", '; |
|
| 26 | 26 | } |
| 27 | - $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
| 27 | + $dataList = "[".rtrim($dataList, ", ")."]"; |
|
| 28 | 28 | |
| 29 | 29 | $script = <<<JS |
| 30 | 30 | var substringMatcher = function(strs) { |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | foreach ($this->definedClasses as $class => $js) { |
| 76 | - $jsBlocks = $js . "\r\n\r\n"; |
|
| 76 | + $jsBlocks = $js."\r\n\r\n"; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $data = <<<HTML |