text:
/*
 * Do not modify this file. This file is generated from the ec2-2015-10-01.normal.json service model.
 */
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;
using System.IO;

using Amazon.Runtime;
using Amazon.Runtime.Internal;

namespace Amazon.EC2.Model
{
    /// <summary>
    /// Describes a network interface.
    /// </summary>
    public partial class InstanceNetworkInterface
    {
        private InstanceNetworkInterfaceAssociation _association;
        private InstanceNetworkInterfaceAttachment _attachment;
        private string _description;
        private List<GroupIdentifier> _groups = new List<GroupIdentifier>();
        private string _macAddress;
        private string _networkInterfaceId;
        private string _ownerId;
        private string _privateDnsName;
        private string _privateIpAddress;
        private List<InstancePrivateIpAddress> _privateIpAddresses = new List<InstancePrivateIpAddress>();
        private bool? _sourceDestCheck;
        private NetworkInterfaceStatus _status;
        private string _subnetId;
        private string _vpcId;

        /// <summary>
        /// Gets and sets the property Association.
        /// <para>
        /// The association information for an Elastic IP associated with the network interface.
        /// </para>
        /// </summary>
        public InstanceNetworkInterfaceAssociation Association
        {
            get { return this._association; }
            set { this._association = value; }
        }

        // Check to see if Association property is set
        internal bool IsSetAssociation()
        {
            return this._association != null;
        }

        /// <summary>
        /// Gets and sets the property Attachment.
        /// <para>
        /// The network interface attachment.
        /// </para>
        /// </summary>
        public InstanceNetworkInterfaceAttachment Attachment
        {
            get { return this._attachment; }
            set { this._attachment = value; }
        }

        // Check to see if Attachment property is set
        internal bool IsSetAttachment()
        {
            return this._attachment != null;
        }

        /// <summary>
        /// Gets and sets the property Description.
        /// <para>
        /// The description.
        /// </para>
        /// </summary>
        public string Description
        {
            get { return this._description; }
            set { this._description = value; }
        }

        // Check to see if Description property is set
        internal bool IsSetDescription()
        {
            return this._description != null;
        }

        /// <summary>
        /// Gets and sets the property Groups.
        /// <para>
        /// One or more security groups.
        /// </para>
        /// </summary>
        public List<GroupIdentifier> Groups
        {
            get { return this._groups; }
            set { this._groups = value; }
        }

        // Check to see if Groups property is set
        internal bool IsSetGroups()
        {
            return this._groups != null && this._groups.Count > 0;
        }

        /// <summary>
        /// Gets and sets the property MacAddress.
        /// <para>
        /// The MAC address.
        /// </para>
        /// </summary>
        public string MacAddress
        {
            get { return this._macAddress; }
            set { this._macAddress = value; }
        }

        // Check to see if MacAddress property is set
        internal bool IsSetMacAddress()
        {
            return this._macAddress != null;
        }

        /// <summary>
        /// Gets and sets the property NetworkInterfaceId.
        /// <para>
        /// The ID of the network interface.
        /// </para>
        /// </summary>
        public string NetworkInterfaceId
        {
            get { return this._networkInterfaceId; }
            set { this._networkInterfaceId = value; }
        }

        // Check to see if NetworkInterfaceId property is set
        internal bool IsSetNetworkInterfaceId()
        {
            return this._networkInterfaceId != null;
        }

        /// <summary>
        /// Gets and sets the property OwnerId.
        /// <para>
        /// The ID of the AWS account that created the network interface.
        /// </para>
        /// </summary>
        public string OwnerId
        {
            get { return this._ownerId; }
            set { this._ownerId = value; }
        }

        // Check to see if OwnerId property is set
        internal bool IsSetOwnerId()
        {
            return this._ownerId != null;
        }

        /// <summary>
        /// Gets and sets the property PrivateDnsName.
        /// <para>
        /// The private DNS name.
        /// </para>
        /// </summary>
        public string PrivateDnsName
        {
            get { return this._privateDnsName; }
            set { this._privateDnsName = value; }
        }

        // Check to see if PrivateDnsName property is set
        internal bool IsSetPrivateDnsName()
        {
            return this._privateDnsName != null;
        }

        /// <summary>
        /// Gets and sets the property PrivateIpAddress.
        /// <para>
        /// The IP address of the network interface within the subnet.
        /// </para>
        /// </summary>
        public string PrivateIpAddress
        {
            get { return this._privateIpAddress; }
            set { this._privateIpAddress = value; }
        }

        // Check to see if PrivateIpAddress property is set
        internal bool IsSetPrivateIpAddress()
        {
            return this._privateIpAddress != null;
        }

        /// <summary>
        /// Gets and sets the property PrivateIpAddresses.
        /// <para>
        /// The private IP addresses associated with the network interface.
        /// </para>
        /// </summary>
        public List<InstancePrivateIpAddress> PrivateIpAddresses
        {
            get { return this._privateIpAddresses; }
            set { this._privateIpAddresses = value; }
        }

        // Check to see if PrivateIpAddresses property is set
        internal bool IsSetPrivateIpAddresses()
        {
            return this._privateIpAddresses != null && this._privateIpAddresses.Count > 0;
        }

        /// <summary>
        /// Gets and sets the property SourceDestCheck.
        /// <para>
        /// Indicates whether to validate network traffic to or from this network interface.
        /// </para>
        /// </summary>
        public bool SourceDestCheck
        {
            get { return this._sourceDestCheck.GetValueOrDefault(); }
            set { this._sourceDestCheck = value; }
        }

        // Check to see if SourceDestCheck property is set
        internal bool IsSetSourceDestCheck()
        {
            return this._sourceDestCheck.HasValue;
        }

        /// <summary>
        /// Gets and sets the property Status.
        /// <para>
        /// The status of the network interface.
        /// </para>
        /// </summary>
        public NetworkInterfaceStatus Status
        {
            get { return this._status; }
            set { this._status = value; }
        }

        // Check to see if Status property is set
        internal bool IsSetStatus()
        {
            return this._status != null;
        }

        /// <summary>
        /// Gets and sets the property SubnetId.
        /// <para>
        /// The ID of the subnet.
        /// </para>
        /// </summary>
        public string SubnetId
        {
            get { return this._subnetId; }
            set { this._subnetId = value; }
        }

        // Check to see if SubnetId property is set
        internal bool IsSetSubnetId()
        {
            return this._subnetId != null;
        }

        /// <summary>
        /// Gets and sets the property VpcId.
        /// <para>
        /// The ID of the VPC.
        /// </para>
        /// </summary>
        public string VpcId
        {
            get { return this._vpcId; }
            set { this._vpcId = value; }
        }

        // Check to see if VpcId property is set
        internal bool IsSetVpcId()
        {
            return this._vpcId != null;
        }

    }
}


text:
//
// Copyright (c) 2012 Regents of the SIGNET lab, University of Padova.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
// 3. Neither the name of the University of Padova (SIGNET lab) nor the
//    names of its contributors may be used to endorse or promote products
//    derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/**
 * @file   woss-groupmobility-3d.cpp
 * @author Saiful Azad
 * @version 1.0.0
 *
 * @brief Implementation of GroupMobility-3D for WOSS framework
 */

#include <node-core.h>
#include<rng.h>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<string>
#include "woss-groupmobility-3d.h"

/**
 * TCL Hooks for the simulator
 */
static class WossGroupMob3DClass : public TclClass {
public:
	/**
	 * Class constructor
	 */
	WossGroupMob3DClass() : TclClass("WOSS/GroupMob3D") {}
	TclObject* create(int, const char*const*) {
		return (new WossGroupMob3D);
	}
} class_wossgroupmob3D;

void WossGroupMob3D::UpdatePositionTimer::expire(Event* e) {

  if (mod->wossgroup_debug_) cout << NOW << " WossGroupMob3D::UpdateTimerPosition(" << mod->maddr << "), timer expire, curr_state = UpdatePositionTime(), next_state = update()" << endl;

  mod -> update();

}

WossGroupMob3D::WossGroupMob3D() :
	update_position_timer(this),
	xFieldWidth_(0),
	yFieldWidth_(0),
	zFieldWidth_(0.0),
	alpha_(0),
	speedMean_(0),
	directionMean_(0),
	bound_(REBOUNCE),
	updateTime_(0),
	wossgroup_debug_(0),
	speed_(0),
	maddr(-1),
	start_latitude(0.0),
	start_longitude(0.0),
	start_x(0.0),
	start_y(0.0),
	mtrace_(0),
	mtrace_of_node_(0),
	pitch_(0.0),
	pitchMean_(0.0),
	sigmaPitch_(0.0),
	speedM_(0.0),
	speedS_(0.0),
	eta_(0.0),
	charge_(0.0),
	beta_(0.0),
	direction_(0.0),
	galpha_(0.0),
	count(0),
	zmin_(0.0),
	vx(0.0),
	vy(0.0),
	vz(0.0),
	x_coord(0.0),
	y_coord(0.0),
	z_coord(0.0),
	newx(0),
	newy(0),
	newz(0),
	leader_(0)
{
	bind("xFieldWidth_", &xFieldWidth_);
	bind("yFieldWidth_", &yFieldWidth_);
	bind("zFieldWidth_", &zFieldWidth_);
	bind("alpha_", &alpha_);
	bind("updateTime_", &updateTime_);
	bind("directionMean_", &directionMean_);
	bind("pitchMean_", &pitchMean_);
	bind("sigmaPitch_", &sigmaPitch_);
	bind("zmin_", &zmin_);
	bind("wossgroup_debug_", &wossgroup_debug_);
	bind("speedM_", &speedM_);
	bind("speedS_", &speedS_);
	bind("eta_", &eta_);
	bind("charge_", &charge_);
	bind("leaderCharge_", &leaderCharge_);
	bind("galpha_", &galpha_);

	count = 0;
	update_position_timer.schedule (1.0);
}

WossGroupMob3D::~WossGroupMob3D()
{
}

int WossGroupMob3D::command(int argc, const char*const* argv)
{
	Tcl& tcl = Tcl::instance();
	if(argc == 3)
	{
		if(strcasecmp(argv[1], "bound") == 0)
		{
			if (strcasecmp(argv[2],"SPHERIC")==0)
				bound_ = SPHERIC;
			else
			{
				if (strcasecmp(argv[2],"THOROIDAL")==0)
					bound_ = THOROIDAL;
				else
				{
					if (strcasecmp(argv[2],"HARDWALL")==0)
						bound_ = HARDWALL;
					else
					{
						if (strcasecmp(argv[2],"REBOUNCE")==0)
							bound_ = REBOUNCE;
						else
						{
							fprintf(stderr,"GMPosition::command(%s), unrecognized bound_ type (%s)\n",argv[1],argv[2]);
							exit(1);
						}
					}
				}
			}
			return TCL_OK;
		}
		if(strcasecmp(argv[1], "speedMean") == 0)
		{
			speedMean_ = speed_ = atof(argv[2]);
			return TCL_OK;
		}
		if(strcasecmp(argv[1], "maddr") == 0)
		{
			maddr = atoi(argv[2]);
			return TCL_OK;
		}
		if(strcasecmp(argv[1], "startLatitude") == 0)
		{
			start_latitude = atof(argv[2]);
			return TCL_OK;
		}
		if(strcasecmp(argv[1], "startLongitude") == 0)
		{
			start_longitude = atof(argv[2]);
			return TCL_OK;
		}
		if(strcasecmp(argv[1], "mtrace") == 0)
		{
			mtrace_ = atoi(argv[2]);
			return TCL_OK;
		}
		if(strcasecmp(argv[1], "mTraceOfNode") == 0)
		{
			mtrace_of_node_ = atoi(argv[2]);
			return TCL_OK;
		}
		if(strcasecmp(argv[1], "leader") == 0)
		{
			WossPosition* lead = (WossPosition*)TclObject::lookup(argv[2]);
			leader_ = lead;
			if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::command(" << maddr << "), pointer of the leader is: " << leader_ << endl;
			return TCL_OK;
		}
		if(strcasecmp(argv[1], "gm3dGroupTraceFile") == 0)
		{
			gm3dGroupTraceFile = argv[2];
			return TCL_OK;
		}
	}
	else if(argc == 2) {
	  if(strcasecmp(argv[1], "start") == 0)
		{
			update();
			return TCL_OK;
		}

	}

	return Position::command(argc, argv);
}

