public function _add_layer()
 {
     $this->layers = Event::$data;
     $this->layers = $this->_create_layer();
     // Return layers object with new Cloudmade Layer
     Event::$data = $this->layers;
 }
Пример #2
0
 /**
  * Put clickable links into description
  */
 public function _make_clickable()
 {
     // Access the report description
     $report_description = Event::$data;
     $report_description = $this->_convert_to_clickable($report_description);
     // Return new description
     Event::$data = $report_description;
 }
Пример #3
0
 public function _embed_youtube()
 {
     // Access the report description
     $report_description = Event::$data;
     $report_description = $this->_auto_embed($report_description);
     // Return new description
     Event::$data = $report_description;
 }
Пример #4
0
 public static function render($print = false)
 {
     Benchmark::start(self::$benchmark_name);
     $template = new View('toolbar');
     if (Kohana::config('debug_toolbar.panels.database')) {
         $template->set('queries', self::queries());
     }
     if (Kohana::config('debug_toolbar.panels.logs')) {
         $template->set('logs', self::logs());
     }
     if (Kohana::config('debug_toolbar.panels.vars_and_config')) {
         $template->set('configs', self::configs());
     }
     if (Kohana::config('debug_toolbar.panels.files')) {
         $template->set('files', self::files());
     }
     if (Kohana::config('debug_toolbar.firephp_enabled')) {
         self::firephp();
     }
     switch (Kohana::config('debug_toolbar.align')) {
         case 'right':
         case 'center':
         case 'left':
             $template->set('align', Kohana::config('debug_toolbar.align'));
             break;
         default:
             $template->set('align', 'left');
     }
     $template->set('scripts', file_get_contents(Kohana::find_file('views', 'toolbar', true, 'js')));
     Benchmark::stop(self::$benchmark_name);
     if (Kohana::config('debug_toolbar.panels.benchmarks')) {
         $template->set('benchmarks', self::benchmarks());
     }
     if (Event::$data) {
         if (Kohana::config('debug_toolbar.auto_render') or Kohana::config('debug_toolbar.secret_key') !== FALSE and isset($_GET[Kohana::config('debug_toolbar.secret_key')])) {
             // try to add css to <head>, otherwise, send to template
             $styles = file_get_contents(Kohana::find_file('views', 'toolbar', false, 'css'));
             if (stripos(Event::$data, '</head>') !== FALSE) {
                 Event::$data = str_ireplace('</head>', $styles . '</head>', Event::$data);
             } else {
                 $template->set('styles', $styles);
             }
             // try to add js and HTML just before the </body> tag,
             // otherwise just append it to the output
             if (stripos(Event::$data, '</body>') !== FALSE) {
                 Event::$data = str_ireplace('</body>', $template->render() . '</body>', Event::$data);
             } else {
                 Event::$data .= $template->render();
             }
         }
     } else {
         if ($print) {
             $template->render(TRUE);
         } else {
             return $template->render();
         }
     }
 }
Пример #5
0
 protected function viewSetup()
 {
     $this->subview = new View('media/update');
     $this->subview->tab = 'main';
     $this->subview->section = 'general';
     $data = Event::$data;
     Event::run('bluebox.media.widget');
     Event::$data = $data;
     if (self::$components) {
         $this->subview->set('components', self::$components);
         return TRUE;
     }
     return FALSE;
 }
Пример #6
0
 /**
  * Appends a javascript redirect if to webgrind if XDEBUG_PROFILE is present.
  */
 public function webgrind_redirect()
 {
     //  check for XDEBUG_PROFILE
     if (strpos(Router::$query_string, 'XDEBUG_PROFILE')) {
         $js = self::js_new_window();
         // check for body tag and insert js after that or if no body tag
         // then prepend it to view data.
         if ($pos = stripos(Event::$data, '<body>')) {
             $replace = substr(Event::$data, $pos, 6) . $js;
             Event::$data = substr_replace(Event::$data, $replace, $pos, 6);
         } else {
             Event::$data = $js . Event::$data;
         }
     }
 }
