text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.Environment.Descriptor;
using Orchard.FileSystems.AppData;
using Orchard.ImportExport.Models;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Recipes.Models;
using Orchard.Recipes.Services;
using VersionOptions = Orchard.ContentManagement.VersionOptions;

namespace Orchard.ImportExport.Services {
    [UsedImplicitly]
    public class ImportExportService : IImportExportService {
        private readonly IOrchardServices _orchardServices;
        private readonly IContentDefinitionManager _contentDefinitionManager;
        private readonly IContentDefinitionWriter _contentDefinitionWriter;
        private readonly IAppDataFolder _appDataFolder;
        private readonly IRecipeParser _recipeParser;
        private readonly IRecipeManager _recipeManager;
        private readonly IShellDescriptorManager _shellDescriptorManager;
        private const string ExportsDirectory = "Exports";

        public ImportExportService(
            IOrchardServices orchardServices,
            IContentDefinitionManager contentDefinitionManager,
            IContentDefinitionWriter contentDefinitionWriter,
            IAppDataFolder appDataFolder,
            IRecipeParser recipeParser,
            IRecipeManager recipeManager,
            IShellDescriptorManager shellDescriptorManager) {
            _orchardServices = orchardServices;
            _contentDefinitionManager = contentDefinitionManager;
            _contentDefinitionWriter = contentDefinitionWriter;
            _appDataFolder = appDataFolder;
            _recipeParser = recipeParser;
            _recipeManager = recipeManager;
            _shellDescriptorManager = shellDescriptorManager;
            Logger = NullLogger.Instance;
            T = NullLocalizer.Instance;
        }

        public Localizer T { get; set; }
        public ILogger Logger { get; set; }

        public void Import(string recipeText) {
            var recipe = _recipeParser.ParseRecipe(recipeText);
            CheckRecipeSteps(recipe);
            _recipeManager.Execute(recipe);
            UpdateShell();
        }

        public string Export(IEnumerable<string> contentTypes, ExportOptions exportOptions) {
            var exportDocument = CreateExportRoot();

            if (exportOptions.ExportMetadata) {
                exportDocument.Element("Orchard").Add(ExportMetadata(contentTypes));
            }

            if (exportOptions.ExportSiteSettings) {
                exportDocument.Element("Orchard").Add(ExportSiteSettings());
            }

            if (exportOptions.ExportData) {
                exportDocument.Element("Orchard").Add(ExportData(contentTypes, exportOptions.VersionHistoryOptions));
            }

            return WriteExportFile(exportDocument.ToString());
        }

        private XDocument CreateExportRoot() {
            var exportRoot = new XDocument(
                new XDeclaration("1.0", "", "yes"),
                new XComment("Exported from Orchard"),
                new XElement("Orchard",
                             new XElement("Recipe",
                                          new XElement("Name", "Generated by Orchard.ImportExport"),
                                          new XElement("Author", _orchardServices.WorkContext.CurrentUser.UserName)
                                 )
                    )
                );
            return exportRoot;
        }

        private XElement ExportMetadata(IEnumerable<string> contentTypes) {
            var typesElement = new XElement("Types");
            var partsElement = new XElement("Parts");
            var typesToExport = _contentDefinitionManager.ListTypeDefinitions()
                .Where(typeDefinition => contentTypes.Contains(typeDefinition.Name))
                .ToList();
            var partsToExport = new List<string>();

            foreach (var contentTypeDefinition in typesToExport) {
                foreach (var contentPartDefinition in contentTypeDefinition.Parts) {
                    if (partsToExport.Contains(contentPartDefinition.PartDefinition.Name)) {
                        continue;
                    }
                    partsToExport.Add(contentPartDefinition.PartDefinition.Name);
                    partsElement.Add(_contentDefinitionWriter.Export(contentPartDefinition.PartDefinition));
                }
                typesElement.Add(_contentDefinitionWriter.Export(contentTypeDefinition));
            }

            return new XElement("Metadata", typesElement, partsElement);
        }

        private XElement ExportSiteSettings() {
            var settings = new XElement("Settings");
            var hasSetting = false;

            foreach (var sitePart in _orchardServices.WorkContext.CurrentSite.ContentItem.Parts) {
                var setting = new XElement(sitePart.PartDefinition.Name);

                foreach (var property in sitePart.GetType().GetProperties()) {
                    var propertyType = property.PropertyType;
                    // Supported types (we also know they are not indexed properties).
                    if (propertyType == typeof(string) || propertyType == typeof(bool) || propertyType == typeof(int)) {
                        // Exclude read-only properties.
                        if (property.GetSetMethod() != null) {
                            setting.SetAttributeValue(property.Name, property.GetValue(sitePart, null));
                            hasSetting = true;
                        }
                    }
                }

                if (hasSetting) {
                    settings.Add(setting);
                    hasSetting = false;
                }
            }

            return settings;
        }

