Your IP : 216.73.216.240
<?php
/*------------------------------------------------------------------------
# com_zhgooglemap - Zh GoogleMap
# ------------------------------------------------------------------------
# author: Dmitry Zhuk
# copyright: Copyright (C) 2011 zhuk.cc. All Rights Reserved.
# license: http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
# website: http://zhuk.cc
# Technical Support Forum: http://forum.zhuk.cc/
-------------------------------------------------------------------------*/
// No direct access
defined('_JEXEC') or die('Restricted access');
// import Joomla table library
jimport('joomla.database.table');
/**
* zhgooglemaps_markers Table class
*/
class ZhGoogleMapTableMapMarker extends JTable
{
/**
* Constructor
*
* @param object Database connector object
*/
function __construct(&$db)
{
parent::__construct('#__zhgooglemaps_markers', 'id', $db);
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_zhgooglemap.mapmarker'));
}
/**
* Overloaded check function
*
* @return boolean
* @see JTable::check
* @since 1.5
*/
public function check()
{
// Check the publish down date is not earlier than publish up.
if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up)
{
$this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
return false;
}
/*
if (empty($this->alias))
{
$this->alias = $this->title;
}
$this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '')
{
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
}
*/
return true;
}
/**
* Overloaded bind function
*
* @param array named array
* @return null|string null is operation was satisfactory, otherwise returns an error
* @see JTable:bind
* @since 1.5
*/
public function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params']))
{
// Convert the params field to a string.
$parameter = new JRegistry;
$parameter->loadArray($array['params']);
$array['params'] = (string)$parameter;
}
return parent::bind($array, $ignore);
}
/**
* Method to compute the default name of the asset.
* The default name is in the form `table_name.id`
* where id is the value of the primary key of the table.
*
* @return string
* @since 1.6
*/
protected function _getAssetName()
{
$k = $this->_tbl_key;
return 'com_zhgooglemap.mapmarker.'.(int) $this->$k;
}
/**
* Method to return the title to use for the asset table.
*
* @return string
* @since 1.6
*/
protected function _getAssetTitle()
{
return $this->title;
}
/**
* Get the parent asset id for the record
*
* @return int
* @since 1.6
*/
protected function _getAssetParentId(JTable $table = null, $id = null)
{
$asset = JTable::getInstance('Asset');
$asset->loadByName('com_zhgooglemap');
return $asset->id;
}
/**
* Overriden JTable::store to set modified data and user id.
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success.
*
* @since 3.1
*/
public function store($updateNulls = false)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing item
/*
Do not monitor changes
$this->modified_time = $date->toSql();
$this->modified_user_id = $user->get('id');
*/
}
else
{
// New record. Created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
/*
if (!(int) $this->created_time) {
$this->created_time = $date->toSql();
}
if (empty($this->created_user_id)) {
$this->created_user_id = $user->get('id');
}
*/
$this->rating_value = 0;
$this->rating_count = 0;
}
// Verify that the alias is unique
/*
$table = JTable::getInstance('MapMarker', 'ZhGoogleMapTable');
if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0))
{
$this->setError(JText::_('***** ERROR_UNIQUE_ALIAS* **** '));
return false;
}
*/
return parent::store($updateNulls);
}
}