コード例 #1
0
ファイル: amex-hpp.php プロジェクト: grlf/eyedock
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $req = new Am_HttpRequest(sprintf('https://gateway-japa.americanexpress.com/api/rest/version/23/merchant/%s/session', $this->getConfig('merchant')), Am_HttpRequest::METHOD_POST);
     $req->setAuth('merchant.' . $this->getConfig('merchant'), $this->getConfig('password'));
     $req->setBody(Am_Controller::getJson(array('apiOperation' => 'CREATE_PAYMENT_PAGE_SESSION', 'order' => array('id' => $invoice->public_id, 'amount' => $invoice->first_total, 'currency' => $invoice->currency), 'paymentPage' => array('cancelUrl' => $this->getCancelUrl(), 'returnUrl' => $this->getPluginUrl('thanks')))));
     $this->logRequest($req);
     $res = $req->send();
     $this->logResponse($res);
     if ($res->getStatus() != 201) {
         $result->setFailed(sprintf('Incorrect Responce Status From Paysystem [%s]', $res->getStatus()));
         return;
     }
     $msg = Am_Controller::decodeJson($res->getBody());
     if ($msg['result'] == 'ERROR') {
         $result->setFailed($msg['error']['explanation']);
         return;
     }
     $invoice->data()->set(self::DATA_KEY, $msg['successIndicator'])->update();
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->{'merchant'} = $this->getConfig('merchant');
     $a->{'order.description'} = $invoice->getLineDescription();
     $a->{'paymentPage.merchant.name'} = $this->getDi()->config->get('site_title');
     $a->{'session.id'} = $msg['session']['id'];
     $this->logRequest($a);
     $result->setAction($a);
 }
コード例 #2
0
 protected function getWrapper($obj, $grid)
 {
     $id = $this->action->getIdForRecord($obj);
     list($url, $params) = $this->divideUrlAndParams($this->action->getUrl($obj, $id));
     $start = sprintf("<span class='live-edit' id='%s' livetemplate='%s' liveurl='%s' livedata='%s' placeholder='%s'>", $grid->getId() . '_' . $this->field->getFieldName() . '-' . $grid->escape($id), $grid->escape($this->getInputTemplate()), $url, Am_Controller::getJson($params), $grid->escape($this->action->getPlaceholder()));
     $stop = '</span>';
     return array($start, $stop);
 }
コード例 #3
0
ファイル: LiveCheckbox.php プロジェクト: alexanderTsig/arabic
 protected function getContent($obj, Am_Grid_Editable $grid)
 {
     $id = $this->action->getIdForRecord($obj);
     $val = $obj->{$this->field->getFieldName()};
     list($url, $params) = $this->divideUrlAndParams($this->action->getUrl($obj, $id));
     $content = sprintf('<input name="%s" class="live-checkbox" data-url="%s" data-id="%d" data-params="%s" data-value="%s" data-empty_value="%s" type="checkbox" %s/>', Am_Controller::escape($grid->getId() . '_' . $this->field->getFieldName() . '-' . $grid->escape($id)), Am_Controller::escape($url), $id, Am_Controller::escape(Am_Controller::getJson($params)), Am_Controller::escape($this->action->getValue()), Am_Controller::escape($this->action->getEmptyValue()), $val == $this->action->getValue() ? 'checked ' : '');
     return $content;
 }
コード例 #4
0
ファイル: LiveEdit.php プロジェクト: grlf/eyedock
 protected function getWrapper($obj, $grid)
 {
     $id = $this->action->getIdForRecord($obj);
     $val = $obj->{$this->field->getFieldName()};
     list($url, $params) = $this->divideUrlAndParams($this->action->getUrl($obj, $id));
     $start = sprintf('<span class="live-edit%s" id="%s" livetemplate="%s" liveurl="%s" livedata="%s" placeholder="%s" data-init-callback="%s">', $val ? '' : ' live-edit-placeholder', $grid->getId() . '_' . $this->field->getFieldName() . '-' . $grid->escape($id), $grid->escape($this->getInputTemplate()), $url, $grid->escape(Am_Controller::getJson($params)), $grid->escape($this->action->getPlaceholder()), $grid->escape($this->action->getInitCallback()));
     $stop = '</span>';
     return array($start, $stop);
 }
