first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
function st_allegro_delivery_times_select_tag($name, $value)
|
||||
{
|
||||
return select_tag($name, options_for_select(stAllegroApi::getDeliveryTimes(), $value));
|
||||
}
|
||||
|
||||
function st_allegro_shippin_rates_select_tag($name, $value)
|
||||
{
|
||||
$options = array();
|
||||
|
||||
try
|
||||
{
|
||||
$api = stAllegroApi::getInstance();
|
||||
|
||||
foreach ($api->getShippingRates() as $rate)
|
||||
{
|
||||
$options[$rate->id] = $rate->name;
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if (SF_ENVIRONMENT == 'dev')
|
||||
{
|
||||
sfLogger::getInstance()->crit('{stAllegro} st_allegro_shippin_rates_select_tag: '. $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return select_tag($name, options_for_select($options, $value, array('include_custom' => __('Wybierz'))));
|
||||
}
|
||||
315
plugins/stAllegroPlugin/lib/helper/stAllegroHelper.php
Normal file
315
plugins/stAllegroPlugin/lib/helper/stAllegroHelper.php
Normal file
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
|
||||
sfLoader::loadHelpers(array('Helper', 'stProduct'), 'stProduct');
|
||||
|
||||
function st_allegro_selected_product($id)
|
||||
{
|
||||
if ($id)
|
||||
{
|
||||
$api = stAllegroApi::getInstance();
|
||||
$product = $api->getProduct($id);
|
||||
|
||||
st_allegro_product($product);
|
||||
}
|
||||
}
|
||||
|
||||
function st_allegro_product($product)
|
||||
{
|
||||
$image = $product->images ? $product->images[0]->url : "https://assets.allegrostatic.com/metrum/placeholder/placeholder-2447b7d18a.svg";
|
||||
echo '<div class="allegro-product" data-id="'.$product->id.'">';
|
||||
echo ' <div class="image" style="background-image: url('.$image.');"></div>';
|
||||
echo ' <div class="description">';
|
||||
echo ' <h3>'.$product->name.'</h3>';
|
||||
echo ' <ul class="parameters">';
|
||||
foreach ($product->parameters as $index => $parameter)
|
||||
{
|
||||
if ($index > 4) break;
|
||||
echo ' <li>'.$parameter->name.': <b>'.st_allegro_product_parameter_value($parameter).'</b></li>';
|
||||
}
|
||||
echo ' </ul>';
|
||||
echo ' </div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function st_allegro_payment_type($type)
|
||||
{
|
||||
$payments = array(
|
||||
'm' => 'mTransfer - mBank',
|
||||
'mtex' => 'mTransfer mobilny - mBank',
|
||||
'w' => 'BZWBK - Przelew24',
|
||||
'o' => 'Pekao24Przelew - Bank Pekao',
|
||||
'i' => 'Inteligo',
|
||||
'p' => 'iPKO',
|
||||
'pkex' => 'PayU Express Bank Pekao',
|
||||
'g' => 'ING',
|
||||
'gbx' => 'Getin Bank',
|
||||
'gbex' => 'GetIn Bank PayU Express',
|
||||
'nlx' => 'Noble Bank',
|
||||
'nlex' => 'Noble Bank PayU Express',
|
||||
'ib' => 'Paylink Idea - IdeaBank',
|
||||
'l' => 'Credit Agricole',
|
||||
'as' => 'T-mobile Usługi Bankowe dostarczane przez Alior Bank',
|
||||
'exas' => 'PayU Express T-mobile Usługi Bankowe',
|
||||
'u' => 'Eurobank',
|
||||
'ab' => 'Alior Bankiem',
|
||||
'exab' => 'PayU Express z Alior Bankiem',
|
||||
'ps' => 'PBS',
|
||||
'wm' => 'Przelew z Millennium',
|
||||
'h' => 'Przelew z BPH',
|
||||
'wd' => 'Przelew z Deutsche Banku',
|
||||
'wc' => 'Przelew z Citi Handlowego',
|
||||
'bo' => 'BOŚ',
|
||||
'bnx' => 'BNP Paribas',
|
||||
'bnex' => 'BNP Paribas PayU Express',
|
||||
'orx' => 'Orange',
|
||||
'orex' => 'PayU Express Orange',
|
||||
'c' => 'Karta kredytowa',
|
||||
'tt' => 'Karta kredytowa',
|
||||
'b' => 'Przelew tradycyjny',
|
||||
'ai' => 'Raty',
|
||||
'blik' => 'Blik',
|
||||
'ap' => 'Android Pay',
|
||||
'neb' => 'Nest Bank',
|
||||
'rap' => 'Raiffeisen R-Przelew',
|
||||
'plb' => 'Plus Bank',
|
||||
'bpo' => 'e-transfer Pocztowy24',
|
||||
'collect_on_delivery' => 'Płacę przy odbiorze',
|
||||
'cash_on_delivery' => 'Płacę przy odbiorze',
|
||||
'wire_transfer' => 'Zwykły przelew (poza systemem Allegro Finanse)',
|
||||
'p24' => 'Przelewy24',
|
||||
'payu' => 'PayU'
|
||||
);
|
||||
|
||||
if (isset($payments[$type]))
|
||||
{
|
||||
return $payments[$type];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function st_allegro_edit_row($title, $content, $options = null) {
|
||||
$title = __($title, null, 'stAllegroBackend');
|
||||
$labelClass = "";
|
||||
$rowClass = "";
|
||||
if (is_array($options)) {
|
||||
if (isset($options['row'])) {
|
||||
$rowClass = " ".$options['row'];
|
||||
}
|
||||
} elseif ($options) {
|
||||
$labelClass = ' class="required"';
|
||||
}
|
||||
$content = <<<CONTENT
|
||||
<div class="row{$rowClass}">
|
||||
<label{$labelClass}>$title</label>
|
||||
<div class="field">
|
||||
<div class="field-container">$content</div>
|
||||
<div class="clr"></div>
|
||||
</div>
|
||||
</div>
|
||||
CONTENT;
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function st_allegro_edit_row_olny_title($title) {
|
||||
$title = __($title, null, 'stAllegroBackend');
|
||||
$content = <<<CONTENT
|
||||
<div class="row">
|
||||
$title
|
||||
</div>
|
||||
CONTENT;
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function st_allegro_get_tables($quantity, $content) {
|
||||
$tables = array();
|
||||
$tableElementsQuantity = ceil(count($content['tbody'])/$quantity);
|
||||
|
||||
for ($i = 1; $i <= $quantity; $i++) {
|
||||
$data = array('thead' => $content['thead'], 'tbody' => array());
|
||||
for ($j = 0; $j < $tableElementsQuantity; $j++)
|
||||
if (count($content['tbody']))
|
||||
$data['tbody'][] = array_shift($content['tbody']);
|
||||
|
||||
$tables[] = st_allegro_get_table($data);
|
||||
}
|
||||
|
||||
return implode('', $tables);
|
||||
}
|
||||
|
||||
function st_allegro_get_table($content) {
|
||||
$thead = st_allegro_get_table_row('thead', $content);
|
||||
$tbody = st_allegro_get_table_row('tbody', $content);
|
||||
|
||||
$content = <<<CONTENT
|
||||
<table class="st_record_list st_record_manager st-allegro-edit-table-size" cellspacing="0">
|
||||
$thead
|
||||
$tbody
|
||||
</table>
|
||||
CONTENT;
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function st_allegro_get_table_row($type, $content) {
|
||||
if (isset($content[$type]) && !empty($content[$type])) {
|
||||
$result = '<'.$type.'>';
|
||||
foreach ($content[$type] as $row) {
|
||||
$result .= '<tr>';
|
||||
foreach ($row as $record)
|
||||
$result .= '<'.($type == 'tbody' ? 'td' : 'th').'>'.$record.'</'.($type == 'tbody' ? 'td' : 'th').'>';
|
||||
$result .= '</tr>';
|
||||
}
|
||||
$result .= '</'.$type.'>';
|
||||
|
||||
return $result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function st_allegro_show_category_status(stAllegroCategory $allegroObject) {
|
||||
$categoryStatus = $allegroObject->checkStatus();
|
||||
|
||||
if ($categoryStatus === 1)
|
||||
$msg = __('Brak nowych kategorii do pobrania.').' '.__('Data ostatniego pobierania').': '.$allegroObject->getDownloadedTime('d.m.Y H:i');
|
||||
elseif ($categoryStatus === 0)
|
||||
$msg = __('Dostępne są nowe kategorie do pobrania.').' '.__('Data ostatniego pobierania').': '.$allegroObject->getDownloadedTime('d.m.Y H:i');
|
||||
elseif ($categoryStatus === -1)
|
||||
$msg = __('Brak pobranych kategorii, należy pobrać kategorie.');
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
function st_allegro_get_auction_link(AllegroAuction $auction) {
|
||||
if ($link = $auction->getAuctionLink()) {
|
||||
return '<a href="'.$link.'" target="_blank">'.$auction->getAuctionId().'</a>';
|
||||
} else
|
||||
return '-';
|
||||
|
||||
}
|
||||
|
||||
|
||||
function st_allegro_status_label($status)
|
||||
{
|
||||
$enum = stAllegroApi::getStatusList();
|
||||
|
||||
return isset($enum[$status]) ? $enum[$status] : '';
|
||||
}
|
||||
|
||||
|
||||
function st_allegro_implied_warranty_select_tag($name, $value)
|
||||
{
|
||||
$options = array();
|
||||
|
||||
try
|
||||
{
|
||||
$api = stAllegroApi::getInstance();
|
||||
|
||||
foreach ($api->getImpliedWarranties() as $warranty)
|
||||
{
|
||||
$options[$warranty->id] = $warranty->name;
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if (SF_ENVIRONMENT == 'dev')
|
||||
{
|
||||
sfLogger::getInstance()->crit('{stAllegro} st_allegro_implied_warranty_select_tag: '. $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return select_tag($name, options_for_select($options, $value, array('include_custom' => __('Wybierz'))), array('style' => 'width: 300px'));
|
||||
}
|
||||
|
||||
function st_allegro_warranty_select_tag($name, $value)
|
||||
{
|
||||
$options = array();
|
||||
|
||||
try
|
||||
{
|
||||
$api = stAllegroApi::getInstance();
|
||||
|
||||
foreach ($api->getWarranties() as $warranty)
|
||||
{
|
||||
$options[$warranty->id] = $warranty->name;
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if (SF_ENVIRONMENT == 'dev')
|
||||
{
|
||||
sfLogger::getInstance()->crit('{stAllegro} st_allegro_warranty_select_tag: '. $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return select_tag($name, options_for_select($options, $value, array('include_custom' => __('Wybierz'))), array('style' => 'width: 300px'));
|
||||
}
|
||||
|
||||
function st_allegro_return_policy_select_tag($name, $value)
|
||||
{
|
||||
$options = array();
|
||||
|
||||
try
|
||||
{
|
||||
$api = stAllegroApi::getInstance();
|
||||
|
||||
foreach ($api->getReturnPolicies() as $policy)
|
||||
{
|
||||
$options[$policy->id] = $policy->name;
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if (SF_ENVIRONMENT == 'dev')
|
||||
{
|
||||
sfLogger::getInstance()->crit('{stAllegro} st_allegro_return_policy_select_tag: '. $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return select_tag($name, options_for_select($options, $value, array('include_custom' => __('Wybierz'))), array('style' => 'width: 300px'));
|
||||
}
|
||||
|
||||
function st_allegro_product_code(AllegroAuction $auction = null)
|
||||
{
|
||||
$product = null;
|
||||
|
||||
if ($auction)
|
||||
{
|
||||
$product = $auction->getProduct();
|
||||
}
|
||||
|
||||
return $product ? '<a href="'.url_for('@stProduct?action=edit&id=' . $product->getId()).'">' . $product->getCode() . '</a>' : '';
|
||||
}
|
||||
|
||||
function st_allegro_duration_time_select_tag($name, $value, array $params = array())
|
||||
{
|
||||
return select_tag($name, options_for_select(stAllegroApi::getDurationTimes(), $value), $params);
|
||||
}
|
||||
|
||||
function st_allegro_payments_invoice_select_tag($name, $value, array $params = array())
|
||||
{
|
||||
return select_tag($name, options_for_select(stAllegroApi::getPaymentInvoiceList(), $value), $params);
|
||||
}
|
||||
|
||||
function st_allegro_product_search($name, $value, $options = array())
|
||||
{
|
||||
$results_formatter = _token_input_product_results_formatter();
|
||||
|
||||
$token_formatter = _token_input_product_token_formatter();
|
||||
|
||||
$url = st_url_for('@stProductEdit?action=ajaxProductsToken&id=0');
|
||||
|
||||
$tokenizer = array_merge(array(
|
||||
'preventDuplicates' => true,
|
||||
'resultsFormatter' => $results_formatter,
|
||||
'tokenFormatter' => $token_formatter,
|
||||
'hintText' => __('Wpisz kod/nazwę szukanego produktu'),
|
||||
'additionalDataFields' => array('code'),
|
||||
'tokenLimit' => 1,
|
||||
'sortable' => true,
|
||||
), isset($options['tokenizer']) ? $options['tokenizer'] : array());
|
||||
|
||||
return st_tokenizer_input_tag($name, $url, $value, array('tokenizer' => $tokenizer));
|
||||
}
|
||||
262
plugins/stAllegroPlugin/lib/helper/stAllegroParameterHelper.php
Normal file
262
plugins/stAllegroPlugin/lib/helper/stAllegroParameterHelper.php
Normal file
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
|
||||
use_helper('stPrice');
|
||||
|
||||
function st_allegro_product_parameter_value($parameter)
|
||||
{
|
||||
if (isset($parameter->values))
|
||||
{
|
||||
$content = implode(", ", $parameter->values);
|
||||
}
|
||||
elseif (isset($parameter->valuesLabels))
|
||||
{
|
||||
$content = implode(", ", $parameter->valuesLabels);
|
||||
}
|
||||
else
|
||||
{
|
||||
$content = 'Brak';
|
||||
}
|
||||
|
||||
if (isset($parameter->unit))
|
||||
{
|
||||
$content .= " ".$parameter->unit;
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function st_allegro_parameter($name, $parameter, array $values, &$dependencies)
|
||||
{
|
||||
// echo "<pre>".var_export($parameter, true)."</pre>";
|
||||
$type = 'st_allegro_parameter_' . $parameter->type;
|
||||
$value = isset($values[$parameter->id]) ? $values[$parameter->id] : null;
|
||||
|
||||
$required = $parameter->required;
|
||||
$display = "flex";
|
||||
|
||||
if ($parameter->options->dependsOnParameterId)
|
||||
{
|
||||
$parameterValueIds = isset($values[$parameter->options->dependsOnParameterId]) ? $values[$parameter->options->dependsOnParameterId]->valuesIds : array();
|
||||
|
||||
if ($parameter->options->requiredDependsOnValueIds)
|
||||
{
|
||||
$intersect = array_intersect($parameter->options->requiredDependsOnValueIds, $parameterValueIds);
|
||||
$required = count($intersect) > 0;
|
||||
}
|
||||
|
||||
if ($parameter->options->displayDependsOnValueIds)
|
||||
{
|
||||
$intersect = array_intersect($parameter->options->displayDependsOnValueIds, $parameterValueIds);
|
||||
$display = count($intersect) > 0 ? "flex" : "none";
|
||||
}
|
||||
|
||||
$dependencies[$parameter->options->dependsOnParameterId][$parameter->id] = array(
|
||||
'required' => $parameter->options->requiredDependsOnValueIds,
|
||||
'display' => $parameter->options->displayDependsOnValueIds,
|
||||
);
|
||||
}
|
||||
|
||||
$options = array(
|
||||
'required' => $required,
|
||||
'parameter' => $parameter,
|
||||
'postfix' => $parameter->unit ? '<span style="vertical-align: middle">'.$parameter->unit.'</span>' : null,
|
||||
'row_attr' => array(
|
||||
'style' => 'display: ' . $display
|
||||
),
|
||||
'id' => 'st_allegro_offer_parameter_' . $parameter->id,
|
||||
);
|
||||
|
||||
if ($parameter->type == 'dictionary' && $parameter->restrictions->multipleChoices)
|
||||
{
|
||||
$options['row_attr']['data-selected-ids'] = json_encode($value ? $value->valuesIds : array());
|
||||
}
|
||||
|
||||
if (isset($parameter->restrictions->min))
|
||||
{
|
||||
$options['help'] = __("Wartość minimalna: %min%, wartość mayksymalna: %max%", array('%min%' => $parameter->restrictions->min, '%max%' => $parameter->restrictions->max));
|
||||
}
|
||||
|
||||
echo st_admin_get_form_field($name . '[' . $parameter->type . '][' . $parameter->id . ']', $parameter->name, $value, $type, $options);
|
||||
}
|
||||
|
||||
function st_allegro_parameter_dictionary($name, $value, array $params)
|
||||
{
|
||||
$parameter = $params['parameter'];
|
||||
|
||||
if (!$parameter->restrictions->multipleChoices)
|
||||
{
|
||||
return st_allegro_parameter_dictionary_single($name, $value, $params);
|
||||
}
|
||||
else
|
||||
{
|
||||
return st_allegro_parameter_dictionary_multiple($name, $value, $params);
|
||||
}
|
||||
}
|
||||
|
||||
function st_allegro_parameter_dictionary_single($name, $value, array $params)
|
||||
{
|
||||
$parameter = $params['parameter'];
|
||||
|
||||
$options = array();
|
||||
|
||||
foreach ($parameter->dictionary as $dictionary)
|
||||
{
|
||||
$options[$dictionary->id] = array(
|
||||
'label' => $dictionary->value,
|
||||
'attr' => array(
|
||||
'data-depends-on-value-ids' => $dictionary->dependsOnValueIds ? json_encode(array_values($dictionary->dependsOnValueIds)) : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$value_id = $value && $value->valuesIds ? $value->valuesIds[0] : null;
|
||||
|
||||
$options_for_select = options_for_select($options, $value_id, array('include_custom' => __("Wybierz")));
|
||||
|
||||
$content = select_tag($name.'[value]', $options_for_select, array(
|
||||
'id' => $params['id'],
|
||||
'class' => 'st_allegro_parameter_dictionary st_allegro_parameter',
|
||||
'data-ambiguous-value-id' => $parameter->options->ambiguousValueId,
|
||||
'data-custom-value-enabled' => $parameter->options->customValuesEnabled,
|
||||
'data-parameter-id' => $parameter->id,
|
||||
));
|
||||
|
||||
if ($parameter->options->ambiguousValueId && $parameter->options->customValuesEnabled)
|
||||
{
|
||||
$visible = $parameter->options->ambiguousValueId == $value_id;
|
||||
|
||||
$content .= " ".input_tag($name.'[custom]', $visible && $value && isset($value->values) && !empty($value->values) ? $value->values[0] : null, array(
|
||||
'disabled' => !$visible,
|
||||
'style' => !$visible ? 'display: none' : '',
|
||||
'placeholder' => __('Wprowadź własną wartość'),
|
||||
'size' => '40',
|
||||
'class' => 'st_allegro_parameter_dictionary_custom'
|
||||
));
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function st_allegro_parameter_dictionary_multiple($name, $value, array $params)
|
||||
{
|
||||
$parameter = $params['parameter'];
|
||||
|
||||
$values = $value ? $value->valuesIds : array();
|
||||
|
||||
ob_start();
|
||||
|
||||
foreach ($parameter->dictionary as $dictionary)
|
||||
{
|
||||
echo '<label class="bs-mt-1 bs-d-block">';
|
||||
echo st_admin_checkbox_tag($name . '[value][]', $dictionary->id, in_array($dictionary->id, $values), array(
|
||||
'id' => $params['id'] . '_' . $parameter->id,
|
||||
'class' => 'st_allegro_parameter_dictionary st_allegro_parameter',
|
||||
'data-depends-on-value-ids' => $dictionary->dependsOnValueIds ? json_encode($dictionary->dependsOnValueIds) : null,
|
||||
'data-ambiguous-value-id' => $parameter->options->ambiguousValueId,
|
||||
'data-custom-value-enabled' => $parameter->options->customValuesEnabled,
|
||||
'data-parameter-id' => $parameter->id,
|
||||
)) . ' ' . $dictionary->value;
|
||||
if ($parameter->options->ambiguousValueId == $dictionary->id && $parameter->options->customValuesEnabled)
|
||||
{
|
||||
$visible = in_array($parameter->options->ambiguousValueId , $values);
|
||||
echo " ".input_tag($name.'[custom]', $value && isset($value->values) && !empty($value->values) ? $value->values[0] : null, array(
|
||||
'disabled' => !$visible,
|
||||
'style' => !$visible ? 'display: none' : '',
|
||||
'placeholder' => __('Wprowadź własną wartość'),
|
||||
'size' => '40',
|
||||
'class' => 'st_allegro_parameter_dictionary_custom'
|
||||
));
|
||||
}
|
||||
echo '</label>';
|
||||
}
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
function st_allegro_parameter_float($name, $value, array $params)
|
||||
{
|
||||
return st_allegro_parameter_numeric($name, $value, $params);
|
||||
}
|
||||
|
||||
function st_allegro_parameter_integer($name, $value, array $params)
|
||||
{
|
||||
return st_allegro_parameter_numeric($name, $value, $params);
|
||||
}
|
||||
|
||||
function st_allegro_parameter_numeric($name, $value, array $params)
|
||||
{
|
||||
$parameter = $params['parameter'];
|
||||
|
||||
if (!$parameter->restrictions->range)
|
||||
{
|
||||
return input_tag($name, $value && $value->values ? $value->values[0] : null, array(
|
||||
'id' => $params['id'],
|
||||
'class' => 'number-type st_allegro_parameter',
|
||||
'size' => 10,
|
||||
'data-min' => $parameter->restrictions->min,
|
||||
'data-max' => $parameter->restrictions->max,
|
||||
'data-precision' => isset($parameter->restrictions->precision) && $parameter->restrictions->precision ? $parameter->restrictions->precision : 0,
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
return input_tag($name . '[from]', $value && $value->rangeValue ? $value->rangeValue->from : null, array(
|
||||
'id' => $params['id'] . '_from',
|
||||
'class' => 'number-type st_allegro_parameter',
|
||||
'size' => 10,
|
||||
'data-min' => $parameter->restrictions->min,
|
||||
'data-max' => $parameter->restrictions->max,
|
||||
'data-precision' => isset($parameter->restrictions->precision) && $parameter->restrictions->precision ? $parameter->restrictions->precision : 0,
|
||||
)) . ' - ' . input_tag($name . '[to]', $value && $value->rangeValue ? $value->rangeValue->to : null, array(
|
||||
'id' => $params['id'] . '_to',
|
||||
'class' => 'number-type st_allegro_parameter',
|
||||
'size' => 10,
|
||||
'data-min' => $parameter->restrictions->min,
|
||||
'data-max' => $parameter->restrictions->max,
|
||||
'data-precision' => isset($parameter->restrictions->precision) && $parameter->restrictions->precision ? $parameter->restrictions->precision : 0,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
function st_allegro_parameter_string($name, $value, array $params)
|
||||
{
|
||||
$parameter = $params['parameter'];
|
||||
|
||||
if ($parameter->restrictions->allowedNumberOfValues == 1)
|
||||
{
|
||||
return st_allegro_parameter_string_single($name, $value, $params);
|
||||
}
|
||||
else
|
||||
{
|
||||
return st_allegro_parameter_string_multiple($name, $value, $params);
|
||||
}
|
||||
}
|
||||
|
||||
function st_allegro_parameter_string_single($name, $value, array $params)
|
||||
{
|
||||
$parameter = $params['parameter'];
|
||||
|
||||
return input_tag($name, $value && $value->values ? $value->values[0] : null, array(
|
||||
'class' => 'string-type st_allegro_parameter',
|
||||
'maxlength' => $parameter->restrictions->maxLength,
|
||||
'size' => '40',
|
||||
));
|
||||
}
|
||||
|
||||
function st_allegro_parameter_string_multiple($name, $value, array $params)
|
||||
{
|
||||
$parameter = $params['parameter'];
|
||||
|
||||
$values = $value ? $value->values : array();
|
||||
|
||||
ob_start();
|
||||
|
||||
for ($i = 0; $i < $parameter->restrictions->allowedNumberOfValues; $i++)
|
||||
{
|
||||
echo '<div style="margin-bottom: 5px">';
|
||||
echo input_tag($name . '[' . $i . ']', isset($values[$i]) ? $values[$i] : null, array('class' => 'string-type st_allegro_parameter', 'maxlength' => $parameter->restrictions->maxLength, 'size' => '40', 'placeholder' => __('Wartość %no%', array('%no%' => $i + 1))));
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
Reference in New Issue
Block a user