text:
WireToolSetup.setCategory( "Memory" )
WireToolSetup.open( "data_store", "Store", "gmod_wire_data_store", nil, "Data Stores" )

if ( CLIENT ) then
    language.Add( "Tool.wire_data_store.name", "Data Store Tool (Wire)" )
    language.Add( "Tool.wire_data_store.desc", "Spawns a data store." )
    language.Add( "Tool.wire_data_store.0", "Primary: Create/Update data store" )
    language.Add( "WireDataStoreTool_data_store", "Data Store:" )
end
WireToolSetup.BaseLang()
WireToolSetup.SetupMax( 20 )

if (SERVER) then
	-- Uses default WireToolObj:MakeEnt's WireLib.MakeWireEnt function
end

TOOL.ClientConVar[ "model" ] = "models/jaanus/wiretool/wiretool_range.mdl"

function TOOL.BuildCPanel(panel)
	WireDermaExts.ModelSelect(panel, "wire_data_store_model", list.Get( "Wire_Misc_Tools_Models" ), 1)
end


text:
package stsc.integration.tests.algorithms.indices.ikh.stock;

import java.util.ArrayList;

import org.joda.time.LocalDate;
import org.junit.Assert;
import org.junit.Test;

import stsc.algorithms.indices.ikh.stock.IkhSenkauA;
import stsc.common.Day;
import stsc.common.stocks.Stock;
import stsc.common.stocks.united.format.UnitedFormatStock;
import stsc.integration.tests.helper.StockAlgoInitHelper;
import stsc.integration.tests.helper.TestAlgorithmsHelper;

public class IkhSenkauATest {

	@Test
	public void testIkhTenkan() throws Exception {
		testHelperIkhTenkan(6, 12);
		testHelperIkhTenkan(12, 6);
		testHelperIkhTenkan(9, 26);
	}

	private void testHelperIkhTenkan(final int ts, final int tm) throws Exception {
		final StockAlgoInitHelper stockInit = new StockAlgoInitHelper("in", "aapl");
		final StockAlgoInitHelper sAInit = new StockAlgoInitHelper("senkauA", "aapl", stockInit.getStorage());
		sAInit.getSettings().setInteger("TS", ts);
		sAInit.getSettings().setInteger("TM", tm);
		final IkhSenkauA senkauA = new IkhSenkauA(sAInit.getInit());

		final Stock aapl = UnitedFormatStock.readFromUniteFormatFile(TestAlgorithmsHelper.resourceToPath("aapl"));
		final int aaplIndex = aapl.findDayIndex(new LocalDate(2011, 9, 4).toDate());
		final ArrayList<Day> days = aapl.getDays();

		for (int i = aaplIndex; i < days.size(); ++i) {
			final Day day = days.get(i);
			senkauA.process(day);
			Assert.assertNotNull(stockInit.getStorage().getStockSignal("aapl", "senkauA", day.getDate()));
		}
	}
}

redpajama_set_name: RedPajamaGithub


text:
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
// Copyright (c) 2002  Per M.A. Bothner.
// This is free software;  for terms and warranty disclaimer see ./COPYING.

package gnu.jemacs.buffer;
import gnu.lists.LList;

public abstract class EFrame
{
  public static EFrame selectedFrame;
  public EWindow selectedWindow;

  static int counter;
  protected int id = ++counter;
  public EWindow firstWindow;

  public static String defaultName ()
  {
    return "Emacs";
  }

  public EFrame ()
  {
    if (selectedFrame == null)
      selectedFrame = this;
  }

  public EFrame (EWindow win)
  {
    win.frame = this;
    firstWindow = win;
    win.nextWindow = win;
    win.prevWindow = win;
    EWindow.setSelected(win);
  }

  public void validate ()
  {
  }

  public void delete()
  {
    for (;;)
      {
	EWindow win = firstWindow;
	if (win == null)
	  break;
        win.deleteNoValidate();
      }
    if (this == selectedFrame)
      selectedFrame = null;
  }

  public abstract boolean isLive();

  public EWindow getFirstWindow()
  {
    return firstWindow;
  }

  public EWindow getLastWindow()
  {
    return firstWindow.prevWindow;
  }

  public static EFrame getSelectedFrame()
  {
    return selectedFrame;
  }

  public EWindow getSelectedWindow()
  {
    return selectedWindow;
  }

  public EWindow otherWindow(int count)
  {
    return selectedWindow.getNextWindowInFrame(count);
  }

  public abstract void setMenuBar (LList menu);

  public abstract String ask(String prompt);

  public String aboutMessage ()
  {
    return "JEmacs is written by Per Bothner <per@bothner.com>.";
  }

  public abstract void showAboutMessage ();

  public abstract void showInfoMessage (String msg);

  public String toString()
  {
    StringBuffer sbuf = new StringBuffer(100);
    sbuf.append("#<frame #");
    sbuf.append(id);
    sbuf.append('>');
    return sbuf.toString();
  }
}


text:
<?php

namespace Etki\Testing\AllureFramework\Runner\Utility;

use Guzzle\Http\Client;

/**
 * Downloads stuff.
 *
 * @version 0.1.0
 * @since   0.1.0
 * @package Etki\Testing\AllureFramework\Runner\Utility
 * @author  Etki <etki@etki.name>
 */
class Downloader
{
    /**
     * Guzzle instance.
     *
     * @type Client
     * @since 0.1.0
     */
    private $guzzle;
    /**
     * Filesystem helper instance.
     *
     * @type Filesystem
     * @since 0.10
     */
    private $filesystem;

    /**
     * Initializer.
     *
     * @param Client     $guzzle     Guzzle client.
     * @param Filesystem $filesystem Filesystem helper.
     *
     * @codeCoverageIgnore
     *
     * @since 0.1.0
     */
    public function __construct(Client $guzzle, Filesystem $filesystem)
    {
        $this->guzzle = $guzzle;
        $this->filesystem = $filesystem;
    }

    /**
     * Downloads single file
     *
     * @param string $source Source file URL.
     * @param string $target Path to file to write.
     *
     * @return void
     * @since 0.1.0
     */
    public function download($source, $target)
    {
        $request = $this->guzzle->get($source);
        $response = $request->send();
        // todo use streams plz
        $this->filesystem->writeFile($target, $response->getBody(true));
    }
}


text:
<?php

return array(
    'service_manager' => array(
        'factories' => array(
            'Agister\Backend\Hydrator\Timeline' => 'Agister\Backend\Factory\TimelineHydrator',
            'Agister\Backend\Rest\TaskResource' => 'Agister\Backend\Factory\TaskResource',
        ),
    ),
    'router' => array(
        'routes' => array(
            'api' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/api',
                ),
                'may_terminate' => false,
                'child_routes' => array(
                    'tasks' => array(
                        'type' => 'Segment',
                        'options' => array(
                            'route' => '/tasks[/:id]',
                            'defaults' => array(
                                'controller' => 'Agister\Backend\TaskApiController',
                            ),
                        ),
                    ),
                ),
            ),
        )
    ),
    'zf-rest' => array(
        'Agister\Backend\TaskApiController' => array(
            'identifier'              => 'Tasks',
            'listener'                => 'Agister\Backend\Rest\TaskResource',
            'resource_identifiers'    => array('TaskResource'),
            'collection_http_options' => array('get', 'post', 'delete'),
            'collection_name'         => 'tasks',
            'page_size'               => 10,
            'resource_http_options'   => array('get'),
            'route_name'              => 'api/tasks',
        ),
    ),
);


text:
from urllib2 import Request, urlopen, URLError, quote
import base64
import xml.etree.ElementTree as etree

def indent(elem, level=0):
    """Indents an etree element so printing that element is actually human-readable"""
    i = "\n" + level*"  "
    if len(elem):
        if not elem.text or not elem.text.strip():
            elem.text = i + "  "
        if not elem.tail or not elem.tail.strip():
            elem.tail = i
        for elem in elem:
            indent(elem, level+1)
        if not elem.tail or not elem.tail.strip():
            elem.tail = i
    else:
        if level and (not elem.tail or not elem.tail.strip()):
            elem.tail = i

def debug_print(elem):
    indent(elem)
    etree.dump(elem)

class Credentials(object):
    def __init__(self, username, password):
        self.username = username
        self.password = password

class Address(object):
    def __init__(self, name, address, city, state, zip, country, address2='', phone=''):
        self.name = name
        self.address1 = address
        self.address2 = address2
        self.city = city
        self.state = state
        self.zip = str(zip)
        self.country = country
        self.phone = phone

class Package(object):
    FirstClassService='FIRST CLASS'
    PriorityService='PRIORITY'
    PriorityCommericialService='PRIORITY COMMERCIAL'
    ExpressService='EXPRESS'
    ExpressCommercialService='EXPRESS COMMERCIAL'
    ExpressSHService='EXPRESS SH'
    ExpressSHCommercialService='EXPRESS SH COMMERCIAL'
    ExpressHFPService='EXPRESS HFP'
    ExpressHFPCommercialService='EXPRESS HFP COMMERCIAL'
    BPMService='BPM'
    ParcelService='PARCEL'
    MediaService='MEDIA'
    LibraryService='LIBRARY'
    AllService='ALL'
    OnlineService='ONLINE'

    LetterMailType = 'LETTER'
    FlatMailType = 'FLAT'
    ParcelMailType = 'PARCEL'

    RegularSize = 'REGULAR'
    LargeSize = 'LARGE'
    OversizeSize = 'OVERSIZE'

    def __init__(self, shipper, recipient, weight_lbs, weight_ozs, length, width, height):
        self.service_type = self.AllService
        self.shipper = shipper
        self.recipient = recipient
        self.weight = (weight_lbs, weight_ozs)
        self.dimensions = (length, width, height)
        self.size = self.RegularSize
        self.postages = dict()

    def __repr__(self):
        text = self.ID()
        for (mail_type, rate) in self.postages.items():
            text += '\n\t%s: %s' % (mail_type, rate)
        return text

    def ID(self):
        id = '%s To %s Package' % (self.shipper.name, self.recipient.name)
        return id.replace(' ', '')

    def SetFirstClass(self, mail_type):
        self.service_type = self.FirstClassService
        self.first_class_mail_type = mail_type

    def AddPostage(self, mail_type, rate):
        self.postages[mail_type] = rate

class Error(object):
    def __init__(self, number, description, source):
        self.number = number
        self.description = description
        self.source = source

    def __repr__(self):
        return "Error in '%s': %s" % (self.source, self.description)

class USPSRequest(object):
    def __init__(self, credentials, url):
        self.credentials = credentials
        self.url = url

    def Send(self):
        root = self._get_xml()
        request_text = etree.tostring(root)

        try:
            full_url = '%s%s' % (self.url, quote(request_text))
            request = Request(full_url)
            response_text = urlopen(request).read()
            response = self._ParseResponse(response_text)
        except URLError, e:
            if hasattr(e, 'reason'):
                print 'Could not reach the server, reason: %s' % e.reason
            elif hasattr(e, 'code'):
                print 'Could not fulfill the request, code: %d' % e.code
            raise

        return response

    def _get_xml(self):
        return self._GetBody()

    def _ParseResponse(self, response_text):
        """Parses the text from a USPS web service call"""
        root = etree.fromstring(response_text)
        response = None
        if root.tag == 'Error':
            response = self._ParseError(root)
        else:
            response = self._parse_response_body(root)
        return response

    def _ParseError(self, error_root):
        number = error_root.findtext('Number')
        description = error_root.findtext('Description')
        source = error_root.findtext('Source')
        return Error(number, description, source)

class RateRequest(USPSRequest):
    def __init__(self, username, packages):
        self.debug = True
        url = 'http://testing.shippingapis.com/ShippingAPITest.dll?API=RateV2&XML=' if self.debug else 'http://production.shippingapis.com/ShippingAPI.dll?API=RateV3&XML='

        credentials = Credentials(username, '')
        super(RateRequest, self).__init__(credentials, url)
        self.packages = packages

    def __repr__(self):
        body = self._GetBody()
        indent(body)
        return etree.tostring(body)

    def _GetBody(self):
        root_id = u'RateV2Request' if self.debug else u'RateV3Request'
        root = etree.Element(root_id)
        root.set('USERID', self.credentials.username)

        for i, package in enumerate(self.packages):
            package_token = etree.SubElement(root, u'Package')
            package_id = '%s%d' % (package.ID(), i)
            package_token.set('ID', package_id)

            etree.SubElement(package_token, u'Service').text = package.service_type
            if package.service_type == Package.FirstClassService:
                etree.SubElement(package_token, u'FirstClassMailType').text = package.first_class_mail_type

            etree.SubElement(package_token, u'ZipOrigination').text = package.shipper.zip
            etree.SubElement(package_token, u'ZipDestination').text = package.recipient.zip

            etree.SubElement(package_token, u'Pounds').text = str(package.weight[0])
            etree.SubElement(package_token, u'Ounces').text = str(package.weight[1])

            etree.SubElement(package_token, u'Container')

            """
            May be left blank in situations that do not require a Size. Defined as follows: REGULAR: package length plus girth is 84 inches or less; LARGE: package length plus girth measure more than 84 inches but not more than 108 inches; OVERSIZE: package length plus girth is more than 108 but not more than 130 inches.
            """
            length = max(package.dimensions)
            etree.SubElement(package_token, u'Size').text = Package.LargeSize

            etree.SubElement(package_token, u'Machinable').text = 'true'

        return root

    def _parse_response_body(self, root):
        return RateResponse(root, self.packages)

class RateResponse(object):
    def __init__(self, root, packages):
        self.packages = packages

        package_roots = root.findall('Package')
        assert len(package_roots) == len(self.packages)
        for i, package in enumerate(self.packages):
            postage_roots = package_roots[i].findall('Postage')
            for postage_root in postage_roots:
                mail_service = postage_root.findtext('MailService')
                rate = postage_root.findtext('Rate')
                package.AddPostage(mail_service, rate)

    def __repr__(self):
        import pprint
        return pprint.pformat(self.packages)