double WossGroupMob3D::distance(WossPosition* pos1, WossPosition* pos2)
{
  double xdiff, ydiff, zdiff;
  double dist;

  xdiff = pos1->getX() - pos2->getX();
  ydiff = pos1->getY() - pos2->getY();
  zdiff = pos1->getZ() - pos2->getZ();

  if (bound_==SPHERIC) {

    xdiff = (fabs(xdiff)<((xFieldWidth_)/2))? xdiff : (xFieldWidth_ - fabs(xdiff));
    ydiff = (fabs(ydiff)<((yFieldWidth_)/2))? ydiff : (yFieldWidth_ - fabs(ydiff));
    zdiff = (fabs(zdiff)<((zFieldWidth_)/2))? zdiff : (zFieldWidth_ - fabs(zdiff));

  }

  dist = (sqrt(xdiff*xdiff + ydiff*ydiff + zdiff*zdiff));

  if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::distance(" << maddr << "), distance between leader and follower is: " << dist << endl;

  return dist;

}

double WossGroupMob3D::mirror_posx(double x_coord_node, double x_coord_leader)
{
  if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::mirror_posx(" << maddr << "), calculating mirror position x " << endl;

  double d, dref;

  d = fabs(x_coord_node - x_coord_leader);
  dref = (xFieldWidth_)/2.0;

  if ((d>dref) && (bound_==SPHERIC))
    return ( x_coord_leader - (xFieldWidth_)*(sgn(x_coord_leader - x_coord_node)) );
  return x_coord_leader;

}

double WossGroupMob3D::mirror_posy(double y_coord_node, double y_coord_leader)
{
  if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::mirror_posy(" << maddr << "), calculating mirror position y " << endl;

  double d, dref;

  d = fabs(y_coord_node - y_coord_leader);
  dref = (yFieldWidth_)/2.0;

  if ((d>dref) && (bound_==SPHERIC))
    return ( y_coord_leader - (yFieldWidth_)*(sgn(y_coord_leader - y_coord_node)) );
  return y_coord_leader;

}

double WossGroupMob3D::mirror_posz(double z_coord_node, double z_coord_leader)
{
  if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::mirror_posz(" << maddr << "), calculating mirror position z " << endl;

  double d, dref;

  d = fabs(z_coord_node - z_coord_leader);
  dref = (zFieldWidth_)/2.0;

  if ((d>dref) && (bound_==SPHERIC))
    return ( z_coord_leader - (zFieldWidth_)*(sgn(z_coord_leader - z_coord_node)) );
  return z_coord_leader;

}

double WossGroupMob3D::Gaussian()
{
	double x1, x2, w, y1;
	static double y2;
	static int cache = 0;

	if (wossgroup_debug_) cout << "value of cache(" << maddr << "): " << cache << endl;

	if (cache)
	{
		y1 = y2;
		cache = 0;
	}
	else
	{
		do
		{
			x1 = 2.0 * RNG::defaultrng()->uniform_double() - 1.0;
			x2 = 2.0 * RNG::defaultrng()->uniform_double() - 1.0;
			w = x1 * x1 + x2 * x2;
		} while ( w >= 1.0 );

		w = sqrt( (-2.0 * log( w ) ) / w );
		y1 = x1 * w;
		y2 = x2 * w;
		cache = 1;
	}
	if (wossgroup_debug_) cout << "value of y1(" << maddr << "): " << y1 << endl;
	return(y1);
}

double WossGroupMob3D::getStartX()
{
	start_x = (earth_radius - WossPosition::getDepth()) * sin((90.0 - start_latitude) * M_PI / 180.0) * cos (start_longitude * M_PI / 180.0);
	if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::getStartX(" << maddr << "), values of x0: " << setprecision(12) << start_x << endl;
	return start_x;

}

double WossGroupMob3D::getStartY()
{
	start_y = (earth_radius - WossPosition::getDepth()) * sin((90.0 - start_latitude) * M_PI / 180.0) * sin (start_longitude * M_PI / 180.0);
	if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::getStartY(" << maddr << "), values of y0: " << setprecision(12) << start_y << endl;
	return start_y;

}

void WossGroupMob3D::setLat(double x_coord, double y_coord)
{
	double lati, longi;
	longi = atan2(y_coord,x_coord) * 180.0 / M_PI;
	lati = 90.0 - (asin ( x_coord / ((earth_radius - WossPosition::getDepth()) * cos ( longi * M_PI / 180.0 ))) * 180.0 / M_PI);
	if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::setLatitude(" << maddr << "), new latitude value: " << setprecision(12) << lati << endl;
	WossPosition::setLatitude(lati);
}

void WossGroupMob3D::setLong(double x_coord, double y_coord)
{
	double longi;
	longi = atan2(y_coord,x_coord) * 180.0 / M_PI;
	if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::setLongitude(" << maddr << "), new longitude value: " << setprecision(12) << longi << endl;
	WossPosition::setLongitude(longi);
}

void WossGroupMob3D::update()
{
	if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), updating value. " << endl;

	double pr_pitch_;

		// calculate new sample of speed and direction
		if (wossgroup_debug_)
			printf("GMPosition::Update(%d), Update at (%.3f) old speed %.2f old direction %.2f old pitch %.2f\n", maddr, NOW, speed_, direction_, pitch_);

		if (wossgroup_debug_) printf ("previous x-coord(%d) value: %.6f \n", maddr, WossPosition::getX());
		x_coord = WossPosition::getX() - getStartX();
		if (wossgroup_debug_) printf ("x-coord(%d) value: %.6f \n", maddr, x_coord);

		if (wossgroup_debug_) printf ("previous y-coord(%d) value: %.6f \n", maddr, WossPosition::getY());
		y_coord = WossPosition::getY() - getStartY();
		if (wossgroup_debug_) printf ("y-coord(%d) value: %.6f \n", maddr, y_coord);

		if (wossgroup_debug_) printf ("previous z-coord(%d) value: %.6f \n", maddr, WossPosition::getDepth());
		z_coord = WossPosition::getDepth();
		if (wossgroup_debug_) printf ("z-coord(%d) value: %.6f \n", maddr, z_coord);

	if (speedMean_ == 0) {
		newx = x_coord;
		newy = y_coord;
		newz = z_coord;
	}
	else {
		speed_ = (alpha_*speed_) + (((1.0-alpha_))*speedMean_) + (sqrt(1.0-pow(alpha_,2.0))*Gaussian());
		direction_ = (alpha_*direction_) + (((1.0-alpha_))*directionMean_) + (sqrt(1.0-pow(alpha_,2.0))*Gaussian());
		pitch_ = randlib.Gauss(pitchMean_, sigmaPitch_, 0);

		pr_pitch_ = pitch_;

		if (wossgroup_debug_)
			printf("GMPosition::Update(%d), new speed %.2f new direction %.2f new pitch %.2f\n", maddr, speed_, direction_, pitch_);

		//calculate velocity

		vx = speed_ * cos(direction_) * cos(pitch_);
		if (wossgroup_debug_) cout << "velocity in x(" << maddr << "): " << vx << endl;
		vy = speed_ * sin(direction_) * cos(pitch_);
		if (wossgroup_debug_) cout << "velocity in y(" << maddr << "): " << vy << endl;
		vz = speed_ * sin(pitch_);
		if (wossgroup_debug_) cout << "velocity in z(" << maddr << "): " << vz << endl;

		// calculate new position
		newx = x_coord + (vx * updateTime_);
		if (wossgroup_debug_) cout << "newx(" << maddr << ") value: " << newx << endl;
		newy = y_coord + (vy * updateTime_);
		if (wossgroup_debug_) cout << "newy(" << maddr << ") value: " << newy << endl;
		newz = z_coord + (vz * updateTime_);
		if (wossgroup_debug_) cout << "newz(" << maddr << ") value: " << newz << endl;

	//Add leader Attraction

	if (leader_ != 0) {

	  double cx, cy, cz, dist, gamma;

	  //gamma = direction_;

	  cx = mirror_posx(newx, (leader_->getX() - getStartX()));
	  cy = mirror_posy(newy, (leader_->getY() - getStartY()));
	  cz = mirror_posz(newz, (leader_->getDepth()));

	  dist = distance(leader_,this);
	  if((galpha_ < 0) && (dist < 1)) dist = 1.0;

	  beta_ = ((1.0 - eta_) * beta_) + (eta_ * randlib.Gauss(speedM_,speedS_,0));

	  double rho = updateTime_ * beta_ * charge_ * leaderCharge_ * pow(dist, -galpha_);

	  if ((cx - newx) == 0) direction_ = pi / 2 * sgn (cy - newy);
	  else direction_ = atan ((cy - newy) / (cx - newx));
	  if ((cx - newx) < 0.0) direction_ += (newy - cy) >= 0.0 ? pi : - pi;
	  if (((cx - newx) == 0) && ((cy - newy) == 0) && ((cz - newz) == 0)) pitch_ = pitch_ / pi;

	  if (wossgroup_debug_) cout << "Value of rho: " << rho << endl;
	  if (wossgroup_debug_) cout << "Value of direction: " << gamma << endl;

	  if (pr_pitch_ == pitch_) {
	    newx += rho * cos(direction_);
	    if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), new x-coord value (after leader attraction): " << setprecision(12) << newx << endl;
	    newy += rho * sin(direction_);
	    if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), new y-coord value (after leader attraction): " << setprecision(12) << newy << endl;
	    }
	  else {
	    newx += rho * cos(direction_) * cos(pitch_);
	    if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), new x-coord value (after leader attraction): " << setprecision(12) << newx << endl;

	    newy += rho * sin(direction_) * cos(pitch_);
	    if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), new x-coord value (after leader attraction): " << setprecision(12) << newy << endl;

	    newz += rho * sin(pitch_);
	    if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), new z-coord value (after leader attraction): " << setprecision(12) << newz << endl;
	    }

	  }

	// verify whether the new position has to be re-computed in order
	// to maintain node position within the simulation

	if ((newy > yFieldWidth_) || ( newy < 0))
	{
		switch (bound_)
		{
		case SPHERIC:
			y_coord -= yFieldWidth_*(sgn(newy));
			newy -= yFieldWidth_*(sgn(newy));
			break;
		case THOROIDAL:
			x_coord = (xFieldWidth_/2) + x_coord - newx;
			y_coord = (yFieldWidth_/2) + y_coord - newy;
			z_coord = (zFieldWidth_/2) + z_coord - newz;

			newx = xFieldWidth_/2;
			newy = yFieldWidth_/2;
			newz = zFieldWidth_/2;

			break;
		case HARDWALL:
			newy = newy<0?0:yFieldWidth_;
			break;
		case REBOUNCE:
			if (newy>yFieldWidth_)
			{
				newy = 2*yFieldWidth_ - newy;
				y_coord = 2*yFieldWidth_ - y_coord;
			}else{
				newy = 0 - newy;
				y_coord = 0 - y_coord;
			}
			direction_ *= -1;
			break;
		}
	}

	if ((newx > xFieldWidth_) || ( newx < 0))
	{
		switch (bound_)
		{
		case SPHERIC:
			x_coord -= xFieldWidth_*(sgn(newx));
			newx -= xFieldWidth_*(sgn(newx));
			break;
		case THOROIDAL:
			x_coord = (xFieldWidth_/2) + x_coord - newx;
			y_coord = (yFieldWidth_/2) + y_coord - newy;
			z_coord = (zFieldWidth_/2) + z_coord - newz;

			newx = xFieldWidth_/2;
			newy = yFieldWidth_/2;
			newz = zFieldWidth_/2;

			break;
		case HARDWALL:
			newx = newx<0?0:xFieldWidth_;
			break;
		case REBOUNCE:
			if (newx > xFieldWidth_)
			{
				newx = 2*xFieldWidth_ - newx;
				x_coord = 2*xFieldWidth_ - x_coord;
			}else{
				newx = 0 - newx;
				x_coord = 0 - x_coord;
			}
			if (newy==y_coord)
			{
				if (newx>x_coord)
					direction_ = 0;
				else
					direction_ = pi;
			}else{
				if (newy>y_coord)
					direction_ = pi - direction_;
				else
					direction_ = -pi - direction_;
			}
			break;
		}
	}

	if ((newz > zFieldWidth_) || ( newz < zmin_))
	{
		switch (bound_)
		{
		case SPHERIC:
			z_coord -= zFieldWidth_*(sgn(newz));
			newz -= zFieldWidth_*(sgn(newz));
			break;
		case THOROIDAL:
			x_coord = (xFieldWidth_/2) + x_coord - newx;
			y_coord = (yFieldWidth_/2) + y_coord - newy;
			z_coord = (zFieldWidth_/2) + z_coord - newz;

			newx = xFieldWidth_/2;
			newy = yFieldWidth_/2;
			newz = zFieldWidth_/2;

			break;
		case HARDWALL:
			newz = newz<0?0:zFieldWidth_;
			break;
		case REBOUNCE:
			if (newz > zFieldWidth_)
			{
				newz = 2*zFieldWidth_ - newz;
				z_coord = 2*zFieldWidth_ - z_coord;
			}else{
				newz = 2*zmin_ - newz;
				z_coord = 2*zmin_ - z_coord;
			}
			break;
		}
	}

	if ((newx < 0.0)||(newx > xFieldWidth_)||(newy < 0.0)||(newy > yFieldWidth_)||(newz < zmin_)||(newz > zFieldWidth_)) {
	  cout << NOW << " WossGroupMob3D::update(" << maddr << "), error in postion! Abort!! " << endl;
	  update();
	}

	if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), new x-coord value (after wrapping): " << setprecision(12) << newx << endl;
	if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), new y-coord value (after wrapping): " << setprecision(12) << newy << endl;
	if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), new z-coord value (after wrapping): " << setprecision(12) << newz << endl;

	x_coord = newx + getStartX();
	Position::setX(x_coord);
	y_coord = newy + getStartY();
	Position::setY(y_coord);
	z_coord = newz;
	Position::setZ(z_coord);
	if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), new cartesian x-coord value: " << setprecision(12) << x_coord << endl;
	if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), new cartesian y-coord value: " << setprecision(12) << y_coord << endl;
	if (wossgroup_debug_) cout << NOW << " WossGroupMob3D::update(" << maddr << "), new depth value: " << setprecision(12) << z_coord << endl;

	directionMean_ = direction_;
      }

	setLat(x_coord,y_coord);
	setLong(x_coord,y_coord);
	WossPosition::setDepth(z_coord);

	if (wossgroup_debug_)
		printf(" WossGroupMob3D::Update(%d), now %f, updateTime %f\n", maddr,NOW, updateTime_);

	if (mtrace_) {
	  if (maddr == mtrace_of_node_) {
	    ofstream saveInFile(gm3dGroupTraceFile.c_str(), ios::app);
	    saveInFile << NOW << "\t" << setprecision(12) << newx << "\t" << setprecision(12) << newy << "\t" << WossPosition::getDepth() << endl;
	    saveInFile.close();
	  }
	}

	update_position_timer.schedule (updateTime_);
}

