Completed
Branch master (52775d)
by Pierre-Henry
36:45
created

BannerForm::display()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 32
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 23
nc 2
nop 0
dl 0
loc 32
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author         Pierre-Henry Soria <[email protected]>
4
 * @copyright      (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved.
5
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
6
 * @package        PH7 / App / System / Module / Affiliate / Form
7
 */
8
namespace PH7;
9
10
use PH7\Framework\Parse\SysVar, PH7\Framework\Navigation\Page;
11
12
class BannerForm
13
{
14
    const ADS_PER_PAGE = 10;
15
16
    public static function display()
17
    {
18
        $oForm = new \PFBC\Form('form_banner_ads');
19
        $oPage = new Page;
20
        $oAdsModel = new AdsCoreModel;
21
22
        $oPage->getTotalPages($oAdsModel->total('AdsAffiliates'), self::ADS_PER_PAGE);
23
        $oAds = $oAdsModel->get(
24
            null,
25
            $oPage->getFirstItem(),
26
            $oPage->getNbItemsPerPage(),
27
            'AdsAffiliates'
28
        );
29
        unset($oPage, $oAdsModel);
30
31
        $oSysVar = new SysVar;
32
        foreach ($oAds as $oRow) {
33
            // Begin ads div tags
34
            $oForm->addElement(new \PFBC\Element\HTMLExternal('<div id="ad_' . $oRow->adsId . '">'));
35
36
            $oForm->addElement(new \PFBC\Element\Hidden('id_ads', $oRow->adsId));
37
            $oForm->addElement(new \PFBC\Element\HTMLExternal('<h2>' . $oRow->name . '</h2>'));
38
            $oForm->addElement(new \PFBC\Element\HTMLExternal('<p>' . t('Preview Banner:') . '</p>'));
39
            $oForm->addElement(new \PFBC\Element\HTMLExternal('<div>' . $oSysVar->parse($oRow->code) . '</div>'));
40
            $oForm->addElement(new \PFBC\Element\Textarea(t('Banner:'),'code', array('readonly'=>'readonly','onclick'=>'this.select()','value'=>$oSysVar->parse($oRow->code))));
41
            // End ads div tags
42
            $oForm->addElement(new \PFBC\Element\HTMLExternal('</div>'));
43
            $oForm->addElement(new \PFBC\Element\HTMLExternal('<br /><hr /><br />'));
44
        }
45
        $oForm->render();
46
        unset($oSysVar);
47
    }
48
}
49