SCZF
[
class tree: SCZF
] [
index: SCZF
] [
all elements
]
Packages:
SCZF
Source for file ScLayouts.php
Documentation is available at
ScLayouts.php
<?php
/**
* SCZF
*
* An open source SmartClient View Helper for Zend Framework
*
*
@package
SCZF
*
@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 Layouts Helper
*
*
@uses
viewHelper SmartClient
*/
class
SmartClient_Helper_ScLayouts
extends
SmartClient_Helper_ScGeneral
{
/**
*
@var
Zend_View_Interface
*/
public
$view
;
/**
*
@var
Array
All members
*/
protected
$_members
;
/**
*
* Return instance
*
*/
public
function
ScLayouts
(
)
{
return
$this
;
}
/**
*
* Sets the view field
*
@param
$view
Zend_View_Interface
*
*/
public
function
setView
(
Zend_View_Interface
$view
)
{
$this
->
view
=
$view
;
}
/**
*
* Add Member
*
*
@param
string
$data
Content of the member. Can be the ID of an element
*
*/
public
function
addMember
(
$data
)
{
$newMember
=
$data
;
// Add member to the array
$this
->
_members
[
]
=
$newMember
;
}
/**
* Add Multiple Members
*
*
@param
array
$data
Array containing multiple members
*
*/
public
function
addMembers
(
$data
)
{
if
(
is_array
(
$data
) )
{
foreach
(
$data
as
$row
)
{
$this
->
addMember
(
$row
)
;
}
}
}
/**
* Get Members
*
* Return the current members array
*
*
@return
array
*
*/
public
function
getMembers
(
)
{
return
$this
->
_members
;
}
/**
*
* Clear Members array
*
*/
public
function
clearMembers
(
)
{
unset
(
$this
->
_members
)
;
}
/**
*
* Creates a Layout
*
*
@param
mixed
$data
If string, it must be the element ID. If array, them we will loop through it
*
@param
integer
$width
Width of the tab set
*
@param
integer
$height
Height of the tab set
*
@param
string
$type
Type of the layout
*
@param
array
$options
Additional options
*
@return
string
*
*/
public
function
create
(
$data
,
$width
=
''
,
$height
=
''
,
$layoutType
=
'HLayout'
,
$options
=
''
)
{
$newLayout
=
array
(
)
;
// Set the valid type of layouts
$validTypes
=
array
(
'HLayout'
,
'VLayout'
)
;
// Check if it is an array
if
(
is_array
(
$data
) )
{
// Get layout type off the array
$layoutType
=
$data
[
'layoutType'
]
;
unset
(
$data
[
'layoutType'
]
)
;
$newLayout
=
$data
;
}
else
{
// Add vars to the new button
$newLayout
[
'ID'
]
=
$data
;
$newLayout
[
'width'
]
=
$width
;
$newLayout
[
'height'
]
=
$height
;
// Set members
$newLayout
[
'members'
]
=
$this
->
_members
;
// Check if options is array and do the loop
if
(
is_array
(
$options
) )
{
foreach
(
$options
as
$name
=>
$value
)
{
$newLayout
[
$name
]
=
$value
;
}
}
}
// Check if layoutType is valid
if
(
!
in_array
(
$layoutType
,
$validTypes
) )
{
// Set layoutType to a default value
$layoutType
=
'HLayout'
;
}
// Encode all data
$dataEncoded
=
Zend_Json
::
encode
(
$newLayout
)
;
// Remove vars that shouldn't be quoted
$dataEncoded
=
$this
->
removeQuotes
(
$dataEncoded
)
;
// Generate js code
$js
=
'
<script type="text/javascript">
isc.'
.
$layoutType
.
'.create(
'
.
$dataEncoded
.
'
);
</script>
'
;
return
$js
;
}
}
Documentation generated on Mon, 20 Jul 2009 16:51:57 -0300 by
phpDocumentor 1.4.1