Fix helper comments and PHPDoc for better tooltips in eclipse

This commit is contained in:
Eike Foken
2011-09-20 01:30:22 +02:00
parent 07f29a8f54
commit 2c24c46cd1
6 changed files with 187 additions and 96 deletions

View File

@@ -1,83 +1,82 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); <?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/** /**
* Extends CI's date helpers. * Extends CI's date helpers.
* *
* @package ScattPort
* @subpackage Helpers
* @author Karsten Heiken <karsten@disposed.de> * @author Karsten Heiken <karsten@disposed.de>
*/ */
// ------------------------------------------------------------------------ if (!function_exists('mysql_now')) {
/** /**
* CodeIgniter Date Helpers * Get "now" time formatted for MySQL.
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/date_helper.html
*/
// ------------------------------------------------------------------------
/**
* Get "now" time formatted for MySQL
* *
* Returns time() formatted for direct insertion into a DATETIME field. * Returns time() formatted for direct insertion into a DATETIME field.
* *
* @access public
* @return integer * @return integer
*/ */
if ( ! function_exists('mysql_now')) function mysql_now() {
{
function mysql_now()
{
return mdate('%Y-%m-%d %H:%i:%s', now()); return mdate('%Y-%m-%d %H:%i:%s', now());
} }
} }
if (!function_exists('time_diff')) {
/** /**
* Function to calculate date or time difference. * Calculates a date or time difference.
*
* Function to calculate date or time difference. Returns an array or
* false on error.
* *
* @author J de Silva <giddomains@gmail.com> * @author J de Silva <giddomains@gmail.com>
* @copyright Copyright &copy; 2005, J de Silva * @copyright Copyright &copy; 2005, J de Silva
* @link http://www.gidnetwork.com/b-16.html Get the date / time difference with PHP * @link http://www.gidnetwork.com/b-16.html
* @param string $start * @param string $start
* @param string $end * @param string $end
* @return array * @return mixed Returns the difference as integer or FALSE on error.
*/ */
if ( ! function_exists('time_diff')) function time_diff($start, $end) {
{
function time_diff($start, $end)
{
$uts['start'] = strtotime($start); $uts['start'] = strtotime($start);
$uts['end'] = strtotime($end); $uts['end'] = strtotime($end);
if ($uts['start'] !== -1 && $uts['end'] !== -1) { if ($uts['start'] !== -1 && $uts['end'] !== -1) {
if ($uts['end'] >= $uts['start']) { if ($uts['end'] >= $uts['start']) {
$diff = $uts['end'] - $uts['start']; $diff = $uts['end'] - $uts['start'];
$diff = intval($diff); $diff = intval($diff);
return ($diff); return $diff;
} }
} }
return (false); return false;
} }
} }
if (!function_exists('prettyTime')) {
/** /**
* Function to convert seconds to a pretty string. * Converts seconds to a pretty string.
* *
* @author Karsten Heiken <karsten@disposed.de> * @author Karsten Heiken <karsten@disposed.de>
* @param integer $secs the amount of seconds * @param integer $secs The amount of seconds
* @param boolean $includeseconds should seconds be appended to the string? * @param boolean $includeseconds Should seconds be appended to the string?
* @return string * @return string
*/ */
if ( ! function_exists('prettyTime')) function prettyTime($secs, $includeseconds = false) {
{
function prettyTime($secs, $includeseconds = false)
{
if(!defined('SECOND')) define("SECOND", 1); if(!defined('SECOND')) define("SECOND", 1);
if(!defined('MINUTE')) define("MINUTE", 60 * SECOND); if(!defined('MINUTE')) define("MINUTE", 60 * SECOND);
if(!defined('HOUR')) define("HOUR", 60 * MINUTE); if(!defined('HOUR')) define("HOUR", 60 * MINUTE);
@@ -112,6 +111,7 @@ if ( ! function_exists('prettyTime'))
} }
} }
if (!function_exists('relative_time')) {
/** /**
* Parses any english textual datetime description into a relative date string. * Parses any english textual datetime description into a relative date string.
* *
@@ -120,7 +120,6 @@ if ( ! function_exists('prettyTime'))
* @param boolean $show_seconds * @param boolean $show_seconds
* @return string * @return string
*/ */
if (!function_exists('relative_time')) {
function relative_time($date, $show_seconds = false) { function relative_time($date, $show_seconds = false) {
$diff = time() - strtotime($date); $diff = time() - strtotime($date);

View File

@@ -1,17 +1,42 @@
<?php defined('BASEPATH') || exit('No direct script access allowed'); <?php defined('BASEPATH') || exit('No direct script access allowed');
/** /*
* Extends CI's directory helpers. * Copyright (c) 2011 Karsten Heiken, Eike Foken
* *
* @author Eike Foken <kontakt@eikefoken.de> * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/ */
/** /**
* Creates a directory if it not already exists. Works recursively. * Extends CI's directory helpers.
* *
* @param string $path Path to the directory to create * @package ScattPort
* @return boolean * @subpackage Helpers
* @author Eike Foken <kontakt@eikefoken.de>
*/ */
if (!function_exists('mkdirs')) { if (!function_exists('mkdirs')) {
/**
* Recursively creates a directory if it not already exists.
*
* @param string $path
* @param integer $mode
* @return boolean Returns TRUE on success or FALSE on failure.
*/
function mkdirs($path, $mode = 0777) { function mkdirs($path, $mode = 0777) {
if (!is_dir($path)) { if (!is_dir($path)) {
$old_umask = umask(0); $old_umask = umask(0);

View File

@@ -1,6 +1,6 @@
<?php defined('BASEPATH') || exit('No direct script access allowed'); <?php defined('BASEPATH') || exit('No direct script access allowed');
/* /*
* Copyright (c) 2011 Eike Foken <kontakt@eikefoken.de> * Copyright (c) 2011 Karsten Heiken, Eike Foken
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,19 +1,41 @@
<?php defined('BASEPATH') || exit("No direct script access allowed"); <?php defined('BASEPATH') || exit('No direct script access allowed');
/** /*
* Extends CI's Language helpers. * Copyright (c) 2011 Karsten Heiken, Eike Foken
* *
* @author Eike Foken <kontakt@eikefoken.de> * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/ */
/** /**
* Generates a link for language selection. * Extends CI's Language helpers.
* *
* @access public * @package ScattPort
* @param string $img_folder Folder of the images for the language selection * @subpackage Helpers
* @param boolean $index_page Should index_page be added to the JavaScript path * @author Eike Foken <kontakt@eikefoken.de>
* @return string
*/ */
if (!function_exists('lang_select')) { if (!function_exists('lang_select')) {
/**
* Generates a link for changing the language.
*
* @param string $img_folder The folder containing flags for the language selection
* @return string The generated link
*/
function lang_select($img_folder = '') { function lang_select($img_folder = '') {
$CI =& get_instance(); $CI =& get_instance();
@@ -37,4 +59,3 @@ if (!function_exists('lang_select')) {
/* End of file MY_language_helper.php */ /* End of file MY_language_helper.php */
/* Location: ./application/helpers/MY_language_helper.php */ /* Location: ./application/helpers/MY_language_helper.php */

View File

@@ -1,7 +1,31 @@
<?php defined('BASEPATH') || exit('No direct script access allowed'); <?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/** /**
* Helper functions for including assets. * Helper functions for including assets.
* *
* @package ScattPort
* @subpackage Helpers
* @author Eike Foken <kontakt@eikefoken.de> * @author Eike Foken <kontakt@eikefoken.de>
*/ */

View File

@@ -1,20 +1,42 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); <?php defined('BASEPATH') || exit('No direct script access allowed');
/** /*
* Helper for generating hash values. * Copyright (c) 2011 Karsten Heiken, Eike Foken
* *
* @author Karsten Heiken <karsten@disposed.de> * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/ */
/** /**
* Generate a pseudo-random SHA1-hash. * Helper for generating hash values.
* *
* @access public * @package ScattPort
* @subpackage Helpers
* @author Karsten Heiken <karsten@disposed.de>
*/
if (!function_exists('random_hash')) {
/**
* Generates a pseudo-random SHA1-hash.
*
* @param integer $len
* @return integer * @return integer
*/ */
if ( ! function_exists('random_hash')) function random_hash($len = 40) {
{
function random_hash($len = 40)
{
return substr(sha1(rand(1,1000).now().rand(1001,2000)), 0, $len); return substr(sha1(rand(1,1000).now().rand(1001,2000)), 0, $len);
} }
} }