v7‰PNG  IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ± üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0A­ºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT PK=\Mu//MailEditor.phpnu[ 'mail-editor')); $this->addClass('no-label'); $this->addStatic()->setContent('
'); $this->addStatic()->setContent('
'); $subject = $this->addElement('text', 'subject', array( 'class' => 'el-wide', 'placeholder' => ___('Subject'))) ->setLabel(___('Subject')); $subject->addRule('required'); $this->addStatic()->setContent('
'); $this->addStatic()->setContent('
'); $format = $this->addGroup(null)->setLabel(___('E-Mail Format'))->setSeparator(' '); $format->addRadio('format', array('value'=>'html'))->setContent(___('HTML Message')); $format->addRadio('format', array('value'=>'text'))->setContent(___('Plain-Text Message')); $this->addStatic()->setContent('
'); $this->addStatic()->setContent('
'); $this->editor = $this->addElement(new Am_Form_Element_HtmlEditor('txt', null, array('dontInitMce' => true))); $this->editor->addRule('required'); $this->addStatic()->setContent('
'); $this->addStatic()->setContent('
'); $this->tagsOptions = Am_Mail_TemplateTypes::getInstance()->getTagsOptions($name); $tagsOptions = array(); foreach ($this->tagsOptions as $k => $v) $tagsOptions[$k] = "$k - $v"; $sel = $this->addSelect('', array('id'=>'insert-tags', )); $sel->loadOptions(array_merge(array(''=>''), $tagsOptions)); $this->addStatic()->setContent('
'); $this->addStatic()->setContent('
'); $this->addStatic()->setContent('

' . ___('Attachments') . '

