public function generateLink($options = array()) { if ($this->_validateOptions($options)) { $encodedOptions = $this->encodeUrlParam($options); return UrlHelper::getActionUrl('vCard', array('vcard' => $encodedOptions)); } }
public function pluginUpdatePluginsUrl($plugins) { Craft::log(__METHOD__, LogLevel::Info, true); if (is_array($plugins)) { $plugins = implode(",", $plugins); } return UrlHelper::getActionUrl('oauth/plugin/updatePlugins', array('plugins' => $plugins)); }
/** * Method that triggers any pending tasks immediately. */ private function _triggerTasksNow() { $url = UrlHelper::getActionUrl('tasks/runPendingTasks'); if (function_exists('curl_init')) { $ch = curl_init($url); $options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => false, CURLOPT_NOSIGNAL => true); if (defined('CURLOPT_TIMEOUT_MS')) { $options[CURLOPT_TIMEOUT_MS] = 500; } else { $options[CURLOPT_TIMEOUT] = 1; } curl_setopt_array($ch, $options); curl_exec($ch); $curlErrorNo = curl_errno($ch); $curlError = curl_error($ch); $httpStatus = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE)); curl_close($ch); if ($curlErrorNo !== 0) { ImagerPlugin::log("Request for running tasks immediately failed with error number {$curlErrorNo} and error message: {$curlError}", LogLevel::Error); } if ($httpStatus !== 200) { ImagerPlugin::log("Request for running tasks immediately failed with http status {$httpStatus}", LogLevel::Error); } } }
/** * Connect */ public function connect($variables) { if (!craft()->httpSession->get('oauth.response')) { // we don't have any response yet, get ready to connect // clean session $this->_sessionClean(); // get provider $provider = craft()->oauth->getProvider($variables['provider']); // referer if (!empty($variables['referer'])) { $referer = $variables['referer']; } else { $referer = craft()->request->getUrl(); } craft()->httpSession->add('oauth.referer', $referer); // scope if (!empty($variables['scope'])) { $scope = $variables['scope']; } else { $scope = []; } craft()->httpSession->add('oauth.scope', $scope); // authorizationOptions if (!empty($variables['authorizationOptions'])) { $authorizationOptions = $variables['authorizationOptions']; } else { $authorizationOptions = []; // $authorizationOptions = $provider->getauthorizationOptions(); } craft()->httpSession->add('oauth.authorizationOptions', $authorizationOptions); // redirect url $redirectUrl = UrlHelper::getActionUrl('oauth/connect/', array('provider' => $variables['provider'])); OauthPlugin::log('Redirect to OAuth Connect' . "\r\n" . 'Redirect to: ' . $redirectUrl . "\r\n" . 'Session Data: ' . print_r(['oauth.referer' => $referer, 'oauth.scope' => $scope, 'oauth.authorizationOptions' => $authorizationOptions], true) . "\r\n", LogLevel::Info); // redirect craft()->request->redirect($redirectUrl); } else { // populate token object from response $response = craft()->httpSession->get('oauth.response'); craft()->httpSession->remove('oauth.response'); OauthPlugin::log('OAuth Connect - Retrieve token from response' . "\r\n" . 'Session Data: ' . print_r(['oauth.response' => $response], true) . "\r\n", LogLevel::Info); if ($response['token']) { // response token to token model $token = new Oauth_TokenModel(); $provider = $this->getProvider($variables['provider']); if ($provider) { switch ($provider->getOauthVersion()) { case 1: if (!empty($response['token']['identifier'])) { $token->accessToken = $response['token']['identifier']; } if (!empty($response['token']['secret'])) { $token->secret = $response['token']['secret']; } break; case 2: if (!empty($response['token']['accessToken'])) { $token->accessToken = $response['token']['accessToken']; } if (!empty($response['token']['endOfLife'])) { $token->endOfLife = $response['token']['endOfLife']; } if (!empty($response['token']['refreshToken'])) { $token->refreshToken = $response['token']['refreshToken']; } break; } } $token->providerHandle = $variables['provider']; $token->pluginHandle = $variables['plugin']; OauthPlugin::log('OAuth Connect - Token' . "\r\n" . print_r(["Token: \r\n" . print_r($token->getAttributes(), true)], true), LogLevel::Info); $response['token'] = $token; } $this->_sessionClean(); return $response; } }
/** * Returns the link to the Order's PDF file for download. * @param string $option * @return string */ public function getPdfUrl($option = '') { return UrlHelper::getActionUrl('market/download/pdf?number=' . $this->number . "&option=" . $option); }
public function renderSeoMetrics() { $oldPath = method_exists(craft()->templates, 'getTemplatesPath') ? craft()->templates->getTemplatesPath() : craft()->path->getTemplatesPath(); $newPath = craft()->path->getPluginsPath() . 'seomatic/templates'; method_exists(craft()->templates, 'setTemplatesPath') ? craft()->templates->setTemplatesPath($newPath) : craft()->path->setTemplatesPath($newPath); /* -- Render the SEOmatic metrics floater template */ $requestUrl = $this->getFullyQualifiedUrl(craft()->request->url); $keywords = ""; $urlParams = array('url' => $requestUrl, 'keywords' => $keywords); $metricsActionUrl = UrlHelper::getActionUrl('seomatic/renderMetrics', $urlParams); $vars = array('metricsActionUrl' => $metricsActionUrl); $htmlText = craft()->templates->render('_seo_metrics_floater.twig', $vars); craft()->templates->includeFootHtml($htmlText); method_exists(craft()->templates, 'setTemplatesPath') ? craft()->templates->setTemplatesPath($oldPath) : craft()->path->setTemplatesPath($oldPath); }
/** * Returns the redirect URI * * @return array|string */ public function getRedirectUri() { // Force `addTrailingSlashesToUrls` to `false` while we generate the redirectUri $addTrailingSlashesToUrls = \Craft\craft()->config->get('addTrailingSlashesToUrls'); \Craft\craft()->config->set('addTrailingSlashesToUrls', false); $redirectUri = \Craft\UrlHelper::getActionUrl('oauth/connect'); // Set `addTrailingSlashesToUrls` back to its original value \Craft\craft()->config->set('addTrailingSlashesToUrls', $addTrailingSlashesToUrls); // We don't want the CP trigger showing in the action URL. $redirectUri = str_replace(\Craft\craft()->config->get('cpTrigger') . '/', '', $redirectUri); OauthPlugin::log('Redirect URI: ' . $redirectUri, LogLevel::Info); return $redirectUri; }
public function connect($variables) { if (!craft()->httpSession->get('oauth.response')) { craft()->oauth->sessionClean(); if (!empty($variables['referer'])) { $referer = $variables['referer']; } else { $referer = craft()->request->getUrl(); } craft()->httpSession->add('oauth.referer', $referer); // redirect if (!empty($variables['redirect'])) { $redirect = $variables['redirect']; } else { $redirect = craft()->request->getUrlReferrer(); } craft()->httpSession->add('oauth.redirect', $redirect); // error redirect if (!empty($variables['errorRedirect'])) { $errorRedirect = $variables['errorRedirect']; } else { $errorRedirect = craft()->request->getUrlReferrer(); } craft()->httpSession->add('oauth.errorRedirect', $errorRedirect); // scopes if (!empty($variables['scopes'])) { $scopes = $variables['scopes']; } else { $scopes = array(); } craft()->httpSession->add('oauth.scopes', $scopes); // params if (!empty($variables['params'])) { $params = $variables['params']; } else { $params = array(); } craft()->httpSession->add('oauth.params', $params); // redirect craft()->request->redirect(UrlHelper::getActionUrl('oauth/connect/', array('provider' => $variables['provider']))); } else { $response = craft()->httpSession->get('oauth.response'); if (!empty($response['token'])) { $response['token'] = craft()->oauth->arrayToToken($response['token']); } craft()->oauth->sessionClean(); return $response; } }
/** * Connect */ public function connect($variables) { if (!craft()->httpSession->get('oauth.response')) { // we don't have any response yet, get ready to connect // clean session $this->_sessionClean(); // get provider $provider = craft()->oauth->getProvider($variables['provider']); // referer if (!empty($variables['referer'])) { $referer = $variables['referer']; } else { $referer = craft()->request->getUrl(); } craft()->httpSession->add('oauth.referer', $referer); // scopes if (!empty($variables['scopes'])) { $scopes = $variables['scopes']; } else { $scopes = $provider->getScopes(); } craft()->httpSession->add('oauth.scopes', $scopes); // params if (!empty($variables['params'])) { $params = $variables['params']; } else { $params = $provider->getParams(); } craft()->httpSession->add('oauth.params', $params); // redirect craft()->request->redirect(UrlHelper::getActionUrl('oauth/connect/', array('provider' => $variables['provider']))); } else { // populate token object from response $response = craft()->httpSession->get('oauth.response'); if (!empty($response['token'])) { // response token to token model $token = new Oauth_TokenModel(); $provider = $this->getProvider($variables['provider']); if ($provider) { switch ($provider->oauthVersion) { case 1: if (!empty($response['token']['identifier'])) { $token->accessToken = $response['token']['identifier']; } if (!empty($response['token']['secret'])) { $token->secret = $response['token']['secret']; } break; case 2: if (!empty($response['token']['accessToken'])) { $token->accessToken = $response['token']['accessToken']; } if (!empty($response['token']['expires'])) { $token->endOfLife = $response['token']['expires']; } if (!empty($response['token']['refreshToken'])) { $token->refreshToken = $response['token']['refreshToken']; } break; } } $token->providerHandle = $variables['provider']; $token->pluginHandle = $variables['plugin']; $response['token'] = $token; } $this->_sessionClean(); return $response; } }
/** * @param Market_TransactionModel $transaction * @param CreditCard $card * * @return array */ private function buildPaymentRequest(Market_TransactionModel $transaction, CreditCard $card = null) { $request = ['amount' => $transaction->amount, 'currency' => craft()->market_settings->getOption('defaultCurrency'), 'transactionId' => $transaction->id, 'clientIp' => craft()->request->getIpAddress(), 'returnUrl' => UrlHelper::getActionUrl('market/cartPayment/complete', ['id' => $transaction->id, 'hash' => $transaction->hash]), 'cancelUrl' => UrlHelper::getSiteUrl($transaction->order->cancelUrl)]; if ($card) { $request['card'] = $card; } return $request; }
public function block_foot($context, array $blocks = array()) { // line 37 echo "\t<noscript>\n\t\t<div class=\"message-container no-access\">\n\t\t\t<div class=\"pane notice\">\n\t\t\t\t<p>"; // line 40 echo twig_escape_filter($this->env, \Craft\Craft::t("JavaScript must be enabled to access the Craft control panel."), "html", null, true); echo "</p>\n\t\t\t</div>\n\t\t</div>\n\t</noscript>\n\n\t<script type=\"text/javascript\">\n\t\twindow.Craft = {\n\t\t\tsiteUid: \""; // line 47 echo twig_escape_filter($this->env, twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "app"), "getSiteUid", array(), "method"), "js"), "html", null, true); echo "\",\n\t\t\tbaseUrl: \""; // line 48 echo twig_escape_filter($this->env, twig_escape_filter($this->env, \Craft\UrlHelper::getUrl(), "js"), "html", null, true); echo "\",\n\t\t\tbaseCpUrl: \""; // line 49 echo twig_escape_filter($this->env, twig_escape_filter($this->env, \Craft\UrlHelper::getCpUrl(), "js"), "html", null, true); echo "\",\n\t\t\tbaseSiteUrl: \""; // line 50 echo twig_escape_filter($this->env, twig_escape_filter($this->env, \Craft\UrlHelper::getSiteUrl(), "js"), "html", null, true); echo "\",\n\t\t\tactionUrl: \""; // line 51 echo twig_escape_filter($this->env, twig_escape_filter($this->env, \Craft\UrlHelper::getActionUrl(), "js"), "html", null, true); echo "\",\n\t\t\tresourceUrl: \""; // line 52 echo twig_escape_filter($this->env, twig_escape_filter($this->env, \Craft\UrlHelper::getResourceUrl(), "js"), "html", null, true); echo "\",\n\t\t\tscriptName: \""; // line 53 echo twig_escape_filter($this->env, twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "request"), "getScriptName", array(), "method"), "js"), "html", null, true); echo "\",\n\t\t\tomitScriptNameInUrls: "; // line 54 echo $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "config"), "omitScriptNameInUrls", array(), "method") ? "true" : "false"; echo ",\n\t\t\tusePathInfo: "; // line 55 echo $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "config"), "usePathInfo", array(), "method") ? "true" : "false"; echo ",\n\t\t\tresourceTrigger: \""; // line 56 echo twig_escape_filter($this->env, twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "config"), "getResourceTrigger", array(), "method"), "js"), "html", null, true); echo "\",\n\t\t\tactionTrigger: \""; // line 57 echo twig_escape_filter($this->env, twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "config"), "actionTrigger"), "js"), "html", null, true); echo "\",\n\t\t\tpath: \""; // line 58 echo twig_escape_filter($this->env, twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "request"), "getPath", array(), "method"), "js"), "html", null, true); echo "\",\n\t\t\tlocale: \""; // line 59 echo twig_escape_filter($this->env, twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "craft"), "locale"), "js"), "html", null, true); echo "\",\n\t\t\torientation: \""; // line 60 echo twig_escape_filter($this->env, twig_escape_filter($this->env, $this->getContext($context, "orientation"), "js"), "html", null, true); echo "\",\n\t\t\tleft: \""; // line 61 echo $this->getContext($context, "orientation") == "ltr" ? "left" : "right"; echo "\",\n\t\t\tright: \""; // line 62 echo $this->getContext($context, "orientation") == "ltr" ? "right" : "left"; echo "\",\n\t\t\tPersonal: "; // line 63 echo twig_escape_filter($this->env, $this->getContext($context, "CraftPersonal"), "html", null, true); echo ",\n\t\t\tClient: "; // line 64 echo twig_escape_filter($this->env, $this->getContext($context, "CraftClient"), "html", null, true); echo ",\n\t\t\tPro: "; // line 65 echo twig_escape_filter($this->env, $this->getContext($context, "CraftPro"), "html", null, true); echo ",\n\t\t\tedition: "; // line 66 echo twig_escape_filter($this->env, $this->getContext($context, "CraftEdition"), "html", null, true); echo ",\n\t\t\tisLocalized: "; // line 67 echo $this->getAttribute($this->getContext($context, "craft"), "isLocalized", array(), "method") ? "true" : "false"; echo ",\n\t\t\ttranslations: "; // line 68 echo \Craft\craft()->templates->getTranslations(); echo ",\n\t\t\tmaxUploadSize: "; // line 69 echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "app"), "getMaxUploadSize", array(), "method"), "html", null, true); echo ",\n\t\t\tslugWordSeparator: \""; // line 70 echo twig_escape_filter($this->env, twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "config"), "slugWordSeparator"), "js"), "html", null, true); echo "\"\n\t\t};\n\n\t\twindow.Craft.fileKinds = {};\n\t\t"; // line 74 $context['_parent'] = (array) $context; $context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "app"), "getFileKinds", array(), "method")); foreach ($context['_seq'] as $context["kind"] => $context["info"]) { // line 75 echo "\t\t\twindow.Craft.fileKinds."; echo twig_escape_filter($this->env, $this->getContext($context, "kind"), "html", null, true); echo " = [];\n\t\t\t"; // line 76 $context['_parent'] = (array) $context; $context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getContext($context, "info"), "extensions")); foreach ($context['_seq'] as $context["_key"] => $context["extension"]) { // line 77 echo "\t\t\t\twindow.Craft.fileKinds."; echo twig_escape_filter($this->env, $this->getContext($context, "kind"), "html", null, true); echo ".push(\""; echo twig_escape_filter($this->env, $this->getContext($context, "extension"), "html", null, true); echo "\");\n\t\t\t"; } $_parent = $context['_parent']; unset($context['_seq'], $context['_iterated'], $context['_key'], $context['extension'], $context['_parent'], $context['loop']); $context = array_intersect_key($context, $_parent) + $_parent; // line 79 echo "\t\t"; } $_parent = $context['_parent']; unset($context['_seq'], $context['_iterated'], $context['kind'], $context['info'], $context['_parent'], $context['loop']); $context = array_intersect_key($context, $_parent) + $_parent; // line 80 echo "\t</script>\n"; }