コード例 #1
0
ファイル: customer.php プロジェクト: forthrobot/inuvik
 /**
  * Provides the submit login button markup
  *
  * @api `shopp('customer.submit-login')`
  * @since 1.0
  *
  * @param string        $result  The output
  * @param array         $options The options
  * - **autocomplete**: (on, off) Specifies whether an `<input>` element should have autocomplete enabled
  * - **accesskey**: Specifies a shortcut key to activate/focus an element. Linux/Windows: `[Alt]`+`accesskey`, Mac: `[Ctrl]``[Opt]`+`accesskey`
  * - **class**: The class attribute specifies one or more class-names for an element
  * - **disabled**: Specifies that an `<input>` element should be disabled
  * - **placeholder**: Specifies a short hint that describes the expected value of an `<input>` element
  * - **required**: Adds a class that specified an input field must be filled out before submitting the form, enforced by JS
  * - **tabindex**: Specifies the tabbing order of an element
  * - **title**: Specifies extra information about an element
  * - **label**: Specifies the value of the button element. Defaults to `Login`
  * - **redirect**: Specifies the URL the customer is redirected to after login. Defaults to `$_REQUEST['redirect']`.
  * @param ShoppCustomer $O       The working object
  * @return string The button markup
  **/
 public static function submit_login($result, $options, $O)
 {
     $request = $_GET;
     $defaults = array('label' => Shopp::__('Login'), 'redirect' => isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : Shopp::url($request, 'account', ShoppOrder()->security()));
     $options = array_merge($defaults, $options);
     extract($options, EXTR_SKIP);
     $string = '';
     $id = 'submit-login';
     $context = ShoppStorefront::intemplate();
     if (isset($request['acct']) && 'logout' == $request['acct']) {
         unset($request['acct']);
     }
     if ('checkout.php' == $context) {
         $redirect = 'checkout';
         $id .= '-' . $redirect;
     }
     return '<input type="hidden" name="redirect" value="' . esc_attr($redirect) . '" />' . '<input type="submit" name="submit-login" id="' . $id . '"' . inputattrs($options) . ' />';
 }
コード例 #2
0
ファイル: Purchase.php プロジェクト: borkweb/shopp
 public function receipt($template = 'receipt.php')
 {
     if (empty($this->purchased)) {
         $this->load_purchased();
     }
     if ('receipt.php' == $template) {
         // If not overridden
         $context = ShoppStorefront::intemplate();
         // Set receipt context
         if (!empty($context)) {
             $template = "receipt-{$context}";
         }
     }
     ob_start();
     locate_shopp_template(array($template, 'receipt.php'), true);
     $content = ob_get_clean();
     return apply_filters('shopp_order_receipt', $content);
 }
コード例 #3
0
ファイル: Pages.php プロジェクト: jonathandavis/shopp
 public function content($content, $request = false)
 {
     if (!$request) {
         global $wp_query;
         // Test that this is the main query and it is the account page
         if (!$wp_query->is_main_query() || !is_shopp_page('account')) {
             return $content;
         }
     }
     $widget = 'widget' === $request;
     if ($widget) {
         $request = 'menu';
     }
     // Modify widget request to render the account menu
     $orderlookup = '';
     if ('none' == shopp_setting('account_system')) {
         $orderlookup = shopp('customer', 'get-order-lookup');
     }
     // $download_request = get_query_var('s_dl');
     if (!$request) {
         $request = ShoppStorefront()->account['request'];
     }
     $templates = array('account-' . $request . '.php', 'account.php');
     $context = ShoppStorefront::intemplate();
     // Set account page context
     $Errors = ShoppErrorStorefrontNotices();
     ob_start();
     if (apply_filters('shopp_show_account_errors', true) && $Errors->exist()) {
         echo ShoppStorefront::errors(array("errors-{$context}", 'account-errors.php', 'errors.php'));
     }
     if (!empty($orderlookup)) {
         echo $orderlookup;
     } else {
         if ('login' == $request || !ShoppCustomer()->loggedin()) {
             $templates = array('login-' . $request . '.php', 'login.php');
         }
         Shopp::locate_template($templates, true);
     }
     $content = ob_get_clean();
     // Suppress the #shopp div for sidebar widgets
     if ($widget) {
         $content = '<!-- id="shopp" -->' . $content;
     }
     return apply_filters('shopp_account_template', $content, $request);
 }
