コード例 #1
0
ファイル: Page.php プロジェクト: frogsystem/legacy-bridge
 /**
  * @param $view
  * @return \template
  */
 protected function getTemplate($view)
 {
     $template = new \template();
     $template->setFile(strtok($view, '/'));
     $template->load(strtok('/'));
     return $template;
 }
コード例 #2
0
ファイル: domain.php プロジェクト: sunfun/Bagira.CMS
 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;
             }
         }
     }
 }
コード例 #3
0
ファイル: polls.php プロジェクト: frogsystem/legacy-polls
     $template = new \template();
     $template->setFile('0_polls.tpl');
     $template->load('LIST_LINE');
     $template->tag('question', $poll_arr['poll_quest']);
     $template->tag('url', $poll_arr['poll_url']);
     $template->tag('all_votes', $poll_arr['all_votes']);
     $template->tag('participants', $poll_arr['poll_participants']);
     $template->tag('type', $poll_arr['poll_type']);
     $template->tag('start_date', $poll_arr['poll_start']);
     $template->tag('end_date', $poll_arr['poll_end']);
     $template = $template->display();
     $list_lines .= $template;
 }
 // Get Template
 $template = new \template();
 $template->setFile('0_polls.tpl');
 $template->load('LIST_BODY');
 $template->tag('polls', $list_lines);
 $template->tag('order_question', get_poll_list_order('question', $_GET['sort'], $_GET['order']));
 $template->tag('order_all_votes', get_poll_list_order('all_votes', $_GET['sort'], $_GET['order'], 0));
 $template->tag('order_participants', get_poll_list_order("participants", $_GET['sort'], $_GET['order'], 0));
 $template->tag('order_type', get_poll_list_order('type', $_GET['sort'], $_GET['order']));
 $template->tag('order_start_date', get_poll_list_order('start_date', $_GET['sort'], $_GET['order'], 0));
 $template->tag('order_end_date', get_poll_list_order('end_date', $_GET['sort'], $_GET['order'], 0));
 $template->tag('arrow_question', get_poll_list_arrows('question', $_GET['sort'], $_GET['order']));
 $template->tag('arrow_all_votes', get_poll_list_arrows('all_votes', $_GET['sort'], $_GET['order']));
 $template->tag('arrow_participants', get_poll_list_arrows('participants', $_GET['sort'], $_GET['order']));
 $template->tag('arrow_type', get_poll_list_arrows('type', $_GET['sort'], $_GET['order']));
 $template->tag('arrow_start_date', get_poll_list_arrows('start_date', $_GET['sort'], $_GET['order']));
 $template->tag('arrow_end_date', get_poll_list_arrows('end_date', $_GET['sort'], $_GET['order']));
 $template = $template->display();
コード例 #4
0
ファイル: language.php プロジェクト: sunfun/Bagira.CMS
 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;
             }
         }
     }
 }
コード例 #5
0
ファイル: __page.php プロジェクト: sunfun/Bagira.CMS
 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;
     }
 }
コード例 #6
0
ファイル: __settings.php プロジェクト: sunfun/Bagira.CMS
 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;
 }