Exemplo n.º 1
0
 /**
  * @override
  */
 function PreRender($args = array())
 {
     if (count($args) > 0) {
         $controller =& $args[0];
         // just to render close button with the right id
         if (!is_null($this->CloseButton)) {
             $temp = array($this->CloseButton => $this->CloseButtonAction);
             $this->Buttons = array_merge($this->Buttons, $temp);
         }
         $rem = system_is_ajax_call() ? ".remove()" : '';
         $close_action = "\$('#{$this->id}').dialog('close'){$rem};";
         foreach ($this->Buttons as $label => $action) {
             if (!starts_with($action, '[jscode]') && !starts_with($action, 'function')) {
                 $action = "function(){ {$action} }";
             }
             $this->Buttons[$label] = str_replace("{close_action}", $close_action, $action);
         }
         $this->Options['buttons'] = $this->Buttons;
         $tmp = $this->_script;
         $this->_script = array();
         $this->script("try{ \$('#{$this->id}').dialog(" . system_to_json($this->Options) . "); }catch(ex){ wdf.debug(ex); }");
         $this->script("\$('#{$this->id}').parent().find('.ui-dialog-buttonpane .ui-button').click(function(){ \$(this).parent().find('.ui-button').button('disable'); });");
         $this->_script = array_merge($this->_script, $tmp);
         foreach ($this->_script as $s) {
             $controller->addDocReady($s);
         }
     }
     return parent::PreRender($args);
 }
Exemplo n.º 2
0
 /**
  * @override
  */
 function PreRender($args = array())
 {
     $opts = array();
     if ($this->min !== false) {
         $opts['min'] = $this->min;
     }
     if ($this->max !== false) {
         $opts['max'] = $this->max;
     }
     if ($this->value !== false) {
         $opts['value'] = $this->value;
     }
     if ($this->range !== false) {
         $opts['range'] = $this->range;
     }
     if ($this->onslide !== false) {
         $opts['slide'] = $this->onslide;
     }
     if ($this->values !== false) {
         if (!is_array($this->values)) {
             $this->values = array($this->values);
         }
         $opts['values'] = "[" . implode(",", $this->values) . "]";
     }
     $opts = array_merge($opts, $this->Options);
     if ($opts['value'] > $opts['max']) {
         $opts['value'] = $opts['max'];
     }
     if ($opts['value'] < $opts['min']) {
         $opts['value'] = $opts['min'];
     }
     $opts = system_to_json($opts);
     $this->script("\$('#{$this->id}').slider({$opts});");
     parent::PreRender($args);
 }
Exemplo n.º 3
0
 /**
  * @override
  */
 function PreRender($args = array())
 {
     foreach ($this->_sections as $section => $section_content) {
         $this->content("<h3>{$section}</h3>");
         $this->content($section_content);
     }
     $this->script("\$('#" . $this->id . "').accordion(" . system_to_json($this->Options) . ")");
     parent::PreRender($args);
 }
Exemplo n.º 4
0
 /**
  * @param type $options SimplyScroll options (see http://logicbox.net/jquery/simplyscroll)
  */
 function __initialize($options = array())
 {
     parent::__initialize("ul");
     if (!isset($options['autoMode'])) {
         $options['autoMode'] = 'loop';
     }
     $this->Options = $options;
     $options = system_to_json($this->Options);
     $code = "\$('#{self}').simplyScroll({$options});";
     $this->script($code);
 }
 /**
  * @internal PreRender HOOK handler
  */
 function AddLoaderCode($args)
 {
     $loader = array();
     foreach (self::$_apis as $api => $definition) {
         list($version, $options) = $definition;
         if (isset($options['callback'])) {
             $options['callback'] = "function(){ " . implode("\n", $options['callback']) . " }";
         }
         $loader[] = "google.load('{$api}','{$version}'," . system_to_json($options) . ");";
     }
     $controller = $args[0];
     $controller->addDocReady($loader, false);
     // <- see the 'false'? we add these codes inline, not into the ready handler as this crashes
 }
