Created
December 2, 2014 11:39
-
-
Save ticklemynausea/b843e9e27d68e22a1231 to your computer and use it in GitHub Desktop.
generate_background_css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function generate_background_css return varchar2 is | |
| cursor c_get_background_css(p_sys_cliente_id integer, p_sys_utilizador_id integer) is | |
| select nvl(cb.background_repeat, 1) background_repeat, | |
| nvl(cb.background_attachment,1) background_attachment, | |
| nvl(cb.background_position, 1) background_position, | |
| nvl(cb.background_color, '#000000') background_color | |
| from cli_backgrounds cb | |
| where cb.sys_cliente_id = p_sys_cliente_id | |
| and cb.sys_utilizador_id = p_sys_utilizador_id; | |
| l_background_css c_get_background_css%rowtype; | |
| l_found boolean; | |
| type t_css_background is table of varchar2(64); | |
| l_css_background_repeat t_css_background; | |
| l_css_background_attachment t_css_background; | |
| l_css_background_position t_css_background; | |
| l_str varchar2(32767); | |
| l_url_background varchar2(512); | |
| l_cache integer; | |
| begin | |
| open c_get_background_css(g_sessao.sys_cliente_id, g_sessao.sys_utilizador_id); | |
| fetch c_get_background_css into l_background_css; | |
| l_found := c_get_background_css%found; | |
| close c_get_background_css; | |
| if not l_found then | |
| open c_get_background_css(0, 1); | |
| fetch c_get_background_css into l_background_css; | |
| close c_get_background_css; | |
| end if; | |
| l_css_background_repeat := t_css_background('repeat', 'repeat-x', 'repeat-y', 'no-repeat'); | |
| l_css_background_attachment := t_css_background('scroll', 'fixed'); | |
| l_css_background_position := t_css_background( | |
| 'left top', | |
| 'left center', | |
| 'left bottom', | |
| 'right top', | |
| 'right center', | |
| 'right bottom', | |
| 'center top', | |
| 'center center', | |
| 'center bottom' | |
| ); | |
| l_cache := (sysdate - to_date('01-01-1970 00:00:00', 'dd-mm-yyyy hh24:mi:ss')) * 24 * 60 * 60; | |
| l_url_background := helpers.url('pk_home.v_background', g_sessao.id); -- l_cache ?? | |
| l_str := '<style type="text/css">'; | |
| l_str := l_str || 'body {'; | |
| begin | |
| l_str := l_str || ' background: url('''||l_url_background||''');'; | |
| l_str := l_str || ' background-repeat: '||l_css_background_repeat(l_background_css.background_repeat)||';'; | |
| l_str := l_str || ' background-attachment: '||l_css_background_attachment(l_background_css.background_attachment)||';'; | |
| l_str := l_str || ' background-position: '||l_css_background_position(l_background_css.background_position)||';'; | |
| l_str := l_str || ' background-color: '||l_background_css.background_color||';'; | |
| exception when | |
| VALUE_ERROR then | |
| null; | |
| end; | |
| l_str := l_str || '}'; | |
| l_str := l_str || '</style>'; | |
| return l_str; | |
| end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment