本文整理汇总了PHP中JArrayHelper::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP JArrayHelper::toString方法的具体用法?PHP JArrayHelper::toString怎么用?PHP JArrayHelper::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JArrayHelper
的用法示例。
在下文中一共展示了JArrayHelper::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderNone
private function renderNone($text, $name, $attribs = null)
{
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
return '<span style="color:red" ' . $attribs . '><input type="hidden" name="' . $name . '" value="none" />' . JText::_($text) . '</span>';
}
示例2: radiolist
/**
* Generates an HTML radio list.
*
* @param array $data An array of objects
* @param string $name The value of the HTML name attribute
* @param string $attribs Additional HTML attributes for the <select> tag
* @param mixed $optKey The key that is selected
* @param string $optText The name of the object variable for the option value
* @param string $selected The name of the object variable for the option text
* @param boolean $idtag Value of the field id or null by default
* @param boolean $translate True if options will be translated
*
* @return string HTML for the select list
*
* @since 3.0
*/
public function radiolist($data, $name, $attribs = null, $optKey = 'value', $optText = 'text', $selected = null, $idtag = false, $translate = false)
{
reset($data);
$result = array();
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
$id_text = $idtag ? $idtag : $name;
foreach ($data as $obj) {
$k = $obj->{$optKey};
$t = $translate ? JText::_($obj->{$optText}) : $obj->{$optText};
$id = isset($obj->id) ? $obj->id : null;
$extra = '';
$extra .= $id ? ' id="' . $obj->id . '"' : '';
if (is_array($selected)) {
foreach ($selected as $val) {
$k2 = is_object($val) ? $val->{$optKey} : $val;
if ($k == $k2) {
$extra .= ' selected="selected"';
break;
}
}
} else {
$extra .= (string) $k == (string) $selected ? ' checked="checked"' : '';
}
$result[] = '<input type="radio" name="' . $name . '"' . ' id="' . $id_text . $k . '" value="' . $k . '"' . ' ' . $extra . ' ' . $attribs . '/>' . "\n\t" . '<label for="' . $id_text . $k . '"' . ' id="' . $id_text . $k . '-lbl" class="radiobtn">' . $t . '</label>';
}
return $result;
}
示例3: getControlHtml
/**
* Method to create the html string for control
* @return string html
*/
public function getControlHtml()
{
$field = $this->field->getField();
$clabel = $this->createlabel();
$ccustomtext = $this->getCustomText();
$html = "";
$html .= '<div class="fc-tbx' . $field->errorId . '"></div>';
//we wrap the control in a div if the field isCondtional, so that we can easily hide the whole control
$html .= '<div class="';
$html .= isset($field->isConditional) && $field->isConditional == true ? 'conditional field' . $field->id : 'field' . $field->id;
$html .= isset($field->attribute_required) && $field->attribute_required == true ? ' required' : '';
//closing quote for class attribute
$html .= '"';
$html .= isset($field->isDisabled) && $field->isDisabled == true ? ' style="display:none;" ' : "";
$html .= '>';
if ($ccustomtext != '' && isset($field->customtextposition) && ($field->customtextposition == 0 || $field->customtextposition == 1)) {
$html .= $ccustomtext;
}
$html .= '<label class="checkbox asterix-ancor ' . $field->labelCSSclass . '" id="' . $field->name . 'lbl" for="field' . $field->id . '">';
$html .= '<input ';
if (!empty($field->attributeArray)) {
//add all attributes
$html .= JArrayHelper::toString($field->attributeArray, '=', ' ', true);
}
$html .= '/>';
$html .= JHTML::_('visforms.createTip', $field);
$html .= "</label>";
if ($ccustomtext != '' && (isset($field->customtextposition) && $field->customtextposition == 2 || !isset($field->customtextposition))) {
$html .= $ccustomtext;
}
$html .= '</div>';
return $html;
}
示例4: savefilters
/**
* savefilters task
*
*
* @return void
* @since 1.0
* @author Sakis Terz
*/
public function savefilters()
{
$model = $this->getModel();
$app = JFactory::getApplication();
$jinput = $app->input;
$type_ids = $jinput->get('type_id', array(), 'array');
$alias = $jinput->get('alias', array(), 'array');
$smart_search = $jinput->get('smart_search', array(), 'array');
$expanded = $jinput->get('expanded', array(), 'array');
$scrollbar_after = $jinput->get('scrollbar_after', array(), 'array');
$params_array = array();
JArrayHelper::toInteger($type_ids);
JArrayHelper::toInteger($smart_search);
JArrayHelper::toInteger($expanded);
JArrayHelper::toString($alias);
JArrayHelper::toString($scrollbar_after);
//store the params in an assoc array an use the item id as key
foreach ($smart_search as $key => $val) {
$params_array[$key] = array('smart_search' => $val, 'expanded' => $expanded[$key], 'scrollbar_after' => $scrollbar_after[$key]);
}
$params_fromated = $this->formatParams($params_array);
//sanitize the input to be int
if ($type_ids || $alias || $params_fromated) {
if (!$model->savefilters($type_ids, $alias, $params_fromated)) {
JError::raiseWarning(500, $model->getError());
} else {
$this->setMessage(JText::_('COM_CUSTOMFILTERS_FILTERS_SAVED_SUCCESS'));
}
}
$this->setRedirect('index.php?option=com_customfilters&view=customfilters');
}
示例5: callElement
public function callElement()
{
// get request vars
$element = YRequest::getCmd('element', '');
$method = YRequest::getCmd('method', '');
$args = YRequest::getVar('args', array(), 'default', 'array');
$item_id = (int) YRequest::getInt('item_id', 0);
JArrayHelper::toString($args);
// get item
$item = YTable::getInstance('item')->get($item_id);
// raise warning when item can not be accessed
if (empty($item->id) || !$item->canAccess($this->user)) {
JError::raiseError(500, JText::_('Unable to access item'));
return;
}
// raise warning when item is not published
$nulldate = JFactory::getDBO()->getNullDate();
$date = JFactory::getDate()->toUnix();
$publish_up = JFactory::getDate($item->publish_up);
$publish_down = JFactory::getDate($item->publish_down);
if ($item->state != 1 || !(($item->publish_up == $nulldate || $publish_up->toUnix() <= $date) && ($item->publish_down == $nulldate || $publish_down->toUnix() >= $date))) {
JError::raiseError(404, JText::_('Item not published'));
return;
}
// get element and execute callback method
if ($element = $item->getElement($element)) {
$element->callback($method, $args);
}
}
示例6: link
static function link($url, $text, $attribs = null)
{
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
return "<a href='" . $url . "' " . $attribs . ">" . $text . "</a>";
}
示例7: returnQuestion
/** this function returns math expression into your form, the parameter is optional
* quite simmilar to insertQuestion, but returns the output as a text instead of echoing
*/
public static function returnQuestion($attributes = array(), $suffix = '')
{
//default prime is 37, you can change it when specifying the different parameter
$a = rand() % 10;
// generates the random number
$b = rand() % 10;
// generates the random number
$code = $a + $b;
if (!is_array($attributes)) {
$attributes = array();
}
if (!isset($attributes['name'])) {
$suffix = $suffix . rand(1, 99999);
$attributes['name'] = 'captcha_code' . $suffix;
}
if (!isset($attributes['id'])) {
$attributes['id'] = $attributes['name'];
}
if (!isset($attributes['size'])) {
$attributes['size'] = '2';
}
if (!isset($attributes['class'])) {
$attributes['class'] = 'inputbox mathguard-answer required';
}
$session =& JFactory::getSession();
$session->set($attributes['name'], $code);
return $a . ' + ' . $b . ' = ' . '<input type="text" ' . JArrayHelper::toString($attributes) . ' />';
}
示例8: getArray
public static function getArray($name, $default = array(), $type = 'array', $hash = 'default', $mask = 0)
{
// explode name
$parts = explode('.', $name);
if (count($parts) > 1) {
$name = $parts[0];
$key = $parts[1];
}
$array = self::getVar($name, $default, $hash, 'array', $mask);
if (isset($key)) {
if (is_array($array) && array_key_exists($key, $array)) {
$value = $array[$key];
settype($value, $type);
return $value;
}
return $default;
}
if ($type == 'string') {
JArrayHelper::toString($array);
} else {
if ($type == 'int') {
JArrayHelper::toInteger($array);
}
}
return $array;
}
示例9: getLink
public static function getLink(&$params)
{
$document = JFactory::getDocument();
foreach ($document->_links as $link => $value) {
$value = JArrayHelper::toString($value);
if (strpos($value, 'application/' . $params->get('format') . '+xml')) {
return $link;
}
}
}
示例10: getControlHtml
/**
* Method to create the html string for control
* @return string html
*/
public function getControlHtml()
{
$field = $this->field->getField();
//input
$html = '';
$html .= '<input ';
if (!empty($field->attributeArray)) {
//add all attributes
$html .= JArrayHelper::toString($field->attributeArray, '=', ' ', true);
}
$html .= '/>';
return $html;
}
示例11: _HtmlElement
static function _HtmlElement($tagName, $id, $name = '', $content = '', $attributes = array())
{
$attributes["id"] = JCKOutput::fixId($id);
if ($name) {
$attributes["name"] = $name;
}
$attrStr = "";
if (!empty($attributes)) {
$attrStr = JArrayHelper::toString($attributes);
}
$html = chr(13) . "<{$tagName} {$attrStr}>{$content}</{$tagName}>";
return $html;
}
示例12: getControlHtml
/**
* Method to create the html string for control
* @return string html
*/
public function getControlHtml()
{
$field = $this->field->getField();
//input
$html = '';
if (!isset($field->noborder) || isset($field->noborder) && $field->noborder != "1") {
$html .= '<hr ';
if (!empty($field->attributeArray)) {
//add all attributes
$html .= JArrayHelper::toString($field->attributeArray, '=', ' ', true);
}
$html .= '/>';
}
return $html;
}
示例13: image
/**
* Method to parse an image on the filesystem to an HMLT-tag
*
* @access public
* @param string $file
* @param string $alt
* @param mixed $attribs
* @return string HTML output
*/
public function image($file, $alt = null, $attribs = null)
{
if (!file_exists(JPATH_SITE . '/' . $file)) {
return null;
}
$info = getimagesize(JPATH_SITE . '/' . $file);
if (empty($alt)) {
$alt = basename($file);
}
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
$picture = JURI::base() . '/' . $file;
return '<img src="' . $picture . '" alt="' . $alt . '" ' . $attribs . ' ' . $info[3] . ' />';
}
示例14: checkbox
public static function checkbox($name, $class, $attribs = array(), $selected = null, $id = false)
{
$selectedHtml = '';
$html = '';
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
if ($selected) {
$selectedHtml .= " checked=\"checked\"";
}
$html .= "\n<input type='hidden' value='0' name=\"{$name}\">";
// Self destruct
$html .= "\n<input type=\"checkbox\" name=\"{$name}\" class=\"{$class}\" value=\"1\" {$attribs} {$selectedHtml} />";
$html .= "\n<span class=\"lbl\"></span>";
return $html;
}
示例15: calendar
function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null)
{
JHTML::_('behavior.calendar');
//load the calendar behavior
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
$document = JFactory::getDocument();
$document->addScriptDeclaration('window.addEvent(\'domready\', function() {Calendar.setup({
inputField : "' . $id . '", // id of the input field
ifFormat : "' . $format . '", // format of the input field
button : "' . $id . '_img", // trigger for the calendar (button ID)
align : "Tl", // alignment (defaults to "Bl")
singleClick : true
});});');
return '<input type="text" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />' . '<img class="calendar" src="' . JURI::root(true) . '/templates/system/images/calendar.png" alt="calendar" id="' . $id . '_img" />';
}