Exemplo n.º 6
0
 /**
  * @override
  */
 function PreRender($args = array())
 {
     if (!$this->CultureInfo) {
         $this->SetCulture(Localization::detectCulture());
     }
     if (isset($this->value)) {
         $this->value = get_class_simple($this) == "uiDatePicker" ? $this->CultureInfo->FormatDate($this->value, DateTimeFormat::DF_SHORTDATE) : $this->CultureInfo->FormatDateTime($this->value);
     }
     if (isset($this->Options['defaultDate'])) {
         $this->Options['defaultDate'] = get_class_simple($this) == "uiDatePicker" ? $this->CultureInfo->FormatDate($this->Options['defaultDate'], DateTimeFormat::DF_SHORTDATE) : $this->CultureInfo->FormatDateTime($this->Options['defaultDate']);
     }
     $this->script("\$('#{$this->id}').{$this->init_code}(" . system_to_json($this->Options) . ");");
     parent::PreRender($args);
 }
Exemplo n.º 7
0
 /**
  * @override
  */
 function PreRender($args = array())
 {
     if ($this->Url || $this->NodeSelected) {
         $options = new StdClass();
         if ($this->Url) {
             $options->url = $this->Url;
         }
         if ($this->NodeSelected) {
             $options->nodeSelected = $this->NodeSelected;
         }
         $this->script("\$('#" . $this->id . "').treeview(" . system_to_json($options) . ");");
     } else {
         $this->script("\$('#" . $this->id . "').treeview({});");
     }
     return parent::PreRender($args);
 }
Exemplo n.º 8
0
 /**
  * @override
  */
 public function PreRender($args = array())
 {
     if (isset($this->Options['captionEl'])) {
         $title = isset($this->Options['captionTitle']) ? $this->Options['captionTitle'] . ": " : getString("TXT_RATING") . ": ";
         $labTitle = new Label($title);
         $labTitle->class = "userrating";
         $caption_element = "<span id='" . $this->Options['captionEl'] . "'></span>";
         $caption = ", captionEl: \$('#" . $this->Options['captionEl'] . "')}";
         unset($this->Options['captionEl']);
         unset($this->Options['captionTitle']);
         $this->Options = system_to_json($this->Options);
         $this->Options = str_replace("}", $caption, $this->Options);
         $this->content($labTitle);
         $this->content($this->CreateSelect($this->id . "_select"));
         //$this->_content[] = "&nbsp;&nbsp;(".$caption_element.")";
     } else {
         $this->Options = system_to_json($this->Options);
         $this->content($this->CreateSelect($this->id . "_select"));
     }
     $script = "\$('#{$this->id}').stars({$this->Options});";
     $this->script($script);
     parent::PreRender($args);
 }
Exemplo n.º 9
0
 /**
  * @override
  */
 function PreRender($args = array())
 {
     $id = $this->id;
     $this->_basicOptions['center'] = '[jscode]' . $this->_basicOptions['center'];
     $this->_basicOptions['mapTypeId'] = '[jscode]' . $this->_basicOptions['mapTypeId'];
     if ($this->AutoShowHints) {
         $this->_basicOptions['autoShowHints'] = true;
     }
     $init = array("wdf.gmap.init('{$id}'," . system_to_json($this->_basicOptions) . ");");
     foreach ($this->_markers as $m) {
         list($lat, $lng, $opt) = $m;
         $init[] = "wdf.gmap.addMarker('{$id}',{$lat},{$lng}," . json_encode($opt) . ");";
     }
     foreach ($this->_addresses as $a) {
         if (is_array($a)) {
             $init[] = "wdf.gmap.addAddress('{$id}'," . json_encode($a['address']) . "," . json_encode($a['title']) . ");";
         } else {
             $init[] = "wdf.gmap.addAddress('{$id}'," . json_encode($a) . ");";
         }
     }
     $init[] = "wdf.gmap.showAllMarkers('{$id}');";
     $this->_addLoadCallback('maps', $init);
     return parent::PreRender($args);
 }
Exemplo n.º 10
0
 /**
  * @override
  */
 function PreRender($args = array())
 {
     $this->script("\$('#{self}').container(" . system_to_json($this->Options) . ");");
     parent::PreRender($args);
 }
