コード例 #1
0
 /**
  * Report on the currently loading template
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @return string The template file being loaded
  **/
 public static function intemplate($template = null)
 {
     if (isset($template)) {
         self::$template = basename($template);
     }
     if (empty(self::$template)) {
         return '';
     }
     return self::$template;
 }
コード例 #2
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) . ' />';
 }
コード例 #3
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);
 }
コード例 #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
ファイル: Pages.php プロジェクト: jonathandavis/shopp
 public function content($content)
 {
     global $wp_query;
     // Test that this is the main query and it is a product
     if (!$wp_query->is_main_query() || !is_shopp_product()) {
         return $content;
     }
     $Product = ShoppProduct();
     $templates = array('product.php');
     if (isset($Product->id) && !empty($Product->id)) {
         array_unshift($templates, 'product-' . $Product->id . '.php');
     }
     if (isset($Product->slug) && !empty($Product->slug)) {
         array_unshift($templates, 'product-' . $Product->slug . '.php');
     }
     // Load product summary data, before checking inventory
     if (!isset($Product->summed)) {
         $Product->load_data(array('summary'));
     }
     if (Shopp::str_true($Product->inventory) && $Product->stock < 1) {
         array_unshift($templates, 'product-outofstock.php');
     }
     ob_start();
     locate_shopp_template($templates, true);
     $content = ob_get_contents();
     ob_end_clean();
     return ShoppStorefront::wrapper($content);
 }
コード例 #6
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;
 }
コード例 #7
0
ファイル: storefront.php プロジェクト: jonathandavis/shopp
 /**
  * Checks if the storefront has any categories
  *
  * @api `shopp('storefront.has-categories')`
  * @since 1.1
  *
  * @param string          $result  The output
  * @param array           $options The options
  * - **showsmart**: (before,after) Include smart collections before or after the categories
  * @param ShoppStorefront $O       The working object
  * @return bool True if categories exist, false otherwise
  **/
 public static function has_categories($result, $options, $O)
 {
     $defaults = array('showsmart' => false);
     $options = array_merge($defaults, $options);
     extract($options, EXTR_SKIP);
     if (empty($O->categories)) {
         $O->load_categories($options, $showsmart);
     } else {
         // Make sure each entry is a valid ProductCollection to prevent fatal errors @bug #2017
         foreach ($O->categories as $id => $term) {
             if ($Category instanceof ProductCollection) {
                 continue;
             }
             $ProductCategory = new ProductCategory();
             $ProductCategory->populate($term);
             $O->categories[$id] = $ProductCategory;
         }
         reset($O->categories);
         return true;
     }
     reset($O->categories);
     return count($O->categories) > 0;
 }