forked from koala-framework/koala-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form.php
44 lines (41 loc) · 1.59 KB
/
Form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
class Kwc_Basic_ImageEnlarge_Form extends Kwc_Abstract_Image_Form
{
protected $_imageUploadFieldClass = 'Kwc_Basic_ImageEnlarge_ImageUploadField';
protected function _initFields()
{
parent::_initFields();
$this->setIdentifier('kwc-basic-imageenlarge-form');
$linkTag = $this->getByName('linkTag');
if ($linkTag) {
$childs = $linkTag->getChildren();
$childs = $childs[0]->getChildren();
if ($childs[0] instanceof Kwf_Form_Container_Cards) {
$linkTag->setTitle(trlKwf('Click on Preview Image').':');
} else {
$linkTag->setTitle(trlKwf('Image Enlarge').':');
}
}
}
private static function _findDimensionByChildComponentClassRecursive($class)
{
$parents = Kwc_Abstract::getSetting($class, 'parentClasses');
if (in_array('Kwc_Basic_ImageEnlarge_EnlargeTag_Component', $parents)) {
return Kwc_Abstract::getSetting($class, 'dimension');
} else {
foreach (Kwc_Abstract::getChildComponentClasses($class) as $childClass) {
$dimension = self::_findDimensionByChildComponentClassRecursive($childClass);
if ($dimension) {
return $dimension;
}
}
}
return false;
}
protected function _createImageUploadField($imageLabel)
{
$ret = parent::_createImageUploadField($imageLabel);
$ret->setImageEnlargeDimension(self::_findDimensionByChildComponentClassRecursive($this->getClass()));
return $ret;
}
}