|
21 | 21 |
|
22 | 22 | namespace MetaModels\DcGeneral\Events\Table\MetaModels; |
23 | 23 |
|
24 | | -use ContaoCommunityAlliance\Contao\Bindings\ContaoEvents; |
25 | | -use ContaoCommunityAlliance\Contao\Bindings\Events\Image\ResizeImageEvent; |
26 | 24 | use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\DecodePropertyValueForWidgetEvent; |
27 | 25 | use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\EncodePropertyValueFromWidgetEvent; |
28 | 26 | use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetBreadcrumbEvent; |
@@ -156,45 +154,34 @@ public function modelToLabel(ModelToLabelEvent $event) |
156 | 154 | $model = $event->getModel(); |
157 | 155 | $translator = $event->getEnvironment()->getTranslator(); |
158 | 156 | $database = $this->getDatabase(); |
| 157 | + $tableName = $model->getProperty('tableName'); |
159 | 158 |
|
160 | | - if (!($model && $database->tableExists($model->getProviderName()))) { |
| 159 | + if (!($model && !empty($tableName) && $database->tableExists($tableName))) { |
161 | 160 | return; |
162 | 161 | } |
163 | 162 |
|
164 | 163 | $strLabel = vsprintf($event->getLabel(), $event->getArgs()); |
165 | | - |
166 | | - $strImage = ''; |
167 | | - if ($model->getProperty('addImage')) { |
168 | | - $arrSize = deserialize($model->getProperty('size')); |
169 | | - $imageEvent = new ResizeImageEvent($model->getProperty('singleSRC'), $arrSize[0], $arrSize[1], $arrSize[2]); |
170 | | - |
171 | | - $event->getEnvironment()->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_RESIZE, $event); |
172 | | - |
173 | | - $strImage = sprintf( |
174 | | - '<div class="image" style="padding-top:3px"><img src="%s" alt="%%1$s" /></div> ', |
175 | | - $imageEvent->getImage(), |
176 | | - htmlspecialchars($strLabel) |
177 | | - ); |
178 | | - } |
179 | | - |
| 164 | + $image = ((bool) $model->getProperty('translated')) ? 'locale.png' : 'locale_1.png'; |
180 | 165 | $objCount = $database |
181 | | - ->prepare('SELECT count(*) AS itemCount FROM ' . $model->getProperty('tableName')) |
| 166 | + ->prepare('SELECT count(*) AS itemCount FROM ' . $tableName) |
182 | 167 | ->execute(); |
183 | 168 | /** @noinspection PhpUndefinedFieldInspection */ |
184 | 169 | $count = $objCount->itemCount; |
185 | 170 |
|
186 | | - $itemCount = sprintf( |
187 | | - '<span style="color:#b3b3b3; padding-left:3px">[%s]</span>', |
188 | | - $translator->translatePluralized( |
189 | | - 'itemFormatCount', |
190 | | - $count, |
191 | | - 'tl_metamodel', |
192 | | - array($count) |
| 171 | + $event->setArgs([ |
| 172 | + sprintf( |
| 173 | + ' |
| 174 | +<span class="name"> |
| 175 | + <img src="system/modules/metamodels/assets/images/icons/%1$s" /> %2$s |
| 176 | + <span style="color:#b3b3b3; padding-left:3px">(%3$s)</span> |
| 177 | + <span style="color:#b3b3b3; padding-left:3px">[%4$s]</span> |
| 178 | +</span>', |
| 179 | + $image, |
| 180 | + $strLabel, |
| 181 | + $tableName, |
| 182 | + $translator->translatePluralized('itemFormatCount', $count, 'tl_metamodel', [$count]) |
193 | 183 | ) |
194 | | - ); |
195 | | - $tableName = '<span style="color:#b3b3b3; padding-left:3px">(' . $model->getProperty('tableName') . ')</span>'; |
196 | | - |
197 | | - $event->setArgs(array('<span class="name">' . $strLabel . $tableName . $itemCount . '</span>' . $strImage)); |
| 184 | + ]); |
198 | 185 | } |
199 | 186 |
|
200 | 187 | /** |
|
0 commit comments