当前位置: 首页>>代码示例>>PHP>>正文


PHP system::json方法代码示例

本文整理汇总了PHP中system::json方法的典型用法代码示例。如果您正苦于以下问题:PHP system::json方法的具体用法?PHP system::json怎么用?PHP system::json使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在system的用法示例。


在下文中一共展示了system::json方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addAction

 public function addAction()
 {
     if (user::isGuest() && reg::getKey('/comments/only_reg')) {
         system::stop();
     }
     if (user::isGuest() && !system::validCapcha('random_image')) {
         system::json(array('error' => 1, 'data' => lang::get('FEEDBACK_ERROR1')));
     }
     // Добавляем новый комментарий
     $comment = new comment();
     $comment->setParentId(system::POST('parent_id'));
     $comment->setObjId(system::POST('obj_id'));
     $comment->setUserName(system::POST('username'));
     $comment->setEmail(system::POST('email'));
     $comment->setText(system::POST('text'));
     $comment->setSendEmail(system::POST('send_email'));
     $obj_id = $comment->save();
     if ($obj_id) {
         page::assign('current_url', system::POST('back_url'));
         $html = page::macros('comments')->view($comment->id());
         system::json(array('error' => 0, 'data' => $html));
     } else {
         system::json(array('error' => 2, 'data' => $comment->getErrorListText(' ')));
     }
     if (!empty($_POST['back_url']) && !system::isAjax()) {
         system::redirect($_POST['back_url'] . '#comment' . $obj_id, true);
     } else {
         system::stop();
     }
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:30,代码来源:controller.php

示例2: subscribeAction

 public function subscribeAction()
 {
     $email = system::POST('email', isEmail);
     if (empty($email)) {
         $answer = array('error' => 1, 'msg' => lang::get('SUBSCRIPTION_EMPTY_EMAIL'));
     } else {
         if (empty($_POST['subscribes'])) {
             $answer = array('error' => 2, 'msg' => lang::get('SUBSCRIPTION_EMPTY_LIST'));
         } else {
             $sid = mailingProcess::addEmail($email, $_POST['subscribes'], true);
             if ($sid) {
                 $answer = array('error' => 0, 'msg' => lang::get('SUBSCRIPTION_MSG'));
             } else {
                 $answer = array('error' => 3, 'msg' => lang::get('SUBSCRIPTION_ERROR'));
             }
         }
     }
     if (!system::isAjax()) {
         if (!empty($answer['error'])) {
             system::saveErrorToSession('subscription', $answer);
             if (!empty($_POST['back_url'])) {
                 system::redirect($_POST['back_url'], true);
             }
         } else {
             system::redirect('/subscription/ok');
         }
     } else {
         system::json($answer);
     }
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:30,代码来源:controller.php

示例3: proc_edit

 public function proc_edit()
 {
     $text = system::checkVar(system::POST('minitext'), isText);
     $id = system::checkVar(system::POST('minitext_id'), isInt);
     $key = ormPages::getPrefix() . '/minitext/' . $id;
     if ($text && $id && reg::existKey($key)) {
         if (reg::setKey($key, $text)) {
             system::json(array('error' => 0));
             system::stop();
         }
     }
     system::json(array('error' => 1, 'errorInfo' => lang::get('STRUCTURE_MINITEXT_ERROR')));
     system::stop();
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:14,代码来源:__minitext.php

示例4: doAction

 public function doAction()
 {
     $answers = system::POST('answers');
     $error = 2;
     $msg = '';
     if (count($answers) > 0) {
         if ($vote = ormPages::get(system::POST('vote_id'), 'vote')) {
             if (!$vote->close) {
                 $sel = new ormSelect('answer');
                 $sel->fields('name, count');
                 $sel->where('parents', '=', $vote->id);
                 while ($answ = $sel->getObject()) {
                     if (in_array($answ->id, $answers)) {
                         $answ->count = $answ->count + 1;
                         $answ->save();
                         if (!$vote->multiselect) {
                             break;
                         }
                     }
                 }
                 cache::delete('vote' . $vote->id . '1');
                 cache::delete('vote' . $vote->id . '0');
                 $_SESSION['voting_' . $vote->id] = 1;
                 $error = 0;
             } else {
                 // Голосование закрыто
                 $msg = lang::get('VOTING_MSG_CLOSE');
                 $error = 1;
             }
         } else {
             $msg = lang::get('VOTING_MSG_NOT_FOUND');
         }
     } else {
         $msg = lang::get('VOTING_MSG_CHOSE_VAR');
     }
     if (system::isAjax()) {
         if ($error < 2 && $vote instanceof ormPage) {
             $data = page::macros('voting')->objView($vote->id);
         }
         system::json(array('error' => 0, 'html' => $data, 'msg' => $msg));
     } else {
         if (!empty($_POST['back_url'])) {
             system::redirect($_POST['back_url'], true);
         } else {
             system::redirect('/');
         }
     }
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:48,代码来源:controller.php

示例5: proc

 public function proc()
 {
     if (system::isAjax() && system::issetUrl(2)) {
         if (system::url(2) == 'start') {
             searchIndex::clear();
             reg::setKey(ormPages::getPrefix('search') . '/index_date', date('d.m.Y'));
             $sel = new ormSelect();
             $sel->fields('name');
             $sel->findInPages();
             $sel->where('active', '=', 1);
             $sel->where('in_search', '=', 1);
             echo $sel->getCount();
         } else {
             if (system::url(2) == 'info') {
                 $data = reg::getKey(ormPages::getPrefix('search') . '/index_date');
                 if (empty($data)) {
                     $data = '-';
                 }
                 system::json(array('pages' => searchIndex::getCountPages(), 'words' => searchIndex::getCountWords(), 'data' => $data));
             } else {
                 $sel = new ormSelect();
                 $sel->findInPages();
                 $sel->where('active', '=', 1);
                 $sel->where('in_search', '=', 1);
                 $sel->limit(system::url(2), 1);
                 searchIndex::indexPage($sel->getObject());
                 echo 'ok';
             }
         }
         system::stop();
     }
     if (system::POST('parram') == 'clear') {
         searchIndex::clear();
     }
     system::redirect('/search/index');
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:36,代码来源:__index.php

示例6: change_rateAction

 public function change_rateAction()
 {
     if ($page = ormPages::get(system::url(2))) {
         if (!isset($_SESSION['change_rate'][$page->id]) && $page->getClass()->issetField('rate')) {
             // Высчитываем новый рейтинг
             $rate = system::checkVar(system::url(3), isInt);
             if ($rate > 5) {
                 $rate = 5;
             } else {
                 if ($rate < 1) {
                     $rate = 1;
                 }
             }
             $new_rate = $page->rate != 0 ? ($page->rate + $rate) / 2 : $rate;
             // Сохраняем
             $page->rate = $new_rate;
             $page->save();
             $_SESSION['change_rate'][$page->id] = 1;
             system::json(array('error' => 0, 'new_rate' => $new_rate));
         }
     }
     system::json(array('error' => 1, 'new_rate' => 0));
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:23,代码来源:controller.php

示例7: send_messageAction


//.........这里部分代码省略.........
             $obj->in_search = 1;
             $obj->in_index = 1;
             $obj->is_home_page = 0;
             if ($obj->name != '') {
                 $obj->h1 = $obj->name;
                 $obj->title = $obj->name;
             }
             $obj->pseudo_url = rand(1000, 9999);
             $obj->template_id = ($sect = ormPages::get($form_obj->section)) ? $sect->template_id : 1;
             $obj->form_id = $form_obj->id;
             $obj->setRightForAll(2);
             $obj_id = $obj->save();
             if ($obj_id) {
                 $obj->pseudo_url = $obj_id;
                 $obj->save();
                 $obj = new ormPage($obj_id);
             } else {
                 $issetErrors = true;
                 $f = $obj->getErrorFields();
                 $answer = array('field' => $f['focus'], 'msg' => $obj->getErrorListText(' '));
             }
         }
         if (!$issetErrors) {
             // Отправка нужных писем
             page::assign('site_name', domains::curDomain()->getSiteName());
             page::assign('site_url', domains::curDomain()->getName());
             page::assign('base_email', domains::curDomain()->getEmail());
             while (list($key, $val) = each($_POST)) {
                 page::assign($key, system::checkVar($val, isText));
             }
             if (isset($obj)) {
                 $fields = $obj->getClass()->loadFields();
                 foreach ($fields as $field) {
                     if (in_array($field['f_type'], array(70, 75, 80, 85))) {
                         $fsname = $field['f_sname'];
                         $fvalue = $obj->{$fsname};
                         if ($fvalue != '') {
                             page::assign($fsname, $fvalue);
                         }
                     }
                 }
             }
             // Если указан список адресатов, отправляем письма
             if ($form_obj->mailing_list != '') {
                 $mail = new phpmailer();
                 $mail->From = $this->parse($form_obj->admin_sender_address);
                 $mail->FromName = $this->parse($form_obj->admin_sender_name);
                 /*
                                   if (!empty($this->files))
                 for($i = 0; $i < count($this->files); $i++)
                    $mail->AddAttachment($this->files[$i][0], $this->files[$i][1]);
                 */
                 $mail->AddAddress($form_obj->mailing_list);
                 $mail->WordWrap = 50;
                 $mail->IsHTML(true);
                 $mail->Subject = $this->parse($form_obj->admin_subject);
                 $mail->Body = $this->parse($form_obj->admin_template);
                 $mail->Send();
             }
             // Если нужно, отправляем уведомление пользователю
             if ($form_obj->send_notice && !$issetErrors) {
                 $mail = new phpmailer();
                 $mail->From = $this->parse($form_obj->notice_sender_address);
                 $mail->FromName = $this->parse($form_obj->notice_sender_name);
                 $mail->AddAddress(system::POST('email'));
                 $mail->WordWrap = 50;
                 $mail->IsHTML(true);
                 $mail->Subject = $this->parse($form_obj->notice_subject);
                 $mail->Body = $this->parse($form_obj->notice_template);
                 $mail->Send();
             }
             // Показываем результат
             if (system::isAjax()) {
                 if ($form_obj->msg != '') {
                     $text = $form_obj->msg;
                 } else {
                     $text = lang::get('FEEDBACK_MSG_1');
                 }
                 system::json(array('field' => 0, 'msg' => strip_tags($text)));
             } else {
                 system::redirect('/feedback/ok/' . $form_obj->id);
             }
         } else {
             // Произошли ошибки
             if (system::isAjax()) {
                 system::json($answer);
             } else {
                 system::savePostToSession();
                 system::saveErrorToSession('feedback', $answer);
                 if (empty($_POST['back_url'])) {
                     $_POST['back_url'] = '/structure/map';
                 }
                 system::redirect($_POST['back_url'], true);
             }
         }
         system::stop();
     } else {
         system::stop();
     }
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:101,代码来源:controller.php

示例8: change_password_procAction

 public function change_password_procAction()
 {
     if (user::isGuest()) {
         system::redirect('/users/add');
     }
     $cur_password = system::POST('current_password', isPassword);
     $new_passw = system::POST('password', isPassword);
     $new_passw2 = system::POST('password2', isPassword);
     if ($cur_password == user::get('password')) {
         if ($new_passw && $new_passw == $new_passw2) {
             if ($user = user::getObject()) {
                 $user->password = system::POST('password');
                 if ($user->save()) {
                     if (system::isAjax()) {
                         system::json(array('ok' => 1));
                     } else {
                         system::redirect('/users/change_password/ok');
                     }
                 }
             }
         }
     } else {
         $answer = array('msg' => lang::get('USERS_CHANGE_PSW_MSG'), 'field' => 'current_password');
         if (!system::isAjax()) {
             system::saveErrorToSession('change_password', $answer);
             system::redirect('/users/change_password');
         } else {
             system::json($answer);
         }
     }
     system::redirect('/users/change_password');
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:32,代码来源:controller.php


注:本文中的system::json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。