'); $prefix = isset($options['upload-prefix']) ? $options['upload-prefix'] : EmailTemplate::ATTACHMENT_FILE_PREFIX; $fileChooser = new Am_Form_Element_Upload('attachments', array('multiple'=>1), array('prefix'=>$prefix)); $this->addElement($fileChooser)->setLabel(___('Attachments')); $this->addStatic()->setContent('
'); $this->addStatic()->setContent('
'); } protected function renderClientRules(HTML_QuickForm2_JavascriptBuilder $builder) { $id = Am_Html::escape($this->editor->getId()); $vars = ""; foreach ($this->tagsOptions as $k => $v) $vars .= sprintf("[%s, %s],\n", json_encode($v), json_encode($k)); $vars = trim($vars, "\n\r,"); $builder->addElementJavascript(<<brickedForm = $form; class_exists('Am_Form_Brick', true); foreach ($this->brickedForm->getAvailableBricks() as $brick) $this->bricks[$brick->getClass()][$brick->getId()] = $brick; } public function getType() { return 'hidden'; // we will output the row HTML too } public function getRawValue() { $value = array(); foreach ($this->value as $row) { if ($brick = $this->getBrick($row['class'], $row['id'])) $value[] = $brick->getRecord(); } return json_encode($value); } public function setValue($value) { if (is_string($value)) $value = json_decode($value, true); $this->value = (array)$value; foreach ($this->value as & $row) { if (empty($row['id'])) continue; if (isset($row['config']) && is_string($row['config'])) { parse_str($row['config'], $c); if (get_magic_quotes_gpc()) $c = Am_Mvc_Request::ss($c); // remove quotes $row['config'] = $c; } if ($brick = $this->getBrick($row['class'], $row['id'])) { $brick->setFromRecord($row); } } // handle special case - where there is a "multiple" brick and that is enabled // we have to insert additional brick to "disabled", so new bricks of same // type can be added in editor $disabled = $this->getBricks(self::DISABLED); foreach ($this->getBricks(self::ENABLED) as $brick) { if (!$brick->isMultiple()) continue; $found = false; foreach ($disabled as $dBrick) if ($dBrick->getClass() == $brick->getClass()) { $found = true; break;}; // create new disabled brick of same class if (!$found) $this->getBrick($brick->getClass(), null); } } /** * Clones element if necessary (if id passed say as "id-1" and it is not found) * @return Am_Form_Brick|null */ public function getBrick($class, $id) { if ( !isset($this->bricks[$class][$id]) && isset($this->bricks[$class]) && current($this->bricks[$class])->isMultiple() ) { if ($id === null) for ($i = 0; $i<100; $i++) if (!array_key_exists($class . '-' . $i, $this->bricks[$class])) { $id = $class . '-' . $i; break; } $this->bricks[$class][$id] = Am_Form_Brick::createFromRecord(array('class' => $class, 'id' => $id)); } return empty($this->bricks[$class][$id]) ? null : $this->bricks[$class][$id]; } public function getBricks($where = self::ALL) { $enabled = array(); foreach ($this->value as $row) if (!empty($row['id'])) $enabled[ ] = $row['id']; $ret = array(); foreach ($this->bricks as $class => $bricks) foreach ($bricks as $id => $b) { if ($where == self::ENABLED && !in_array($id, $enabled)) continue; if ($where == self::DISABLED && in_array($id, $enabled)) continue; $ret[$id] = $b; } // if we need enabled element, we need to maintain order according to value if ($where == self::ENABLED) { $ret0 = $ret; $ret = array(); foreach ($enabled as $id) if (isset($ret0[$id])) $ret[$id] = $ret0[$id]; } return $ret; } public function render(HTML_QuickForm2_Renderer $renderer) { $view = new Am_View; $p = explode('bricks-editor.js', $view->_scriptJs('bricks-editor.js')); // dirty hack to get path to JS folder $renderer->getJavascriptBuilder()->addLibrary('bricks-editor', 'bricks-editor.js', $p[0]); return parent::render($renderer); } public function __toString() { $enabled = $disabled = ""; foreach ($this->getBricks(self::ENABLED) as $brick) $enabled .= $this->renderBrick($brick, true) . "\n"; foreach ($this->getBricks(self::DISABLED) as $brick) $disabled .= $this->renderBrick($brick, false) . "\n"; $hidden = is_string($this->value) ? $this->value : json_encode($this->value); $hidden = Am_Html::escape($hidden); $name = $this->getName(); $formBricks = ___("Form Bricks (drag to right to remove)"); $availableBricks = ___("Available Bricks (drag to left to add)"); $comments = nl2br( ___("To add fields into the form, move item from 'Available Bricks' to 'Form Bricks'.\n". "To remove fields, move it back to 'Available Bricks'.\n". "To make form multi-page, insert 'PageSeparator' item into the place where you want page to be split.") ); $filter = $this->renderFilter(); return $this->getCss() . $this->getJs() . <<

$formBricks

$filter
$enabled

$availableBricks

