Commits

sembrestels committed 1fee1c8

Added freelicences module.

Comments (0)

Files changed (15)

elgg/mod/freelicenses/actions/file/upload.php

+<?php
+	/**
+	 * Elgg file browser uploader/edit action
+	 * 
+	 * @package ElggFile
+	 */
+
+	global $CONFIG;
+
+	gatekeeper();
+	
+	// Get variables
+	$title = get_input("title");
+	$desc = get_input("description");
+	$access_id = (int) get_input("access_id");
+	$container_guid = (int) get_input('container_guid', 0);
+	if ($container_guid == 0) {
+		$container_guid = get_loggedin_userid();
+	}
+	$guid = (int) get_input('file_guid');
+	$tags = get_input("tags");
+	$license = get_input("license");
+	
+	// check whether this is a new file or an edit
+	$new_file = true;
+	if ($guid > 0) {
+		$new_file = false;
+	}
+	
+	if ($new_file) {
+		// must have a file if a new file upload
+		if (empty($_FILES['upload']['name'])) {
+			// cache information in session
+			$_SESSION['uploadtitle'] = $title;
+			$_SESSION['uploaddesc'] = $desc;
+			$_SESSION['uploadtags'] = $tags;
+			$_SESSION['uploadaccessid'] = $access_id;
+			
+			register_error(elgg_echo('file:nofile'));
+			forward($_SERVER['HTTP_REFERER']);
+		}
+		
+		$file = new FilePluginFile();
+		$file->subtype = "file";
+		
+		// if no title on new upload, grab filename
+		if (empty($title)) {
+			$title = $_FILES['upload']['name'];
+		}
+	
+	} else {
+		// load original file object
+		$file = get_entity($guid);
+		if (!$file) {
+			register_error(elgg_echo('file:cannotload'));
+			forward($_SERVER['HTTP_REFERER']);
+		}
+		
+		// user must be able to edit file
+		if (!$file->canEdit()) {
+			register_error(elgg_echo('file:noaccess'));
+			forward($_SERVER['HTTP_REFERER']);
+		}
+	}
+	
+	$file->title = $title;
+	$file->description = $desc;
+	$file->access_id = $access_id;
+	$file->container_guid = $container_guid;
+	
+	$tags = explode(",", $tags);
+	$file->tags = $tags;
+	$file->license = $license;
+	
+	// we have a file upload, so process it
+	if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) {
+		
+		$prefix = "file/";
+		
+		// if previous file, delete it
+		if ($new_file == false) {
+			$filename = $file->getFilenameOnFilestore();
+			if (file_exists($filename)) {
+				unlink($filename);
+			}
+
+			// use same filename on the disk - ensures thumbnails are overwritten
+			$filestorename = $file->getFilename();
+			$filestorename = elgg_substr($filestorename, elgg_strlen($prefix));
+		} else {
+			$filestorename = elgg_strtolower(time().$_FILES['upload']['name']);
+		}
+		
+		$file->setFilename($prefix.$filestorename);
+		$file->setMimeType($_FILES['upload']['type']);
+		$file->originalfilename = $_FILES['upload']['name'];
+		$file->simpletype = get_general_file_type($_FILES['upload']['type']);
+
+		// Open the file to guarantee the directory exists
+		$file->open("write");
+		$file->close();
+		// move using built in function to allow large files to be uploaded
+		move_uploaded_file($_FILES['upload']['tmp_name'], $file->getFilenameOnFilestore());
+		
+		$guid = $file->save();
+		
+		// if image, we need to create thumbnails (this should be moved into a function)
+		if ($guid && $file->simpletype == "image") {
+			$thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),60,60, true);
+			if ($thumbnail) {
+				$thumb = new ElggFile();
+				$thumb->setMimeType($_FILES['upload']['type']);
+				
+				$thumb->setFilename($prefix."thumb".$filestorename);
+				$thumb->open("write");
+				$thumb->write($thumbnail);
+				$thumb->close();
+				
+				$file->thumbnail = $prefix."thumb".$filestorename;
+				unset($thumbnail);
+			}
+			
+			$thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),153,153, true);
+			if ($thumbsmall) {
+				$thumb->setFilename($prefix."smallthumb".$filestorename);
+				$thumb->open("write");
+				$thumb->write($thumbsmall);
+				$thumb->close();
+				$file->smallthumb = $prefix."smallthumb".$filestorename;
+				unset($thumbsmall);
+			}
+			
+			$thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),600,600, false);
+			if ($thumblarge) {
+				$thumb->setFilename($prefix."largethumb".$filestorename);
+				$thumb->open("write");
+				$thumb->write($thumblarge);
+				$thumb->close();
+				$file->largethumb = $prefix."largethumb".$filestorename;
+				unset($thumblarge);
+			}
+		}
+	} else {
+		// not saving a file but still need to save the entity to push attributes to database
+		$file->save();
+	}
+	
+	// make sure session cache is cleared
+	unset($_SESSION['uploadtitle']);
+	unset($_SESSION['uploaddesc']);
+	unset($_SESSION['uploadtags']);
+	unset($_SESSION['uploadaccessid']);
+	
+	// handle results differently for new files and file updates
+	if ($new_file) {
+		if ($guid) {
+			system_message(elgg_echo("file:saved"));
+			add_to_river('river/object/file/create', 'create', get_loggedin_userid(), $file->guid);
+		} else {
+			// failed to save file object - nothing we can do about this
+			register_error(elgg_echo("file:uploadfailed"));
+		}
+	
+		$container_user = get_entity($container_guid);
+		forward($CONFIG->wwwroot . "pg/file/owner/" . $container_user->username);
+	
+	} else {
+		if ($guid) {
+			system_message(elgg_echo("file:saved"));
+		} else {
+			register_error(elgg_echo("file:uploadfailed"));
+		}
+		
+		forward($file->getURL());
+	}	
Add a comment to this file

elgg/mod/freelicenses/graphics/icons.png

Added
New image

elgg/mod/freelicenses/languages/ca.php

+<?php
+/**
+         * Elgg freelicenses plugin
+         * 
+         * @package ElggFreeLicenses
+         * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+         * @author lorea
+         * @copyright lorea
+         * @link http://lorea.cc
+         */
+
+	$catalan = array(
+		"pages:license" => "Llicència",
+		"groups:license" => "Llicència",
+		"file:license" => "Llicència",
+		"freelicenses:under" => "Llicenciat sota",
+		"freelicenses:input:none" => "Sense llicència",
+		"freelicenses:license:againstdrm" => "Against DRM",
+		"freelicenses:license:cc_by" => "Creative Commons Attribution",
+		"freelicenses:license:cc_by_sa" => "Creative Commons Attribution ShareAlike",
+		"freelicenses:license:design_sc" => "Design Science License",
+		"freelicenses:license:free_art" => "Free Art License",
+		"freelicenses:license:freebsd_doc" => "FreeBSD Documentation License",
+		"freelicenses:license:gnu_fdl" => "GNU Free Documentation License",
+		"freelicenses:license:gnu_lgpl" => "GNU Lesser General Public License",
+		"freelicenses:license:gnu_gpl" => "GNU General Public License",
+		"freelicenses:license:freire_inhalte" => "Lizenz für Freie Inhalte",
+		"freelicenses:license:miros" => "MirOS Licence",
+		"freelicenses:license:mit" => "MIT License",
+		"freelicenses:sa" => "Copyleft",
+		"freelicenses:sc" => "Modificable a la pràctica",
+		"freelicenses:by" => "Atribució",
+		"freelicenses:rr" => "Drets relacionats",
+		"freelicenses:drmp" => "Prohibició de control d'accès",
+		"freelicenses:yes" => "Sí",
+		"freelicenses:no" => "No",
+		"freelicenses:by:copyright_notice" => "Nota de copyright",
+		"freelicenses:rr:granted" => "Garantitzat",
+		"freelicenses:access_control_prohibition:licensor_licensee" => "Llicenciador y Llicenciat",
+		"freelicenses:sa:weak" => "Dèbil",
+		"freelicenses:sa:strong" => "Fort",
+		"freelicenses:drmp:prohibits_tivoisation" => "La version 3 prohibeix la \"Tivoisation\" en cierts casos",
+	);
+	
+	add_translation("ca", $catalan);
+
+?>

elgg/mod/freelicenses/languages/en.php

+<?php
+/**
+         * Elgg freelicenses plugin
+         * 
+         * @package ElggFreeLicenses
+         * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+         * @author lorea
+         * @copyright lorea
+         * @link http://lorea.cc
+         */
+
+	$english = array(
+		"pages:license" => "License",
+		"groups:license" => "Licence",
+		"file:license" => "License",
+		"freelicenses:under" => "Licensed under",
+		"freelicenses:input:none" => "None",
+		"freelicenses:license:againstdrm" => "Against DRM",
+		"freelicenses:license:cc_by" => "Creative Commons Attribution",
+		"freelicenses:license:cc_by_sa" => "Creative Commons Attribution ShareAlike",
+		"freelicenses:license:design_sc" => "Design Science License",
+		"freelicenses:license:free_art" => "Free Art License",
+		"freelicenses:license:freebsd_doc" => "FreeBSD Documentation License",
+		"freelicenses:license:gnu_fdl" => "GNU Free Documentation License",
+		"freelicenses:license:gnu_lgpl" => "GNU Lesser General Public License",
+		"freelicenses:license:gnu_gpl" => "GNU General Public License",
+		"freelicenses:license:freire_inhalte" => "Lizenz für Freie Inhalte",
+		"freelicenses:license:miros" => "MirOS Licence",
+		"freelicenses:license:mit" => "MIT License",
+		"freelicenses:sa" => "Copyleft",
+		"freelicenses:sc" => "Practical modifiability",
+		"freelicenses:by" => "Attribution",
+		"freelicenses:rr" => "Related rights",
+		"freelicenses:drmp" => "Access control prohibition",
+		"freelicenses:yes" => "Yes",
+		"freelicenses:no" => "No",
+		"freelicenses:by:copyright_notice" => "Copyright notice",
+		"freelicenses:rr:granted" => "Granted",
+		"freelicenses:access_control_prohibition:licensor_licensee" => "Licensor & Licensee",
+		"freelicenses:sa:weak" => "Weak",
+		"freelicenses:sa:strong" => "Strong",
+		"freelicenses:drmp:prohibits_tivoisation" => "Version 3 prohibits \"Tivoisation\" in certain cases",
+	);
+	
+	add_translation("en", $english);
+
+?>

elgg/mod/freelicenses/languages/es.php