Пример #7
0
 protected function _callListener(callable $listener, Event $event)
 {
     $data = $event->data();
     $length = count($data);
     if ($length) {
         $data = array_values($data);
     }
     switch ($length) {
         case 0:
             return $listener($event);
         case 1:
             return $listener($event, $data[0]);
         case 2:
             return $listener($event, $data[0], $data[1]);
         case 3:
             return $listener($event, $data[0], $data[1], $data[2]);
         default:
             array_unshift($data, $event);
             return call_user_func_array($listener, $data);
     }
 }
 /**
  * This bit makes the reports::fetch_incidents() filter by IVR comments
  */
 public function _add_ivr_comment_filter()
 {
     $params = $this->get_get_params();
     if ($params['time'] != 'N/A') {
         $filter_params = Event::$data;
         //get the table prefix
         $table_prefix = Kohana::config('database.default.table_prefix');
         $sql = 'i.id IN (SELECT DISTINCT data.incident_id FROM ' . $table_prefix . 'ivrapi_data AS data ';
         $sql .= 'LEFT JOIN ' . $table_prefix . 'ivrapi_data_comments AS comments ON comments.ivr_data_id = data.id ';
         //don't bother if we don't care about time
         if ($params['time'] != '2') {
             $sql .= 'LEFT JOIN ' . $table_prefix . 'incident_category AS ic ON ic.incident_id = data.incident_id ';
         }
         //get the operator
         $operator = $params['operator'];
         //create the where text
         $i = 0;
         foreach ($params['conditions'] as $key) {
             //skip this
             if ($key == 'undefined') {
                 continue;
             }
             $i++;
             if ($i == 1) {
                 $sql .= ' WHERE ';
             }
             if ($i > 1) {
                 $sql .= $operator;
             }
             $sql .= $this->condition_mapping[$key] . ' = 1 ';
         }
         //deal with the time component
         $sql .= $this->time_mapping[$params['time']];
         $sql .= ' ) ';
         array_push($filter_params, $sql);
         Event::$data = $filter_params;
     }
 }
Пример #9
0
 public function test()
 {
     Event::$data = Event::$data . '<!-- Powered by Kohana-->';
 }
Пример #10
0
function test_filter()
{
    $trace = debug_backtrace();
    $event = $trace[2]['args'][0];
    Event::$data = $event . Event::$data;
}
Пример #11
0
 /**
  * Ejecuta los handlers asociados al evento
  *
  * @param string $event evento
  * @param array $args argumentos
  * @return mixed
  */
 public static function trigger($event, $args = array())
 {
     $value = false;
     if (isset(self::$_events[$event])) {
         foreach (self::$_events[$event] as $handler) {
             $value = call_user_func_array($handler, $args);
         }
     }
     self::$data = null;
     return $value;
 }
Пример #12
0
 /**
  * This method will add in some Density Map specific filtering
  */
 public function _add_incident_filter()
 {
     //We're going to assume that the big map plugin will handle the AND / OR / Simple Groups stuff
     //check for the "dm" get parameter
     if (isset($_GET['dm']) and !is_array($_GET['dm']) and intval($_GET['dm']) >= 0) {
         //get the table prefix
         $table_prefix = Kohana::config('database.default.table_prefix');
         //get the params
         $cat_id = intval($_GET['dm']);
         $params = Event::$data;
         array_push($params, 'i.id IN (SELECT DISTINCT incident_id FROM ' . $table_prefix . 'incident_category WHERE category_id = ' . $cat_id . ')');
         Event::$data = $params;
     }
 }