コード例 #5
0
ファイル: MailEditor.php プロジェクト: grlf/eyedock
    protected function renderClientRules(HTML_QuickForm2_JavascriptBuilder $builder)
    {
        $id = Am_Controller::escape($this->editor->getId());
        $vars = "";
        foreach ($this->tagsOptions as $k => $v) {
            $vars .= sprintf("[%s, %s],\n", Am_Controller::getJson($v), Am_Controller::getJson($k));
        }
        $vars = trim($vars, "\n\r,");
        $builder->addElementJavascript(<<<CUT
\$(function(){
    \$('select#insert-tags').change(function(){
        var val = \$(this).val();
        if (!val) return;
        \$("#txt-0").insertAtCaret(val);
        \$(this).prop("selectedIndex", -1);
    });
            
    if (CKEDITOR.instances["{$id}"]) {
        delete CKEDITOR.instances["{$id}"];
    }
    var editor = null;
    \$("input[name='format']").change(function()
    {
        if (window.configDisable_rte) return;
        if (!this.checked) return;
        if (this.value == 'html')
        {
            if (!editor) {
                editor = initCkeditor("{$id}", { placeholder_items: [
                    {$vars}
                ], entities_greek: false});
            }
            \$('#insert-tags-wrapper').hide();
        } else {
            if (editor) {
                editor.destroy();
                editor = null;
            }
            \$('#insert-tags-wrapper').show();
        }
    }).change();
});            
CUT
);
    }
コード例 #6
0
    public function addDbPrefix()
    {
        $title = $this->getTitle();
        $fs = $this->addFieldset('db-prefix')->setLabel(___("%s database and tables prefix", $title));
        $group = $fs->addGroup()->setLabel("{$title} Database name and Tables Prefix");
        $group->addText("db", array('class' => 'db-prefiix'))->addRule('required', 'this field is required');
        $group->addText("prefix", array('class' => 'db-prefiix'));
        $group->addRule('callback2', '-error-', array($this, 'configCheckDbSettings'));
        try {
            $a = array();
            foreach ($this->plugin->guessDbPrefix(Am_Di::getInstance()->db) as $v) {
                list($d, $p) = explode('.', $v, 2);
                $a[] = array('label' => $v, 'value' => $d);
            }
            if ($a) {
                $guessDb = Am_Controller::getJson((array) $a);
                $this->addScript('guess_db_script')->setScript(<<<CUT
\$(function(){
    \$("input[name\$='___db']").autocomplete({
        source : {$guessDb},
        minLength: 0
    }).focus(function(){
        \$(this).autocomplete("search", "");
    }).bind( "autocompleteselect", function(event, ui) {
        var a = ui.item.label.split(".", 2);
        \$(event.target).autocomplete("close");
        \$("input[name\$='___prefix']").val(a[1]);
    });
});
CUT
);
            }
        } catch (Am_Exception $e) {
        }
    }
コード例 #7
0
ファイル: ReadOnly.php プロジェクト: alexanderTsig/arabic
 public function run(Zend_Controller_Response_Abstract $response = null)
 {
     $args = array($this);
     $this->runCallback(self::CB_BEFORE_RUN, $args);
     if ($response === null) {
         $response = new Zend_Controller_Response_Http();
     }
     $this->response = $response;
     $action = $this->getCurrentAction();
     $this->request->setActionName($action);
     ob_start();
     $this->actionRun($action);
     if ($this->response->isRedirect() && $this->completeRequest->isXmlHttpRequest()) {
         $url = null;
         foreach ($response->getHeaders() as $header) {
             if ($header['name'] == 'Location') {
                 $url = $header['value'];
             }
         }
         $code = $response->getHttpResponseCode();
         // change request to ajax response
         $response->clearAllHeaders();
         $response->clearBody();
         $response->setHttpResponseCode(200);
         $response->setHeader("Content-Type", "application/json; charset=UTF-8", true);
         $response->setBody(Am_Controller::getJson(array('ngrid-redirect' => $url, 'status' => $code)));
         //throw new Am_Exception_Redirect($url);
     } else {
         $response->appendBody(ob_get_clean());
     }
     unset($this->response);
     return $response;
 }
