SCPHP
[
class tree: SCPHP
] [
index: SCPHP
] [
all elements
]
Packages:
SCPHP
Source for file ScWindows.php
Documentation is available at
ScWindows.php
<?php
/**
* SCPHP
*
* An open source SmartClient library for PHP
*
*
@package
SCPHP
*
@author
Fernando Marcelo Morgenstern <fernando@consultorpc.com>
*
@copyright
Copyright (c) 2009, ConsultorPC
*
@license
http://www.gnu.org/licenses/lgpl-3.0-standalone.html
*
@link
http://smartclientphp.com/
*
@since
Version 0.1b
*
@filesource
*/
/**
* Smart Client Windows Helper
*
*/
class
ScWindows
extends
ScGeneral
{
/**
*
@var
Array
Items for this window
*/
protected
$_items
;
/**
*
* Add Item
*
*
@param
mixed
$itemID
ID of the item
*
@return
string
*
*/
public
function
addItem
(
$itemID
)
{
$this
->
_items
[
]
=
$itemID
;
}
/**
* Add Multiple Items
*
*
@param
array
$data
Array containing multiple items
*
*/
public
function
addItems
(
$data
)
{
if
(
is_array
(
$data
) )
{
foreach
(
$data
as
$row
)
{
$this
->
addItem
(
$row
)
;
}
}
}
/**
* Get Items
*
* Return the current items array
*
*
@return
array
*
*/
public
function
getItems
(
)
{
return
$this
->
_items
;
}
/**
*
* Clear Items array
*
*/
public
function
clearItems
(
)
{
unset
(
$this
->
_items
)
;
}
/**
*
* Creates a Window
*
*
@param
mixed
$data
If string, it must be the element ID. If array, them we will loop through it
*
@param
string
$title
Title of the window
*
@param
integer
$width
Width of the window
*
@param
integer
$height
Height of the window
*
@param
string
$content
Content of the window ( can be override by items )
*
@param
array
$options
Additional options
*
@return
string
*
*/
public
function
create
(
$data
,
$title
=
''
,
$width
=
''
,
$height
=
''
,
$content
=
''
,
$options
=
''
)
{
$newWindow
=
array
(
)
;
// Check if it is an array
if
(
is_array
(
$data
) )
{
$newWindow
=
$data
;
}
else
{
// Add vars to the new button
$newWindow
[
'ID'
]
=
$data
;
$newWindow
[
'title'
]
=
$title
;
$newWindow
[
'width'
]
=
$width
;
$newWindow
[
'height'
]
=
$height
;
$newWindow
[
'content'
]
=
$content
;
// Generate the items string
$itemsStr
=
implode
(
','
,
$this
->
_items
)
;
// Set items
$newWindow
[
'items'
]
=
$this
->
addQuotesStr
(
$itemsStr
)
;
// Set default value for autoSize if it is not set
if
(
!
isset
(
$options
[
'autoSize'
]
) )
{
$options
[
'autoSize'
]
=
true
;
}
// Set default value for canDragResize if it is not set
if
(
!
isset
(
$options
[
'canDragResize'
]
) )
{
$options
[
'canDragResize'
]
=
true
;
}
// Check if options is array and do the loop
if
(
is_array
(
$options
) )
{
foreach
(
$options
as
$name
=>
$value
)
{
$newWindow
[
$name
]
=
$value
;
}
}
}
// Encode all data
$dataEncoded
=
json_encode
(
$newWindow
)
;
// Remove vars that shouldn't be quoted
$dataEncoded
=
$this
->
removeQuotes
(
$dataEncoded
)
;
// Generate js code
$js
=
'
<script type="text/javascript">
isc.Window.create(
'
.
$dataEncoded
.
'
);
</script>
'
;
return
$js
;
}
}
Documentation generated on Wed, 29 Jul 2009 22:37:15 -0300 by
phpDocumentor 1.4.1