Пример #13
0
 /**
  * Runs an event.
  * @param string $name
  * @param null $data
  * @return void
  */
 public static function run($name, $data = null)
 {
     if (!empty(self::$_events[$name])) {
         self::$data = $data;
         $callbacks = self::get($name);
         foreach ($callbacks as $callback) {
             call_user_func($callback);
         }
         $clear_data = '';
         self::$data =& $clear_data;
     }
     // Mark event as running
     self::$_has_run[$name] = $name;
 }
 /**
  * Renders the Debug Toolbar
  *
  * @param bool print rendered output
  * @return string debug toolbar rendered output
  */
 public static function render($print = false)
 {
     Benchmark::start(self::$benchmark_name);
     $template = new View('toolbar');
     // Database panel
     if (Kohana::config('debug_toolbar.panels.database') === TRUE) {
         $template->set('queries', self::get_queries());
     }
     // Logs panel
     if (Kohana::config('debug_toolbar.panels.logs') === TRUE) {
         $template->set('logs', self::get_logs());
     }
     // Vars and Config panel
     if (Kohana::config('debug_toolbar.panels.vars_and_config') === TRUE) {
         $template->set('configs', self::get_configs());
     }
     // Files panel
     if (Kohana::config('debug_toolbar.panels.files') === TRUE) {
         $template->set('files', self::get_files());
     }
     // FirePHP
     if (Kohana::config('debug_toolbar.firephp_enabled') === TRUE) {
         self::firephp();
     }
     // Set alignment for toolbar
     switch (Kohana::config('debug_toolbar.align')) {
         case 'right':
         case 'center':
         case 'left':
             $template->set('align', Kohana::config('debug_toolbar.align'));
             break;
         default:
             $template->set('align', 'left');
     }
     // Javascript for toolbar
     $template->set('scripts', file_get_contents(Kohana::find_file('views', 'toolbar', TRUE, 'js')));
     // CSS for toolbar
     $styles = file_get_contents(Kohana::find_file('views', 'toolbar', FALSE, 'css'));
     Benchmark::stop(self::$benchmark_name);
     // Benchmarks panel
     if (Kohana::config('debug_toolbar.panels.benchmarks') === TRUE) {
         $template->set('benchmarks', self::get_benchmarks());
     }
     if (Event::$data and self::is_enabled()) {
         // Try to add css just before the </head> tag
         if (stripos(Event::$data, '</head>') !== FALSE) {
             Event::$data = str_ireplace('</head>', $styles . '</head>', Event::$data);
         } else {
             // No </head> tag found, append styles to output
             $template->set('styles', $styles);
         }
         // Try to add js and HTML just before the </body> tag
         if (stripos(Event::$data, '</body>') !== FALSE) {
             Event::$data = str_ireplace('</body>', $template->render() . '</body>', Event::$data);
         } else {
             // Closing <body> tag not found, just append toolbar to output
             Event::$data .= $template->render();
         }
     } else {
         $template->set('styles', $styles);
         return $template->render($print);
     }
 }
Пример #15
0
    public function add_jquery()
    {
        $current_url = url::site(url::current());
        $script = <<<EOT
<script type="text/javascript">
\$(document).ready(function(){\t
\tvar elements = \$('input:not(:hidden, :submit, #captcha, [class*=no_ajax]), textarea:not(.no_ajax), select:not(.no_ajax)');
\t
\t// add a span element to all inputs for the ajax messages
\t
\t\$(\$('<span class="{$this->message_class}"></span>')).insertAfter(elements);
\t\t\t\t\t\t
\t// on change event, validate element using current url & element's name / value
\t\$(elements).change(function(){
\t\t
\t\tvar element = \$(this);

\t\t// add a loading class to the element, and remove it after ajax call
\t\telement.addClass('loading').ajaxStop(function(){
\t\t\telement.removeClass('loading');
\t\t});
\t\t
\t\t\$(this).parents('form').ajaxSubmit({
\t\t\turl: '{$current_url}?element='+element.attr('name'),
\t\t\tsuccess: function(data){
\t\t\t\t
\t\t\t\tdata = jQuery.trim(data);

\t\t\t\tvar message = element.next('span.{$this->message_class}');

\t\t\t\t// if an error message is present, remove it
\t\t\t\t\$('span[class*=error]',element.parents('p')).not(message).remove();
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
\t\t\t\tif(data) // if error
\t\t\t\t{
\t\t\t\t\tmessage.text(data)
\t\t\t\t\t\t.removeClass()
\t\t\t\t\t\t.addClass('{$this->message_class} {$this->error_class}');
\t\t\t\t}
\t\t\t\telse // if valid
\t\t\t\t{
\t\t\t\t\tmessage.text('{$this->valid_message}')
\t\t\t\t\t\t.removeClass()
\t\t\t\t\t\t.addClass('{$this->message_class} {$this->valid_class}');
\t\t\t\t}
\t\t\t\t
\t\t\t}
\t\t});
\t});
\t
\t// on blur event, validate all required elements that are empty
\t\$('form .required').blur(function(){
\t\t
\t\tif(\$(this).val() == '')
\t\t{
\t\t\t\$(this).change();
\t\t}
\t});
});
</script>
EOT;
        Event::$data = str_replace("</body>", $script . " </body>", Event::$data);
    }
