本文整理汇总了PHP中CsviHelper::replaceValue方法的典型用法代码示例。如果您正苦于以下问题:PHP CsviHelper::replaceValue方法的具体用法?PHP CsviHelper::replaceValue怎么用?PHP CsviHelper::replaceValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsviHelper
的用法示例。
在下文中一共展示了CsviHelper::replaceValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStart
/**
* Waiting list export
*
* @copyright
* @author RolandD
* @todo
* @see
* @access public
* @param
* @return void
* @since 3.1
*/
public function getStart()
{
// Get some basic data
$db = JFactory::getDbo();
$csvidb = new CsviDb();
$jinput = JFactory::getApplication()->input;
$csvilog = $jinput->get('csvilog', null, null);
$template = $jinput->get('template', null, null);
$exportclass = $jinput->get('export.class', null, null);
$export_fields = $jinput->get('export.fields', array(), 'array');
// Build something fancy to only get the fieldnames the user wants
$userfields = array();
foreach ($export_fields as $column_id => $field) {
if ($field->process) {
switch ($field->field_name) {
case 'virtuemart_user_id':
case 'virtuemart_product_id':
case 'created_on':
case 'modified_on':
case 'locked_on':
case 'created_by':
case 'modified_by':
case 'locked_by':
$userfields[] = $db->quoteName('#__virtuemart_waitingusers') . '.' . $db->quoteName($field->field_name);
break;
// Man made fields, do not export them
// Man made fields, do not export them
case 'custom':
case 'username':
break;
default:
$userfields[] = $db->quoteName($field->field_name);
break;
}
}
}
// Build the query
$userfields = array_unique($userfields);
$query = $db->getQuery(true);
$query->select(implode(",\n", $userfields));
$query->from('#__virtuemart_waitingusers');
$query->leftJoin('#__virtuemart_products ON #__virtuemart_products.virtuemart_product_id = #__virtuemart_waitingusers.virtuemart_product_id');
$query->leftJoin('#__users ON #__users.id = #__virtuemart_waitingusers.virtuemart_user_id');
// Ignore fields
$ignore = array('custom', 'username');
// Check if we need to group the orders together
$groupby = $template->get('groupby', 'general', false, 'bool');
if ($groupby) {
$filter = $this->getFilterBy('groupby', $ignore);
if (!empty($filter)) {
$query->group($filter);
}
}
// Order by set field
$orderby = $this->getFilterBy('sort', $ignore);
if (!empty($orderby)) {
$query->order($orderby);
}
// Add export limits
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
$jinput->set('logcount', $logcount);
if ($logcount > 0) {
$linenumber = 1;
while ($record = $csvidb->getRow()) {
$csvilog->setLinenumber($linenumber++);
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
foreach ($export_fields as $column_id => $field) {
$fieldname = $field->field_name;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'created_on':
//.........这里部分代码省略.........
示例2: getStart
//.........这里部分代码省略.........
ON #__vm_product_product_type_xref.product_type_id = #__vm_product_type.product_type_id
LEFT JOIN #__virtuemart_products
ON #__vm_product_product_type_xref.product_id = #__virtuemart_products.virtuemart_product_id ';
// Add the product type X tables
$q .= "\nLEFT JOIN #__" . $vmid . " ON #__" . $vmid . ".product_id = #__virtuemart_products.virtuemart_product_id " . "\n";
// Check if there are any selectors
$selectors = array();
// Add product type ID checks
if (is_int($filterid)) {
$selectors[] = '#__vm_product_type.product_type_id = ' . $filterid;
}
// Filter by product type name
if ($producttypeid) {
$selectors[] = '#__vm_product_type.product_type_id IN (' . implode(',', $producttypeid) . ')';
}
// Check if we need to attach any selectors to the query
if (count($selectors) > 0) {
$q .= ' WHERE ' . implode(' AND ', $selectors) . "\n";
}
// Special field treatment
$special = array();
$special['product_sku'] = $db->qn('#__virtuemart_products') . '.' . $db->qn('product_sku');
$special['product_id'] = $db->qn('#__virtuemart_products') . '.' . $db->qn('virtuemart_product_id');
$special['product_type_name'] = $db->qn('#__vm_product_type') . '.' . $db->qn('product_type_name');
$special['product_type_id'] = $db->qn('#__vm_product_type') . '.' . $db->qn('product_type_id');
// Check if we need to group the orders together
$groupby = $template->get('groupby', 'general', false, 'bool');
if ($groupby) {
$filter = $this->getFilterBy('groupby', $ignore, $special);
if (!empty($filter)) {
$q .= " GROUP BY " . $filter;
}
}
// Order by set field
$orderby = $this->getFilterBy('sort', $ignore, $special);
if (!empty($orderby)) {
$q .= " ORDER BY " . $orderby;
}
$queries[] = $q . ')';
}
// Create the full query
$q = implode("\nUNION\n", $queries);
// Add export limits
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($q, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
$jinput->set('logcount', $logcount);
if ($logcount > 0) {
while ($record = $csvidb->getRow()) {
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
foreach ($export_fields as $column_id => $field) {
if ($field->process) {
$fieldname = $field->field_name;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
default:
// Check if we have any content otherwise use the default value
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$record->output[$column_id] = $fieldvalue;
break;
}
}
}
// Output the data
$this->addExportFields($record);
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeEnd());
}
// Output the contents
$this->writeOutput();
}
} else {
$this->addExportContent(JText::_('COM_CSVI_NO_DATA_FOUND'));
// Output the contents
$this->writeOutput();
}
}
} else {
$this->addExportContent(JText::_('COM_CSVI_NO_DATA_FOUND'));
$this->writeOutput();
$csvilog->AddStats('incorrect', $db->getErrorMsg());
}
}
示例3: getStart
/**
* Customfields tables export
*
* Exports category details data to either csv, xml or HTML format
*
* @copyright
* @author RolandD
* @todo
* @see
* @access public
* @param
* @return void
* @since 3.0
*/
public function getStart()
{
// Get some basic data
$db = JFactory::getDbo();
$csvidb = new CsviDb();
$jinput = JFactory::getApplication()->input;
$csvilog = $jinput->get('csvilog', null, null);
$template = $jinput->get('template', null, null);
$exportclass = $jinput->get('export.class', null, null);
$export_fields = $jinput->get('export.fields', array(), 'array');
// Build something fancy to only get the fieldnames the user wants
$userfields = array();
foreach ($export_fields as $column_id => $field) {
switch ($field->field_name) {
case 'id':
$userfields[] = $db->qn('c.id');
break;
case 'custom_title':
$userfields[] = $db->qn('c.vm_custom_id');
break;
case 'display_type':
$userfields[] = $db->qn('c.type_id');
$userfields[] = $db->qn('f.type', 'display_type');
break;
case 'smart_search':
case 'expanded':
case 'scrollbar_after':
$userfields[] = $db->qn('c.params');
break;
case 'custom':
break;
default:
$userfields[] = $db->qn($field->field_name);
break;
}
}
// Export SQL Query
// Build the query
$userfields = array_unique($userfields);
$query = $db->getQuery(true);
$query->select(implode(",\n", $userfields));
$query->from($db->qn("#__cf_customfields", "c"));
$query->leftJoin($db->qn("#__cf_filtertypes", "f") . " ON " . $db->qn("c") . '.' . $db->qn("type_id") . ' = ' . $db->qn("f") . '.' . $db->qn("id"));
// Ingore fields
$ignore = array('custom', 'custom_title', 'display_type', 'smart_search', 'smart_search', 'expanded', 'scrollbar_after');
// Check if we need to group the orders together
$groupby = $template->get('groupby', 'general', false, 'bool');
if ($groupby) {
$filter = $this->getFilterBy('groupby', $ignore);
if (!empty($filter)) {
$query->group($filter);
}
}
// Order by set field
$orderby = $this->getFilterBy('sort', $ignore);
if (!empty($orderby)) {
$query->order($orderby);
}
// Add a limit if user wants us to
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
$jinput->set('logcount', $logcount);
if ($logcount > 0) {
while ($record = $csvidb->getRow()) {
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
foreach ($export_fields as $column_id => $field) {
$fieldname = $field->field_name;
$fieldreplace = $field->field_name . $field->column_header;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
//.........这里部分代码省略.........
示例4: getStart
//.........这里部分代码省略.........
if (!empty($filter)) {
$query->group($filter);
}
}
// Order by set field
$orderby = $this->getFilterBy('sort', $ignore);
if (!empty($orderby)) {
$query->order($orderby);
}
// Add export limits
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
JRequest::setVar('logcount', array('export' => $logcount));
if ($logcount > 0) {
$linenumber = 1;
while ($record = $csvidb->getRow()) {
$csvilog->setLinenumber($linenumber++);
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
foreach ($export_fields as $column_id => $field) {
$fieldname = $field->field_name;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'created_on':
case 'modified_on':
case 'locked_on':
case 'lastvisitdate':
$date = JFactory::getDate($record->{$fieldname});
$fieldvalue = CsviHelper::replaceValue($field->replace, date($template->get('export_date_format', 'general'), $date->toUnix()));
$this->addExportField($field->combine, $fieldvalue, $fieldname, $field->column_header);
break;
case 'address_type':
// Check if we have any content otherwise use the default value
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
if ($fieldvalue == 'BT') {
$fieldvalue = JText::_('COM_CSVI_BILLING_ADDRESS');
} else {
if ($fieldvalue == 'ST') {
$fieldvalue = JText::_('COM_CSVI_SHIPPING_ADDRESS');
}
}
$this->addExportField($field->combine, $fieldvalue, $fieldname, $field->column_header);
break;
case 'full_name':
$fieldvalue = str_replace(' ', ' ', $record->first_name . ' ' . $record->middle_name . ' ' . $record->last_name);
$fieldvalue = CsviHelper::replaceValue($field->replace, $fieldvalue);
// Check if we have any content otherwise use the default value
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
示例5: getStart
//.........这里部分代码省略.........
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
JRequest::setVar('logcount', $logcount);
if ($logcount > 0) {
$linenumber = 1;
$shipment_params = array();
while ($record = $csvidb->getRow()) {
$csvilog->setLinenumber($linenumber++);
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
// Check if the shipment params need to be converted
if (isset($record->shipment_params)) {
$ship_params = explode('|', $record->shipment_params);
array_pop($ship_params);
foreach ($ship_params as $param) {
list($name, $value) = explode('=', $param);
$shipment_params[$name] = $value;
}
}
foreach ($export_fields as $column_id => $field) {
$fieldname = $field->field_name;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'shipment_name':
case 'shipment_desc':
case 'slug':
$query = $db->getQuery(true);
$query->select($fieldname);
$query->from('#__virtuemart_shipmentmethods_' . $template->get('language', 'general'));
$query->where('virtuemart_shipmentmethod_id = ' . $record->virtuemart_shipmentmethod_id);
$db->setQuery($query);
$fieldvalue = $db->loadResult();
// Check if we have any content otherwise use the default value
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$this->addExportField($field->combine, $fieldvalue, $fieldname, $field->column_header, true);
break;
case 'shipment_logos':
case 'countries':
$fieldvalue = json_decode($shipment_params[$fieldname]);
if (!empty($fieldvalue)) {
$fieldvalue = implode(',', $fieldvalue);
}
$fieldvalue = CsviHelper::replaceValue($field->replace, $fieldvalue);
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$this->addExportField($field->combine, $fieldvalue, $fieldname, $field->column_header, true);
break;
case 'zip_start':
示例6: getStart
//.........这里部分代码省略.........
$logcount = $csvidb->getNumRows();
JRequest::setVar('logcount', $logcount);
if ($logcount > 0) {
$linenumber = 1;
while ($record = $csvidb->getRow()) {
$csvilog->setLinenumber($linenumber++);
// Start the XML/HTML output
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
// Load JoomFish translation if needed
$joomfish = array();
if ($template->get('use_joomfish', 'product', false)) {
$jfdb = JFactory::getDBO();
// Get the product details
$q = "SELECT value, reference_field\r\n\t\t\t\t\t\t\tFROM #__jf_content\r\n\t\t\t\t\t\t\tWHERE reference_table = 'vm_product'\r\n\t\t\t\t\t\t\tAND language_id = " . $template->get('joomfish_language', 'product') . "\r\n\t\t\t\t\t\t\tAND reference_id = " . $record->main_product_id;
$jfdb->setQuery($q);
$joomfish = $jfdb->loadObjectList('reference_field');
}
// Reset the prices
$this->_prices = array();
// Process all the export fields
foreach ($export_fields as $column_id => $field) {
if ($field->process) {
$fieldname = $field->field_name;
// Add the replacement & JoomFish
if (isset($record->{$fieldname})) {
// Get the JoomFish data
if (array_key_exists($fieldname, $joomfish)) {
$fieldvalue = $joomfish[$fieldname]->value;
} else {
$fieldvalue = $record->{$fieldname};
}
$fieldvalue = CsviHelper::replaceValue($field->replace, $fieldvalue);
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'category_id':
$category_path = trim($helper->createCategoryPath($record->virtuemart_product_id, true));
if (strlen(trim($category_path)) == 0) {
$category_path = $field->default_value;
}
$category_path = CsviHelper::replaceValue($field->replace, $category_path);
$this->addExportField($field->combine, $category_path, $fieldname, $field->column_header, true);
break;
case 'category_path':
$category_path = trim($helper->createCategoryPath($record->virtuemart_product_id));
if (strlen(trim($category_path)) == 0) {
$category_path = $field->default_value;
}
$category_path = CsviHelper::replaceValue($field->replace, $category_path);
$this->addExportField($field->combine, $category_path, $fieldname, $field->column_header, true);
break;
case 'product_name':
case 'product_s_desc':
case 'product_desc':
case 'metadesc':
case 'metakey':
case 'slug':
case 'customtitle':
$query = $db->getQuery(true);
$query->select($fieldname);
$query->from('#__virtuemart_products_' . $template->get('language', 'general'));
$query->where('virtuemart_product_id = ' . $record->virtuemart_product_id);
$db->setQuery($query);
示例7: getStart
//.........这里部分代码省略.........
if (!empty($filter)) {
$query->group($filter);
}
}
// Order by set field
$orderby = $this->getFilterBy('sort', $ignore);
if (!empty($orderby)) {
$query->order($orderby);
}
// Add a limit if user wants us to
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
$jinput->set('logcount', $logcount);
if ($logcount > 0) {
$linenumber = 1;
while ($record = $csvidb->getRow()) {
$csvilog->setLinenumber($linenumber++);
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
foreach ($export_fields as $column_id => $field) {
$fieldname = $field->field_name;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'product_sku':
$query = $db->getQuery(true);
$query->select('product_sku');
$query->from('#__virtuemart_products');
$query->where('virtuemart_product_id = ' . $record->virtuemart_product_id);
$db->setQuery($query);
$fieldvalue = $db->loadResult();
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$record->output[$column_id] = $fieldvalue;
break;
case 'product_name':
$query = $db->getQuery(true);
$query->select($fieldname);
$query->from('#__virtuemart_products_' . $template->get('language', 'general'));
$query->where('virtuemart_product_id = ' . $record->virtuemart_product_id);
$db->setQuery($query);
$fieldvalue = CsviHelper::replaceValue($field->replace, $db->loadResult());
// Check if we have any content otherwise use the default value
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$record->output[$column_id] = $fieldvalue;
break;
case 'product_price':
$product_price = number_format($record->product_price, $template->get('export_price_format_decimal', 'general', 2, 'int'), $template->get('export_price_format_decsep', 'general'), $template->get('export_price_format_thousep', 'general'));
if (strlen(trim($product_price)) == 0) {
示例8: getStart
//.........这里部分代码省略.........
$selectors[] = '#__virtuemart_orders.order_currency IN (\'' . implode("','", $ordercurrency) . '\')';
}
// Check if we need to attach any selectors to the query
if (count($selectors) > 0) {
$query->where(implode("\n AND ", $selectors));
}
// Ignore fields
$ignore = array('full_name');
// Check if we need to group the orders together
$groupby = $template->get('groupby', 'general', false, 'bool');
if ($groupby) {
$filter = $this->getFilterBy('groupby', $ignore);
if (!empty($filter)) {
$query->group($filter);
}
}
// Order by set field
$orderby = $this->getFilterBy('sort', $ignore);
if (!empty($orderby)) {
$query->order($orderby);
}
// Add a limit if user wants us to
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
$jinput->set('logcount', $logcount);
if ($logcount > 0) {
$linenumber = 1;
while ($record = $csvidb->getRow()) {
$csvilog->setLinenumber($linenumber++);
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
foreach ($export_fields as $column_id => $field) {
$fieldname = $field->field_name;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'created_on':
case 'modified_on':
case 'locked_on':
$date = JFactory::getDate($record->{$fieldname});
$fieldvalue = CsviHelper::replaceValue($field->replace, date($template->get('export_date_format', 'general'), $date->toUnix()));
$record->output[$column_id] = $fieldvalue;
break;
case 'product_item_price':
case 'product_final_price':
case 'product_price':
$fieldvalue = number_format($fieldvalue, $template->get('export_price_format_decimal', 'general', 2, 'int'), $template->get('export_price_format_decsep', 'general'), $template->get('export_price_format_thousep', 'general'));
$fieldvalue = CsviHelper::replaceValue($field->replace, $fieldvalue);
// Check if we have any content otherwise use the default value
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$record->output[$column_id] = $fieldvalue;
break;
case 'full_name':
$fieldvalue = str_replace(' ', ' ', $record->first_name . ' ' . $record->middle_name . ' ' . $record->last_name);
// Check if we have any content otherwise use the default value
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$record->output[$column_id] = $fieldvalue;
break;
default:
// Check if we have any content otherwise use the default value
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$record->output[$column_id] = $fieldvalue;
break;
}
}
// Output the data
$this->addExportFields($record);
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeEnd());
}
// Output the contents
$this->writeOutput();
}
} else {
$this->addExportContent(JText::_('COM_CSVI_NO_DATA_FOUND'));
// Output the contents
$this->writeOutput();
}
}
}
示例9: getStart
//.........这里部分代码省略.........
if ($groupby) {
$filter = $this->getFilterBy('groupby', $ignore);
if (!empty($filter)) {
$query->group($filter);
}
}
// Order by set field
$orderby = $this->getFilterBy('sort', $ignore);
if (!empty($orderby)) {
$query->order($orderby);
}
// Add a limit if user wants us to
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
$jinput->set('logcount', $logcount);
if ($logcount > 0) {
while ($record = $csvidb->getRow()) {
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
foreach ($export_fields as $column_id => $field) {
$fieldname = $field->field_name;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'category_path':
// Get all linked category IDs
$query = $db->getQuery(true)->select($db->qn('asset_id'))->from($db->qn('#__awocoupon_asset1'))->where($db->qn('coupon_id') . ' = ' . $record->id)->where($db->qn('asset_type') . '=' . $db->q('category'));
$db->setQuery($query);
$catids = $db->loadColumn();
// Create the paths
$category_path = trim($helper->createCategoryPathById($catids));
if (strlen(trim($category_path)) == 0) {
$category_path = $field->default_value;
}
$category_path = CsviHelper::replaceValue($field->replace, $category_path);
$record->output[$column_id] = $category_path;
break;
case 'product_sku':
// Get all linked product SKUs
$query = $db->getQuery(true)->select($db->qn('product_sku'))->from($db->qn('#__virtuemart_products', 'p'))->leftJoin($db->qn('#__awocoupon_asset1', 'a') . ' ON ' . $db->qn('p.virtuemart_product_id') . ' = ' . $db->qn('a.asset_id'))->where($db->qn('a.coupon_id') . ' = ' . $record->id)->where($db->qn('a.asset_type') . '=' . $db->q('product'));
$db->setQuery($query);
$skus = $db->loadColumn();
// Create the SKUs
$product_sku = implode('|', $skus);
if (strlen(trim($product_sku)) == 0) {
$product_sku = $field->default_value;
}
$product_sku = CsviHelper::replaceValue($field->replace, $product_sku);
$record->output[$column_id] = $product_sku;
break;
case 'manufacturer_name':
$query = $db->getQuery(true)->select($db->qn('mf_name'))->from($db->qn('#__virtuemart_manufacturers_' . $template->get('language', 'general'), 'm'))->leftJoin($db->qn('#__virtuemart_product_manufacturers', 'pm') . ' ON ' . $db->qn('pm.virtuemart_manufacturer_id') . ' = ' . $db->qn('m.virtuemart_manufacturer_id'))->leftJoin($db->qn('#__awocoupon_asset1', 'a') . ' ON ' . $db->qn('a.asset_id') . ' = ' . $db->qn('m.virtuemart_manufacturer_id'))->where($db->qn('a.coupon_id') . ' = ' . $record->id)->where($db->qn('asset_type') . '=' . $db->q('manufacturer'))->group($db->qn('mf_name'));
示例10: getStart
//.........这里部分代码省略.........
} else {
$selectors[] = $db->qn('u.registerDate') . ' >= ' . $db->q($dStart->format('Y-m-d H:i:s')) . ' AND u.registerDate <=' . $db->q($dNow->format('Y-m-d H:i:s'));
}
}
// Check if we need to attach any selectors to the query
if (count($selectors) > 0) {
$query->where(implode("\n AND ", $selectors));
}
// Ingore fields
$ignore = array('custom', 'fullname', 'usergroup_name');
// Check if we need to group the users together
$groupby = $template->get('groupby', 'general', false, 'bool');
if ($groupby) {
$filter = $this->getFilterBy('groupby', $ignore);
if (!empty($filter)) {
$query->group($filter);
}
}
// Order by set field
$orderby = $this->getFilterBy('sort', $ignore);
if (!empty($orderby)) {
$query->order($orderby);
}
// Add a limit if user wants us to
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
$jinput->set('logcount', $logcount);
if ($logcount > 0) {
while ($record = $csvidb->getRow()) {
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
foreach ($export_fields as $column_id => $field) {
$fieldname = $field->field_name;
$fieldreplace = $field->field_name . $field->column_header;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'usergroup_name':
$query = $db->getQuery(true);
$query->select($db->qn('title'));
$query->from($db->qn('#__usergroups'));
$query->leftJoin($db->qn('#__user_usergroup_map') . ' ON ' . $db->qn('#__user_usergroup_map.group_id') . ' = ' . $db->qn('#__usergroups.id'));
$query->where($db->qn('user_id') . ' = ' . $record->id);
$db->setQuery($query);
$groups = $db->loadColumn();
if (is_array($groups)) {
$fieldvalue = implode('|', $groups);
} else {
$fieldvalue = '';
}
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$record->output[$column_id] = $fieldvalue;
break;
case 'custom':
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$fieldvalue = CsviHelper::replaceValue($field->replace, $fieldvalue);
$record->output[$column_id] = $fieldvalue;
break;
default:
// Check if we have any content otherwise use the default value
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$record->output[$column_id] = $fieldvalue;
break;
}
}
// Output the data
$this->addExportFields($record);
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeEnd());
}
// Output the contents
$this->writeOutput();
}
} else {
$this->addExportContent(JText::_('COM_CSVI_NO_DATA_FOUND'));
// Output the contents
$this->writeOutput();
}
}
}
示例11: getData
/**
* Get the data to process by the model
*
* @copyright
* @author RolandD
* @todo
* @see
* @access public
* @param
* @return array array of fields and data
* @since 4.6
*/
public function getData()
{
// Remove the skip and combine fields
$data = array();
foreach ($this->_fields as $name => $field) {
if ($name !== 'skip' && strpos($name, 'combine') === false) {
// Replace the values
foreach ($field as $key => $details) {
if (!empty($details['replace'])) {
$field[$key]['value'] = CsviHelper::replaceValue($details['replace'], $details['value']);
}
}
$data[$name] = $field;
}
}
return $data;
}
示例12: getStart
//.........这里部分代码省略.........
$query->group($filter);
}
}
// Order by set field
$orderby = $this->getFilterBy('sort', $address, $user_info_fields);
if (!empty($orderby)) {
$query->order($orderby);
}
// Add a limit if user wants us to
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
$jinput->set('logcount', $logcount);
if ($logcount > 0) {
$linenumber = 1;
while ($record = $csvidb->getRow()) {
$csvilog->setLinenumber($linenumber++);
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
foreach ($export_fields as $column_id => $field) {
if ($field->process) {
$fieldname = $field->field_name;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'payment_element':
$query = $db->getQuery(true);
$query->select($fieldname);
$query->from('#__virtuemart_paymentmethods');
$query->where('virtuemart_paymentmethod_id = ' . $record->virtuemart_paymentmethod_id);
$db->setQuery($query);
$fieldvalue = CsviHelper::replaceValue($field->replace, $db->loadResult());
$this->addExportField($field->combine, $fieldvalue, $fieldname, $field->column_header);
break;
case 'shipment_element':
$query = $db->getQuery(true);
$query->select($fieldname);
$query->from('#__virtuemart_shipmentmethods');
$query->where('virtuemart_shipmentmethod_id = ' . $record->virtuemart_shipmentmethod_id);
$db->setQuery($query);
$fieldvalue = CsviHelper::replaceValue($field->replace, $db->loadResult());
$this->addExportField($field->combine, $fieldvalue, $fieldname, $field->column_header);
break;
case 'state_2_code':
case 'state_3_code':
case 'state_name':
$query = $db->getQuery(true);
$query->select($fieldname);
$query->from('#__virtuemart_states');
$query->where('virtuemart_state_id = ' . $record->virtuemart_state_id);
$db->setQuery($query);
$fieldvalue = CsviHelper::replaceValue($field->replace, $db->loadResult());
$this->addExportField($field->combine, $fieldvalue, $fieldname, $field->column_header);
示例13: getStart
//.........这里部分代码省略.........
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
$jinput->set('logcount', $logcount);
if ($logcount > 0) {
$linenumber = 1;
$orderid = null;
while ($record = $csvidb->getRow()) {
$csvilog->setLinenumber($linenumber++);
// Add an order
if (is_null($orderid) || $record->virtuemart_order_id != $orderid) {
if (!is_null($orderid)) {
// Output the contents
$this->addExportContent($exportclass->NodeEnd());
$this->writeOutput();
}
$orderid = $record->virtuemart_order_id;
$this->addExportContent($exportclass->Order());
}
// Add an orderline
$this->addExportContent($exportclass->Orderline());
foreach ($export_fields as $column_id => $field) {
if ($field->process) {
$fieldname = $field->field_name;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'payment_element':
$query = $db->getQuery(true);
$query->select($fieldname);
$query->from('#__virtuemart_paymentmethods');
$query->where('virtuemart_paymentmethod_id = ' . $record->virtuemart_paymentmethod_id);
$db->setQuery($query);
$fieldvalue = CsviHelper::replaceValue($field->replace, $db->loadResult());
$record->output[$column_id] = $fieldvalue;
break;
case 'shipment_element':
$query = $db->getQuery(true);
$query->select($fieldname);
$query->from('#__virtuemart_shipmentmethods');
$query->where('virtuemart_shipmentmethod_id = ' . $record->virtuemart_shipmentmethod_id);
$db->setQuery($query);
$fieldvalue = CsviHelper::replaceValue($field->replace, $db->loadResult());
$record->output[$column_id] = $fieldvalue;
break;
case 'state_2_code':
case 'state_3_code':
case 'state_name':
case 'shipping_state_2_code':
case 'shipping_state_3_code':
case 'shipping_state_name':
$query = $db->getQuery(true);
$query->select(str_ireplace('shipping_', '', $fieldname));
$query->from('#__virtuemart_states');
$query->where('virtuemart_state_id = ' . $record->{$fieldname});
示例14: getStart
//.........这里部分代码省略.........
// Check if we need to attach any selectors to the query
if (count($selectors) > 0) {
$query->where(implode("\n AND ", $selectors));
}
// Ingore fields
$ignore = array('custom', 'category_path', 'article_url');
// Check if we need to group the orders together
$groupby = $template->get('groupby', 'general', false, 'bool');
if ($groupby) {
$filter = $this->getFilterBy('groupby', $ignore);
if (!empty($filter)) {
$query->group($filter);
}
}
// Order by set field
$orderby = $this->getFilterBy('sort', $ignore);
if (!empty($orderby)) {
$query->order($orderby);
}
// Add a limit if user wants us to
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
$jinput->set('logcount', $logcount);
if ($logcount > 0) {
while ($record = $csvidb->getRow()) {
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
foreach ($export_fields as $column_id => $field) {
$fieldname = $field->field_name;
$fieldreplace = $field->field_name . $field->column_header;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'category_path':
$query->clear();
$query->select('path')->from('#__categories')->where('id = ' . $record->catid);
$db->setQuery($query);
$fieldvalue = $db->loadResult();
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$fieldvalue = CsviHelper::replaceValue($field->replace, $fieldvalue);
$record->output[$column_id] = $fieldvalue;
break;
case 'article_url':
// Let's create a SEF URL
$_SERVER['QUERY_STRING'] = 'option=com_content&view=article&id=' . $record->id . '&catid=' . $record->catid . '&Itemid=' . $template->get('j_itemid', 'product', 1, 'int');
$article_url = $sef->getSiteRoute('index.php?' . $_SERVER['QUERY_STRING']);
// Check for https, replace with http. https has unnecessary overhead
if (substr($article_url, 0, 5) == 'https') {
$article_url = 'http' . substr($article_url, 5);
}
$article_url = CsviHelper::replaceValue($field->replace, $article_url);
$record->output[$column_id] = $article_url;
break;
case 'custom':
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$fieldvalue = CsviHelper::replaceValue($field->replace, $fieldvalue);
$record->output[$column_id] = $fieldvalue;
break;
default:
// Check if we have any content otherwise use the default value
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}
$record->output[$column_id] = $fieldvalue;
break;
}
}
// Output the data
$this->addExportFields($record);
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeEnd());
}
// Output the contents
$this->writeOutput();
}
} else {
$this->addExportContent(JText::_('COM_CSVI_NO_DATA_FOUND'));
// Output the contents
$this->writeOutput();
}
}
}
示例15: getStart
//.........这里部分代码省略.........
$filter = $this->getFilterBy('groupby', $ignore);
if (!empty($filter)) {
$query->group($filter);
}
}
// Order by set field
$orderby = $this->getFilterBy('sort', $ignore);
if (!empty($orderby)) {
$query->order($orderby);
}
// Add a limit if user wants us to
$limits = $this->getExportLimit();
// Execute the query
$csvidb->setQuery($query, $limits['offset'], $limits['limit']);
$csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
// There are no records, write SQL query to log
if (!is_null($csvidb->getErrorMsg())) {
$this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
$this->writeOutput();
$csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
} else {
$logcount = $csvidb->getNumRows();
$jinput->set('logcount', $logcount);
if ($logcount > 0) {
while ($record = $csvidb->getRow()) {
if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
$this->addExportContent($exportclass->NodeStart());
}
foreach ($export_fields as $column_id => $field) {
$fieldname = $field->field_name;
$fieldreplace = $field->field_name . $field->column_header;
// Add the replacement
if (isset($record->{$fieldname})) {
$fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
} else {
$fieldvalue = '';
}
switch ($fieldname) {
case 'aucdate':
case 'availdate':
case 'checked_out_time':
case 'listdate':
case 'ohdate':
case 'ohdate2':
$date = JFactory::getDate($record->{$fieldname});
$fieldvalue = CsviHelper::replaceValue($field->replace, date($template->get('export_date_format', 'general'), $date->toUnix()));
$record->output[$column_id] = $fieldvalue;
break;
case 'expdate':
case 'lastupdate':
$fieldvalue = CsviHelper::replaceValue($field->replace, date($template->get('export_date_format', 'general'), $record->{$fieldname}));
$record->output[$column_id] = $fieldvalue;
break;
case 'bond':
case 'closeprice':
case 'offpeak':
case 'price':
$fieldvalue = number_format($fieldvalue, $template->get('export_price_format_decimal', 'general', 2, 'int'), $template->get('export_price_format_decsep', 'general'), $template->get('export_price_format_thousep', 'general'));
if ($template->get('add_currency_to_price', 'general')) {
$fieldvalue = $config->get('er_currencycode') . ' ' . $fieldvalue;
}
$fieldvalue = CsviHelper::replaceValue($field->replace, $fieldvalue);
// Check if we have any content otherwise use the default value
if (strlen(trim($fieldvalue)) == 0) {
$fieldvalue = $field->default_value;
}