redpajama_set_name: RedPajamaGithub


text:
package util
package concurrent

import akka.actor._
import akka.pattern.ask
import akka.routing.RoundRobinRouter
import akka.util.Duration

import play.api.libs.concurrent._

import java.util.concurrent.TimeoutException
//import scala.collection.immutable.Vector

class BackgroundProcessorActor extends Actor {
  def receive = {
    case processor: BackgroundProcess[_] => sender ! processor.run()
  }
}

case class SexyTimeoutException(timeout: Duration) extends Exception("Command timeout after %s seconds".format(timeout.toSeconds.toString)) {
  override def toString(): String = {
    this.getMessage()
  }
}
object BackgroundProcessor {
  import play.api.Play.current

  lazy val ref = {
    val routees = (0 until 128).map { _ =>
      Akka.system.actorOf(Props[BackgroundProcessorActor])
    }
    Akka.system.actorOf(
      Props[BackgroundProcessorActor].withRouter(RoundRobinRouter(routees))
    )
  }

  type SendType[T] = Tuple2[Option[Throwable], Option[T]]
  def send[PROC_RES,RESPONSE](cmd: BackgroundProcess[PROC_RES])(result: SendType[PROC_RES] => RESPONSE)(implicit mf: Manifest[PROC_RES]) = {
    ask(ref, cmd)(cmd.timeout).mapTo[PROC_RES].asPromise.extend1 {
      case Redeemed(v) => result(Tuple2(None, Some(v)))
      case Thrown(e) => e match {
        case t: TimeoutException =>
          result(Tuple2(Some(SexyTimeoutException(cmd.timeout)), None))
        case _ =>
          result(Tuple2(Some(e), None))
      }
    }
  }
}


text:
<?php

/**
 *  ====================
 *
 * Supported Option Types:
 *      text                    - standard text input (display size 20 chars)
 *      midtext                 - same as text (display size 40 chars)
 *      longtext                - same as text (display size 80 chars)
 *      email                   - same as text (display size 40 chars)
 *      textarea                - same as text (display size 4 rows, 60 cols)
 *      codeblock               - intended for markup and embedded javascript for inclusion elsewhere
 *      natural                 - positive number only, leading 0 allowed (display size 20 chars)
 *      integer                 - integer, positive or negative, no decimals (display size 20 chars)
 *      decimal                 - positive or negative number, may contain decimal point (display size 20 chars)
 *      checkbox                - true or false option type
 *      multicheck              - option grouping allows multiple options for selection (horizontal or vertical display)
 *      select                  - standard select option with pre-defined choices
 *      radio                   - option grouping allowing one option for selection (horizontal or vertical display)
 *      range                   - range slider with min, max, and step values
 *      single_select_page      - select that lists all available WordPress pages with a 'None' choice as well
 *      single_select_country   - select allowing a single choice of all Jigoshop defined countries
 *      multi_select_countries  - multicheck allowing multiple choices of all Jigoshop defined countries
 *      user_defined            - a user installed option type, must provide display and option update callbacks
 *
 *  ====================
 *
 *  The Options array uses Tabs for display and each tab begins with a 'tab' option type
 *  Each Tab Heading may be optionally divided into sections defined by a 'title' option type
 *  A Payment Gateway for example, would install itself into a 'tab' and provide a section 'title' with options
 *  List each option sequentially for display under each 'title' or 'tab' option type
 *
 *  Each Option may have any or all of the following items: (for an option, 'id' is MANDATORY and should be unique)
		'tab'           => '',                      - calculated based on position in array
		'section'       => '',                      - calculated based on position in array
		'id'            => null,                    - required
		'type'          => '',                      - required
		'name'          => __( '', 'jigoshop' ),    - used for Option title in Admin display
		'desc'          => __( '', 'jigoshop' ),    - option descriptive information appears under the option in Admin
		'tip'           => __( '', 'jigoshop' ),    - a pop-up tool tip providing help information
		'std'           => '',                      - required, default value for the option
		'choices'       => array(),                 - for selects, radios, etc.
		'class'         => '',                      - any special CSS classes to assign to the options display
		'display'       => null,        - call back function for 'user_defined' - array( $this, 'function_name' )
		'update'        => null,        - call back function for 'user_defined' - array( $this, 'function_name' )
		'extra'         => null,                    - for display and verification - array( 'horizontal' )
 *
 *  ====================
 *
 * Example checkbox option definition:              // Choices should be defined with 'yes' and 'no'
		self::$default_options[] = array(
			'name'		=> __('Jigoshop Checkbox Testing','jigoshop'),
			'desc' 		=> '',
			'tip' 		=> '',
			'id' 		=> 'jigoshop_checkbox_test',
			'type' 		=> 'checkbox',
			'std' 		=> 'yes',
			'choices'	=> array(
				'no'			=> __('No', 'jigoshop'),
				'yes'			=> __('Yes', 'jigoshop')
			)
		);
 *
 *  ====================
 *
 * Example range option definition:
		self::$default_options[] = array(
			'name'		=> __('Jigoshop Range Testing','jigoshop'),
			'desc' 		=> '',
			'tip' 		=> '',
			'id' 		=> 'jigoshop_range_test',
			'type' 		=> 'range',
			'std' 		=> 100,
			'extra'		=> array(
				'min'			=> 50,
				'max'			=> 300,
				'step'			=> 5
			)
		);
 *
 *  ====================
 *
 * Example vertical multicheck option definition:
		self::$default_options[] = array(
			'name'		=> __('Display Sidebar on these pages:','jigoshop'),
			'desc' 		=> '',
			'tip' 		=> '',
			'id' 		=> 'jigoshop_multicheck_test',
			'type' 		=> 'multicheck',
			"std"		=> array('shop' => true,'category' => false,'single' => true,'cart' => false,'checkout' => true,'account' => true),
			"choices"	=> array(
				"shop"			=> "Shop",
				"category"		=> "Product Categories",
				"single"		=> "Single Products",
				"cart"			=> "Cart",
				"checkout"		=> "Checkout",
				"account"		=> "Account Pages",
			),
			'extra'		=> array( 'vertical' )
		);
 *
 */

class Jigoshop_Options implements Jigoshop_Options_Interface {
	private static $default_options;
	private static $current_options;
	private $bad_extensions = array();

	/**
	 * Instantiates a new Options object
	 *
	 * @return Jigoshop_Options
	 * @since  1.3
	 */
	public function __construct(){
		self::$current_options = array();

		$options = get_option(JIGOSHOP_OPTIONS);
		if(is_array($options)){
			self::$current_options = $options;
		}
	}

