function webvideo_alter_render_early($args) { $elem =& $args['elem']; $obj = $args['obj']; if (!elem_has_class($elem, 'webvideo')) { return false; } if (empty($obj['webvideo-provider']) || empty($obj['webvideo-id'])) { return false; } $i = elem('iframe'); if ($obj['webvideo-provider'] == 'youtube') { if (empty($_SERVER['HTTPS'])) { $src = 'http://'; } else { $src = 'https://'; } $src .= 'www.youtube.com/embed/' . $obj['webvideo-id'] . '?rel=0'; if (isset($obj['webvideo-autoplay']) && $obj['webvideo-autoplay'] == 'autoplay') { $src .= '&autoplay=1'; } if (isset($obj['webvideo-loop']) && $obj['webvideo-loop'] == 'loop') { // this is not yet supported by the new youtube embed player $src .= '&loop=1'; } elem_attr($i, 'src', $src); elem_add_class($i, 'youtube-player'); } elseif ($obj['webvideo-provider'] == 'vimeo') { $src = 'http://player.vimeo.com/video/' . $obj['webvideo-id'] . '?title=0&byline=0&portrait=0&color=ffffff'; if (isset($obj['webvideo-autoplay']) && $obj['webvideo-autoplay'] == 'autoplay') { $src .= '&autoplay=1'; } if (isset($obj['webvideo-loop']) && $obj['webvideo-loop'] == 'loop') { $src .= '&loop=1'; } elem_attr($i, 'src', $src); } // frameborder is not valid html //elem_attr($i, 'frameborder', '0'); elem_css($i, 'border-width', '0px'); elem_css($i, 'height', '100%'); elem_css($i, 'position', 'absolute'); elem_css($i, 'width', '100%'); elem_append($elem, $i); if ($args['edit']) { // add handle as well $h = elem('div'); elem_add_class($h, 'glue-webvideo-handle'); elem_add_class($h, 'glue-ui'); elem_attr($h, 'title', 'drag here'); elem_append($elem, $h); } return true; }
function lock_render_object($args) { $elem =& $args['elem']; $obj =& $args['obj']; if (!elem_has_class($elem, 'object')) { return false; } if (!empty($obj['object-lock'])) { elem_css($elem, 'object-lock', $obj['object-lock']); } }
function transform_render_object($args) { $elem =& $args['elem']; $obj =& $args['obj']; if (!elem_has_class($elem, 'object')) { return false; } if (!empty($obj['transform-flip'])) { elem_css($elem, '-webkit-transform', $obj['transform-flip']); elem_css($elem, '-moz-transform', $obj['transform-flip']); } }
function iframe_alter_render_early($args) { $elem =& $args['elem']; $obj = $args['obj']; if (!elem_has_class($elem, 'iframe')) { return false; } // add iframe $i = elem('iframe'); // frameborder is not valid html5 //if (!$args['edit'] && IE8_COMPAT) { // elem_attr($i, 'frameborder', '0'); //} // set the name attribute elem_attr($i, 'name', $obj['name']); if (!$args['edit']) { // try to lift any restrictions elem_attr($i, 'sandbox', 'allow-forms allow-same-origin allow-scripts allow-top-navigation'); } elem_css($i, 'background-color', 'transparent'); elem_css($i, 'border-width', '0px'); elem_css($i, 'height', '100%'); elem_css($i, 'position', 'absolute'); elem_css($i, 'width', '100%'); // url if (!empty($obj['iframe-url'])) { elem_attr($i, 'src', $obj['iframe-url']); } else { elem_attr($i, 'src', ''); } // scrolling if (isset($obj['iframe-scroll']) && $obj['iframe-scroll'] == 'scroll') { elem_css($i, 'overflow', 'auto'); // attribute scrolling is not available in html5 but this effectivly // removes the scrollbars on Chrome, so.. elem_attr($i, 'scrolling', 'auto'); } else { elem_css($i, 'overflow', 'hidden'); elem_attr($i, 'scrolling', 'no'); elem_attr($i, 'seamless', 'seamless'); } elem_append($elem, $i); if ($args['edit']) { // add shield as well $s = elem('div'); elem_add_class($s, 'glue-iframe-shield'); elem_add_class($s, 'glue-ui'); elem_css($s, 'height', '100%'); elem_css($s, 'position', 'absolute'); elem_css($s, 'width', '100%'); elem_attr($s, 'title', 'visitors will be able to interact with the webpage below'); elem_append($elem, $s); } return true; }
function object_alter_save($args) { $elem = $args['elem']; $obj =& $args['obj']; if (!elem_has_class($elem, 'object')) { return false; } if (elem_css($elem, 'height') !== NULL) { $obj['object-height'] = elem_css($elem, 'height'); } else { unset($obj['object-height']); } if (elem_css($elem, 'left') !== NULL) { $obj['object-left'] = elem_css($elem, 'left'); } else { unset($obj['object-left']); } if (elem_css($elem, 'opacity') !== NULL) { $obj['object-opacity'] = elem_css($elem, 'opacity'); } else { unset($obj['object-opacity']); } if (elem_css($elem, 'top') !== NULL) { $obj['object-top'] = elem_css($elem, 'top'); } else { unset($obj['object-top']); } if (elem_css($elem, 'width') !== NULL) { $obj['object-width'] = elem_css($elem, 'width'); } else { unset($obj['object-width']); } if (elem_css($elem, 'z-index') !== NULL) { $obj['object-zindex'] = elem_css($elem, 'z-index'); } else { unset($obj['object-zindex']); } return true; }
function text_alter_render_early($args) { $elem =& $args['elem']; $obj = $args['obj']; if (!elem_has_class($elem, 'text')) { return false; } // background-color if (!empty($obj['text-background-color'])) { elem_css($elem, 'background-color', $obj['text-background-color']); } // content if (!isset($obj['content'])) { $obj['content'] = ''; } if ($args['edit']) { // add a textarea $i = elem('textarea'); elem_add_class($i, 'glue-text-input'); elem_css($i, 'width', '100%'); elem_css($i, 'height', '100%'); // hide the text area by default elem_css($i, 'display', 'none'); // set the context to the textarea to the (unrendered) object content $content = htmlspecialchars($obj['content'], ENT_NOQUOTES, 'UTF-8'); // replace newline characters by an entity to prevent render_object() // from adding some indentation $content = str_replace("\r\n", ' ', $content); $content = str_replace("\n", ' ', $content); // why not replace tabs as well why we are at it $content = str_replace("\t", '	', $content); elem_val($i, $content); elem_append($elem, $i); // and a nested div $r = elem('div'); elem_add_class($r, 'glue-text-render'); elem_css($r, 'width', '100%'); elem_css($r, 'height', '100%'); // set the content of the div to the rendered object content elem_val($r, _text_render_content($obj['content'], $obj['name'])); elem_append($elem, $r); } else { elem_append($elem, _text_render_content($obj['content'], $obj['name'])); } // font-color if (!empty($obj['text-font-color'])) { elem_css($elem, 'color', $obj['text-font-color']); } // font-family if (!empty($obj['text-font-family'])) { elem_css($elem, 'font-family', $obj['text-font-family']); if (TEXT_USE_WOFF_FONTS) { if (_is_woff_font($obj['text-font-family'])) { // include all styles of the font because of inline html // (<strong>, etc) _include_woff_font($obj['text-font-family']); } } } // font-size if (!empty($obj['text-font-size'])) { elem_css($elem, 'font-size', $obj['text-font-size']); } // font-style if (!empty($obj['text-font-style'])) { elem_css($elem, 'font-style', $obj['text-font-style']); } // font-weight if (!empty($obj['text-font-weight'])) { elem_css($elem, 'font-weight', $obj['text-font-weight']); } // letter-spacing if (!empty($obj['text-letter-spacing'])) { elem_css($elem, 'letter-spacing', $obj['text-letter-spacing']); } // line-height if (!empty($obj['text-line-height'])) { elem_css($elem, 'line-height', $obj['text-line-height']); } // padding-x if (!empty($obj['text-padding-x'])) { elem_css($elem, 'padding-left', $obj['text-padding-x']); elem_css($elem, 'padding-right', $obj['text-padding-x']); } // padding-y if (!empty($obj['text-padding-y'])) { elem_css($elem, 'padding-top', $obj['text-padding-y']); elem_css($elem, 'padding-bottom', $obj['text-padding-y']); } // text-align if (!empty($obj['text-align'])) { elem_css($elem, 'text-align', $obj['text-align']); } // word-spacing if (!empty($obj['text-word-spacing'])) { elem_css($elem, 'word-spacing', $obj['text-word-spacing']); } return true; }
function video_alter_render_early($args) { $elem =& $args['elem']; $obj = $args['obj']; if (!elem_has_class($elem, 'video')) { return false; } // add a css (for viewing as well as editing) html_add_css(base_url() . 'modules/video/video.css'); $v = elem('video'); if (empty($obj['video-file'])) { elem_attr($v, 'src', ''); } else { // TODO (later): support URLs as well if (SHORT_URLS) { elem_attr($v, 'src', base_url() . urlencode($obj['name'])); } else { elem_attr($v, 'src', base_url() . '?' . urlencode($obj['name'])); } } elem_css($v, 'width', '100%'); elem_css($v, 'height', '100%'); // we're currently not preloading the video due to some troubles on // Firefox //elem_css($v, 'preload', 'preload'); // set some fallback text if (!empty($obj['video-file']) && !empty($obj['video-file-mime'])) { elem_val($v, '<div class="video-fallback">You are not seeing the video because your browser does not support ' . htmlspecialchars($obj['video-file-mime'], ENT_NOQUOTES, 'UTF-8') . '. Consider using a contemporary web browser.</div>'); } else { elem_val($v, '<div class="video-fallback">You are not seeing the video because your browser does not support it. Consider using a contemporary web browser.</div>'); } // autoplay if (!isset($obj['video-autoplay']) || $obj['video-autoplay'] == 'autoplay') { // autoplay is the default elem_attr($v, 'autoplay', 'autoplay'); } else { if (VIDEO_START_ON_CLICK) { elem_attr($v, 'onclick', 'this.play()'); } } // loop if (!empty($obj['video-loop'])) { elem_attr($v, 'loop', 'loop'); } // controls if (!empty($obj['video-controls'])) { elem_attr($v, 'controls', 'controls'); } // volume if (isset($obj['video-volume']) && $obj['video-volume'] == '0') { elem_attr($v, 'audio', 'muted'); } elem_append($elem, $v); return true; }
/** * implements alter_save * * see image_save_state() */ function image_alter_save($args) { $elem = $args['elem']; // make sure that obj is a reference to the other object here $obj =& $args['obj']; // only handle the element when we are one of its classes // notice the difference to image_save_state()? if (!elem_has_class($elem, 'image')) { return false; } // update the object based on the element's properties // by convention all properties are prefixed with the module name, in order // to prevent any naming collisions if (elem_css($elem, 'background-repeat') !== NULL) { $val = elem_css($elem, 'background-repeat'); // normalize if ($val == 'no-repeat no-repeat') { $val = 'no-repeat'; } $obj['image-background-repeat'] = $val; } else { unset($obj['image-background-repeat']); } if (elem_css($elem, 'background-position') !== NULL) { $obj['image-background-position'] = elem_css($elem, 'background-position'); } else { unset($obj['image-background-position']); } // this is more out of courtesy than anything else return true; }