class DeliveryConfirmationRequest(USPSRequest):
    def __init__(self, username, sender, recipient, weight_in_ounces):
        self.debug = True
        url = 'https://secure.shippingapis.com/ShippingAPITest.dll?API=DelivConfirmCertifyV3&XML=' if self.debug else 'https://production.shippingapis.com/ShippingAPI.dll?API=DeliveryConfirmationV3&XML='

        credentials = Credentials(username, '')
        super(DeliveryConfirmationRequest, self).__init__(credentials, url)

        self.sender = sender
        self.recipient = recipient
        self.weight_in_ounces = str(weight_in_ounces)

    def __repr__(self):
        body = self._GetBody()
        indent(body)
        return etree.tostring(body)

    def _GetBody(self):
        root_id = u'DelivConfirmCertifyV3.0Request' if self.debug else u'DeliveryConfirmationV3.0Request'
        root = etree.Element(root_id)
        root.set('USERID', self.credentials.username)

        etree.SubElement(root, u'Option').text = '1'
        etree.SubElement(root, u'ImageParameters')

        etree.SubElement(root, u'FromName').text = self.sender.name[0:31]
        etree.SubElement(root, u'FromFirm')
        etree.SubElement(root, u'FromAddress1').text = self.sender.address2[0:31]
        etree.SubElement(root, u'FromAddress2').text = self.sender.address1[0:31]
        etree.SubElement(root, u'FromCity').text = self.sender.city[0:31]
        etree.SubElement(root, u'FromState').text = self.sender.state
        etree.SubElement(root, u'FromZip5').text = self.sender.zip
        etree.SubElement(root, u'FromZip4')

        etree.SubElement(root, u'ToName').text = self.recipient.name[0:31]
        etree.SubElement(root, u'ToFirm')
        etree.SubElement(root, u'ToAddress1').text = self.recipient.address2[0:31]
        etree.SubElement(root, u'ToAddress2').text = self.recipient.address1[0:31]
        etree.SubElement(root, u'ToCity').text = self.recipient.city[0:31]
        etree.SubElement(root, u'ToState').text = self.recipient.state
        etree.SubElement(root, u'ToZip5').text = self.recipient.zip
        etree.SubElement(root, u'ToZip4')

        etree.SubElement(root, u'WeightInOunces').text = self.weight_in_ounces
        etree.SubElement(root, u'ServiceType').text = 'Priority'
        etree.SubElement(root, u'POZipCode')

        etree.SubElement(root, u'ImageType').text = 'TIF'
        etree.SubElement(root, u'AddressServiceRequest').text = 'TRUE'
        etree.SubElement(root, u'LabelDate')

        return root

    def _parse_response_body(self, root):
        return DeliveryConfirmationResponse(root)

class DeliveryConfirmationResponse(object):
    def __init__(self, root):
        self.tracking = root.findtext('DeliveryConfirmationNumber')
        label = root.findtext('DeliveryConfirmationLabel')
        self.label = base64.b64decode(label)

    def __repr__(self):
        indent(self.root)
        return etree.tostring(self.root)

class ExpressMailRequest(USPSRequest):
    def __init__(self, username, sender, recipient, weight_in_ounces):
        self.debug = True
        url = 'https://secure.shippingapis.com/ShippingAPITest.dll?API=ExpressMailLabel&XML=' if self.debug else 'https://production.shippingapis.com/ShippingAPI.dll?API=ExpressMailLabel&XML='

        credentials = Credentials(username, '')
        super(ExpressMailRequest, self).__init__(credentials, url)

        self.sender = sender
        self.recipient = recipient
        self.weight_in_ounces = str(weight_in_ounces)

    def __repr__(self):
        body = self._GetBody()
        indent(body)
        return etree.tostring(body)

    def _GetBody(self):
        root_id = u'ExpressMailLabelRequest' if self.debug else u'ExpressMailLabelRequest'
        root = etree.Element(root_id)
        root.set('USERID', self.credentials.username)

        etree.SubElement(root, u'Option')
        etree.SubElement(root, u'ImageParameters')

        etree.SubElement(root, u'FromName').text = self.sender.name[0:31]
        etree.SubElement(root, u'FromFirm')
        etree.SubElement(root, u'FromAddress1').text = self.sender.address2[0:31]
        etree.SubElement(root, u'FromAddress2').text = self.sender.address1[0:31]
        etree.SubElement(root, u'FromCity').text = self.sender.city[0:31]
        etree.SubElement(root, u'FromState').text = self.sender.state
        etree.SubElement(root, u'FromZip5').text = self.sender.zip
        etree.SubElement(root, u'FromZip4')

        etree.SubElement(root, u'ToName').text = self.recipient.name[0:31]
        etree.SubElement(root, u'ToFirm')
        etree.SubElement(root, u'ToAddress1').text = self.recipient.address2[0:31]
        etree.SubElement(root, u'ToAddress2').text = self.recipient.address1[0:31]
        etree.SubElement(root, u'ToCity').text = self.recipient.city[0:31]
        etree.SubElement(root, u'ToState').text = self.recipient.state
        etree.SubElement(root, u'ToZip5').text = self.recipient.zip
        etree.SubElement(root, u'ToZip4')

        etree.SubElement(root, u'WeightInOunces').text = self.weight_in_ounces
        etree.SubElement(root, u'ServiceType').text = 'Priority'
        etree.SubElement(root, u'POZipCode')

        etree.SubElement(root, u'ImageType').text = 'TIF'
        #etree.SubElement(root, u'AddressServiceRequest').text = 'TRUE'
        etree.SubElement(root, u'LabelDate')

        return root

    def _parse_response_body(self, root):
        return ExpressMailResponse(root)

class ExpressMailResponse(object):
    def __init__(self, root):
        self.root = root

    def __repr__(self):
        indent(self.root)
        return etree.tostring(self.root)


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:baselineAligned="false"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:gravity="center"
    android:orientation="vertical"
    android:visibility="visible" >

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:background="@drawable/feather_infoscreen_background"
        android:padding="20dp" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="vertical" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="centerInside"
                android:src="@drawable/aviary_logo_big" />

            <com.aviary.android.feather.widget.TextViewCustomFont
                android:id="@+id/version_text"
                style="@style/FeatherInfoScreen.Version"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="" />

            <com.aviary.android.feather.widget.TextViewCustomFont
                style="@style/FeatherInfoScreen.Content"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:text="@string/infoscreen_text" />

            <com.aviary.android.feather.widget.ButtonCustomFont
                android:id="@+id/aviary_infoscreen_submit"
                style="@style/FeatherTool"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="@string/infoscreen_submit" />
        </LinearLayout>
    </ScrollView>

</LinearLayout>


text:
var keystone = require('keystone'),
	_ = require('underscore');

exports = module.exports = function(req, res) {

	var view = new keystone.View(req, res),
		locals = res.locals;

	locals.section = 'download-center';
	locals.page.title = 'VegsocHK Download Center';

	view.render('site/downloadCenter');

}