コード例 #8
0
ファイル: JavascriptBuilder.php プロジェクト: grlf/eyedock
    public function getFormJavascript($formId = null, $addScriptTags = true)
    {
        $rules = Am_Controller::getJson($this->rules);
        $messages = Am_Controller::getJson($this->messages);
        $formSelector = Am_Controller::getJson('form#' . $formId);
        /**
         * we send special submit handler for multi page form (signup)
         * to avoide issue when clicked button do not included to request
         * (it contain info about next action for multi page action)
         * in case of valid field has remote validation and validation
         * is not finished when user click submit button.
         */
        $submitHandler = strpos($formId, 'page') === 0 ? ',submitHandler: function(form, event){form.submit();}' : '';
        $output = <<<CUT
<script type="text/javascript">
jQuery(document).ready(function(\$) {
    if (jQuery && jQuery.validator)
    {
        jQuery.validator.addMethod("regex", function(value, element, params) {
            return this.optional(element) || new RegExp(params[0],params[1]).test(value);
        }, "Invalid Value");

        jQuery({$formSelector}).validate({
            ignore: ':hidden'
            ,rules: {$rules}
            ,messages: {$messages}
            //,debug : true
            ,errorPlacement: function(error, element) {
                error.appendTo( element.parent());
            }
            {$submitHandler}
            // custom validate js code start
            //-CUSTOM VALIDATE JS CODE-//
            // custom validate js code end
        });
    }
    // custom js code start
    //-CUSTOM JS CODE-//
    // custom js code end
});
</script>
CUT;
        $output = str_replace('//-CUSTOM JS CODE-//', implode(";\n", $this->scripts), $output);
        $addValidateJs = join(",\n", $this->addValidateJs);
        if ($addValidateJs != '') {
            $output = str_replace('//-CUSTOM VALIDATE JS CODE-//', "\n," . $addValidateJs, $output);
        }
        if (!$this->rules && !$this->scripts && !$this->addValidateJs) {
            return null;
        }
        return $output;
    }
コード例 #9
0
ファイル: Report.php プロジェクト: irovast/eyedock
    public function render()
    {
        $ret = $this->getData();
        $ret['element'] = $this->divId;
        $class = $ret['class'];
        unset($ret['class']);
        $options = Am_Controller::getJson($ret);
        return <<<CUT
<div id='{$this->divId}' style='width: {$this->getWidth()}; height: {$this->getHeight()};'></div>
<script type='text/javascript'>
new {$class}({$options});
</script>
CUT;
    }
コード例 #10
0
ファイル: SavedForm.php プロジェクト: grlf/eyedock
 function setFields(array $fields)
 {
     $this->fields = Am_Controller::getJson($fields);
 }
