コード例 #1
0
 public function ibox_status_summary()
 {
     $begin = null;
     $end = null;
     $mode = 'day';
     $beginTime = new DateTime();
     $beginTime->sub(DateInterval::createFromDateString('1 month'));
     $endTime = new DateTime();
     if (!isset($_POST['__nouse__'])) {
         $begin = $this->input->post('begin');
         $end = $this->input->post('end');
         $mode = $this->input->post('mode');
         switch ($mode) {
             case 'month':
                 $this->setState('month', 'status');
                 break;
             case 'week':
                 $this->setState('week', 'status');
                 break;
         }
         $beginTime = parse_datetime($begin, $beginTime);
         $endTime = parse_datetime($end, $endTime);
     }
     $heart_beat_rate = get_ci_config('heart_beat_rate');
     $diff = ($endTime->getTimestamp() - $beginTime->getTimestamp()) / 60 / $heart_beat_rate;
     $user_id = $this->user_model->getLoginUserID();
     $this->jquery_mousewheel();
     $this->less('business/ibox_status_summary_css');
     $this->render('business/ibox_status_summary', array('form_data' => $this->_buildSearches($begin, $end, $mode), 'args' => array($user_id), 'online_args' => array($heart_beat_rate, $diff, $user_id), 'begin' => $begin, 'end' => $end, 'mode' => $mode));
 }
コード例 #2
0
function smarty_function_picture($params, $template)
{
    $src = smarty_plugin_get_variable($params, $template, 'src', true);
    $alt = smarty_plugin_get_variable($params, $template, 'alt');
    $path = smarty_plugin_get_variable($params, $template, 'path');
    $CI =& get_instance();
    $CI->load->helper('image');
    $file = find_file($src, 'static/img/');
    // Try to find the image in static/img
    if ($file == null) {
        // We can't read the file
        $file = find_file($src, 'static/uploads/');
        if ($file == null) {
            $src = 'default.png';
        }
    }
    $size = get_image_size($src);
    $size = $size['width'];
    $attr = $params;
    $medias = array();
    $ret = array();
    $attr['src'] = $src;
    if ($path != '') {
        $attr['path'] = site_url($path);
    }
    $ret[] = '<picture ' . _parse_form_attributes($attr, array()) . ' >';
    foreach ($params as $key => $value) {
        // Check if user has set the customized media
        if (strpos($key, 'media') !== false) {
            $media = str_replace('media', '', $key);
            $medias[] = $media;
            $ret[] = "\t" . '<source src="' . site_url('responsive/size/' . $value . '/' . $src) . '" media="(min-width:' . $media . 'px)">';
            continue;
        }
        $attr[$key] = smarty_plugin_get_variable($params, $template, $key, false);
    }
    if ($path == '') {
        $resolutions = get_ci_config('resolutions');
        foreach ($resolutions as $res) {
            if (array_search($res, $medias) !== false) {
                // If the resolution is already covered
                continue;
            }
            $ret[] = "\t" . '<source src="' . site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src) . '" media="(min-width:' . $res . 'px)">';
        }
    }
    $ret[] = "\t" . '<noscript>';
    $ret[] = "\t\t" . '<img src="' . site_url('static/img/' . $src) . '" alt="' . $alt . '">';
    $ret[] = "\t" . '</noscript>';
    $ret[] = '</picture>';
    return implode("\n", $ret);
}
コード例 #3
0
 public function __construct()
 {
     $this->sass = new Sass();
     if (!get_ci_config('debug_sass', false)) {
         $this->sass->setStyle(Sass::STYLE_COMPRESSED);
     }
     $this->sasses = array();
     $this->includePathes = array();
     $this->resolutions = get_ci_config('resolutions');
     foreach (array(APPPATH, 'pinet/') as $p) {
         $this->includePathes[] = FCPATH . $p . 'static/scss/';
     }
 }
