table_id; } /** * Установить имя пользователя * * @param string $username имя пользавтеля * * @return bool|string true в случае успеха. иначе сообщение с разъяснениями */ public function setUserName( $username ) { if ( preg_match( '/[a-z,\d]{3,}/i', $username ) ) { $this->table_username = $username; return true; } else { return "Только цифры и буквы латинского алфавита, минимум 3"; } } /** * Получить имя пользователя * * @return string */ public function getUserName(){ return $this->table_username; } /** * Установка e-mail * * @param string $email * * @return bool|string true в случае успеха. иначе сообщение с разъяснениями */ public function setEmail( $email ) { if ( preg_match('/.+@.+\..+/i', $email ) ) { $this->table_email = $email; return true; } else { return "Введите коректный e-mail адрес"; } } /** * Получить e-mail * * @return mixed */ public function getEmail() { return $this->table_email; } /** * Установка домашней страницы * * @param string $homepage URL * * @return bool|string true в случае успеха. иначе сообщение с разъяснениями */ public function setHomepage( $homepage ) { if ( preg_match('|https?://.*\..*|i', $homepage ) ) { $this->table_homepage = strip_tags( $homepage ); return true; } else { return "Введите коректный адрес"; } } /** * Получение домашней страницы * * @return mixed */ public function getHomepage() { return $this->table_homepage; } /** * Установка IP адреса * * @param mixed $ip */ public function setIp( $ip ) { $this->table_ip = $ip; } /** * Получение IP адреса * * @return mixed */ public function getIp() { return $this->table_ip; } /** * Установка данных User-Agent * * @param mixed $browser */ public function setBrowser( $browser ) { $this->table_browser = $browser; } /** * Получение данных User-Agent * * @return mixed */ public function getBrowser() { return $this->table_browser; } /** * Установка текста * * @param mixed $text */ public function setText( $text ) { $this->table_ptext = strip_tags($text); } /** * Получение текста * * @return mixed */ public function getText() { return $this->table_ptext; } /** * Установка даты * * @param mixed $date */ public function setDate( $date ) { $this->table_pdate = $date; } /** * Получение даты * @return mixed */ public function getDate() { return $this->table_pdate; } /** * Получение количества страниц * * @return int */ public function countPages() { return (int) ceil($this->count()/25); } /** * Получение массива объектов для вывода на страницах * * @param integer $page_number номер страницы * @param string $sort_by сортировка по столбцу * @param string $order сортировка по возрастанию или убыванию * * @return mixed */ static public function getForPage( $page_number = 1, $sort_by = 'pdate', $order = 'ASC' ) { $class_name = __CLASS__; $offset = ($page_number - 1) * 25; return $class_name::find(" 1 ORDER BY $sort_by $order LIMIT $offset,25"); } }