コード例 #11
0
 function createForm()
 {
     $form = new Am_Form_Admin();
     $title = $form->addText('title', array('class' => 'el-wide'))->setLabel(___("Title\ndisplayed to customers"));
     $title->addRule('required');
     $form->addText('desc', array('class' => 'el-wide'))->setLabel(___('Description'));
     $form->addAdvCheckbox('hide')->setLabel(___("Hide\n" . "do not display this item link in members area"));
     $path = $form->addText('path')->setLabel(___('Path to Folder'))->setAttribute('size', 50)->addClass('dir-browser');
     $path->addRule('required');
     $path->addRule('callback2', '-- Wrong path --', array($this, 'validatePath'));
     $url = $form->addGroup()->setLabel(___('Folder URL'));
     $url->addRule('required');
     $url->addText('url')->setAttribute('size', 50)->setId('url');
     $url->addHtml()->setHtml(' <a href="#" id="test-url-link">' . ___('open in new window') . '</a>');
     $methods = array('new-rewrite' => ___('New Rewrite'), 'htpasswd' => ___('Traditional .htpasswd'));
     foreach ($methods as $k => $v) {
         if (!Am_Di::getInstance()->plugins_protect->isEnabled($k)) {
             unset($methods[$k]);
         }
     }
     $method = $form->addAdvRadio('method')->setLabel(___('Protection Method'));
     $method->loadOptions($methods);
     if (count($methods) == 0) {
         throw new Am_Exception_InputError(___('No protection plugins enabled, please enable new-rewrite or htpasswd at aMember CP -> Setup -> Plugins'));
     } elseif (count($methods) == 1) {
         $method->setValue(key($methods))->toggleFrozen(true);
     }
     $form->addElement(new Am_Form_Element_ResourceAccess())->setName('_access')->setLabel(___('Access Permissions'))->setAttribute('without_free_without_login', 'true');
     $form->addScript('script')->setScript('
     $(function(){
         $(".dir-browser").dirBrowser({
             urlField : "#url",
             rootUrl  : ' . Am_Controller::getJson(REL_ROOT_URL) . ',
         });
         $("#test-url-link").click(function() {
             var href = $("input", $(this).parent()).val();
             if (href)
                 window.open(href , "test-url", "");
         });
     });
     ');
     $form->addText('no_access_url', array('class' => 'el-wide'))->setLabel(___("No Access URL\ncustomer without required access will be redirected to this url\nleave empty if you want to redirect to default 'No access' page"));
     $this->addCategoryToForm($form);
     return $form;
 }
コード例 #12
0
 protected function renderNameStandart($obj)
 {
     $data = array('name' => $obj->getName(), 'size_readable' => $obj->getSizeReadable(), 'upload_id' => $obj->pk(), 'mime' => $obj->mime, 'ok' => true);
     return sprintf('<a href="javascript:;" class="filesmanager-file" data-info="%s"><span class="upload-name">%s</span></a>', $this->escape(Am_Controller::getJson($data)), $this->escape($obj->name));
 }
コード例 #13
0
ファイル: BricksEditor.php プロジェクト: grlf/eyedock
 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'] = Am_Controller::getJson($brick->getConfigArray());
         $configure = "<a class='configure local' href='javascript:;'>" . ___('configure') . "</a>";
     }
     if ($brick->getStdLabels()) {
         $attr['data-labels'] = Am_Controller::getJson($brick->getCustomLabels());
         $attr['data-stdlabels'] = Am_Controller::getJson($brick->getStdLabels());
         $class = $brick->getCustomLabels() ? 'labels custom-labels' : 'labels';
         $labels = "<a class='{$class} local' href='javascript:;'>" . ___('labels') . "</a>";
     }
     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 "<div {$attrString}>\n        <strong class=\"brick-title\">{$brick->getName()}</strong>\n        {$configure}\n        {$labels}\n        {$checkbox}\n        </div>";
 }
コード例 #14
0
ファイル: Form.php プロジェクト: alexanderTsig/arabic
    public function render(HTML_QuickForm2_Renderer $renderer)
    {
        $id = $this->getId();
        $url = REL_ROOT_URL . '/application/default/views/public/js/ckeditor/ckeditor.js';
        $renderer->getJavascriptBuilder()->addElementJavascript(<<<CUT
if (!window.CKEDITOR) {            
    var script = \$('<script type="text/javascript" src="{$url}"></' + 'script>');  
    \$('head').append(script);    
}
CUT
);
        if (!$this->dontInitMce) {
            $options = $this->mceOptions ? Am_Controller::getJson($this->mceOptions) : '{}';
            $renderer->getJavascriptBuilder()->addElementJavascript(<<<CUT
\$(function(){            
    initCkeditor('{$id}', {$options});
});
CUT
);
        }
        return parent::render($renderer);
    }
コード例 #15
0
ファイル: sliiing.php プロジェクト: grlf/eyedock
 public function setValue($value)
 {
     $value = is_array($value) ? Am_Controller::getJson($value) : $value;
     parent::setValue($value);
 }
コード例 #16
0
ファイル: View.php プロジェクト: alexanderTsig/arabic
 function adminHeadInit()
 {
     $this->headLink()->appendStylesheet($this->_scriptCss('reset.css'));
     $this->headLink()->appendStylesheet(REL_ROOT_URL . "/application/default/views/public/js/jquery/jquery.ui.css");
     $this->headLink()->appendStylesheet(REL_ROOT_URL . "/application/default/views/public/js/chosen/chosen.min.css");
     $this->headLink()->appendStylesheet($this->_scriptCss('admin.css'));
     list($lang, ) = explode('_', Zend_Registry::get('Am_Locale')->getId());
     if ($theme = $this->_scriptCss('admin-theme.css')) {
         $this->headLink()->appendStylesheet($theme);
     }
     $this->headScript()->prependScript("window.uiDateFormat = " . Am_Controller::getJson($this->convertDateFormat(Zend_Registry::get('Am_Locale')->getDateFormat())) . ";\n")->prependScript(sprintf("window.uiDefaultDate = new Date(%d,%d,%d);\n", date('Y'), date('n') - 1, date('d')))->prependScript("window.lang = " . Am_Controller::getJson($lang) . ";\n")->prependScript(sprintf("window.configDisable_rte = %d;\n", $this->di->config->get('disable_rte', 0)))->prependFile(REL_ROOT_URL . "/js.php?js=admin");
     $this->placeholder('body-start')->append('<div id="flash-message"></div>');
     if (!empty($this->use_angularjs)) {
         $this->headScript()->prependFile($this->_scriptJs('angular/angular-route.js'));
         $this->headScript()->prependFile($this->_scriptJs('angular/angular-resource.js'));
         $this->headScript()->prependFile($this->_scriptJs('angular/angular.js'));
     }
 }
コード例 #17
0
    public function getFormJavascript($formId = null, $addScriptTags = true)
    {
        $rules = Am_Controller::getJson($this->rules);
        $messages = Am_Controller::getJson($this->messages);
        $formId = Am_Controller::getJson('form#' . $formId);
        $output = <<<CUT
<script type="text/javascript">
jQuery(document).ready(function(\$) {
    if (jQuery && jQuery.validator)
    {
        jQuery.validator.addMethod("regex", function(value, element, params) {
            return this.optional(element) || new RegExp(params[0],params[1]).test(value);
        }, "Invalid Value");

        jQuery({$formId}).validate({
            // custom validate js code start
            //-CUSTOM VALIDATE JS CODE-//
            // custom validate js code end
            ignore: ':hidden'
            ,rules: {$rules}
            ,messages: {$messages}
            //,debug : true
            ,errorPlacement: function(error, element) {
                error.appendTo( element.parent());
            }
        });
    }
    // custom js code start
    //-CUSTOM JS CODE-//
    // custom js code end
});
</script>
CUT;
        $output = str_replace('//-CUSTOM JS CODE-//', implode(";\n", $this->scripts), $output);
        $addValidateJs = join(",\n", $this->addValidateJs);
        if ($addValidateJs != '') {
            $output = str_replace('//-CUSTOM VALIDATE JS CODE-//', $addValidateJs . ",\n", $output);
        }
        if (!$this->rules && !$this->scripts && !$this->addValidateJs) {
            return null;
        }
        return $output;
    }
コード例 #18
0
ファイル: Form.php プロジェクト: subashemphasize/test_site
 public function setValue($value)
 {
     if (!$value) {
         return;
     }
     if (!empty($this->attributes['multiple'])) {
         $value = array_filter($value);
         $plainValue = implode(',', $value);
     } else {
         $plainValue = $value;
     }
     $data = array();
     $value = empty($this->attributes['multiple']) ? array($value) : $value;
     foreach ($value as $upload_id) {
         $upload = Am_Di::getInstance()->uploadTable->load($upload_id, false);
         if ($upload) {
             $data[$upload_id] = array('name' => $upload->getName(), 'size_readable' => $upload->getSizeReadable(), 'upload_id' => $upload->pk(), 'mime' => $upload->mime);
         }
     }
     $this->setAttribute('data-info', Am_Controller::getJson($data));
     parent::setValue($plainValue);
 }
コード例 #19
0
ファイル: View.php プロジェクト: subashemphasize/test_site
 function adminHeadInit()
 {
     $this->headLink()->appendStylesheet($this->_scriptCss('reset.css'));
     $this->headLink()->appendStylesheet(REL_ROOT_URL . "/application/default/views/public/js/jquery/jquery.ui.css");
     $this->headLink()->appendStylesheet($this->_scriptCss('admin.css'));
     if ($theme = $this->_scriptCss('admin-theme.css')) {
         $this->headLink()->appendStylesheet($theme);
     }
     $this->headScript()->prependScript("window.uiDateFormat = " . Am_Controller::getJson($this->convertDateFormat(Zend_Registry::get('Am_Locale')->getDateFormat())) . ";\n")->prependFile(REL_ROOT_URL . "/js.php?js=admin");
     $this->placeholder('body-start')->append('<div id="flash-message"><p class="loading" style="display: none">Loading...</p></div>');
 }
コード例 #20
0
ファイル: AdminEmailController.php プロジェクト: grlf/eyedock
    function createForm()
    {
        $form = new Am_Form_Admin('am-form-email');
        $form->setDataSources(array($this->getRequest()));
        $form->setAction($this->getUrl(null, 'preview'));
        if ($options = $this->getDi()->emailTemplateLayoutTable->getOptions()) {
            $form->addSelect('email_template_layout_id')->setLabel(___('Layout'))->loadOptions(array('' => ___('No Layout')) + $options);
        }
        $gr = $form->addGroup()->setLabel(___("Reply To\n" . "mailbox for replies to message"))->setSeparator(' ');
        $sel = $gr->addSelect('reply_to')->loadOptions($this->getReplyToOptions());
        $id = $sel->getId();
        $gr->addText('reply_to_other', array('placeholder' => ___('Email Address')))->setId($id . '-other')->persistentFreeze(true);
        // ??? why is it necessary? but it is
        $gr->addScript()->setScript(<<<CUT
\$('#{$id}').change(function(){
   \$('#{$id}-other').toggle(\$(this).val() == 'other');
}).change();
CUT
);
        $subj = $form->addText('subject', array('class' => 'el-wide'))->setLabel(___('Email Subject'));
        $subj->persistentFreeze(true);
        // ??? why is it necessary? but it is
        $subj->addRule('required', ___('Subject is required'));
        //        $arch = $form->addElement('advcheckbox', 'do_archive')->setLabel(array('Archive Message', 'if you are sending it to newsletter subscribers'));
        $format = $form->addGroup(null)->setLabel(___('E-Mail Format'));
        $format->setSeparator(' ');
        $format->addRadio('format', array('value' => 'html'))->setContent(___('HTML Message'));
        $format->addRadio('format', array('value' => 'text'))->setContent(___('Plain-Text Message'));
        $group = $form->addGroup('', array('id' => 'body-group', 'class' => 'no-label'))->setLabel(___('Message Text'));
        $group->addStatic()->setContent('<div class="mail-editor">');
        $group->addStatic()->setContent('<div class="mail-editor-element">');
        $group->addElement('textarea', 'body', array('id' => 'body-0', 'rows' => '15', 'class' => 'el-wide'));
        $group->addStatic()->setContent('</div>');
        $group->addStatic()->setContent('<div class="mail-editor-element">');
        $this->tagsOptions = Am_Mail_TemplateTypes::getInstance()->getTagsOptions('send_signup_mail');
        $tagsOptions = array();
        foreach ($this->tagsOptions as $k => $v) {
            $tagsOptions[$k] = "{$k} - {$v}";
        }
        $sel = $group->addSelect('', array('id' => 'insert-tags'));
        $sel->loadOptions(array_merge(array('' => ''), $tagsOptions));
        $group->addStatic()->setContent('</div>');
        $group->addStatic()->setContent('</div>');
        $fileChooser = new Am_Form_Element_Upload('files', array('multiple' => '1'), array('prefix' => 'email'));
        $form->addElement($fileChooser)->setLabel(___('Attachments'));
        foreach ($this->searchUi->getHidden() as $k => $v) {
            $form->addHidden($k)->setValue($v);
        }
        $id = 'body-0';
        $vars = "";
        foreach ($this->tagsOptions as $k => $v) {
            $vars .= sprintf("[%s, %s],\n", Am_Controller::getJson($v), Am_Controller::getJson($k));
        }
        $vars = trim($vars, "\n\r,");
        if ($this->queue_id) {
            $form->addHidden('queue_id')->setValue($this->queue_id);
        }
        $form->addScript('_bodyscript')->setScript(<<<CUT
\$(function(){
    \$('select#insert-tags').change(function(){
        var val = \$(this).val();
        if (!val) return;
        \$("#{$id}").insertAtCaret(val);
        \$(this).prop("selectedIndex", -1);
    });

    if (CKEDITOR.instances["{$id}"]) {
        delete CKEDITOR.instances["{$id}"];
    }
    var editor = null;
    \$("input[name='format']").change(function()
    {
        if (window.configDisable_rte) return;
        if (!this.checked) return;
        if (this.value == 'html')
        {
            if (!editor) {
                editor = initCkeditor("{$id}", { placeholder_items: [
                    {$vars}
                ],entities_greek: false});
            }
            \$('select#insert-tags').hide();
        } else {
            if (editor) {
                editor.destroy();
                editor = null;
            }
            \$('select#insert-tags').show();
        }
    }).change();
});

CUT
);
        $this->getDi()->hook->call(Am_Event::MAIL_SIMPLE_INIT_FORM, array('form' => $form));
        $buttons = $form->addGroup('buttons');
        $buttons->addSubmit('send', array('value' => ___('Preview')));
        return $form;
    }