+<?php
+/**
+         * Elgg freelicenses plugin
+         * 
+         * @package ElggFreeLicenses
+         * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+         * @author lorea
+         * @copyright lorea
+         * @link http://lorea.cc
+         */
+
+	$spanish = array(
+		"pages:license" => "Licencia",
+		"groups:license" => "Licencia",
+		"file:license" => "Licencia",
+		"freelicenses:under" => "Licenciado bajo",
+		"freelicenses:input:none" => "Sin licencia",
+		"freelicenses:license:againstdrm" => "Against DRM",
+		"freelicenses:license:cc_by" => "Creative Commons Attribution",
+		"freelicenses:license:cc_by_sa" => "Creative Commons Attribution ShareAlike",
+		"freelicenses:license:design_sc" => "Design Science License",
+		"freelicenses:license:free_art" => "Free Art License",
+		"freelicenses:license:freebsd_doc" => "FreeBSD Documentation License",
+		"freelicenses:license:gnu_fdl" => "GNU Free Documentation License",
+		"freelicenses:license:gnu_lgpl" => "GNU Lesser General Public License",
+		"freelicenses:license:gnu_gpl" => "GNU General Public License",
+		"freelicenses:license:freire_inhalte" => "Lizenz für Freie Inhalte",
+		"freelicenses:license:miros" => "MirOS Licence",
+		"freelicenses:license:mit" => "MIT License",
+		"freelicenses:sa" => "Copyleft",
+		"freelicenses:sc" => "Modificable en la práctica",
+		"freelicenses:by" => "Atribución",
+		"freelicenses:rr" => "Derechos relacionados",
+		"freelicenses:drmp" => "Prohibición de control de acceso",
+		"freelicenses:yes" => "Sí",
+		"freelicenses:no" => "No",
+		"freelicenses:by:copyright_notice" => "Nota de copyright",
+		"freelicenses:rr:granted" => "Garantizado",
+		"freelicenses:access_control_prohibition:licensor_licensee" => "Licenciador y Licenciado",
+		"freelicenses:sa:weak" => "Débil",
+		"freelicenses:sa:strong" => "Fuerte",
+		"freelicenses:drmp:prohibits_tivoisation" => "La version 3 prohibe la \"Tivoisation\" en ciertos casos",
+	);
+	
+	add_translation("es", $spanish);
+
+?>

elgg/mod/freelicenses/lib/licenses.php

+<?php
+class License{
+	public $code;
+	public $name;
+	public $description;
+	public $url;
+	public $sa = false;
+	public $sc = false;
+	public $by = false;
+	public $rr = false;
+	public $drmp = false;
+
+	private static $free_licenses;
+
+	function __construct($code, $url){
+		$this->code = $code;
+		$this->name = elgg_echo("freelicenses:license:$code");
+		$this->description = elgg_echo("freelicenses:license:$code:description");
+		$this->url = $url;
+	}
+
+	private static function createLicenses(){
+		$againstDRM = new License('againstdrm', 'http://www.freecreations.org/Against_DRM2.html');
+		$againstDRM->sa = true;
+		$againstDRM->by = elgg_echo('freelicenses:by:copyright_notice');
+		$againstDRM->rr = elgg_echo('freelicenses:rr:granted');
+		$againstDRM->drmp = elgg_echo('freelicenses:access_control_prohibition:licensor_licensee');
+
+		$cc_by = new License('cc_by', 'http://creativecommons.org/licenses/by/3.0/legalcode');
+		$cc_by->by = elgg_echo('freelicenses:by:copyright_notice');
+		$cc_by->drmp = true;
+
+		$cc_by_sa = new License('cc_by_sa', 'http://creativecommons.org/licenses/by-sa/3.0/legalcode');
+		$cc_by_sa->sa = true;
+		$cc_by_sa->by = elgg_echo('freelicenses:by:copyright_notice');
+		$cc_by_sa->drmp = true;
+
+		$design_sc = new License('design_sc', 'http://www.gnu.org/licenses/dsl.html');
+		$design_sc->sa = true;
+		$design_sc->sc = true;
+		$design_sc->by = elgg_echo('freelicenses:by:copyright_notice');
+
+		$free_art = new License('free_art', 'http://artlibre.org/licence/lal/en/');
+		$free_art->sa = true;
+		$free_art->sc = true;
+		$free_art->by = true;
+		$free_art->rr = true;
+		$free_art->drmp = true;
+
+		$freebsd_doc = new License('freebsd_doc', 'http://www.freebsd.org/copyright/freebsd-doc-license.html');
+		$freebsd_doc->sc = true;
+		$freebsd_doc->by = elgg_echo('freelicenses:by:copyright_notice');
+		$freebsd_doc->rr = true;
+		$freebsd_doc->drmp = true;
+
+		$gnu_fdl = new License('gnu_fdl', 'http://www.gnu.org/copyleft/fdl.html');
+		$gnu_fdl->sa = true;
+		$gnu_fdl->sc = true;
+		$gnu_fdl->by = true;
+		$gnu_fdl->rr = true;
+		$gnu_fdl->drmp = true;
+
+		$gnu_lgpl = new License('gnu_lgpl', 'http://www.gnu.org/copyleft/lgpl.html');
+		$gnu_lgpl->sa = elgg_echo('freelicenses:sa:weak');
+		$gnu_lgpl->sc = true;
+		$gnu_lgpl->by = elgg_echo('freelicenses:by:copyright_notice');
+		$gnu_lgpl->rr = true;
+		$gnu_lgpl->drmp = true;
+
+		$gnu_gpl = new License('gnu_gpl', 'http://www.gnu.org/copyleft/gpl.html');
+		$gnu_gpl->sa = elgg_echo('freelicenses:sa:strong');
+		$gnu_gpl->sc = true;
+		$gnu_gpl->by = elgg_echo('freelicenses:by:copyright_notice');
+		$gnu_gpl->rr = elgg_echo('freelicenses:drmp:prohibits_tivoisation');
+
+		$freie_inhalte = new License('freie_inhalte', 'http://www.neppstar.net/webstar/freieinhalte-webstar.html');
+		$freie_inhalte->sa = true;
+		$freie_inhalte->sc = true;
+		$freie_inhalte->by = true;
+		$freie_inhalte->rr = true;
+		$freie_inhalte->drmp = true;
+
+		$miros = new License('miros', 'http://mirbsd.de/MirOS-Licence');
+		$miros->sc = true;
+		$miros->by = elgg_echo('freelicenses:by:copyright_notice');
+		$miros->rr = true;
+
+		$mit = new License('mit', 'http://www.opensource.org/osi3.0/licenses/mit-license.php');
+		$mit->sc = true;
+		$mit->by = elgg_echo('freelicenses:by:copyright_notice');
+		$mit->rr = true;
+		$mit->drmp = true;
+
+		self::$free_licenses = array(
+			$againstDRM->code => $againstDRM,
+			$cc_by->code => $cc_by,
+			$cc_by_sa->code => $cc_by_sa,
+			$design_sc->code => $design_sc,
+			$free_art->code => $free_art,
+			$freebsd_doc->code => $freebsd_doc,
+			$gnu_fdl->code => $gnu_fdl,
+			$gnu_lgpl->code => $gnu_lgpl,
+			$gnu_gpl->code => $gnu_gpl,
+			$freie_inhalte->code => $freie_inhalte,
+			$miros->code => $miros,
+			$mit->code => $mit
+		);
+	}
+
+	static function getLicenses(){
+		if(!self::$free_licenses) self::createLicenses();
+		return self::$free_licenses;
+	}
+
+	static function getLicensesJSON(){
+		$licenses = array_values(self::getLicenses());
+		return json_encode($licenses);
+	}
+}
+?>