Exemplo n.º 11
0
 /**
  * Set a valud to a data-$name attribute.
  * 
  * Those can be accessed in JS easily using jQuery.data method
  * @param string $name Data name
  * @param mixed $value Data value (<system_to_json> will be used for arrays and objects) 
  * @return Control `$this`
  */
 function setData($name, $value)
 {
     if (is_array($value) || is_object($value)) {
         $this->_data_attributes[$name] = system_to_json($value);
     } else {
         $this->_data_attributes[$name] = $value;
     }
     return $this;
 }
Exemplo n.º 12
0
 /**
  * @internal PreRender HOOK handler
  */
 function AddLoaderCode($args)
 {
     $loader = array();
     foreach (self::$_apis as $api => $definition) {
         list($version, $options) = $definition;
         if (isset($options['callback'])) {
             $options['callback'] = "function(){ " . implode("\n", $options['callback']) . " }";
         } else {
             $options['callback'] = "function(){}";
         }
         if ($this->_culture) {
             $options['language'] = $this->_culture->ResolveToLanguage()->Code;
         }
         if ($this->frozen) {
             $loader[] = "window.googleLoadCallback = " . $options['callback'];
             $options['callback'] = 'function(){ window.googleLoadCallback(); }';
             $loader[] = "if( window.googleLoaded ) { window.googleLoadCallback(); } else { window.googleLoaded = true; google.charts.load('42'," . system_to_json($options) . "); }";
         } else {
             $loader[] = "google.load('{$api}','{$version}'," . system_to_json($options) . ");";
         }
     }
     $controller = $args[0];
     if (system_is_ajax_call()) {
         $controller->script($loader);
     } elseif ($controller instanceof HtmlPage) {
         $controller->addDocReady($loader, false);
     }
     // <- see the 'false'? we add these codes inline, not into the ready handler as this crashes
 }
Exemplo n.º 13
0
 /**
  * @override
  */
 function PreRender($args = array())
 {
     $this->script("\$('#{$this->id}').autocomplete(" . system_to_json($this->Options) . ");");
     parent::PreRender($args);
 }
 /**
  * @override
  */
 function PreRender($args = array())
 {
     if (count($this->_data) > 1) {
         $id = $this->id;
         $opts = json_encode($this->gvOptions);
         if (count($this->_data) > 0) {
             array_walk_recursive($this->_data, function (&$item, &$key) {
                 if ($item instanceof DateTime) {
                     $item = "[jscode]new Date(" . $item->getTimestamp() * 1000 . ")";
                 }
             });
             $d = system_to_json($this->_data);
             $js = "var d=google.visualization.arrayToDataTable({$d});" . "var c=new google.visualization.{$this->gvType}(\$('#{$id}').get(0));" . "google.visualization.events.addListener(c, 'ready', function(){ \$('#{$id}').data('ready',true); });" . "c.draw(d,{$opts});" . "\$('#{$id}').data('googlechart', c);";
         } else {
             $q = buildQuery($this->id, 'Query');
             $js = "var {$id} = new google.visualization.Query('{$q}');" . "{$id}.setQuery('{$this->gvQuery}');" . "{$id}.send(function(r){ if(r.isError()){ \$('#{$id}').html(r.getDetailedMessage()); }else{ var c=new google.visualization.{$this->gvType}(\$('#{$id}').get(0));" . "google.visualization.events.addListener(c, 'ready', function(){ \$('#{$id}').data('ready',true); });" . "c.draw(r.getDataTable(),{$opts});" . "\$('#{$id}').data('googlechart', c);}});";
         }
         $this->_addLoadCallback('visualization', $js, true);
     } else {
         $t = $this->opt('title');
         $this->css('text-align', 'center')->content(($t ? "<b>{$t}:</b> " : "") . tds("TXT_NO_DATA", "No data found"), true);
     }
     if (isset($this->gvOptions['width'])) {
         $this->css('width', "{$this->gvOptions['width']}px");
     }
     if (isset($this->gvOptions['height'])) {
         $this->css('height', "{$this->gvOptions['height']}px");
     }
     return parent::PreRender($args);
 }