コード例 #21
0
ファイル: Report.php プロジェクト: subashemphasize/test_site
    public function render()
    {
        $ret = $this->getData();
        $options = Am_Controller::getJson($ret);
        $options = str_replace(array('"\\u0003', '\\u0003"'), array('', ''), $options);
        return <<<CUT
<div id='{$this->divId}' style='width: {$this->width}px; height: {$this->height}px;'></div>   
<script type='text/javascript'>
\$(function(){
    var chart = new Highcharts.Chart(
        {$options}
    );
});
</script>
CUT;
    }
コード例 #22
0
 public function renderButtons()
 {
     $actions = $this->getActions(Am_Grid_Action_Abstract::NORECORD);
     if (!$actions) {
         return;
     }
     $out = '<div class="norecord-actions">' . PHP_EOL;
     foreach ($actions as $action) {
         $out .= sprintf('<input type="button" id="%s" value="%s" onclick="window.location=%s" >' . PHP_EOL, $this->getCssClass() . '-' . $action->getId() . '-button', $this->escape($this->getRecordTitle($action->getTitle())), $this->escape(Am_Controller::getJson($action->getUrl())));
     }
     $out .= "</div>" . PHP_EOL;
     return $out;
 }
コード例 #23
0
ファイル: Brick.php プロジェクト: alexanderTsig/arabic
    public function insertBrick(HTML_QuickForm2_Container $form)
    {
        $paysystems = $this->getPaysystems();
        if (count($paysystems) == 1 && $this->getConfig('hide_if_one')) {
            reset($paysystems);
            $form->addHidden('paysys_id')->setValue(current($paysystems)->getId())->toggleFrozen(true);
            return;
        }
        $psOptions = $psHide = array();
        foreach ($paysystems as $ps) {
            $psOptions[$ps->getId()] = $this->renderPaysys($ps);
            $psHide[$ps->getId()] = Am_Di::getInstance()->plugins_payment->loadGet($ps->getId())->hideBricks();
        }
        $psHide = Am_Controller::getJson($psHide);
        if (count($paysystems) != 1) {
            $attrs = array('id' => 'paysys_id');
            $el0 = $el = $form->addAdvRadio('paysys_id', array('id' => 'paysys_id'), array('intrinsic_validation' => false));
            $first = 0;
            foreach ($psOptions as $k => $v) {
                $attrs = array();
                if (!$first++ && Am_Di::getInstance()->request->isGet()) {
                    $attrs['checked'] = 'checked';
                }
                $el->addOption($v, $k, $attrs);
            }
        } else {
            /** @todo display html here */
            reset($psOptions);
            $el = $form->addStatic('_paysys_id', array('id' => 'paysys_id'))->setContent(current($psOptions));
            $el->toggleFrozen(true);
            $el0 = $form->addHidden('paysys_id')->setValue(key($psOptions));
        }
        $el0->addRule('required', $this->___('Please choose a payment system'), null, HTML_QuickForm2_Rule::SERVER);
        $el0->addFilter('filterId');
        $el->setLabel($this->___('Payment System'));
        $form->addScript()->setScript(<<<CUT
jQuery(document).ready(function(\$) {
    /// hide payment system selection if:
    //   - there are only free products in the form
    //   - there are selected products, and all of them are free
    \$(":checkbox[name^='product_id'], select[name^='product_id'], :radio[name^='product_id'], input[type=hidden][name^='product_id']").change(function(){
        var count_free = 0, count_paid = 0, total_count_free = 0, total_count_paid = 0;
        \$(":checkbox[name^='product_id']:checked, select[name^='product_id'] option:selected, :radio[name^='product_id']:checked, input[type=hidden][name^='product_id']").each(function(){
            if ((\$(this).data('first_price')>0) || (\$(this).data('second_price')>0))
                count_paid++;
            else
                count_free++;
        });

        \$(":checkbox[name^='product_id'], select[name^='product_id'] option, :radio[name^='product_id'], input[type=hidden][name^='product_id']").each(function(){
            if ((\$(this).data('first_price')>0) || (\$(this).data('second_price')>0))
                total_count_paid++;
            else
                total_count_free++;
        });
        if ( ((count_free && !count_paid) || (!total_count_paid && total_count_free)) && (total_count_paid + total_count_free)>0)
        { // hide select
            \$("#row-paysys_id").hide().after("<input type='hidden' name='paysys_id' value='free' class='hidden-paysys_id' />");
        } else { // show select
            \$("#row-paysys_id").show();
            \$(".hidden-paysys_id").remove();
        }
    }).change();
    window.psHiddenBricks = [];
    \$("input[name='paysys_id']").change(function(){
        if (!this.checked) return;
        var val = \$(this).val();
        var hideBricks = {$psHide};
        \$.each(window.psHiddenBricks, function(k,v){ \$('#row-'+v+'-0').show(); });
        window.psHiddenBricks = hideBricks[val];
        if (window.psHiddenBricks)
        {
            \$.each(window.psHiddenBricks, function(k,v){ \$('#row-'+v+'-0').hide(); });
        }
    }).change();
});
CUT
);
    }
コード例 #24
0
 public function renderBrick(Am_Form_Brick $brick, $enabled)
 {
     $class = $enabled ? 'ui-state-default' : 'ui-state-default';
     $configure = $labels = null;
     $attr = array('id' => $brick->getId(), 'class' => "brick {$class} " . $brick->getClass(), 'data-class' => $brick->getClass());
     if ($brick->haveConfigForm()) {
         $attr['data-config'] = Am_Controller::getJson($brick->getConfigArray());
         $configure = "<a class='configure'>configure...</a>";
     }
     if ($brick->getStdLabels()) {
         $attr['data-labels'] = Am_Controller::getJson($brick->getCustomLabels());
         $attr['data-stdlabels'] = Am_Controller::getJson($brick->getStdLabels());
         $class = $brick->getCustomLabels() ? 'labels custom-labels' : 'labels';
         $labels = "<a class='{$class}'>labels...</a>";
     }
     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}=\"" . Am_Controller::escape($v) . "\"";
     }
     $checkbox = $this->renderHideIfLoggedInCheckbox($brick);
     return "<div {$attrString}>\n        {$brick->getName()}\n        {$configure}\n        {$labels}\n        {$checkbox}\n        </div>";
 }