	/**
	 * Updates the database with the current options
	 *
	 * At various times during a page load, options can be set, or added.
	 * We will flush them all out on the WordPress 'shutdown' action hook.
	 *
	 * If options don't exist (fresh install), they are created with default 'true' for WP autoload
	 *
	 * @since	1.3
	 */
	public function update_options(){
		update_option(JIGOSHOP_OPTIONS, self::$current_options);
	}

	/**
	 * Adds a named option
	 * Will do nothing if option already exists to match WordPress behaviour
	 * Use 'set' to actually set an existing option
	 *
	 * @param   string  the name of the option to add
	 * @param   mixed  the value to set if the option doesn't exist
	 * @since  1.12
	 */
	public function add($name, $value)
	{
		$this->get_current_options();
		if(!isset(self::$current_options[$name])){
			self::$current_options[$name] = $value;
			if(!has_action('shutdown', array($this, 'update_options'))){
				add_action('shutdown', array($this, 'update_options'));
			}
		}
	}

	/**
	 * Adds a named option to our collection
	 *
	 * Will do nothing if option already exists to match WordPress behaviour
	 * Use 'set' to actually set an existing option
	 *
	 * @param string $name the name of the option to add
	 * @param mixed	$value the value to set if the option doesn't exist
	 * @since	1.3
	 */
	public function add_option($name, $value){
		$this->add($name, $value);
	}

	/**
	 * Returns a named Jigoshop option
	 *
	 * @param   string  the name of the option to retrieve
	 * @param   mixed  the value to return if the option doesn't exist
	 * @return  mixed  the value of the option, null if no $default and option doesn't exist
	 * @since  1.12
	 */
	public function get($name, $default = null)
	{
		if(isset(self::$current_options[$name])){
			return apply_filters('jigoshop_get_option', self::$current_options[$name], $name, $default);
		} elseif(($old_option = get_option($name)) !== false){
			return apply_filters('jigoshop_get_option', $old_option, $name, $default);
		} elseif(isset($default)){
			return apply_filters('jigoshop_get_option', $default, $name, $default);
		} else {
			return null;
		}
	}

	/**
	 * Returns a named Jigoshop option
	 *
	 * @param string $name the name of the option to retrieve
	 * @param mixed $default the value to return if the option doesn't exist
	 * @return mixed the value of the option, null if no $default and doesn't exist
	 * @since  1.3
	 */
	public function get_option($name, $default = null){
		return $this->get($name, $default);
	}

	/**
	 * Sets a named Jigoshop option
	 *
	 * @param   string  the name of the option to set
	 * @param  mixed  the value to set
	 * @since  1.12
	 */
	public function set($name, $value)
	{
		$this->get_current_options();

		if(isset($name)){
			self::$current_options[$name] = $value;
			if(!has_action('shutdown', array($this, 'update_options'))){
				add_action('shutdown', array($this, 'update_options'));
			}
		}
	}

	/**
	 * Sets a named Jigoshop option
	 *
	 * @param string $name the name of the option to set
	 * @param	mixed	$value the value to set
	 * @since	1.3
	 */
	public function set_option($name, $value){
		$this->set($name, $value);
	}

	/**
	 * Deletes a named Jigoshop option
	 *
	 * @param   string  the name of the option to delete
	 * @return  bool  true for successful completion if option found, false otherwise
	 * @since  1.12
	 */
	public function delete($name)
	{
		$this->get_current_options();
		if(isset($name)){
			unset(self::$current_options[$name]);
			if(!has_action('shutdown', array($this, 'update_options'))){
				add_action('shutdown', array($this, 'update_options'));
			}

			return true;
		}

		return false;
	}

	/**
	 * Deletes a named Jigoshop option
	 *
	 * @param string $name the name of the option to delete
	 * @return bool true for successful completion if option found, false otherwise
	 * @since	1.3
	 */
	public function delete_option($name){
		return $this->delete($name);
	}

	/**
	 * Determines whether an Option exists
	 *
	 * @param $name string the name of option to check for existence
	 * @return  bool  true for successful completion if option found, false otherwise
	 * @since  1.12
	 */
	public function exists($name)
	{
		$this->get_current_options();
		if(isset(self::$current_options[$name])){
			return true;
		}

		return false;
	}

	/**
	 * Determines whether an Option exists
	 *
	 * @param string $name Option name.
	 * @return bool true for successful completion if option found, false otherwise
	 * @since 1.3
	 */
	public function exists_option($name){
		return $this->exists($name);
	}

	/**
	 * Install additional Tab's to Jigoshop Options
	 * Extensions would use this to add a new Tab for their own options
	 *
	 * NOTE: External code should not call this function any earlier than the WordPress 'init'
	 *       action hook in order for Jigoshop language translations to function properly
	 *
	 * @param	string $tab The name of the Tab ('tab'), eg. 'My Extension'
	 * @param	array	$options The array of options to install onto this tab
	 *
	 * @since	1.3
	 */
	public function install_external_options_tab($tab, $options){
		// only proceed with function if we have options to add
		if(empty($options)){
			return;
		}
		if(empty($tab)){
			return;
		}

		$our_options = $this->get_default_options();
		$our_options[] = array('type' => 'tab', 'name' => $tab);

		if(!empty($options)){
			foreach($options as $option){
				if(isset($option['id']) && !$this->exists($option['id'])){
					$this->add($option['id'], isset($option['std']) ? $option['std'] : '');
				}
				$our_options[] = $option;
			}
		}

		self::$default_options = $our_options;
	}

	/**
	 * Install additional default options for parsing onto a specific Tab
	 * Shipping methods, Payment gateways and Extensions would use this
	 *
	 * NOTE: External code should not call this function any earlier than the WordPress 'init'
	 *       action hook in order for Jigoshop language translations to function properly
	 *
	 * @param	string $tab The name of the Tab ('tab') to install onto
	 * @param	array	$options The array of options to install at the end of the current options on this Tab
	 *
	 * @since	1.3
	 */
	public function install_external_options_onto_tab($tab, $options){
		// only proceed with function if we have options to add
		if(empty($options)){
			return;
		}
		if(empty($tab)){
			return;
		}

		$our_options = $this->get_default_options();
		$first_index = -1;
		$second_index = -1;
		foreach($our_options as $index => $option){
			if($option['type'] <> 'tab'){
				continue;
			}
			if($option['name'] == $tab){
				$first_index = $index;
				continue;
			}
			if($first_index >= 0){
				$second_index = $index;
				break;
			}
		}

		if($second_index < 0){
			$second_index = count($our_options);
		}

		/*** get the start of the array ***/
		$start = array_slice($our_options, 0, $second_index);
		/*** get the end of the array ***/
		$end = array_slice($our_options, $second_index);
		/*** add the new elements to the array ***/
		foreach($options as $option){
			if(isset($option['id']) && !$this->exists($option['id'])){
				$this->add($option['id'], isset($option['std']) ? $option['std'] : '');
			}
			$start[] = $option;
		}

		/*** glue them back together ***/
		self::$default_options = array_merge($start, $end);
	}

	/**
	 * Install additional default options for parsing after a specific option ID
	 * Extensions would use this
	 *
	 * NOTE: External code should not call this function any earlier than the WordPress 'init'
	 *       action hook in order for Jigoshop language translations to function properly
	 *
	 * @param	string $insert_after_id	The name of the ID  to install -after-
	 * @param	array	$options The array of options to install
	 * @since	1.3
	 */
	public function install_external_options_after_id($insert_after_id, $options){
		// only proceed with function if we have options to add
		if(empty($options)){
			return;
		}
		if(empty($insert_after_id)){
			return;
		}

		$our_options = $this->get_default_options();
		$first_index = -1;
		foreach($our_options as $index => $option){
			if(!isset($option['id']) || $option['id'] <> $insert_after_id){
				continue;
			}
			$first_index = $index;
			break;
		}

		/*** get the start of the array ***/
		$start = array_slice($our_options, 0, $first_index + 1);
		/*** get the end of the array ***/
		$end = array_slice($our_options, $first_index + 1);
		/*** add the new elements to the array ***/
		foreach($options as $option){
			if(isset($option['id']) && !$this->exists($option['id'])){
				$this->add($option['id'], isset($option['std']) ? $option['std'] : '');
			}
			$start[] = $option;
		}

		/*** glue them back together ***/
		self::$default_options = array_merge($start, $end);
	}

	/**
	 * Return the Jigoshop current options
	 *
	 * @return array the entire current options array is returned
	 * @since	1.3
	 */
	public function get_current_options(){
		if(empty(self::$current_options)){
			if(empty(self::$default_options)){
				$this->set_default_options();
			}
			$this->set_current_options(self::$default_options);
		}

		return self::$current_options;
	}

	/**
	 * Sets the entire Jigoshop current options
	 *
	 * @param array $options an array containing all the current Jigoshop option => value pairs to use
	 * @since 1.3
	 */
	private function set_current_options($options){
		self::$current_options = $options;
		if(!has_action('shutdown', array($this, 'update_options'))){
			add_action('shutdown', array($this, 'update_options'));
		}
	}

	/**
	 * Return the Jigoshop default options
	 *
	 * @return  array  the entire default options array is returned
	 * @since  1.3
	 */
	public function get_default_options(){
		if(empty(self::$default_options)){
			$this->set_default_options();
		}

		return self::$default_options;
	}

	public function generate_defaults_emails(){
		return '<button type="button" onClick="parent.location=\'admin.php?page=jigoshop_settings&install_emails=1\'">'.__('Generate Defaults', 'jigoshop').'</button>';
	}