text:
package org.springframework.security.config.http;

import java.lang.reflect.Method;

import javax.servlet.Filter;
import javax.servlet.http.HttpServletResponse;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.mock.web.MockFilterChain;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.security.config.util.InMemoryXmlApplicationContext;
import org.springframework.security.crypto.codec.Base64;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * @author Rob Winch
 */
public class NamespaceHttpBasicTests {
	@Mock
	Method method;

	MockHttpServletRequest request;
	MockHttpServletResponse response;
	MockFilterChain chain;

	ConfigurableApplicationContext context;

	Filter springSecurityFilterChain;

	@Before
	public void setup() {
		this.request = new MockHttpServletRequest();
		this.request.setMethod("GET");
		this.response = new MockHttpServletResponse();
		this.chain = new MockFilterChain();
	}

	@After
	public void teardown() {
		if (this.context != null) {
			this.context.close();
		}
	}

	// gh-3296
	@Test
	public void httpBasicWithPasswordEncoder() throws Exception {
		// @formatter:off
		loadContext("<http>\n" +
			"		<intercept-url pattern=\"/**\" access=\"hasRole('USER')\" />\n" +
			"		<http-basic />\n" +
			"	</http>\n" +
			"\n" +
			"	<authentication-manager id=\"authenticationManager\">\n" +
			"		<authentication-provider>\n" +
			"			<password-encoder ref=\"passwordEncoder\" />\n" +
			"			<user-service>\n" +
			"				<user name=\"user\" password=\"$2a$10$Zk1MxFEt7YYji4Ccy9xlfuewWzUMsmHZfy4UcCmNKVV6z5i/JNGJW\" authorities=\"ROLE_USER\"/>\n" +
			"			</user-service>\n" +
			"		</authentication-provider>\n" +
			"	</authentication-manager>\n" +
			"	<b:bean id=\"passwordEncoder\"\n" +
			"		class=\"org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder\" />");
			// @formatter:on

		this.request.addHeader("Authorization",
				"Basic " + new String(Base64.encode("user:test".getBytes("UTF-8"))));

		this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain);

		assertThat(this.response.getStatus()).isEqualTo(HttpServletResponse.SC_OK);
	}

	private void loadContext(String context) {
		this.context = new InMemoryXmlApplicationContext(context);
		this.springSecurityFilterChain = this.context.getBean("springSecurityFilterChain",
				Filter.class);
	}
}


text:
<?php

class WPML_Package_Translation extends WPML_Package_Helper {
	var $load_priority = 100;
	var $package_translation_active;
	var $admin_lang_switcher = null;

	function __construct() {

		$this->package_translation_active = false;

		parent::__construct();
		add_action( 'wpml_loaded', array( $this, 'loaded' ), $this->load_priority );
		add_action( 'shutdown', array( $this, 'shutdown' ) );
	}

	function loaded() {
		parent::loaded();
		if ( $this->passed_dependencies() ) {
			if ( icl_get_setting( 'setup_complete' ) ) {
				$this->add_admin_hooks();
				$this->add_global_hooks();

				if ( is_admin() ) {
					$this->run_db_update();
					if ( get_option( 'wpml-package-translation-refresh-required', true ) ) {
						add_action( 'init', array( $this, 'refresh_packages' ), 999, 0 );
						update_option( 'wpml-package-translation-refresh-required', false );
					}
				}

				$this->package_translation_active = true;
			}
		}
	}

	function shutdown() {
		if ( is_admin() ) {
			if ( ! $this->package_translation_active ) {
				update_option( 'wpml-package-translation-refresh-required', true );
			}
		}
	}

	private function add_admin_hooks() {
		if ( is_admin() || $this->is_doing_xmlrpc() ) {
			add_action( 'wp_ajax_wpml_delete_packages', array( $this, 'delete_packages_ajax' ) );
			add_action( 'wp_ajax_wpml_change_package_lang', array( $this, 'change_package_lang_ajax' ) );

			/* Core hooks */
			add_filter( 'wpml_pt_all_packages', array( $this, 'get_all_packages' ) );

			/* Translation hooks for other plugins to use */
			add_filter( 'wpml_tm_element_type', array( $this, 'get_element_type' ), 10, 2 );
			add_filter( 'wpml_tm_dashboard_title_locations', array( $this, 'add_title_db_location' ), 10, 2 );

			//NOTE: for some reasons 'WPML_register_string' has been created as a filter, which makes little sense, considering that we never actually use it as a filer.
			//This action is a candidate to be in future the only way to register packages and strings
			add_action( 'wpml_register_string', array( $this, 'register_string_action' ), 10, 5 );
			add_filter( 'wpml_string_id_from_package', array( $this, 'string_id_from_package_filter' ), 10, 4 );
			add_filter( 'wpml_string_title_from_id', array( $this, 'string_title_from_id_filter' ), 10, 2 );
			//TODO: deprecated, use the 'wpml_register_string' action
			add_filter( 'WPML_register_string', array( $this, 'register_string_for_translation' ), 10, 5 );

			add_action( 'wpml_add_string_translation', array( $this, 'add_string_translation_action' ), 10, 7 );

			//TODO: These 3 hooks are deprecated. They are needed for Layouts 1.0. Consider removing them after Layouts 1.2 is released
			add_filter( 'WPML_get_translated_strings', array( $this, 'get_translated_strings' ), 10, 2 );
			add_action( 'WPML_set_translated_strings', array( $this, 'set_translated_strings' ), 10, 2 );
			add_action( 'WPML_show_package_language_ui', array( $this, 'show_language_selector' ), 10, 2 );

			add_filter( 'wpml_get_translated_strings', array( $this, 'get_translated_strings' ), 10, 2 );
			add_action( 'wpml_set_translated_strings', array( $this, 'set_translated_strings' ), 10, 2 );
			add_action( 'wpml_show_package_language_ui', array( $this, 'show_language_selector' ), 10, 2 );
			add_action( 'wpml_show_package_language_admin_bar', array( $this, 'show_admin_bar_language_selector' ), 10 , 2 );

			/* WPML hooks */
			add_filter( 'wpml_get_translatable_types', array( $this, 'get_translatable_types' ), 10, 1 );
			add_filter( 'wpml_get_translatable_item', array( $this, 'get_translatable_item' ), 10, 2 );
			add_filter( 'wpml_external_item_url', array( $this, 'get_package_edit_url' ), 10, 2 );
			add_filter( 'wpml_external_item_link', array( $this, 'get_package_edit_link' ), 10, 3 );
			add_filter( 'wpml_get_external_item_title', array( $this, 'get_package_title' ), 10, 3 );
			add_filter( 'wpml_element_id_from_package', array( $this, 'get_element_id_from_package_filter' ), 10, 2 );
			add_filter( 'wpml_get_package_type', array( $this, 'get_package_type' ), 10, 2 );
			add_filter( 'wpml_get_package_type_prefix', array( $this, 'get_package_type_prefix' ), 10, 2 );
			add_filter( 'wpml_language_for_element', array( $this, 'get_language_for_element' ), 10, 2 );
			add_filter( 'wpml_st_get_post_string_packages', array( $this, 'get_post_string_packages' ), 10, 2 );
			add_filter( 'wpml_st_get_string_package', array( $this, 'get_string_package' ), 10, 2 );

			/* Translation queue hooks */
			add_filter( 'wpml_tm_external_translation_job_title', array( $this, 'get_post_title' ), 10, 2 );
			add_filter( 'wpml_tm_add_to_basket', array( $this, 'add_to_basket' ), 10, 2 );
			add_filter( 'wpml_tm_translation_jobs_basket', array( $this, 'update_translation_jobs_basket' ), 10, 3 );
			add_filter( 'wpml_tm_basket_items_types', array( $this, 'basket_items_types' ), 10, 2 );

			/* TM Hooks */
			//This is called by \TranslationManagement::send_all_jobs - The hook is dynamically built.
			add_action( 'wpml_tm_send_package_jobs', array( $this, 'send_jobs' ), 10, 5 );

			/* Translation editor hooks */
			add_filter( 'wpml_tm_editor_string_name', array( $this, 'get_editor_string_name' ), 10, 2 );
			add_filter( 'wpml_tm_editor_string_style', array( $this, 'get_editor_string_style' ), 10, 3 );

			/* API Hooks */
			//TODO: [WPML 3.2] implement the filter based on \WPML_TM_Menus::build_content_dashboard_documents_row
			add_filter( 'wpml_tm_wpml_package_estimate_word_count', array( $this, 'estimate_word_count' ), 10, 2 );
			//@deprecated @since 3.2 Use 'wpml_delete_package'
			add_action( 'wpml_delete_package_action', array( $this, 'delete_package_action' ), 10, 2 );
			add_action( 'wpml_delete_package', array( $this, 'delete_package_action' ), 10, 2 );
		}
	}

