/** * Interface processor for the product editor * * @author Jonathan Davis * @return void **/ public function editor() { $Shopp = Shopp::object(); if (!current_user_can('shopp_products')) { wp_die(__('You do not have sufficient permissions to access this page.')); } if (empty($Shopp->Product)) { $Product = new ShoppProduct(); $Product->status = "publish"; } else { $Product = $Shopp->Product; } $Product->slug = apply_filters('editable_slug', $Product->slug); $permalink = trailingslashit(Shopp::url()); $Price = new ShoppPrice(); $priceTypes = ShoppPrice::types(); $billPeriods = ShoppPrice::periods(); $workflows = array('continue' => Shopp::__('Continue Editing'), 'close' => Shopp::__('Products Manager'), 'new' => Shopp::__('New Product'), 'next' => Shopp::__('Edit Next'), 'previous' => Shopp::__('Edit Previous')); $taglist = array(); foreach ($Product->tags as $tag) { $taglist[] = $tag->name; } if ($Product->id && !empty($Product->images)) { $ids = join(',', array_keys($Product->images)); $CoverImage = reset($Product->images); $image_table = $CoverImage->_table; $Product->cropped = sDB::query("SELECT * FROM {$image_table} WHERE context='image' AND type='image' AND '2'=SUBSTRING_INDEX(SUBSTRING_INDEX(name,'_',4),'_',-1) AND parent IN ({$ids})", 'array', 'index', 'parent'); } $shiprates = shopp_setting('shipping_rates'); if (!empty($shiprates)) { ksort($shiprates); } $uploader = shopp_setting('uploader_pref'); if (!$uploader) { $uploader = 'flash'; } $process = empty($Product->id) ? 'new' : $Product->id; $_POST['action'] = add_query_arg(array_merge($_GET, array('page' => $this->Admin->pagename('products'))), admin_url('admin.php')); $post_type = ShoppProduct::posttype(); // Re-index menu options to maintain order in JS #2930 if (isset($Product->options['v']) || isset($Product->options['a'])) { $options = array_keys($Product->options); foreach ($options as $type) { foreach ($Product->options[$type] as $id => $menu) { $Product->options[$type][$type . $id] = $menu; $Product->options[$type][$type . $id]['options'] = array_values($menu['options']); unset($Product->options[$type][$id]); } } } else { foreach ($Product->options as &$menu) { $menu['options'] = array_values($menu['options']); } } do_action('add_meta_boxes', ShoppProduct::$posttype, $Product); do_action('add_meta_boxes_' . ShoppProduct::$posttype, $Product); do_action('do_meta_boxes', ShoppProduct::$posttype, 'normal', $Product); do_action('do_meta_boxes', ShoppProduct::$posttype, 'advanced', $Product); do_action('do_meta_boxes', ShoppProduct::$posttype, 'side', $Product); include $this->ui('editor.php'); }
/** * Interface processor for the category editor * * @author Jonathan Davis * @since 1.0 * @return void **/ public function screen() { global $CategoryImages; $Shopp = Shopp::object(); if (!current_user_can('shopp_categories')) { wp_die(__('You do not have sufficient permissions to access this page.')); } $Category = $this->Model; $Price = new ShoppPrice(); $priceTypes = ShoppPrice::types(); $billPeriods = ShoppPrice::periods(); // Build permalink for slug editor $permalink = trailingslashit(Shopp::url()) . "category/"; $Category->slug = apply_filters('editable_slug', $Category->slug); $pricerange_menu = array("disabled" => __('Price ranges disabled', 'Shopp'), "auto" => __('Build price ranges automatically', 'Shopp'), "custom" => __('Use custom price ranges', 'Shopp')); $uploader = shopp_setting('uploader_pref'); if (!$uploader) { $uploader = 'flash'; } $workflows = array("continue" => __('Continue Editing', 'Shopp'), "close" => __('Categories Manager', 'Shopp'), "new" => __('New Category', 'Shopp'), "next" => __('Edit Next', 'Shopp'), "previous" => __('Edit Previous', 'Shopp')); do_action('add_meta_boxes', ProductCategory::$taxon, $Category); do_action('add_meta_boxes_' . ProductCategory::$taxon, $Category); do_action('do_meta_boxes', ProductCategory::$taxon, 'normal', $Category); do_action('do_meta_boxes', ProductCategory::$taxon, 'advanced', $Category); do_action('do_meta_boxes', ProductCategory::$taxon, 'side', $Category); include $this->ui('category.php'); }
/** * @ignore Helper function for shopp_add_product that can be called recursively to validate the associative data array needed to build a product object. * @since 1.2 * * @param array $data the associative array being used to build the product object * @param string $types (optional default:data) Sets the _type that will be evaluated for proper types. $_data is the top level, and each non-built in type is described * in subsequent _type arrays * @param array $problems array of problems that have been found in the data through recursive calls * @return array list of problems with the data preventing proper product object construction **/ function _validate_product_data($data, $types = 'data', $problems = array()) { $t = '_' . $types; if (!is_array($data)) { $problems["{$types} must be an array."] = true; return $problems; } // data properties needed to populate a product $_data = array('name' => 'string', 'slug' => 'string', 'publish' => 'publish', 'categories' => 'terms', 'tags' => 'terms', 'terms' => 'terms', 'description' => 'string', 'summary' => 'string', 'specs' => 'array', 'single' => 'variant', 'variants' => 'variants', 'addons' => 'variants', 'featured' => 'bool', 'packaging' => 'bool', 'processing' => 'processing'); $_publish = array('flag' => 'bool', 'publishtime' => 'timestamp'); $_timestamp = array('month' => 'int', 'day' => 'int', 'year' => 'int', 'hour' => 'int', 'minute' => 'int', 'meridian' => 'enum'); $_meridian = array('AM', 'PM'); $_terms = array('terms' => 'array', 'taxonomy' => 'string'); // variants structure $_variants = array('menu' => 'array', 'count' => 'int', '#' => 'variant'); // single/variant/addon structure $_variant = array('option' => 'array', 'type' => 'enum', 'taxed' => 'bool', 'price' => 'float', 'sale' => 'sale', 'shipping' => 'shipping', 'inventory' => 'inventory', 'donation' => 'donation', 'subscription' => 'subscription'); // order processing estimate $_processing = array('flag' => 'bool', 'min' => 'cycle', 'max' => 'cycle'); // variant types $_types = ShoppPrice::types(); $_type = array(); foreach ($_types as $type) { $_type[] = $type['value']; } // sale price $_sale = array('flag' => 'bool', 'price' => 'float'); // variant shipping settings $_shipping = array('flag' => 'bool', 'fee' => 'float', 'weight' => 'float', 'height' => 'float', 'width' => 'float', 'length' => 'float'); // variant inventory settings $_inventory = array('flag' => 'bool', 'stock' => 'int', 'sku' => 'string'); // variant donation settings $_donation = array('variable' => 'bool', 'minimum' => 'bool'); // variant subscription settings $_subscription = array('trial' => 'trial', 'billcycle' => 'billcycle'); // subscriptions billing cycle $_billcycle = array('cycle' => 'cycle', 'cycles' => 'int'); // subscription trial settings $_trial = array('cycle' => 'cycle', 'price' => 'float'); // time cycles $_cycle = array('interval' => 'int', 'period' => 'enum'); $_periods = ShoppPrice::periods(); $_period = array(); foreach ($_periods[0] as $p) { $_period[] = $p['value']; } $known_types = array('int' => 'is_numeric', 'float' => 'is_numeric', 'bool' => 'is_bool', 'string' => 'is_string', 'array' => 'is_array'); foreach ($data as $key => $value) { if (is_numeric($key) && 'variants' == $types) { $key = '#'; } $k = '_' . $key; $recurse = ${$t}[$key]; $r = '_' . $recurse; if (in_array(${$t}[$key], array_keys($known_types))) { // check known types first if (!$known_types[${$t}[$key]]($value)) { if (!isset($problems['type mismatch'])) { $problems['type mismatch'] = array(); } if (!isset($problems['type mismatch'][$types])) { $problems['type mismatch'][$types] = array(); } $problems['type mismatch'][$types][$key] = ${$t}[$key]; } } else { if ('enum' == ${$t}[$key] && !in_array($value, ${$k})) { // check enumerated types if (!isset($problems['out of range'])) { $problems['out of range'] = array(); } if (!isset($problems['out of range'][$types])) { $problems['out of range'][$types] = array(); } $problems['out of range'][$types][$key] = implode(', ', ${$k}); } else { if (isset(${$r})) { // recurse into provided data structure, and validate $problems = _validate_product_data($value, $recurse, $problems); } else { if (!in_array($key, array_keys(${$t}))) { // unknown data type if (!isset($problems['unknown data type'])) { $problems['unknown data type'] = array(); } if (!isset($problems['unknown data type'][$types])) { $problems['unknown data type'][$types] = array(); } $problems['unknown data type'][$types][] = $key; } } } } if ('single' == $key && isset($data['variants']) || 'variants' == $key && isset($data['single'])) { $problems['both single and variant price definitions detected'] = true; } } return $problems; }
?> ', pluginuri = <?php echo json_encode(SHOPP_PLUGINURI); ?> , rule_groups = <?php echo json_encode($rulegroups); ?> , rule_types = <?php echo json_encode($ruletypes); ?> , bill_periods = <?php echo json_encode(ShoppPrice::periods()); ?> , rules = <?php echo json_encode($MemberPlan->stages); ?> , STAGE_LABEL = <?php _jse('Content Access Rules', 'Shopp'); ?> , STAGES_LABEL = <?php _jse('Step', 'Shopp'); ?> , DELETE_RULE_PROMPT = <?php