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


PHP Ajax::is方法代码示例

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


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

示例1: init

 /**
  * Init
  */
 public function init()
 {
     parent::init();
     if (Ajax::is()) {
         event('ajax.hashchange');
     }
 }
开发者ID:brussens,项目名称:cogear2,代码行数:10,代码来源:Gear.php

示例2: upload_action

 /**
  * Access
  */
 public function upload_action()
 {
     if (Ajax::is() && $_FILES['images']) {
         $image = new Image_Upload(array('name' => 'images', 'allowed_types' => array('png', 'jpg', 'gif'), 'maxsize' => '100Kb', 'overwrite' => TRUE, 'path' => Image::uploadPath(), 'preset' => 'post.large'));
         $files = $image->upload();
         $data = array();
         $ajax = new Ajax();
         if ($image->uploaded) {
             $data['success'] = TRUE;
             $data['code'] = '';
             foreach ($files as $file) {
                 if ($file->uri_full) {
                     $data['code'] .= template('Image/templates/insert', array('image' => $file))->render();
                 }
             }
         } else {
             $data['success'] = FALSE;
             if ($image->errors) {
                 $data['messages'][] = array('type' => 'error', 'body' => implode('<br/>', $image->errors));
             }
         }
         $ajax->json($data);
     }
 }
开发者ID:brussens,项目名称:cogear2,代码行数:27,代码来源:Gear.php

示例3: delete_action

 /**
  * Delete post
  *
  * @param type $cid
  */
 public function delete_action($post_id)
 {
     $post = new Post();
     $post->id = $post_id;
     if ($post->find() && access('Post.delete.all')) {
         if ($post->delete()) {
             $message = t('Пост удалён');
             if (Ajax::is()) {
                 $data['success'] = TRUE;
                 $data['messages'] = array(array('type' => 'success', 'body' => $message));
                 $data['redirect'] = server('referer');
                 $ajax = new Ajax();
                 $ajax->json($data);
             }
             $post = new Post();
             $post->id = $post->post_id;
             flash_success($message);
             back(-2);
         }
     }
 }
开发者ID:brussens,项目名称:cogear2,代码行数:26,代码来源:Gear.php

示例4: result

 /**
  * Result
  *
  * @return  NULL|Core_ArrayObject — filtered and validated data
  */
 public function result()
 {
     // Define if form is requested via ajaxed
     $this->ajaxed = $this->options->ajax && Ajax::is() && cogear()->input->post('ajaxed') === $this->getId();
     $method = strtolower($this->options->method);
     $result = array();
     $is_valid = TRUE;
     if (cogear()->input->{$method}() or $_FILES) {
         foreach ($this->elements as $name => $element) {
             $value = $element->result();
             if ($value !== NULL) {
                 $result[$name] = $value;
             }
             if ($value === FALSE) {
                 $is_valid = FALSE;
             }
         }
     }
     if ($this->ajaxed) {
         $data = array();
         $data['success'] = $is_valid && $result;
         if ($data['success']) {
             $data['result'] = $result;
         } else {
             foreach ($this->elements as $key => $element) {
                 $element->errors->count() > 0 && ($data['errors'][$key] = $element->errors);
             }
             $ajax = new Ajax();
             $ajax->json($data);
         }
     }
     if ($is_valid && $result) {
         $result = Core_ArrayObject::transform($result);
     }
     if (!event('form.result.' . $this->options->name, $this, $is_valid, $result)->check() or !event('form.result', $this, $is_valid, $result)->check()) {
         return FALSE;
     }
     return $is_valid ? $result : FALSE;
 }
开发者ID:brussens,项目名称:cogear2,代码行数:44,代码来源:Object.php

示例5: ajax_action

 /**
  * Обработка Ajax-запросов
  *
  * @param string $action
  */
 public function ajax_action($action = 'scan', $path = '')
 {
     if (!Ajax::is()) {
         return event('403');
     }
     $ajax = new Ajax();
     $ajax->success = TRUE;
     $ajax->text = '';
     switch ($action) {
         case 'change':
             if ($lang = $this->input->post('lang')) {
                 if ($this->getLangs(array($lang))) {
                     $this->set('lang.lang', $lang);
                     $this->config->store();
                 } else {
                     $ajax->success = FALSE;
                 }
             }
             break;
         case 'save':
             $path = $this->input->post('path');
             if ($path && $this->checkPath($path)) {
                 $file = ROOT . DS . $path . $this->prepareFilePath();
                 $options = config('lang');
                 $options->file = $file;
                 $index = Lang::factory('temp', $options);
                 $index->load();
             } else {
                 $index = Lang::factory('index');
             }
             if ($values = $this->input->post('values')) {
                 $index->import($values);
             } else {
                 $source = $this->input->post('source');
                 $translation = $this->input->post('translation');
                 $index->set($source, $translation);
             }
             $index->save();
             break;
         case 'scan':
             if (!$this->checkPath($path)) {
                 exit(t("Вы указали недопустимый путь!"));
             }
             // Важно! Если выбираем только шестерёнки или только темы,
             // то для каждой из них обновляются языковые файлы
             if (preg_match('#(gears|themes)/?$#', $path)) {
                 session('admin.lang.updateEach', TRUE);
             }
             $path = $path ? ROOT . DS . $path : ROOT;
             $index_file = $path . DS . LANG . DS . $this->lang . EXT;
             File::mkdir(dirname($index_file));
             if ($this->input->get('reset')) {
                 cogear()->session->remove('admin.lang.scan');
                 $ajax->action = 'reset';
             }
             // Сначала сканируем PHP-файлы
             $files = session('admin.lang.scan');
             if (!is_array($files)) {
                 $files = File::findByMask($path, '/^.+\\.(php|js)$/i');
                 $files = array_reverse($files);
                 $folder = $path === ROOT ? '/' : File::pathToUri($path);
                 $ajax->text .= t('Сканирование папки <b>%s</b>…', $folder) . '<br/>';
                 session('admin.lang.scan.path', $path);
                 session('admin.lang.index', array());
                 session('admin.lang.scan', $files);
                 session('admin.lang.scan.counter', count($files));
                 session('admin.lang.scan.index', 1);
                 session('admin.lang.scan.translations', 1);
                 session('admin.lang.updateСurrent', FALSE);
             }
             if (!$files) {
                 $ajax->success = FALSE;
                 if (session('admin.lang.updateEach')) {
                     $this->dumpIndex($ajax);
                     cogear()->session->remove('admin.lang.updateEach');
                     cogear()->session->remove('admin.lang.updateCurrent');
                 } else {
                     $ajax->finish = TRUE;
                 }
                 $ajax->text .= t('<p class="alert alert-success">Сканирование завершено.</p>');
                 $ajax->result = t('Найдено <b>%d</b> строк', session('admin.lang.scan.translations'));
                 $ajax->text .= $ajax->result;
                 $ajax->index = session('admin.lang.scan.index');
                 $ajax->total = session('admin.lang.scan.counter');
                 cogear()->session->remove('admin.lang.scan');
                 cogear()->session->remove('admin.lang.scan.counter');
                 //                    cogear()->session->remove('admin.lang.scan.index');
                 cogear()->session->remove('admin.lang.scan.translations');
                 /**
                 *  $options = config('lang');
                  $options->path = dirname($index_file);
                  $index = Lang::factory('index', $options);
                  $index->load();
                  foreach ($strings as $string) {
                  $index->offsetExists($string) OR $index->set($string, '');
//.........这里部分代码省略.........
开发者ID:brussens,项目名称:cogear2,代码行数:101,代码来源:Gear.php


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