| Current Path : /var/www/iplanru/data/www/i-plan.ru/administrator/components/com_poll/tables/ |
| Current File : /var/www/iplanru/data/www/i-plan.ru/administrator/components/com_poll/tables/pollquestions.php |
<?php
// No direct access
defined( '_JEXEC' ) or die;
/**
* Object Class Table
* @author kirdinyuri
*/
class TablePollquestions extends JTable
{
/**
* Class constructor
* @param Object $db (database link object)
*/
function __construct( &$db )
{
parent::__construct( '#__pollquestions', 'id', $db );
}
/**
* Method for loading data into the object field
* @param Array $array (Featured in the field of data)
* @param String $ignore
* @return Boolean result
*/
public function bind( $array, $ignore = '' )
{
/*if ( empty( $array['created_by'] ) ) {
$user = JFactory::getUser();
$array['created_by'] = $user->id;
}
if ( empty( $array['created'] ) ) {
$array['created'] = date( 'Y-m-d H:i:s' );
}
if ( isset( $array['rules'] ) && is_array( $array['rules'] ) ) {
$rules = new JAccessRules( $array['rules'] );
$this->setRules( $rules );
}
$array['alias'] = JApplication::stringURLSafe( $array['alias'] );
if ( trim( str_replace( '-', '', $array['alias'] ) ) == '' ) {
$array['alias'] = JApplication::stringURLSafe( $array['title'] );
}
if ( isset( $array['text'] ) )
{
$pattern = '#<hr\s+id=("|\')system-readmore("|\')\s*\/*>#i';
$tagPos = preg_match($pattern, $array['text'] );
if ($tagPos == 0)
{
$this->introtext = $array['text'];
$this->fulltext = '';
}
else
{
list ($this->introtext, $this->fulltext) = preg_split( $pattern, $array['text'], 2 );
}
}*/
if ( isset( $array['params'] ) && is_array( $array['params'] ) )
{
$registry = new JRegistry;
$registry->loadArray( $array['params'] );
$array['params'] = (string) $registry;
}
return parent::bind( $array, $ignore );
}
public function load($pk = null, $reset = true)
{
if (parent::load($pk, $reset))
{
// Конвертируем поле параметров в регистр.
$params = new JRegistry;
$params->loadString($this->params);
$this->params = $params;
return true;
}
else
{
return false;
}
}
public function publish($pks = null, $state = 1, $userId = 0)
{
$k = $this->_tbl_key;
// Очищаем входные параметры.
JArrayHelper::toInteger($pks);
$state = (int) $state;
// Если первичные ключи не установлены, то проверяем ключ в текущем объекте.
if (empty($pks))
{
if ($this->$k)
{
$pks = array($this->$k);
}
else
{
throw new RuntimeException(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'), 500);
}
}
// Устанавливаем состояние для всех первичных ключей.
foreach ($pks as $pk)
{
// Загружаем сообщение.
if (!$this->load($pk))
{
throw new RuntimeException(JText::_('COM_POLL_TABLE_ERROR_RECORD_LOAD'), 500);
}
$this->state = $state;
// Сохраняем сообщение.
if (!$this->store())
{
throw new RuntimeException(JText::_('COM_POLL_TABLE_ERROR_RECORD_STORE'), 500);
}
}
return true;
}
/**
* Метод для вычисления уникального имени ассета по умолчанию.
* По умолчанию имя берется из формы: `table_name.id`,
* где id - это значение первичного ключа таблицы.
*
* @return string Название ассета.
*/
protected function _getAssetName()
{
$k = $this->_tbl_key;
return 'com_poll.question.' . ( int )$this->$k;
}
/**
* Метод для получения названия ассета для таблицы ассетов.
*
* @return string
*/
protected function _getAssetTitle()
{
return $this->id;
}
/**
* Метод для получения id родителя записи.
*
* @return int Id родителя записи.
*/
protected function _getAssetParentId( $table = null, $id = null )
{
$asset = JTable::getInstance( 'Asset' );
$asset->loadByName( 'com_poll' );
return $asset->id;
}
}