elgg/mod/freelicenses/manifest.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest>
+        <field key="author" value="Lorea" />
+        <field key="version" value="1.0_rc" />
+        <field key="description" value="Elgg free licencing plugin" />
+        <field key="website" value="https://lorea.cc/" />
+        <field key="copyright" value="(C) Lorea 2011" />
+        <field key="licence" value="GNU Public License version 2" />
+        <field key="elgg_version" value="2010030101" />
+</plugin_manifest>

elgg/mod/freelicenses/start.php

+<?php
+
+	/**
+	 * Elgg free licenses plugin
+	 *
+	 * @package ElggFreeLicenses
+	 */
+
+	/**
+	 * Free licenses initialisation
+	 *
+	 */
+
+		function free_licenses_init() {
+			global $CONFIG;
+			if(is_array($CONFIG->pages)){
+				$CONFIG->pages['license'] = 'license';
+			}
+			register_plugin_hook('profile:fields', 'all', 'free_licenses_group_field');
+			register_action('file/upload', false, $CONFIG->pluginspath . 'freelicenses/actions/file/upload.php');
+			elgg_extend_view('css', 'freelicenses/css');
+		}
+
+		function free_licenses_group_field($hook, $entity_type, $returnvalue, $params){
+			if($entity_type == "group"){
+				$returnvalue['license'] = 'license';
+			}
+			return $returnvalue;
+		}
+
+		register_elgg_event_handler('init','system','free_licenses_init');
+
+?>

elgg/mod/freelicenses/views/default/file/upload.php

