本文整理汇总了PHP中template::save方法的典型用法代码示例。如果您正苦于以下问题:PHP template::save方法的具体用法?PHP template::save怎么用?PHP template::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类template
的用法示例。
在下文中一共展示了template::save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save()
{
if (!$this->issetErrors() && (empty($this->values['d_name']) || empty($this->values['d_def_lang']) || empty($this->values['d_email']) || empty($this->values['d_sitename']))) {
$this->newError(61, 'Не все обязательные поля были заполнены!');
}
if ($this->issetErrors()) {
return false;
} else {
if (!empty($this->id)) {
// Изменение домена
$sql = $this->getSql();
if (!empty($sql)) {
db::q('UPDATE <<domains>> SET ' . $sql . ' WHERE d_id = "' . $this->id . '";');
}
system::log('Изменен домен "' . $this->values['d_name'] . '" (id:' . $this->id . ')', warning);
// Переименовываем папки с шаблонами
if ($this->old_name != $this->values['d_name']) {
$lang = languages::getAll();
while (list($key, $val) = each($lang)) {
if ($this->id != 1 || $val['l_id'] != 1) {
$old_name = '/__' . str_replace('.', '_', $this->old_name) . '_' . $val['l_prefix'];
$new_name = '/__' . str_replace('.', '_', $this->values['d_name']) . '_' . $val['l_prefix'];
@rename(TEMPL_DIR . $old_name, TEMPL_DIR . $new_name);
}
}
}
return true;
} else {
// Добавление домена
$sql = $this->getSql();
if (!empty($sql)) {
$this->id = db::q('INSERT INTO <<domains>> SET ' . $sql . ';');
}
if (!empty($this->id)) {
$lang = languages::getAll();
while (list($key, $val) = each($lang)) {
rights::createForStructure($this->id, $val['id']);
$templ = new template();
$templ->setName('default');
$templ->setFile('default');
$templ->setLangId($val['id']);
$templ->setDomainId($this->id);
$templ->save();
reg::setKey('/structure/' . $this->id . '/' . $val['id'] . '/title_prefix', '%text% | ' . $this->values['d_sitename']);
reg::setKey('/structure/' . $this->id . '/' . $val['id'] . '/view_as_tree', 1);
$dname = '/__' . str_replace('.', '_', $this->values['d_name']) . '_' . $val['l_prefix'];
$this->copyDir(TEMPL_DIR, TEMPL_DIR . $dname);
}
system::log('Создан домен "' . $this->values['d_name'] . '" (id:' . $this->id . ')', warning);
return true;
} else {
$this->newError(62, 'Произошла ошибка при добавлении домена!');
system::log('Произошла ошибка при добавлении домена!', error);
return false;
}
}
}
}
示例2: save
/**
* Speichert Template in Dateisystem
* @return boolean
*/
public function save()
{
$this->content = strip_tags($this->content);
$this->content = $this->events->runEvent('templateSave', array('file' => $this->fullpath, 'content' => $this->content))['content'];
return parent::save();
}
示例3: save
public function save()
{
if (!$this->issetErrors() && (empty($this->values['l_name']) || empty($this->values['l_prefix']))) {
$this->newError(52, 'Поля "Название" и "Префикс" обязательны для заполнения!');
}
if ($this->issetErrors()) {
return false;
} else {
if (!empty($this->id)) {
// Изменение языка
$sql = $this->getSql();
if (!empty($sql)) {
db::q('UPDATE <<langs>> SET ' . $sql . ' WHERE l_id = "' . $this->id . '";');
}
system::log('Изменена языковая версия сайта "' . $this->values['l_name'] . '" (id:' . $this->id . ')', warning);
// Переименовываем папки с шаблонами
if ($this->old_prefix != $this->values['l_prefix']) {
$domain = domains::getAll();
while (list($key, $val) = each($domain)) {
if ($this->id != 1 || $val['d_id'] != 1) {
$old_name = '/__' . str_replace('.', '_', $val['d_name']) . '_' . $this->old_prefix;
$new_name = '/__' . str_replace('.', '_', $val['d_name']) . '_' . $this->values['l_prefix'];
@rename(TEMPL_DIR . $old_name, TEMPL_DIR . $new_name);
}
}
}
return true;
} else {
// Добавление языка
$sql = $this->getSql();
if (!empty($sql)) {
$this->id = db::q('INSERT INTO <<langs>> SET ' . $sql . ';');
}
if (is_numeric($this->id)) {
// Добавляем для каждого домена право и шаблон
$domain = domains::getAll();
while (list($key, $val) = each($domain)) {
rights::createForStructure($val['id'], $this->id);
$templ = new template();
$templ->setName('default');
$templ->setFile('default');
$templ->setLangId($this->id);
$templ->setDomainId($val['id']);
$templ->save();
reg::setKey('/structure/' . $val['id'] . '/' . $this->id . '/title_prefix', '%text% | ' . $val['d_sitename']);
reg::setKey('/structure/' . $val['id'] . '/' . $this->id . '/view_as_tree', 1);
// Создаем папки с шаблонами
$dname = '/__' . str_replace('.', '_', $val['d_name']) . '_' . $this->values['l_prefix'];
$this->copyDir(TEMPL_DIR, TEMPL_DIR . $dname);
}
system::log('Создана новая языковая версия сайта "' . $this->values['l_name'] . '" (id:' . $this->id . ')', warning);
return true;
} else {
$this->newError(53, 'Произошла ошибка при добавление языка!');
system::log('Произошла ошибка при добавление языка!', error);
return false;
}
}
}
}
示例4: createTemplate
private function createTemplate($field_name)
{
$id = 0;
$type = $field_name == 'template_id' ? 0 : 1;
if (!empty($_POST[$field_name . '_new_val']) && !empty($_POST[$field_name . '_new_val2'])) {
$templ = new template($id);
$templ->setName($_POST[$field_name . '_new_val']);
$templ->setFile($_POST[$field_name . '_new_val2']);
$templ->setDestination($type);
$templ->setLangId(languages::curId());
$templ->setDomainId(domains::curId());
$id = $templ->save();
}
if (!empty($id)) {
$_POST[$field_name] = $id;
}
}
示例5: changeTempl
function changeTempl($id, $obj, $form_name)
{
$type = $form_name == 'page_tpl' ? 0 : 1;
$templ = new template($id);
$templ->setName($obj['t_name']);
$templ->setFile($obj['t_file']);
$templ->setDestination($type);
$templ->setLangId(languages::curId());
$templ->setDomainId(domains::curId());
$templ->save();
return true;
}
示例6: run
function run()
{
global $user;
global $layout;
global $DB;
global $website;
$out = '';
$item = new template();
switch ($_REQUEST['act']) {
case 'json':
case 1:
// json data retrieval & operations
switch ($_REQUEST['oper']) {
case 'del':
// remove rows
$ids = $_REQUEST['ids'];
foreach ($ids as $id) {
$item->load($id);
$item->delete();
}
echo json_encode(true);
break;
default:
// list or search
// we have to merge the theme templates with the custom private templates (which are defined in the DB)
// as we don't expect a lot of templates, we will always return the whole dataset
// for this reason, paginate is useless
$orderby = $_REQUEST['sidx'] . ' ' . $_REQUEST['sord'];
if (isset($_REQUEST['quicksearch'])) {
$dataset = template::search($orderby, array('quicksearch' => $_REQUEST['quicksearch']));
} else {
$dataset = template::search($orderby);
}
$total = count($dataset);
$out = array();
$permissions = array(0 => '<img src="img/icons/silk/world.png" align="absmiddle" /> ' . t(69, 'Published'), 1 => '<img src="img/icons/silk/world_dawn.png" align="absmiddle" /> ' . t(70, 'Private'), 2 => '<img src="img/icons/silk/world_night.png" align="absmiddle" /> ' . t(81, 'Hidden'));
if (empty($dataset)) {
$rows = 0;
} else {
$rows = count($dataset);
}
for ($i = 0; $i < $rows; $i++) {
$out[$i] = array(0 => $dataset[$i]['id'], 1 => $dataset[$i]['title'], 2 => $dataset[$i]['theme'], 3 => $permissions[$dataset[$i]['permission']], 4 => $dataset[$i]['enabled'] == 1 ? '<img src="img/icons/silk/accept.png" />' : '<img src="img/icons/silk/cancel.png" />');
}
navitable::jqgridJson($out, 1, 0, PHP_INT_MAX, $total);
break;
}
core_terminate();
break;
case 'load':
case 2:
// edit/new form
if (!empty($_REQUEST['id'])) {
if (is_numeric($_REQUEST['id'])) {
$item->load(intval($_REQUEST['id']));
} else {
$item->load_from_theme($_REQUEST['id']);
}
}
if (isset($_REQUEST['form-sent'])) {
$item->load_from_post();
try {
$item->save();
if (!empty($_REQUEST['property-enabled'])) {
$enableds = array_values($_REQUEST['property-enabled']);
} else {
$enableds = array();
}
property::reorder("template", $item->id, $_REQUEST['template-properties-order'], $enableds);
$layout->navigate_notification(t(53, "Data saved successfully."), false, false, 'fa fa-check');
} catch (Exception $e) {
$layout->navigate_notification($e->getMessage(), true, true);
}
users_log::action($_REQUEST['fid'], $item->id, 'save', $item->title, json_encode($_REQUEST));
} else {
users_log::action($_REQUEST['fid'], $item->id, 'load', $item->title);
}
$out = templates_form($item);
break;
case 'save_template_file':
// save template html
if (!empty($_REQUEST['id'])) {
$item->load(intval($_REQUEST['id']));
}
$data = $_REQUEST['templates-file-edit-area'];
$data = str_replace("\r\n", "\r", $data);
$x = file_put_contents(NAVIGATE_PRIVATE . '/' . $website->id . '/templates/' . $item->file, $data);
echo json_encode($x > 0);
session_write_close();
exit;
break;
case 4:
// remove
if (!empty($_REQUEST['id'])) {
$item->load(intval($_REQUEST['id']));
if ($item->delete() > 0) {
$layout->navigate_notification(t(55, 'Item removed successfully.'), false);
$out = templates_list();
} else {
$layout->navigate_notification(t(56, 'Unexpected error.'), false);
//.........这里部分代码省略.........