コード例 #1
0
 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!'));
 }
コード例 #2
0
 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!'));
 }
コード例 #3
0
ファイル: AdsAjax.php プロジェクト: joswilson/NotJustOK
 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;
 }
コード例 #4
0
 /**
  * Get Total Advertisements.
  *
  * @param string $sTable Default 'Ads'
  * @return integer
  */
 public function total($sTable = 'Ads')
 {
     $this->cache->start(self::CACHE_GROUP, 'total' . $sTable, 604800);
     if (!($iData = $this->cache->get())) {
         AdsCore::checkTable($sTable);
         $rStmt = Db::getInstance()->prepare('SELECT COUNT(adsId) AS totalAds FROM' . Db::prefix($sTable));
         $rStmt->execute();
         $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         $iData = (int) $oRow->totalAds;
         unset($oRow);
         $this->cache->put($iData);
     }
     return $iData;
 }
コード例 #5
0
 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!'));
 }
コード例 #6
0
 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();
 }
コード例 #7
0
 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();
     }
 }
コード例 #8
0
 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();
 }
コード例 #9
0
 /**
  * Check table.
  *
  * @see \PH7\Framework\Mvc\Model\Engine\Util\Various::launchErr()
  *
  * @param string $sTable
  * @return mixed (string | void) Returns the table if it is correct.
  * @throws \PH7\Framework\Mvc\Model\Engine\Util\Various::launchErr() If the table is not valid.
  */
 public static function checkTable($sTable)
 {
     switch ($sTable) {
         case 'Members':
         case 'AlbumsPictures':
         case 'AlbumsVideos':
         case 'Pictures':
         case 'Videos':
         case 'Games':
         case 'Blogs':
         case 'Notes':
             return $sTable;
             break;
             /** Check Ads Tables **/
             \PH7\AdsCore::checkTable($sTable);
         default:
             static::launchErr($sTable);
     }
 }