SCZF
[
class tree: SCZF
] [
index: SCZF
] [
all elements
]
Packages:
SCZF
Source for file ScButtons.php
Documentation is available at
ScButtons.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 Buttons Helper
*
*
@uses
viewHelper SmartClient
*/
class
SmartClient_Helper_ScButtons
extends
SmartClient_Helper_ScGeneral
{
/**
*
@var
Zend_View_Interface
*/
public
$view
;
/**
*
* Return instance
*
*/
public
function
ScButtons
(
)
{
return
$this
;
}
/**
*
* Sets the view field
*
@param
$view
Zend_View_Interface
*
*/
public
function
setView
(
Zend_View_Interface
$view
)
{
$this
->
view
=
$view
;
}
/**
*
* Button
*
* Creates a new button
*
*
@param
mixed
$data
If string, it must be the title of the button. If array, them we will loop through it
*
@param
string
$click
Onclick function
*
@param
string
$buttonType
Type of the button
*
@param
array
$options
Additional options
*
@return
string
*
*/
public
function
create
(
$data
,
$click
=
''
,
$buttonType
=
''
,
$options
=
''
)
{
$newButton
=
array
(
)
;
// Set the valid buttons
$validButtons
=
array
(
'Button'
,
'IButton'
,
'ImgButton'
)
;
// Check if it is an array
if
(
is_array
(
$data
) )
{
// Get button type off the array
$buttonType
=
$data
[
'buttonType'
]
;
unset
(
$data
[
'buttonType'
]
)
;
$newButton
=
$data
;
}
else
{
// Add vars to the new button
$newButton
[
'title'
]
=
$data
;
$newButton
[
'click'
]
=
$this
->
addQuotesStr
(
$click
)
;
// Check if options is array and do the loop
if
(
is_array
(
$options
) )
{
foreach
(
$options
as
$name
=>
$value
)
{
$newButton
[
$name
]
=
$value
;
}
}
}
// Check if buttonType is valid
if
(
!
in_array
(
$buttonType
,
$validButtons
) )
{
// Set buttonType to a default value
$buttonType
=
'IButton'
;
}
// Encode all data
$dataEncoded
=
Zend_Json
::
encode
(
$newButton
)
;
// Remove vars that shouldn't be quoted
$dataEncoded
=
$this
->
removeQuotes
(
$dataEncoded
)
;
// Generate js code
$js
=
'
<script type="text/javascript">
isc.'
.
$buttonType
.
'.create(
'
.
$dataEncoded
.
'
);
</script>
'
;
return
$js
;
}
}
Documentation generated on Mon, 20 Jul 2009 16:51:56 -0300 by
phpDocumentor 1.4.1