+<?php
+	/**
+	 * Elgg file browser uploader
+	 * 
+	 * @package ElggFile
+	 */
+
+	global $CONFIG;
+
+	if (isset($vars['entity'])) {
+		$action_type = "update";
+		$action = "file/upload";
+		$title = $vars['entity']->title;
+		$description = $vars['entity']->description;
+		$tags = $vars['entity']->tags;
+		$license = $vars['entity']->license;
+		$access_id = $vars['entity']->access_id;
+		$container_guid = $vars['entity']->container_guid;
+	} else  {
+		$action_type = "new";
+		$action = "file/upload";
+		$title = isset($_SESSION['uploadtitle']) ? $_SESSION['uploadtitle'] : '';
+		$description = isset($_SESSION['uploaddesc']) ? $_SESSION['uploaddesc'] : '';
+		$tags = isset($_SESSION['uploadtags']) ? $_SESSION['uploadtags'] : '';
+		$container_guid = page_owner_entity()->guid;
+		if ($container_guid && get_entity($container_guid) instanceof ElggGroup) {
+			$access_id = get_entity($container_guid)->access_id;
+		}
+		elseif (defined('ACCESS_DEFAULT')) {
+			$access_id = ACCESS_DEFAULT;
+		} else {
+			$access_id = 0;
+		}
+		$access_id = isset($_SESSION['uploadaccessid']) ? $_SESSION['uploadaccessid'] : $access_id;
+		$container_guid = page_owner_entity()->guid;
+		$comes_from_url = $vars['entity']->url1;
+		$comes_from_url2 = $vars['entity']->url2;
+	}
+		
+	// make sure session cache is cleared
+	unset($_SESSION['uploadtitle']);
+	unset($_SESSION['uploaddesc']);
+	unset($_SESSION['uploadtags']);
+	unset($_SESSION['uploadaccessid']);
+	
+	
+?>
+<div class="contentWrapper">
+<form action="<?php echo $vars['url']; ?>action/<?php echo $action; ?>" enctype="multipart/form-data" method="post">
+<p>
+	<label>
+<?php
+	echo elgg_view('input/securitytoken');
+	if ($action_type == "new") {
+		echo elgg_echo("file:file");
+	} else {
+		echo elgg_echo("file:replace");
+	}
+?>
+<br />
+<?php
+
+	echo elgg_view("input/file",array('internalname' => 'upload'));
+
+	$max_upload = (int)(ini_get('upload_max_filesize'));
+	$max_post = (int)(ini_get('post_max_size'));
+	$memory_limit = (int)(ini_get('memory_limit'));
+	$upload_mb = min($max_upload/(1024*1024), $max_post/(1024*1024), $memory_limit);
+	echo "<br/>".elgg_echo("file:maxsize").": ".$upload_mb . "MB";
+?>
+	</label>
+</p>
+<p>
+	<label><?php echo elgg_echo("title"); ?><br />
+<?php
+
+	echo elgg_view("input/text", array(
+									"internalname" => "title",
+									"value" => $title,
+													));
+			
+?>
+	</label>
+</p>
+<p class="longtext_editarea">
+	<label><?php echo elgg_echo("description"); ?><br />
+<?php
+
+	echo elgg_view("input/longtext",array(
+									"internalname" => "description",
+									"value" => $description,
+													));
+?>
+	</label>
+</p>
+<p>
+	<label><?php echo elgg_echo("tags"); ?><br />
+<?php
+
+	echo elgg_view("input/tags", array(
+									"internalname" => "tags",
+									"value" => $tags,
+													));
+?>
+	</label>
+</p>
+<?php
+
+	$categories = elgg_view('categories',$vars);
+	if (!empty($categories)) {
+?>
+
+		<p>
+			<?php echo $categories; ?>
+		</p>
+
+<?php
+		}
+
+?>
+<p>
+	<label>
+		<?php echo elgg_echo('file:license'); ?><br />
+		<?php echo elgg_view("input/license", array(
+												"internalname" => "license",
+												"value" => $license ));
+		?>
+	</label>
+</p>
+<p>
+	<label>
+		<?php echo elgg_echo('access'); ?><br />
+		<?php echo elgg_view('input/access', array('internalname' => 'access_id','value' => $access_id)); ?>
+	</label>
+</p>
+	
+<p>
+<?php
+
+	echo "<input type=\"hidden\" name=\"container_guid\" value=\"{$container_guid}\" />";
+	
+	if (isset($vars['entity'])) {
+		echo "<input type=\"hidden\" name=\"file_guid\" value=\"{$vars['entity']->getGUID()}\" />";
+	}
+	
+?>
+	<input type="submit" value="<?php echo elgg_echo("save"); ?>" />
+</p>
+
+</form>
+</div>

elgg/mod/freelicenses/views/default/forms/pages/edit.php

+<?php
+	/**
+	 * Elgg Pages
+	 * 
+	 * @package ElggPages
+	 */
+
+	$parent_guid = (int)get_input('parent_guid');
+	$container_guid = (int)get_input('container_guid');
+	if (!$container_guid) {
+		$container_guid = page_owner();
+	}
+	
+	$new_page = false;
+	if (!$vars['entity']) {
+		$new_page = true;
+		
+		// bootstrap the access permissions in the entity array so we can use defaults
+		if (get_entity($container_guid) instanceof ElggGroup) {
+			$access_id = $vars['container_guid'];
+			$vars['entity']->access_id = $access_id;
+			$vars['entity']->write_access_id = $access_id;
+		}
+		elseif (defined('ACCESS_DEFAULT')) {
+			$vars['entity']->access_id = ACCESS_DEFAULT;
+			$vars['entity']->write_access_id = ACCESS_DEFAULT;
+		} else {
+			$vars['entity']->access_id = 0;
+			$vars['entity']->write_access_id = 0;
+		}
+
+		// pull in sticky values from session
+		if (isset($_SESSION['page_description'])) {
+			$vars['entity']->description = $_SESSION['page_description'];
+			$vars['entity']->tags = $_SESSION['page_tags'];
+			$vars['entity']->access_id = $_SESSION['page_read_access'];
+			$vars['entity']->write_access_id = $_SESSION['page_write_access'];
+
+			// clear them
+			unset($_SESSION['page_description']);
+			unset($_SESSION['page_tags']);
+			unset($_SESSION['page_read_access']);
+			unset($_SESSION['page_write_access']);
+		}
+	}
+?>
+<div class="contentWrapper">
+<form action="<?php echo $vars['url']; ?>action/pages/edit" method="post">
+<?php
+	echo elgg_view('input/securitytoken'); 
+	if (is_array($vars['config']->pages) && sizeof($vars['config']->pages) > 0)
+		foreach($vars['config']->pages as $shortname => $valtype) {
+?>
+
+	<p>
+		<label>
+			<?php echo elgg_echo("pages:{$shortname}") ?><br />
+			<?php echo elgg_view("input/{$valtype}",array(
+				'internalname' => $shortname,
+				'value' => $vars['entity']->$shortname,
+			)); ?>
+		</label>
+	</p>
+
+<?php
+			
+		}
+		$cats = elgg_view('categories',$vars);
+		if (!empty($cats)) {
+			
+?>
+	<p>
+		<?php 
+			echo $cats;
+		?>
+	</p>
+<?php
+			
+		}
+
+?>
+	<p>
+		<?php
+			if (!$new_page)
+			{ 
+			?><input type="hidden" name="pages_guid" value="<?php echo $vars['entity']->getGUID(); ?>" /><?php 
+			}
+		?>
+		<?php
+			if ($container_guid)
+			{
+				?><input type="hidden" name="container_guid" value="<?php echo $container_guid; ?>" /><?php 
+			}
+		?>
+		<input type="hidden" name="parent_guid" value="<?php if (!$new_page) echo $vars['entity']->parent_guid; else echo $parent_guid; ?>" />
+		<input type="hidden" name="owner_guid" value="<?php if (!$new_page) echo $vars['entity']->owner_guid; else echo page_owner(); ?>" />
+		<input type="submit" class="submit_button" value="<?php echo elgg_echo("save"); ?>" />
+	</p>
+
+</form>
+</div>