        private XElement ExportData(IEnumerable<string> contentTypes, VersionHistoryOptions versionHistoryOptions) {
            var data = new XElement("Data");
            var options = GetContentExportVersionOptions(versionHistoryOptions);

            var contentItems = _orchardServices.ContentManager.Query(options).List();

            foreach (var contentType in contentTypes) {
                var type = contentType;
                var items = contentItems.Where(i => i.ContentType == type);
                foreach (var contentItem in items) {
                    var contentItemElement = ExportContentItem(contentItem);
                    if (contentItemElement != null)
                        data.Add(contentItemElement);
                }
            }

            return data;
        }

        private XElement ExportContentItem(ContentItem contentItem) {
            // Call export handler for the item.
            return _orchardServices.ContentManager.Export(contentItem);
        }

        private static VersionOptions GetContentExportVersionOptions(VersionHistoryOptions versionHistoryOptions) {
            if (versionHistoryOptions.HasFlag(VersionHistoryOptions.Draft)) {
                return VersionOptions.Draft;
            }
            return VersionOptions.Published;
        }

        private string WriteExportFile(string exportDocument) {
            var exportFile = string.Format("Export-{0}-{1}.xml", _orchardServices.WorkContext.CurrentUser.UserName, DateTime.UtcNow.Ticks);
            if (!_appDataFolder.DirectoryExists(ExportsDirectory)) {
                _appDataFolder.CreateDirectory(ExportsDirectory);
            }

            var path = _appDataFolder.Combine(ExportsDirectory, exportFile);
            _appDataFolder.CreateFile(path, exportDocument);

            return _appDataFolder.MapPath(path);
        }

        private void CheckRecipeSteps(Recipe recipe) {
            foreach (var step in recipe.RecipeSteps) {
                switch (step.Name) {
                    case "Metadata":
                    case "Settings":
                    case "Data":
                        break;
                    default:
                        throw new InvalidOperationException(T("Step {0} is not a supported import step.", step.Name).Text);
                }
            }
        }

        private void UpdateShell() {
            var descriptor = _shellDescriptorManager.GetShellDescriptor();
            _shellDescriptorManager.UpdateShellDescriptor(descriptor.SerialNumber, descriptor.Features, descriptor.Parameters);
        }
    }
}


text:
function calc_total(){
    var sum = 0;
    $('.input-amount').each(function(){
        sum += parseFloat($(this).text());
    });
    $(".preview-total").text(sum);
}
$(document).on('click', '.input-remove-row', function(){
    var tr = $(this).closest('tr');
    tr.fadeOut(200, function(){
    	tr.remove();
	   	calc_total()
	});
});

