Вынес класс в отдельный файл

This commit is contained in:
Фёдор Подлеснов 2018-01-30 15:31:18 +03:00
parent 7187963ac9
commit 7bbccea3b0
5 changed files with 68 additions and 62 deletions

View file

@ -126,7 +126,7 @@ class Database extends PDO
$sql = "INSERT INTO $table (" . implode(",", array_keys($values)) $sql = "INSERT INTO $table (" . implode(",", array_keys($values))
. ") VALUES (" . implode(",", array_keys($prep)). ")"; . ") VALUES (" . implode(",", array_keys($prep)). ")";
if($return_id){ if ($return_id) {
if ($this->isPostgres()){ if ($this->isPostgres()){
$sql = $sql." RETURNING $index"; $sql = $sql." RETURNING $index";
} }
@ -139,7 +139,7 @@ class Database extends PDO
if ($this->isPostgres()) { if ($this->isPostgres()) {
return $result[$index]; return $result[$index];
} else { } else {
$result = $this->fetchOneArray("SELECT $index AS lastid FROM $table WHERE OID = last_insert_rowid()"); $result = $this->fetchOneArray("SELECT $index AS lastid FROM $table WHERE OID = last_insert_rowid()");
return $result['lastid']; return $result['lastid'];
} }
} }

50
src/Form/Field.php Normal file
View file

@ -0,0 +1,50 @@
<?php
/**
* Элемент формы
*/
class Form_Field
{
public $hidden = false;
public $name;
public $label; // Метка поля
public $value; // Значение поля
public $type = ""; // Каждому типу элемента соответствует макрос TAL
public $error_msg = null;
public $default = null;
public $error = false;
public $require = false;
public $hint = null;
public $fieldset = null;
// Блоки (Убрать в отдельный класс!!!)
public $_title = array();
public $description = "";
public $alias = array();
public function __construct ($input = array(), $factory = null)
{
$this->default = null;
if (isset($input['validate'])) {
$this->require = strpos($input['validate'], 'require') !== false;
}
if (isset($input['fieldset'])) {
$this->fieldset = $input['fieldset'];
}
// Инициализация свойст обьетка
foreach (array('label', 'name', 'type', 'description') as $name) {
if (isset($input[$name])) {
$this->$name = $input[$name];
}
}
}
function setValue(/*.any.*/$value)
{
$this->value = $value;
}
function getId()
{
return $this->name . '_label';
}
}

View file

@ -1,62 +1,12 @@
<?php <?php
/**
* Элемент формы
*/
class TField
{
public $hidden = false;
public $name;
public $label; // Метка поля
public $value; // Значение поля
public $type = ""; // Каждому типу элемента соответствует макрос TAL
public $error_msg = null;
public $default = null;
public $error = false;
public $require = false;
public $hint = null;
public $fieldset = null;
// Блоки (Убрать в отдельный класс!!!)
public $_title = array();
public $description = "";
public $alias = array();
public function __construct ($input = array(), $factory = null)
{
$this->default = null;
if (isset($input['validate'])) {
$this->require = strpos($input['validate'], 'require') !== false;
}
if (isset($input['fieldset'])) {
$this->fieldset = $input['fieldset'];
}
// Инициализация свойст обьетка
foreach (array('label', 'name', 'type', 'description') as $name) {
if (isset($input[$name])) {
$this->$name = $input[$name];
}
}
}
function setValue(/*.any.*/$value)
{
$this->value = $value;
}
function getId()
{
return $this->name . '_label';
}
}
/** /**
* Поле ввода Input * Поле ввода Input
*/ */
class TInput extends TField { class TInput extends Form_Field {
} }
class TCheckbox extends TField class TCheckbox extends Form_Field
{ {
public $checked = false; public $checked = false;
function setValue($value) function setValue($value)
@ -67,7 +17,7 @@ class TCheckbox extends TField
} }
class TSelect extends TField class TSelect extends Form_Field
{ {
public $options = array(); public $options = array();
@ -140,14 +90,14 @@ class TQuestionType extends TSelect
/** /**
* Поле с датой * Поле с датой
*/ */
class TDate extends TField class TDate extends Form_Field
{ {
} }
/** /**
* Поле с цветом * Поле с цветом
*/ */
class TColor extends TField class TColor extends Form_Field
{ {
} }
@ -155,7 +105,7 @@ class TColor extends TField
/** /**
* Текстовое поле * Текстовое поле
*/ */
class TTextArea extends TField class TTextArea extends Form_Field
{ {
function setValue($value) function setValue($value)
{ {
@ -166,11 +116,11 @@ class TTextArea extends TField
/** /**
* Поле для ввода пароля * Поле для ввода пароля
*/ */
class TSecret extends TField class TSecret extends Form_Field
{ {
} }
class TUpload extends TField class TUpload extends Form_Field
{ {
} }

View file

@ -3,6 +3,7 @@
class MailAlt class MailAlt
{ {
public $mailer; public $mailer;
public $_notify;
function __construct() { function __construct() {
$this->mailer = new PHPMailer(); $this->mailer = new PHPMailer();
@ -35,7 +36,7 @@ class MailAlt
*/ */
function copy($name) // recipient cc function copy($name) // recipient cc
{ {
$this->addCC($name); $this->mailer->addCC($name);
} }
function notify($notify) function notify($notify)
@ -87,4 +88,8 @@ class MailAlt
{ {
return $this->mailer->send(); return $this->mailer->send();
} }
function eml() {
return $this->mailer->getSentMIMEMessage();
}
} }

View file

@ -48,11 +48,12 @@ class View_Page extends View_View
function replaceContent($match, $offset) function replaceContent($match, $offset)
{ {
//$result = phptal_component($match, $offset); //$result = phptal_component($match, $offset);
/*.Controller_Component.*/$component = null;
if(class_exists("Controller_Site")){ //Если мы в CMS2 if(class_exists("Controller_Site")){ //Если мы в CMS2
$component = Controller_Site::loadComponent($match); $component = Controller_Site::loadComponent($match);
}else{ } else {
global $db, $registry; // global $db, $registry; //
$component = Controller_Component::loadComponent($match, $db, $registry); $component = Controller_Component::loadComponent($match, $db, $registry);
} }