コード例 #4
0
 public function __construct()
 {
     $this->key_path = get_ci_config('encryptor_key', FCPATH . APPPATH . 'config/encrypt.key');
     $this->public_key_path = get_ci_config('encryptor_public_key', FCPATH . APPPATH . 'config/encrypt_public.key');
     if (file_exists($this->key_path)) {
         ci_log('Loading the private key file from %s', $this->key_path);
         $this->key = file_get_contents($this->key_path);
     } else {
         ci_error('Can\'t find private key file at %s', $this->key_path);
     }
     if (file_exists($this->public_key_path)) {
         ci_log('Loading the public key file from %s', $this->public_key_path);
         $this->public_key = file_get_contents($this->public_key_path);
     } else {
         ci_error('Can\'t find public key file at %s', $this->key_path);
     }
 }
コード例 #5
0
function smarty_block_figure($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        // Skip the start part
        return;
    }
    $src = smarty_plugin_get_variable($params, $template, 'src', true);
    $path = smarty_plugin_get_variable($params, $template, 'path');
    $size = get_image_size($src);
    $size = $size['width'];
    if ($path == '') {
        // If we are using auto resizing, skip the resolutions
        $resolutions = get_ci_config('resolutions');
        foreach ($resolutions as $res) {
            $attr['data-media' . $res] = site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src);
        }
    }
    foreach ($params as $key => $value) {
        if ($key == 'path') {
            $attr[$key] = site_url(get_smarty_variable($params, $template, 'path', $value));
            continue;
        }
        if (strpos($key, 'media') !== false) {
            $attr['data-' . $key] = site_url('responsive/size/' . $value . '/' . $src);
        } else {
            $attr[$key] = get_smarty_variable($params, $template, $value, $value);
        }
    }
    $ret = array();
    $ret[] = '<figure ' . _parse_form_attributes($attr, array()) . '>';
    if (isset($attr['action'])) {
        $ret[] = '<a href="' . $attr['action'] . '">';
    }
    $ret[] = '<noscript>';
    $ret[] = '<img src="' . site_url('static/img/' . $src) . '">';
    $ret[] = '</noscript>';
    if (isset($attr['action'])) {
        $ret[] = '</a>';
    }
    $ret[] = '<figcaption>';
    $ret[] = $content;
    $ret[] = '</figcaption>';
    $ret[] = '</figure>';
    return implode("\n", $ret);
}
コード例 #6
0
 public function addOperation($ids, $data)
 {
     $this->config->load('operations');
     $result = -1;
     foreach ($ids as $id) {
         $data['gateway_id'] = $id;
         $data['operation'] = get_ci_config($data['operation'], $data['operation']);
         $operation = $this->getOperation($id, $data['operation'], 0);
         if ($operation) {
             $now = new DateTime();
             $data['timestamp'] = $now->format('Y-m-d H:i:s');
             $result = $this->update($operation->id, $data);
         } else {
             $result = $this->insert($data);
         }
     }
     return $result;
 }
コード例 #7
0
 protected function installNavigations($actions = null)
 {
     if ($actions == null) {
         $actions = get_ci_config('navigations');
     }
     foreach ($actions as $action) {
         $this->action_model->insert($action);
         if (isset($action['subnavi'])) {
             $arr = array();
             $subnavis = $action['subnavi'];
             foreach ($subnavis as $subnavi) {
                 $subnavi['group'] = $action['name'];
                 $arr[] = $subnavi;
             }
             //ci_log('The subnavis is ', $arr);
             $this->installNavigations($arr);
         }
     }
 }