コード例 #4
0
ファイル: checkout.php プロジェクト: forthrobot/inuvik
 /**
  * Generates the shopping cart summary markup from the `summary.php` template file
  *
  * @api `shopp('checkout.cart-summary')`
  * @since 1.0
  *
  * @param string     $result  The output
  * @param array      $options The options
  * @param ShoppOrder $O       The working object
  * @return string The generated cart summary markup
  **/
 public static function cart_summary($result, $options, $O)
 {
     $templates = array('summary.php');
     $context = ShoppStorefront::intemplate();
     // Set summary context
     if (!empty($context)) {
         // Prepend the summary-context.php template file
         array_unshift($templates, "summary-{$context}");
     }
     ob_start();
     locate_shopp_template($templates, true);
     $content = ob_get_clean();
     // If inside the checkout form, strip the extra <form> tag so we don't break standards
     // This is ugly, but necessary given the different markup contexts the cart summary is used in
     if ('checkout.php' == $context) {
         $content = preg_replace('/<\\/?form.*?>/', '', $content);
     }
     return $content;
 }
コード例 #5
0
ファイル: Core.php プロジェクト: BlessySoftwares/anvelocom
 /**
  * Sends an email message based on a specified template file
  *
  * Sends an e-mail message in the format of a specified e-mail
  * template file using variable substitution for variables appearing in
  * the template as a bracketed [variable] with data from the
  * provided data array or the super-global $_POST array
  *
  * @author Jonathan Davis
  * @since 1.0
  *
  * @param string $template Email template file path (or a string containing the template itself)
  * @param array $data The data to populate the template with
  * @return boolean True on success, false on failure
  **/
 public static function email($template, array $data = array())
 {
     $debug = defined('SHOPP_DEBUG_EMAIL') && SHOPP_DEBUG_EMAIL;
     $headers = array();
     $to = $subject = $message = '';
     $addrs = array('from', 'sender', 'reply-to', 'to', 'cc', 'bcc');
     $protected = array_merge($addrs, array('subject'));
     if (false == strpos($template, "\n") && file_exists($template)) {
         $templatefile = $template;
         // Include to parse the PHP and Theme API tags
         ob_start();
         ShoppStorefront::intemplate($templatefile);
         include $templatefile;
         ShoppStorefront::intemplate('');
         $template = ob_get_clean();
         if (empty($template)) {
             return shopp_add_error(Shopp::__('Could not open the email template because the file does not exist or is not readable.'), SHOPP_ADMIN_ERR, array('template' => $templatefile));
         }
     }
     // Sanitize line endings
     $template = str_replace(array("\r\n", "\r"), "\n", $template);
     $lines = explode("\n", $template);
     // Collect headers
     while ($line = array_shift($lines)) {
         if (false === strpos($line, ':')) {
             continue;
         }
         // Skip invalid header lines
         list($header, $value) = explode(':', $line, 2);
         $header = strtolower($header);
         if (in_array($header, $protected)) {
             // Protect against header injection
             $value = str_replace(array("\n", "\r"), '', rawurldecode($value));
         }
         if (in_array($header, array('to', 'subject'))) {
             $headers[$header] = trim($value);
         } else {
             $headers[$header] = $line;
         }
     }
     $message = join("\n", $lines);
     // If not already in place, setup default system email filters
     ShoppEmailDefaultFilters::init();
     // Message filters first
     $message = apply_filters('shopp_email_message', $message, $headers);
     $headers = apply_filters('shopp_email_headers', $headers, $message);
     $to = $headers['to'];
     unset($headers['to']);
     $subject = $headers['subject'];
     unset($headers['subject']);
     $sent = wp_mail($to, $subject, $message, $headers);
     do_action('shopp_email_completed');
     if ($debug) {
         shopp_debug("To: " . htmlspecialchars($to) . "\n");
         shopp_debug("Subject: {$subject}\n\n");
         shopp_debug("Headers:\n");
         shopp_debug("\nMessage:\n{$message}\n");
     }
     return $sent;
 }