function delta($current_value, $old_value) { if ($current_value == $old_value) { return '--'; } return percentage($current_value - $old_value, $old_value, 1, 'NA', '%', true); }
function get_wait_info($data) { require_once 'common_natural_language.php'; global $mysqli; $fork_key = $data['fork_key']; $sql = sprintf("select `Fork Key`,`Fork Result`,`Fork Scheduled Date`,`Fork Start Date`,`Fork State`,`Fork Type`,`Fork Operations Done`,`Fork Operations No Changed`,`Fork Operations Errors`,`Fork Operations Total Operations` from `Fork Dimension` where `Fork Key`=%d ", $fork_key); $res = $mysqli->query($sql); if ($row = $res->fetch_assoc()) { $result_extra_data = array(); switch ($data['tag']) { case 'journals': $formated_tag = ' ' . ngettext('journal', 'journals', $row['Fork Operations Total Operations']); break; default: $formated_tag = ' ' . ngettext('record', 'records', $row['Fork Operations Total Operations']); } $etr = ''; if ($row['Fork State'] == 'In Process') { //$msg=number($row['Fork Operations Done']+$row['Fork Operations Errors']+$row['Fork Operations No Changed']).'/'.$row['Fork Operations Total Operations']; $formated_status = _('In Process'); $formated_progress = _('Processing') . ' ' . number($row['Fork Operations Done']) . ' ' . _('of') . ' ' . number($row['Fork Operations Total Operations']); $formated_progress .= $formated_tag; if ($row['Fork Operations Done'] > 1) { $etr = _('ETA') . ': ' . seconds_to_string(($row['Fork Operations Total Operations'] - $row['Fork Operations Done']) * (gmdate('U') - strtotime($row['Fork Start Date'])) / $row['Fork Operations Done']); } } elseif ($row['Fork State'] == 'Queued') { $formated_status = _('Queued'); $formated_progress = _('Records to process') . ': ' . number($row['Fork Operations Total Operations']); } elseif ($row['Fork State'] == 'Finished') { $formated_status = _('Finished'); $formated_progress = number($row['Fork Operations Done']) . $formated_tag . ' ' . _('processed'); } elseif ($row['Fork State'] == 'Cancelled') { $formated_status = _('Cancelled'); $formated_progress = number($row['Fork Operations Done']) . $formated_tag . ' ' . _('processed'); } else { $formated_status = $row['Fork State']; $formated_progress = ''; } $response = array('state' => 200, 'date' => gmdate('Y-m-d H:i:s'), 'fork_key' => $fork_key, 'fork_state' => $row['Fork State'], 'done' => number($row['Fork Operations Done']), 'no_changed' => number($row['Fork Operations No Changed']), 'errors' => number($row['Fork Operations Errors']), 'total' => number($row['Fork Operations Total Operations']), 'todo' => number($row['Fork Operations Total Operations'] - $row['Fork Operations Done']), 'result' => $row['Fork Result'], 'formated_status' => $formated_status, 'formated_progress' => $formated_progress . '<br>' . $etr, 'progress' => sprintf('%s/%s (%s)', number($row['Fork Operations Done']), number($row['Fork Operations Total Operations']), percentage($row['Fork Operations Done'], $row['Fork Operations Total Operations'])), 'tag' => $data['tag'], 'result_extra_data' => $result_extra_data, 'etr' => $etr); echo json_encode($response); } else { $response = array('state' => 400); echo json_encode($response); } }
function Step2() { $q = new mysql_squid_builder(); percentage("Fix tables", 2); $q->FixTables(); percentage("check_to_hour_tables", 2); $squid_stats_tools = new squid_stats_tools(); $squid_stats_tools->check_to_hour_tables(true); percentage("not_categorized_day_scan", 2); $squid_stats_tools->not_categorized_day_scan(); }
public function column_quality($Item) { $quality = isset(ShoppImageSetting::$qualities[$Item->quality]) ? ShoppImageSetting::$qualities[$Item->quality] : $Item->quality; $quality = percentage($quality, array('precision' => 0)); echo esc_html($quality); }
$response->header('Content-Type', 'application/json'); return $response; } }); Route::post('upload/data', 'MediaController@uploadData'); Route::post('upload/file', 'MediaController@uploadFile'); Route::get('premium', function () { if (Auth::guest()) { } else { return View::make('widgets.premium'); } }); Route::get('user/settings', function () { if (Auth::guest()) { } else { $data = array('avlbytes' => getfilesize(Auth::user()->avl_bytes), 'usedbytes' => getfilesize(Auth::user()->used_bytes), 'freebytes' => getfilesize(Auth::user()->avl_bytes - Auth::user()->used_bytes), 'perc' => percentage(Auth::user()->used_bytes, Auth::user()->avl_bytes, '1'), 'plan_name' => Auth::user()->category()->name, 'plan_exp' => Auth::user()->prem_valid, 'set_ea' => Auth::user()->ea, 'set_sub_lng' => Auth::user()->default_sub_lng); return View::make('widgets.settings', $data); } }); Route::get('user/share/{id}', function ($id) { if (Auth::user()->category_id == 1 || Auth::user()->category_id == 27) { } else { $user_media = UserMedia::where('uni_id', '=', $id)->where('user_id', '=', Auth::user()->id)->first(); if (isset($user_media->id)) { $share_m = ShareMedia::where('user_id', '=', Auth::user()->id)->where('media_id', '=', $user_media->media_id)->first(); if (isset($share_m->id)) { $link = "http://okaydrive.com/share/" . $share_m->uni_id; } else { $media = Media::where('id', '=', $user_media->media_id)->first(); if ($media->state == "done") { $new_smedia = new ShareMedia();
/** * Provides ecart('cart') template api functionality * * @since 1.0 * * @return mixed **/ function tag ($property,$options=array()) { global $Ecart; $submit_attrs = array('title','value','disabled','tabindex','accesskey','class'); // Return strings with no options switch ($property) { case "url": return ecarturl(false,'cart'); break; case "referrer": case "referer": $referrer = $Ecart->Shopping->data->referrer; if (!$referrer) $referrer = ecart('catalog','url','return=1'); return $referrer; break; case "hasitems": case "has-items": return (count($this->contents) > 0); break; case "totalitems": case "total-items": return $this->Totals->quantity; break; case "items": if (!isset($this->_item_loop)) { reset($this->contents); $this->_item_loop = true; } else next($this->contents); if (current($this->contents)) return true; else { unset($this->_item_loop); reset($this->contents); return false; } break; case "hasshipped": case "has-shipped": return $this->shipped(); break; case "shippeditems": case "shipped-items": if (!isset($this->_shipped_loop)) { reset($this->shipped); $this->_shipped_loop = true; } else next($this->shipped); if (current($this->shipped)) return true; else { unset($this->_shipped_loop); reset($this->shipped); return false; } break; case "hasdownloads": case "has-downloads": return $this->downloads(); break; case "downloaditems": case "download-items": if (!isset($this->_downloads_loop)) { reset($this->downloads); $this->_downloads_loop = true; } else next($this->downloads); if (current($this->downloads)) return true; else { unset($this->_downloads_loop); reset($this->downloads); return false; } break; case "lastitem": case "last-item": return $this->contents[$this->added]; break; case "totalpromos": case "total-promos": return count($this->discounts); break; case "haspromos": case "has-promos": return (count($this->discounts) > 0); break; case "discounts": case "promos": if (!isset($this->_promo_looping)) { reset($this->discounts); $this->_promo_looping = true; } else next($this->discounts); $discount = current($this->discounts); while ($discount && empty($discount->applied) && !$discount->freeshipping) $discount = next($this->discounts); if (current($this->discounts)) return true; else { unset($this->_promo_looping); reset($this->discounts); return false; } case "promoname": case "promo-name": $discount = current($this->discounts); if ($discount->applied == 0 && empty($discount->items) && !isset($this->freeshipping)) return false; return $discount->name; break; case "promodiscount": case "promo-discount": $discount = current($this->discounts); if ($discount->applied == 0 && empty($discount->items) && !isset($this->freeshipping)) return false; if (!isset($options['label'])) $options['label'] = ' '.__('Off!','Ecart'); else $options['label'] = ' '.$options['label']; $string = false; if (!empty($options['before'])) $string = $options['before']; switch($discount->type) { case "Free Shipping": $string .= money($discount->freeshipping).$options['label']; break; case "Percentage Off": $string .= percentage($discount->discount,array('precision' => 0)).$options['label']; break; case "Amount Off": $string .= money($discount->discount).$options['label']; break; case "Buy X Get Y Free": return sprintf(__('Buy %s get %s free','Ecart'),$discount->buyqty,$discount->getqty); break; } if (!empty($options['after'])) $string .= $options['after']; return $string; break; case "function": $result = '<div class="hidden"><input type="hidden" id="cart-action" name="cart" value="true" /></div><input type="submit" name="update" id="hidden-update" />'; $Errors = &EcartErrors(); if (!$Errors->exist(ECART_STOCK_ERR)) return $result; ob_start(); include(ECART_TEMPLATES."/errors.php"); $errors = ob_get_contents(); ob_end_clean(); return $result.$errors; break; case "emptybutton": case "empty-button": if (!isset($options['value'])) $options['value'] = __('Empty Cart','Ecart'); return '<input type="submit" name="empty" id="empty-button" '.inputattrs($options,$submit_attrs).' />'; break; case "updatebutton": case "update-button": if (!isset($options['value'])) $options['value'] = __('Update Subtotal','Ecart'); if (isset($options['class'])) $options['class'] .= " update-button"; else $options['class'] = "update-button"; return '<input type="submit" name="update"'.inputattrs($options,$submit_attrs).' />'; break; case "sidecart": ob_start(); include(ECART_TEMPLATES."/sidecart.php"); $content = ob_get_contents(); ob_end_clean(); return $content; break; case "hasdiscount": case "has-discount": return ($this->Totals->discount > 0); break; case "discount": return money($this->Totals->discount); break; } $result = ""; switch ($property) { case "promos-available": if (!$Ecart->Promotions->available()) return false; // Skip if the promo limit has been reached if ($Ecart->Settings->get('promo_limit') > 0 && count($this->discounts) >= $Ecart->Settings->get('promo_limit')) return false; return true; break; case "promo-code": // Skip if no promotions exist if (!$Ecart->Promotions->available()) return false; // Skip if the promo limit has been reached if ($Ecart->Settings->get('promo_limit') > 0 && count($this->discounts) >= $Ecart->Settings->get('promo_limit')) return false; if (!isset($options['value'])) $options['value'] = __("Apply Promo Code","Ecart"); $result = '<ul><li>'; if ($Ecart->Errors->exist()) { $result .= '<p class="error">'; $errors = $Ecart->Errors->source('CartDiscounts'); foreach ((array)$errors as $error) if (!empty($error)) $result .= $error->message(true,false); $result .= '</p>'; } $result .= '<span><input type="text" id="promocode" name="promocode" value="" size="10" /></span>'; $result .= '<span><input type="submit" id="apply-code" name="update" '.inputattrs($options,$submit_attrs).' /></span>'; $result .= '</li></ul>'; return $result; case "has-shipping-methods": return apply_filters( 'ecart_shipping_hasestimates', (!empty($this->shipping) && !$this->noshipping), $this->shipping ); break; case "needs-shipped": return (!empty($this->shipped)); break; case "hasshipcosts": case "has-shipcosts": case "hasship-costs": case "has-ship-costs": return ($this->Totals->shipping > 0); break; case "needs-shipping-estimates": $markets = $Ecart->Settings->get('target_markets'); return (!empty($this->shipped) && !$this->noshipping && ($this->showpostcode || count($markets) > 1)); break; case "shipping-estimates": if (empty($this->shipped)) return ""; $base = $Ecart->Settings->get('base_operations'); $markets = $Ecart->Settings->get('target_markets'); $Shipping = &$Ecart->Order->Shipping; if (empty($markets)) return ""; foreach ($markets as $iso => $country) $countries[$iso] = $country; if (!empty($Shipping->country)) $selected = $Shipping->country; else $selected = $base['country']; $result .= '<ul><li>'; if ((isset($options['postcode']) && value_is_true($options['postcode'])) || $this->showpostcode) { $result .= '<span>'; $result .= '<input type="text" name="shipping[postcode]" id="shipping-postcode" size="6" value="'.$Shipping->postcode.'" /> '; $result .= '</span>'; } if (count($countries) > 1) { $result .= '<span>'; $result .= '<select name="shipping[country]" id="shipping-country">'; $result .= menuoptions($countries,$selected,true); $result .= '</select>'; $result .= '</span>'; } else $result .= '<input type="hidden" name="shipping[country]" id="shipping-country" value="'.key($markets).'" />'; $result .= '<br class="clear" /></li></ul>'; return $result; break; } $result = ""; switch ($property) { case "subtotal": $result = $this->Totals->subtotal; break; case "shipping": if (empty($this->shipped)) return ""; if (isset($options['label'])) { $options['currency'] = "false"; if ($this->freeshipping) { $result = $Ecart->Settings->get('free_shipping_text'); if (empty($result)) $result = __('Free Shipping!','Ecart'); } else $result = $options['label']; } else { if ($this->Totals->shipping === null) return __("Enter Postal Code","Ecart"); elseif ($this->Totals->shipping === false) return __("Not Available","Ecart"); else $result = $this->Totals->shipping; } break; case "hastaxes": case "has-taxes": return ($this->Totals->tax > 0); break; case "tax": if ($this->Totals->tax > 0) { if (isset($options['label'])) { $options['currency'] = "false"; $result = $options['label']; } else $result = $this->Totals->tax; } else $options['currency'] = "false"; break; case "total": $result = $this->Totals->total; break; } if (isset($options['currency']) && !value_is_true($options['currency'])) return $result; if (is_numeric($result)) return '<span class="ecart_cart_'.$property.'">'.money($result).'</span>'; return false; }
function tag ($property,$options=array()) { global $Ecart; $select_attrs = array('title','required','class','disabled','required','size','tabindex','accesskey'); $submit_attrs = array('title','class','value','disabled','tabindex','accesskey'); switch ($property) { case "link": case "url": return ecarturl(ECART_PRETTYURLS?$this->slug:array('ecart_pid'=>$this->id)); break; case "found": if (empty($this->id)) return false; $load = array('prices','images','specs','tags','categories'); if (isset($options['load'])) $load = explode(",",$options['load']); $this->load_data($load); return true; break; case "relevance": return (string)$this->score; break; case "id": return $this->id; break; case "name": return apply_filters('ecart_product_name',$this->name); break; case "slug": return $this->slug; break; case "summary": return apply_filters('ecart_product_summary',$this->summary); break; case "description": return apply_filters('ecart_product_description',$this->description); case "isfeatured": case "is-featured": return ($this->featured == "on"); break; case "price": case "saleprice": if (empty($this->prices)) $this->load_data(array('prices')); $defaults = array( 'taxes' => null, 'starting' => '' ); $options = array_merge($defaults,$options); extract($options); if (!is_null($taxes)) $taxes = value_is_true($taxes); $min = $this->min[$property]; $mintax = $this->min[$property.'_tax']; $max = $this->max[$property]; $maxtax = $this->max[$property.'_tax']; $taxrate = ecart_taxrate($taxes,$this->prices[0]->tax,$this); if ("saleprice" == $property) $pricetag = $this->prices[0]->promoprice; else $pricetag = $this->prices[0]->price; if (count($this->options) > 0) { $taxrate = ecart_taxrate($taxes,true,$this); $mintax = $mintax?$min*$taxrate:0; $maxtax = $maxtax?$max*$taxrate:0; if ($min == $max) return money($min+$mintax); else { if (!empty($starting)) return "$starting ".money($min+$mintax); return money($min+$mintax)." — ".money($max+$maxtax); } } else return money($pricetag+($pricetag*$taxrate)); break; case "taxrate": return ecart_taxrate(null,true,$this); break; case "weight": if(empty($this->prices)) $this->load_data(array('prices')); $defaults = array( 'unit' => $Ecart->Settings->get('weight_unit'), 'min' => $this->min['weight'], 'max' => $this->max['weight'], 'units' => true, 'convert' => false ); $options = array_merge($defaults,$options); extract($options); if(!isset($this->min['weight'])) return false; if ($convert !== false) { $min = convert_unit($min,$convert); $max = convert_unit($max,$convert); if (is_null($units)) $units = true; $unit = $convert; } $range = false; if ($min != $max) { $range = array($min,$max); sort($range); } $string = ($min == $max)?round($min,3):round($range[0],3)." - ".round($range[1],3); $string .= value_is_true($units) ? " $unit" : ""; return $string; break; case "onsale": if (empty($this->prices)) $this->load_data(array('prices')); if (empty($this->prices)) return false; return $this->onsale; break; case "has-savings": return ($this->onsale && $this->min['saved'] > 0); break; case "savings": if (empty($this->prices)) $this->load_data(array('prices')); if (!isset($options['taxes'])) $options['taxes'] = null; $taxrate = ecart_taxrate($options['taxes']); $range = false; if (!isset($options['show'])) $options['show'] = ''; if ($options['show'] == "%" || $options['show'] == "percent") { if ($this->options > 1) { if (round($this->min['savings']) != round($this->max['savings'])) { $range = array($this->min['savings'],$this->max['savings']); sort($range); } if (!$range) return percentage($this->min['savings'],array('precision' => 0)); // No price range else return percentage($range[0],array('precision' => 0))." — ".percentage($range[1],array('precision' => 0)); } else return percentage($this->max['savings'],array('precision' => 0)); } else { if ($this->options > 1) { if (round($this->min['saved']) != round($this->max['saved'])) { $range = array($this->min['saved'],$this->max['saved']); sort($range); } if (!$range) return money($this->min['saved']+($this->min['saved']*$taxrate)); // No price range else return money($range[0]+($range[0]*$taxrate))." — ".money($range[1]+($range[1]*$taxrate)); } else return money($this->max['saved']+($this->max['saved']*$taxrate)); } break; case "freeshipping": if (empty($this->prices)) $this->load_data(array('prices')); return $this->freeshipping; case "hasimages": case "has-images": if (empty($this->images)) $this->load_data(array('images')); return (!empty($this->images)); break; case "images": if (!$this->images) return false; if (!isset($this->_images_loop)) { reset($this->images); $this->_images_loop = true; } else next($this->images); if (current($this->images) !== false) return true; else { unset($this->_images_loop); return false; } break; case "coverimage": // Force select the first loaded image unset($options['id']); $options['index'] = 0; case "thumbnail": // deprecated case "image": if (empty($this->images)) $this->load_data(array('images')); if (!(count($this->images) > 0)) return ""; // Compatibility defaults $_size = 96; $_width = $Ecart->Settings->get('gallery_thumbnail_width'); $_height = $Ecart->Settings->get('gallery_thumbnail_height'); if (!$_width) $_width = $_size; if (!$_height) $_height = $_size; $defaults = array( 'img' => false, 'id' => false, 'index' => false, 'class' => '', 'width' => false, 'height' => false, 'size' => false, 'fit' => false, 'sharpen' => false, 'quality' => false, 'bg' => false, 'alt' => '', 'title' => '', 'zoom' => '', 'zoomfx' => 'ecart-zoom', 'property' => false ); $options = array_merge($defaults,$options); extract($options); // Select image by database id if ($id !== false) { for ($i = 0; $i < count($this->images); $i++) { if ($img->id == $id) { $img = $this->images[$i]; break; } } if (!$img) return ""; } // Select image by index position in the list if ($index !== false && isset($this->images[$index])) $img = $this->images[$index]; // Use the current image pointer by default if (!$img) $img = current($this->images); if ($size !== false) $width = $height = $size; if (!$width) $width = $_width; if (!$height) $height = $_height; $scale = $fit?array_search($fit,$img->_scaling):false; $sharpen = $sharpen?min($sharpen,$img->_sharpen):false; $quality = $quality?min($quality,$img->_quality):false; $fill = $bg?hexdec(ltrim($bg,'#')):false; list($width_a,$height_a) = array_values($img->scaled($width,$height,$scale)); if ($size == "original") { $width_a = $img->width; $height_a = $img->height; } if ($width_a === false) $width_a = $width; if ($height_a === false) $height_a = $height; $alt = esc_attr(empty($alt)?(empty($img->alt)?$img->name:$img->alt):$alt); $title = empty($title)?$img->title:$title; $titleattr = empty($title)?'':' title="'.esc_attr($title).'"'; $classes = empty($class)?'':' class="'.esc_attr($class).'"'; $src = ecarturl($img->id,'images'); if (ECART_PERMALINKS) $src = trailingslashit($src).$img->filename; if ($size != "original") $src = add_query_string($img->resizing($width,$height,$scale,$sharpen,$quality,$fill),$src); switch (strtolower($property)) { case "id": return $img->id; break; case "url": case "src": return $src; break; case "title": return $title; break; case "alt": return $alt; break; case "width": return $width_a; break; case "height": return $height_a; break; case "class": return $class; break; } $imgtag = '<img src="'.$src.'"'.$titleattr.' alt="'.$alt.'" width="'.$width_a.'" height="'.$height_a.'" '.$classes.' />'; if (value_is_true($zoom)) return '<a href="'.ecarturl($img->id,'images').'/'.$img->filename.'" class="'.$zoomfx.'" rel="product-'.$this->id.'">'.$imgtag.'</a>'; return $imgtag; break; case "gallery": if (empty($this->images)) $this->load_data(array('images')); if (empty($this->images)) return false; $styles = ''; $_size = 240; $_width = $Ecart->Settings->get('gallery_small_width'); $_height = $Ecart->Settings->get('gallery_small_height'); if (!$_width) $_width = $_size; if (!$_height) $_height = $_size; $defaults = array( // Layout settings 'margins' => 20, 'rowthumbs' => false, // 'thumbpos' => 'after', // Preview image settings 'p.size' => false, 'p.width' => false, 'p.height' => false, 'p.fit' => false, 'p.sharpen' => false, 'p.quality' => false, 'p.bg' => false, 'p.link' => true, 'rel' => '', // Thumbnail image settings 'thumbsize' => false, 'thumbwidth' => false, 'thumbheight' => false, 'thumbfit' => false, 'thumbsharpen' => false, 'thumbquality' => false, 'thumbbg' => false, // Effects settings 'zoomfx' => 'ecart-zoom', 'preview' => 'click', 'colorbox' => '{}' ); $optionset = array_merge($defaults,$options); // Translate dot names $options = array(); $keys = array_keys($optionset); foreach ($keys as $key) $options[str_replace('.','_',$key)] = $optionset[$key]; extract($options); if ($p_size > 0) $_width = $_height = $p_size; $width = $p_width > 0?$p_width:$_width; $height = $p_height > 0?$p_height:$_height; $preview_width = $width; $previews = '<ul class="previews">'; $firstPreview = true; // Find the max dimensions to use for the preview spacing image $maxwidth = $maxheight = 0; foreach ($this->images as $img) { $scale = $p_fit?false:array_search($p_fit,$img->_scaling); $scaled = $img->scaled($width,$height,$scale); $maxwidth = max($maxwidth,$scaled['width']); $maxheight = max($maxheight,$scaled['height']); } if ($maxwidth == 0) $maxwidth = $width; if ($maxheight == 0) $maxheight = $height; $p_link = value_is_true($p_link); foreach ($this->images as $img) { $scale = $p_fit?array_search($p_fit,$img->_scaling):false; $sharpen = $p_sharpen?min($p_sharpen,$img->_sharpen):false; $quality = $p_quality?min($p_quality,$img->_quality):false; $fill = $p_bg?hexdec(ltrim($p_bg,'#')):false; $scaled = $img->scaled($width,$height,$scale); if ($firstPreview) { // Adds "filler" image to reserve the dimensions in the DOM $href = ecarturl(ECART_PERMALINKS?trailingslashit('000'):'000','images'); $previews .= '<li id="preview-fill"'.(($firstPreview)?' class="fill"':'').'>'; $previews .= '<img src="'.add_query_string("$maxwidth,$maxheight",$href).'" alt=" " width="'.$maxwidth.'" height="'.$maxheight.'" />'; $previews .= '</li>'; } $title = !empty($img->title)?' title="'.esc_attr($img->title).'"':''; $alt = esc_attr(!empty($img->alt)?$img->alt:$img->filename); $previews .= '<li id="preview-'.$img->id.'"'.(($firstPreview)?' class="active"':'').'>'; $href = ecarturl(ECART_PERMALINKS?trailingslashit($img->id).$img->filename:$img->id,'images'); if ($p_link) $previews .= '<a href="'.$href.'" class="gallery product_'.$this->id.' '.$options['zoomfx'].'"'.(!empty($rel)?' rel="'.$rel.'"':'').'>'; // else $previews .= '<a name="preview-'.$img->id.'">'; // If links are turned off, leave the <a> so we don't break layout $previews .= '<img src="'.add_query_string($img->resizing($width,$height,$scale,$sharpen,$quality,$fill),ecarturl($img->id,'images')).'"'.$title.' alt="'.$alt.'" width="'.$scaled['width'].'" height="'.$scaled['height'].'" />'; if ($p_link) $previews .= '</a>'; $previews .= '</li>'; $firstPreview = false; } $previews .= '</ul>'; $thumbs = ""; $twidth = $preview_width+$margins; if (count($this->images) > 1) { $default_size = 64; $_thumbwidth = $Ecart->Settings->get('gallery_thumbnail_width'); $_thumbheight = $Ecart->Settings->get('gallery_thumbnail_height'); if (!$_thumbwidth) $_thumbwidth = $default_size; if (!$_thumbheight) $_thumbheight = $default_size; if ($thumbsize > 0) $thumbwidth = $thumbheight = $thumbsize; $width = $thumbwidth > 0?$thumbwidth:$_thumbwidth; $height = $thumbheight > 0?$thumbheight:$_thumbheight; $firstThumb = true; $thumbs = '<ul class="thumbnails">'; foreach ($this->images as $img) { $scale = $thumbfit?array_search($thumbfit,$img->_scaling):false; $sharpen = $thumbsharpen?min($thumbsharpen,$img->_sharpen):false; $quality = $thumbquality?min($thumbquality,$img->_quality):false; $fill = $thumbbg?hexdec(ltrim($thumbbg,'#')):false; $scaled = $img->scaled($width,$height,$scale); $title = !empty($img->title)?' title="'.esc_attr($img->title).'"':''; $alt = esc_attr(!empty($img->alt)?$img->alt:$img->name); $thumbs .= '<li id="thumbnail-'.$img->id.'" class="preview-'.$img->id.(($firstThumb)?' first':'').'">'; $thumbs .= '<img src="'.add_query_string($img->resizing($width,$height,$scale,$sharpen,$quality,$fill),ecarturl($img->id,'images')).'"'.$title.' alt="'.$alt.'" width="'.$scaled['width'].'" height="'.$scaled['height'].'" />'; $thumbs .= '</li>'."\n"; $firstThumb = false; } $thumbs .= '</ul>'; } if ($rowthumbs > 0) $twidth = ($width+$margins+2)*(int)$rowthumbs; $result = '<div id="gallery-'.$this->id.'" class="gallery">'.$previews.$thumbs.'</div>'; $script = "\t".'EcartGallery("#gallery-'.$this->id.'","'.$preview.'"'.($twidth?",$twidth":"").');'; add_storefrontjs($script); return $result; break; case "has-categories": if (empty($this->categories)) $this->load_data(array('categories')); if (count($this->categories) > 0) return true; else return false; break; case "categories": if (!isset($this->_categories_loop)) { reset($this->categories); $this->_categories_loop = true; } else next($this->categories); if (current($this->categories) !== false) return true; else { unset($this->_categories_loop); return false; } break; case "in-category": if (empty($this->categories)) $this->load_data(array('categories')); if (isset($options['id'])) $field = "id"; if (isset($options['name'])) $field = "name"; if (isset($options['slug'])) $field = "slug"; foreach ($this->categories as $category) if ($category->{$field} == $options[$field]) return true; return false; case "category": $category = current($this->categories); if (isset($options['show'])) { if ($options['show'] == "id") return $category->id; if ($options['show'] == "slug") return $category->slug; } return $category->name; break; case "hastags": case "has-tags": if (empty($this->tags)) $this->load_data(array('tags')); if (count($this->tags) > 0) return true; else return false; break; case "tags": if (!isset($this->_tags_loop)) { reset($this->tags); $this->_tags_loop = true; } else next($this->tags); if (current($this->tags) !== false) return true; else { unset($this->_tags_loop); return false; } break; case "tagged": if (empty($this->tags)) $this->load_data(array('tags')); if (isset($options['id'])) $field = "id"; if (isset($options['name'])) $field = "name"; foreach ($this->tags as $tag) if ($tag->{$field} == $options[$field]) return true; return false; case "tag": $tag = current($this->tags); if (isset($options['show'])) { if ($options['show'] == "id") return $tag->id; } return $tag->name; break; case "hasspecs": case "has-specs": if (empty($this->specs)) $this->load_data(array('specs')); if (count($this->specs) > 0) { $this->merge_specs(); return true; } else return false; break; case "specs": if (!isset($this->_specs_loop)) { reset($this->specs); $this->_specs_loop = true; } else next($this->specs); if (current($this->specs) !== false) return true; else { unset($this->_specs_loop); return false; } break; case "spec": $string = ""; $separator = ": "; $delimiter = ", "; if (isset($options['separator'])) $separator = $options['separator']; if (isset($options['delimiter'])) $separator = $options['delimiter']; $spec = current($this->specs); if (is_array($spec->value)) $spec->value = join($delimiter,$spec->value); if (isset($options['name']) && !empty($options['name']) && isset($this->specskey[$options['name']])) { $spec = $this->specskey[$options['name']]; if (is_array($spec)) { if (isset($options['index'])) { foreach ($spec as $index => $entry) if ($index+1 == $options['index']) $content = $entry->value; } else { foreach ($spec as $entry) $contents[] = $entry->value; $content = join($delimiter,$contents); } } else $content = $spec->value; $string = apply_filters('ecart_product_spec',$content); return $string; } if (isset($options['name']) && isset($options['content'])) $string = "{$spec->name}{$separator}".apply_filters('ecart_product_spec',$spec->value); elseif (isset($options['name'])) $string = $spec->name; elseif (isset($options['content'])) $string = apply_filters('ecart_product_spec',$spec->value); else $string = "{$spec->name}{$separator}".apply_filters('ecart_product_spec',$spec->value); return $string; break; case "has-variations": return ($this->variations == "on" && (!empty($this->options['v']) || !empty($this->options))); break; case "variations": $string = ""; if (!isset($options['mode'])) { if (!isset($this->_prices_loop)) { reset($this->prices); $this->_prices_loop = true; } else next($this->prices); $price = current($this->prices); if ($price && ($price->type == 'N/A' || $price->context != 'variation')) next($this->prices); if (current($this->prices) !== false) return true; else { unset($this->_prices_loop); return false; } return true; } if ($this->outofstock) return false; // Completely out of stock, hide menus if (!isset($options['taxes'])) $options['taxes'] = null; $defaults = array( 'defaults' => '', 'disabled' => 'show', 'pricetags' => 'show', 'before_menu' => '', 'after_menu' => '', 'label' => 'on', 'required' => __('You must select the options for this item before you can add it to your shopping cart.','Ecart') ); $options = array_merge($defaults,$options); if ($options['mode'] == "single") { if (!empty($options['before_menu'])) $string .= $options['before_menu']."\n"; if (value_is_true($options['label'])) $string .= '<label for="product-options'.$this->id.'">'. __('Options').': </label> '."\n"; $string .= '<select name="products['.$this->id.'][price]" id="product-options'.$this->id.'">'; if (!empty($options['defaults'])) $string .= '<option value="">'.$options['defaults'].'</option>'."\n"; foreach ($this->prices as $pricetag) { if ($pricetag->context != "variation") continue; if (!isset($options['taxes'])) $taxrate = ecart_taxrate(null,$pricetag->tax); else $taxrate = ecart_taxrate(value_is_true($options['taxes']),$pricetag->tax); $currently = ($pricetag->sale == "on")?$pricetag->promoprice:$pricetag->price; $disabled = ($pricetag->inventory == "on" && $pricetag->stock == 0)?' disabled="disabled"':''; $price = ' ('.money($currently).')'; if ($pricetag->type != "N/A") $string .= '<option value="'.$pricetag->id.'"'.$disabled.'>'.$pricetag->label.$price.'</option>'."\n"; } $string .= '</select>'; if (!empty($options['after_menu'])) $string .= $options['after_menu']."\n"; } else { if (!isset($this->options)) return; $menuoptions = $this->options; if (!empty($this->options['v'])) $menuoptions = $this->options['v']; $baseop = $Ecart->Settings->get('base_operations'); $precision = $baseop['currency']['format']['precision']; if (!isset($options['taxes'])) $taxrate = ecart_taxrate(null,true,$this); else $taxrate = ecart_taxrate(value_is_true($options['taxes']),true,$this); $pricekeys = array(); foreach ($this->pricekey as $key => $pricing) { $filter = array(''); $_ = new StdClass(); if ($pricing->type != "Donation") $_->p = ((isset($pricing->onsale) && $pricing->onsale == "on")? (float)$pricing->promoprice: (float)$pricing->price); $_->i = ($pricing->inventory == "on"); $_->s = ($pricing->inventory == "on")?$pricing->stock:false; $_->tax = ($pricing->tax == "on"); $_->t = $pricing->type; $pricekeys[$key] = $_; } ob_start(); ?><?php if (!empty($options['defaults'])): ?> sjss.opdef = true; <?php endif; ?> <?php if (!empty($options['required'])): ?> sjss.opreq = "<?php echo $options['required']; ?>"; <?php endif; ?> pricetags[<?php echo $this->id; ?>] = <?php echo json_encode($pricekeys); ?>; new ProductOptionsMenus('select<?php if (!empty($Ecart->Category->slug)) echo ".category-".$Ecart->Category->slug; ?>.product<?php echo $this->id; ?>.options',{<?php if ($options['disabled'] == "hide") echo "disabled:false,"; ?><?php if ($options['pricetags'] == "hide") echo "pricetags:false,"; ?><?php if (!empty($taxrate)) echo "taxrate:$taxrate,"?>prices:pricetags[<?php echo $this->id; ?>]}); <?php $script = ob_get_contents(); ob_end_clean(); add_storefrontjs($script); foreach ($menuoptions as $id => $menu) { if (!empty($options['before_menu'])) $string .= $options['before_menu']."\n"; if (value_is_true($options['label'])) $string .= '<label for="options-'.$menu['id'].'">'.$menu['name'].'</label> '."\n"; $category_class = isset($Ecart->Category->slug)?'category-'.$Ecart->Category->slug:''; $string .= '<select name="products['.$this->id.'][options][]" class="'.$category_class.' product'.$this->id.' options" id="options-'.$menu['id'].'">'; if (!empty($options['defaults'])) $string .= '<option value="">'.$options['defaults'].'</option>'."\n"; foreach ($menu['options'] as $key => $option) $string .= '<option value="'.$option['id'].'">'.$option['name'].'</option>'."\n"; $string .= '</select>'; } if (!empty($options['after_menu'])) $string .= $options['after_menu']."\n"; } return $string; break; case "variation": $variation = current($this->prices); if (!isset($options['taxes'])) $options['taxes'] = null; else $options['taxes'] = value_is_true($options['taxes']); $taxrate = ecart_taxrate($options['taxes'],$variation->tax,$this); $weightunit = (isset($options['units']) && !value_is_true($options['units']) ) ? false : $Ecart->Settings->get('weight_unit'); $string = ''; if (array_key_exists('id',$options)) $string .= $variation->id; if (array_key_exists('label',$options)) $string .= $variation->label; if (array_key_exists('type',$options)) $string .= $variation->type; if (array_key_exists('sku',$options)) $string .= $variation->sku; if (array_key_exists('price',$options)) $string .= money($variation->price+($variation->price*$taxrate)); if (array_key_exists('saleprice',$options)) { if (isset($options['promos']) && !value_is_true($options['promos'])) { $string .= money($variation->saleprice+($variation->saleprice*$taxrate)); } else $string .= money($variation->promoprice+($variation->promoprice*$taxrate)); } if (array_key_exists('stock',$options)) $string .= $variation->stock; if (array_key_exists('weight',$options)) $string .= round($variation->weight, 3) . ($weightunit ? " $weightunit" : false); if (array_key_exists('shipfee',$options)) $string .= money(floatvalue($variation->shipfee)); if (array_key_exists('sale',$options)) return ($variation->sale == "on"); if (array_key_exists('shipping',$options)) return ($variation->shipping == "on"); if (array_key_exists('tax',$options)) return ($variation->tax == "on"); if (array_key_exists('inventory',$options)) return ($variation->inventory == "on"); return $string; break; case "has-addons": return ($this->addons == "on" && !empty($this->options['a'])); break; break; case "addons": $string = ""; if (!isset($options['mode'])) { if (!$this->priceloop) { reset($this->prices); $this->priceloop = true; } else next($this->prices); $thisprice = current($this->prices); if ($thisprice && $thisprice->type == "N/A") next($this->prices); if ($thisprice && $thisprice->context != "addon") next($this->prices); if (current($this->prices) !== false) return true; else { $this->priceloop = false; return false; } return true; } if ($this->outofstock) return false; // Completely out of stock, hide menus if (!isset($options['taxes'])) $options['taxes'] = null; $defaults = array( 'defaults' => '', 'disabled' => 'show', 'before_menu' => '', 'after_menu' => '' ); $options = array_merge($defaults,$options); if (!isset($options['label'])) $options['label'] = "on"; if (!isset($options['required'])) $options['required'] = __('You must select the options for this item before you can add it to your shopping cart.','Ecart'); if ($options['mode'] == "single") { if (!empty($options['before_menu'])) $string .= $options['before_menu']."\n"; if (value_is_true($options['label'])) $string .= '<label for="product-options'.$this->id.'">'. __('Options').': </label> '."\n"; $string .= '<select name="products['.$this->id.'][price]" id="product-options'.$this->id.'">'; if (!empty($options['defaults'])) $string .= '<option value="">'.$options['defaults'].'</option>'."\n"; foreach ($this->prices as $pricetag) { if ($pricetag->context != "addon") continue; if (isset($options['taxes'])) $taxrate = ecart_taxrate(value_is_true($options['taxes']),$pricetag->tax,$this); else $taxrate = ecart_taxrate(null,$pricetag->tax,$this); $currently = ($pricetag->sale == "on")?$pricetag->promoprice:$pricetag->price; $disabled = ($pricetag->inventory == "on" && $pricetag->stock == 0)?' disabled="disabled"':''; $price = ' ('.money($currently).')'; if ($pricetag->type != "N/A") $string .= '<option value="'.$pricetag->id.'"'.$disabled.'>'.$pricetag->label.$price.'</option>'."\n"; } $string .= '</select>'; if (!empty($options['after_menu'])) $string .= $options['after_menu']."\n"; } else { if (!isset($this->options['a'])) return; $taxrate = ecart_taxrate($options['taxes'],true,$this); // Index addon prices by option $pricing = array(); foreach ($this->prices as $pricetag) { if ($pricetag->context != "addon") continue; $pricing[$pricetag->options] = $pricetag; } foreach ($this->options['a'] as $id => $menu) { if (!empty($options['before_menu'])) $string .= $options['before_menu']."\n"; if (value_is_true($options['label'])) $string .= '<label for="options-'.$menu['id'].'">'.$menu['name'].'</label> '."\n"; $category_class = isset($Ecart->Category->slug)?'category-'.$Ecart->Category->slug:''; $string .= '<select name="products['.$this->id.'][addons][]" class="'.$category_class.' product'.$this->id.' addons" id="addons-'.$menu['id'].'">'; if (!empty($options['defaults'])) $string .= '<option value="">'.$options['defaults'].'</option>'."\n"; foreach ($menu['options'] as $key => $option) { $pricetag = $pricing[$option['id']]; if (isset($options['taxes'])) $taxrate = ecart_taxrate(value_is_true($options['taxes']),$pricetag->tax,$this); else $taxrate = ecart_taxrate(null,$pricetag->tax,$this); $currently = ($pricetag->sale == "on")?$pricetag->promoprice:$pricetag->price; if ($taxrate > 0) $currently = $currently+($currently*$taxrate); $string .= '<option value="'.$option['id'].'">'.$option['name'].' (+'.money($currently).')</option>'."\n"; } $string .= '</select>'; } if (!empty($options['after_menu'])) $string .= $options['after_menu']."\n"; } return $string; break; case "donation": case "amount": case "quantity": if ($this->outofstock) return false; $inputs = array('text','menu'); $defaults = array( 'value' => 1, 'input' => 'text', // accepts text,menu 'labelpos' => 'before', 'label' => '', 'options' => '1-15,20,25,30,40,50,75,100', 'size' => 3 ); $options = array_merge($defaults,$options); $_options = $options; extract($options); unset($_options['label']); // Interferes with the text input value when passed to inputattrs() $labeling = '<label for="quantity-'.$this->id.'">'.$label.'</label>'; if (!isset($this->_prices_loop)) reset($this->prices); $variation = current($this->prices); $_ = array(); if ("before" == $labelpos) $_[] = $labeling; if ("menu" == $input) { if ($this->inventory && $this->max['stock'] == 0) return ""; if (strpos($options,",") !== false) $options = explode(",",$options); else $options = array($options); $qtys = array(); foreach ((array)$options as $v) { if (strpos($v,"-") !== false) { $v = explode("-",$v); if ($v[0] >= $v[1]) $qtys[] = $v[0]; else for ($i = $v[0]; $i < $v[1]+1; $i++) $qtys[] = $i; } else $qtys[] = $v; } $_[] = '<select name="products['.$this->id.'][quantity]" id="quantity-'.$this->id.'">'; foreach ($qtys as $qty) { $amount = $qty; $selection = (isset($this->quantity))?$this->quantity:1; if ($variation->type == "Donation" && $variation->donation['var'] == "on") { if ($variation->donation['min'] == "on" && $amount < $variation->price) continue; $amount = money($amount); $selection = $variation->price; } else { if ($this->inventory && $amount > $this->max['stock']) continue; } $selected = ($qty==$selection)?' selected="selected"':''; $_[] = '<option'.$selected.' value="'.$qty.'">'.$amount.'</option>'; } $_[] = '</select>'; } elseif (valid_input($input)) { if ($variation->type == "Donation" && $variation->donation['var'] == "on") { if ($variation->donation['min']) $_options['value'] = $variation->price; $_options['class'] .= " currency"; } $_[] = '<input type="'.$input.'" name="products['.$this->id.'][quantity]" id="quantity-'.$this->id.'"'.inputattrs($_options).' />'; } if ("after" == $labelpos) $_[] = $labeling; return join("\n",$_); break; case "input": if (!isset($options['type']) || ($options['type'] != "menu" && $options['type'] != "textarea" && !valid_input($options['type']))) $options['type'] = "text"; if (!isset($options['name'])) return ""; if ($options['type'] == "menu") { $result = '<select name="products['.$this->id.'][data]['.$options['name'].']" id="data-'.$options['name'].'-'.$this->id.'"'.inputattrs($options,$select_attrs).'>'; if (isset($options['options'])) $menuoptions = preg_split('/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/',$options['options']); if (is_array($menuoptions)) { foreach($menuoptions as $option) { $selected = ""; $option = trim($option,'"'); if (isset($options['default']) && $options['default'] == $option) $selected = ' selected="selected"'; $result .= '<option value="'.$option.'"'.$selected.'>'.$option.'</option>'; } } $result .= '</select>'; } elseif ($options['type'] == "textarea") { if (isset($options['cols'])) $cols = ' cols="'.$options['cols'].'"'; if (isset($options['rows'])) $rows = ' rows="'.$options['rows'].'"'; $result .= '<textarea name="products['.$this->id.'][data]['.$options['name'].']" id="data-'.$options['name'].'-'.$this->id.'"'.$cols.$rows.inputattrs($options).'>'.$options['value'].'</textarea>'; } else { $result = '<input type="'.$options['type'].'" name="products['.$this->id.'][data]['.$options['name'].']" id="data-'.$options['name'].'-'.$this->id.'"'.inputattrs($options).' />'; } return $result; break; case "outofstock": if ($this->outofstock) { $label = isset($options['label'])?$options['label']:$Ecart->Settings->get('outofstock_text'); $string = '<span class="outofstock">'.$label.'</span>'; return $string; } else return false; break; case "buynow": if (!isset($options['value'])) $options['value'] = __("Buy Now","Ecart"); case "addtocart": if (!isset($options['class'])) $options['class'] = "addtocart"; else $options['class'] .= " addtocart"; if (!isset($options['value'])) $options['value'] = __("Add to Cart","Ecart"); $string = ""; if ($this->outofstock) { $string .= '<span class="outofstock">'.$Ecart->Settings->get('outofstock_text').'</span>'; return $string; } if (isset($options['redirect']) && !isset($options['ajax'])) $string .= '<input type="hidden" name="redirect" value="'.$options['redirect'].'" />'; $string .= '<input type="hidden" name="products['.$this->id.'][product]" value="'.$this->id.'" />'; if (!empty($this->prices[0]) && $this->prices[0]->type != "N/A") $string .= '<input type="hidden" name="products['.$this->id.'][price]" value="'.$this->prices[0]->id.'" />'; if (!empty($Ecart->Category)) { if (ECART_PRETTYURLS) $string .= '<input type="hidden" name="products['.$this->id.'][category]" value="'.$Ecart->Category->uri.'" />'; else $string .= '<input type="hidden" name="products['.$this->id.'][category]" value="'.((!empty($Ecart->Category->id))?$Ecart->Category->id:$Ecart->Category->slug).'" />'; } $string .= '<input type="hidden" name="cart" value="add" />'; if (isset($options['ajax'])) { if ($options['ajax'] == "html") $options['class'] .= ' ajax-html'; else $options['class'] .= " ajax"; $string .= '<input type="hidden" name="ajax" value="true" />'; $string .= '<input type="button" name="addtocart" '.inputattrs($options).' />'; } else { $string .= '<input type="submit" name="addtocart" '.inputattrs($options).' />'; } return $string; } }
<?php } ?> <h2 id="apcu">APCu</h2> <div> <h3>Memory <?php echo human_size(apc_mem('used')); ?> of <?php echo human_size(apc_mem('total')); ?> </h3> <div class="full bar green"> <div class="orange" style="width: <?php echo percentage(apc_mem('used'), apc_mem('total')); ?> %"></div> </div> </div> <div> <h3>Actions</h3> <form action="?" method="GET"> <label>Cache: <button name="action" value="apc_restart">Restart</button> </label> </form> <form action="?" method="GET"> <label>Key(s): <input name="selector" type="text" value="" placeholder=".*" /> </label>
$failedUrls[] = $item; } } // Label skipHandleResults: // // Check which alerts if a title yields alot of hits. Means this title's query may be worth verifying. // if ($itemCount >= $verifyLimit) { $toVerifyArray[] = $titleName . " (ID: " . $titleId . " - Results:" . $itemCount . " )"; } $curResultCnt = " " . $itemCount . " URL(s) added succesfully!"; echo "\r"; // Wipe line printf($mask, " " . $titleName, $curResultCnt); echo "\rProgress: " . floor(percentage($curTitle, $totalTitles)) . "% (" . $curTitle . "/" . $totalTitles . ") | URL's found: " . $totalItemCount . " | Ignored URL's: " . count($failedUrls) . " | Queries: " . $queryCount . " | Errors: " . $errors . "/" . $errorLimit; // SIGNAL handling if (isset($exit)) { echo "\n\nGot an exit signal! ({$exit})\n"; break 2; } // Slow down - Google seems to like this usleep(200000); } echo "\r+--------------------------------------------------------------------------------------------------------------+\n"; } //Add line-break echo "\n"; //Print info echo "Found a total of " . $totalItemCount . " new links!\n"; echo "I needed " . $queryCount . " queries to find these!\n";
echo percentage(folderdisktotal($currentgroup), $clientmaxfilesize); ?> " data-line-width="2" data-size="100" data-bar-color="#3675c5" data-track-color="#eeeeee"> <span class="h4"><?php echo humanFileSize(folderdisktotal($currentgroup), 'MB'); ?> <br><small class="h5 font-w400 text-muted">/<?php echo humanFileSize($clientmaxfilesize, 'MB'); ?> </small></span> <canvas height="0" width="0"></canvas></div> </div> <div class="block-content block-content-full col-lg-6 text-center"> <!-- Pie Chart Container --> <div class="js-pie-chart pie-chart" data-percent="<?php echo percentage(orbislookup($currentgroup, 'file_group_id', 'files', 'COUNT(*)'), $clientmaxfiles); ?> " data-line-width="2" data-size="100" data-bar-color="#3675c5" data-track-color="#eeeeee"> <span class="h4"><?php echo orbislookup($currentgroup, 'file_group_id', 'files', 'COUNT(*)'); ?> Files<br><small class="h5 font-w400 text-muted">/<?php echo $clientmaxfiles; ?> Files</small></span> <canvas height="0" width="0"></canvas></div> </div> </div> <div class="block-content"> <div class="row items-push text-center"> <div class="col-xs-6">
} } } /* End Models */ } # Progress Info $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = $endtime - $starttime; $systemAllowTime = ini_get('max_execution_time'); //$systemAllowTime = 100; $timeStatus = 0; if ($systemAllowTime != 0) { $timeStatus = percentage($totaltime, $systemAllowTime, 0); } echo ' <script> function getGreenToRed(percent){ r = percent<50 ? 255 : Math.floor(255-(percent*2-100)*255/100); g = percent>50 ? 255 : Math.floor((percent*2)*255/100); return "rgb("+g+","+r+",0)"; } $("#import_prog .well").append("- ' . subscribers_file_opened . '<br>"); $("#import_prog .well").append("- ' . subscribers_counting_records . '..<br>"); $("#import_prog .well").append("- ' . subscribers_max_valid_data . ': ' . $fTotal . '<br>"); $("#import_prog .well").append("- ' . subscribers_total_phase . ': ~' . $fTotalPhase . '<br>"); $("#import_prog .well").append("- ' . subscribers_parsing_has_begun . '..<br>"); $("#import_prog .well").append("- ' . subscribers_found_in_the_blacklist . ': <span class=text-muted>' . $recBL . '</span><br>");
function Item($Product, $pricing, $category, $data = array()) { global $Shopp; // To access settings $Product->load_data(array('prices', 'images')); // If product variations are enabled, disregard the first priceline if ($Product->variations == "on") { array_shift($Product->prices); } // If option ids are passed, lookup by option key, otherwise by id if (is_array($pricing)) { $Price = $Product->pricekey[$Product->optionkey($pricing)]; if (empty($Price)) { $Price = $Product->pricekey[$Product->optionkey($pricing, true)]; } } elseif ($pricing) { $Price = $Product->priceid[$pricing]; } else { foreach ($Product->prices as &$Price) { if ($Price->type != "N/A" && (!$Price->stocked || $Price->stocked && $Price->stock > 0)) { break; } } } if (isset($Product->id)) { $this->product = $Product->id; } if (isset($Price->id)) { $this->price = $Price->id; } $this->category = $category; $this->option = $Price; $this->name = $Product->name; $this->slug = $Product->slug; $this->description = $Product->summary; if (isset($Product->thumbnail)) { $this->thumbnail = $Product->thumbnail; } $this->menus = $Product->options; if ($Product->variations == "on") { $this->options = $Product->prices; } $this->sku = $Price->sku; $this->type = $Price->type; $this->sale = $Price->onsale; $this->freeshipping = $Price->freeshipping; $this->saved = $Price->price - $Price->promoprice; $this->savings = $Price->price > 0 ? percentage($this->saved / $Price->price) * 100 : 0; $this->unitprice = $Price->onsale ? $Price->promoprice : $Price->price; $this->optionlabel = count($Product->prices) > 1 ? $Price->label : ''; $this->donation = $Price->donation; $this->data = stripslashes_deep(attribute_escape_deep($data)); // Map out the selected menu name and option if ($Product->variations == "on") { $selected = explode(",", $this->option->options); $s = 0; foreach ($this->menus as $i => $menu) { foreach ($menu['options'] as $option) { if ($option['id'] == $selected[$s]) { $this->variation[$menu['name']] = $option['name']; break; } } $s++; } } if (!empty($Price->download)) { $this->download = $Price->download; } if ($Price->type == "Shipped") { $this->shipping = true; if ($Price->shipping == "on") { $this->weight = $Price->weight; $this->shipfee = $Price->shipfee; } else { $this->freeshipping = true; } } $this->inventory = $Price->inventory == "on" ? true : false; $this->taxable = $Price->tax == "on" && $Shopp->Settings->get('taxes') == "on" ? true : false; }
function _repair_from_sources_tables($sourcetable, $daytable) { percentage("Repair {$daytable} FROM {$sourcetable}", 2); //zMD5 | sitename | familysite | client | hostname | account | hour | remote_ip | MAC | country | size | hits | uid | category | cached $f = array(); $sql = "SELECT HOUR(zDate) as `hour`,SUM(QuerySize) as size, SUM(hits) as hits, \n\tsitename,uid,CLIENT,hostname,MAC,account,cached FROM {$sourcetable} \n\tGROUP BY `hour`,sitename,uid,CLIENT,hostname,MAC,account,cached"; $prefix = "INSERT IGNORE INTO {$daytable} \n\t(`zMD5`,`sitename`,`familysite`,`client`,`hostname`,`uid`,`account`,`hour`,`MAC`,`size`,`hits`) VALUES"; $q = new mysql_squid_builder(); $results = $q->QUERY_SQL($sql); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $zMD5 = md5(serialize($ligne)); $familysite = $q->GetFamilySites($ligne["sitename"]); while (list($key, $val) = each($ligne)) { $ligne[$key] = mysql_escape_string2($val); } $f[] = "('{$zMD5}','{$ligne["sitename"]}','{$familysite}','{$ligne["CLIENT"]}','{$ligne["hostname"]}','{$ligne["uid"]}','{$ligne["account"]}','{$ligne["hour"]}','{$ligne["MAC"]}','{$ligne["size"]}','{$ligne["hits"]}')"; if (count($f) > 0) { $q->QUERY_SQL($prefix . @implode(",", $f)); $f = array(); } } if (count($f) > 0) { $q->QUERY_SQL($prefix . @implode(",", $f)); $f = array(); } $sql = "SELECT COUNT(`sitename`) as tcount FROM {$daytable} WHERE LENGTH(`category`)=0"; if ($GLOBALS["VERBOSE"]) { echo $sql . "\n"; } $ligne2 = mysql_fetch_array($q->QUERY_SQL($sql)); $max = $ligne2["tcount"]; $sql = "UPDATE tables_day SET `not_categorized`={$max} WHERE tablename='{$sourcetable}'"; $q->QUERY_SQL($sql); }
"' href='' rel="<?php echo $Promotion->id; ?> "><?php _e('Delete', 'Shopp'); ?> </a></span> </div> </td> <td class="discount column-discount<?php echo in_array('discount', $hidden) ? ' hidden' : ''; ?> "><?php if ($Promotion->type == "Percentage Off") { echo percentage($Promotion->discount); } if ($Promotion->type == "Amount Off") { echo money($Promotion->discount); } if ($Promotion->type == "Free Shipping") { echo $this->Settings->get("free_shipping_text"); } if ($Promotion->type == "Buy X Get Y Free") { echo __('Buy', 'Shopp') . ' ' . $Promotion->buyqty . ' ' . __('Get', 'Shopp') . ' ' . $Promotion->getqty . ' ' . __('Free', 'Shopp'); } ?> </td> <td class="applied column-applied<?php echo in_array('applied', $hidden) ? ' hidden' : ''; ?>
function sync_categories() { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidfile); if ($pid < 100) { $pid = null; } $unix = new unix(); if ($unix->process_exists($pid, basename(__FILE__))) { if ($GLOBALS["VERBOSE"]) { echo "Already executed pid {$pid}\n"; } return; } $mypid = getmypid(); @file_put_contents($pidfile, $mypid); $sql = "SELECT * FROM visited_sites WHERE sitename LIKE 'www.%'"; $results = $GLOBALS["Q"]->QUERY_SQL($sql); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $website = trim($ligne["sitename"]); if (preg_match("#^www\\.(.+)#", $website, $re)) { $ligne2 = mysql_fetch_array($GLOBALS["Q"]->QUERY_SQL("SELECT sitename FROM visited_sites WHERE sitename='{$re[1]}'")); if ($ligne2["sitename"] != null) { $GLOBALS["Q"]->QUERY_SQL("DELETE FROM visited_sites WHERE sitename='{$website}'"); } else { $GLOBALS["Q"]->QUERY_SQL("UPDATE visited_sites SET sitename='{$re[1]}' WHERE sitename='{$ligne["sitename"]}'"); } $GLOBALS["Q"]->UPDATE_WEBSITES_TABLES($ligne["sitename"], $re[1]); } } $sql = "SELECT sitename FROM visited_sites WHERE LENGTH(category)=0 ORDER BY Querysize DESC LIMIT 0,500"; if ($GLOBALS["VERBOSE"]) { echo "{$sql}\n"; } $results = $GLOBALS["Q"]->QUERY_SQL($sql); if (!$GLOBALS["Q"]->ok) { ufdbguard_admin_events("Starting analyzing not categorized websites Failed " . $GLOBALS["Q"]->mysql_error, __FUNCTION__, __FILE__, __LINE__, "stats"); return; } $num_rows = mysql_num_rows($results); $t = time(); if ($num_rows == 0) { if ($GLOBALS["VERBOSE"]) { echo "No datas " . __FUNCTION__ . " " . __LINE__ . "\n"; } return; } stats_admin_events(0, "Starting analyzing {$num_rows} not categorized websites", null, __FILE__, __LINE__); $c = 0; $d = 0; $CATZP = 0; $TTIME = 0; $NOTCATZ = array(); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $website = trim($ligne["sitename"]); $category = null; if ($website == null) { continue; } $t2 = time(); $c++; $d++; $TTIME++; if ($d > 1000) { if ($GLOBALS["VERBOSE"]) { echo "Analyzed {$c} websites\n"; $d = 0; } } percentage("{$c}/{$num_rows} {$ligne["sitename"]}", 49); $category = $GLOBALS["Q"]->GET_CATEGORIES($website, true); if (trim($category) != null) { $CATZP++; $took = $unix->distanceOfTimeInWords($t2, time()); $GLOBALS["Q"]->UPDATE_CATEGORIES_TABLES($website, $category); if ($GLOBALS["VERBOSE"]) { echo "UPDATE_CATEGORIES_TABLES DONE..\n"; } $GLOBALS["Q"]->QUERY_SQL("UPDATE visited_sites SET category='{$category}' WHERE sitename='{$website}'"); if (!$GLOBALS["Q"]->ok) { stats_admin_events(0, "Fatal error while update visited_sites", $GLOBALS["Q"]->mysql_error, __FILE__, __LINE__); } } else { $NOTCATZ[] = $website; } if ($TTIME > 10) { if (SquidStatisticsTasksOverTime()) { stats_admin_events(1, "Statistics overtime... Aborting", null, __FILE__, __LINE__); return; } } } if ($CATZP > 0) { $took = $unix->distanceOfTimeInWords($t, time()); stats_admin_events(2, "{$CATZP} new categorized website task:finish ({$took})", null, __FILE__, __LINE__); } if (count($NOTCATZ) > 0) { stats_admin_events(1, count($NOTCATZ) . " unknown websites", @implode("\n", $NOTCATZ), __FILE__, __LINE__); } $unix = new unix(); $nohup = $unix->find_program("nohup"); shell_exec("{$nohup} " . $unix->LOCATE_PHP5_BIN() . __FILE__ . " --defrag --schedule-id={$GLOBALS["SCHEDULE_ID"]} >/dev/null 2>&1 &"); }
function getChartParticipation($data) { $nbTeams = $data->nbTeamsAll; if ($nbTeams == 0) { return "<div>No participants for {$data->contestName} ({$data->contestID})</div>"; } $ratioGirls = percentage($data->nbParticipantsGirl / $data->nbParticipants); $ratioMixed = percentage($data->nbTeamsMixed / $nbTeams); $data->nbTeamsDouble = $data->nbTeamsAll - $data->nbTeamsSingle; $ratioDoubles = percentage($data->nbTeamsDouble / $nbTeams); // $ratioDoubles2 = round(100 * ($data->nbParticipants - $nbTeams) / $nbTeams) . "%"; $data->sumScoreDouble = $data->sumScoreAll - $data->sumScoreSingle; // $data->nbTeamsBoy = $data->nbTeamsSingle - $data->nbTeamsGirl; // $data->sumScoreBoy = $data->sumScoreSingle - $data->sumScoreGirl; $avgScoreTeams = roundScore($data->sumScoreAll / $data->nbTeamsAll); $avgScoreSingle = roundScoreAndRelative($data->sumScoreSingle / $data->nbTeamsSingle, $avgScoreTeams); $avgScoreDouble = roundScoreAndRelative($data->sumScoreDouble / $data->nbTeamsDouble, $avgScoreTeams); $avgScoreBoy = roundScoreAndRelative($data->sumScoreBoy / $data->nbTeamsBoy, $avgScoreTeams); $avgScoreGirl = roundScoreAndRelative($data->sumScoreGirl / $data->nbTeamsGirl, $avgScoreTeams); $avgScoreMixed = roundScoreAndRelative($data->sumScoreMixed / $data->nbTeamsMixed, $avgScoreTeams); $extra = ""; if (!empty($data->nbSchoolsForeign)) { $extra .= "<tr><td>nbSchoolsForeign</td><td>{$data->nbSchoolsForeign}</td></tr>"; $extra .= "<tr><td>nbParticipantsForeign</td><td>{$data->nbParticipantsForeign}</td></tr>"; } return "\n <style>\n .participation {\n margin: 1em;\n border-collapse: collapse;\n }\n .participation td {\n border: 1px solid black;\n padding: 0.2em;\n }\n </style>\n <div>\n <table class='participation'>\n <tr><td>name</td><td style='width: 20em'>{$data->contestName}</td></tr>\n <tr><td>nbParticipants</td><td>{$data->nbParticipants}</td></tr>\n <tr><td>ratioGirls</td><td>{$ratioGirls}</td></tr>\n <tr><td>nbTeamsTotal</td><td>{$data->nbTeamsAll}</td></tr>\n <tr><td>ratioDoubles</td><td>{$ratioDoubles}</td></tr>\n <tr><td>ratioMixed</td><td>{$ratioMixed}</td></tr>\n <tr><td>avgScoreTeams</td><td>{$avgScoreTeams}</td></tr>\n <tr><td>avgScoreSingle</td><td>{$avgScoreSingle}</td></tr>\n <tr><td>avgScoreDouble</td><td>{$avgScoreDouble}</td></tr>\n <tr><td>avgScoreSingleBoy</td><td>{$avgScoreBoy}</td></tr>\n <tr><td>avgScoreSingleGirl</td><td>{$avgScoreGirl}</td></tr>\n <tr><td>avgScoreMixed</td><td>{$avgScoreMixed}</td></tr>\n <tr><td>nbSchools</td><td>{$data->nbSchools}</td></tr>\n {$extra}\n </table>\n </div>"; }
public function portfolio_gains($stocks = "", $portfolio = "") { $stock_val = $this->get_current_stock_value($stocks); $gains = ($portfolio->current_cap + $stock_val) / $portfolio->beginning_cap; return percentage($gains - 1); }
<h5><?php echo letheglobal_list_quality; ?> </h5> <h3 class="text-success"><span class="count" data-from="0" data-to="<?php echo 100 - $bounce_perc; ?> ">0</span>% <span class="glyphicon glyphicon-thumbs-up"></span></h3> </div> <div class="col-xs-6 col-md-3"> <h5><?php echo letheglobal_campaign_quality; ?> </h5> <h3 class="text-success"><span class="count" data-from="0" data-to="<?php echo percentage(($click_perc + $open_perc) / 2, 100, 0); ?> ">0</span>% <span class="glyphicon glyphicon-thumbs-up"></span></h3> </div> </div> <script> $(".countScore").countTo({ onUpdate: function (value) { $(".score-count").css("color",getGreenToRed(parseInt(value))); if(value<50){ $(".score-count .glyphicon").removeClass("glyphicon-thumbs-up"); $(".score-count .glyphicon").addClass("glyphicon-thumbs-down"); }else{ $(".score-count .glyphicon").removeClass("glyphicon-thumbs-down"); $(".score-count .glyphicon").addClass("glyphicon-thumbs-up"); }
function getMyLimits($currData, $quot, $unlimited = true) { $perStat = percentage($currData, $quot, 0); $progCol = ''; switch ($perStat) { case $perStat >= 0 && $perStat <= 25: $progCol = 'progress-bar-success progress-bar-striped active'; break; case $perStat >= 26 && $perStat <= 50: $progCol = 'progress-bar-primary progress-bar-striped active'; break; case $perStat >= 51 && $perStat <= 75: $progCol = 'progress-bar-warning progress-bar-striped active'; break; case $perStat >= 76 && $perStat <= 100: $progCol = 'progress-bar-danger ' . ($perStat != 100 ? 'progress-bar-striped active' : '') . ' '; break; default: break; } /* $drawBar = ' <div class="progress tooltips" data-placement="bottom" title="'. $perStat .'% - '.$currData.'/'.$quot.'"> <div class="progress-bar '. $progCol .'" role="progressbar" aria-valuenow="'. $perStat .'" aria-valuemin="0" aria-valuemax="100" style="width: '. $perStat .'%;'. ($perStat>0 ? 'min-width:20px;':'color:#555;') .'"> '. $perStat .'% - '.$currData.'/'.$quot.' </div> </div> '; */ $drawBar = '<div class="progress tooltips" data-placement="bottom" title="' . $perStat . '% - ' . $currData . '/' . $quot . '"> <div class="progress-bar ' . $progCol . '" role="progressbar" aria-valuenow="' . $perStat . '" aria-valuemin="0" aria-valuemax="100" style="width: ' . $perStat . '%;' . ($perStat > 0 ? 'min-width:20px;' : 'color:#555;') . '"> ' . $perStat . '% - ' . $currData . '/' . $quot . ' </div> </div>'; if ($quot == 0 && $unlimited == true) { $drawBar = '<span class="label label-success">' . letheglobal_unlimited . '</span>'; } return $drawBar; }
foreach ($xml->characterInfo->reputationTab->faction as $faction) { // find WOTLK factions if ((string) $faction['key'] == 'wrathofthelichking') { $factions = buildFactions($faction); } } //$factions = buildFactions($xml->characterInfo->reputationTab->faction[1]); krsort($factions); // reverse sort it $out = ''; foreach ($factions as $index => $value) { $out .= '<table class="rep-table" cellspacing="1" cellpadding="0">'; $out .= '<tr><th colspan="3">' . $index . '</th></tr>'; foreach ($value as $rep) { $standing = calculateStanding($rep['rep']); $percent = percentage((int) $standing['value'], (int) $standing['max']); $out .= '<tr><td width="45%" style="text-align: center;">' . $rep['name'] . '</td>'; $out .= '<td width="15%"><div class="rep-box"><span style="width: ' . $percent . '%;" class="rep-' . strtolower($standing['class']) . '"> </span></div></td>'; $out .= '<td width="40%" style="text-align: center;">' . $standing['value'] . '/' . $standing['max'] . ' ' . $standing['word'] . '</td></tr>'; } $out .= '</table><br />'; } // insert/update mysql $dummy_text = "INSERT INTO `" . WHP_DB_PREFIX . "recruit` (\n\t\t\t\t\t\t\t`uniquekey`, \n\t\t\t\t\t\t\t`cache`,\n\t\t\t\t\t\t\t`faction`\n\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t'{$key}',\n\t\t\t\t\t\t\tUNIX_TIMESTAMP(NOW()),\n\t\t\t\t\t\t\t'" . addslashes($out) . "'\n\t\t\t\t\t\t)\n\t\t\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t\t\t\tfaction='" . addslashes($out) . "',\n\t\t\t\t\t\t\tcache=UNIX_TIMESTAMP(NOW())"; $dummy = mysql_query($dummy_text); print $out; } else { print stripslashes($faction); } } elseif ($mode == 'raid') { $query = mysql_query("SELECT raid FROM " . WHP_DB_PREFIX . "recruit WHERE uniquekey='{$key}' AND cache > UNIX_TIMESTAMP(NOW()) - {$recruit_cache} LIMIT 1");
/** * Provides the tax rate percentage * * @api `shopp('cartitem.taxrate')` * @since 1.0 * * @param string $result The output * @param array $options The options * @param ShoppCartItem $O The working object * @return string The tax rate percentage (10.1%) **/ public static function taxrate($result, $options, $O) { if (count($O->taxes) == 1) { $Tax = reset($O->taxes); return percentage($Tax->rate * 100, array('precision' => 1)); } $compounding = false; $rate = 0; foreach ($O->taxes as $Tax) { $rate += $Tax->rate; if (Shopp::str_true($Tax->compound)) { $compounding = true; break; } } if ($compounding) { $rate = $O->unittax / $O->unitprice; } return percentage($rate * 100, array('precision' => 1)); }
ShoppUI::print_column_headers($this->id); ?> </tr> </thead> <tfoot> <tr><?php ShoppUI::print_column_headers($this->id, false); ?> </tr> </tfoot> <tbody id="taxrates-table" class="list"> <?php if ($edit !== false && !isset($rates[$edit])) { $defaults = array('rate' => 0, 'country' => false, 'zone' => false, 'rules' => array(), 'locals' => array(), 'haslocals' => false, 'compound' => false); extract($defaults); echo ShoppUI::template($editor, array('${id}' => $edit, '${rate}' => percentage($rate, array('precision' => 4)), '${countries}' => menuoptions($countries, $country, true), '${zones}' => !empty($zones[$country]) ? menuoptions($zones[$country], $zone, true) : '', '${conditions}' => join('', $conditions), '${haslocals}' => $haslocals, '${localrates}' => join('', $localrates), '${instructions}' => $localerror ? '<p class="error">' . $localerror . '</p>' : $instructions, '${compounded}' => Shopp::str_true($compound) ? 'checked="checked"' : '')); } if (count($rates) == 0 && $edit === false) { ?> <tr id="no-taxrates"><td colspan="5"><?php _e('No tax rates, yet.', 'Shopp'); ?> </td></tr> <?php } $hidden = get_hidden_columns('shopp_page_shopp-settings-taxrates'); $even = false; foreach ($rates as $index => $taxrate) { $defaults = array('rate' => 0, 'country' => false, 'zone' => false, 'rules' => array(), 'locals' => array(), 'haslocals' => false); $taxrate = array_merge($defaults, $taxrate); extract($taxrate);
/** * Provides a labeled version of the current applied discount * * This is used within a discount loop. * * @see ShoppCartThemeAPI::discounts() Used within a shopp('cart.discounts') loop * @api `shopp('cart.discount-applied')` * @since 1.1 * * @param string $result The output * @param array $options The options * - **label**: `%s off` The label format where `%s` is a token replaced with the discount name * - **creditlabel**: `%s applied` The label for credits (not discounts) where `%s` is the credit name * - **before**: Markup to use before the entry * - **after**: Markup to use after the entry, * - **remove**: `on` (on, off) Include a remove link that unapplies the discount * @param ShoppCart $O The working object * @return The discount label **/ public static function discount_applied($result, $options, $O) { $Discount = ShoppOrder()->Discounts->current(); if (!$Discount->applies()) { return false; } $defaults = array('label' => __('%s off', 'Shopp'), 'creditlabel' => __('%s applied', 'Shopp'), 'before' => '', 'after' => '', 'remove' => 'on'); $options = array_merge($defaults, $options); extract($options, EXTR_SKIP); if (false === strpos($label, '%s')) { $label = "%s {$label}"; } $string = $before; switch ($Discount->type()) { case ShoppOrderDiscount::SHIP_FREE: $string .= Shopp::esc_html__('Free Shipping!'); break; case ShoppOrderDiscount::PERCENT_OFF: $string .= sprintf(esc_html($label), percentage((double) $Discount->discount(), array('precision' => 0))); break; case ShoppOrderDiscount::AMOUNT_OFF: $string .= sprintf(esc_html($label), money($Discount->discount())); break; case ShoppOrderDiscount::CREDIT: $string .= sprintf(esc_html($creditlabel), money($Discount->amount())); break; case ShoppOrderDiscount::BOGOF: list($buy, $get) = $Discount->discount(); $string .= ucfirst(strtolower(Shopp::esc_html__('Buy %s Get %s Free', $buy, $get))); break; } $options['label'] = ''; if (Shopp::str_true($remove)) { $string .= ' ' . self::discount_remove('', $options, $O); } $string .= $after; return $string; }
function tag($property, $options = array()) { global $Shopp; switch ($property) { case "link": case "url": if (SHOPP_PERMALINKS) { $url = esc_url(add_query_arg($_GET, $Shopp->shopuri . urldecode($this->slug) . "/")); } else { $url = add_query_arg('shopp_pid', $this->id, $Shopp->shopuri); } return $url; break; case "found": if (empty($this->id)) { return false; } $load = array('prices', 'images', 'specs'); if (isset($options['load'])) { $load = explode(",", $options['load']); } $this->load_data($load); return true; break; case "id": return $this->id; break; case "name": return $this->name; break; case "slug": return $this->slug; break; case "summary": return $this->summary; break; case "description": return apply_filters('shopp_product_description', $this->description); case "isfeatured": case "is-featured": return $this->featured == "on"; break; case "price": if (empty($this->prices)) { $this->load_data(array('prices')); } if (!isset($options['taxes'])) { $options['taxes'] = null; } // $taxrate = 0; // $taxes = false; // $base = $Shopp->Settings->get('base_operations'); // if ($base['vat']) $taxes = true; // if (isset($options['taxes'])) $taxes = (value_is_true($options['taxes'])); // if ($taxes) $taxrate = $Shopp->Cart->taxrate(); if (count($this->options) > 0) { $taxrate = shopp_taxrate($options['taxes']); if ($this->pricerange['min']['price'] == $this->pricerange['max']['price']) { return money($this->pricerange['min']['price'] + $this->pricerange['min']['price'] * $taxrate); } else { if (!empty($options['starting'])) { return $options['starting'] . " " . money($this->pricerange['min']['price'] + $this->pricerange['min']['price'] * $taxrate); } return money($this->pricerange['min']['price'] + $this->pricerange['min']['price'] * $taxrate) . " — " . money($this->pricerange['max']['price'] + $this->pricerange['max']['price'] * $taxrate); } } else { $taxrate = shopp_taxrate($options['taxes'], $this->prices[0]->tax); return money($this->prices[0]->price + $this->prices[0]->price * $taxrate); } break; case "weight": if (empty($this->prices)) { $this->load_data(array('prices')); } $unit = isset($options['units']) && !value_is_true($options['units']) ? false : $Shopp->Settings->get('weight_unit'); if (!$this->weightrange['min']) { return false; } $string = $this->weightrange['min'] == $this->weightrange['max'] ? round($this->weightrange['min'], 3) : round($this->weightrange['min'], 3) . " - " . round($this->weightrange['max'], 3); $string .= $unit ? " {$unit}" : ""; return $string; break; case "onsale": if (empty($this->prices)) { $this->load_data(array('prices')); } if (empty($this->prices)) { return false; } return $this->onsale; // if (empty($this->prices)) $this->load_prices(); $sale = false; if (count($this->prices) > 1) { foreach ($this->prices as $pricetag) { if (isset($pricetag->onsale) && $pricetag->onsale == "on") { $sale = true; } } return $sale; } else { return $this->prices[0]->onsale == "on" ? true : false; } break; case "saleprice": if (empty($this->prices)) { $this->load_data(array('prices')); } if (!isset($options['taxes'])) { $options['taxes'] = null; } $pricetag = 'price'; if ($this->onsale) { $pricetag = 'saleprice'; } if (count($this->options) > 0) { $taxrate = shopp_taxrate($options['taxes']); if ($this->pricerange['min'][$pricetag] == $this->pricerange['max'][$pricetag]) { return money($this->pricerange['min'][$pricetag] + $this->pricerange['min'][$pricetag] * $taxrate); } else { if (!empty($options['starting'])) { return $options['starting'] . " " . money($this->pricerange['min'][$pricetag] + $this->pricerange['min'][$pricetag] * $taxrate); } return money($this->pricerange['min'][$pricetag] + $this->pricerange['min'][$pricetag] * $taxrate) . " — " . money($this->pricerange['max'][$pricetag] + $this->pricerange['max'][$pricetag] * $taxrate); } } else { $taxrate = shopp_taxrate($options['taxes'], $this->prices[0]->tax); return money($this->prices[0]->promoprice + $this->prices[0]->promoprice * $taxrate); } break; case "has-savings": return $this->onsale && $this->pricerange['min']['saved'] > 0 ? true : false; break; case "savings": if (empty($this->prices)) { $this->load_data(array('prices')); } if (!isset($options['taxes'])) { $options['taxes'] = null; } $taxrate = shopp_taxrate($options['taxes']); if (!isset($options['show'])) { $options['show'] = ''; } if ($options['show'] == "%" || $options['show'] == "percent") { if ($this->options > 1) { if (round($this->pricerange['min']['savings']) == round($this->pricerange['max']['savings'])) { return percentage($this->pricerange['min']['savings']); } else { return percentage($this->pricerange['min']['savings']) . " — " . percentage($this->pricerange['max']['savings']); } } else { return percentage($this->pricerange['max']['savings']); } } else { if ($this->options > 1) { if ($this->pricerange['min']['saved'] == $this->pricerange['max']['saved']) { return money($this->pricerange['min']['saved'] + $this->pricerange['min']['saved'] * $taxrate); } else { return money($this->pricerange['min']['saved'] + $this->pricerange['min']['saved'] * $taxrate) . " — " . money($this->pricerange['max']['saved'] + $this->pricerange['max']['saved'] * $taxrate); } } else { return money($this->pricerange['max']['saved'] + $this->pricerange['max']['saved'] * $taxrate); } } break; case "freeshipping": if (empty($this->prices)) { $this->load_data(array('prices')); } // if (empty($this->prices)) $this->load_prices(); return $this->freeshipping; case "thumbnail": if (empty($this->imagesets)) { $this->load_data(array('images')); } if (empty($options['class'])) { $options['class'] = ''; } else { $options['class'] = ' class="' . $options['class'] . '"'; } if (isset($this->thumbnail)) { $img = $this->thumbnail; $title = !empty($img->properties['title']) ? ' title="' . attribute_escape($img->properties['title']) . '"' : ''; $width = isset($options['width']) ? $options['width'] : $img->properties['width']; $height = isset($options['height']) ? $options['height'] : $img->properties['height']; if (isset($options['width']) && !isset($options['height'])) { $scale = $width / $img->properties['width']; $height = round($img->properties['height'] * $scale); } if (isset($options['height']) && !isset($options['width'])) { $scale = $height / $img->properties['height']; $width = round($img->properties['width'] * $scale); } if (!empty($options['title'])) { $title = ' title="' . attribute_escape($options['title']) . '"'; } $alt = attribute_escape(!empty($img->properties['alt']) ? $img->properties['alt'] : $this->name); return '<img src="' . $img->uri . '"' . $title . ' alt="' . $alt . '" width="' . $width . '" height="' . $height . '" ' . $options['class'] . ' />'; break; } break; case "hasimages": case "has-images": if (empty($options['type'])) { $options['type'] = "thumbnail"; } if (empty($this->images)) { $this->load_data(array('images')); } if (!empty($this->imagesets[$options['type']])) { $this->imageset =& $this->imagesets[$options['type']]; return true; } else { return false; } break; case "images": if (!$this->imageset) { return false; } if (!$this->imageloop) { reset($this->imageset); $this->imageloop = true; } else { next($this->imageset); } if (current($this->imageset)) { return true; } else { $this->imageloop = false; $this->imageset = false; return false; } break; case "image": $img = current($this->imageset); if (isset($options['property'])) { switch (strtolower($options['property'])) { case "url": return $img->uri; case "width": return $img->properties['width']; case "height": return $img->properties['height']; case "title": return attribute_escape($img->properties['title']); case "alt": return attribute_escape($img->properties['alt']); default: return $img->id; } } if (!isset($options['class'])) { $options['class'] = false; } if (!empty($options['class'])) { $options['class'] = ' class="' . $options['class'] . '"'; } $title = !empty($img->properties['title']) ? ' title="' . attribute_escape($img->properties['title']) . '"' : ''; $width = isset($options['width']) ? $options['width'] : $img->properties['width']; $height = isset($options['height']) ? $options['height'] : $img->properties['height']; if (isset($options['width']) && !isset($options['height'])) { $scale = $width / $img->properties['width']; $height = round($img->properties['height'] * $scale); } if (isset($options['height']) && !isset($options['width'])) { $scale = $height / $img->properties['height']; $width = round($img->properties['width'] * $scale); } if (!empty($options['title'])) { $title = ' title="' . attribute_escape($options['title']) . '"'; } $alt = attribute_escape(!empty($img->properties['alt']) ? $img->properties['alt'] : $this->name); $string = ""; if (!isset($options['zoomfx'])) { $options['zoomfx'] = "shopp-thickbox"; } if (!empty($options['zoom'])) { $string .= '<a href="' . $Shopp->imguri . $img->src . '/' . str_replace('small_', '', $img->name) . '" class="' . $options['zoomfx'] . '" rel="product-gallery">'; } $string .= '<img src="' . $img->uri . '"' . $title . ' alt="' . $alt . '" width="' . $width . '" height="' . $height . '" ' . $options['class'] . ' />'; if (!empty($options['zoom'])) { $string .= "</a>"; } return $string; break; case "gallery": if (empty($this->images)) { $this->load_data(array('images')); } if (!isset($options['zoomfx'])) { $options['zoomfx'] = "shopp-thickbox"; } if (!isset($options['preview'])) { $options['preview'] = "click"; } $previews = '<ul class="previews">'; $firstPreview = true; if (!empty($this->imagesets['small'])) { foreach ($this->imagesets['small'] as $img) { if ($firstPreview) { $previews .= '<li id="preview-fill"' . ($firstPreview ? ' class="fill"' : '') . '>'; $previews .= '<img src="' . $Shopp->uri . '/core/ui/icons/clear.png' . '" alt="' . $img->datatype . '" width="' . $img->properties['width'] . '" height="' . $img->properties['height'] . '" />'; $previews .= '</li>'; } $title = !empty($img->properties['title']) ? ' title="' . attribute_escape($img->properties['title']) . '"' : ''; $alt = attribute_escape(!empty($img->properties['alt']) ? $img->properties['alt'] : $img->name); $rel = isset($options['rel']) && $options['rel'] ? ' rel="product_' . $this->id . '_gallery"' : ''; $previews .= '<li id="preview-' . $img->src . '"' . ($firstPreview ? ' class="active"' : '') . '>'; $previews .= '<a href="' . $Shopp->imguri . $img->src . '/' . str_replace('small_', '', $img->name) . '" class="product_' . $this->id . '_gallery ' . $options['zoomfx'] . '"' . $rel . '>'; $previews .= '<img src="' . $Shopp->imguri . $img->id . '"' . $title . ' alt="' . $alt . '" width="' . $img->properties['width'] . '" height="' . $img->properties['height'] . '" />'; $previews .= '</a>'; $previews .= '</li>'; $firstPreview = false; } } $previews .= '</ul>'; $thumbs = ""; if (isset($this->imagesets['thumbnail']) && count($this->imagesets['thumbnail']) > 1) { $thumbsize = 32; if (isset($options['thumbsize'])) { $thumbsize = $options['thumbsize']; } $thumbwidth = $thumbsize; $thumbheight = $thumbsize; if (isset($options['thumbwidth'])) { $thumbwidth = $options['thumbwidth']; } if (isset($options['thumbheight'])) { $thumbheight = $options['thumbheight']; } $firstThumb = true; $thumbs = '<ul class="thumbnails">'; foreach ($this->imagesets['thumbnail'] as $img) { if (isset($options['thumbwidth']) && !isset($options['thumbheight'])) { $scale = $thumbwidth / $img->properties['width']; $thumbheight = round($img->properties['height'] * $scale); } if (isset($options['thumbheight']) && !isset($options['thumbwidth'])) { $scale = $thumbheight / $img->properties['height']; $thumbwidth = round($img->properties['width'] * $scale); } $title = !empty($img->properties['title']) ? ' title="' . attribute_escape($img->properties['title']) . '"' : ''; $alt = attribute_escape(!empty($img->properties['alt']) ? $img->properties['alt'] : $img->name); $thumbs .= '<li id="thumbnail-' . $img->src . '" class="preview-' . $img->src . ($firstThumb ? ' first' : ' test') . '">'; $thumbs .= '<img src="' . $Shopp->imguri . $img->id . '"' . $title . ' alt="' . $alt . '" width="' . $thumbwidth . '" height="' . $thumbheight . '" />'; $thumbs .= '</li>'; $firstThumb = false; } $thumbs .= '</ul>'; } $result = '<div id="gallery-' . $this->id . '" class="gallery">' . $previews . $thumbs . '</div>'; $result .= '<script type="text/javascript"><!-- jQuery(document).ready( function() { shopp_gallery("#gallery-' . $this->id . '","' . $options['preview'] . '"); }); // --></script>'; return $result; break; case "has-categories": if (empty($this->categories)) { $this->load_data(array('categories')); } if (count($this->categories) > 0) { return true; } else { return false; } break; case "categories": if (!$this->categoryloop) { reset($this->categories); $this->categoryloop = true; } else { next($this->categories); } if (current($this->categories)) { return true; } else { $this->categoryloop = false; return false; } break; case "in-category": if (empty($this->categories)) { $this->load_data(array('categories')); } if (isset($options['id'])) { $field = "id"; } if (isset($options['name'])) { $field = "name"; } if (isset($options['slug'])) { $field = "slug"; } foreach ($this->categories as $category) { if ($category->{$field} == $options[$field]) { return true; } } return false; case "category": $category = current($this->categories); if (isset($options['show'])) { if ($options['show'] == "id") { return $category->id; } if ($options['show'] == "slug") { return $category->slug; } } return $category->name; break; case "has-tags": if (empty($this->tags)) { $this->load_data(array('tags')); } if (count($this->tags) > 0) { return true; } else { return false; } break; case "tags": if (!$this->tagloop) { reset($this->tags); $this->tagloop = true; } else { next($this->tags); } if (current($this->tags)) { return true; } else { $this->tagloop = false; return false; } break; case "tagged": if (empty($this->tags)) { $this->load_data(array('tags')); } if (isset($options['id'])) { $field = "id"; } if (isset($options['name'])) { $field = "name"; } foreach ($this->tags as $tag) { if ($tag->{$field} == $options[$field]) { return true; } } return false; case "tag": $tag = current($this->tags); if (isset($options['show'])) { if ($options['show'] == "id") { return $tag->id; } } return $tag->name; break; case "has-specs": if (empty($this->specs)) { $this->load_data(array('specs')); } if (count($this->specs) > 0) { $this->merge_specs(); return true; } else { return false; } break; case "specs": if (!$this->specloop) { reset($this->specs); $this->specloop = true; } else { next($this->specs); } if (current($this->specs)) { return true; } else { $this->specloop = false; return false; } break; case "spec": $string = ""; $separator = ": "; $delimiter = ", "; if (isset($options['separator'])) { $separator = $options['separator']; } if (isset($options['delimiter'])) { $separator = $options['delimiter']; } $spec = current($this->specs); if (is_array($spec->content)) { $spec->content = join($delimiter, $spec->content); } if (isset($options['name']) && !empty($options['name']) && isset($this->specskey[$options['name']])) { $spec = $this->specskey[$options['name']]; if (is_array($spec)) { if (isset($options['index'])) { foreach ($spec as $index => $entry) { if ($index + 1 == $options['index']) { $content = $entry->content; } } } else { foreach ($spec as $entry) { $contents[] = $entry->content; } $content = join($delimiter, $contents); } } else { $content = $spec->content; } $string = apply_filters('shopp_product_spec', $content); return $string; } if (isset($options['name']) && isset($options['content'])) { $string = "{$spec->name}{$separator}" . apply_filters('shopp_product_spec', $spec->content); } elseif (isset($options['name'])) { $string = $spec->name; } elseif (isset($options['content'])) { $string = apply_filters('shopp_product_spec', $spec->content); } else { $string = "{$spec->name}{$separator}" . apply_filters('shopp_product_spec', $spec->content); } return $string; break; case "has-variations": return $this->variations == "on" && !empty($this->options); break; case "variations": $string = ""; if (!isset($options['mode'])) { if (!$this->priceloop) { reset($this->prices); $this->priceloop = true; } else { next($this->prices); } $thisprice = current($this->prices); if ($thisprice && $thisprice->type == "N/A") { next($this->prices); } if (current($this->prices)) { return true; } else { $this->priceloop = false; return false; } return true; } if ($this->outofstock) { return false; } // Completely out of stock, hide menus if (!isset($options['taxes'])) { $options['taxes'] = null; } $defaults = array('defaults' => '', 'disabled' => 'show', 'before_menu' => '', 'after_menu' => ''); $options = array_merge($defaults, $options); if (!isset($options['label'])) { $options['label'] = "on"; } if (!isset($options['required'])) { $options['required'] = __('You must select the options for this item before you can add it to your shopping cart.', 'Shopp'); } if ($options['mode'] == "single") { if (!empty($options['before_menu'])) { $string .= $options['before_menu'] . "\n"; } if (value_is_true($options['label'])) { $string .= '<label for="product-options' . $this->id . '">Options: </label> ' . "\n"; } $string .= '<select name="products[' . $this->id . '][price]" id="product-options' . $this->id . '">'; if (!empty($options['defaults'])) { $string .= '<option value="">' . $options['defaults'] . '</option>' . "\n"; } foreach ($this->prices as $pricetag) { if ($pricetag->context != "variation") { continue; } $taxrate = shopp_taxrate($options['taxes'], $pricetag->tax); $currently = $pricetag->sale == "on" ? $pricetag->promoprice : $pricetag->price; $disabled = $pricetag->inventory == "on" && $pricetag->stock == 0 ? ' disabled="disabled"' : ''; $price = ' (' . money($currently) . ')'; if ($pricetag->type != "N/A") { $string .= '<option value="' . $pricetag->id . '"' . $disabled . '>' . $pricetag->label . $price . '</option>' . "\n"; } } $string .= '</select>'; if (!empty($options['after_menu'])) { $string .= $options['after_menu'] . "\n"; } } else { $taxrate = shopp_taxrate($options['taxes'], true); ob_start(); ?> <script type="text/javascript"> <!-- (function($) { $(document).ready(function () { productOptions[<?php echo $this->id; ?> ] = new Array(); productOptions[<?php echo $this->id; ?> ]['pricing'] = <?php echo json_encode($this->pricekey); ?> ; options_default = <?php echo !empty($options['defaults']) ? 'true' : 'false'; ?> ; options_required = "<?php echo $options['required']; ?> "; productOptions[<?php echo $this->id; ?> ]['menu'] = new ProductOptionsMenus('select<?php if (isset($Shopp->Category->slug)) { echo ".category-" . $Shopp->Category->slug; } ?> .product<?php echo $this->id; ?> ',<?php echo $options['disabled'] == "hide" ? "true" : "false"; ?> ,productOptions[<?php echo $this->id; ?> ]['pricing'],<?php echo empty($taxrate) ? '0' : $taxrate; ?> ); }); })(jQuery) //--> </script> <?php $script = ob_get_contents(); ob_end_clean(); $options['after_menu'] = $script . $options['after_menu']; if (isset($this->options['variations'])) { foreach ($this->options['variations'] as $id => $menu) { if (!empty($options['before_menu'])) { $string .= $options['before_menu'] . "\n"; } if (value_is_true($options['label'])) { $string .= '<label for="options-' . $id . '">' . $menu['menu'] . '</label> ' . "\n"; } $string .= '<select name="products[' . $this->id . '][options][]" class="product' . $this->id . ' options">'; if (!empty($options['defaults'])) { $string .= '<option value="">' . $options['defaults'] . '</option>' . "\n"; } foreach ($menu['label'] as $key => $option) { $string .= '<option value="' . $menu['id'][$key] . '">' . $option . '</option>' . "\n"; } $string .= '</select>'; if (!empty($options['after_menu'])) { $string .= $options['after_menu'] . "\n"; } } } else { foreach ($this->options as $id => $menu) { if (!empty($options['before_menu'])) { $string .= $options['before_menu'] . "\n"; } if (value_is_true($options['label'])) { $string .= '<label for="options-' . $menu['id'] . '">' . $menu['name'] . '</label> ' . "\n"; } $category_class = isset($Shopp->Category->slug) ? 'category-' . $Shopp->Category->slug : ''; $string .= '<select name="products[' . $this->id . '][options][]" class="' . $category_class . ' product' . $this->id . ' options" id="options-' . $menu['id'] . '">'; if (!empty($options['defaults'])) { $string .= '<option value="">' . $options['defaults'] . '</option>' . "\n"; } foreach ($menu['options'] as $key => $option) { $string .= '<option value="' . $option['id'] . '">' . $option['name'] . '</option>' . "\n"; } $string .= '</select>'; if (!empty($options['after_menu'])) { $string .= $options['after_menu'] . "\n"; } } } } return $string; break; case "variation": $variation = current($this->prices); if (!isset($options['taxes'])) { $options['taxes'] = null; } $taxrate = shopp_taxrate($options['taxes'], $variation->tax); $weightunit = isset($options['units']) && !value_is_true($options['units']) ? false : $Shopp->Settings->get('weight_unit'); $string = ''; if (array_key_exists('id', $options)) { $string .= $variation->id; } if (array_key_exists('label', $options)) { $string .= $variation->label; } if (array_key_exists('type', $options)) { $string .= $variation->type; } if (array_key_exists('sku', $options)) { $string .= $variation->sku; } if (array_key_exists('price', $options)) { $string .= money($variation->price + $variation->price * $taxrate); } if (array_key_exists('saleprice', $options)) { $string .= money($variation->saleprice + $variation->saleprice * $taxrate); } if (array_key_exists('stock', $options)) { $string .= $variation->stock; } if (array_key_exists('weight', $options)) { $string .= round($variation->weight, 3) . ($weightunit ? " {$weightunit}" : false); } if (array_key_exists('shipfee', $options)) { $string .= money(floatvalue($variation->shipfee)); } if (array_key_exists('sale', $options)) { return $variation->sale == "on"; } if (array_key_exists('shipping', $options)) { return $variation->shipping == "on"; } if (array_key_exists('tax', $options)) { return $variation->tax == "on"; } if (array_key_exists('inventory', $options)) { return $variation->inventory == "on"; } return $string; break; case "has-addons": if (isset($this->options['addons'])) { return true; } else { return false; } break; break; case "donation": case "amount": case "quantity": if ($this->outofstock) { return false; } if (!isset($options['value'])) { $options['value'] = 1; } if (!isset($options['input'])) { $options['input'] = "text"; } if (!isset($options['labelpos'])) { $options['labelpos'] = "before"; } if (!isset($options['label'])) { $label = ""; } else { $label = '<label for="quantity' . $this->id . '">' . $options['label'] . '</label>'; } $result = ""; if ($options['labelpos'] == "before") { $result .= "{$label} "; } if (!$this->priceloop) { reset($this->prices); } $variation = current($this->prices); if (isset($options['input']) && $options['input'] == "menu") { if (!isset($options['options'])) { $values = "1-15,20,25,30,40,50,75,100"; } else { $values = $options['options']; } if ($this->inventory && $this->pricerange['max']['stock'] == 0) { return ""; } if (strpos($values, ",") !== false) { $values = explode(",", $values); } else { $values = array($values); } $qtys = array(); foreach ($values as $value) { if (strpos($value, "-") !== false) { $value = explode("-", $value); if ($value[0] >= $value[1]) { $qtys[] = $value[0]; } else { for ($i = $value[0]; $i < $value[1] + 1; $i++) { $qtys[] = $i; } } } else { $qtys[] = $value; } } $result .= '<select name="products[' . $this->id . '][quantity]" id="quantity-' . $this->id . '">'; foreach ($qtys as $qty) { $amount = $qty; $selected = isset($this->quantity) ? $this->quantity : 1; if ($variation->type == "Donation" && $variation->donation['var'] == "on") { if ($variation->donation['min'] == "on" && $amount < $variation->price) { continue; } $amount = money($amount); $selected = $variation->price; } else { if ($this->inventory && $amount > $this->pricerange['max']['stock']) { continue; } } $result .= '<option' . ($qty == $selected ? ' selected="selected"' : '') . ' value="' . $qty . '">' . $amount . '</option>'; } $result .= '</select>'; if ($options['labelpos'] == "after") { $result .= " {$label}"; } return $result; } if (valid_input($options['input'])) { if (!isset($options['size'])) { $options['size'] = 3; } if ($variation->type == "Donation" && $variation->donation['var'] == "on") { if ($variation->donation['min']) { $options['value'] = $variation->price; } $options['class'] .= " currency"; } $result = '<input type="' . $options['input'] . '" name="products[' . $this->id . '][quantity]" id="quantity-' . $this->id . '"' . inputattrs($options) . ' />'; } if ($options['labelpos'] == "after") { $result .= " {$label}"; } return $result; break; case "input": if (!isset($options['type']) || $options['type'] != "menu" && $options['type'] != "textarea" && !valid_input($options['type'])) { $options['type'] = "text"; } if (!isset($options['name'])) { return ""; } if ($options['type'] == "menu") { $result = '<select name="products[' . $this->id . '][data][' . $options['name'] . ']" id="data-' . $options['name'] . '-' . $this->id . '">'; if (isset($options['options'])) { $menuoptions = preg_split('/,(?=(?:[^\\"]*\\"[^\\"]*\\")*(?![^\\"]*\\"))/', $options['options']); } if (is_array($menuoptions)) { foreach ($menuoptions as $option) { $selected = ""; $option = trim($option, '"'); if (isset($options['default']) && $options['default'] == $option) { $selected = ' selected="selected"'; } $result .= '<option value="' . $option . '"' . $selected . '>' . $option . '</option>'; } } $result .= '</select>'; } elseif ($options['type'] == "textarea") { if (isset($options['cols'])) { $cols = ' cols="' . $options['cols'] . '"'; } if (isset($options['rows'])) { $rows = ' rows="' . $options['rows'] . '"'; } $result .= '<textarea name="products[' . $this->id . '][data][' . $options['name'] . ']" id="data-' . $options['name'] . '-' . $this->id . '"' . $cols . $rows . '>' . $options['value'] . '</textarea>'; } else { $result = '<input type="' . $options['type'] . '" name="products[' . $this->id . '][data][' . $options['name'] . ']" id="data-' . $options['name'] . '-' . $this->id . '"' . inputattrs($options) . ' />'; } return $result; break; case "outofstock": if ($this->outofstock) { $label = isset($options['label']) ? $options['label'] : $Shopp->Settings->get('outofstock_text'); $string = '<span class="outofstock">' . $label . '</span>'; return $string; } else { return false; } break; case "buynow": if (!isset($options['value'])) { $options['value'] = __("Buy Now", "Shopp"); } case "addtocart": if (!isset($options['class'])) { $options['class'] = "addtocart"; } else { $options['class'] .= " addtocart"; } if (!isset($options['value'])) { $options['value'] = __("Add to Cart", "Shopp"); } $string = ""; if ($this->outofstock) { $string .= '<span class="outofstock">' . $Shopp->Settings->get('outofstock_text') . '</span>'; return $string; } $string .= '<input type="hidden" name="products[' . $this->id . '][product]" value="' . $this->id . '" />'; if (!empty($this->prices[0]) && $this->prices[0]->type != "N/A") { $string .= '<input type="hidden" name="products[' . $this->id . '][price]" value="' . $this->prices[0]->id . '" />'; } if (!empty($Shopp->Category)) { if (SHOPP_PERMALINKS) { $string .= '<input type="hidden" name="products[' . $this->id . '][category]" value="' . $Shopp->Category->uri . '" />'; } else { $string .= '<input type="hidden" name="products[' . $this->id . '][category]" value="' . (!empty($Shopp->Category->id) ? $Shopp->Category->id : $Shopp->Category->slug) . '" />'; } } $string .= '<input type="hidden" name="cart" value="add" />'; if (isset($options['ajax'])) { $options['class'] .= " ajax"; $string .= '<input type="hidden" name="ajax" value="true" />'; $string .= '<input type="button" name="addtocart" ' . inputattrs($options) . ' />'; } else { $string .= '<input type="submit" name="addtocart" ' . inputattrs($options) . ' />'; } return $string; } }
public function editor($Item) { extract($Item); $conditions = array(); foreach ($rules as $ruleid => $rule) { $conditionals = array('${id}' => $edit, '${ruleid}' => $ruleid, '${property_menu}' => $this->property_menu($rule['p']), '${rulevalue}' => esc_attr($rule['v'])); $conditions[] = str_replace(array_keys($conditionals), $conditionals, $this->template_conditional()); } $localrates = array(); foreach ($locals as $localename => $localerate) { $localrate_data = array('${id}' => $edit, '${localename}' => $localename, '${localerate}' => (double) $localerate); $localrates[] = str_replace(array_keys($localrate_data), $localrate_data, $this->template_localrate()); } $data = array('${id}' => $id, '${rate}' => percentage($rate, array('precision' => 4)), '${countries}' => menuoptions($this->countries, $country, true), '${zones}' => !empty($zones[$country]) ? menuoptions($zones[$country], $zone, true) : '', '${conditions}' => join('', $conditions), '${haslocals}' => $haslocals, '${localrates}' => join('', $localrates), '${instructions}' => $localerror ? '<p class="error">' . $localerror . '</p>' : $instructions, '${compounded}' => Shopp::str_true($compound) ? 'checked="checked"' : '', '${cancel_href}' => add_query_arg(array('id' => null, '_wpnonce' => null))); if ($conditions) { $data['no-conditions'] = ''; } if (!empty($zones[$country])) { $data['no-zones'] = ''; } if ($haslocals) { $data['no-local-rates'] = ''; } else { $data['has-local-rates'] = ''; } if (count($locals) > 0) { $data['instructions'] = 'hidden'; } echo ShoppUI::template($this->editor, $data); }
foreach ($Promotions as $Promotion): $editurl = add_query_arg(array_merge($_GET,array('page'=>'ecart-promotions','id'=>$Promotion->id)),admin_url('admin.php')); $deleteurl = add_query_arg(array_merge($_GET,array('page'=>'ecart-promotions','delete[]'=>$Promotion->id,'deleting'=>'promotion')),admin_url('admin.php')); $PromotionName = empty($Promotion->name)?'('.__('no promotion name').')':$Promotion->name; ?> <tr<?php if (!$even) echo " class='alternate'"; $even = !$even; ?>> <th scope='row' class='check-column'><input type='checkbox' name='delete[]' value='<?php echo $Promotion->id; ?>' /></th> <td width="33%" class="name column-name"><a class='row-title' href='<?php echo esc_url($editurl); ?>' title='<?php _e('Edit','Ecart'); ?> "<?php echo esc_attr($PromotionName); ?>"'><?php echo esc_html($PromotionName); ?></a> <div class="row-actions"> <span class='edit'><a href="<?php echo esc_url($editurl); ?>" title="<?php _e('Edit','Ecart'); ?> "<?php echo esc_attr($PromotionName); ?>""><?php _e('Edit','Ecart'); ?></a> | </span> <span class='delete'><a class='submitdelete' title='<?php _e('Delete','Ecart'); ?> "<?php echo esc_attr($PromotionName); ?>"' href="<?php echo esc_url($deleteurl); ?>" rel="<?php echo $Promotion->id; ?>"><?php _e('Delete','Ecart'); ?></a></span> </div> </td> <td class="discount column-discount<?php echo in_array('discount',$hidden)?' hidden':''; ?>"><?php if ($Promotion->type == "Percentage Off") echo percentage($Promotion->discount); if ($Promotion->type == "Amount Off") echo money($Promotion->discount); if ($Promotion->type == "Free Shipping") echo $this->Settings->get("free_shipping_text"); if ($Promotion->type == "Buy X Get Y Free") echo __('Buy','Ecart').' '.$Promotion->buyqty.' '.__('Get','Ecart').' '.$Promotion->getqty.' '.__('Free','Ecart'); ?></td> <td class="applied column-applied<?php echo in_array('applied',$hidden)?' hidden':''; ?>"><?php echo $Promotion->target; ?></td> <td class="eff column-eff<?php echo in_array('eff',$hidden)?' hidden':''; ?>"><strong><?php echo $status[$Promotion->status]; ?></strong><?php $starts = (mktimestamp($Promotion->starts) > 1) ? _d(get_option('date_format'),mktimestamp($Promotion->starts)) : _d(get_option('date_format'),mktimestamp($Promotion->created)); $ends = (mktimestamp($Promotion->ends) > 1) ? " — " . _d(get_option('date_format'),mktimestamp($Promotion->ends)) : ", " . __('does not expire','Ecart'); echo "<br />".$starts.$ends; ?></td> </tr>
</p> <ul class="flex-container"> <!-- end for each word--> <?php foreach ($words as $key => $word) { ?> <li class="list-group-item" id="<?php echo $key; ?> "> <span class="badge"><?php echo $word; ?> </span> <span class="badge">%<?php echo percentage($word, $total_words); ?> </span> <?php echo ucfirst($key); ?> </li> <?php } ?> </ul> </div> </div> </div> </body> </html>
/** * Provides the amount of cost savings between the regular price and the sale price * * @api `shopp('product.savings')` * @since 1.1 * * @param string $result The output * @param array $options The options * - **taxes**: Used to include or exclude taxes from consideration in the calculations * - **show**: (%,percent) Change the amount to calculate the percentage savings instead of the total amount * - **separator**: ` — ` The separator between a range of settings * @param ShoppProduct $O The working object * @return string The savings amount **/ public static function savings($result, $options, $O) { $defaults = array('taxes' => null, 'show' => '', 'separator' => ' — '); $options = array_merge($defaults, $options); extract($options); $min = 0; $max = 0; $levels = array('min', 'max'); foreach ($levels as $level) { ${$level} = isset($O->{$level}['savings']) ? $O->{$level}['savings'] : false; } if (in_array(strtolower($show), array('%', 'percent'))) { $savings = round($min) == round($max) ? array($min) : array($min, $max); sort($savings); foreach ($savings as &$amount) { $amount = percentage($amount, array('precision' => 0)); } return join($separator, $savings); } else { $inclusivetax = self::_inclusive_taxes($O); $taxes = isset($taxes) ? Shopp::str_true($taxes) : null; if (isset($taxes) && $inclusivetax ^ $taxes) { list($regmin, $regmax) = self::_taxes($O, 'price', $taxes); $min *= $regmin / 100; $max *= $regmax / 100; } else { foreach ($levels as $level) { ${$level} = isset($O->{$level}['saved']) ? $O->{$level}['saved'] : false; } } $saved = $min == $max ? array($min) : array($min, $max); foreach ($saved as &$amount) { $amount = money($amount); } return join($separator, $saved); } }
/** * Provides support for the ecart('cartitem') tags * * @since 1.1 * * @return mixed **/ function tag ($id,$property,$options=array()) { global $Ecart; // Return strings with no options switch ($property) { case "id": return $id; case "product": return $this->product; case "name": return $this->name; case "type": return $this->type; case "link": case "url": return ecarturl(ECART_PRETTYURLS?$this->slug:array('ecart_pid'=>$this->product)); case "sku": return $this->sku; } $taxes = isset($options['taxes'])?value_is_true($options['taxes']):null; if (in_array($property,array('price','newprice','unitprice','total','tax','options'))) $taxes = ecart_taxrate($taxes,$this->taxable,$this) > 0?true:false; // Handle currency values $result = ""; switch ($property) { case "discount": $result = (float)$this->discount; break; case "unitprice": $result = (float)$this->unitprice+($taxes?$this->unittax:0); break; case "unittax": $result = (float)$this->unittax; break; case "discounts": $result = (float)$this->discounts; break; case "tax": $result = (float)$this->tax; break; case "total": $result = (float)$this->total+($taxes?($this->unittax*$this->quantity):0); break; } if (is_float($result)) { if (isset($options['currency']) && !value_is_true($options['currency'])) return $result; else return money($result); } // Handle values with complex options switch ($property) { case "taxrate": return percentage($this->taxrate*100,array('precision' => 1)); break; case "quantity": $result = $this->quantity; if ($this->type == "Donation" && $this->donation['var'] == "on") return $result; if (isset($options['input']) && $options['input'] == "menu") { if (!isset($options['value'])) $options['value'] = $this->quantity; if (!isset($options['options'])) $values = "1-15,20,25,30,35,40,45,50,60,70,80,90,100"; else $values = $options['options']; if (strpos($values,",") !== false) $values = explode(",",$values); else $values = array($values); $qtys = array(); foreach ($values as $value) { if (strpos($value,"-") !== false) { $value = explode("-",$value); if ($value[0] >= $value[1]) $qtys[] = $value[0]; else for ($i = $value[0]; $i < $value[1]+1; $i++) $qtys[] = $i; } else $qtys[] = $value; } $result = '<select name="items['.$id.']['.$property.']">'; foreach ($qtys as $qty) $result .= '<option'.(($qty == $this->quantity)?' selected="selected"':'').' value="'.$qty.'">'.$qty.'</option>'; $result .= '</select>'; } elseif (isset($options['input']) && valid_input($options['input'])) { if (!isset($options['size'])) $options['size'] = 5; if (!isset($options['value'])) $options['value'] = $this->quantity; $result = '<input type="'.$options['input'].'" name="items['.$id.']['.$property.']" id="items-'.$id.'-'.$property.'" '.inputattrs($options).'/>'; } else $result = $this->quantity; break; case "remove": $label = __("Remove"); if (isset($options['label'])) $label = $options['label']; if (isset($options['class'])) $class = ' class="'.$options['class'].'"'; else $class = ' class="remove"'; if (isset($options['input'])) { switch ($options['input']) { case "button": $result = '<button type="submit" name="remove['.$id.']" value="'.$id.'"'.$class.' tabindex="">'.$label.'</button>'; break; case "checkbox": $result = '<input type="checkbox" name="remove['.$id.']" value="'.$id.'"'.$class.' tabindex="" title="'.$label.'"/>'; break; } } else { $result = '<a href="'.href_add_query_arg(array('cart'=>'update','item'=>$id,'quantity'=>0),ecarturl(false,'cart')).'"'.$class.'>'.$label.'</a>'; } break; case "optionlabel": $result = $this->option->label; break; case "options": $class = ""; if (!isset($options['before'])) $options['before'] = ''; if (!isset($options['after'])) $options['after'] = ''; if (isset($options['show']) && strtolower($options['show']) == "selected") return (!empty($this->option->label))? $options['before'].$this->option->label.$options['after']:''; if (isset($options['class'])) $class = ' class="'.$options['class'].'" '; if (count($this->variations) > 1) { $result .= $options['before']; $result .= '<input type="hidden" name="items['.$id.'][product]" value="'.$this->product.'"/>'; $result .= ' <select name="items['.$id.'][price]" id="items-'.$id.'-price"'.$class.'>'; $result .= $this->options($this->priceline); $result .= '</select>'; $result .= $options['after']; } break; case "addons-list": case "addonslist": if (empty($this->addons)) return false; $defaults = array( 'before' => '', 'after' => '', 'class' => '', 'exclude' => '', 'prices' => true, ); $options = array_merge($defaults,$options); extract($options); $classes = !empty($class)?' class="'.join(' ',$class).'"':''; $excludes = explode(',',$exclude); $prices = value_is_true($prices); $result .= $before.'<ul'.$classes.'>'; foreach ($this->addons as $id => $addon) { if (in_array($addon->label,$excludes)) continue; $price = ($addon->onsale?$addon->promoprice:$addon->price); if ($this->taxrate > 0) $price = $price+($price*$this->taxrate); if ($prices) $pricing = " (".($addon->unitprice < 0?'-':'+').money($price).")"; $result .= '<li>'.$addon->label.$pricing.'</li>'; } $result .= '</ul>'.$after; return $result; break; case "hasinputs": case "has-inputs": return (count($this->data) > 0); break; case "inputs": if (!isset($this->_data_loop)) { reset($this->data); $this->_data_loop = true; } else next($this->data); if (current($this->data) !== false) return true; else { unset($this->_data_loop); reset($this->data); return false; } break; case "input": $data = current($this->data); $name = key($this->data); if (isset($options['name'])) return $name; return $data; break; case "inputs-list": case "inputslist": if (empty($this->data)) return false; $before = ""; $after = ""; $classes = ""; $excludes = array(); if (!empty($options['class'])) $classes = ' class="'.$options['class'].'"'; if (!empty($options['exclude'])) $excludes = explode(",",$options['exclude']); if (!empty($options['before'])) $before = $options['before']; if (!empty($options['after'])) $after = $options['after']; $result .= $before.'<ul'.$classes.'>'; foreach ($this->data as $name => $data) { if (in_array($name,$excludes)) continue; $result .= '<li><strong>'.$name.'</strong>: '.$data.'</li>'; } $result .= '</ul>'.$after; return $result; break; case "coverimage": case "thumbnail": $defaults = array( 'class' => '', 'width' => 48, 'height' => 48, 'size' => false, 'fit' => false, 'sharpen' => false, 'quality' => false, 'bg' => false, 'alt' => false, 'title' => false ); $options = array_merge($defaults,$options); extract($options); if ($this->image !== false) { $img = $this->image; if ($size !== false) $width = $height = $size; $scale = (!$fit)?false:esc_attr(array_search($fit,$img->_scaling)); $sharpen = (!$sharpen)?false:esc_attr(min($sharpen,$img->_sharpen)); $quality = (!$quality)?false:esc_attr(min($quality,$img->_quality)); $fill = (!$bg)?false:esc_attr(hexdec(ltrim($bg,'#'))); $scaled = $img->scaled($width,$height,$scale); $alt = empty($alt)?$img->alt:$alt; $title = empty($title)?$img->title:$title; $title = empty($title)?'':' title="'.esc_attr($title).'"'; $class = !empty($class)?' class="'.esc_attr($class).'"':''; if (!empty($options['title'])) $title = ' title="'.esc_attr($options['title']).'"'; $alt = esc_attr(!empty($img->alt)?$img->alt:$this->name); return '<img src="'.add_query_string($img->resizing($width,$height,$scale,$sharpen,$quality,$fill),ecarturl($img->id,'images')).'"'.$title.' alt="'.$alt.'" width="'.$scaled['width'].'" height="'.$scaled['height'].'"'.$class.' />'; } break; } if (!empty($result)) return $result; return false; }
<div class="col-md-4"><div class="alert alert-custom-7">' . letheglobal_opens . '<br><span class="count" data-from="0" data-to="' . $opensPerc . '">0</span>%</div></div> <div class="col-md-4"><div class="alert alert-custom-4">' . letheglobal_unsubscribe . '<br><span class="count" data-from="0" data-to="' . $totalUnsubPerc . '">0</span>%</div></div> <div class="col-md-4"><div class="alert alert-custom-6">' . letheglobal_bounces . '<br><span class="count" data-from="0" data-to="' . $bouncesPerc . '">0</span>%</div></div> </div> <div class="row"> <div class="col-md-4"> <h5>' . letheglobal_losses . '</h5><hr> <h3 class="text-danger"><span class="count" data-from="0" data-to="' . $totalUnsubPerc . '">0</span>% <span class="glyphicon glyphicon-thumbs-down"></span></h3> </div> <div class="col-md-4"> <h5>' . letheglobal_list_quality . '</h5><hr> <h3 class="text-success"><span class="count" data-from="0" data-to="' . (100 - $bouncesPerc) . '">0</span>% <span class="glyphicon glyphicon-thumbs-up"></span></h3> </div> <div class="col-md-4"> <h5>' . letheglobal_campaign_quality . '</h5><hr> <h3 class="text-success"><span class="count" data-from="0" data-to="' . percentage(($clicksPerc + $opensPerc) / 2, 100, 0) . '">0</span>% <span class="glyphicon glyphicon-thumbs-up"></span></h3> </div> </div> </div> </div> </div> <script> var data = [ { value: ' . $sent . ', color: "#57464e", highlight: "#7b646f", label: "' . letheglobal_sent . '" },