コード例 #8
0
function smarty_function_css($params, $template)
{
    $CI =& get_instance();
    foreach ($CI->cssFiles as $css) {
        echo $css->render();
    }
    if (isset($CI->sasscompiler)) {
        $meta = get_controller_meta();
        $CI =& get_instance();
        $suffix = get_default($CI, 'sass_suffix', '');
        $name = $meta->controller . '-' . $meta->method . $suffix . '.css';
        $dir = 'cache/css/';
        if (!file_exists(FCPATH . APPPATH . $dir)) {
            mkdir(FCPATH . APPPATH . $dir, 0755, true);
        }
        $file_name = FCPATH . APPPATH . $dir . $name;
        if (!file_exists($file_name) || get_ci_config('debug_sass')) {
            ci_log('The compiler is ', $CI->sasscompiler);
            file_put_contents($file_name, $CI->sasscompiler->compile());
        }
        return '<link rel="stylesheet" href="' . site_url(APPPATH . $dir . $name) . '">';
    }
}
コード例 #9
0
function send_admin_email($to, $subject, $message, $attachments = array(), $mail_type = 'qq')
{
    $CI =& get_instance();
    $CI->config->load('email_settings');
    $CI->load->library('email');
    $config = get_ci_config('email_settings');
    if ($config) {
        $email_config = $config[$mail_type];
        $from = $config['admin_info']['from'];
        $name = $config['admin_info']['name'];
        $CI->email->initialize($email_config);
        $CI->email->from($from, $name);
        $CI->email->to($to);
        $CI->email->subject($subject);
        $CI->email->message($message);
        foreach ($attachments as $attachment) {
            $CI->email->attach($attachment);
        }
        $CI->email->send();
    }
}
コード例 #10
0
 function __construct()
 {
     parent::__construct();
     $this->hackFormValidation();
     $this->load->helper(array('language', 'url', 'common', 'page', 'form'));
     $this->load->library(array('form_validation', 'log', 'fb', 'interceptor_support'));
     if (get_ci_config('enable_audit')) {
         $this->log('The audit manager is enabled for this application');
         $this->load->library('audit_manager');
     }
     if (get_ci_config('enable_transaction')) {
         $this->log('The transaction manager is enabled for this application');
         $this->load->library('transaction_manager');
     }
     if (get_ci_config('enable_security') && !defined('PHPUNIT_TEST')) {
         // Skip the testing environment
         $this->log('The security engine is enabled for this application');
         $this->load->library('security_engine');
     }
     // Load the default language files, if the lang is set
     if ($this->messages != '') {
         $this->loadLang();
     }
     // This is for the js and css auto import support
     $this->jsFolder = $this->config->item('js_folder');
     $this->cssFolder = $this->config->item('css_folder');
     $this->bootstrapFolder = $this->config->item('bootstrap_folder');
     $this->datatablesFloder = $this->config->item('datatables_folder');
     $this->use_less = $this->config->item('use_less');
     // This is used for hacking smarty view
     $this->load->spark('smartyview/0.0.1');
     $arr = obj2array($this->smartyview);
     $this->smarty = $arr['smarty'];
     $this->smarty->addPluginsDir(APPPATH . 'views/smarty_plugins');
     $this->jsFiles = array();
     $this->cssFiles = array();
 }
コード例 #11
0
 function render($template, $args = array())
 {
     $t = '';
     if (isset($this->title)) {
         $t = $this->title;
     }
     if (isset($args['title'])) {
         $t = $args['title'];
     }
     if (isset($this->navigation)) {
         $args['navigations'] = $this->navigation->getNavigations();
     }
     if (get_ci_config('less_js')) {
         $args['use_less_js'] = true;
     }
     if (is_array($t)) {
         $args['title'] = lang_f($t[0], $t[1]);
     } else {
         $args['title'] = lang($t);
     }
     if (!$this->input->get('nohead')) {
         $args['has_head'] = true;
     } else {
         $args['has_head'] = false;
     }
     if (isset($this->interceptors) && isset($this->interceptors['render'])) {
         foreach ($this->interceptors['render'] as $i) {
             $i->intercept($template, $args);
         }
     }
     $this->smartyview->render($template . '.tpl', $args);
 }
コード例 #12
0
function render_image_thumbnail($orig, $width, $height = 0)
{
    $file = inner_create_image_thumbnail($orig, $width, $height);
    if ($file) {
        if (get_ci_config('enable_cache') && cache_support($file)) {
            return;
        }
        $out = fopen('php://output', 'wb');
        $in = fopen($file, 'r');
        stream_copy_to_stream($in, $out);
        fclose($in);
        return;
    }
    trigger_error('No image generated!!!!');
}