	/**
	 * Sets the Jigoshop default options
	 *
	 * This will create the default options array. Extensions may install options of the same format into this.
	 *
	 * @param   none
	 * @return  Void
	 *
	 * @since	1.3
	 *
	 */
	private function set_default_options(){
		$symbols = jigoshop::currency_symbols();
		$countries = jigoshop::currency_countries();

		$currencies = array();
		foreach($countries as $key => $country){
			$currencies[$key] = $country.' ('.$symbols[$key].')';
		}
		$currencies = apply_filters('jigoshop_currencies', $currencies);

		$cSymbol = '';
		if(function_exists('get_jigoshop_currency_symbol')){
			$cSymbol = get_jigoshop_currency_symbol();
		}

		$cCode = $this->get('jigoshop_currency') ? $this->get('jigoshop_currency') : 'GBP';
		$cSep = $this->get('jigoshop_price_decimal_sep') ? $this->get('jigoshop_price_decimal_sep') : '.';

		self::$default_options = array(
			// Shop tab
			array('type' => 'tab', 'name' => __('Shop', 'jigoshop')),
			array('name' => __('Shop Options', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Base Country/Region', 'jigoshop'),
				'desc' => '',
				'tip' => __('This is the base country for your business. Tax rates will be based on this country.', 'jigoshop'),
				'id' => 'jigoshop_default_country',
				'type' => 'single_select_country',
			),
			array(
				'name' => __('Default Country/Region for customer', 'jigoshop'),
				'desc' => '',
				'tip' => __('This is the country for your clients with new accounts.', 'jigoshop'),
				'id' => 'jigoshop_default_country_for_customer',
				'std' => $this->get('jigoshop_default_country'),
				'type' => 'single_select_country',
				'options' => array(
					'add_empty' => true,
				),
			),
			array(
				'name' => __('Currency', 'jigoshop'),
				'desc' => '',
				'tip' => __('This controls what currency the prices are listed with in the Catalog, and which currency PayPal, and other gateways, will take payments in.', 'jigoshop'),
				'id' => 'jigoshop_currency',
				'type' => 'select',
				'choices' => $currencies,
			),
			array(
				'name' => __('Allowed Countries', 'jigoshop'),
				'desc' => '',
				'tip' => __('These are countries that you are willing to ship to.', 'jigoshop'),
				'id' => 'jigoshop_allowed_countries',
				'type' => 'select',
				'choices' => array(
					'all' => __('All Countries', 'jigoshop'),
					'specific' => __('Specific Countries', 'jigoshop'),
				),
			),
			array(
				'name' => __('Specific Countries', 'jigoshop'),
				'desc' => '',
				'tip' => '',
				'id' => 'jigoshop_specific_allowed_countries',
				'type' => 'multi_select_countries',
			),
			array(
				'name' => __('Demo store', 'jigoshop'),
				'desc' => '',
				'tip' => __('Enable this option to show a banner at the top of every page stating this shop is currently in testing mode.', 'jigoshop'),
				'id' => 'jigoshop_demo_store',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array('name' => __('Invoicing', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Company Name', 'jigoshop'),
				'desc' => '',
				'tip' => __('Setting your company name will enable us to print it out on your invoice emails. Leave blank to disable.', 'jigoshop'),
				'id' => 'jigoshop_company_name',
				'type' => 'text',
			),
			array(
				'name' => __('Tax Registration Number', 'jigoshop'),
				'desc' => __('Add your tax registration label before the registration number and it will be printed as well. eg. VAT Number: 88888888', 'jigoshop'),
				'tip' => __('Setting your tax number will enable us to print it out on your invoice emails. Leave blank to disable.', 'jigoshop'),
				'id' => 'jigoshop_tax_number',
				'type' => 'text',
			),
			array(
				'name' => __('Address Line1', 'jigoshop'),
				'desc' => '',
				'tip' => __('Setting your address will enable us to print it out on your invoice emails. Leave blank to disable.', 'jigoshop'),
				'id' => 'jigoshop_address_1',
				'type' => 'longtext',
			),
			array(
				'name' => __('Address Line2', 'jigoshop'),
				'desc' => '',
				'tip' => __('If address line1 is not set, address line2 will not display even if you put a value in it. Setting your address will enable us to print it out on your invoice emails. Leave blank to disable.', 'jigoshop'),
				'id' => 'jigoshop_address_2',
				'type' => 'longtext',
			),
			array(
				'name' => __('Company Phone', 'jigoshop'),
				'desc' => '',
				'tip' => __('Setting your company phone number will enable us to print it out on your invoice emails. Leave blank to disable.', 'jigoshop'),
				'id' => 'jigoshop_company_phone',
				'type' => 'text',
			),
			array(
				'name' => __('Company Email', 'jigoshop'),
				'desc' => '',
				'tip' => __('Setting your company email will enable us to print it out on your invoice emails. Leave blank to disable.', 'jigoshop'),
				'id' => 'jigoshop_company_email',
				'type' => 'email',
			),
			array('name' => __('Permalinks', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Prepend shop categories and tags with base page', 'jigoshop'),
				'desc' => '',
				'tip' => __('This will only apply to tags & categories.
Enabled: http://yoursite.com / product_category / YourCategory
Disabled: http://yoursite.com / base_page / product_category / YourCategory', 'jigoshop'),
				'id' => 'jigoshop_prepend_shop_page_to_urls',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Prepend product permalinks with shop base page', 'jigoshop'),
				'desc' => '',
				'tip' => '',
				'id' => 'jigoshop_prepend_shop_page_to_product',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Prepend product permalinks with product category', 'jigoshop'),
				'desc' => '',
				'tip' => '',
				'id' => 'jigoshop_prepend_category_to_product',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Product category slug', 'jigoshop'),
				'desc' => '',
				'tip' => __('Slug displayed in product category URLs. Leave blank to use default "product-category"', 'jigoshop'),
				'id' => 'jigoshop_product_category_slug',
				'type' => 'text',
			),
			array(
				'name' => __('Product tag slug', 'jigoshop'),
				'desc' => '',
				'tip' => __('Slug displayed in product tag URLs. Leave blank to use default "product-tag"', 'jigoshop'),
				'id' => 'jigoshop_product_tag_slug',
				'type' => 'text',
			),
			// General tab
			array('type' => 'tab', 'name' => __('General', 'jigoshop')),
			array('name' => __('General Options', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Cart shows "Return to Shop" button', 'jigoshop'),
				'desc' => '',
				'tip' => __('Enabling this setting will display a "Return to Shop" button on the Cart page along with the "Continue to Checkout" button.', 'jigoshop'),
				'id' => 'jigoshop_cart_shows_shop_button',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('After adding product to cart', 'jigoshop'),
				'desc' => '',
				'tip' => __('Define what should happen when a user clicks on "Add to Cart" on any product or page.', 'jigoshop'),
				'id' => 'jigoshop_redirect_add_to_cart',
				'type' => 'radio',
				'extra' => array('vertical'),
				'choices' => array(
					'same_page' => __('Stay on the same page', 'jigoshop'),
					'to_checkout' => __('Redirect to Checkout', 'jigoshop'),
					'to_cart' => __('Redirect to Cart', 'jigoshop'),
				),
			),
			array(
				'name' => __('Cart status after login', 'jigoshop'),
				'desc' => __('Current cart always will be loaded if customer logs in checkout page.', 'jigoshop'),
				'tip' => __("Define what should happen with shopping cart if customer added items to shopping cart as guest and than he logs in to your shop.", 'jigoshop'),
				'id' => 'jigoshop_cart_after_login',
				'type' => 'select',
				'choices' => array(
					'load_saved' => __('Load saved cart', 'jigoshop'),
					'load_current' => __('Load current cart', 'jigoshop'),
					'merge' => __('Merge saved and current carts', 'jigoshop'),
				)
			),
			array(
				'name' => __('Reset pending Orders', 'jigoshop'),
				'desc' => __("Change all 'Pending' Orders older than one month to 'On Hold'", 'jigoshop'),
				'tip' => __("For customers that have not completed the Checkout process or haven't paid for an Order after a period of time, this will reset the Order to On Hold allowing the Shop owner to take action.  WARNING: For the first use on an existing Shop this setting can generate a lot of email!", 'jigoshop'),
				'id' => 'jigoshop_reset_pending_orders',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Complete processing Orders', 'jigoshop'),
				'desc' => __("Change all 'Processing' Orders older than one month to 'Completed'", 'jigoshop'),
				'tip' => __("For orders that have been completed but the status is still set to 'processing'.  This will move them to a 'completed' status without sending an email out to all the customers.", 'jigoshop'),
				'id' => 'jigoshop_complete_processing_orders',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Enforce login for downloads', 'jigoshop'),
				'desc' => '',
				'tip' => __('If a guest purchases a download, the guest can still download a link without logging in. We recommend disabling guest purchases if you enable this option.', 'jigoshop'),
				'id' => 'jigoshop_downloads_require_login',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Disable Jigoshop frontend.css', 'jigoshop'),
				'desc' => __('(The next option below will have no effect if this one is disabled)', 'jigoshop'),
				'tip' => __('Useful if you want to disable Jigoshop styles and theme it yourself via your theme.', 'jigoshop'),
				'id' => 'jigoshop_disable_css',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Include extra theme styles with Jigoshop frontend.css', 'jigoshop'),
				'desc' => '',
				'tip' => __("With this option on, Jigoshop's default frontend.css will still load, and any extra bits found in 'theme/jigoshop/style.css' for over-rides will also be loaded.", 'jigoshop'),
				'id' => 'jigoshop_frontend_with_theme_css',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Disable bundled Lightbox', 'jigoshop'),
				'desc' => __('Product galleries and images as well as the Add Review form will open in a lightbox.', 'jigoshop'),
				'tip' => __('Useful if your theme or other plugin already loads our Lightbox script and css (prettyPhoto), or you want to use a different one.', 'jigoshop'),
				'id' => 'jigoshop_disable_fancybox',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array('name' => __('Jigoshop messages', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Message disappear time', 'jigoshop'),
				'desc' => __('How long message is displayed before disappearing (in ms). Set to 0 to keep it displayed.', 'jigoshop'),
				'id' => 'jigoshop_message_disappear_time',
				'type' => 'natural',
			),
			array(
				'name' => __('Error disappear time', 'jigoshop'),
				'desc' => __('How long error is displayed before disappearing (in ms). Set to 0 to keep it displayed.', 'jigoshop'),
				'id' => 'jigoshop_error_disappear_time',
				'type' => 'natural',
			),
			array('name' => __('Email Details', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Jigoshop email address', 'jigoshop'),
				'desc' => '',
				'tip' => __('The email address used to send all Jigoshop related emails, such as order confirmations and notices.  This may be different than your Company email address on "Shop Tab -> Invoicing".', 'jigoshop'),
				'id' => 'jigoshop_email',
				'type' => 'email',
			),
			array(
				'name' => __('Email from name', 'jigoshop'),
				'desc' => '',
				'tip' => __('', 'jigoshop'),
				'id' => 'jigoshop_email_from_name',
				'type' => 'text',
			),
			array(
				'name' => __('Email footer', 'jigoshop'),
				'desc' => '',
				'tip' => __('The email footer used in all jigoshop emails.', 'jigoshop'),
				'id' => 'jigoshop_email_footer',
				'type' => 'textarea',
			),
			array(
				'name' => __('Generate default emails', 'jigoshop'),
				'desc' => '',
				'tip' => '',
				'id' => 'jigoshop_email_generete_defaults',
				'type' => 'user_defined',
				'display' => array($this, 'generate_defaults_emails'),
			),
			array('name' => __('Checkout page', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Validate postal/zip codes', 'jigoshop'),
				'desc' => '',
				'tip' => __('Enabling this setting will force proper postcodes to be entered by a customer for a country.', 'jigoshop'),
				'id' => 'jigoshop_enable_postcode_validating',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Show verify information message', 'jigoshop'),
				'desc' => '',
				'tip' => __('Enabling this setting will display a message at the bottom of the Checkout asking customers to verify all their informatioin is correctly entered before placing their Order.  This is useful in particular for Countries that have states to ensure the correct shipping state is selected.', 'jigoshop'),
				'id' => 'jigoshop_verify_checkout_info_message',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Show EU VAT reduction message', 'jigoshop'),
				'desc' => __('This will only apply to EU Union based Shops.', 'jigoshop'),
				'tip' => __('Enabling this setting will display a message at the bottom of the Checkout informing the customer that EU VAT will not be removed until the Order is placed and only if they have provided a valid EU VAT Number.', 'jigoshop'),
				'id' => 'jigoshop_eu_vat_reduction_message',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Allow guest purchases', 'jigoshop'),
				'desc' => '',
				'tip' => __('Enabling this setting will allow users to checkout without registering or signing up. Otherwise, users must be signed in or must sign up to checkout.', 'jigoshop'),
				'id' => 'jigoshop_enable_guest_checkout',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Show login form', 'jigoshop'),
				'desc' => '',
				'id' => 'jigoshop_enable_guest_login',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Allow registration', 'jigoshop'),
				'desc' => '',
				'id' => 'jigoshop_enable_signup_form',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Force SSL on checkout', 'jigoshop'),
				'desc' => '',
				'tip' => __('This will load your checkout page with https://. An SSL certificate is required if you choose yes. Contact your hosting provider for more information on SSL Certs.', 'jigoshop'),
				'id' => 'jigoshop_force_ssl_checkout',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array('name' => __('Integration', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('ShareThis Publisher ID', 'jigoshop'),
				'desc' => __("Enter your ShareThis publisher ID to show ShareThis on product pages.", 'jigoshop'),
				'tip' => __('ShareThis is a small social sharing widget for posting links on popular sites such as Twitter and Facebook.', 'jigoshop'),
				'id' => 'jigoshop_sharethis',
				'type' => 'text',
			),
			array(
				'name' => __('Google Analytics ID', 'jigoshop'),
				'desc' => __('Log into your Google Analytics account to find your ID. e.g. UA-XXXXXXX-X', 'jigoshop'),
				'id' => 'jigoshop_ga_id',
				'type' => 'text',
			),
			array(
				'name' => __('Enable eCommerce Tracking', 'jigoshop'),
				'tip' => __('Add Google Analytics eCommerce tracking code upon successful orders', 'jigoshop'),
				'desc' => __('Learn how to enable eCommerce tracking for your Google Analytics account.', 'jigoshop'),
				'id' => 'jigoshop_ga_ecommerce_tracking_enabled',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			// Pages tab
			array('type' => 'tab', 'name' => __('Pages', 'jigoshop')),
			array('name' => __('Page configurations', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Cart Page', 'jigoshop'),
				'desc' => __('Shortcode to place on page: [jigoshop_cart]', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_cart_page_id',
				'type' => 'single_select_page',
			),
			array(
				'name' => __('Checkout Page', 'jigoshop'),
				'desc' => __('Shortcode to place on page: [jigoshop_checkout]', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_checkout_page_id',
				'type' => 'single_select_page',
			),
			array(
				'name' => __('Pay Page', 'jigoshop'),
				'desc' => __('Shortcode to place on page: [jigoshop_pay]
Default parent page: Checkout', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_pay_page_id',
				'type' => 'single_select_page',
			),
			array(
				'name' => __('Thanks Page', 'jigoshop'),
				'desc' => __('Shortcode to place on page: [jigoshop_thankyou]
Default parent page: Checkout', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_thanks_page_id',
				'type' => 'single_select_page',
			),
			array(
				'name' => __('My Account Page', 'jigoshop'),
				'desc' => __('Shortcode to place on page: [jigoshop_my_account]', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_myaccount_page_id',
				'type' => 'single_select_page',
			),
			array(
				'name' => __('Edit Address Page', 'jigoshop'),
				'desc' => __('Shortcode to place on page: [jigoshop_edit_address]
Default parent page: My Account', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_edit_address_page_id',
				'type' => 'single_select_page',
			),
			array(
				'name' => __('View Order Page', 'jigoshop'),
				'desc' => __('Shortcode to place on page: [jigoshop_view_order]
Default parent page: My Account', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_view_order_page_id',
				'type' => 'single_select_page',
			),
			array(
				'name' => __('Change Password Page', 'jigoshop'),
				'desc' => __('Shortcode to place on page: [jigoshop_change_password]
Default parent page: My Account', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_change_password_page_id',
				'type' => 'single_select_page',
			),
			array(
				'name' => __('Track Order Page', 'jigoshop'),
				'desc' => __('Shortcode to place on page: [jigoshop_order_tracking]', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_track_order_page_id',
				'type' => 'single_select_page',
			),
			array(
				'name' => __('Terms Page', 'jigoshop'),
				'desc' => __('If you define a "Terms" page the customer will be asked to accept it before allowing them to place their order.', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_terms_page_id',
				'type' => 'single_select_page',
				'extra' => 'show_option_none='.__('None', 'jigoshop'),
			),
			// Catalog & Pricing tab
			array('type' => 'tab', 'name' => __('Catalog & Pricing', 'jigoshop')),
			array('name' => __('Catalog Options', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Catalog base page', 'jigoshop'),
				'desc' => '',
				'tip' => __('This sets the base page of your shop. You should not change this value once you have launched your site otherwise you risk breaking urls of other sites pointing to yours, etc.', 'jigoshop'),
				'id' => 'jigoshop_shop_page_id',
				'type' => 'single_select_page',
			),
			array(
				'name' => __('Shop redirection page', 'jigoshop'),
				'desc' => '',
				'tip' => __('This will point users to the page you set for buttons like `Return to shop` or `Continue Shopping`.', 'jigoshop'),
				'id' => 'jigoshop_shop_redirect_page_id',
				'type' => 'single_select_page',
			),
			array(
				'name' => __('Catalog product buttons show', 'jigoshop'),
				'desc' => '',
				'tip' => __('This will determine the type of button and the action it will use when clicked on the Shop and Category product listings.  You can also set it to use no button.', 'jigoshop'),
				'id' => 'jigoshop_catalog_product_button',
				'type' => 'radio',
				'choices' => array(
					'add' => __('Add to Cart', 'jigoshop'),
					'view' => __('View Product', 'jigoshop'),
					'none' => __('No Button', 'jigoshop'),
				),
			),
			array(
				'name' => __('Sort products in catalog by', 'jigoshop'),
				'desc' => '',
				'tip' => __('Determines the display sort order of products for the Shop, Categories, and Tag pages.', 'jigoshop'),
				'id' => 'jigoshop_catalog_sort_orderby',
				'type' => 'radio',
				'choices' => array(
					'post_date' => __('Creation Date', 'jigoshop'),
					'title' => __('Product Title', 'jigoshop'),
					'menu_order' => __('Product Post Order', 'jigoshop'),
				),
			),
			array(
				'name' => __('Catalog sort direction', 'jigoshop'),
				'desc' => '',
				'tip' => __('Determines whether the catalog sort orderby is ascending or descending.', 'jigoshop'),
				'id' => 'jigoshop_catalog_sort_direction',
				'type' => 'radio',
				'choices' => array(
					'asc' => __('Ascending', 'jigoshop'),
					'desc' => __('Descending', 'jigoshop'),
				),
			),
			array(
				'name' => __('Catalog products per row', 'jigoshop'),
				'desc' => __('Default = 3', 'jigoshop'),
				'tip' => __('Determines how many products to show on one display row for Shop, Category and Tag pages.', 'jigoshop'),
				'id' => 'jigoshop_catalog_columns',
				'type' => 'number',
				'extra' => array(
					'min' => 1,
					'max' => 10,
					'step' => 1,
				),
			),
			array(
				'name' => __('Catalog products per page', 'jigoshop'),
				'desc' => __('Default = 12', 'jigoshop'),
				'tip' => __('Determines how many products to display on Shop, Category and Tag pages before needing next and previous page navigation.', 'jigoshop'),
				'id' => 'jigoshop_catalog_per_page',
				'type' => 'number',
				'extra' => array(
					'min' => 1,
					'max' => 100,
					'step' => 1,
				),
			),
			array('name' => __('Pricing Options', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Show prices with tax', 'jigoshop'),
				'desc' => __("This controls the display of the product price in cart and checkout page.", 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_show_prices_with_tax',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Currency display', 'jigoshop'),
				'desc' => __("This controls the display of the currency symbol and currency code.", 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_currency_pos',
				'type' => 'select',
				'choices' => array(
					'left' => sprintf('%1$s0%2$s00', $cSymbol, $cSep),// symbol.'0'.separator.'00'
					'left_space' => sprintf('%1$s0 %2$s00', $cSymbol, $cSep),// symbol.' 0'.separator.'00'
					'right' => sprintf('0%2$s00%1$s', $cSymbol, $cSep),// '0'.separator.'00'.symbol
					'right_space' => sprintf('0%2$s00 %1$s', $cSymbol, $cSep),// '0'.separator.'00 '.symbol
					'left_code' => sprintf('%1$s0%2$s00', $cCode, $cSep),// code.'0'.separator.'00'
					'left_code_space' => sprintf('%1$s 0%2$s00', $cCode, $cSep),// code.' 0'.separator.'00'
					'right_code' => sprintf('0%2$s00%1$s', $cCode, $cSep),// '0'.separator.'00'.code
					'right_code_space' => sprintf('0%2$s00 %1$s', $cCode, $cSep),// '0'.separator.'00 '.code
					'symbol_code' => sprintf('%1$s0%2$s00%3$s', $cSymbol, $cSep, $cCode),// symbol.'0'.separator.'00'.code
					'symbol_code_space' => sprintf('%1$s 0%2$s00 %3$s', $cSymbol, $cSep, $cCode),// symbol.' 0'.separator.'00 '.code
					'code_symbol' => sprintf('%3$s0%2$s00%1$s', $cSymbol, $cSep, $cCode),// code.'0'.separator.'00'.symbol
					'code_symbol_space' => sprintf('%3$s 0%2$s00 %1$s', $cSymbol, $cSep, $cCode),// code.' 0'.separator.'00 '.symbol
				)
			),
			array(
				'name' => __('Thousand separator', 'jigoshop'),
				'desc' => __('This sets the thousand separator of displayed prices.', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_price_thousand_sep',
				'type' => 'text',
			),
			array(
				'name' => __('Decimal separator', 'jigoshop'),
				'desc' => __('This sets the decimal separator of displayed prices.', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_price_decimal_sep',
				'type' => 'text',
			),
			array(
				'name' => __('Number of decimals', 'jigoshop'),
				'desc' => __('This sets the number of decimal points shown in displayed prices.', 'jigoshop'),
				'tip' => '',
				'id' => 'jigoshop_price_num_decimals',
				'type' => 'natural',
			),
			// Images tab
			array('type' => 'tab', 'name' => __('Images', 'jigoshop')),
			array(
				'name' => __('Image Options', 'jigoshop'),
				'type' => 'title',
				'desc' => sprintf(__('
Changing any of these settings will affect the dimensions of images used in your Shop. After changing these settings you may need to regenerate your thumbnails.

Crop: Leave unchecked to set the image size by resizing the image proportionally (that is, without distorting it). Leave checked to set the image size by hard cropping the image (either from the sides, or from the top and bottom).

Note: Your images may not display in the size you choose below. This is because they may still be affected by CSS styles in your theme.', 'jigoshop'), 'http://wordpress.org/extend/plugins/regenerate-thumbnails/')
			),
			array('name' => __('Cropping Options', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Crop Tiny images', 'jigoshop'),
				'desc' => '',
				'tip' => __('Use No to set the image size by resizing the image proportionally (that is, without distorting it).
Use Yes to set the image size by hard cropping the image (either from the sides, or from the top and bottom).', 'jigoshop'),
				'id' => 'jigoshop_use_wordpress_tiny_crop',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Crop Thumbnail images', 'jigoshop'),
				'desc' => '',
				'tip' => __('Use No to set the image size by resizing the image proportionally (that is, without distorting it).
Use Yes to set the image size by hard cropping the image (either from the sides, or from the top and bottom).', 'jigoshop'),
				'id' => 'jigoshop_use_wordpress_thumbnail_crop',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Crop Catalog images', 'jigoshop'),
				'desc' => '',
				'tip' => __('Use No to set the image size by resizing the image proportionally (that is, without distorting it).
Use Yes to set the image size by hard cropping the image (either from the sides, or from the top and bottom).', 'jigoshop'),
				'id' => 'jigoshop_use_wordpress_catalog_crop',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Crop Large images', 'jigoshop'),
				'desc' => '',
				'tip' => __('Use No to set the image size by resizing the image proportionally (that is, without distorting it).
Use Yes to set the image size by hard cropping the image (either from the sides, or from the top and bottom).', 'jigoshop'),
				'id' => 'jigoshop_use_wordpress_featured_crop',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array('name' => __('Image Sizes', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Tiny Image Width', 'jigoshop'),
				'desc' => __('Default = 36px', 'jigoshop'),
				'tip' => __('Set the width of the small image used in the Cart, Checkout, Orders and Widgets.', 'jigoshop'),
				'id' => 'jigoshop_shop_tiny_w',
				'type' => 'natural',
			),
			array(
				'name' => __('Tiny Image Height', 'jigoshop'),
				'desc' => __('Default = 36px', 'jigoshop'),
				'tip' => __('Set the height of the small image used in the Cart, Checkout, Orders and Widgets.', 'jigoshop'),
				'id' => 'jigoshop_shop_tiny_h',
				'type' => 'natural',
			),
			array(
				'name' => __('Thumbnail Image Width', 'jigoshop'),
				'desc' => __('Default = 90px', 'jigoshop'),
				'tip' => __('Set the width of the thumbnail image for Single Product page extra images.', 'jigoshop'),
				'id' => 'jigoshop_shop_thumbnail_w',
				'type' => 'natural',
			),
			array(
				'name' => __('Thumbnail Image Height', 'jigoshop'),
				'desc' => __('Default = 90px', 'jigoshop'),
				'tip' => __('Set the height of the thumbnail image for Single Product page extra images.', 'jigoshop'),
				'id' => 'jigoshop_shop_thumbnail_h',
				'type' => 'natural',
			),
			array(
				'name' => __('Catalog Image Width', 'jigoshop'),
				'desc' => __('Default = 150px', 'jigoshop'),
				'tip' => __('Set the width of the catalog image for Shop, Categories, Tags, and Related Products.', 'jigoshop'),
				'id' => 'jigoshop_shop_small_w',
				'type' => 'natural',
			),
			array(
				'name' => __('Catalog Image Height', 'jigoshop'),
				'desc' => __('Default = 150px', 'jigoshop'),
				'tip' => __('Set the height of the catalog image for Shop, Categories, Tags, and Related Products.', 'jigoshop'),
				'id' => 'jigoshop_shop_small_h',
				'type' => 'natural',
			),
			array(
				'name' => __('Large Image Width', 'jigoshop'),
				'desc' => __('Default = 300px', 'jigoshop'),
				'tip' => __('Set the width of the Single Product page large or Featured image.', 'jigoshop'),
				'id' => 'jigoshop_shop_large_w',
				'type' => 'natural',
			),
			array(
				'name' => __('Large Image Height', 'jigoshop'),
				'desc' => __('Default = 300px', 'jigoshop'),
				'tip' => __('Set the height of the Single Product page large or Featured image.', 'jigoshop'),
				'id' => 'jigoshop_shop_large_h',
				'type' => 'natural',
			),
			// Products & Inventory tab
			array('type' => 'tab', 'name' => __('Products & Inventory', 'jigoshop')),
			array('name' => __('Product Options', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Enable SKU field', 'jigoshop'),
				'desc' => '',
				'tip' => __('Turning off the SKU field will give products an SKU of their post id.', 'jigoshop'),
				'id' => 'jigoshop_enable_sku',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Enable weight field', 'jigoshop'),
				'desc' => '',
				'tip' => '',
				'id' => 'jigoshop_enable_weight',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Weight Unit', 'jigoshop'),
				'desc' => '',
				'tip' => __("This controls what unit you will define weights in.", 'jigoshop'),
				'id' => 'jigoshop_weight_unit',
				'type' => 'radio',
				'choices' => array(
					'kg' => __('Kilograms', 'jigoshop'),
					'lbs' => __('Pounds', 'jigoshop'),
				),
			),
			array(
				'name' => __('Enable product dimensions', 'jigoshop'),
				'desc' => '',
				'tip' => '',
				'id' => 'jigoshop_enable_dimensions',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Dimensions Unit', 'jigoshop'),
				'desc' => '',
				'tip' => __('This controls what unit you will define dimensions in.', 'jigoshop'),
				'id' => 'jigoshop_dimension_unit',
				'type' => 'radio',
				'choices' => array(
					'cm' => __('centimeters', 'jigoshop'),
					'in' => __('inches', 'jigoshop'),
				),
			),
			array(
				'name' => __('Product thumbnail images per row', 'jigoshop'),
				'desc' => __('Default = 3', 'jigoshop'),
				'tip' => __('Determines how many extra product thumbnail images attached to a product to show on one row for the Single Product page.', 'jigoshop'),
				'id' => 'jigoshop_product_thumbnail_columns',
				'type' => 'number',
				'extra' => array(
					'min' => 1,
					'max' => 10,
					'step' => 1,
				),
			),
			array(
				'name' => __('Show related products', 'jigoshop'),
				'desc' => '',
				'tip' => __('To show or hide the related products section on a single product page.', 'jigoshop'),
				'id' => 'jigoshop_enable_related_products',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array('name' => __('Inventory Options', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Manage stock', 'jigoshop'),
				'desc' => __('If you are not managing stock, turn it off here to disable it in admin and on the front-end.', 'jigoshop'),
				'tip' => __('You can manage stock on a per-item basis if you leave this option on.', 'jigoshop'),
				'id' => 'jigoshop_manage_stock',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Show stock amounts', 'jigoshop'),
				'desc' => '',
				'tip' => __('Set to yes to allow customers to view the amount of stock available for a product.', 'jigoshop'),
				'id' => 'jigoshop_show_stock',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Notify on low stock', 'jigoshop'),
				'desc' => '',
				'id' => 'jigoshop_notify_low_stock',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Low stock threshold', 'jigoshop'),
				'desc' => '',
				'tip' => __('You will receive a notification as soon this threshold is hit (if notifications are turned on).', 'jigoshop'),
				'id' => 'jigoshop_notify_low_stock_amount',
				'type' => 'natural',
				'std' => '2',
			),
			array(
				'name' => __('Notify on out of stock', 'jigoshop'),
				'desc' => '',
				'id' => 'jigoshop_notify_no_stock',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Out of stock threshold', 'jigoshop'),
				'desc' => '',
				'tip' => __('You will receive a notification as soon this threshold is hit (if notifications are turned on).', 'jigoshop'),
				'id' => 'jigoshop_notify_no_stock_amount',
				'type' => 'natural',
			),
			array(
				'name' => __('Hide out of stock products', 'jigoshop'),
				'desc' => '',
				'tip' => __('For Yes: When the Out of Stock Threshold (above) is reached, the product visibility will be set to hidden so that it will not appear on the Catalog or Shop product lists.', 'jigoshop'),
				'id' => 'jigoshop_hide_no_stock_product',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			// Tax tab
			array('type' => 'tab', 'name' => __('Tax', 'jigoshop')),
			array('name' => __('Tax Options', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Calculate Taxes', 'jigoshop'),
				'desc' => __('Only turn this off if you are exclusively selling non-taxable items.', 'jigoshop'),
				'tip' => __('If you are not calculating taxes then you can ignore all other tax options.', 'jigoshop'),
				'id' => 'jigoshop_calc_taxes',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Apply Taxes After Coupon', 'jigoshop'),
				'desc' => __('This will have no effect if Calculate Taxes is turned off.', 'jigoshop'),
				'tip' => __('If yes, taxes get applied after coupons. When no, taxes get applied before coupons.', 'jigoshop'),
				'id' => 'jigoshop_tax_after_coupon',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Catalog Prices include tax?', 'jigoshop'),
				'desc' => __('This will only apply to the Shop, Category and Product pages.', 'jigoshop'),
				'tip' => __('This will have no effect on the Cart, Checkout, Emails, or final Orders; prices are always shown with tax out.', 'jigoshop'),
				'id' => 'jigoshop_prices_include_tax',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Country to base taxes on', 'jigoshop'),
				'desc' => __('This option defines whether to use billing or shipping address to calculate taxes.', 'jigoshop'),
				'id' => 'jigoshop_country_base_tax',
				'type' => 'select',
				'choices' => array(
					'billing_country' => __('Billing', 'jigoshop'),
					'shipping_country' => __('Shipping', 'jigoshop'),
				),
			),
			array(
				'name' => __('Additional Tax classes', 'jigoshop'),
				'desc' => __('List 1 per line. This is in addition to the default Standard Rate.', 'jigoshop'),
				'tip' => __('List product and shipping tax classes here, e.g. Zero Tax, Reduced Rate.', 'jigoshop'),
				'id' => 'jigoshop_tax_classes',
				'type' => 'textarea',
			),
			array(
				'name' => __('Tax rates', 'jigoshop'),
				'desc' => '',
				'tip' => __('To avoid rounding errors, insert tax rates with 4 decimal places.', 'jigoshop'),
				'id' => 'jigoshop_tax_rates',
				'type' => 'tax_rates',
			),
			// Shipping tab
			array('type' => 'tab', 'name' => __('Shipping', 'jigoshop')),
			array('name' => __('Shipping Options', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Enable Shipping', 'jigoshop'),
				'desc' => __('Only turn this off if you are not shipping items, or items have shipping costs included.', 'jigoshop'),
				'tip' => __('If turned off, this will also remove shipping address fields on the Checkout.', 'jigoshop'),
				'id' => 'jigoshop_calc_shipping',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Enable shipping calculator on cart', 'jigoshop'),
				'desc' => '',
				'tip' => '',
				'id' => 'jigoshop_enable_shipping_calc',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Only ship to billing address?', 'jigoshop'),
				'desc' => '',
				'tip' => __('When activated, Shipping address fields will not appear on the Checkout.', 'jigoshop'),
				'id' => 'jigoshop_ship_to_billing_address_only',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Checkout always shows Shipping fields?', 'jigoshop'),
				'desc' => __('This will have no effect if "Only ship to billing address" is activated.', 'jigoshop'),
				'tip' => __('When activated, Shipping address fields will appear by default on the Checkout.', 'jigoshop'),
				'id' => 'jigoshop_show_checkout_shipping_fields',
				'type' => 'checkbox',
				'choices' => array(
					'no' => __('No', 'jigoshop'),
					'yes' => __('Yes', 'jigoshop'),
				),
			),
			array(
				'name' => __('Available Shipping Methods', 'jigoshop'),
				'type' => 'title',
				'desc' => __('Please enable all of the Shipping Methods you wish to make available to your customers.', 'jigoshop'),
			),
			// Payment Gateways tab
			array('type' => 'tab', 'name' => __('Payment Gateways', 'jigoshop')),
			array('name' => __('Gateway Options', 'jigoshop'), 'type' => 'title', 'desc' => ''),
			array(
				'name' => __('Default Gateway', 'jigoshop'),
				'desc' => __('Only enabled gateways will appear in this list.', 'jigoshop'),
				'tip' => __('This will determine which gateway appears first in the Payment Methods list on the Checkout.', 'jigoshop'),
				'id' => 'jigoshop_default_gateway',
				'type' => 'default_gateway',
				'choices' => apply_filters('jigoshop_available_payment_gateways', array()),
			),
			array(
				'name' => __('Available gateways', 'jigoshop'),
				'type' => 'title',
				'desc' => __('Please enable all of the Payment Gateways you wish to make available to your customers.', 'jigoshop'),
			),
		);
	}

	public function jigoshop_deprecated_options(){
		echo '

'.sprintf(__('The following items, from one or more extensions, have tried to add Jigoshop Settings in a manner that is no longer supported as of Jigoshop 1.3. (%s)', 'jigoshop').'

', implode(', ', $this->bad_extensions));
	}
}


text:
package com.baidu.cc.configuration.dao.impl;

import com.baidu.bjf.dao.ConfigurableBaseSqlMapDao;
import com.baidu.bjf.dao.DaoMapper;
import com.baidu.cc.configuration.bo.Project;
import com.baidu.cc.configuration.dao.ProjectDao;
import com.baidu.cc.configuration.dao.ProjectMapper;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Dao implement class for model : com.baidu.cc.configuration.bo.ProjectBase
 *
 * @author BJF
 */
@Service("projectDao")
public class ProjectDaoImpl extends ConfigurableBaseSqlMapDao<Project, Long>
        implements ProjectDao {
    /**
     * DaoMapper 'projectMapper' reference.
     */
    @Autowired
    private ProjectMapper projectMapper;

    /*
     * (non-Javadoc)
     *
     * @see com.baidu.bjf.dao.ConfigurableBaseSqlMapDao#getDaoMapper()
     */
    @Override
    public DaoMapper<Project, Long> getDaoMapper() {
        return projectMapper;
    }

    /*
     * (non-Javadoc)
     *
     * @see
     * com.baidu.bjf.dao.SqlMapDaoSupport#setSqlSessionFactory(org.apache.ibatis
     * .session.SqlSessionFactory)
     */
    @Resource(name = "sqlSessionFactory")
    @Override
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        setSqlSessionFactoryInternal(sqlSessionFactory);
    }

    /*
     * (non-Javadoc)
     *
     * @see
     * com.baidu.bjf.dao.SqlMapDaoSupport#setSqlSessionTemplate(org.mybatis.
     * spring.SqlSessionTemplate)
     */
    @Resource(name = "sqlSessionTemplate")
    @Override
    public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
        setSqlSessionTemplateInternal(sqlSessionTemplate);
    }
}


text:
import requests
import re

base_url = "http://api.popit.sinarproject.org"
token = open('token.txt')
headers = {'Authorization': token.read().rstrip()}

#  =========   UTILS   =========  #

def clean(label):
    return re.sub(r'[^\w\s]', '', label.lower())

def getUsernameFromLink(linkURL):
    userName = linkURL.split(".com/")[-1]
    return userName

def twitterLinkToContact(linkURL):
    '''
    Posts Twitter link entry as contact entry
    '''
    #Obtain username from URL
    userName = getUsernameFromLink(linkURL)
    newContact = {"type": "twitter", "value": userName, "label": "Twitter"}
    return newContact

def contactToLink(c):
    '''
    Posts contact entry as link entry
    '''
    ctype= c['type']
    #Generate URL from username
    urlPrefixes = {"facebook": "https://www.facebook.com" , "twitter": "https://twitter.com"}
    noteType = {"facebook": "Official Facebook account" , "twitter": "Official Twitter account"}

    newURL = urlPrefixes[ctype] + "/" + c['value']
    link_contact = {"url": newURL, "note": noteType[ctype]}

    return link_contact

def delLinksandContacts(personID):

    base_url = "http://api.popit.sinarproject.org"
    token = "Token 3e6a794d84fc00dc613f40e426cbc4f19b69a68e"
    headers = {'Authorization': token}
    URL = base_url+ "/en/persons/"+ personID

    resp = requests.get(URL).json()
    resp= resp['result']
    if resp['links']:
        for link in resp['links']:
            url = URL +"/links/"+link['id']
            requests.delete(url, headers= headers)
    if resp['contact_details']:
        for con in resp['contact_details']:
            url = URL +"/contact_details/"+con['id']
            r = requests.delete(url, headers= headers)

def fixContactType(c):
    ''' Standardise contact type '''
    clabel = clean(c['label'])
    ctype = clean(c['type'])

    if "email" in clabel or "email" in ctype: #change type to email
        c['type'] = 'email'
    elif "handphone" in clabel or "mobile" in clabel or "handphone" in ctype or "mobile" in ctype: #change type to cell
        c['type'] = 'cell'
    elif "fax" in clabel or "fax" in ctype:
        c['type'] = 'fax'
    elif "phone" in clabel or "phone" in ctype:
        c['type'] = 'voice'
    elif "address" in clabel or "address" in ctype:
        c['type'] = 'address'
    else:
        pass

    return c

#  =========   MAIN   =========  #
def missingContacts_aux(r):
    ''' Migrate missing contacts for a single page '''
    for person in r['result']:
        twitAdded = [] #Keeps track of added accounts to prevent duplication
        fbAdded = []

        if person['contact_details']:
            for contact in person['contact_details']:
                if contact['type'] == "facebook":
                    link_contact = contactToLink(contact)

                    #Post new link entry for contact
                    postURL = base_url+"/en/persons/"+person['id']+ "/links"
                    r = requests.post(postURL, headers = headers, json = link_contact)
                    fbAdded.append(contact['value'])

                elif contact['type'] == "twitter":

                    link_contact = contactToLink(contact)
                    #Post new link entry for contact
                    postURL = base_url+"/en/persons/"+person['id']+ "/links"
                    r = requests.post(postURL, headers = headers, json = link_contact)
                    #print(link_contact)

                    #Proceed with posting contact entry
                    url = base_url+"/en/persons/"+person['id']+ "/contact_details"
                    r = requests.post(url, headers = headers, json = contact)
                    twitAdded.append(contact['value'])
                    #print(contact)

                else:
                    contact = fixContactType(contact)
                    url = base_url+"/en/persons/"+person['id']+ "/contact_details"
                    r = requests.post(url, headers = headers, json = contact)
                    #print(contact)
        if person['links']:
            for link in person['links']:
                if "twitter" in clean(link['note']):
                    twitContact = twitterLinkToContact(link['url'])
                    if twitContact['value'] in twitAdded:
                        pass
                    else:
                        url = base_url+"/en/persons/"+person['id']+ "/contact_details"
                        r = requests.post(url, headers = headers, json = twitContact)
                        #print(twitContact)
                elif "facebook" in clean(link['note']):
                    if getUsernameFromLink(link['url']) in fbAdded:
                        pass
                    else:
                        url = base_url+"/en/persons/"+person['id']+ "/links"
                        r = requests.post(url, headers = headers, json = link)
                        #print(link)
                else:
                    url = base_url+"/en/persons/"+person['id']+ "/links"

                    r = requests.post(url, headers = headers, json = link)
                    #print r.content

def missingContacts():
    ''' Migrate missing contacts for all pages '''
    has_more = True
    pg = 1

    while has_more:
        print("Page: "+ str(pg)+ "\n")
        r = requests.get('https://sinar-malaysia.popit.mysociety.org/api/v0.1/persons/?page='+str(pg)).json()
        missingContacts_aux(r)

        has_more = r['has_more']
        pg +=1


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>commons</artifactId>
        <groupId>tc.oc</groupId>
        <version>0.1.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>commons-bukkit</artifactId>

    <properties>
        <!-- The prefix to use when logging to the console -->
        <plugin.prefix>Commons</plugin.prefix>
        <!-- The main class -->
        <plugin.mainClass>tc.oc.commons.bukkit.CommonsPlugin</plugin.mainClass>
    </properties>

    <repositories>
        <repository>
            <name>Bukkit repository</name>
            <id>bukkit-repo</id>
            <url>http://repo.bukkit.org/content/groups/public</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>tc.oc</groupId>
            <artifactId>commons-core</artifactId>
            <version>${version}</version>
        </dependency>
        <dependency>
            <groupId>org.bukkit</groupId>
            <artifactId>bukkit</artifactId>
            <version>1.6.4-R0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.sk89q</groupId>
            <artifactId>command-framework-bukkit</artifactId>
            <version>0.5-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <includes>
                                    <include>com.sk89q:command-framework-bukkit</include>
                                    <include>tc.oc:commons-core</include>
                                </includes>
                            </artifactSet>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>


text:
package com.jcabi.github;

import com.google.common.base.Optional;
import com.jcabi.github.mock.MkGithub;
import com.jcabi.http.Request;
import com.jcabi.http.mock.MkAnswer;
import com.jcabi.http.mock.MkContainer;
import com.jcabi.http.mock.MkGrizzlyContainer;
import com.jcabi.http.mock.MkQuery;
import com.jcabi.http.request.ApacheRequest;
import com.jcabi.http.request.FakeRequest;
import java.io.IOException;
import java.io.StringReader;
import java.net.HttpURLConnection;
import javax.json.Json;
import javax.json.JsonObject;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;

/**
 * Testcase for {@link RtStatuses}.
 *
 * @author Marcin Cylke (marcin.cylke+github@gmail.com)
 * @version $Id$
 * @checkstyle MultipleStringLiterals (500 lines)
 * @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
 * @todo #1130:30min Write RtStatusesITCase, an integration test case for
 *  RtStatuses/RtStatus against real GitHub commit status data.
 */
public final class RtStatusesTest {
    /**
     * RtStatuses can fetch its commit.
     * @throws IOException If there is an I/O problem.
     */
    @Test
    public void fetchesCommit() throws IOException {
        final Commit original = new MkGithub().randomRepo().git()
            .commits().get("5e8d65e0dbfab0716db16493e03a0baba480625a");
        MatcherAssert.assertThat(
            new RtStatuses(new FakeRequest(), original).commit(),
            Matchers.equalTo(original)
        );
    }

    /**
     * Tests creating a Status.
     *
     * @throws Exception when an Error occurs
     */
    @Test
    public void createsStatus() throws Exception {
        final String stateprop = "state";
        final String urlprop = "target_url";
        final String descriptionprop = "description";
        final String contextprop = "context";
        final String url = "https://ci.example.com/1000/output";
        final String description = "Build has completed successfully";
        final String context = "continuous-integration/jenkins";
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_CREATED,
                Json.createObjectBuilder().add(stateprop, "failure")
                    .add(urlprop, url)
                    .add(descriptionprop, description)
                    .add(contextprop, context)
                    .build().toString()
            )
        ).start();
        final Request entry = new ApacheRequest(container.home());
        final Statuses statuses = new RtStatuses(
            entry,
            new RtCommit(
                entry,
                new MkGithub().randomRepo(),
                "0abcd89jcabitest"
            )
        );
        try {
            statuses.create(
                new Statuses.StatusCreate(Status.State.FAILURE)
                    .withTargetUrl(Optional.of(url))
                    .withDescription(description)
                    .withContext(Optional.of(context))
            );
            final MkQuery request = container.take();
            MatcherAssert.assertThat(
                request.method(),
                Matchers.equalTo(Request.POST)
            );
            final JsonObject obj = Json.createReader(
                new StringReader(request.body())
            ).readObject();
            MatcherAssert.assertThat(
                obj.getString(stateprop),
                Matchers.equalTo(Status.State.FAILURE.identifier())
            );
            MatcherAssert.assertThat(
                obj.getString(contextprop),
                Matchers.equalTo(context)
            );
            MatcherAssert.assertThat(
                obj.getString(descriptionprop),
                Matchers.equalTo(description)
            );
            MatcherAssert.assertThat(
                obj.getString(urlprop),
                Matchers.equalTo(url)
            );
        } finally {
            container.stop();
        }
    }
}