Difference between revisions of "API:EPrints/Utils"
Line 1: | Line 1: | ||
<!-- Pod2Wiki=_preamble_ | <!-- Pod2Wiki=_preamble_ | ||
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost. | This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost. | ||
− | --> | + | -->{{API}}{{Pod2Wiki}}{{API:Source|file=EPrints/Utils.pm|package_name=EPrints::Utils}}[[Category:API|Utils]]<div><!-- Edit below this comment --> |
− | |||
− | {{API}}{{Pod2Wiki}}{{API:Source|file=EPrints/Utils.pm|package_name=EPrints::Utils}}[[Category:API|Utils]]<div><!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=_private_ --><!-- Pod2Wiki=head_name --> |
==NAME== | ==NAME== | ||
'''EPrints::Utils''' - Utility functions for EPrints. | '''EPrints::Utils''' - Utility functions for EPrints. | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=head_synopsis --> | ||
==SYNOPSIS == | ==SYNOPSIS == | ||
$boolean = EPrints::Utils::is_set( $object ) | $boolean = EPrints::Utils::is_set( $object ) | ||
Line 43: | Line 43: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=head_description --> | ||
==DESCRIPTION== | ==DESCRIPTION== | ||
This package contains functions which don't belong anywhere else. | This package contains functions which don't belong anywhere else. | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
− | + | </div> | |
− | + | <!-- Pod2Wiki=item_prepare_cmd --> | |
− | |||
− | |||
− | |||
− | <!-- Pod2Wiki=item_prepare_cmd -- | ||
===$cmd = EPrints::Utils::prepare_cmd($cmd,%VARS)=== | ===$cmd = EPrints::Utils::prepare_cmd($cmd,%VARS)=== | ||
Line 70: | Line 68: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_make_name_string --> | ||
===$string = EPrints::Utils::make_name_string( $name, [$familylast] )=== | ===$string = EPrints::Utils::make_name_string( $name, [$familylast] )=== | ||
Line 90: | Line 90: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_wrap_text --> | ||
===$str = EPrints::Utils::wrap_text( $text, [$width], [$init_tab], [$sub_tab] )=== | ===$str = EPrints::Utils::wrap_text( $text, [$width], [$init_tab], [$sub_tab] )=== | ||
Line 102: | Line 104: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_is_set --> | ||
===$boolean = EPrints::Utils::is_set( $r )=== | ===$boolean = EPrints::Utils::is_set( $r )=== | ||
Line 120: | Line 124: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_tree_to_utf8 --> | ||
===$string = EPrints::Utils::tree_to_utf8( $tree, $width, [$pre], [$whitespace_before], [$ignore_a] )=== | ===$string = EPrints::Utils::tree_to_utf8( $tree, $width, [$pre], [$whitespace_before], [$ignore_a] )=== | ||
Line 144: | Line 150: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
− | + | </div> | |
− | + | <!-- Pod2Wiki=item_copy --> | |
− | |||
− | |||
− | |||
− | <!-- Pod2Wiki=item_copy -- | ||
===$ok = EPrints::Utils::copy( $source, $target )=== | ===$ok = EPrints::Utils::copy( $source, $target )=== | ||
Line 162: | Line 164: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_wget --> | ||
===$response = EPrints::Utils::wget( $session, $source, $target )=== | ===$response = EPrints::Utils::wget( $session, $source, $target )=== | ||
Line 176: | Line 180: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_rmtree --> | ||
===$ok = EPrints::Utils::rmtree( $full_path )=== | ===$ok = EPrints::Utils::rmtree( $full_path )=== | ||
Line 194: | Line 194: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
− | + | </div> | |
− | + | <!-- Pod2Wiki=item_field_from_config_string --> | |
− | |||
− | |||
− | |||
− | <!-- Pod2Wiki=item_field_from_config_string -- | ||
===$metafield = EPrints::Utils::field_from_config_string( $dataset, $fieldname )=== | ===$metafield = EPrints::Utils::field_from_config_string( $dataset, $fieldname )=== | ||
Line 212: | Line 208: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_get_input --> | ||
===$string = EPrints::Utils::get_input( $regexp, [$prompt], [$default] )=== | ===$string = EPrints::Utils::get_input( $regexp, [$prompt], [$default] )=== | ||
Line 237: | Line 229: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
− | + | </div> | |
− | + | <!-- Pod2Wiki=item_get_input_hidden --> | |
− | |||
− | |||
− | |||
− | <!-- Pod2Wiki=item_get_input_hidden -- | ||
===EPrints::Utils::get_input_hidden( $regexp, [$prompt], [$default] )=== | ===EPrints::Utils::get_input_hidden( $regexp, [$prompt], [$default] )=== | ||
Line 255: | Line 243: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_get_input_confirm --> | ||
===EPrints::Utils::get_input_confirm( [$prompt], [$quick], [$default] )=== | ===EPrints::Utils::get_input_confirm( [$prompt], [$quick], [$default] )=== | ||
Line 275: | Line 259: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_clone --> | ||
===$clone_of_data = EPrints::Utils::clone( $data )=== | ===$clone_of_data = EPrints::Utils::clone( $data )=== | ||
Line 295: | Line 275: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_crypt_password --> | ||
===$crypted_value = EPrints::Utils::crypt_password( $value, $session )=== | ===$crypted_value = EPrints::Utils::crypt_password( $value, $session )=== | ||
Line 311: | Line 287: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_url_escape --> | ||
===$string = EPrints::Utils::url_escape( $url )=== | ===$string = EPrints::Utils::url_escape( $url )=== | ||
Line 321: | Line 299: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_ip2long --> | ||
===$long = EPrints::Utils::ip2long( $ip )=== | ===$long = EPrints::Utils::ip2long( $ip )=== | ||
Line 337: | Line 311: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_long2ip --> | ||
===$ip = EPrints::Utils::long2ip( $ip )=== | ===$ip = EPrints::Utils::long2ip( $ip )=== | ||
Line 347: | Line 323: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_cmd_version --> | ||
===EPrints::Utils::cmd_version( $progname )=== | ===EPrints::Utils::cmd_version( $progname )=== | ||
Line 365: | Line 337: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_escape_filename --> | ||
===$esc_string = EPrints::Utils::escape_filename( $string )=== | ===$esc_string = EPrints::Utils::escape_filename( $string )=== | ||
Line 375: | Line 349: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_unescape_filename --> | ||
===$string = EPrints::Utils::unescape_filename( $esc_string )=== | ===$string = EPrints::Utils::unescape_filename( $esc_string )=== | ||
Line 385: | Line 361: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki= --> |
+ | </div> | ||
+ | <!-- Pod2Wiki=item_human_filesize --> | ||
===$filesize_text = EPrints::Utils::human_filesize( $size_in_bytes )=== | ===$filesize_text = EPrints::Utils::human_filesize( $size_in_bytes )=== | ||
Line 399: | Line 377: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
+ | <!-- Pod2Wiki= --> | ||
+ | </div> | ||
<!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment --> | <!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment --> |
Revision as of 13:21, 25 February 2010
EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects
Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki
Contents
- 1 NAME
- 2 SYNOPSIS
- 3 DESCRIPTION
- 3.1 $cmd = EPrints::Utils::prepare_cmd($cmd,%VARS)
- 3.2 $string = EPrints::Utils::make_name_string( $name, [$familylast] )
- 3.3 $str = EPrints::Utils::wrap_text( $text, [$width], [$init_tab], [$sub_tab] )
- 3.4 $boolean = EPrints::Utils::is_set( $r )
- 3.5 $string = EPrints::Utils::tree_to_utf8( $tree, $width, [$pre], [$whitespace_before], [$ignore_a] )
- 3.6 $ok = EPrints::Utils::copy( $source, $target )
- 3.7 $response = EPrints::Utils::wget( $session, $source, $target )
- 3.8 $ok = EPrints::Utils::rmtree( $full_path )
- 3.9 $metafield = EPrints::Utils::field_from_config_string( $dataset, $fieldname )
- 3.10 $string = EPrints::Utils::get_input( $regexp, [$prompt], [$default] )
- 3.11 EPrints::Utils::get_input_hidden( $regexp, [$prompt], [$default] )
- 3.12 EPrints::Utils::get_input_confirm( [$prompt], [$quick], [$default] )
- 3.13 $clone_of_data = EPrints::Utils::clone( $data )
- 3.14 $crypted_value = EPrints::Utils::crypt_password( $value, $session )
- 3.15 $string = EPrints::Utils::url_escape( $url )
- 3.16 $long = EPrints::Utils::ip2long( $ip )
- 3.17 $ip = EPrints::Utils::long2ip( $ip )
- 3.18 EPrints::Utils::cmd_version( $progname )
- 3.19 $esc_string = EPrints::Utils::escape_filename( $string )
- 3.20 $string = EPrints::Utils::unescape_filename( $esc_string )
- 3.21 $filesize_text = EPrints::Utils::human_filesize( $size_in_bytes )
NAME
EPrints::Utils - Utility functions for EPrints.
SYNOPSIS
$boolean = EPrints::Utils::is_set( $object ) # return true if an object/scalar/array has any data in it # copy the contents of the url to a file $response = EPrints::Utils::wget( $handle, "http://www.eprints.org/index.php", "temp_dir/my_file" ) if($response->is_sucess()){ do something...} $name = { given=>"Wendy", family=>"Hall", honourific=>"Dame" }; # return Dame Wendy Hall $string = EPrints::Utils::make_name_string( $name, 1 ); # return Dame Hall, Wendy $string = EPrints::Utils::make_name_string( $name, 0 ); # returns http://www.eprints.org?var=%3Cfoo%3E $string = EPrints::Utils::url_escape( "http://www.eprints.org?var=<foo>" ); $esc_string = EPrints::Utils::escape_filename( $string ); $string = EPrints::Utils::unescape_filename( $esc_string ); $filesize_text = EPrints::Utils::human_filesize( 3300 ); # returns "3kb"
DESCRIPTION
This package contains functions which don't belong anywhere else.
$cmd = EPrints::Utils::prepare_cmd($cmd,%VARS)
Prepare command string $cmd by substituting variables (specified by $(varname)) with their value from %VARS (key is varname). All %VARS are quoted before replacement to make it shell-safe.
If a variable is specified in $cmd, but not present in %VARS a die is thrown.
$string = EPrints::Utils::make_name_string( $name, [$familylast] )
Return a string containing the name described in the hash reference $name.
The keys of the hash are one or more of given, family, honourific and lineage. The values are utf-8 strings.
Normally the result will be:
"family lineage, honourific given"
but if $familylast is true then it will be:
"honourific given family lineage"
$str = EPrints::Utils::wrap_text( $text, [$width], [$init_tab], [$sub_tab] )
Wrap $text to be at most $width (or 80 if undefined) characters per line. As a special case $width may be console, in which case the width used is the current console width (Term::ReadKey).
$init_tab and $sub_tab allow indenting on the first and subsequent lines respectively (see Text::Wrap for more information).
$boolean = EPrints::Utils::is_set( $r )
Recursive function.
Return false if $r is not set.
If $r is a scalar then returns true if it is not an empty string.
For arrays and hashes return true if at least one value of them is_set().
This is used to see if a complex data structure actually has any data in it.
$string = EPrints::Utils::tree_to_utf8( $tree, $width, [$pre], [$whitespace_before], [$ignore_a] )
Convert a XML DOM tree to a utf-8 encoded string.
If $width is set then word-wrap at that many characters.
XHTML elements are removed with the following exceptions:
<br /> is converted to a newline.
<p>...</p> will have a blank line above and below.
<img /> will be replaced with the content of the alt attribute.
<hr /> will, if a width was specified, insert a line of dashes.
<a href="foo">bar</a> will be converted into "bar <foo>" unless ignore_a is set.
$ok = EPrints::Utils::copy( $source, $target )
Copy $source file to $target file without alteration.
Return true on success (sets $! on error).
$response = EPrints::Utils::wget( $session, $source, $target )
Copy $source file or URL to $target file without alteration.
Will fail if $source is a "file:" and "enable_file_imports" is false or if $source is any other scheme and "enable_web_imports" is false.
Returns the HTTP response object: use $response->is_success to check whether the copy succeeded.
$ok = EPrints::Utils::rmtree( $full_path )
Unlinks the path and everything in it.
Return true on success.
$metafield = EPrints::Utils::field_from_config_string( $dataset, $fieldname )
Return the EPrint::MetaField from $dataset with the given name.
If fieldname has a semicolon followed by render options then these are passed as render options to the new EPrints::MetaField object.
$string = EPrints::Utils::get_input( $regexp, [$prompt], [$default] )
Read input from the keyboard.
Prints the promp and default value, if any. eg.
How many fish [5] >
Return the value the user enters at the keyboard.
If the value does not match the regexp then print the prompt again and try again.
If a default is set and the user just hits return then the default value is returned.
Get input from the console without echoing the entered characters (mostly useful for getting passwords). Uses Term::ReadKey.
Identical to get_input except the characters don't appear.
EPrints::Utils::get_input_confirm( [$prompt], [$quick], [$default] )
Asks the user for confirmation (yes/no). If $quick is true only checks for a single-character input ('y' or 'n').
If $default is '1' defaults to yes, if '0' defaults to no.
Returns true if the user answers 'yes' or false for any other value.
$clone_of_data = EPrints::Utils::clone( $data )
Deep copies the data structure $data, following arrays and hashes.
Does not handle blessed items.
Useful when we want to modify a temporary copy of a data structure that came from the configuration files.
$crypted_value = EPrints::Utils::crypt_password( $value, $session )
Apply the crypt encoding to the given $value.
$string = EPrints::Utils::url_escape( $url )
Escape the given $url, so that it can appear safely in HTML.
$long = EPrints::Utils::ip2long( $ip )
Convert quad-dotted notation to long
$ip = EPrints::Utils::long2ip( $ip )
Convert long to quad-dotted notation
EPrints::Utils::cmd_version( $progname )
Print out a "--version" style message to STDOUT.
$progname is the name of the current script.
$esc_string = EPrints::Utils::escape_filename( $string )
Take a value and escape it to be a legal filename to go in the /view/ section of the site.
$string = EPrints::Utils::unescape_filename( $esc_string )
Unescape a string previously escaped with escape_filename().
$filesize_text = EPrints::Utils::human_filesize( $size_in_bytes )
Return a human readable version of a filesize. If 0-4095b then show as bytes, if 4-4095Kb show as Kb otherwise show as Mb.
eg. Input of 5234 gives "5Kb", input of 3234 gives "3234b".
This is not internationalised, I don't think it needs to be. Let me know if this is a problem. support@eprints.org