Серверная часть системы создания и управления сайтами

Дипломная работа - Компьютеры, программирование

Другие дипломы по предмету Компьютеры, программирование



$this->dbm->SelectDatabase ($this->db_name);

// Adding project

$vals = array (project_uid=>$project_uid);

$this->dbm->AddData ($this->db_tables_projects, $vals);OK;

}

// Adding new resourceAddResource ($uid, $isglobal, $path, $type, $project_uid,

$usedin_uid = NULL, $usedin_type = NULL)

{

// Checking if input is correct(! valcheck:isuid($uid) ||! is_bool($isglobal) ||

! valcheck:issystempath($path) ||! valcheck:isalpha($type) ||

! valcheck:isuid ($project_uid))

{Bad input 1;

}(!$isglobal && (! valcheck:isuid ($usedin_uid) ||

! valcheck:isalpha ($usedin_type)))

{Bad input 2;

}

$this->dbm->SelectDatabase ($this->db_name);

$project_id = $this->getIdByUid ($this->db_tables_projects, project_uid, $project_uid);

$vals = array (resource_uid=>$uid,

isglobal=>$isglobal,

path=>$path,

data_type=>$type,

project_id=>$project_id);

$this->dbm->AddData ($this->db_tables_resources, $vals);(!$isglobal)

{

// Getting resource id from uid

$id = $this->getIdByUidCond ($this->db_tables_resources, resource_uid, $uid, project_id, $project_id);

// Getting usedin id from uid($usedin_type == page)

{

$usedin_id = $this->getIdByUidCond ($this->db_tables_pages, page_uid, $usedin_uid, project_id, $project_id);

}

{

$usedin_id = $this->getIdByUidCond ($this->db_tables_templates, template_uid, $usedin_uid, project_id, $project_id);

}

// Adding links

$vals = array (resource_id=>$id,

usedin_id=>$usedin_id,

usedin_type=>$usedin_type);

$this->dbm->AddData ($this->db_tables_resource_usedin, $vals);

}OK;

}

// Adding new templateAddTemplate ($template_uid, $draft_uid, $creation_time,

$modification_time, $object_data, $project_uid)

{

// Checking if input is correct(! valcheck:isuid ($template_uid) ||! valcheck:isuid ($draft_uid) ||

! valcheck:isunixtime ($creation_time) ||

! valcheck:isunixtime ($modification_time) ||

! valcheck:isobjectdata ($object_data) ||

! valcheck:isuid ($project_uid))

{Bad input;

}

$this->dbm->SelectDatabase ($this->db_name);

$project_id = $this->getIdByUid ($this->db_tables_projects, project_uid, $project_uid);

// Adding template

$vals = array (template_uid=>$template_uid,

project_id=>$project_id);

$this->dbm->AddData ($this->db_tables_templates, $vals);

// Getting template id from uid

$template_id = $this->getIdByUidCond ($this->db_tables_templates, template_uid, $template_uid, project_id, $project_id);

// Adding template draft

$vals = array (draft_uid=>$draft_uid,

template_id=>$template_id,

creation_time=>$creation_time,

modification_time=>$modification_time,

object_data=>$object_data);

$this->dbm->AddData ($this->db_tables_template_drafts, $vals);OK;

}

// Adding new pageAddPage ($page_uid, $draft_uid, $template_uid, $creation_time,

$modification_time, $page_url, $object_data, $published,

$generated_modification_time, $generated_draft_uid,

$project_uid)

{

// Checking if input is correct(! valcheck:isuid ($page_uid) ||! valcheck:isuid ($draft_uid) ||

! valcheck:isuid ($template_uid) ||! valcheck:isurl ($page_url) ||

! valcheck:isunixtime ($creation_time) ||

! valcheck:isunixtime ($modification_time) ||

! valcheck:isobjectdata ($object_data) ||! is_bool (strbool:tobool($published)) ||

! valcheck:isunixtime ($generated_modification_time) ||

! valcheck:isuid ($generated_draft_uid) ||

! valcheck:isuid ($project_uid))

{Bad input;

}

// Adding page

$this->dbm->SelectDatabase ($this->db_name);

$project_id = $this->getIdByUid ($this->db_tables_projects, project_uid, $project_uid);

