public function __construct() { parent::__construct(); $sTable = AdsCore::getTable(); (new AdsCoreModel())->update($this->httpRequest->post('id_ads'), $this->httpRequest->post('title'), $this->httpRequest->post('code', Http::NO_CLEAN), $sTable); /* Clean Model\Design for STATIC data */ (new Framework\Cache\Cache())->start(Framework\Mvc\Model\Design::CACHE_STATIC_GROUP, null, null)->clear(); \PFBC\Form::setSuccess('form_update_ads', t('The Advertisements was saved successfully!')); }
public function __construct() { parent::__construct(); $sTable = AdsCore::getTable(); (new AdsCoreModel())->add($this->httpRequest->post('title'), $this->httpRequest->post('code', Http::NO_CLEAN), $sTable); /* Clean AdminCoreModel Ads and Model\Design for STATIC data */ (new Framework\Cache\Cache())->start(Framework\Mvc\Model\Design::CACHE_STATIC_GROUP, null, null)->clear()->start(AdsCoreModel::CACHE_GROUP, 'totalAds', null)->clear()->start(AdsCoreModel::CACHE_GROUP, 'totalAdsAffiliates', null)->clear(); $sSlug = AdsCore::getTable() == 'AdsAffiliates' ? 'affiliate' : ''; HeaderUrl::redirect(Uri::get(PH7_ADMIN_MOD, 'setting', 'ads', $sSlug), t('The Advertisement was added successfully!')); }
protected function delete() { $sTable = AdsCore::getTable(); $this->_bStatus = $this->_oAdsModel->delete($this->_oHttpRequest->post('adsId'), $sTable); if ($this->_bStatus) { /* Clean AdminCoreModel Ads and Model\Design for STATIC data */ (new Framework\Cache\Cache())->start(Design::CACHE_STATIC_GROUP, null, null)->clear()->start(AdsCoreModel::CACHE_GROUP, 'totalAds', null)->clear()->start(AdsCoreModel::CACHE_GROUP, 'totalAdsAffiliates', null)->clear(); $this->_sMsg = jsonMsg(1, t('The Advertisement we been deleted.')); } else { $this->_sMsg = jsonMsg(0, t('Cannot remove Advertisement, please try later.')); } echo $this->_sMsg; }
public function __construct() { parent::__construct(); $iIsAff = AdsCore::getTable() == 'AdsAffiliates'; $sTable = AdsCore::getTable(); $sTitle = $this->httpRequest->post('title'); $sCode = $this->httpRequest->post('code', Http::NO_CLEAN); $aSize = explode('x', $this->httpRequest->post('size')); $iWidth = $aSize[0]; $iHeight = $aSize[1]; (new AdsCoreModel())->add($sTitle, $sCode, $iWidth, $iHeight, $sTable); /* Clean AdminCoreModel Ads and Model\Design for STATIC data */ (new Framework\Cache\Cache())->start(Framework\Mvc\Model\Design::CACHE_STATIC_GROUP, null, null)->clear()->start(AdsCoreModel::CACHE_GROUP, 'totalAds' . ($iIsAff ? 'Affiliates' : ''), null)->clear(); $sSlug = $iIsAff ? 'affiliate' : ''; Header::redirect(Uri::get(PH7_ADMIN_MOD, 'setting', 'ads', $sSlug), t('The Advertisement was added successfully!')); }
public function ads() { $oPage = new Page(); $sTable = AdsCore::getTable(); $iTotalAds = (new AdsCoreModel())->total($sTable); $this->view->total_pages = $oPage->getTotalPages($iTotalAds, 10); $this->view->current_page = $oPage->getCurrentPage(); unset($oPage, $sTable); // Add JS file for the ads form $this->design->addJs(PH7_LAYOUT . PH7_SYS . PH7_MOD . $this->registry->module . PH7_SH . PH7_TPL . PH7_TPL_MOD_NAME . PH7_SH . PH7_JS, 'common.js'); $this->sTitle = t('Advertisement Settings'); $this->view->page_title = $this->sTitle; $this->view->h1_title = $this->sTitle; $this->view->h4_title = t('%0% Banners', $iTotalAds); $this->output(); }
public static function display() { if (isset($_POST['submit_update_ads'])) { if (\PFBC\Form::isValid($_POST['submit_update_ads'])) { new UpdateAdsFormProcess(); } Framework\Url\Header::redirect(); } $oPage = new Page(); $oAdsModel = new AdsCoreModel(); $sTable = AdsCore::getTable(); $sCSRFToken = (new Framework\Security\CSRF\Token())->generate('ads'); $oPage->getTotalPages($oAdsModel->total($sTable), 10); $oAds = $oAdsModel->get(null, $oPage->getFirstItem(), $oPage->getNbItemsByPage(), $sTable); unset($oPage, $oAdsModel); $oSysVar = new SysVar(); foreach ($oAds as $oRow) { $oForm = new \PFBC\Form('form_update_ads', 500); $oForm->configure(array('action' => '')); $oForm->addElement(new \PFBC\Element\Hidden('submit_update_ads', 'form_update_ads')); $oForm->addElement(new \PFBC\Element\Token('update_ads')); // Begin ads div tags $oForm->addElement(new \PFBC\Element\HTMLExternal('<div id="ad_' . $oRow->adsId . '">')); $oForm->addElement(new \PFBC\Element\Hidden('id_ads', $oRow->adsId)); $oForm->addElement(new \PFBC\Element\Textbox(t('Title:'), 'title', array('value' => $oRow->name, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 40)))); $oForm->addElement(new \PFBC\Element\HTMLExternal('<p>' . t('Preview Ad:') . '</p>')); $oForm->addElement(new \PFBC\Element\HTMLExternal($oSysVar->parse($oRow->code))); // ID textarea form was generated with "mt_rand" because it is faster than "uniqid" // See also this discussion we asked: http://stackoverflow.com/questions/9152600/uniqid-versus-mt-rand-php-function $oForm->addElement(new \PFBC\Element\Textarea(t('Advertisement:'), 'code', array('id' => mt_rand(), 'value' => $oSysVar->parse($oRow->code), 'required' => 1))); // mt_rand() function for generate an ID different if it causes problems in the display. $oForm->addElement(new \PFBC\Element\Button(t('Update'), 'submit', array('id' => mt_rand()))); if (AdsCore::getTable() == 'Ads') { // This feature is not available for affiliate banners $oForm->addElement(new \PFBC\Element\HTMLExternal(t('Views: %0% | Clicks: %1%', $oRow->views, $oRow->clicks) . ' | ')); } $oForm->addElement(new \PFBC\Element\HTMLExternal('<a class="medium_button" href="javascript:void(0)" onclick="ads(\'delete\',' . $oRow->adsId . ',\'' . $sCSRFToken . '\')">' . t('Delete') . '</a> | ')); if ($oRow->active == 1) { $oForm->addElement(new \PFBC\Element\HTMLExternal('<a class="medium_button" href="javascript:void(0)" onclick="ads(\'deactivate\',' . $oRow->adsId . ',\'' . $sCSRFToken . '\')">' . t('Deactivate') . '</a>')); } else { $oForm->addElement(new \PFBC\Element\HTMLExternal('<a class="medium_button" href="javascript:void(0)" onclick="ads(\'activate\',' . $oRow->adsId . ',\'' . $sCSRFToken . '\')">' . t('Activate') . '</a>')); } // End ads div tags $oForm->addElement(new \PFBC\Element\HTMLExternal('</div>')); $oForm->render(); } }
public static function display() { if (isset($_POST['submit_ads'])) { if (\PFBC\Form::isValid($_POST['submit_ads'])) { new AdsFormProcess(); } Framework\Url\Header::redirect(); } $aAdSizes = Import::file(PH7_PATH_APP_CONFIG . 'ad_sizes'); $oForm = new \PFBC\Form('form_ads', 500); $oForm->configure(array('action' => '')); $oForm->addElement(new \PFBC\Element\Hidden('submit_ads', 'form_ads')); $oForm->addElement(new \PFBC\Element\Token('ads')); $oForm->addElement(new \PFBC\Element\Textbox(t('Title:'), 'title', array('required' => 1, 'validation' => new \PFBC\Validation\Str(2, 40)))); $oForm->addElement(new \PFBC\Element\Select(t('Size of the Banner:'), 'size', $aAdSizes, array('required' => 1))); $sText = AdsCore::getTable() == 'AdsAffiliates' ? t('The predefined variable for the URL of an affiliate account to put in the HTML is: %0%.', '<strong>#!%affiliate_url%!#</strong>') : t('The predefined variable to the URL of your site to indicate this in the HTML is: %0%.', '<strong>#!%site_url%!#</strong>'); $oForm->addElement(new \PFBC\Element\Textarea(t('Banner:'), 'code', array('description' => $sText, 'required' => 1))); $oForm->addElement(new \PFBC\Element\Button()); $oForm->render(); }