elgg/mod/freelicenses/views/default/freelicenses/css.php

+<?php
+	$base_url = $vars['url'].'mod/freelicenses/graphics/';
+?>
+
+.license-output .license-name{
+	margin-right: 5px;
+}
+.license-output .license-icons{
+	<?php
+		echo "background: url(\"{$base_url}icons.png\") no-repeat right;"
+	?>
+}
+.license-output .license-icons *{
+	height: 20px;
+	width: 20px;
+	margin-right: 5px;
+	display: inline-block;
+	vertical-align: middle;
+	background-color: rgb(255,255,255);
+	background-color: rgba(255,255,255,0.6);
+}
+
+.license-output .license-icons .active{
+	background:transparent;
+	border: none;
+}
+
+.filerepo_license{
+	float: right;
+}

elgg/mod/freelicenses/views/default/input/license.php

+<?php
+/*
+ * @url http://freedomdefined.org/Licenses
+ */
+global $CONFIG;
+include_once($CONFIG->pluginspath.'freelicenses/lib/licenses.php');
+
+if(class_exists('License')){
+	$vars['options_values'] = array('' => elgg_echo('freelicenses:input:none'));
+	foreach(License::getLicenses() as $license){
+		$vars['options_values'][$license->code] = $license->name;
+	}
+	$vars['class'] .= $vars['class']? ' license-input' : 'license-input';
+	$vars['show'] = 'only-icons'; 
+	echo elgg_view('input/pulldown', $vars);
+	echo elgg_view('output/license', $vars);
+
+	if(!$freelicenses_input_script_loaded){
+?>
+
+<script type="text/javascript">
+	jQuery.fn.setIcon = function(icon, value){
+		<?php
+			$icons = array('sa', 'sc', 'by', 'rr', 'drmp');
+			$icons_values = array();
+			foreach($icons as $icon){
+				$icons_values[$icon] = elgg_echo("freelicenses:$icon");
+			}
+			echo "icons_values = ".json_encode($icons_values).";\n";
+		?>
+
+		if(value){
+			$(this).addClass('active');
+		} else {
+			$(this).removeClass('active');
+		}
+
+		if(typeof value == 'boolean'){
+			if(value) {
+				value = "<?php echo elgg_echo('freelicenses:yes'); ?>";
+			} else {
+				value = "<?php echo elgg_echo('freelicenses:no'); ?>";
+			}
+		}
+		$(this).attr('title', icons_values[icon]+": "+value);
+	}
+	jQuery.fn.setLicense = function(license){
+		licenses = <?php echo License::getLicensesJSON(); ?>;
+		
+		i = 0;
+		while (i < licenses.length && licenses[i].code != license){
+			i++;
+		}
+		if(i != licenses.length){
+
+			license = licenses[i];
+
+			$(this).attr('href', license.url)
+				.css('visibility','visible');
+
+			$(this).find('.license-sa').setIcon('sa', license.sa);
+			$(this).find('.license-sc').setIcon('sc', license.sc);
+			$(this).find('.license-by').setIcon('by', license.by);
+			$(this).find('.license-rr').setIcon('rr', license.rr);
+			$(this).find('.license-drmp').setIcon('drmp', license.drmp);
+			
+		} else { // no free license code
+			$(this).css('visibility','hidden');
+		}
+	};
+	$(function(){
+		$('.license-input').change(function(){
+			$('.license-output')
+				.setLicense($(this).val());
+		});
+	});
+</script>
+
+<?php
+	}
+}
+?>

elgg/mod/freelicenses/views/default/object/file.php