Exemplo n.º 15
0
 /**
  * @override
  */
 function PreRender($args = array())
 {
     if (count($args) > 0) {
         $controller = $args[0];
         $opts = array();
         if (isset($this->_icon)) {
             $opts['icons'] = array('primary' => "ui-icon-" . $this->_icon);
         }
         if (count($this->_content) == 0) {
             $opts['text'] = false;
         }
         if ($controller instanceof \ScavixWDF\Base\HtmlPage) {
             $controller->addDocReady("\$('#" . $this->id . "').button(" . system_to_json($opts) . ");");
         } else {
             $controller->script("\$('#" . $this->id . "').button(" . system_to_json($opts) . ");");
         }
     }
     return parent::PreRender($args);
 }
Exemplo n.º 16
0
 /**
  * Add resizable init code to the uiControl.
  * 
  * @param array $options See http://api.jqueryui.com/resizable/
  * @return uiControl $this
  */
 public function Resizable($options = array())
 {
     $this->script("\$('#" . $this->id . "').resizable(" . system_to_json($options) . ")");
     return $this;
 }
Exemplo n.º 17
0
 /**
  * @internal Renders the response for output.
  */
 function Render()
 {
     if ($this->_data) {
         if (isset($this->_data->script)) {
             $this->_data->script = "<script>" . implode("\n", $this->_data->script) . "</script>";
         }
         $res = system_to_json($this->_data);
     } elseif ($this->_text) {
         $res = json_encode($this->_text);
     } else {
         return '""';
     }
     // return an empty string JSON encoded to not kill the app JS side
     return !$this->_translated && system_is_module_loaded("translation") ? __translate($res) : $res;
 }
Exemplo n.º 18
0
/**
 * Terminats the current run.
 * 
 * Will be called from exception and error handlers. You may, call this directly, but we
 * recommend to throw an exception instead. See the WdfException class and it's Raise() method
 * for more about this.
 * Note: This function will call `die()`!
 * @param string $reason The reason as human readable and hopefully understandable text
 * @param string $additional_message More details to be logged
 * @return void
 */
function system_die($reason, $additional_message = '')
{
    if ($reason instanceof Exception) {
        $stacktrace = $reason instanceof WdfException ? $reason->getTraceEx() : $reason->getTrace();
        $reason = logging_render_var($reason);
    }
    if (!isset($stacktrace)) {
        $stacktrace = debug_backtrace();
    }
    if (isset($GLOBALS['system']['hooks'][HOOK_SYSTEM_DIE]) && count($GLOBALS['system']['hooks'][HOOK_SYSTEM_DIE]) > 0) {
        execute_hooks(HOOK_SYSTEM_DIE, array($reason, $stacktrace));
    }
    if (system_is_ajax_call()) {
        $res = AjaxResponse::Error($reason . "\n" . $additional_message, true);
        die($res->Render());
        $code = "alert(unescape(" . json_encode($reason . "\n" . $additional_message) . "));";
        $res = new stdClass();
        $res->html = "<script>{$code}</script>";
        die(system_to_json($res));
    } else {
        $stacktrace = system_stacktrace_to_string($stacktrace);
        $res = "<html><head><title>Fatal system error</title></head>";
        $res .= "<body>";
        if (isDev()) {
            $res .= "<pre>{$reason}</pre><pre>{$additional_message}</pre><pre>" . $stacktrace . "</pre>";
        } else {
            $res .= "Fatal System Error occured.<br/>Please try again.<br/>Contact our technical support if this problem occurs again.<br/><br/>Apologies for any inconveniences this may have caused you.";
        }
        $res .= "</body></html>";
        die($res);
    }
}
Exemplo n.º 19
0
 /**
  * @override
  */
 public function PreRender($args = array())
 {
     log_debug(__METHOD__);
     $this->script("\$('#{self}').tabs(" . system_to_json($this->Options) . ")");
     return parent::PreRender($args);
 }