Пример #16
0
 /**
  * Adds extra filter parameters to the reports::fetch_incidents()
  * method. This way we can add 'all_reports=>TRUE and other filters
  * that don't come standard since we are on the backend.
  * Works by simply adding in SQL conditions to the params
  * array of the reports::fetch_incidents() method
  * @return none
  */
 public function _add_incident_filters()
 {
     $params = Event::$data;
     $params = array_merge($params, $this->params);
     Event::$data = $params;
 }
Пример #17
0
	public function display()
	{
	    Event::$data = mb_convert_encoding(Event::$data, 'sjis-win', 'utf8');
	}
Пример #18
0
    public function numberInventory()
    {
        $subview = new View('numbermanager/numberInventory');

        $subview->tab = 'main';

        $subview->section = 'number_inventory';

        $subview->render_conditional = array(
            'qtipAjaxForm' => FALSE,
            'ajax' => FALSE
        );

        $base = $this->getBaseModelObject();

        if (!$base)
        {
            return TRUE;
        }

        if (get_parent_class($base) == 'Bluebox_Record')
        {
            $class_type = get_class($base) .'Number';
        } 
        else
        {
            $class_type = get_parent_class($base) .'Number';
        }

        $identifiers = $base->identifier();

        if (!empty($identifiers))
        {
            $foreign_id = reset($identifiers);
        } 
        else
        {
            $foreign_id = 0;
        }

        $numbers = array(
            'avaliable' => array(),
            'assigned' => array()
        );

        $numberOptionTemplates = array();

        $event_data = Event::$data;
        
        Event::run('numbermanager.collectNumberOptions', $numberOptionTemplates);

        Event::$data = $event_data;

        $numbers['assigned'] = Doctrine_Query::create()
            ->from('Number n')
            ->where('foreign_id = ?', array($foreign_id))
            ->andWhere('class_type = ?', $class_type)
            ->orderBy('number')
            ->execute(array(), Doctrine::HYDRATE_ARRAY);

        $numbers['avaliable'] = Doctrine_Query::create()
            ->select('np.number_type_id, nt.class, n.*')
            ->from('NumberPool np, np.Number n, np.NumberType nt')
            ->where('(n.foreign_id = ? OR n.foreign_id IS NULL)', array(0))
            ->andwhereIn('nt.class', array($class_type))
            ->orderBy('number')
            ->execute(array(), Doctrine::HYDRATE_ARRAY);

        foreach ($numbers['assigned'] as $key => $number)
        {
            $numbers['assigned'][$key]['registry'] =
                numbermanager::prepareNumberOptions($number['registry']);
        }

        $subview->assignedNumberTemplate = self::getAssignedNumberTemplate($numberOptionTemplates, $class_type);

        $subview->avaliableNumberTemplate = self::getAvaliableNumberTemplate();

        $subview->numberOptionTemplates = $numberOptionTemplates;

        $subview->numbers = $numbers;

        $subview->class_type = $class_type;

        $this->views[] = $subview;

        return TRUE;
    }
Пример #19
0
 public function _admin_nav_tab()
 {
     $tabs = Event::$data;
     $tabs['adminmap'] = Kohana::lang('adminmap.admin_map_main_menu_tab');
     Event::$data = $tabs;
 }
Пример #20
0
 public function _alter_timeline()
 {
     //find all the files associated with this incident
     $files = ORM::factory('fileupload')->where('incident_id', $this->milestone->id)->where('association_type', 3)->find_all();
     if (count($files) > 0) {
         $prefix = url::base() . Kohana::config('upload.relative_directory');
         $event = Event::$data;
         $event['description'] .= "<strong>" . Kohana::lang('fileupload.incident_files') . ':</strong><ul>';
         foreach ($files as $file) {
             $file_name = $file->file_link;
             $event['description'] .= '<li><a href="' . $prefix . '/' . $file_name . '">' . $file->file_title . '</a></li>';
         }
         $event['description'] .= '</ul>';
         Event::$data = $event;
     }
 }
 public function _footer_block()
 {
     $themes = new Themes();
     Event::$data = str_replace($themes->scheduler_js(), '', Event::$data);
 }