$(function(){
    $('.preview-add-button').click(function(){
        var form_data = {};
        form_data["concept"] = $('.payment-form input[name="concept"]').val();
        form_data["description"] = $('.payment-form input[name="description"]').val();
        form_data["amount"] = parseFloat($('.payment-form input[name="amount"]').val()).toFixed(2);
        form_data["status"] = $('.payment-form #status option:selected').text();
        form_data["date"] = $('.payment-form input[name="date"]').val();
        form_data["remove-row"] = '';
        var row = $('

');
        $.each(form_data, function( type, value ) {
            $('	').html(value).appendTo(row);
        });
        $('.preview-table > tbody:last').append(row);
        calc_total();
    });
});

redpajama_set_name: RedPajamaGithub


text:
<component name="libraryTable">
  <library name="adapters-1.2.1">
    <CLASSES>
      <root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.databinding/adapters/1.2.1/jars/classes.jar!/" />
      <root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.databinding/adapters/1.2.1/res" />
    </CLASSES>
    <JAVADOC />
    <SOURCES>
      <root url="jar://D:/adt-bundle-windows-x86_64-20140702/sdk/extras/android/m2repository/com/android/databinding/adapters/1.2.1/adapters-1.2.1-sources.jar!/" />
    </SOURCES>
  </library>
</component>


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<TITLE
>TAP Tests</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.6.2 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Regression Tests"
HREF="regress.html"><LINK
REL="PREVIOUS"
TITLE="Variant Comparison Files"
HREF="regress-variant.html"><LINK
REL="NEXT"
TITLE="Test Coverage Examination"
HREF="regress-coverage.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2017-02-06T21:56:32">

PostgreSQL 9.6.2 Documentation

Prev	Up	Chapter 31. Regression Tests	Next

31.4. TAP Tests

    The client program tests under <TT
CLASS="FILENAME"
>src/bin</TT
> use the Perl
    TAP tools and are run by <TT
CLASS="COMMAND"
>prove</TT
>.  You can pass
    command-line options to <TT
CLASS="COMMAND"
>prove</TT
> by setting
    the <TT
CLASS="COMMAND"
>make</TT
> variable <TT
CLASS="VARNAME"
>PROVE_FLAGS</TT
>, for example:

make -C src/bin check PROVE_FLAGS='--reverse'

    The default is <TT
CLASS="LITERAL"
>--verbose</TT
>.  See the manual page
    of <TT
CLASS="COMMAND"
>prove</TT
> for more information.

    The tests written in Perl require the Perl
    module <TT
CLASS="LITERAL"
>IPC::Run</TT
>.
    This module is available from CPAN or an operating system package.

Prev	Home	Next

Variant Comparison Files	Up	Test Coverage Examination


text:
<?php

namespace lithium\net\socket;

use lithium\core\NetworkException;

/**
 * A PHP stream-based socket adapter.
 *
 * This stream adapter provides the required method implementations of the abstract `Socket` class
 * for the `open()`, `close()`, `read()`, `write()`, `timeout()` `eof()` and `encoding()` methods.
 *
 * @link http://www.php.net/manual/en/book.stream.php PHP Manual: Streams
 * @see lithium\net\socket\Stream
 */
class Stream extends \lithium\net\Socket {

	/**
	 * Opens a socket and initializes the internal resource handle.
	 *
	 * @param array $options update the config settings
	 * @return mixed Returns `false` if the socket configuration does not contain the
	 *         `'scheme'` or `'host'` settings, or if configuration fails, otherwise returns a
	 *         resource stream. Throws exception if there is a network error.
	 */
	public function open(array $options = array()) {
		parent::open($options);
		$config = $this->_config;

		if (!$config['scheme'] || !$config['host']) {
			return false;
		}
		$scheme = ($config['scheme'] !== 'udp') ? 'tcp' : 'udp';
		$port = $config['port'] ?: 80;
		$host = "{$scheme}://{$config['host']}:{$port}";
		$flags = STREAM_CLIENT_CONNECT;

		if ($config['persistent']) {
			$flags = STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT;
		}
		$this->_resource = stream_socket_client(
			$host, $errorCode, $errorMessage, $config['timeout'], $flags
		);
		if ($errorCode || $errorMessage) {
			throw new NetworkException($errorMessage);
		}
		$this->timeout($config['timeout']);

		if (!empty($config['encoding'])) {
			$this->encoding($config['encoding']);
		}
		return $this->_resource;
	}

	/**
	 * Closes the stream
	 *
	 * @return boolean True on closed connection
	 */
	public function close() {
		if (!is_resource($this->_resource)) {
			return true;
		}
		fclose($this->_resource);

		if (is_resource($this->_resource)) {
			$this->close();
		}
		return true;
	}

	/**
	 * Determines if the socket resource is at EOF.
	 *
	 * @return boolean Returns `true` if resource pointer is at its EOF, `false` otherwise.
	 */
	public function eof() {
		return is_resource($this->_resource) ? feof($this->_resource) : true;
	}

	/**
	 * Reads data from the stream resource
	 *
	 * @param integer $length If specified, will read up to $length bytes from the stream.
	 *        If no value is specified, all remaining bytes in the buffer will be read.
	 * @param integer $offset Seek to the specified byte offset before reading.
	 * @return string Returns string read from stream resource on success, false otherwise.
	 */
	public function read($length = null, $offset = null) {
		if (!is_resource($this->_resource)) {
			return false;
		}
		if (!$length) {
			return stream_get_contents($this->_resource);
		}
		return stream_get_contents($this->_resource, $length, $offset);
	}

	/**
	 * writes data to the stream resource
	 *
	 * @param string $data The string to be written.
	 * @return mixed False on error, number of bytes written otherwise.
	 */
	public function write($data = null) {
		if (!is_resource($this->_resource)) {
			return false;
		}
		if (!is_object($data)) {
			$data = $this->_instance($this->_classes['request'], (array) $data + $this->_config);
		}
		return fwrite($this->_resource, (string) $data, strlen((string) $data));
	}

	/**
	 * Set timeout period on a stream.
	 *
	 * @link http://www.php.net/manual/en/function.stream-set-timeout.php
	 *       PHP Manual: stream_set_timeout()
	 * @param integer $time The timeout value in seconds.
	 * @return void
	 */
	public function timeout($time) {
		if (!is_resource($this->_resource)) {
			return false;
		}
		return stream_set_timeout($this->_resource, $time);
	}

	/**
	 * Sets the character set for stream encoding
	 *
	 * Note: This function only exists in PHP 6. For PHP < 6, this method will return void.
	 *
	 * @link http://www.php.net/manual/en/function.stream-encoding.php stream_encoding()
	 * @param string $charset
	 * @return mixed Returns `null` if `stream_encoding()` function does not exist, boolean
	 *         result of `stream_encoding()` otherwise.
	 */
	public function encoding($charset) {
		if (!function_exists('stream_encoding')) {
			return false;
		}
		return is_resource($this->_resource) ? stream_encoding($this->_resource, $charset) : false;
	}
}

?>


text:
package com.opengamma.analytics.math.regression;

import org.apache.commons.math.distribution.ContinuousDistribution;
import org.apache.commons.math.distribution.TDistributionImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cern.colt.matrix.DoubleFactory1D;
import cern.colt.matrix.DoubleFactory2D;
import cern.colt.matrix.DoubleMatrix1D;
import cern.colt.matrix.DoubleMatrix2D;
import cern.colt.matrix.linalg.Algebra;

/**
 *
 */
public class WeightedLeastSquaresRegression extends LeastSquaresRegression {
  private static final Logger LOGGER = LoggerFactory.getLogger(WeightedLeastSquaresRegression.class);
  private final Algebra _algebra = new Algebra();

  @Override
  public LeastSquaresRegressionResult regress(final double[][] x, final double[][] weights, final double[] y, final boolean useIntercept) {
    if (weights == null) {
      throw new IllegalArgumentException("Cannot perform WLS regression without an array of weights");
    }
    checkData(x, weights, y);
    LOGGER
    .info(
        "Have a two-dimensional array for what should be a one-dimensional array of weights. The weights used in this "
            + "regression will be the diagonal elements only");
    final double[] w = new double[weights.length];
    for (int i = 0; i < w.length; i++) {
      w[i] = weights[i][i];
    }
    return regress(x, w, y, useIntercept);
  }

  public LeastSquaresRegressionResult regress(final double[][] x, final double[] weights, final double[] y, final boolean useIntercept) {
    if (weights == null) {
      throw new IllegalArgumentException("Cannot perform WLS regression without an array of weights");
    }
    checkData(x, weights, y);
    final double[][] dep = addInterceptVariable(x, useIntercept);
    final double[] indep = new double[y.length];
    final double[] w = new double[weights.length];
    for (int i = 0; i < y.length; i++) {
      indep[i] = y[i];
      w[i] = weights[i];
    }
    final DoubleMatrix2D matrix = DoubleFactory2D.dense.make(dep);
    final DoubleMatrix1D vector = DoubleFactory1D.dense.make(indep);
    final DoubleMatrix2D wDiag = DoubleFactory2D.sparse.diagonal(DoubleFactory1D.dense.make(w));
    final DoubleMatrix2D transpose = _algebra.transpose(matrix);
    final DoubleMatrix1D betasVector = _algebra
        .mult(_algebra.mult(_algebra.mult(_algebra.inverse(_algebra.mult(transpose, _algebra.mult(wDiag, matrix))), transpose), wDiag), vector);
    final double[] yModel = convertArray(_algebra.mult(matrix, betasVector).toArray());
    final double[] betas = convertArray(betasVector.toArray());
    return getResultWithStatistics(x, convertArray(wDiag.toArray()), y, betas, yModel, transpose, matrix, useIntercept);
  }

  private LeastSquaresRegressionResult getResultWithStatistics(final double[][] x, final double[][] w, final double[] y, final double[] betas,
      final double[] yModel, final DoubleMatrix2D transpose, final DoubleMatrix2D matrix, final boolean useIntercept) {
    double yMean = 0.;
    for (final double y1 : y) {
      yMean += y1;
    }
    yMean /= y.length;
    double totalSumOfSquares = 0.;
    double errorSumOfSquares = 0.;
    final int n = x.length;
    final int k = betas.length;
    final double[] residuals = new double[n];
    final double[] standardErrorsOfBeta = new double[k];
    final double[] tStats = new double[k];
    final double[] pValues = new double[k];
    for (int i = 0; i < n; i++) {
      totalSumOfSquares += w[i][i] * (y[i] - yMean) * (y[i] - yMean);
      residuals[i] = y[i] - yModel[i];
      errorSumOfSquares += w[i][i] * residuals[i] * residuals[i];
    }
    final double regressionSumOfSquares = totalSumOfSquares - errorSumOfSquares;
    final double[][] covarianceBetas = convertArray(_algebra.inverse(_algebra.mult(transpose, matrix)).toArray());
    final double rSquared = regressionSumOfSquares / totalSumOfSquares;
    final double adjustedRSquared = 1. - (1 - rSquared) * (n - 1) / (n - k);
    final double meanSquareError = errorSumOfSquares / (n - k);
    final ContinuousDistribution studentT = new TDistributionImpl(n - k);
    for (int i = 0; i < k; i++) {
      standardErrorsOfBeta[i] = Math.sqrt(meanSquareError * covarianceBetas[i][i]);
      tStats[i] = betas[i] / standardErrorsOfBeta[i];
      try {
        pValues[i] = 1 - studentT.cumulativeProbability(Math.abs(tStats[i]));
      } catch (final org.apache.commons.math.MathException e) {
        throw new com.opengamma.analytics.math.MathException(e);
      }
    }
    return new WeightedLeastSquaresRegressionResult(betas, residuals, meanSquareError, standardErrorsOfBeta, rSquared, adjustedRSquared, tStats, pValues,
        useIntercept);
  }
}


text:
package org.hibernate.engine;

import java.util.Iterator;

import org.hibernate.JDBCException;

/**
 * Hibernate-specific iterator that may be closed
 *
 * @see org.hibernate.Query#iterate()
 * @see org.hibernate.Hibernate#close(java.util.Iterator)
 *
 * @author Gavin King
 */
public interface HibernateIterator extends Iterator {
	/**
	 * Close the Hibernate query result iterator
	 *
	 * @throws JDBCException Indicates a problem releasing the underlying JDBC resources.
	 */
	public void close() throws JDBCException;
}


text:
title: GHA Conference 2013
subtitle: Poster
layout: default
modal-id: 1
date: 2013-02-15
img: GHAPoster2013.png
thumbnail: GHAPoster2013-thumbnail.png
alt: image-alt
project-date: February 2013
client: Graduate History Association
categories: Design
description: Poster for GHA Annual Conference. Theme was New Approaches to History. Made in Photoshop.
---


text:
<?php
class KVDthes_TermTest extends PHPUnit_Framework_TestCase
{
    /**
     * @var    KVDthes_Term
     * @access protected
     */
    protected $object;

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     *
     * @access protected
     */
    protected function setUp()
    {
        $this->sessie = $this->getMock( 'KVDthes_Sessie' );
        $termType = new KVDthes_TermType( 'PT', 'voorkeursterm' );
        $this->object = new KVDthes_TestTerm( 507, $this->sessie, 'kapellen', $termType, 'klein erfgoed');
    }

    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     *
     * @access protected
     */
    protected function tearDown()
    {
        $this->sessie = null;
        $this->object = null;
    }

    public function testLoadState() {
        $this->assertTrue( $this->object->isLoadState( KVDthes_Term::LS_TERM ) );
        $this->assertFalse( $this->object->isLoadState( KVDthes_Term::LS_REL ) );
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->assertTrue( $this->object->isLoadState( KVDthes_Term::LS_REL ) );
    }

    public function testIsNull( )
    {
        $this->assertFalse( $this->object->isNull( ) );
        $niets = KVDthes_TestTerm::newNull( );
        $this->assertTrue( $niets->isNull( ) );
    }

    public function testGetTerm() {
        $this->assertEquals( 'kapellen', $this->object->getTerm( ) );
    }

    public function testSetTerm( )
    {
        $this->object->setLoadState( KVDthes_Term::LS_NOTES );
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->object->setLoadState( KVDthes_Term::LS_MATCH );
        $this->object->setTerm( 'klootschieten' );
        $this->assertEquals( 'klootschieten', $this->object->getTerm( ) );
    }

    public function testGetQualifier() {
        $this->assertEquals( 'klein erfgoed', $this->object->getQualifier( ) );
    }

    public function testSetQualifier( )
    {
        $this->object->setLoadState( KVDthes_Term::LS_NOTES );
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->object->setLoadState( KVDthes_Term::LS_MATCH );
        $this->object->setQualifier( 'groot erfgoed' );
        $this->assertEquals( 'groot erfgoed', $this->object->getQualifier( ) );
    }

    public function testGetQualifiedTerm( ) {
        $this->assertEquals( 'kapellen (klein erfgoed)', $this->object->getQualifiedTerm( ) );
    }

    public function testGetId() {
        $this->assertEquals( 507 , $this->object->getId( ) );
    }

    public function testSetType( )
    {
        $this->object->setLoadState( KVDthes_Term::LS_NOTES );
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->object->setLoadState( KVDthes_Term::LS_MATCH );
        $this->object->setType( new KVDthes_TermType( 'ND', 'Non-Descriptor' ) );
        $this->assertEquals( 'ND', $this->object->getType()->getId( ) );
    }

    public function testGetLanguage() {
        $this->assertEquals( 'nl-BE', $this->object->getLanguage( ) );
    }

    public function testSetLanguage( )
    {
        $this->object->setLoadState( KVDthes_Term::LS_NOTES );
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->object->setLoadState( KVDthes_Term::LS_MATCH );
        $this->object->setLanguage( 'en-US' );
        $this->assertEquals( 'en-US', $this->object->getLanguage( ) );
    }

    public function testGetClass() {
        $this->assertEquals( 'KVDthes_TestTerm', $this->object->getClass( ) );
    }

    public function testGetOmschrijving() {
        $this->assertEquals( 'kapellen (klein erfgoed)', $this->object->getOmschrijving( ) );
    }

    public function test__toString() {
        $this->assertEquals( 'kapellen (klein erfgoed)', $this->object->__toString( ) );
    }

    public function testSetSortKey( )
    {
        $this->object->setLoadState( KVDthes_Term::LS_NOTES );
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->object->setLoadState( KVDthes_Term::LS_MATCH );
        $this->object->setSortKey( 'aaa' );
        $this->assertEquals( 'aaa', $this->object->getSortKey( ) );
    }

    public function testHasBTRelations(  )
    {
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->assertFalse( $this->object->hasBTRelations( ) );
        $this->assertEquals( $this->object->hasBTRelations( ), $this->object->hasBT( ) );
    }

    public function testPreferredTerm( )
    {
        $termType = new KVDthes_TermType( 'PT', 'voorkeursterm' );
        $term2 = new KVDthes_TestTerm( 508, $this->sessie, 'kapellen', $termType, 'bouwkundig erfgoed' );
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->object->setLoadState( KVDthes_Term::LS_MATCH );
        $this->object->setLoadState( KVDthes_Term::LS_NOTES );
        $term2->setLoadState( KVDthes_Term::LS_REL );
        $term2->setLoadState( KVDthes_Term::LS_MATCH );
        $term2->setLoadState( KVDthes_Term::LS_NOTES );
        $this->object->setType( new KVDthes_TermType( 'ND', 'Non Descriptor' ) );
        $this->object->setPreferredTerm( $term2  );
        $this->assertTrue( $term2->isPreferredTerm( ) );
        $this->assertEquals( $term2, $this->object->getPreferredTerm( ) );
        $this->assertEquals( $term2, $term2->getPreferredTerm( ) );
    }

    public function testAddRemoveRelation( )
    {
        $termType = new KVDthes_TermType( 'PT', 'voorkeursterm' );
        $term2 = new KVDthes_TestTerm( 508, $this->sessie, 'kapellen', $termType, 'bouwkundig erfgoed' );
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->object->setLoadState( KVDthes_Term::LS_MATCH );
        $this->object->setLoadState( KVDthes_Term::LS_NOTES );
        $term2->setLoadState( KVDthes_Term::LS_REL );
        $term2->setLoadState( KVDthes_Term::LS_MATCH );
        $term2->setLoadState( KVDthes_Term::LS_NOTES );
        $this->object->setType( new KVDthes_TermType( 'ND', 'Non Descriptor' ) );
        $this->object->addRelation( new KVDthes_Relation( KVDthes_Relation::REL_USE, $term2 ) );
        $this->assertEquals( $term2, $this->object->getPreferredTerm( ) );
        $term2->removeRelation( new KVDthes_Relation( KVDthes_Relation::REL_UF, $this->object ) );
        $this->assertEquals( $term2, $term2->getPreferredTerm( ) );
    }

    public function testClearRelation( )
    {
        $termType = new KVDthes_TermType( 'PT', 'voorkeursterm' );
        $term2 = new KVDthes_TestTerm( 508, $this->sessie, 'kapellen', $termType, 'bouwkundig erfgoed' );
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->object->setLoadState( KVDthes_Term::LS_MATCH );
        $this->object->setLoadState( KVDthes_Term::LS_NOTES );
        $term2->setLoadState( KVDthes_Term::LS_REL );
        $term2->setLoadState( KVDthes_Term::LS_MATCH );
        $term2->setLoadState( KVDthes_Term::LS_NOTES );
        $this->object->setType( new KVDthes_TermType( 'ND', 'Non Descriptor' ) );
        $this->object->addRelation( new KVDthes_Relation( KVDthes_Relation::REL_USE, $term2 ) );
        $this->assertEquals( 1, count( $this->object->getRelations( ) ) );
        $this->object->clearRelations( );
        $this->assertEquals( 0, count( $this->object->getRelations( ) ) );
    }

    public function testLoadRelation( )
    {
        $termType = new KVDthes_TermType( 'PT', 'voorkeursterm' );
        $term2 = new KVDthes_TestTerm( 508, $this->sessie, 'kapellen', $termType, 'bouwkundig erfgoed' );
        $this->object->loadRelation( new KVDthes_Relation(KVDthes_Relation::REL_RT, $term2 ));
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->object->setLoadState( KVDthes_Term::LS_MATCH );
        $term2->setLoadState( KVDthes_Term::LS_REL );
        $this->assertEquals( 1, count( $this->object->getRelations( ) ) );
        $this->assertEquals( 1, count( $term2->getRelations( ) ) );
    }

    public function testNotes( )
    {
        $this->object->setLoadState( KVDthes_Term::LS_NOTES );
        $this->object->setLoadState( KVDthes_Term::LS_REL );
        $this->object->setLoadState( KVDthes_Term::LS_MATCH );
        $this->object->setScopeNote( 'SN' );
        $this->object->setHistoryNote( 'HN' );
        $this->object->setIndexingNote( 'IN' );
        $this->object->setSourceNote( 'SoN' );
        $this->assertEquals( 'SN', $this->object->getScopeNote( ) );
        $this->assertEquals( 'HN', $this->object->getHistoryNote( ) );
        $this->assertEquals( 'IN', $this->object->getIndexingNote( ) );
        $this->assertEquals( 'SoN', $this->object->getSourceNote( ) );
    }
}
?>


text:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.UI;
using DotNetNuke.Common;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Modules.NavigationProvider;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.UI;
using DotNetNuke.UI.Containers;
using DotNetNuke.UI.WebControls;
using DotNetNuke.Web.DDRMenu.DNNCommon;
using DotNetNuke.Web.DDRMenu.TemplateEngine;

namespace DotNetNuke.Web.DDRMenu
{
	public class Actions : ActionBase
	{
		public string PathSystemScript { get; set; }

		public string MenuStyle { get; set; }

		[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
		[PersistenceMode(PersistenceMode.InnerProperty)]
		public List<ClientOption> ClientOptions { get; set; }

		[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
		[PersistenceMode(PersistenceMode.InnerProperty)]
		public List<TemplateArgument> TemplateArguments { get; set; }

		private DDRMenuNavigationProvider navProvider;
		private Dictionary<int, ModuleAction> actions;

		protected override void OnInit(EventArgs e)
		{
			using (new DNNContext(this))
			{
				base.OnInit(e);

				navProvider = (DDRMenuNavigationProvider)NavigationProvider.Instance("DDRMenuNavigationProvider");
				navProvider.ControlID = "ctl" + ID;
				navProvider.MenuStyle = MenuStyle;
				navProvider.Initialize();

				Controls.Add(navProvider.NavigationControl);
			}
		}

		protected override void OnLoad(EventArgs e)
		{
			using (new DNNContext(this))
			{
				base.OnLoad(e);

				SetMenuDefaults();
			}
		}

		protected override void OnPreRender(EventArgs e)
		{
			using (new DNNContext(this))
			{
				base.OnPreRender(e);

				try
				{
					navProvider.TemplateArguments = TemplateArguments;
					BindMenu(Navigation.GetActionNodes(ActionRoot, this, -1));
				}
				catch (Exception exc)
				{
					Exceptions.ProcessModuleLoadException(this, exc);
				}
			}
		}

		private void BindMenu(DNNNodeCollection objNodes)
		{
			Visible = DisplayControl(objNodes);
			if (!Visible)
			{
				return;
			}

			navProvider.ClearNodes();
			foreach (DNNNode node in objNodes)
			{
				ProcessNode(node);
			}
			navProvider.Bind(objNodes, false);
		}

		private void ActionClick(NavigationEventArgs args)
		{
			using (new DNNContext(this))
			{
				try
				{
					ProcessAction(args.ID);
				}
				catch (Exception exc)
				{
					Exceptions.ProcessModuleLoadException(this, exc);
				}
			}
		}

		private void AddActionIDs(ModuleAction action)
		{
			if (!actions.ContainsKey(action.ID))
			{
				actions.Add(action.ID, action);
			}
			if (action.HasChildren())
			{
				foreach (ModuleAction a in action.Actions)
				{
					AddActionIDs(a);
				}
			}
		}

		private ModuleAction FindAction(int id)
		{
			if (actions == null)
			{
				actions = new Dictionary<int, ModuleAction>();
				AddActionIDs(ActionRoot);
			}

			ModuleAction result;
			return actions.TryGetValue(id, out result) ? result : null;
		}

		private void ProcessNode(DNNNode dnnNode)
		{
			if (!dnnNode.IsBreak)
			{
				var action = FindAction(Convert.ToInt32(dnnNode.Key));
				if (action != null)
				{
					dnnNode.set_CustomAttribute("CommandName", action.CommandName);
					dnnNode.set_CustomAttribute("CommandArgument", action.CommandArgument);
				}
			}

			if (!String.IsNullOrEmpty(dnnNode.JSFunction))
			{
				dnnNode.JSFunction = string.Format(
					"if({0}){{{1}}};",
					dnnNode.JSFunction,
					Page.ClientScript.GetPostBackEventReference(navProvider.NavigationControl, dnnNode.ID));
			}

			foreach (DNNNode node in dnnNode.DNNNodes)
			{
				ProcessNode(node);
			}
		}

		private void SetMenuDefaults()
		{
			try
			{
				navProvider.StyleIconWidth = 15M;
				navProvider.MouseOutHideDelay = 500M;
				navProvider.MouseOverAction = NavigationProvider.HoverAction.Expand;
				navProvider.MouseOverDisplay = NavigationProvider.HoverDisplay.None;
				navProvider.CSSControl = "ModuleTitle_MenuBar";
				navProvider.CSSContainerRoot = "ModuleTitle_MenuContainer";
				navProvider.CSSNode = "ModuleTitle_MenuItem";
				navProvider.CSSIcon = "ModuleTitle_MenuIcon";
				navProvider.CSSContainerSub = "ModuleTitle_SubMenu";
				navProvider.CSSBreak = "ModuleTitle_MenuBreak";
				navProvider.CSSNodeHover = "ModuleTitle_MenuItemSel";
				navProvider.CSSIndicateChildSub = "ModuleTitle_MenuArrow";
				navProvider.CSSIndicateChildRoot = "ModuleTitle_RootMenuArrow";
				navProvider.PathImage = Globals.ApplicationPath + "/Images/";
				navProvider.PathSystemImage = Globals.ApplicationPath + "/Images/";
				navProvider.IndicateChildImageSub = "action_right.gif";
				navProvider.IndicateChildren = true;
				navProvider.StyleRoot = "background-color: Transparent; font-size: 1pt;";
				navProvider.NodeClick += ActionClick;
			}
			catch (Exception exc)
			{
				Exceptions.ProcessModuleLoadException(this, exc);
			}
		}
	}
}


text:
    <button type="button" class="close" ng-click="cancel()" >
      ×Close
    </button>

New resource

    <form ng-submit="add()">

          Name:
          <input ng-model="resource.name" name="name" type="text" class="form-control">

          Description:
          <textarea ng-model="resource.description" name="description" class="form-control" rows="3"></textarea>

          URL:
          <input ng-model="resource.url" name="name" type="url" class="form-control">

      <button type="button" ng-click="cancel()" class="btn btn-default">Close</button>
      <input type="submit" class="btn btn-primary" value="Add">

  </form>


text:
from django.conf.urls import *
from models import *
from views import *
from resources import *

urlpatterns = patterns('',
    (r'^accounts/', include('registration.urls')),
)