$vals = array (page_uid=>$page_uid,

generated_modification_time=>$generated_modification_time,

generated_draft_uid=>$generated_draft_uid,

page_url=>$page_url,

project_id=>$project_id);

$this->dbm->AddData ($this->db_tables_pages, $vals);

// Getting template id from uid

$template_id = $this->getIdByUidCond ($this->db_tables_templates, template_uid, $template_uid, project_id, $project_id);

// Getting page id from uid

$page_id = $this->getIdByUidCond ($this->db_tables_pages, page_uid, $page_uid, project_id, $project_id);

// Adding page draft

$vals = array (draft_uid=>$draft_uid,

template_id=>$template_id,

creation_time=>$creation_time,

modification_time=>$modification_time,

object_data=>$object_data,

published=>strbool:tobool($published),

page_id=>$page_id);

$this->dbm->AddData ($this->db_tables_page_drafts, $vals);

$this->PublishPage ($project_id, $page_uid);OK;

}

// Adding new draftAddDraft ($project_uid, $page_uid, $draft_uid, $template_uid,

$creation_time, $modification_time, $object_data, $published)

{

// Checking if input is correct(! valcheck:isuid ($project_uid) ||

! valcheck:isuid ($page_uid) ||! valcheck:isuid ($draft_uid) ||

! valcheck:isuid ($template_uid) ||

! valcheck:isunixtime ($creation_time) ||

! valcheck:isunixtime ($modification_time) ||

! valcheck:isobjectdata ($object_data) ||

! is_bool (strbool:tobool($published)))

{Bad input;

}

$this->dbm->SelectDatabase ($this->db_name);

$project_id = $this->getIdByUid ($this->db_tables_projects, project_uid, $project_uid);

// Getting template id from uid

$template_id = $this->getIdByUidCond ($this->db_tables_templates, template_uid, $template_uid, project_id, $project_id);($template_id == 0) return Bad template uid;

// Getting page id from uid

$page_id = $this->getIdByUidCond ($this->db_tables_pages, page_uid, $page_uid, project_id, $project_id);($page_id == 0) return Bad page uid;(strbool:istrue($published))

{

// Unpublish all drafts

$table_name = $this->db_tables_page_drafts;

$new_data = array (published=>FALSE);

$condition = array (page_id=>$page_id);

$this->dbm->UpdateData ($table_name, $new_data, $condition);

}

// Adding page draft

$vals = array (draft_uid=>$draft_uid,

template_id=>$template_id,

creation_time=>$creation_time,

modification_time=>$modification_time,

object_data=>$object_data,

published=>strbool:tobool($published),

page_id=>$page_id);

$this->dbm->AddData ($this->db_tables_page_drafts, $vals);

$this->PublishPage ($project_id, $page_uid);OK;

}

// Save templateSaveTemplate ($project_uid, $template_uid, $draft_uid,

$modification_time = FALSE,

$object_data = FALSE,

$new_uid = FALSE)

{

// Checking if input is correct(! valcheck:isuid ($template_uid) ||! valcheck:isuid ($draft_uid) ||

! valcheck:isuid ($project_uid))

{Bad input 1;

}(($modification_time &&! valcheck:isunixtime ($modification_time)) ||

($object_data &&! valcheck:isobjectdata ($object_data)) ||

($new_uid &&! valcheck:isuid ($new_uid)))

{Bad input 2;

}

$this->dbm->SelectDatabase ($this->db_name);

$project_id = $this->getIdByUid ($this->db_tables_projects, project_uid, $project_uid);

// Getting template id from uid

$template_id = $this->getIdByUidCond ($this->db_tables_templates, template_uid, $template_uid, project_id, $project_id);

// Update template draft

$table_name = $this->db_tables_template_drafts;

$new_data = array();($modification_time) $new_data [modification_time] = $modification_time;($object_data) $new_data [object_data] = $object_data;

$condition = array (template_id=>$template_id,

draft_uid=>$draft_uid);

$this->dbm->UpdateData ($table_name, $new_data, $condition);

// Change uid of template($new_uid)

{

$table_name = $this->db_tables_templates;

$new_data = array (template_uid=>$new_uid);

$condition = array (id=>$template_id);

$this->dbm->UpdateData ($table_name, $new_data, $condition);

}OK;

}

// Saving page