function pathConfiguration() { global $xoopsModule; // Upload and Images Folders smartpartner_collapsableBar('configtable', 'configtableicon'); echo "<img id='configtableicon' name='configtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . _AM_SPARTNER_PATHCONFIGURATION . "</h3>"; echo "<div id='configtable'>"; echo "<br />"; echo "<table width='100%' class='outer' cellspacing='1' cellpadding='3' border='0' ><tr>"; echo "<td class='bg3'><b>" . _AM_SPARTNER_PATH_ITEM . "</b></td>"; echo "<td class='bg3'><b>" . _AM_SPARTNER_PATH . "</b></td>"; echo "<td class='bg3' align='center'><b>" . _AM_SPARTNER_STATUS . "</b></td></tr>"; echo "<tr><td class='odd'>" . _AM_SPARTNER_PATH_IMAGES . "</td>"; $image_path = smartpartner_getImageDir(); echo "<td class='odd'>" . $image_path . "</td>"; echo "<td class='even' style='text-align: center;'>" . smartpartner_admin_getPathStatus('images') . "</td></tr>"; echo "</table>"; echo "<br />"; echo "</div>"; }
function pathConfiguration() { global $xoopsModule; // Upload and Images Folders smartpartner_collapsableBar('configtable', 'configtableicon', _AM_SPARTNER_PATHCONFIGURATION); echo "<br />"; echo "<table width='100%' class='outer' cellspacing='1' cellpadding='3' border='0' ><tr>"; echo "<td class='bg3'><b>" . _AM_SPARTNER_PATH_ITEM . "</b></td>"; echo "<td class='bg3'><b>" . _AM_SPARTNER_PATH . "</b></td>"; echo "<td class='bg3' align='center'><b>" . _AM_SPARTNER_STATUS . "</b></td></tr>"; echo "<tr><td class='odd'>" . _AM_SPARTNER_PATH_IMAGES . "</td>"; $image_path = smartpartner_getImageDir(); echo "<td class='odd'>" . $image_path . "</td>"; echo "<td class='even' style='text-align: center;'>" . smartpartner_admin_getPathStatus('images') . "</td></tr>"; echo "<tr><td class='odd'>" . _AM_SPARTNER_PATH_CATEGORY_IMAGES . "</td>"; $image_path = smartpartner_getImageDir('category'); echo "<td class='odd'>" . $image_path . "</td>"; echo "<td class='even' style='text-align: center;'>" . smartpartner_admin_getPathStatus('images/category') . "</td></tr>"; echo "</table>"; echo "<br />"; smartpartner_close_collapsable('configtable', 'configtableicon'); }
function editpartner($showmenu = false, $id = 0) { global $xoopsDB, $smartpartner_partner_handler, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; if (!isset($smartpartner_partner_handler)) { $smartpartner_partner_handler =& smartpartner_gethandler('partner'); } include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // If there is a parameter, and the id exists, retrieve data: we're editing a partner if ($id != 0) { // Creating the partner object $partnerObj = new SmartpartnerPartner($id); if ($partnerObj->notLoaded()) { redirect_header("partner.php", 1, _AM_SPARTNER_NOPARTNERSELECTED); exit; } switch ($partnerObj->status()) { case _SPARTNER_STATUS_SUBMITTED: $breadcrumb_action1 = _AM_SPARTNER_SUBMITTED_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_APPROVING; $page_title = _AM_SPARTNER_SUBMITTED_TITLE; $page_info = _AM_SPARTNER_SUBMITTED_INFO; $button_caption = _AM_SPARTNER_APPROVE; $new_status = _SPARTNER_STATUS_ACTIVE; break; case _SPARTNER_STATUS_ACTIVE: $breadcrumb_action1 = _AM_SPARTNER_ACTIVE_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_ACTIVE_EDITING; $page_info = _AM_SPARTNER_ACTIVE_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_ACTIVE; break; case _SPARTNER_STATUS_INACTIVE: $breadcrumb_action1 = _AM_SPARTNER_INACTIVE_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_INACTIVE_EDITING; $page_info = _AM_SPARTNER_INACTIVE_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_INACTIVE; break; case _SPARTNER_STATUS_REJECTED: $breadcrumb_action1 = _AM_SPARTNER_REJECTED_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_REJECTED_EDITING; $page_info = _AM_SPARTNER_REJECTED_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_REJECTED; break; case "default": default: break; } if ($showmenu) { smartpartner_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } echo "<br />\n"; smartpartner_collapsableBar('editpartner', 'editpartmericon', $page_title, $page_info); } else { // there's no parameter, so we're adding a partner $partnerObj =& $smartpartner_partner_handler->create(); $breadcrumb_action1 = _AM_SPARTNER_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_CREATE; $button_caption = _AM_SPARTNER_CREATE; $new_status = _SPARTNER_STATUS_ACTIVE; if ($showmenu) { smartpartner_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } smartpartner_collapsableBar('addpartner', 'addpartmericon', _AM_SPARTNER_PARTNER_CREATING, _AM_SPARTNER_PARTNER_CREATING_DSC); } // PARTNER FORM $sform = new XoopsThemeForm(_AM_SPARTNER_PARTNERS, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // TITLE $title_text = new XoopsFormText(_AM_SPARTNER_TITLE, 'title', 50, 255, $partnerObj->title('e')); $sform->addElement($title_text, true); // Parent Category $mytree = new SmartTree($xoopsDB->prefix("smartpartner_categories"), "categoryid", "parentid"); ob_start(); $mytree->makeMySelBox("name", "weight", explode('|', $partnerObj->categoryid()), 0, 'categoryid', '', true); //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="") $parent_cat_select = new XoopsFormLabel(_AM_SPARTNER_CATEGORY_BELONG, ob_get_contents()); $parent_cat_select->setDescription(_AM_SPARTNER_BELONG_CATEGORY_DSC); $sform->addElement($parent_cat_select); ob_end_clean(); // LOGO $logo_array =& XoopsLists::getImgListAsArray(smartpartner_getImageDir()); $logo_select = new XoopsFormSelect('', 'image', $partnerObj->image()); $logo_select->addOption('-1', '---------------'); $logo_select->addOptionArray($logo_array); $logo_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . SMARTPARTNER_DIRNAME . '/images' . "\", \"\", \"" . XOOPS_URL . "\")'"); $logo_tray = new XoopsFormElementTray(_AM_SPARTNER_LOGO, ' '); $logo_tray->addElement($logo_select); $logo_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartpartner_getImageDir('', false) . $partnerObj->image() . "' name='image3' id='image3' alt='' />")); $logo_tray->setDescription(_AM_SPARTNER_LOGO_DSC); $sform->addElement($logo_tray); // LOGO UPLOAD $max_size = 5000000; $file_box = new XoopsFormFile(_AM_SPARTNER_LOGO_UPLOAD, "logo_file", $max_size); $file_box->setExtra("size ='45'"); $file_box->setDescription(sprintf(_AM_SPARTNER_LOGO_UPLOAD_DSC, $xoopsModuleConfig['img_max_width'], $xoopsModuleConfig['img_max_height'])); $sform->addElement($file_box); // IMAGE_URL $image_url_text = new XoopsFormText(_CO_SPARTNER_IMAGE_URL, 'image_url', 50, 255, $partnerObj->image_url()); $image_url_text->setDescription(_CO_SPARTNER_IMAGE_URL_DSC); $sform->addElement($image_url_text, false); // URL $url_text = new XoopsFormText(_AM_SPARTNER_URL, 'url', 50, 255, $partnerObj->url()); $url_text->setDescription(_AM_SPARTNER_URL_DSC); $sform->addElement($url_text, false); // SUMMARY $summary_text = new XoopsFormTextArea(_AM_SPARTNER_SUMMARY, 'summary', $partnerObj->summary(0, 'e'), 7, 60); $summary_text->setDescription(_AM_SPARTNER_SUMMARY_DSC); $sform->addElement($summary_text, true); // SHOW summary on partner page $showsum_radio = new XoopsFormRadioYN(_AM_SPARTNER_SHOW_SUMMARY, 'showsummary', $partnerObj->getVar('showsummary')); $showsum_radio->setDescription(_AM_SPARTNER_SHOW_SUMMARY_DSC); $sform->addElement($showsum_radio); // DESCRIPTION $description_text = new XoopsFormDhtmlTextArea(_AM_SPARTNER_DESCRIPTION, 'description', $partnerObj->description(0, 'e'), 15, 60); $description_text->setDescription(_AM_SPARTNER_DESCRIPTION_DSC); $sform->addElement($description_text, false); // CONTACT_NAME $contact_name_text = new XoopsFormText(_CO_SPARTNER_CONTACT_NAME, 'contact_name', 50, 255, $partnerObj->contact_name('e')); $contact_name_text->setDescription(_CO_SPARTNER_CONTACT_NAME_DSC); $sform->addElement($contact_name_text, false); // CONTACT_EMAIL $contact_email_text = new XoopsFormText(_CO_SPARTNER_CONTACT_EMAIL, 'contact_email', 50, 255, $partnerObj->contact_email('e')); $contact_email_text->setDescription(_CO_SPARTNER_CONTACT_EMAIL_DSC); $sform->addElement($contact_email_text, false); // EMAIL_PRIV $email_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_EMAILPRIV, 'email_priv', $partnerObj->email_priv('e')); $email_priv_radio->setDescription(_CO_SPARTNER_CONTACT_EMAILPRIV_DSC); $sform->addElement($email_priv_radio); // CONTACT_PHONE $contact_phone_text = new XoopsFormText(_CO_SPARTNER_CONTACT_PHONE, 'contact_phone', 50, 255, $partnerObj->contact_phone('e')); $contact_phone_text->setDescription(_CO_SPARTNER_CONTACT_PHONE_DSC); $sform->addElement($contact_phone_text, false); // PHONE_PRIV $phone_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_PHONEPRIV, 'phone_priv', $partnerObj->phone_priv('e')); $phone_priv_radio->setDescription(_CO_SPARTNER_CONTACT_PHONEPRIV_DSC); $sform->addElement($phone_priv_radio); // ADRESS //$adress_text = new XoopsFormText(_CO_SPARTNER_ADRESS, 'adress', 50, 255, $partnerObj->adress('e')); $adress_text = new XoopsFormTextArea(_CO_SPARTNER_ADRESS, 'adress', $partnerObj->adress('e')); $adress_text->setDescription(_CO_SPARTNER_ADRESS_DSC); $sform->addElement($adress_text, false); // ADRESS_PRIV $adress_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_ADRESSPRIV, 'adress_priv', $partnerObj->adress_priv('e')); $adress_priv_radio->setDescription(_CO_SPARTNER_CONTACT_ADRESSPRIV_DSC); $sform->addElement($adress_priv_radio); // STATUS $options = $partnerObj->getAvailableStatus(); $status_select = new XoopsFormSelect(_AM_SPARTNER_STATUS, 'status', $new_status); $status_select->addOptionArray($options); $status_select->setDescription(_AM_SPARTNER_STATUS_DSC); $sform->addElement($status_select); // WEIGHT $weight_text = new XoopsFormText(_AM_SPARTNER_WEIGHT, 'weight', 4, 4, $partnerObj->weight()); $weight_text->setDescription(_AM_SPARTNER_WEIGHT_DSC); $sform->addElement($weight_text); //perms global $smartpermissions_handler; include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectpermission.php'; $smartpermissions_handler = new SmartobjectPermissionHandler($smartpartner_partner_handler); if ($partnerObj->id() != 0) { $grantedGroups = $smartpermissions_handler->getGrantedGroups('full_view', $partnerObj->id()); } else { $grantedGroups = $xoopsModuleConfig['default_full_view']; } $full_view_select = new XoopsFormSelectGroup(_CO_SPARTNER_FULL_PERM_READ, 'full_view', true, $grantedGroups, 5, true); $full_view_select->setDescription(_CO_SPARTNER_FULL_PERM_READ_DSC); $sform->addElement($full_view_select); if ($partnerObj->id() != 0) { $partGrantedGroups = $smartpermissions_handler->getGrantedGroups('partial_view', $partnerObj->id()); } else { $partGrantedGroups = $xoopsModuleConfig['default_part_view']; } $part_view_select = new XoopsFormSelectGroup(_CO_SPARTNER_PART_PERM_READ, 'partial_view', true, $partGrantedGroups, 5, true); $part_view_select->setDescription(_CO_SPARTNER_PART_PERM_READ_DSC); $sform->addElement($part_view_select); // Partner id $sform->addElement(new XoopsFormHidden('id', $partnerObj->id())); $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'addpartner'); $button_tray->addElement($hidden); $sform->addElement(new XoopsFormHidden('original_status', $partnerObj->status())); if (!$id) { // there's no id? Then it's a new partner // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_CREATE, 'submit' ) ); $butt_create = new XoopsFormButton('', '', _AM_SPARTNER_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SPARTNER_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } else { // else, we're editing an existing partner // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_MODIFY, 'submit' ) ); $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } $sform->addElement($button_tray); $sform->display(); unset($hidden); if (!$id) { smartpartner_close_collapsable('addpartner', 'addpartnericon'); } else { smartpartner_close_collapsable('editpartner', 'editpartnericon'); } if ($id != 0) { showfiles($partnerObj); } }
// Uploading the logo, if any // Retreive the filename to be uploaded if ($_FILES['logo_file']['name'] != "") { $filename = $_POST["xoops_upload_file"][0]; if (!empty($filename) || $filename != "") { global $xoopsModuleConfig; $max_size = 10000000; $max_imgwidth = $xoopsModuleConfig['img_max_width']; $max_imgheight = $xoopsModuleConfig['img_max_height']; $allowed_mimetypes = smartpartner_getAllowedImagesTypes(); include_once XOOPS_ROOT_PATH . "/class/uploader.php"; if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) { redirect_header('javascript:history.go(-1)', 2, _CO_SPARTNER_FILE_UPLOAD_ERROR); exit; } $uploader = new XoopsMediaUploader(smartpartner_getImageDir(), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($filename) && $uploader->upload()) { $partnerObj->setVar('image', $uploader->getSavedFileName()); } else { redirect_header('javascript:history.go(-1)', 2, _CO_SPARTNER_FILE_UPLOAD_ERROR . $uploader->getErrors()); exit; } } } // Putting the values in the partner object $partnerObj->setVar('id', isset($_POST['id']) ? intval($_POST['id']) : 0); $partnerObj->setVar('title', $_POST['title']); $partnerObj->setVar('summary', $_POST['summary']); $partnerObj->setVar('description', $_POST['description']); $partnerObj->setVar('contact_name', $_POST['contact_name']); $partnerObj->setVar('contact_email', $_POST['contact_email']);
function editpartner($showmenu = false, $id = 0) { global $partner_handler, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // If there is a parameter, and the id exists, retrieve data: we're editing a partner if ($id != 0) { // Creating the partner object $partnerObj = new SmartpartnerPartner($id); if ($partnerObj->notLoaded()) { redirect_header("partner.php", 1, _AM_SPARTNER_NOPARTNERSELECTED); exit; } switch ($partnerObj->status()) { case _SPARTNER_STATUS_SUBMITTED: $breadcrumb_action1 = _AM_SPARTNER_SUBMITTED_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_APPROVING; $page_title = _AM_SPARTNER_SUBMITTED_TITLE; $page_info = _AM_SPARTNER_SUBMITTED_INFO; $button_caption = _AM_SPARTNER_APPROVE; $new_status = _SPARTNER_STATUS_ACTIVE; break; case _SPARTNER_STATUS_ACTIVE: $breadcrumb_action1 = _AM_SPARTNER_ACTIVE_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_ACTIVE_EDITING; $page_info = _AM_SPARTNER_ACTIVE_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_ACTIVE; break; case _SPARTNER_STATUS_INACTIVE: $breadcrumb_action1 = _AM_SPARTNER_INACTIVE_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_INACTIVE_EDITING; $page_info = _AM_SPARTNER_INACTIVE_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_INACTIVE; break; case _SPARTNER_STATUS_REJECTED: $breadcrumb_action1 = _AM_SPARTNER_REJECTED_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_REJECTED_EDITING; $page_info = _AM_SPARTNER_REJECTED_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_REJECTED; break; case "default": default: break; } if ($showmenu) { smartpartner_adminMenu(1, $breadcrumb_action1 . " > " . $breadcrumb_action2); } echo "<br />\n"; smartpartner_collapsableBar('bottomtable', 'bottomtableicon'); echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . $page_title . "</h3>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $page_info . "</span>"; echo "<div id='bottomtable'>"; } else { // there's no parameter, so we're adding a partner $partnerObj =& $partner_handler->create(); $breadcrumb_action1 = _AM_SPARTNER_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_CREATE; $button_caption = _AM_SPARTNER_CREATE; $new_status = _SPARTNER_STATUS_ACTIVE; if ($showmenu) { smartpartner_adminMenu(1, $breadcrumb_action1 . " > " . $breadcrumb_action2); } smartpartner_collapsableBar('bottomtable', 'bottomtableicon'); echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . _AM_SPARTNER_PARTNER_CREATING . "</h3>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_SPARTNER_PARTNER_CREATING_DSC . "</span>"; echo "<div id='bottomtable'>"; } // PARTNER FORM $sform = new XoopsThemeForm(_AM_SPARTNER_PARTNERS, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // TITLE $title_text = new XoopsFormText(_AM_SPARTNER_TITLE_REQ, 'title', 50, 255, $partnerObj->title('e')); $sform->addElement($title_text, true); // LOGO $logo_array =& XoopsLists::getImgListAsArray(smartpartner_getImageDir()); $logo_select = new XoopsFormSelect('', 'image', $partnerObj->image()); $logo_select->addOption('-1', '---------------'); $logo_select->addOptionArray($logo_array); $logo_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . SMARTPARTNER_DIRNAME . '/images' . "\", \"\", \"" . XOOPS_URL . "\")'"); $logo_tray = new XoopsFormElementTray(_AM_SPARTNER_LOGO, ' '); $logo_tray->addElement($logo_select); $logo_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartpartner_getImageDir('', false) . $partnerObj->image() . "' name='image3' id='image3' alt='' />")); $logo_tray->setDescription(_AM_SPARTNER_LOGO_DSC); $sform->addElement($logo_tray); // LOGO UPLOAD $max_size = 5000000; $file_box = new XoopsFormFile(_AM_SPARTNER_LOGO_UPLOAD, "logo_file", $max_size); $file_box->setExtra("size ='45'"); $file_box->setDescription(sprintf(_AM_SPARTNER_LOGO_UPLOAD_DSC, $xoopsModuleConfig['img_max_width'], $xoopsModuleConfig['img_max_height'])); $sform->addElement($file_box); // IMAGE_URL $image_url_text = new XoopsFormText(_CO_SPARTNER_IMAGE_URL, 'image_url', 50, 255, $partnerObj->image_url()); $image_url_text->setDescription(_CO_SPARTNER_IMAGE_URL_DSC); $sform->addElement($image_url_text, false); // URL $url_text = new XoopsFormText(_AM_SPARTNER_URL, 'url', 50, 255, $partnerObj->url()); $url_text->setDescription(_AM_SPARTNER_URL_DSC); $sform->addElement($url_text, false); // SUMMARY $summary_text = new XoopsFormTextArea(_AM_SPARTNER_SUMMARY_REQ, 'summary', $partnerObj->summary(0, 'e'), 7, 60); $summary_text->setDescription(_AM_SPARTNER_SUMMARY_DSC); $sform->addElement($summary_text, true); // DESCRIPTION $description_text = new XoopsFormDhtmlTextArea(_AM_SPARTNER_DESCRIPTION, 'description', $partnerObj->description(0, 'e'), 15, 60); $description_text->setDescription(_AM_SPARTNER_DESCRIPTION_DSC); $sform->addElement($description_text, false); // CONTACT_NAME $contact_name_text = new XoopsFormText(_CO_SPARTNER_CONTACT_NAME, 'contact_name', 50, 255, $partnerObj->contact_name('e')); $contact_name_text->setDescription(_CO_SPARTNER_CONTACT_NAME_DSC); $sform->addElement($contact_name_text, false); // CONTACT_EMAIL $contact_email_text = new XoopsFormText(_CO_SPARTNER_CONTACT_EMAIL, 'contact_email', 50, 255, $partnerObj->contact_email('e')); $contact_email_text->setDescription(_CO_SPARTNER_CONTACT_EMAIL_DSC); $sform->addElement($contact_email_text, false); // CONTACT_PHONE $contact_phone_text = new XoopsFormText(_CO_SPARTNER_CONTACT_PHONE, 'contact_phone', 50, 255, $partnerObj->contact_phone('e')); $contact_phone_text->setDescription(_CO_SPARTNER_CONTACT_PHONE_DSC); $sform->addElement($contact_phone_text, false); // ADRESS //$adress_text = new XoopsFormText(_CO_SPARTNER_ADRESS, 'adress', 50, 255, $partnerObj->adress('e')); $adress_text = new XoopsFormTextArea(_CO_SPARTNER_ADRESS, 'adress', $partnerObj->adress('e')); $adress_text->setDescription(_CO_SPARTNER_ADRESS_DSC); $sform->addElement($adress_text, false); // STATUS $options = $partnerObj->getAvailableStatus(); $status_select = new XoopsFormSelect(_AM_SPARTNER_STATUS, 'status', $new_status); $status_select->addOptionArray($options); $status_select->setDescription(_AM_SPARTNER_STATUS_DSC); $sform->addElement($status_select); // WEIGHT $weight_text = new XoopsFormText(_AM_SPARTNER_WEIGHT, 'weight', 4, 4, $partnerObj->weight()); $weight_text->setDescription(_AM_SPARTNER_WEIGHT_DSC); $sform->addElement($weight_text); // TAGS if (file_exists($GLOBALS['xoops']->path('/modules/tag/include/formtag.php'))) { include_once $GLOBALS['xoops']->path('/modules/tag/include/formtag.php'); $tags_text = new XoopsFormTag("tags", 60, 255, $partnerObj->id(), $catid = 0); $sform->addElement($tags_text, false); } // DOMAINS if (file_exists($GLOBALS['xoops']->path('/modules/multisite/class/formselectdomains.php'))) { include_once $GLOBALS['xoops']->path('/modules/multisite/class/formselectdomains.php'); $domains_text = new XoopsFormSelectDomains(_CO_SPARTNER_DOMAINS, "domains", $partnerObj->getVar('domains'), 10, true); $domains_text->setDescription(_CO_SPARTNER_DOMAINS_DSC); $sform->addElement($domains_text, false); } // Partner id $sform->addElement(new XoopsFormHidden('id', $partnerObj->id())); $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'addpartner'); $button_tray->addElement($hidden); $sform->addElement(new XoopsFormHidden('original_status', $partnerObj->status())); if (!$id) { // there's no id? Then it's a new partner // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_CREATE, 'submit' ) ); $butt_create = new XoopsFormButton('', '', _AM_SPARTNER_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SPARTNER_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } else { // else, we're editing an existing partner // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_MODIFY, 'submit' ) ); $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } $sform->addElement($button_tray); $sform->display(); unset($hidden); echo "</div>"; }
function getImagePath() { if ($this->getVar('image') != '' && $this->getVar('image') != 'blank.png') { return smartpartner_getImageDir() . $this->image(); } else { return false; } }
function toArray($category = array()) { $category['categoryid'] = $this->categoryid(); $category['name'] = $this->name(); $category['categorylink'] = $this->getCategoryLink(); $category['total'] = $this->getVar('itemcount'); $category['description'] = $this->description(); if ($this->image() != 'blank.png') { $category['image_path'] = smartpartner_getImageDir('category', false) . $this->image(); } else { $category['image_path'] = ''; } return $category; }
function editcat($showmenu = false, $categoryid = 0, $nb_subcats = 4, $categoryObj = null) { global $xoopsDB, $smartpartner_category_handler, $xoopsUser, $myts, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // If there is a parameter, and the id exists, retrieve data: we're editing a category if ($categoryid != 0) { // Creating the category object for the selected category //$categoryObj = new SmartpartnerCategory($categoryid); $categoryObj = $smartpartner_category_handler->get($categoryid); if ($showmenu) { smartpartner_adminMenu(1, _AM_SPARTNER_CATEGORIES . " > " . _AM_SPARTNER_EDITING); } echo "<br />\n"; if ($categoryObj->notLoaded()) { redirect_header("category.php", 1, _AM_SPARTNER_NOCOLTOEDIT); exit; } smartpartner_collapsableBar('edittable', 'edittableicon', _AM_SPARTNER_CATEGORY_EDIT, _AM_SPARTNER_CATEGORY_EDIT_INFO); } else { if (!$categoryObj) { $categoryObj = $smartpartner_category_handler->create(); } if ($showmenu) { smartpartner_adminMenu(1, _AM_SPARTNER_CATEGORIES . " > " . _AM_SPARTNER_CATEGORY_CREATING); } //echo "<br />\n"; smartpartner_collapsableBar('createtable', 'createtableicon', _AM_SPARTNER_CATEGORY_CREATE, _AM_SPARTNER_CATEGORY_CREATE_INFO); } // Start category form $mytree = new XoopsTree($xoopsDB->prefix("smartpartner_categories"), "categoryid", "parentid"); $sform = new XoopsThemeForm(_AM_SPARTNER_CATEGORY, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // Name $sform->addElement(new XoopsFormText(_AM_SPARTNER_CATEGORY, 'name', 50, 255, $categoryObj->name('e')), true); // Description $sform->addElement(new XoopsFormTextArea(_AM_SPARTNER_CATEGORY_DSC, 'description', $categoryObj->description('e'), 7, 60)); // IMAGE $image_array =& XoopsLists::getImgListAsArray(smartpartner_getImageDir('category')); $image_select = new XoopsFormSelect('', 'image', $categoryObj->image()); $image_select->addOption('-1', '---------------'); $image_select->addOptionArray($image_array); $image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/smartpartner/images/category/' . "\", \"\", \"" . XOOPS_URL . "\")'"); $image_tray = new XoopsFormElementTray(_AM_SPARTNER_CATEGORY_IMAGE, ' '); $image_tray->addElement($image_select); $image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartpartner_getImageDir('category', false) . $categoryObj->image() . "' name='image3' id='image3' alt='' />")); $image_tray->setDescription(_AM_SPARTNER_CATEGORY_IMAGE_DSC); $sform->addElement($image_tray); // IMAGE UPLOAD $max_size = 5000000; $file_box = new XoopsFormFile(_AM_SPARTNER_CATEGORY_IMAGE_UPLOAD, "image_file", $max_size); $file_box->setExtra("size ='45'"); $file_box->setDescription(_AM_SPARTNER_CATEGORY_IMAGE_UPLOAD_DSC); $sform->addElement($file_box); // Weight $sform->addElement(new XoopsFormText(_AM_SPARTNER_CATEGORY_WEIGHT, 'weight', 4, 4, $categoryObj->weight())); $member_handler =& xoops_gethandler('member'); $group_list =& $member_handler->getGroupList(); $module_id = $xoopsModule->getVar('mid'); // Parent Category ob_start(); $mytree->makeMySelBox("name", "weight", $categoryObj->parentid(), 1, 'parentid'); //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="") $parent_cat_select = new XoopsFormLabel(_AM_SPARTNER_CATEGORY_PARENT, ob_get_contents()); $parent_cat_select->setDescription(_AM_SPARTNER_CATEGORY_PARENT_DSC); $sform->addElement($parent_cat_select); ob_end_clean(); // Added by fx2024 // sub Categories $cat_tray = new XoopsFormElementTray(_AM_SPARTNER_CATEGORY_SUBCATS_CREATE, '<br /><br />'); $cat_tray->setDescription(_AM_SPARTNER_CATEGORY_SUBCATS_CREATE_DSC); for ($i = 0; $i < $nb_subcats; $i++) { if ($i < (isset($_POST['scname']) ? sizeof($_POST['scname']) : 0)) { $subname = isset($_POST['scname']) ? $_POST['scname'][$i] : ''; } else { $subname = ''; } $cat_tray->addElement(new XoopsFormText('', 'scname[' . $i . ']', 50, 255, $subname), true); } $t = new XoopsFormText('', 'nb_subcats', 3, 2); $l = new XoopsFormLabel('', sprintf(_AM_SPARTNER_ADD_OPT, $t->render())); $b = new XoopsFormButton('', 'submit', _AM_SPARTNER_ADD_OPT_SUBMIT, 'submit'); if ($categoryid == 0) { $b->setExtra('onclick="this.form.elements.op.value=\'addsubcats\'"'); } else { $b->setExtra('onclick="this.form.elements.op.value=\'mod\'"'); } $r = new XoopsFormElementTray(''); $r->addElement($l); $r->addElement($b); $cat_tray->addElement($r); $sform->addElement($cat_tray); //End of fx2024 code /*$gperm_handler = &xoops_gethandler('groupperm'); $mod_perms = $gperm_handler->getGroupIds('category_moderation', $categoryid, $module_id); $moderators_select = new XoopsFormSelect('', 'moderators', $moderators, 5, true); $moderators_tray->addElement($moderators_select); $butt_mngmods = new XoopsFormButton('', '', 'Manage mods', 'button'); $butt_mngmods->setExtra('onclick="javascript:small_window(\'pop.php\', 370, 350);"'); $moderators_tray->addElement($butt_mngmods); $butt_delmod = new XoopsFormButton('', '', 'Delete mod', 'button'); $butt_delmod->setExtra('onclick="javascript:deleteSelectedItemsFromList(this.form.elements[\'moderators[]\']);"'); $moderators_tray->addElement($butt_delmod); $sform->addElement($moderators_tray); */ $sform->addElement(new XoopsFormHidden('categoryid', $categoryid)); //$parentid = $categoryObj->parentid('s'); //$sform -> addElement( new XoopsFormHidden( 'parentid', $parentid ) ); $sform->addElement(new XoopsFormHidden('nb_sub_yet', $nb_subcats)); // Action buttons tray $button_tray = new XoopsFormElementTray('', ''); /*for ($i = 0; $i < sizeof($moderators); $i++) { $allmods[] = $moderators[$i]; } $hiddenmods = new XoopsFormHidden('allmods', $allmods); $button_tray->addElement($hiddenmods); */ $hidden = new XoopsFormHidden('op', 'addcategory'); $button_tray->addElement($hidden); // No ID for category -- then it's new category, button says 'Create' if (!$categoryid) { $butt_create = new XoopsFormButton('', '', _AM_SPARTNER_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SPARTNER_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $sform->addElement($button_tray); $sform->display(); smartpartner_close_collapsable('createtable', 'createtableicon'); } else { // button says 'Update' $butt_create = new XoopsFormButton('', '', _AM_SPARTNER_MODIFY, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $sform->addElement($button_tray); $sform->display(); smartpartner_close_collapsable('edittable', 'edittableicon'); } /* //Added by fx2024 if ($categoryid) { // TODO : displaysubcats comes from smartpartner and need to be adapted for smartpartner include_once XOOPS_ROOT_PATH . "/modules/smartpartner/include/displaysubcats.php"; // TODO : displayitems comes from smartpartner and need to be adapted for smartpartner //include_once XOOPS_ROOT_PATH . "/modules/smartpartner/include/displayitems.php"; } //end of fx2024 code */ unset($hidden); }