$filter
$disabled
$comments
CUT; } public function renderConfigForms() { $out = ""; foreach ($this->getBricks(self::ALL) as $brick) { if (!$brick->haveConfigForm()) continue; $form = new Am_Form_Admin(null,null,true); $brick->initConfigForm($form); $form->setDataSources(array(new Am_Mvc_Request($brick->getConfigArray()))); $out .= "\n\n"; } $form = new Am_Form_Admin; $form->addElement('textarea', '_tpl', array('rows' => 2, 'class' => 'el-wide'))->setLabel('-label-'); $out .= "\n"; $out .= ""; return $out; } public function renderBrick(Am_Form_Brick $brick, $enabled) { $class = ''; $configure = $labels = null; $attr = array( 'id' => $brick->getId(), 'class' => "brick $class " . $brick->getClass(), 'data-class' => $brick->getClass(), 'data-title' => strtolower($brick->getName()) ); if ($brick->haveConfigForm()) { $attr['data-config'] = json_encode($brick->getConfigArray()); $configure = "" . ___('configure') . ""; } if ($brick->getStdLabels()) { $attr['data-labels'] = json_encode($brick->getCustomLabels()); $attr['data-stdlabels'] = json_encode($brick->getStdLabels()); $class = $brick->getCustomLabels() ? 'labels custom-labels' : 'labels'; $labels = "" . ___('labels') . ""; } if ($brick->isMultiple()) $attr['data-multiple'] = "1"; if ($brick->hideIfLoggedInPossible() == Am_Form_Brick::HIDE_DESIRED) $attr['data-hide'] = $brick->hideIfLoggedIn() ? 1 : 0; $attrString = ""; foreach ($attr as $k => $v) $attrString .= " $k=\"".htmlentities($v, ENT_QUOTES, 'UTF-8', true)."\""; $checkbox = $this->renderHideIfLoggedInCheckbox($brick); return "
{$brick->getName()} $configure $labels $checkbox
"; } public function renderFilter() { $l_filter = Am_Html::escape(___('filter')); $l_placeholder = Am_Html::escape(___('type part of brick name to filter…')); return <<$l_filter
 
CUT; } protected function renderHideIfLoggedInCheckbox(Am_Form_Brick $brick) { if (($this->brickedForm->isHideBricks())) { if ($brick->hideIfLoggedInPossible() != Am_Form_Brick::HIDE_DONT) { static $checkbox_id = 0; $checkbox_id++; $checked = $brick->hideIfLoggedIn(); if ($brick->hideIfLoggedInPossible() == Am_Form_Brick::HIDE_ALWAYS) { $checked = "checked='checked'"; $disabled = "disabled='disabled'"; } else { $disabled = ""; $checked = $brick->hideIfLoggedIn() ? "checked='checked'" : ''; } return "" . " \n"; } } } public function getJs() { return << jQuery(function(){ jQuery('.input-brick-filter-link').click(function(){ jQuery('.input-brick-filter-wrapper', jQuery(this).closest('.brick-section')).toggle(); if (jQuery(this).hasClass('closed')) jQuery('.input-brick-filter-wrapper input', jQuery(this).closest('.brick-section')).focus(); jQuery(this).toggleClass('opened closed') jQuery('.input-brick-filter', jQuery(this).closest('.brick-section')).val('').change(); }); jQuery(document).on('keyup change','.input-brick-filter', function(){ var \$context = jQuery(this).closest('.brick-section'); jQuery('.input-brick-filter-empty', \$context).toggle(jQuery(this).val().length != 0); if (jQuery(this).val()) { jQuery('.brick', \$context).hide(); jQuery('.brick[data-title*="' + jQuery(this).val().toLowerCase() + '"]', \$context).show(); } else { jQuery('.brick', \$context).show(); } }) jQuery('.input-brick-filter-empty').click(function(){ jQuery(this).closest('.input-brick-filter-wrapper').find('.input-brick-filter').val('').change(); jQuery(this).hide(); }) }); CUT; } public function getCss() { $id = $this->getId(); $declined = Am_Di::getInstance()->view->_scriptImg('icons/decline-d.png'); $decline = Am_Di::getInstance()->view->_scriptImg('icons/decline.png'); return << .brick { border: solid 1px #e7e7e7; margin: 4px; padding: 0.4em; background: #f1f1f1; cursor: move; -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; box-sizing: content-box; } .brick:hover { border-color: #777; } .brick-title { font-weight: normal; color: black } .page-separator { background: #FFFFCF; } .invoice-summary { background: #afccaf; } .product { background: #D3DCE3; } .paysystem { background: #ffd963; } .manual-access, .user-group { opacity: .5; } .brick-section { width: 40%; padding: 10px; float: left; } .brick-section.brick-section-available { width: 55%; } .brick-comment { padding: 10px; } .hide-if-logged-in { margin-left: 20px; float: right; } #bricks-enabled .page-separator { margin-bottom: 20px; } #bricks-enabled { min-height: 200px; padding-bottom:4em; border: 1px dashed #a1a1a1; } #bricks-disabled { overflow: hidden; } #bricks-disabled a.configure, #bricks-disabled a.labels, #bricks-disabled .hide-if-logged-in { display: none; } #bricks-disabled .brick { float: left; margin: 2px; width: 45%; overflow: hidden; white-space: nowrap } a.configure, a.labels { margin-left: 0.2em; cursor: pointer; color: #34536E; } a.labels.custom-labels { color: #360; } /* Filter */ .brick-header { margin-bottom:0.8em; } .brick-header h3 { display: inline; } .input-brick-filter-wrapper { overflow: hidden; padding: 0.4em; border: 1px solid #C2C2C2; border-radius: 5px; margin-bottom: 1em; display: none; } .input-brick-filter-inner-wrapper { position: relative; padding-right:15px; } .input-brick-filter-empty { position: absolute; top:0; right:0; width: 20px; cursor: pointer; opacity: .3; background: url("$declined") no-repeat center center transparent; } .input-brick-filter-empty:hover { opacity: 1; background-image: url("$decline"); } input[type=text].input-brick-filter { padding:0; margin:0; border: none; width:100%; } input[type=text].input-brick-filter:focus { border: none; box-shadow: none; } input[type=text].input-brick-filter:focus { border: none; outline: 0; background: none; } CUT; } } PK=\ׇRegionalTaxes.phpnu[regional_taxes; } protected function updateValue() { $name = $this->getName(); $name2 = Am_Form_Setup::name2underscore($name); foreach ($this->getDataSources() as $ds) { if (null !== ($value = $ds->getValue($name))) { $this->setValue($value); return; } if (null !== ($value = $ds->getValue($name2))) { $this->setValue($value); return; } } } public function setValue($value) { foreach ((array)$value as $k => $r) { if (is_array($r)) continue; $r = preg_replace('/[^A-Za-z0-9_.,|-]/', '', $r); $r = explode('|', $r, 4); $value[$k] = array( 'country' => $r[0], 'state' => $r[1], 'zip' => $r[2], 'tax_value' => sprintf('%.3f', $r[3]), ); } $this->regional_taxes = $value; } public function getType() { return 'custom_row'; } public function __toString() { $output = sprintf('

%s

', ___('Configured Tax Values'), 'class="grid"', ___('Country'), ___('State'), ___('Zip'), ___('Tax Value') ); $label_add = ___('Add'); $output .= "" . "" . "" . "" . "" . "\n"; $name = $this->getName(); foreach ($this->regional_taxes as $id => $region) { $hidden = Am_Html::escape(implode('|', array( $region['country'], $region['state'], $region['zip'], $region['tax_value'], ))); $output .= '' . sprintf('', Am_Di::getInstance()->countryTable->getTitleByCode($region['country'])) . sprintf('', ($region['state'] ? Am_Di::getInstance()->stateTable->getTitleByCode($region['country'], $region['state']) : '*')) . sprintf('', ($region['zip'] ? $region['zip'] : '*')) . sprintf('', $region['tax_value'], ' %') . sprintf('', ___('Remove'), "") . ''; } $output .= '
%s %s %s %s  
" . "
%s%s%s%.3f%s%s%s
'; $id = $this->getId(); $output .= " "; return sprintf('%s', $output . $this->getJs()); } function getJs() { $countries = json_encode(Am_Di::getInstance()->countryTable->getOptions()); $states = array(); foreach (Am_Di::getInstance()->db->select("SELECT country, state, title FROM ?_state") as $r) $states[$r['country']][$r['state']] = $r['title']; $states = json_encode($states); $name = $this->getName(); $remove = ___('Remove'); return << jQuery(function(){ var countries = $countries; var states = $states; jQuery("#regional-tax-country").change(function(){ var sel = jQuery("#regional-tax-state"); sel.find('option').remove(); var options = states[ jQuery(this).val() ]; sel.append(jQuery('