/** * @param Customweb_IForm $form */ public function __construct(Customweb_IForm $form = null) { if ($form !== null) { $this->setButtons($form->getButtons())->setElementGroups($form->getElementGroups())->setId($form->getId())->setMachineName($form->getMachineName())->setRequestMethod($form->getRequestMethod())->setTargetUrl($form->getTargetUrl())->setTargetWindow($form->getTargetWindow())->setTitle($form->getTitle()); } else { $this->id = Customweb_Util_Rand::getUuid(); } }
/** * Get the javascript to send the shipping method form via ajax. * * $shippingPaneSelector and $confirmationPaneSelector are jquery selectors pointing to the pane element surrounding the shipping method and * confirmation forms. * * Customweb.ExternalCheckout.submit() can be used to submit the shipping method form manually. * * @param string $shippingPaneSelector * @param string $confirmationPaneSelector * @return string */ protected final function getAjaxJavascript($shippingPaneSelector, $confirmationPaneSelector) { $jqueryVariableName = 'j' . Customweb_Util_Rand::getRandomString(30); $javascript = Customweb_Core_Util_Class::readResource('Customweb_Payment_ExternalCheckout', 'ExternalCheckout.js') . "\n\n"; $variables = array('jQueryNameSpace' => $jqueryVariableName); foreach ($variables as $variableName => $value) { $javascript = str_replace('____' . $variableName . '____', $value, $javascript); } $javascript .= Customweb_Util_JavaScript::getLoadJQueryCode('1.10.2', $jqueryVariableName, 'function() { Customweb.ExternalCheckout.init("' . $shippingPaneSelector . '", "' . $confirmationPaneSelector . '"); }') . "\n\n"; return $javascript; }
public static function generateMandateId($schema) { $variables = array('{day}' => date('d'), '{month}' => date('m'), '{year}' => date('Y'), '{random}' => strtoupper(Customweb_Util_Rand::getRandomString('20'))); $result = $schema; foreach ($variables as $variableName => $variableValue) { if (strstr($schema, $variableName) === false) { throw new Exception(Customweb_I18n_Translation::__("The SEPA mandate schema does not contain the tag '!tag'. This tag is required.", array('!tag' => $variableName))); } $result = str_replace($variableName, $variableValue, $result); } // Remove unallowed chars, cut of to accepted length return self::sanitizeMandateId($result); }
/** * This method returns a JavaScript snipped which loads jQuery library. The process checks if the given * version is already present, then the library is not loaded again. In any case the jQuery is linked to * the given variable name. Which allows the loading in "noConflict" mode. This makes it more easy to * load jQuery in multiple versions and no conflicts with other libraries should occur. * * When the library is loaded the callback function is called. The callback function is either a named * function or better an anonymous function. The anonymous function must be formulated as following: * <code> * function() { * alert("this code is executed"); * } * </code> * * @param string $versionNumber The version number to be used. Deprecated, not used anymore. * @param string $jqueryVariableName The variable name into which jQuery will be loaded into. * @param string $onLoadCallbackFunction The callback function, which is called when jQuery is loaded. * @return string The resulting JavaScript code to perform the load process. */ public static function getLoadJQueryCode($versionNumber, $jqueryVariableName, $onLoadCallbackFunction) { $jqueryScriptUrl = '//cdn.rawgit.com/customweb/jquery-noconflict/master/jquery.min.js'; $localJqueryScript = dirname(__FILE__) . '/jquery-local.txt'; if (file_exists($localJqueryScript)) { $jqueryScriptUrl = file_get_contents($localJqueryScript); } $functionInvocationCode = $onLoadCallbackFunction . '();'; $onLoadCallbackFunction = trim($onLoadCallbackFunction); if (strpos($onLoadCallbackFunction, 'function') === 0) { $functionInvocationCode = '(' . $onLoadCallbackFunction . ')();'; } $globalJQueryVariableName = 'cwJquery' . md5($_SERVER['SERVER_NAME']); $js = ''; $callbackAfterLoadFunctionName = 'a' . Customweb_Util_Rand::getRandomString(30); $js .= 'var ' . $jqueryVariableName . ' = "";'; $js .= 'var ' . $callbackAfterLoadFunctionName . ' = function() { ' . $jqueryVariableName . ' = wKWa7Q3254geN4.noConflict( true ); window.' . $globalJQueryVariableName . ' = ' . $jqueryVariableName . '; '; $js .= $jqueryVariableName . '( document ).ready(function() { '; $js .= ' ' . $functionInvocationCode . ' '; $js .= ' }); };' . "\n"; $js .= '{ function r(f){/in/.test(document.readyState)?setTimeout("r("+f+")",9):f()} r(function() {'; $js .= 'if (typeof window.' . $globalJQueryVariableName . ' !== "undefined") {' . "\n"; $js .= $jqueryVariableName . ' = window.' . $globalJQueryVariableName . ';'; $js .= $jqueryVariableName . '( document ).ready(function() { '; $js .= ' ' . $functionInvocationCode . ' '; $js .= ' });' . "\n"; $js .= '} else {' . "\n"; $js .= 'var script_tag = document.createElement(\'script\');' . "\n"; $js .= 'script_tag.setAttribute("type", "text/javascript");' . "\n"; $js .= 'script_tag.setAttribute("src", "' . $jqueryScriptUrl . '")' . "\n"; $js .= 'script_tag.onload = ' . $callbackAfterLoadFunctionName . ';' . "\n"; $js .= 'script_tag.onreadystatechange = function() { // IE hack' . "\n"; $js .= 'if (this.readyState == \'complete\' || this.readyState == \'loaded\') {' . "\n"; $js .= $callbackAfterLoadFunctionName . "();\n"; $js .= '}' . "\n"; $js .= '}' . "\n"; $js .= 'document.getElementsByTagName("head")[0].appendChild(script_tag);' . "\n"; $js .= '}}); }' . "\n"; return $js; }
protected function getCardHandlerJavaScriptNameSpace() { if ($this->cardHandlerJavaScriptNameSpace === null) { $this->cardHandlerJavaScriptNameSpace = 'c' . Customweb_Util_Rand::getRandomString(30); } return $this->cardHandlerJavaScriptNameSpace; }
public function resetKey() { $this->key = Customweb_Util_Rand::getRandomString(32, ''); return $this; }
/** * Constructor of the class * * @param string $controlName The name of the control / field name. */ public function __construct($controlName) { $this->controlName = $controlName; $this->controlId = Customweb_Util_Rand::getUuid(); }
public function __construct(Customweb_DependencyInjection_IContainer $container) { $this->container = $container; $this->id = Customweb_Util_Rand::getUuid(); }