+<?php
+	/**
+	 * Elgg file browser.
+	 * File renderer.
+	 * 
+	 * @package ElggFile
+	 */
+
+	global $CONFIG;
+	
+	$file = $vars['entity'];
+	
+	$file_guid = $file->getGUID();
+	$tags = $file->tags;
+	$title = $file->title . elgg_view('tools/object' ,$vars);
+	$desc = $file->description;
+	$owner = $vars['entity']->getOwnerEntity();
+	$friendlytime = elgg_view_friendly_time($vars['entity']->time_created);
+	$mime = $file->mimetype;
+	
+	if (!$title) {
+		$title = elgg_echo('untitled');
+	}
+	
+	if (get_context() == "search") { 	// Start search listing version 
+		
+		if (get_input('search_viewtype') == "gallery") {
+			echo "<div class=\"filerepo_gallery_item\">";
+			if ($vars['entity']->smallthumb) {
+				echo "<p class=\"filerepo_title\">" . $title . "</p>";
+				echo "<p><a href=\"{$file->getURL()}\"><img src=\"{$vars['url']}mod/file/thumbnail.php?size=medium&file_guid={$vars['entity']->getGUID()}\" border=\"0\" /></a></p>";
+				echo "<p class=\"filerepo_timestamp\"><small><a href=\"{$vars['url']}pg/profile/owner/{$owner->username}\">{$owner->username}</a> {$friendlytime}</small></p>";
+
+				//get the number of comments
+				$numcomments = elgg_count_comments($vars['entity']);
+				if ($numcomments)
+					echo "<p class=\"filerepo_comments\"><a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a></p>";
+
+				
+				//if the user can edit, display edit and delete links
+				if ($file->canEdit()) {
+					echo "<div class=\"filerepo_controls\"><p>";
+					echo "<a href=\"{$vars['url']}pg/file/edit/{$file->getGUID()}\">" . elgg_echo('edit') . "</a>&nbsp;";
+					echo elgg_view('output/confirmlink',array(
+						
+							'href' => $vars['url'] . "action/file/delete?file=" . $file->getGUID(),
+							'text' => elgg_echo("delete"),
+							'confirm' => elgg_echo("file:delete:confirm"),
+							'is_action' => true,
+						
+						));
+					echo "</p></div>";
+				}
+					
+			
+			} else {
+				echo "<p class=\"filerepo_title\">{$title}</p>";
+				echo "<a href=\"{$file->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid, 'size' => 'large')) . "</a>";
+				echo "<p class=\"filerepo_timestamp\"><small><a href=\"{$vars['url']}pg/file/profile/{$owner->username}\">{$owner->name}</a> {$friendlytime}</small></p>";
+				//get the number of comments
+				$numcomments = elgg_count_comments($file);
+				if ($numcomments)
+					echo "<p class=\"filerepo_comments\"><a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a></p>";
+
+
+			}
+			echo "</div>";
+			// echo elgg_view("search/gallery",array('info' => $info, 'icon' => $icon));
+			
+		} else {
+		
+			$info = "<p> <a href=\"{$file->getURL()}\">{$title}</a></p>";
+			$info .= "<p class=\"owner_timestamp\"><a href=\"{$vars['url']}pg/file/owner/{$owner->username}\">{$owner->name}</a> {$friendlytime}";
+			$numcomments = elgg_count_comments($file);
+			if ($numcomments)
+				$info .= ", <a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>";
+			$info .= "</p>";
+			
+			// $icon = elgg_view("profile/icon",array('entity' => $owner, 'size' => 'small'));
+			$icon = "<a href=\"{$file->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid, 'size' => 'small')) . "</a>";
+			
+			echo elgg_view_listing($icon, $info);
+		
+		}
+		
+	} else {							// Start main version
+	
+?>
+	<div class="filerepo_file">
+		<div class="filerepo_icon">
+					<a href="<?php echo $vars['url']; ?>mod/file/download.php?file_guid=<?php echo $file_guid; ?>"><?php 
+						
+						echo elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid)); 
+						
+					?></a>					
+		</div>
+		
+		<div class="filerepo_title_owner_wrapper">
+		<?php
+			//get the user and a link to their gallery
+			$user_gallery = $vars['url'] . "mod/file/search.php?md_type=simpletype&subtype=file&tag=image&owner_guid=" . $owner->guid . "&search_viewtype=gallery";
+		?>
+		<div class="filerepo_user_gallery_link"><a href="<?php echo $user_gallery; ?>"><?php echo sprintf(elgg_echo("file:user:gallery"),''); ?></a></div>
+		<div class="filerepo_title"><h2><a href="<?php echo $vars['url']; ?>mod/file/download.php?file_guid=<?php echo $file_guid; ?>"><?php echo $title; ?></a></h2></div>
+		<div class="filerepo_owner">
+				<?php
+
+					echo elgg_view("profile/icon",array('entity' => $owner, 'size' => 'tiny'));
+				
+				?>
+				<p class="filerepo_owner_details"><b><a href="<?php echo $vars['url']; ?>pg/file/owner/<?php echo $owner->username; ?>"><?php echo $owner->name; ?></a></b><br />
+				<small><?php echo $friendlytime; ?></small></p>
+		</div>
+		</div>
+
+		
+		<div class="filerepo_maincontent">
+		
+				<div class="filerepo_description"><?php echo elgg_view('output/longtext', array('value' => $desc)); ?></div>
+				<div class="filerepo_tags">
+<?php
+
+		if (!empty($tags)) {
+
+?>
+		<div class="object_tag_string"><?php
+
+					echo elgg_view('output/tags',array('value' => $tags));
+				
+				?></div>
+<?php
+		}
+
+		$categories = elgg_view('categories/view',$vars);
+		if (!empty($categories)) {
+?>
+		<div class="filerepo_categories">
+			<?php
+
+				echo $categories;
+			
+			?>
+		</div>
+<?php
+		}
+
+?>
+				</div>
+		<?php 
+			if (elgg_view_exists('file/specialcontent/' . $mime)) {
+				echo "<div class=\"filerepo_specialcontent\">".elgg_view('file/specialcontent/' . $mime, $vars)."</div>";
+			} else if (elgg_view_exists("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default")) {
+				echo "<div class=\"filerepo_specialcontent\">".elgg_view("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default", $vars)."</div>";
+			}
+		
+		?>
+		
+		<div class="filerepo_download"><p><a href="<?php echo $vars['url']; ?>mod/file/download.php?file_guid=<?php echo $file_guid; ?>"><?php echo elgg_echo("file:download"); ?></a></p></div>
+		<div class="filerepo_license">
+			<?php
+				if(!empty($file->license)){
+					echo elgg_echo('freelicenses:under');
+					echo elgg_view('output/license', array('value'=>$file->license));
+				}
+			?>
+		</div>	
+<?php
+
+	if ($file->canEdit()) {
+?>
+
+	<div class="filerepo_controls">
+				<p>
+					<a href="<?php echo $vars['url']; ?>pg/file/edit/<?php echo $file->getGUID(); ?>"><?php echo elgg_echo('edit'); ?></a>&nbsp;
+					<?php 
+						echo elgg_view('output/confirmlink',array(
+						
+							'href' => $vars['url'] . "action/file/delete?file=" . $file->getGUID(),
+							'text' => elgg_echo("delete"),
+							'confirm' => elgg_echo("file:delete:confirm"),
+							'is_action' => true,
+						
+						));  
+					?>
+				</p>
+	</div>
+
+<?php		
+	}
+
+?>
+	</div>
+</div>
+
+<?php
+
+	if ($vars['full']) {
+		
+		echo elgg_view_comments($file);
+		
+	}
+
+?>
+
+<?php
+
+	}
+
+?>