	private function is_doing_xmlrpc() {
		return ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST );
	}

	private function add_global_hooks() {

		//TODO: deprecated, use the 'wpml_translate_string' filter
		add_filter( 'WPML_translate_string', array( $this, 'translate_string' ), 10, 3 );
		add_filter( 'wpml_translate_string', array( $this, 'translate_string' ), 10, 3 );

		/* API Hooks */
		add_filter( 'wpml_is_external', array( $this, 'is_external' ), 10, 2 );
	}

	private function run_db_update() {
		if ( is_admin() ) {
			WPML_Package_Translation_Schema::run_update();
		}
	}

	/**
	 * @return bool
	 */
	private function passed_dependencies() {
		return defined( 'ICL_SITEPRESS_VERSION' )
		       && defined( 'WPML_ST_VERSION' )
		       && defined( 'WPML_TM_VERSION' );
	}

	public function add_title_db_location( $locations ) {
		global $wpdb;

		$locations[ $wpdb->prefix . 'icl_string_packages' ] = array(
			'id_column'           => 'ID',
			'title_column'        => 'title',
			'element_type_prefix' => 'package',
			'date_column'         => false,
		);

		return $locations;
	}

	function get_package_edit_url( $url, $post_id ) {
		$package = new WPML_Package( $post_id );
		if ( ! $package ) {
			return false;
		} //not ours
		if ( isset( $package->edit_link ) ) {
			$url = $package->edit_link;
		}

		return $url;
	}

	public function get_package_title( $title, $kind, $id ) {
		$package = new WPML_Package( $id );
		if ( ! $package ) {
			return $title;
		} //not ours
		if ( isset( $package->title ) ) {
			$title = $package->title;
		}

		return $title;
	}

	function get_package_view_link( $link, $post_id, $hide_if_missing_link = false ) {
		$package = new WPML_Package( $post_id );
		if ( ! $package ) {
			return $link;
		} //not ours
		return $this->build_package_link( $package->view_link, $package->title, $hide_if_missing_link );
	}

	function get_package_edit_link( $link, $post_id, $hide_if_missing_link = false ) {
		$package = new WPML_Package( $post_id );
		if ( ! $package ) {
			return $link;
		} //not ours
		return $this->build_package_link( $package->edit_link, esc_html( $package->title ), $hide_if_missing_link );
	}

	private function build_package_link( $url, $title, $hide_if_missing_link = false ) {
		$link = '' . $title . '';
		if ( false === $hide_if_missing_link ) {
			if ( ! $url ) {
				$link = $title;
			}
		} elseif ( ! $url ) {
			$link = '';
		}

		return $link;
	}

	/**
	 * @param       $package
	 * @param array $args
	 */
	function show_language_selector( $package, $args = array() ) {
		global $wpdb, $sitepress;

		$wpml_pt_meta = new WPML_Package_Translation_Metabox($package, $wpdb, $sitepress, $args);
		echo $wpml_pt_meta->get_metabox();
	}

	/**
	 * @param       $package
	 * @param array $args
	 */
	function show_admin_bar_language_selector( $package, $args = array() ) {
		require WPML_PACKAGE_TRANSLATION_PATH . '/inc/wpml-package-admin-lang-switcher.class.php';
		$this->admin_lang_switcher = new WPML_Package_Admin_Lang_Switcher( $package, $args );
	}

	function cleanup_translation_jobs_basket_packages( $translation_jobs_basket ) {
		if ( empty( $translation_jobs_basket[ 'packages' ] ) ) {
			return;
		}

		foreach ( $translation_jobs_basket[ 'packages' ] as $id => $data ) {
			if ( ! new WPML_Package( $id ) ) {
				TranslationProxy_Basket::delete_item_from_basket( $id );
			}
		}
	}

	public function update_translation_jobs_basket( $translation_jobs_cart, $translation_jobs_basket, $item_type ) {
		if ( $item_type == 'package' ) {
			if ( ! isset( $translation_jobs_basket[ $item_type ] ) ) {
				return false;
			}

			$packages = $translation_jobs_basket[ $item_type ];
			if ( empty( $packages ) ) {
				return false;
			}

			$this->cleanup_translation_jobs_basket_packages( $translation_jobs_basket );

			global $sitepress;

			$packages_ids = array_keys( $packages );

			foreach ( $packages_ids as $package_id ) {
				$package = new WPML_Package( $package_id );
				if ( $package ) {
					$package_source_language  = $packages[ $package_id ][ 'from_lang' ];
					$package_target_languages = $packages[ $package_id ][ 'to_langs' ];
					$language_names           = $this->languages_to_csv( $package_target_languages );

					$final_post = array();

					$final_post[ 'post_title' ]       = $package->title;
					$final_post[ 'post_notes' ]       = get_post_meta( $package->ID, '_icl_translator_note', true );
					$final_post[ 'post_type' ]        = $package->kind;
					$final_post[ 'post_status' ]      = $package->post_status;
					$final_post[ 'post_date' ]        = $package->post_date;
					$final_post[ 'from_lang' ]        = $package_source_language;
					$final_post[ 'from_lang_string' ] = ucfirst( $sitepress->get_display_language_name( $package_source_language, $sitepress->get_admin_language() ) );
					$final_post[ 'to_langs' ]         = $package_target_languages;
					$final_post[ 'to_langs_string' ]  = implode( ", ", $language_names );

					$translation_jobs_cart[ $package_id ] = $final_post;
				}
			}
		}

		return $translation_jobs_cart;
	}

	public function basket_items_types( $item_types ) {
		$item_types[ 'package' ] = 'custom';

		return $item_types;
	}

	/**
	 * @param $package_target_languages
	 *
	 * @return array
	 */
	private function languages_to_csv( $package_target_languages ) {
		global $sitepress;

		$language_names = array();
		foreach ( $package_target_languages as $language_code => $value ) {
			$language_names[ ] = ucfirst( $sitepress->get_display_language_name( $language_code, $sitepress->get_admin_language() ) );
		}

		return $language_names;
	}

	//TODO: [WPML 3.3] to implement (a 'get' method of WPML_Package, maybe?)
	/**
	 * @param int          $word_count
	 * @param WPML_Package $package
	 *
	 * @return int
	 */
	function estimate_word_count( $word_count, $package ) {
		if ( $this->is_a_package( $package ) ) {
			$word_count = 0;

			$language_code = $package->get_package_language();
			$strings       = $package->string_data;

			if ( $strings ) {
				global $WPML_String_Translation;
				if ( isset( $WPML_String_Translation ) ) {
					foreach ( $strings as $string_id => $string_value ) {
						$word_count += $WPML_String_Translation->estimate_word_count( $string_value, $language_code );
					}
				}
			}
		}

		return $word_count;
	}

	function is_external( $result, $type ) {
		return $result || is_a( $type, 'WPML_Package' ) || $type == 'package';
	}

	public function get_element_type( $type, $element ) {
		if ( $this->is_a_package( $element ) ) {
			$type = 'package';
		}

		return $type;
	}

	/**
	 * @param $attributes
	 *
	 * @return string
	 */
	public function attributes_to_string( $attributes ) {
		$result = '';
		foreach ( $attributes as $key => $value ) {
			if ( $result ) {
				$result .= ' ';
			}
			$result .= esc_html( $key ) . '="' . esc_attr( $value ) . '"';
		}

		return $result;
	}

	/**
	 * @param int|Array $package
	 *
	 * @return bool
	 */
	public function is_package_registered( $package ) {
		$package_id    = false;
		$is_registered = false;
		if ( is_array( $package ) ) {
			$package_id = $this->_get_package_id( $package );
		} elseif ( is_numeric( $package ) ) {
			$package_id = $package;
		}
		if ( $package_id ) {
			$is_registered = ! isset( $this->registered_strings[ $package_id ] );
		}

		return $is_registered;
	}

	/**
	 * @param $kind_slug
	 *
	 * @return string
	 */
	public function get_package_element_type( $kind_slug ) {
		if ( is_object( $kind_slug ) ) {
			$kind_slug = $kind_slug->kind_slug;
		}
		if ( is_array( $kind_slug ) ) {
			$kind_slug = $kind_slug[ 'kind_slug' ];
		}

		return 'package_' . $kind_slug;
	}

	/**
	 * @param $package
	 *
	 * @return bool
	 */
	public function package_has_kind( $package ) {
		return isset( $package[ 'kind' ] ) && $package[ 'kind' ];
	}

	/**
	 * @param $package
	 *
	 * @return bool
	 */
	public function package_has_name( $package ) {
		return isset( $package[ 'name' ] ) && $package[ 'name' ];
	}

	/**
	 * @param $package
	 *
	 * @return bool
	 */
	public function package_has_title( $package ) {
		return isset( $package[ 'title' ] ) && $package[ 'title' ];
	}

	/**
	 * @param $package
	 *
	 * @return bool
	 */
	public function package_has_kind_and_name( $package ) {
		return $this->package_has_kind( $package ) && $this->package_has_name( $package );
	}

	/**
	 * @param $string_name
	 *
	 * @return mixed
	 */
	public function sanitize_string_with_underscores( $string_name ) {
		return preg_replace( '/[ \[\]]+/', '_', $string_name );
	}

	function new_external_item( $type, $package_item, $get_string_data = false ) {
		//create a new external item for the Translation Dashboard or for translation jobs

		$package_id = $package_item[ 'ID' ];

		$item                 = new stdClass();
		$item->external_type  = true;
		$item->type           = $type;
		$item->ID             = $package_id;
		$item->post_type      = $type;
		$item->post_id        = 'external_' . $item->post_type . '_' . $package_item[ 'ID' ];
		$item->post_date      = '';
		$item->post_status    = __( 'Active', 'wpml-string-translation' );
		$item->post_title     = $package_item[ 'title' ];
		$item->is_translation = false;

		if ( $get_string_data ) {
			$item->string_data = $this->_get_package_strings( $package_item );
		}

		return $item;
	}

	function get_package_from_external_id( $post_id ) {

		global $wpdb;

		$packages = $wpdb->get_col( "SELECT ID FROM {$wpdb->prefix}icl_string_packages WHERE ID>0" );

		foreach ( $packages as $package_id ) {

			$package = new WPML_Package( $package_id );

			$test = $this->get_external_id_from_package( $package );
			if ( is_string( $post_id ) && $post_id == $test ) {
				return $package;
			}
		}

		return false; //not a package type
	}

	function _get_package_strings( $package_item ) {
		global $wpdb;
		$strings = array();

		$package_item_id = $package_item[ 'ID' ];
		$results         = $wpdb->get_results( $wpdb->prepare( "SELECT name, value FROM {$wpdb->prefix}icl_strings WHERE string_package_id=%d", $package_item_id ) );

		foreach ( $results as $result ) {
			$string_name             = (bool) $package_item_id === true && strpos( $result->name,
																				   (string) $package_item_id ) === 0
				? substr( $result->name, strlen( $package_item_id ) + 1 ) : $result->name;
			$strings[ $string_name ] = $result->value;
		}

		// Add/update any registered strings
		if ( isset( $this->registered_strings[ $package_item_id ][ 'strings' ] ) ) {
			foreach ( $this->registered_strings[ $package_item_id ][ 'strings' ] as $id => $string_data ) {
				$strings[ $id ] = $string_data[ 'value' ];
			}
		}

		return $strings;
	}

	function get_link( $item, $package_item, $anchor, $hide_empty ) {
		if ( $item == "" ) {
			$package_item = $this->get_package_from_external_id( $package_item );
			if ( ! $package_item ) {
				return '';
			}

			$has_link = isset( $package_item->edit_link ) && $package_item->edit_link;
			if ( false === $anchor ) {
				if ( $has_link ) {
					$anchor = 'edit_link . '">' . $package_item[ 'title' ] . '';
				} elseif ( ! $hide_empty ) {
					$anchor = $package_item[ 'title' ];
				}
			} else {
				if ( $has_link ) {
					$anchor = '' . $anchor . '';
				}
			}

			$item = $anchor;
		}

		return $item;
	}

	/**
	 * Update translations
	 *
	 * @param      $package_id
	 * @param bool $is_new       - set to true for newly created form (first save without fields)
	 * @param bool $needs_update - when deleting single field we do not need to change the translation status of the form
	 *
	 * @internal param array $item - package information
	 */
	function update_package_translations( $package_id, $is_new, $needs_update = true ) {

		global $sitepress, $wpdb, $iclTranslationManagement;

		$item = $this->get_package_details( $package_id );

		$post_id = $this->get_external_id_from_package( new WPML_Package( $package_id ) );
		$post    = $this->get_translatable_item( null, $post_id );
		if ( ! $post ) {
			return;
		}
		$default_lang = $sitepress->get_default_language();
		$icl_el_type  = $this->get_package_element_type( $item );
		$trid         = $sitepress->get_element_trid( $item[ 'ID' ], $icl_el_type );

		if ( $is_new ) {
			$sitepress->set_element_language_details( $post->ID, $icl_el_type, false, $default_lang, null, false );

			//for new package nothing more to do
			return;
		}

		$sql                  = "
					            SELECT t.translation_id, s.md5
					            FROM {$wpdb->prefix}icl_translations t
					                NATURAL JOIN {$wpdb->prefix}icl_translation_status s
					            WHERE t.trid=%d
					                AND t.source_language_code IS NOT NULL
					            ";
		$element_translations = $wpdb->get_results( $wpdb->prepare( $sql, $trid ) );

		if ( ! empty( $element_translations ) ) {

			$md5 = $iclTranslationManagement->post_md5( $post );

			if ( $md5 != $element_translations[ 0 ]->md5 ) { //all translations need update

				$translation_package = $iclTranslationManagement->create_translation_package( $post );

				foreach ( $element_translations as $trans ) {
					$_prevstate = $wpdb->get_row( $wpdb->prepare( "
                        SELECT status, translator_id, needs_update, md5, translation_service, translation_package, timestamp, links_fixed
                        FROM {$wpdb->prefix}icl_translation_status
                        WHERE translation_id = %d
                    ", $trans->translation_id ), ARRAY_A );
					if ( ! empty( $_prevstate ) ) {
						$data[ '_prevstate' ] = serialize( $_prevstate );
					}
					$data = array(
						'translation_id'      => $trans->translation_id,
						'translation_package' => serialize( $translation_package ),
						'md5'                 => $md5,
					);

					//update only when something changed (we do not need to change status when deleting a field)
					if ( $needs_update ) {
						$data[ 'needs_update' ] = 1;
					}

					$update_result = $iclTranslationManagement->update_translation_status( $data );
					$rid           = $update_result[ 0 ];
					$this->update_icl_translate( $rid, $post );

					//change job status only when needs update
					if ( $needs_update ) {
						$job_id = $wpdb->get_var( $wpdb->prepare( "SELECT MAX(job_id) FROM {$wpdb->prefix}icl_translate_job WHERE rid=%d GROUP BY rid", $rid ) );
						if ( $job_id ) {
							$wpdb->update( "{$wpdb->prefix}icl_translate_job", array( 'translated' => 0 ), array( 'job_id' => $job_id ), array( '%d' ), array( '%d' ) );
						}
					}
				}
			}
		}
	}

	/**
	 * Functions to update translations when packages are modified in admin
	 *
	 * @param $rid
	 * @param $post
	 */

	function update_icl_translate( $rid, $post ) {

		global $wpdb;

		$job_id   = $wpdb->get_var( $wpdb->prepare( "SELECT MAX(job_id) FROM {$wpdb->prefix}icl_translate_job WHERE rid=%d GROUP BY rid", $rid ) );
		$elements = $wpdb->get_results( $wpdb->prepare( "SELECT field_type, field_data, tid, field_translate FROM {$wpdb->prefix}icl_translate
        												WHERE job_id=%d", $job_id ), OBJECT_K );

		foreach ( $post->string_data as $field_type => $field_value ) {
			$field_data = base64_encode( $field_value );
			if ( ! isset( $elements[ $field_type ] ) ) {
				//insert new field

				$data = array(
					'job_id'                => $job_id,
					'content_id'            => 0,
					'field_type'            => $field_type,
					'field_format'          => 'base64',
					'field_translate'       => 1,
					'field_data'            => $field_data,
					'field_data_translated' => 0,
					'field_finished'        => 0
				);

				$wpdb->insert( $wpdb->prefix . 'icl_translate', $data );
			} elseif ( $elements[ $field_type ]->field_data != $field_data ) {
				//update field value
				$wpdb->update( $wpdb->prefix . 'icl_translate', array( 'field_data' => $field_data, 'field_finished' => 0 ), array( 'tid' => $elements[ $field_type ]->tid ) );
			}
		}

		foreach ( $elements as $field_type => $el ) {
			//delete fields that are no longer present
			if ( $el->field_translate && ! isset( $post->string_data[ $field_type ] ) ) {
				$wpdb->delete( $wpdb->prefix . 'icl_translate', array( 'tid' => $el->tid ), array( '%d' ) );
			}
		}
	}

	private function get_package_details( $package_id ) {
		global $wpdb;
		static $cache = array();

		if ( ! isset( $cache[ $package_id ] ) ) {
			$item                 = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}icl_string_packages WHERE ID='%d'", $package_id ), ARRAY_A );
			$cache[ $package_id ] = $item;
		}

		return $cache[ $package_id ];
	}

	function get_string_context_title( $context, $string_details ) {
		global $wpdb;

		static $cache = array();

		if ( ! isset( $cache[ $context ] ) ) {
			$package_id = $wpdb->get_var( "SELECT string_package_id FROM {$wpdb->prefix}icl_strings WHERE id={$string_details['string_id']}" );
			if ( $package_id ) {
				$package_details = $this->get_package_details( $package_id );
				if ( $package_details ) {
					$cache[ $context ] = $package_details->kind . ' - ' . $package_details->title;
				} else {
					$cache[ $context ] = $context;
				}
			} else {
				$cache[ $context ] = $context;
			}
		}

		return $cache[ $context ];
	}

	function get_string_title( $title, $string_details ) {
		global $wpdb;

		$string_title = $wpdb->get_var( "SELECT title FROM {$wpdb->prefix}icl_strings WHERE id={$string_details['string_id']}" );
		if ( $string_title ) {
			return $string_title;
		} else {
			return $title;
		}
	}

	function _get_post_translations( $package ) {
		global $sitepress;

		if ( is_object( $package ) ) {
			$package = get_object_vars( $package );
		}

		$element_type = $this->get_package_element_type( $package[ 'kind_slug' ] );
		$trid         = $sitepress->get_element_trid( $package[ 'ID' ], $element_type );

		return $sitepress->get_element_translations( $trid, $element_type );
	}

	function _is_translation_in_progress( $package ) {
		global $wpdb;

		$post_translations = self::_get_post_translations( $package );

		foreach ( $post_translations as $lang => $translation ) {
			$res = $wpdb->get_row( "SELECT status, needs_update, md5 FROM {$wpdb->prefix}icl_translation_status WHERE translation_id={$translation->translation_id}" );
			if ( $res && $res->status == ICL_TM_IN_PROGRESS ) {
				return true;
			}
		}

		return false;
	}

	function _delete_translation_job( $package_id ) {
		global $wpdb;

		$package = $this->get_package_details( $package_id );

		$post_translations = $this->_get_post_translations( $package );
		foreach ( $post_translations as $lang => $translation ) {
			$rid = $wpdb->get_var( "SELECT rid FROM {$wpdb->prefix}icl_translation_status WHERE translation_id={$translation->translation_id}" );
			if ( $rid ) {
				$job_id = $wpdb->get_var( "SELECT job_id FROM {$wpdb->prefix}icl_translate_job WHERE rid={$rid}" );

				if ( $job_id ) {
					$wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translate_job WHERE job_id={$job_id}" );
					$wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translate WHERE job_id={$job_id}" );
				}
			}
		}
	}

	public function add_to_basket( $data ) {
		if ( isset( $data[ 'tr_action' ] ) ) {
			$posts_ids = TranslationProxy_Basket::get_elements_ids( $data, 'package' );

			foreach ( $posts_ids as $id ) {
				$post_id          = $id;
				$source_language  = $data[ 'translate_from' ];
				$target_languages = $data[ 'tr_action' ];
				foreach ( $target_languages as $translate_to => $translation_action ) {
					$package = new WPML_Package( $post_id );
					$tm      = new WPML_Package_TM( $package );
					$tm->add_package_to_basket( $translation_action, $source_language, $translate_to );
				}
			}
		}
	}

	function _no_wpml_warning() {
		?>

				<?php printf( __( 'WPML Package Translation is enabled but not effective. It requires WPML, String Translation and Translation Management in order to work.', 'wpml-string-translation' ), 'http://wpml.org/' ); ?>

	<?php
	}

	function send_jobs( $item_type_name, $item_type, $package_basket_items, $translators, $basket_name ) {
		if ( $item_type_name == 'package' ) {
			// for every post in cart
			// prepare data for send_jobs() and do it
			foreach ( $package_basket_items as $basket_item_id => $basket_item ) {
				$jobs_data                          = array();
				$jobs_data[ 'iclpost' ][ ]          = $basket_item_id;
				$jobs_data[ 'tr_action' ]           = $basket_item[ 'to_langs' ];
				$jobs_data[ 'translators' ]         = $translators;
				$jobs_data[ 'batch_name' ]          = $basket_name;
				$jobs_data[ 'element_type_prefix' ] = $item_type_name;
				do_action( 'wpml_tm_send_jobs', $jobs_data );
			}
		}
	}
}


text:
<?php namespace Fisharebest\Localization\Script;

class ScriptEthi extends AbstractScript implements ScriptInterface {
	public function code() {
		return 'Ethi';
	}

	public function number() {
		return '430';
	}

	public function unicodeName() {
		return 'Ethiopic';
	}
}


text:
FROM ubuntu:xenial

RUN apt-get update && apt-get install -y wget
RUN wget https://github.com/containerd/containerd/releases/download/v1.4.3/containerd-1.4.3-linux-amd64.tar.gz
RUN tar xvf containerd-1.4.3-linux-amd64.tar.gz


text:
using System;
using System.IO;

namespace TomP2P.Extensions.Workaround
{
    ///
    /// This class allows to write Java types to a byte[].
    /// Internally, a <see cref="BinaryWriter"/> is used.
    ///
    public class JavaBinaryWriter
    {
        private readonly BinaryWriter _bw;

        public JavaBinaryWriter(Stream output)
        {
            _bw = new BinaryWriter(output);
        }

        ///
        /// Writes a 2-byte short to the current stream and advances the stream position by 2 bytes.
        ///
        /// <param name="value"></param>
        public void WriteShort(short value)
        {
            // NOTE: _bw.Write(short) would write in little-endian fashion (.NET)

            // shift short bits to their position and cast to byte
            var b1 = (byte) (value >> 8);
            var b2 = (byte) value;

            // write bytes in big-endian fashion (Java)
            _bw.Write(b1);
            _bw.Write(b2);
        }

        ///
        /// Writes a 4-byte integer to the current stream and advances the stream position by 4 bytes.
        ///
        /// <param name="value"></param>
        public void WriteInt(int value)
        {
            // NOTE: _bw.Write(int) would write in little-endian fashion (.NET)

            // shift int bits to their position and cast to byte
            var b1 = (byte) (value >> 24);
            var b2 = (byte) (value >> 16);
            var b3 = (byte) (value >> 8);
            var b4 = (byte) value;

            // write bytes in big-endian fashion (Java)
            _bw.Write(b1);
            _bw.Write(b2);
            _bw.Write(b3);
            _bw.Write(b4);
        }

        public void WriteLong(long value)
        {
            // NOTE: _bw.Write(long) would write in little-endian fashion (.NET)

            // shift long bits to their position and cast to byte
            var b1 = (byte) (value >> 56);
            var b2 = (byte) (value >> 48);
            var b3 = (byte) (value >> 40);
            var b4 = (byte) (value >> 32);
            var b5 = (byte) (value >> 24);
            var b6 = (byte) (value >> 16);
            var b7 = (byte) (value >> 8);
            var b8 = (byte) value;

            // write bytes in big-endian fashion (Java)
            _bw.Write(b1);
            _bw.Write(b2);
            _bw.Write(b3);
            _bw.Write(b4);
            _bw.Write(b5);
            _bw.Write(b6);
            _bw.Write(b7);
            _bw.Write(b8);
        }

        public void WriteBytes(MemoryStream src, int readable)
        {
            src.CopyTo(_bw.BaseStream, readable); // TODO check if works
        }

        public void WriteByte(sbyte value)
        {
            // Java byte is signed
            _bw.Write(value);
        }

        public void WriteBytes(sbyte[] src)
        {
            // Java byte is signed
            for (int i = 0; i < src.Length; i++)
            {
                WriteByte(src[i]);
            }
        }

        ///
        /// Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.
        ///
        /// <param name="length"></param>
        public void WriteZero(int length)
        {
            for (int i = 0; i < length; i++) // TODO check if correct
            {
                WriteByte(0);
            }
        }

        public Stream BaseStream
        {
            get { return _bw.BaseStream; }
        }
    }
}


text:
var Marionette = require('backbone.marionette');

module.exports = SignUpView = Marionette.ItemView.extend({
    template: require('../../templates/signup.hbs'),
    events: {
        'click a.save-button': 'save'
    },

    save: function(e) {
        e.preventDefault();
        var newUser = {
            firstname: this.$el.find('#firstname').val(),
            lastname: this.$el.find('#lastname').val(),
            phone: this.$el.find('#phone').val(),
            email: this.$el.find('#email').val(),
            password: this.$el.find('#password').val()
        };

        window.App.data.users.create(newUser);
        window.App.core.vent.trigger('app:log', 'Sign Up View: Saved new user!');
        window.App.controller.home();
    }
});