function form($object)
 {
     if (!defined("SYS_FORMS")) {
         require_once BASE . "subsystems/forms.php";
     }
     pathos_forms_initialize();
     $form = new form();
     if (!isset($object->id)) {
         $object->name = "";
         $object->affiliate_id = 0;
         $object->url = "http://";
     } else {
         $form->meta("id", $object->id);
         global $db;
         $file = $db->selectObject("file", "id=" . $object->file_id);
         $form->register(uniqid(""), "", new htmlcontrol("<img src='" . $file->directory . "/" . $file->filename . "'/>"));
     }
     pathos_lang_loadDictionary('standard', 'core');
     pathos_lang_loadDictionary('modules', 'bannermodule');
     $affiliates = bannermodule::listAffiliates();
     $form->register('name', TR_BANNERMODULE_INTERNALNAME, new textcontrol($object->name));
     $submit = new buttongroupcontrol(TR_CORE_SAVE, '', TR_CORE_CANCEL);
     if (count($affiliates)) {
         $form->register('affiliate_id', TR_BANNERMODULE_AFFILIATE, new dropdowncontrol($object->affiliate_id, $affiliates));
     } else {
         $form->registerBefore('name', null, '', new htmlcontrol('<div class="error">' . TR_BANNERMODULE_NOAFFILIATES . '</div>'));
         $submit->disabled = 1;
     }
     $form->register('url', TR_BANNERMODULE_DESTURL, new texteditorcontrol($object->url, 2, 40));
     $form->register('submit', '', $submit);
     return $form;
 }
 function form($object)
 {
     if (!defined('SYS_FORMS')) {
         include_once BASE . 'subsystems/forms.php';
     }
     exponent_forms_initialize();
     $form = new form();
     if (!isset($object->id)) {
         $object->name = '';
         $object->affiliate_id = 0;
         $object->url = 'http://';
     } else {
         $form->meta('id', $object->id);
         global $db;
         $file = $db->selectObject('file', 'id=' . $object->file_id);
         $form->register(uniqid(''), '', new htmlcontrol('<img src="' . $file->directory . '/' . $file->filename . '"/>'));
     }
     $i18n = exponent_lang_loadFile('datatypes/banner_ad.php');
     $affiliates = bannermodule::listAffiliates();
     $form->register('name', $i18n['name'], new textcontrol($object->name));
     $submit = new buttongroupcontrol($i18n['save'], '', $i18n['cancel']);
     if (count($affiliates)) {
         $form->register('affiliate_id', $i18n['affiliate_id'], new dropdowncontrol($object->affiliate_id, $affiliates));
     } else {
         $form->registerBefore('name', null, '', new htmlcontrol('<div class="error">' . $i18n['no_affiliates'] . '</div>'));
         $submit->disabled = 1;
     }
     $form->register('url', $i18n['url'], new texteditorcontrol($object->url, 2, 40));
     $form->register('submit', '', $submit);
     return $form;
 }
示例#3
0
 function show($view, $loc, $title = '')
 {
     global $db;
     $template = new template('bannermodule', $view, $loc);
     $template->assign('title', $title);
     $viewconfig = array('type' => 'default', 'number' => 1);
     if (is_readable($template->viewdir . "/{$view}.config")) {
         $viewconfig = (include $template->viewdir . "/{$view}.config");
     }
     if ($viewconfig['type'] == 'affiliates') {
         $af = $db->selectObjects('banner_affiliate');
         for ($i = 0; $i < count($af); $i++) {
             $af[$i]->bannerCount = $db->countObjects('banner_ad', 'affiliate_id=' . $af[$i]->id);
             $af[$i]->contact_info = str_replace("\n", "<br />", $af[$i]->contact_info);
         }
         if (!defined('SYS_SORTING')) {
             require_once BASE . 'subsystems/sorting.php';
         }
         usort($af, 'pathos_sorting_byNameAscending');
         $template->assign('affiliates', $af);
     } else {
         if (!defined('SYS_FILES')) {
             require_once BASE . 'subsystems/files.php';
         }
         $directory = 'files/bannermodule/' . $loc->src;
         if (!file_exists(BASE . $directory)) {
             $err = pathos_files_makeDirectory($directory);
             if ($err != SYS_FILES_SUCCESS) {
                 $template->assign('noupload', 1);
                 $template->assign('uploadError', $err);
             }
         }
         $all = $db->selectObjects('banner_ad', "location_data='" . serialize($loc) . "'");
         if ($viewconfig['type'] == 'allbanners') {
             $bfiles = $db->selectObjectsIndexedArray('file', "directory='" . $directory . "'");
             $template->assign('affiliates', bannermodule::listAffiliates());
             $template->assign('files', $bfiles);
             $template->assign('banners', $all);
         } else {
             $num = $viewconfig['number'];
             shuffle($all);
             $banners = array_slice($all, 0, $num);
             for ($i = 0; $i < count($banners); $i++) {
                 $banners[$i]->file = $db->selectObject('file', 'id=' . $banners[$i]->file_id);
             }
             $template->assign('banners', $banners);
         }
     }
     $template->register_permissions(array('administrate', 'manage', 'manage_af'), $loc);
     $template->output();
 }