本文整理汇总了PHP中Import::initFileSelectTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP Import::initFileSelectTemplate方法的具体用法?PHP Import::initFileSelectTemplate怎么用?PHP Import::initFileSelectTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Import
的用法示例。
在下文中一共展示了Import::initFileSelectTemplate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importuser
function importuser()
{
global $objDatabase, $_ARRAYLANG;
$objTpl = new \Cx\Core\Html\Sigma(ASCMS_MODULE_PATH . '/Newsletter/View/Template/Backend');
\Cx\Core\Csrf\Controller\Csrf::add_placeholder($objTpl);
$objTpl->setErrorHandling(PEAR_ERROR_DIE);
\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/importexport/import.class.php');
$objImport = new \Import();
$arrFields = array('email' => $_ARRAYLANG['TXT_NEWSLETTER_EMAIL_ADDRESS'], 'sex' => $_ARRAYLANG['TXT_NEWSLETTER_SEX'], 'salutation' => $_ARRAYLANG['TXT_NEWSLETTER_SALUTATION'], 'title' => $_ARRAYLANG['TXT_NEWSLETTER_TITLE'], 'lastname' => $_ARRAYLANG['TXT_NEWSLETTER_LASTNAME'], 'firstname' => $_ARRAYLANG['TXT_NEWSLETTER_FIRSTNAME'], 'position' => $_ARRAYLANG['TXT_NEWSLETTER_POSITION'], 'company' => $_ARRAYLANG['TXT_NEWSLETTER_COMPANY'], 'industry_sector' => $_ARRAYLANG['TXT_NEWSLETTER_INDUSTRY_SECTOR'], 'address' => $_ARRAYLANG['TXT_NEWSLETTER_ADDRESS'], 'zip' => $_ARRAYLANG['TXT_NEWSLETTER_ZIP'], 'city' => $_ARRAYLANG['TXT_NEWSLETTER_CITY'], 'country_id' => $_ARRAYLANG['TXT_NEWSLETTER_COUNTRY'], 'phone_office' => $_ARRAYLANG['TXT_NEWSLETTER_PHONE'], 'phone_private' => $_ARRAYLANG['TXT_NEWSLETTER_PHONE_PRIVATE'], 'phone_mobile' => $_ARRAYLANG['TXT_NEWSLETTER_PHONE_MOBILE'], 'fax' => $_ARRAYLANG['TXT_NEWSLETTER_FAX'], 'birthday' => $_ARRAYLANG['TXT_NEWSLETTER_BIRTHDAY'], 'uri' => $_ARRAYLANG['TXT_NEWSLETTER_WEBSITE'], 'notes' => $_ARRAYLANG['TXT_NEWSLETTER_NOTES'], 'language' => $_ARRAYLANG['TXT_NEWSLETTER_LANGUAGE']);
if (isset($_POST['import_cancel'])) {
// Abbrechen. Siehe Abbrechen
$objImport->cancel();
\Cx\Core\Csrf\Controller\Csrf::header("Location: index.php?cmd=Newsletter&act=users&tpl=import");
exit;
} elseif (isset($_POST['fieldsSelected'])) {
// Speichern der Daten. Siehe Final weiter unten.
$arrRecipients = $objImport->getFinalData($arrFields);
if (empty($_POST['newsletter_recipient_associated_list'])) {
self::$strErrMessage = $_ARRAYLANG['TXT_NEWSLETTER_SELECT_CATEGORY'];
} else {
$arrLists = array();
if (isset($_POST['newsletter_recipient_associated_list'])) {
foreach (explode(',', $_POST['newsletter_recipient_associated_list']) as $listId) {
array_push($arrLists, intval($listId));
}
}
$EmailCount = 0;
$arrBadEmails = array();
$ExistEmails = 0;
$NewEmails = 0;
$recipientSendEmailId = isset($_POST['sendEmail']) ? intval($_POST['sendEmail']) : 0;
foreach ($arrRecipients as $arrRecipient) {
if (empty($arrRecipient['email'])) {
continue;
}
if (!strpos($arrRecipient['email'], '@')) {
continue;
}
$arrRecipient['email'] = trim($arrRecipient['email']);
if (!\FWValidator::isEmail($arrRecipient['email'])) {
array_push($arrBadEmails, $arrRecipient['email']);
} else {
$EmailCount++;
$arrRecipientLists = $arrLists;
// TODO: use FWUSER
if (in_array($arrRecipient['salutation'], $this->_getRecipientTitles())) {
$arrRecipientTitles = array_flip($this->_getRecipientTitles());
$recipientSalutationId = $arrRecipientTitles[$arrRecipient['salutation']];
} else {
$recipientSalutationId = $this->_addRecipientTitle($arrRecipient['salutation']);
}
// try to parse the imported birthday in a usable format
if (!empty($arrRecipient['birthday'])) {
$arrDate = date_parse($arrRecipient['birthday']);
$arrRecipient['birthday'] = $arrDate['day'] . '-' . $arrDate['month'] . '-' . $arrDate['year'];
}
$objRecipient = $objDatabase->SelectLimit("SELECT `id`,\n `language`,\n `status`,\n `notes`\n FROM `" . DBPREFIX . "module_newsletter_user`\n WHERE `email` = '" . addslashes($arrRecipient['email']) . "'", 1);
if ($objRecipient->RecordCount() == 1) {
$recipientId = $objRecipient->fields['id'];
$recipientLanguage = $objRecipient->fields['language'];
$recipientStatus = $objRecipient->fields['status'];
$recipientNotes = !empty($objRecipient->fields['notes']) ? $objRecipient->fields['notes'] . ' ' . $arrRecipient['notes'] : $arrRecipient['notes'];
$objList = $objDatabase->Execute("SELECT `category` FROM " . DBPREFIX . "module_newsletter_rel_user_cat WHERE user=" . $recipientId);
if ($objList !== false) {
while (!$objList->EOF) {
array_push($arrRecipientLists, $objList->fields['category']);
$objList->MoveNext();
}
}
$arrRecipientLists = array_unique($arrRecipientLists);
$recipientAttributeStatus = array();
$this->_updateRecipient($recipientAttributeStatus, $recipientId, $arrRecipient['email'], $arrRecipient['uri'], $arrRecipient['sex'], $recipientSalutationId, $arrRecipient['title'], $arrRecipient['lastname'], $arrRecipient['firstname'], $arrRecipient['position'], $arrRecipient['company'], $arrRecipient['industry_sector'], $arrRecipient['address'], $arrRecipient['zip'], $arrRecipient['city'], $arrRecipient['country_id'], $arrRecipient['phone_office'], $arrRecipient['phone_private'], $arrRecipient['phone_mobile'], $arrRecipient['fax'], $recipientNotes, $arrRecipient['birthday'], $recipientStatus, $arrRecipientLists, $recipientLanguage);
$ExistEmails++;
} else {
$NewEmails++;
if (!$this->_addRecipient($arrRecipient['email'], $arrRecipient['uri'], $arrRecipient['sex'], $recipientSalutationId, $arrRecipient['title'], $arrRecipient['lastname'], $arrRecipient['firstname'], $arrRecipient['position'], $arrRecipient['company'], $arrRecipient['industry_sector'], $arrRecipient['address'], $arrRecipient['zip'], $arrRecipient['city'], $arrRecipient['country_id'], $arrRecipient['phone_office'], $arrRecipient['phone_private'], $arrRecipient['phone_mobile'], $arrRecipient['fax'], $arrRecipient['notes'], $arrRecipient['birthday'], 1, $arrRecipientLists, $arrRecipient['language'])) {
array_push($arrBadEmails, $arrRecipient['email']);
} elseif (!empty($recipientSendEmailId)) {
$objRecipient = $objDatabase->SelectLimit("\n SELECT id\n FROM " . DBPREFIX . "module_newsletter_user\n WHERE email='" . contrexx_input2db($arrRecipient['email']) . "'", 1);
$recipientId = $objRecipient->fields['id'];
$this->insertTmpEmail($recipientSendEmailId, $arrRecipient['email'], self::USER_TYPE_NEWSLETTER);
// setting TmpEntry=1 will set the newsletter status=1, this will force an imediate stop in the newsletter send procedere.
if ($this->SendEmail($recipientId, $recipientSendEmailId, $arrRecipient['email'], 1, self::USER_TYPE_NEWSLETTER) == false) {
self::$strErrMessage .= $_ARRAYLANG['TXT_SENDING_MESSAGE_ERROR'];
} else {
// TODO: Unused
// $objUpdateCount =
$objDatabase->execute('
UPDATE ' . DBPREFIX . 'module_newsletter
SET recipient_count = recipient_count+1
WHERE id=' . intval($recipientSendEmailId));
}
}
}
}
}
self::$strOkMessage = $_ARRAYLANG['TXT_DATA_IMPORT_SUCCESSFUL'] . "<br/>" . $_ARRAYLANG['TXT_CORRECT_EMAILS'] . ": " . $EmailCount . "<br/>" . $_ARRAYLANG['TXT_NOT_VALID_EMAILS'] . ": " . implode(', ', $arrBadEmails) . "<br/>" . $_ARRAYLANG['TXT_EXISTING_EMAILS'] . ": " . $ExistEmails . "<br/>" . $_ARRAYLANG['TXT_NEW_ADDED_EMAILS'] . ": " . $NewEmails;
$objImport->initFileSelectTemplate($objTpl);
$objTpl->setVariable(array("IMPORT_ACTION" => "index.php?cmd=Newsletter&act=users&tpl=import", 'TXT_FILETYPE' => $_ARRAYLANG['TXT_NEWSLETTER_FILE_TYPE'], 'TXT_HELP' => $_ARRAYLANG['TXT_NEWSLETTER_IMPORT_HELP'], 'IMPORT_ADD_NAME' => $_ARRAYLANG['TXT_NEWSLETTER_SEND_EMAIL'], 'IMPORT_ADD_VALUE' => $this->_getEmailsDropDown(), 'IMPORT_ROWCLASS' => 'row1'));
$objTpl->parse("additional");
//.........这里部分代码省略.........
示例2: elseif
/**
* Import
*
* Shows the import dialog
* Customer.
* @access private
* @global ADONewConnection
* @global array
*/
function _import()
{
global $objDatabase, $_ARRAYLANG;
\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/importexport/import.class.php');
$importlib = new \Import();
if (isset($_POST['import_cancel'])) {
$importlib->cancel();
\Cx\Core\Csrf\Controller\Csrf::header("Location: index.php?cmd=MemberDir&act=import");
exit;
} elseif ($_POST['fieldsSelected']) {
$fieldnames = $this->getFieldData($_POST['directory']);
foreach ($fieldnames as $fieldKey => $fieldValue) {
if ($fieldValue['active']) {
$fields[$fieldKey] = $fieldValue['name'];
}
}
$data = $importlib->getFinalData($fields);
foreach ($data as $row) {
$query = "INSERT INTO " . DBPREFIX . "module_memberdir_values\n (`dirid`, `pic1`, `pic2`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`,\n `10`, `11`, `12`, `13`, `14`, `15`, `16`, `17`, `18`, `lang_id`) VALUES\n ('" . $_POST['directory'] . "',\n 'none', 'none',\n '" . $this->getDbInput($row[1]) . "',\n '" . $this->getDbInput($row[2]) . "',\n '" . $this->getDbInput($row[3]) . "',\n '" . $this->getDbInput($row[4]) . "',\n '" . $this->getDbInput($row[5]) . "',\n '" . $this->getDbInput($row[6]) . "',\n '" . $this->getDbInput($row[7]) . "',\n '" . $this->getDbInput($row[8]) . "',\n '" . $this->getDbInput($row[9]) . "',\n '" . $this->getDbInput($row[10]) . "',\n '" . $this->getDbInput($row[11]) . "',\n '" . $this->getDbInput($row[12]) . "',\n '" . $this->getDbInput($row[13]) . "',\n '" . $this->getDbInput($row[14]) . "',\n '" . $this->getDbInput($row[15]) . "',\n '" . $this->getDbInput($row[16]) . "',\n '" . $this->getDbInput($row[17]) . "',\n '" . $this->getDbInput($row[18]) . "',\n '" . $this->langId . "')\n ";
if (!$objDatabase->Execute($query)) {
echo $objDatabase->ErrorMsg();
}
\Cx\Core\Csrf\Controller\Csrf::header("Location: index.php?cmd=MemberDir&act=showdir&id=" . $_POST['directory']);
}
} elseif ($_FILES['importfile']['size'] == 0) {
$importlib->initFileSelectTemplate($this->_objTpl);
/*
* We need an additional input field for the selection
* of the directory
*/
$this->_objTpl->setVariable(array("IMPORT_ACTION" => "?cmd=MemberDir&act=import", "IMPORT_ADD_NAME" => $_ARRAYLANG['TXT_DIRECTORY'], "IMPORT_ADD_VALUE" => $this->dirList('directory', $this->firstDir, 200), "IMPORT_ROWCLASS" => "row1", "TXT_HELP" => $_ARRAYLANG['TXT_IMPORT_HELP']));
$this->_objTpl->parse("additional");
} else {
$fieldnames = $this->getFieldData($_POST['directory']);
foreach ($fieldnames as $key => $value) {
if ($value['active']) {
$given_fields[$key] = $value['name'];
}
}
$importlib->initFieldSelectTemplate($this->_objTpl, $given_fields);
/*
* We need to pass the directory value, given by the
* file selection template to the next step of importing
*/
$this->_objTpl->setVariable(array("IMPORT_HIDDEN_NAME" => "directory", "IMPORT_HIDDEN_VALUE" => $_POST['directory']));
}
}