本文整理汇总了PHP中Element::bindData方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::bindData方法的具体用法?PHP Element::bindData怎么用?PHP Element::bindData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element::bindData方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromCSV
/**
* Import data from CSV cell
* @param $value
* @param null $position
* @return Item
*/
public function fromCSV($value, $position = null)
{
$value = $this->_getAutoClean($value);
if ($this->_element) {
if ($this->_isRepeatable) {
// for repeatable objects
if (strpos($value, JBCSVItem::SEP_ROWS)) {
$tmpData = $this->_getArray($value, JBCSVItem::SEP_ROWS);
foreach ($tmpData as $val) {
if ($val === '') {
return $this->_item;
}
$data[] = array('value' => $val);
}
$this->_element->bindData($data);
} else {
if ($value === '') {
return $this->_item;
}
$data = $position == 1 ? array() : ($data = $this->_element->data());
$data[] = array('value' => JString::trim($value));
$this->_element->bindData($data);
}
} else {
if ($value === '') {
return $this->_item;
}
// for no repeatable objects
$this->_element->bindData(array('value' => $value));
}
}
return $this->_item;
}
示例2: bindData
public function bindData($data = array())
{
parent::bindData($data);
// add image width/height
$file = $this->get('file');
if ($file && ($filepath = $this->app->path->path('root:' . $file))) {
$size = getimagesize($filepath);
$this->set('width', $size ? $size[0] : 0);
$this->set('height', $size ? $size[1] : 0);
}
}
示例3: bindData
public function bindData($data = array())
{
parent::bindData($data);
// calculate rating/votes
$query = 'SELECT AVG(value) AS rating, COUNT(id) AS votes' . ' FROM ' . ZOO_TABLE_RATING . ' WHERE element_id = ' . $this->app->database->Quote($this->identifier) . ' AND item_id = ' . $this->_item->id . ' GROUP BY item_id';
if ($this->_item->id && ($res = $this->app->database->queryAssoc($query))) {
$this->set('votes', $res['votes']);
$this->set('value', $res['rating']);
} else {
$this->set('votes', 0);
$this->set('value', 0);
}
}
示例4: bindData
/**
* @param array $data
*/
public function bindData($data = array())
{
$saveData = $data;
if ($this->getItem()) {
$newData = JFactory::getSession()->get($this->_getSaveKey(), null, __CLASS__);
}
if (!empty($newData)) {
$saveData = $newData;
}
$saveData = array_merge($saveData, $data);
if ($saveData['is_modified'] == self::MODIFIED_EXEC) {
parent::bindData($saveData);
$this->modifyItem();
} else {
parent::bindData($saveData);
}
}
示例5: bindData
/**
* Bind data on save
* Hack for save from admin
* @param array $data
*/
public function bindData($data = array())
{
$saveData = $data;
if ($this->getItem()) {
$newData = JFactory::getSession()->get('items-' . $this->getItem()->id . '-' . $this->identifier, null, __CLASS__);
}
if (!empty($newData)) {
$saveData = $newData;
}
// for administator only
if (isset($data['order_info_admin'])) {
$orderInfo = array('status' => $data['order_info_status'], 'description' => $data['order_info_description']);
if (isset($saveData['is_advance'])) {
$saveData['order_info'] = array_merge($saveData['order_info'], $orderInfo);
} else {
reset($saveData);
$firstKey = key($saveData);
if (!isset($saveData[$firstKey]['order_info'])) {
$saveData[$firstKey]['order_info'] = array();
}
$saveData[$firstKey]['order_info'] = array_merge($saveData[$firstKey]['order_info'], $orderInfo);
}
}
parent::bindData($saveData);
}
示例6: bindData
public function bindData($data = array())
{
$images_arr = $data['images'];
if (empty($images_arr)) {
$images_arr = $data;
}
$key = 0;
if (!empty($images_arr)) {
foreach ($images_arr as $image) {
$datanew[$key]['file'] = $this->getUploadedFilePath($image['name']);
$datanew[$key]['title'] = '';
$datanew[$key]['link'] = '';
$datanew[$key]['target'] = '0';
$datanew[$key]['rel'] = '';
$key++;
}
parent::bindData($datanew);
}
}
示例7: bindData
public function bindData($data = array())
{
parent::bindData($data);
}
示例8: bindData
public function bindData($data = array())
{
if (!isset($data['hits'])) {
$this->setData($this->getItem()->elements);
$data['hits'] = $this->_data->get('hits', 0);
}
parent::bindData($data);
}
示例9: bindData
/**
* Clean data before bind into element
* @param array $data
* @return null | array
*/
public function bindData($data = array())
{
if (isset($data['option'])) {
foreach ($data['option'] as $key => $value) {
$data['option'][$key] = $this->_jbcolor->clean($value);
}
parent::bindData($data);
}
return null;
}