array( 'controller' => 'banner_ui', 'path' => null, 'ui' => 'banner_form_ui', 'uipath' => null ), ); protected $adminMenu = array( 'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'), 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'), // 'main/menu' => array('caption'=> BNRLAN_36, 'perm' => 'P'), //Done in Menu manager #2096 // 'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => 'P'), // 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P') ); protected $adminMenuAliases = array( 'main/edit' => 'main/list' ); protected $menuTitle = 'Banners'; } class banner_ui extends e_admin_ui { protected $pluginTitle = LAN_PLUGIN_BANNER_NAME; protected $pluginName = 'banner'; protected $table = 'banner'; protected $pid = 'banner_id'; protected $perPage = 10; protected $batchDelete = true; protected $batchCopy = true; // protected $sortField = 'somefield_order'; // protected $orderStep = 10; protected $tabs = array(LAN_BASIC, LAN_ADVANCED); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable. // protected $listQry = "SELECT * FROM `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit. protected $listOrder = 'banner_id DESC'; protected $fields = array ( 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ), 'banner_id' => array ( 'title' => LAN_ID, 'type' => null, 'data' => 'int', 'width' => '2%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'banner_campaign' => array ( 'title' => BNRLAN_11, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'inline'=>false, 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => array( 'tdClassRight'=>'form-inline'), 'class' => 'left', 'thclass' => 'left', ), 'banner_clientname' => array ( 'title' => BANNERLAN_22, 'type' => 'method', 'tab'=>1, 'data' => 'str', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'banner_clientlogin' => array ( 'title' => BNRLAN_12, 'type' => 'method', 'tab'=>1, 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'banner_clientpassword' => array ( 'title' => LAN_PASSWORD, 'type' => 'text', 'tab'=>1,'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => 'strength=1&password=1&required=0&generate=1&nomask=1', 'class' => 'center', 'thclass' => 'center', ), 'banner_image' => array ( 'title' => LAN_IMAGE, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => 'thumb=0x50&legacyPath={e_IMAGE}banners', 'writeParms' => 'media=banner&w=600&legacyPath={e_IMAGE}banners', 'class' => 'left', 'thclass' => 'left', ), 'banner_clickurl' => array ( 'title' => BNRLAN_15, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => 'size=xxlarge&required=1', 'class' => 'left', 'thclass' => 'left', ), 'banner_impurchased' => array ( 'title' => BNRLAN_16, 'type' => 'number', 'data' => 'int', 'width' => 'auto', 'inline' => true, 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', 'help'=>'0 = unlimited' ), 'banner_tooltip' => array ( 'title' => LAN_TOOLTIP, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xxlarge'), 'class' => 'center', 'thclass' => 'center', ), 'banner_description' => array ( 'title' => LAN_DESCRIPTION, 'type' => 'textarea', 'data' => 'str', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'banner_keywords' => array ( 'title' => LAN_KEYWORDS, 'type' => 'tags', 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => 'When news or pages are loaded, this will limit banner result to matching keywords. Use with caution.', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'banner_startdate' => array ( 'title' => LAN_START, 'type' => 'datestamp', 'tab'=>1,'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'banner_enddate' => array ( 'title' => LAN_END, 'type' => 'datestamp', 'tab'=>1, 'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'banner_active' => array ( 'title' => LAN_VISIBILITY, 'type' => 'userclass', 'data' => 'int', 'width' => 'auto', 'filter' => true, 'batch'=>true, 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'banner_clicks' => array ( 'title' => BANNERLAN_24, 'type' => 'number', 'noedit'=>true, 'readonly'=>2, 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'click_percentage' => array ( 'title' => BANNERLAN_25, 'type' => 'method', 'noedit'=>true, 'data' => false, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), 'banner_impressions' => array ( 'title' => BANNERLAN_26, 'type' => 'method', 'noedit'=>true, 'data' => 'int', 'width' => '12%', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'banner_ip' => array ( 'title' => LAN_IP, 'type' => 'hidden', 'noedit'=>true, 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'options' => array ( 'title' => LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ), ); protected $fieldpref = array('banner_id', 'banner_campaign', 'banner_image', 'banner_clickurl', 'banner_clicks', 'banner_active', 'click_percentage', 'banner_impressions' ); /* protected $prefs = array( 'banner_caption' => array('title'=> 'Banner_caption', 'type'=>'text', 'data' => 'string','help'=>'Help Text goes here'), 'banner_campaign' => array('title'=> 'Banner_campaign', 'type'=>'method', 'data' => 'string','help'=>'Help Text goes here'), 'banner_amount' => array('title'=> 'Banner_amount', 'type'=>'number', 'data' => 'string','help'=>'Help Text goes here'), 'banner_rendertype' => array('title'=> 'Banner_rendertype', 'type'=>'text', 'data' => 'string','help'=>'Help Text goes here'), ); */ public function init() { /*if (!empty($_POST['update_menu'])) { $this->menuPageSave(); }*/ } // ------- Customize Create -------- public function beforeCreate($new_data, $old_data) { // e107::getMessage()->addDebug(print_a($new_data,true)); if(!empty($new_data['banner_clientname_sel'])) { $new_data['banner_clientname'] = $new_data['banner_clientname_sel']; } if(!empty($new_data['banner_campaign_sel']) && $new_data['banner_campaign_sel'] != '_new_') { $new_data['banner_campaign'] = $new_data['banner_campaign_sel']; } if(!empty($new_data['banner_image_remote'])) { $new_data['banner_image'] = $new_data['banner_image_remote']; } return $new_data; } public function afterCreate($new_data, $old_data, $id) { // do something } public function onCreateError($new_data, $old_data) { // do something exit; } // ------- Customize Update -------- public function beforeUpdate($new_data, $old_data, $id) { // e107::getMessage()->addDebug(print_a($new_data,true)); if(!empty($new_data['banner_clientname_sel'])) { $new_data['banner_clientname'] = $new_data['banner_clientname_sel']; } if(!empty($new_data['banner_campaign_sel']) && empty($new_data['banner_campaign'])) { $new_data['banner_campaign'] = $new_data['banner_campaign_sel']; } if(!empty($new_data['banner_image_remote'])) { $new_data['banner_image'] = $new_data['banner_image_remote']; } // e107::getMessage()->addDebug(print_a($new_data,true)); return $new_data; } public function afterUpdate($new_data, $old_data, $id) { // do something } public function onUpdateError($new_data, $old_data, $id) { // do something } public function ListObserver() { $this->fields['banner_campaign']['type'] = 'text'; $this->fields['banner_campaign']['inline'] = true; parent::ListObserver(); } public function InlineAjaxPage() { $this->fields['banner_campaign']['type'] = 'text'; $this->fields['banner_campaign']['inline'] = true; return parent::InlineAjaxPage(); } /* private function menuPageSave() { $temp = array(); $tp = e107::getParser(); $log = e107::getAdminLog(); $menu_pref = e107::getConfig('menu')->getPref(''); $temp['banner_caption'] = $tp->toDB($_POST['banner_caption']); $temp['banner_amount'] = intval($_POST['banner_amount']); $temp['banner_rendertype'] = intval($_POST['banner_rendertype']); if (isset($_POST['multiaction_cat_active'])) { $cat = implode('|', $tp->toDB($_POST['multiaction_cat_active'])); $temp['banner_campaign'] = $cat; } if ($log->logArrayDiffs($temp,$menu_pref,'BANNER_01')) { $menuPref = e107::getConfig('menu'); //e107::getConfig('menu')->setPref('', $menu_pref); //e107::getConfig('menu')->save(false, true, false); foreach ($temp as $k => $v) { $menuPref->setPref($k, $v); } $menuPref->save(false, true, false); e107::getMessage()->addSuccess(LAN_SAVED); $menu_pref = e107::getConfig('menu')->getPref(''); //banners_adminlog('01', $menu_pref['banner_caption'].'[!br!]'.$menu_pref['banner_amount'].', '.$menu_pref['banner_rendertype'].'[!br!]'.$menu_pref['banner_campaign']); } }*/ public function menuPage() { return e107::getMessage()->addInfo("The menu is now configured within the menu-manager.")->render(); /*$ns = e107::getRender(); $sql = e107::getDb(); $menu_pref = e107::getConfig('menu')->getPref(''); $frm = e107::getForm(); $mes = e107::getMessage(); $in_catname = array(); // Notice removal $all_catname = array(); $array_cat_in = explode("|", $menu_pref['banner_campaign']); if (!$menu_pref['banner_caption']) { $menu_pref['banner_caption'] = BNRLAN_38; } $category_total = $sql->select("banner", "DISTINCT(banner_campaign) as banner_campaign", "ORDER BY banner_campaign", "mode=no_where"); while ($banner_row = $sql -> fetch()) { $all_catname[] = $banner_row['banner_campaign']; if (in_array($banner_row['banner_campaign'], $array_cat_in)) { $in_catname[] = $banner_row['banner_campaign']; } } $text = "
"; return $mes->render().$text; // $ns->tablerender(LAN_PLUGIN_BANNER_NAME.SEP.BNRLAN_36, $mes->render() . $text); */ } public function renderHelp() { $help_text = str_replace("[br]", "". $this->text('banner_image_remote',$val2, 255, array('size'=>'xxlarge', 'placeholder'=>'eg. http://some-website.com/banner-image.jpg', 'title'=>'This will override any local image you have set.'))."
"; if(!empty($val2)) { $tab2 .= e107::getParser()->toImage($val2); } $tabText = array( 'local' => array('caption'=>BNRLAN_50, 'text'=>$tab1), 'remote' => array('caption'=>BNRLAN_51, 'text'=>$tab2), ); return " "; // return $frm->text('banner_clientname',$curVal); // break; case 'filter': case 'batch': return $this->clients; //break; } return null; } // Custom Method/Function function banner_clientname($curVal,$mode) { $frm = e107::getForm(); switch($mode) { case 'read': // List Page return $curVal; // break; case 'write': // Edit Page $text = ''; if (count($this->clients)) { $text = $frm->select('banner_clientname_sel',$this->clients, $curVal,'', LAN_SELECT."..."); $text .= $frm->text('banner_clientname','','',array('placeholder'=> 'Or enter a new client')); } else { $text .= $frm->text('banner_clientname',$curVal); $text .= "".BNRLAN_29.""; } return $text; // return $frm->text('banner_clientname',$curVal); //break; case 'filter': case 'batch': return $this->clients; //break; } return null; } // Custom Method/Function function banner_clientlogin($curVal,$mode) { $frm = e107::getForm(); switch($mode) { case 'read': // List Page return $curVal; break; case 'write': // Edit Page return $frm->text('banner_clientlogin',$curVal); break; case 'filter': case 'batch': return null; break; } return null; } // Custom Method/Function function banner_impressions($curVal,$mode) { $frm = e107::getForm(); switch($mode) { case 'read': // List Page $banner_row = $this->getController()->getListModel()->getData(); // $impressions_left = ($banner_row['banner_impurchased'] ? $banner_row['banner_impurchased'] - $banner_row['banner_impressions'] : BANNERLAN_30); $impressions_purchased = ($banner_row['banner_impurchased'] ? $banner_row['banner_impurchased'] : BANNERLAN_30); return $curVal .' / '.$impressions_purchased; break; case 'write': // Edit Page return $frm->text('banner_impressions',$curVal); break; case 'filter': case 'batch': return array(); break; } return null; } // Custom Method/Function function banner_campaign($curVal,$mode) { $frm = e107::getForm(); switch($mode) { case 'read': // List Page return $curVal; break; case 'write': // Edit Page if (count($this->campaigns)) { $text = $frm->select('banner_campaign_sel',$this->campaigns, $curVal,'',LAN_SELECT."..."); $text .= $frm->text('banner_campaign','','',array('size'=>'xlarge', 'class'=>'e-hideme','placeholder'=> 'Enter a campaign name')); } else { $text = $frm->text('banner_campaign',$curVal, '', array('size'=>'xlarge', 'placeholder'=> 'Enter a campaign name')); } return $text; // $frm->text('banner_campaign',$curVal); break; case 'filter': case 'batch': return $this->campaigns; break; } return null; } // Custom Method/Function function click_percentage($curVal,$mode) { if($mode != 'read') { return null; } unset($curVal); // keep inspector happy. $banner_row = $this->getController()->getListModel()->getData(); // return print_a($banner_row,true); return ($banner_row['banner_clicks'] && $banner_row['banner_impressions'] ? round(($banner_row['banner_clicks'] / $banner_row['banner_impressions']) * 100,1)."%" : "-"); //$impressions_left = ($banner_row['banner_impurchased'] ? $banner_row['banner_impurchased'] - $banner_row['banner_impressions'] : BANNERLAN_30); // $impressions_purchased = ($banner_row['banner_impurchased'] ? $banner_row['banner_impurchased'] : BANNERLAN_30); } } new banner_admin; require_once(e_ADMIN."auth.php"); e107::getAdminUI()->runPage(); require_once(e_ADMIN."footer.php"); //TODO - Put client/password in a separate table?