Пример #22
0
    public function add_jquery()
    {
        $action = $this->form->_action ? $this->form->_action : url::site(url::current());
        // only affect forms that have used ajaxval
        $ajaxed_forms = 'form[name=' . implode('][name=', $this->ajaxed_forms) . ']';
        $script = <<<EOT
<style type="text/css">
form .ajax_loading {background: #fff url({$this->loading_gif_url}) 97% 50% no-repeat;}
</style>

<script type="text/javascript">
\$(document).ready(function(){\t

\tvar elements = \$('.ajaxval',\$('{$ajaxed_forms}'));

\t// add a span element to all inputs for the ajax messages\t
\t\$(\$('<span class="{$this->message_class}"></span>')).appendTo(elements.parents('p'));
\t\t
\t// on change event, validate element using current url & element's name
\t\$(elements).change(function(){

\t\tvar element = \$(this);
\t\t
\t\t// add a loading class to the element, and remove it after ajax call
\t\telement.addClass('ajax_loading');
\t\t
\t\tif(element.hasClass('autocomplete'))
\t\t{
\t\t\tautocomplete = element;
\t\t\telement = element.nextAll('input[name='+element.attr('id')+']');
\t\t}
\t\t
\t\tvar message = \$('span.{$this->message_class}',element.parents('p'));

\t\telement.parents('form').ajaxSubmit({
\t\t\turl: '{$action}?element='+element.attr('name'),
\t\t\ttarget: message,
\t\t\tsuccess: function(data){
\t\t\t\t
\t\t\t\tdata = jQuery.trim(data);
\t\t\t\t\t\t\t\t
\t\t\t\t// if an error message is present, remove it
\t\t\t\t\$('span[class*=error]',element.parents('p')).not(message).remove();
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
\t\t\t\tif(data == '{$this->valid_message}') // if valid
\t\t\t\t{
\t\t\t\t\telement.removeClass('{$this->input_class}');
\t\t\t\t\tmessage.removeClass().addClass('{$this->message_class} {$this->valid_class}');
\t\t\t\t}
\t\t\t\telse // if error
\t\t\t\t{
\t\t\t\t\telement.addClass('{$this->input_class}');
\t\t\t\t\tmessage.removeClass().addClass('{$this->message_class} {$this->error_class}');
\t\t\t\t}\t\t
\t\t\t\telement.removeClass('ajax_loading');
\t\t\t\tautocomplete.removeClass('ajax_loading');
\t\t\t}
\t\t});
\t});
\t
\t// on blur event, validate all required elements that are empty
\t\$('.required',\$('{$ajaxed_forms}')).blur(function(){
\t\tvar element = \$(this).hasClass('autocomplete')
\t\t\t? \$(this).nextAll('input[name='+\$(this).attr('id')+']')
\t\t\t: \$(this);\t
\t\t\t
\t\tif(element.val() == '')
\t\t{
\t\t\telement.change();
\t\t}
\t});
});
</script>
EOT;
        Event::$data = str_replace("</body>", $script . " </body>", Event::$data);
    }
Пример #23
0
    public function decayimage_ushahidi_filter_header_js()
    {
        // Append a new showIncidentMap function to the end of the file
        preg_match(':^(.+)(//-->\\s*</script>\\s*)$:s', Event::$data, $matches);
        $layerName = Kohana::lang('ui_main.reports');
        $site = url::site();
        $new_js = <<<ENDJS
  var showIncidentMapOrig = showIncidentMap;
  //showIncidentMapBak = (function() {
  showIncidentMap = (function() {
  //return showIncidentMapOrig();

  // Set the layer name
  var layerName = "{$layerName}";
      
  // Get all current layers with the same name and remove them from the map
  currentLayers = map.getLayersByName(layerName);
  for (var i = 0; i < currentLayers.length; i++)
  {
    map.removeLayer(currentLayers[i]);
  }

  // TODO: I am not really sure if this is needed
  currentLayersIcons = map.getLayersByName(layerName + ' Category Icons');
  for (var i = 0; i < currentLayersIcons.length; i++)
  {
    map.removeLayer(currentLayersIcons[i]);
  }

  // Default styling for the reports
  var reportStyle = OpenLayers.Util.extend({}, 
    OpenLayers.Feature.Vector.style["default"]);

  reportStyle.pointRadius = 8;
  reportStyle.fillColor = "#30E900";
  reportStyle.fillOpacity = "0.8";
  reportStyle.strokeColor = "#197700";
  // Does this make the total point radius = 8+3/2?
  reportStyle.strokeWidth = 3;
  reportStyle.graphicZIndex = 2;

  // Default style for the associated report category icons 
  var iconStyle =  OpenLayers.Util.extend({}, reportStyle);
  iconStyle.graphicOpacity = 1;
  iconStyle.graphicZIndex = 1;
  iconStyle.graphic = true;
  iconStyle.graphicHeight = 25;

  // create simple vector layer where the report icons will be placed
  var vLayer = new OpenLayers.Layer.Vector(layerName, {
    projection: new OpenLayers.Projection("EPSG:4326"),
    style: reportStyle,
    rendererOptions: {zIndexing: true}
  });

  // create a seperate vector layer where the icons associated with the report
  // categories will be placed.
  var vLayerIcons = new OpenLayers.Layer.Vector(layerName + ' Category Icons', {
    projection: new OpenLayers.Projection("EPSG:4326"),
    style: iconStyle,
    rendererOptions: {zIndexing: true}
  });
      
  // URL to be used for fetching the incidents
  fetchURL = "{$site}api/?task=decayimage";

  // TODO: for right now all additional parameters here are disabled  
  /*
  // Generate the url parameter string
  parameterStr = makeUrlParamStr("", urlParameters);
  
  // Add the parameters to the fetch URL
  fetchURL += "?" + parameterStr;
   */

  // Fetch the incidents
  var json = jQuery.getJSON(fetchURL, function(data) {
    \$.each(data.payload.incidents, function(key, val) {

      // create a point from the latlon
      var incidentPoint = new OpenLayers.Geometry.Point(
        val.incident.locationlongitude,
        val.incident.locationlatitude
      );
      var proj = new OpenLayers.Projection("EPSG:4326");
      incidentPoint.transform(proj, map.getProjectionObject());

      // If the incident has ended but it is configured to "decay" we should
      // set the incident icon to the decayimage default icon
      var newIncidentStyle =  OpenLayers.Util.extend({}, reportStyle);
      if (val.incident.incidenthasended == 1) {
        newIncidentStyle.externalGraphic = data.payload.decayimage_default_icon;
      }

      // create a feature vector from the point and style
      var feature = new OpenLayers.Feature.Vector(incidentPoint, null, newIncidentStyle);
      feature.attributes = {
        link: "{$site}reports/view/"+val.incident.incidentid,
        id: val.incident.incidentid
      };
      vLayer.addFeatures([feature]);

      var offsetRadius = reportStyle.pointRadius+iconStyle.graphicHeight/2;

      var numIcons = val.categories.length;
      var iconCt = 1;
      // Loop over each icon setting externalGraphic and x,y offsets
      \$.each(val.categories, function(index, category) {
        
        var newIconStyle =  OpenLayers.Util.extend({}, iconStyle);
        // TODO: make sure we are using the decayimage category icons if they
        // are set.  I think this should be transparently set by the json 
        // controller anyhow.
        if (val.incident.incidenthasended) {
          newIconStyle.externalGraphic = category.category.icon;
        } else {
          newIconStyle.externalGraphic = category.category.decayimage;
        }

        // TODO: -13 is a magic number here that got this working.
        // I dont totally understant what its related to.
        // pointRadius + strokeWidth + 2FunPixels?
        newIconStyle.graphicXOffset = -13+
          offsetRadius*Math.cos(((2*3.14)/(numIcons))*index);
        newIconStyle.graphicYOffset = -13+
          offsetRadius*Math.sin(((2*3.14)/(numIcons))*index);

        iconPoint = incidentPoint.clone();
        var feature = new OpenLayers.Feature.Vector(
          iconPoint, null, newIconStyle);
        vLayerIcons.addFeatures([feature]);
      });

    });
  });

  // Add the vector layer to the map
  map.addLayer(vLayer);
  map.addLayer(vLayerIcons);

  // Add feature selection events
  addFeatureSelectionEvents(map, vLayer);
});
ENDJS;
        Event::$data = $matches[1] . $new_js . $matches[2];
    }
Пример #24
0
 public function handle_system_display()
 {
     // this prevents kohana from attempting to parse the output
     Event::$data = $this->server->handle();
 }
Пример #25
0
 public function _map_main()
 {
     Event::$data = View::factory('map_main')->render() . Event::$data;
 }
Пример #26
0
	public function _filter_constituency()
	{
		$incidents = Event::$data;
		
		// Check, has the form been submitted
		if ($_POST)
		{
			//echo Kohana::debug($_POST);
			$constituency_id = $_POST['constituency_id'];
			
			$db = new Database;

			$filter = ( isset($_GET['c']) && !empty($_GET['c']) && $_GET['c']!=0 )
				? " AND ( c.id='".$_GET['c']."' OR 
					c.parent_id='".$_GET['c']."' )  "
				: " AND 1 = 1";	

			// Pagination
			$pagination = new Pagination(array(
					'query_string' => 'page',
					'items_per_page' => (int) Kohana::config('settings.items_per_page'),
					'total_items' => $db->query("SELECT DISTINCT i.* FROM `".Kohana::config('database.default.table_prefix')."incident` AS i JOIN `".Kohana::config('database.default.table_prefix')."incident_category` AS ic ON (i.`id` = ic.`incident_id`) JOIN `".Kohana::config('database.default.table_prefix')."filter_incident_constituency` AS icons ON (i.`id` = icons.`incident_id` AND icons.constituency_id = ".$constituency_id.") JOIN `".Kohana::config('database.default.table_prefix')."category` AS c ON (c.`id` = ic.`category_id`) JOIN `".Kohana::config('database.default.table_prefix')."location` AS l ON (i.`location_id` = l.`id`) WHERE `incident_active` = '1' $filter")->count()
					));

			// Incidents
			$incidents = $db->query("SELECT DISTINCT i.*, l.`location_name` FROM `".Kohana::config('database.default.table_prefix')."incident` AS i JOIN `".Kohana::config('database.default.table_prefix')."incident_category` AS ic ON (i.`id` = ic.`incident_id`) JOIN `".Kohana::config('database.default.table_prefix')."filter_incident_constituency` AS icons ON (i.`id` = icons.`incident_id` AND icons.constituency_id = ".$constituency_id.") JOIN  `".Kohana::config('database.default.table_prefix')."category` AS c ON (c.`id` = ic.`category_id`) JOIN `".Kohana::config('database.default.table_prefix')."location` AS l ON (i.`location_id` = l.`id`) WHERE `incident_active` = '1' $filter ORDER BY incident_date DESC LIMIT ".Kohana::config('settings.items_per_page')." OFFSET ".$pagination->sql_offset);
			
			Event::$data = $incidents;
		}
	}
