Beispiel #1
0
 function send_params($a, $b, $c, $d)
 {
     $ajax = CJAX::getInstance();
     $params = "\r\n\t\tparams a: {$a}\n\r\n\t\tparams b: {$b}\n\r\n\t\tparams c: {$c}\n\r\n\t\tparams d: {$d}\n\r\n\t\t";
     $ajax->alert($params);
     $ajax->update('params', $params);
 }
Beispiel #2
0
 public function message($text, $type = self::CSS_SUCCESS)
 {
     $ajax = CJAX::getInstance();
     if ($type == self::CSS_SUCCESS || !$type) {
         $css = " cjax_success";
     } else {
         if ($type == self::CSS_WARNING) {
             $css = " cjax_warning";
         } else {
             if ($type == self::CSS_ERROR) {
                 $css = " cjax_error";
             } else {
                 if ($type == self::CSS_PROCESS) {
                     $css = " cjax_process cjax_loading_f";
                 } else {
                     if ($type == self::CSS_INFO) {
                         $css = " cjax_info";
                     } else {
                         if ($type == self::CSS_LOADING) {
                             $css = " cjax_process cjax_loading_f";
                         }
                     }
                 }
             }
         }
     }
     $data = "<div class='cjax_message cjax_message_type{$css}'>{$text}</div>\n";
     return $data;
 }
Beispiel #3
0
 function send_checkbox($check)
 {
     $ajax = CJAX::getInstance();
     if ($check) {
         $ajax->success("Is checked..");
     } else {
         $ajax->warning("Is not checked..");
     }
 }
Beispiel #4
0
 /**
  * 
  * @deprecated
  * @param unknown_type $file_names
  */
 function send_file($file_names = null)
 {
     $ajax = CJAX::getInstance();
     $dir = realpath(dirname(__FILE__) . '/../');
     //directory where the file is uploaded..
     if ($_FILES || $ajax->get('cjax_iframe')) {
         if (!is_writable($dir)) {
             return $ajax->overlayContent("Directory {$dir} is not writeable.\nPermission denied.<br /> (chmod {$dir} 777) or make sure the directory exists.");
         }
         if (empty($_FILES)) {
             return $ajax->overlay("ajax.php?controller=upload_file&function=error");
         }
         $file = $_FILES['my_file'];
         if (!$file['name']) {
             exit('error');
         }
         $temp = $file['tmp_name'] ? $file['tmp_name'] : null;
         $temp = trim($temp, DIRECTORY_SEPARATOR);
         if (@move_uploaded_file($temp, $dir . '/' . $file['name'])) {
             $ajax->success("File uploaded..", 10);
         } else {
             $ajax->warning("Could not move file");
         }
     } else {
         if ($ajax->request()) {
             $ajax->process("Uploading file..", 1000);
             //Ajax request
             //PRE-POST FILE
             if (!$_REQUEST['my_file']) {
                 $ajax->warning("Please select a file");
                 $ajax->focus('my_file');
                 exit;
             }
         }
     }
 }
Beispiel #5
0
 public static function connect($file = null, $port = 80, $local = false)
 {
     $ajax = CJAX::getInstance();
     if (!$port) {
         $port = $ajax->port;
         if (!$port) {
             $port = 80;
         }
     }
     if (!function_exists('fsockopen')) {
         die('no fsockopen: be sure that php function fsockopen is enabled.');
     }
     $fp = @fsockopen($host, $port, $errno, $errstr);
     if (!$fp) {
         return false;
     }
     if ($errstr) {
         die('error:' . $errstr);
     }
     if ($fp) {
         $base = "/";
         @fputs($fp, "GET {$base}{$file} HTTP/1.1\r\n");
         @fputs($fp, "HOST: {$host}\r\n");
         @fputs($fp, "Connection: close\r\n\r\n");
     } else {
         return false;
     }
     $get_info = false;
     $data = array();
     while (!feof($fp)) {
         if ($get_info) {
             $data[] = fread($fp, 1024);
         } else {
             if (fgets($fp, 1024) == "\r\n") {
                 $get_info = true;
             } else {
                 //break;
             }
         }
     }
     fclose($fp);
     return implode($data);
 }
Beispiel #6
0
    protected function _class($controller)
    {
        $raw_controller = $controller;
        $ajax = ajax();
        if ($ajax->config->camelize) {
            $controller = $ajax->camelize($controller, $ajax->config->camelizeUcfirst);
        }
        $_classes = array();
        $_classes[] = 'controller_' . $controller;
        $_classes[] = '_' . $controller;
        $_classes[] = $controller;
        //backward compatiblity with > 5.0-RC2
        $_classes[] = 'controller_' . $raw_controller;
        $_classes[] = '_' . $raw_controller;
        $_classes[] = $raw_controller;
        do {
            $c = $_classes[key($_classes)];
            if (class_exists($c)) {
                return $c;
            }
        } while (next($_classes));
        return $c;
    }
}
define('AJAX_CONTROLLER', 1);
require_once dirname(__FILE__) . '/cjax/cjax.php';
$ajax = CJAX::getInstance();
$controller = $ajax->input('controller');
if ($controller) {
    new ajax($controller);
}
Beispiel #7
0
 /**
  *
  * this is part of the "invalid" plugin which displays an dynamic invalid message.
  */
 function invalid()
 {
     $ajax = CJAX::getInstance();
     $ajax->invalid(array('text1' => 'Enter Value..', 'text2' => 'Enter Value..', 'text3' => 'Enter Value..'));
 }
Beispiel #8
0
 function confirm_action()
 {
     $ajax = CJAX::getInstance();
     $ajax->success("Do something..");
 }
Beispiel #9
0
 function bind_elements()
 {
     $ajax = CJAX::getInstance();
     $ajax->info("same command..");
 }
Beispiel #10
0
 function test()
 {
     $ajax = CJAX::getInstance();
     $ajax->success("Testing controller <b>sample</b>.  Works ok.");
 }
Beispiel #11
0
 function fire_alert($message)
 {
     $ajax = CJAX::getInstance();
     $ajax->alert($message);
 }
Beispiel #12
0
function ajax()
{
    return CJAX::getInstance();
}
Beispiel #13
0
 /**
  * Submit a form
  *
  * @param require string $url  url where the request will be sent to
  * @param require string $form_id  the form id
  * @param optional string $container_id = null  alternative element where to load the response
  * @param optional string $confirm  ask before sending the request
  * @return unknown
  */
 public function form($url, $form_id = null, $container_id = null, $confirm = null)
 {
     $ajax = CJAX::getInstance();
     $out = array();
     $out['do'] = '_form';
     $out['url'] = $url;
     if ($form_id) {
         $out['form_id'] = $form_id;
     }
     if (!is_null($container_id)) {
         $out['container'] = $container_id;
     }
     if (!is_null($ajax->text)) {
         $out['text'] = $ajax->text;
     } elseif ($ajax->text === false) {
         $out['text'] = 'Loading...';
     }
     if ($confirm) {
         $out['confirm'] = $confirm;
     }
     if (is_array($ajax->post)) {
         $args = http_build_query($ajax->post);
         $out['args'] = $args;
         $out['post'] = true;
     } else {
         $out['post'] = 1;
     }
     $xml = $this->xmlItem($this->xml($out), 'form', 'api');
     return $xml;
 }