elgg/mod/freelicenses/views/default/output/license.php

+<?php 
+	global $CONFIG;
+	include_once($CONFIG->pluginspath.'freelicenses/lib/licenses.php');
+	
+	if(class_exists("License")){
+		$license = $vars['value'];
+		$licenses = License::getLicenses();
+		$license = $licenses[$license];
+?>
+<span class="license-output" style="visibility:<?php echo $license?'visible':'hidden'; ?>">
+	<?php
+		if($vars['show'] != 'only-icons'){
+			echo "<a class=\"license-name\" href=\"$license->url\">$license->name</a>";
+		}
+
+		echo '<span class="license-icons">';
+
+		$icons = array('sa', 'sc', 'by', 'rr', 'drmp');
+
+		foreach ($icons as $icon){
+			$title = elgg_echo("freelicenses:$icon").": ";
+			$value = $license->$icon;
+
+			if($value === true) {
+				$title .= elgg_echo('freelicenses:yes');
+			} elseif($value === false) {
+				$title .= elgg_echo('freelicenses:no');
+			} else {
+				$title .= $value;
+			}
+
+			echo '<span title="'.$title.'" class="license-'.$icon.($value?' active':'').'"></span>'; 
+		}
+		
+		echo '</span>';
+	?>
+</span>
+<?php	} ?>

elgg/mod/freelicenses/views/default/pages/pageprofile.php

+<?php
+	/**
+	 * Elgg Pages
+	 * 
+	 * @package ElggPages
+	 */
+
+	// Output body
+	$entity = $vars['entity'];
+	
+	$rev = (int)get_input('rev');
+	
+	if ($rev)
+	{	
+		$latest = get_annotation($rev);	
+	}
+	else
+	{
+		$latest = $entity->getAnnotations('page', 1, 0, 'desc');
+		if ($latest) $latest = $latest[0];
+	}
+	
+?>	
+	<div class="contentWrapper">	
+	<div id="pages_page">
+	
+<?php	
+	if ($entity)
+	{
+		echo elgg_view('output/longtext', array('value' => /*$entity->description*/ $latest->value));
+		
+		$tags = $vars['entity']->tags;
+		if (!empty($tags)) {
+		
+?>
+		<!-- display tags -->
+		<p class="tags">
+			<?php
+
+				echo elgg_view('output/tags', array('tags' => $tags));
+			
+			?>
+		</p>
+		
+<?php
+
+		}
+		$cats = elgg_view('categories/view',$vars);
+		if (!empty($cats)) {
+			
+?>
+		<p class="categories">
+			<?php echo $cats; ?>
+		</p>
+<?php
+			
+		}
+	}
+
+	// last edit & by whome
+?>
+
+	<p class="strapline">
+		<?php
+                
+			$time_updated = $latest->time_created;
+			$owner_guid = $latest->owner_guid;
+			$owner = get_entity($owner_guid);
+			if ($owner)
+			echo sprintf(elgg_echo("pages:strapline"),
+							elgg_view_friendly_time($time_updated),
+							"<a href=\"" . $owner->getURL() . "\">" . $owner->name ."</a>"
+			);
+		
+			if(!empty($entity->license)){
+				echo '<br />'.elgg_echo('freelicenses:under');
+				echo elgg_view('output/license', array('value'=>$entity->license));
+			}
+		?>
+	</p>
+</div>
+
+</div>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.