Пример #27
0
 function _add_map_layers_js()
 {
     $js = Event::$data;
     // Next get the default base layer
     $default_map = Kohana::config('settings.default_map');
     // Hack on Mapbox Attribution layer here
     if (stripos($default_map, 'mapbox_') !== FALSE) {
         $js .= "\$('div#map').append('<div style=\"position:absolute;right:0;z-index:1000;margin: -40px 10px 0 90px;\"><small>Designed by <a href=\"http://mapbox.com/about/maps/\">MapBox</a> with data from OpenStreet Map.<br/ >&copy;<a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CCBYSA</a> 2010 <a href=\"http://www.openstreetmap.org/\">OpenStreetMap.org</a> contributors</small></div>');";
     }
     Event::$data = $js;
 }
 /**
  * Alter markers before conversion to geojson
  * add URL to shared markers
  */
 public function json_alter_markers()
 {
     $markers = Event::$data;
     $markers = $markers->as_array();
     foreach ($markers as $key => $marker) {
         if (isset($marker->source) and $marker->source != 'main') {
             $markers[$key]->url = Sharing_Incident_Model::get_url($marker);
         }
     }
     Event::$data = $markers;
 }
Пример #29
0
 public function _admin_map_let_view()
 {
     $user = new User_Model($_SESSION['auth_user']->id);
     //figure out what group this user is
     //if they're not a groupie, then quit
     $group_id = groups::get_user_group($user);
     if ($group_id) {
         Event::$data = true;
     }
 }
Пример #30
0
 /**
  * Used to set the increments of the slider
  * This should set the endDate variable
  * all the processing was done in the above function
  * but to set two seperate variables we need two seperate
  * filters
  */
 public function _set_slider_end()
 {
     //if the interval_mode is set to 1, then just leave the interval at months
     //but if interval_mode is set to 2 then rewrite things as days
     if ($this->settings->interval_mode == 1) {
         Event::$data = $this->endDate;
     } else {
         if ($this->settings->interval_mode == 2) {
             Event::$data = $this->endDate;
         }
     }
 }