Exemple #1
0
 function render()
 {
     parent::render();
     $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/d3.v3.min.js'));
     $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/dagre-d3.min.js'));
     $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/graphlib-dot.min.js'));
 }
Exemple #2
0
 function _addJsCode()
 {
     if (!org_glizy_ObjectValues::get('org.glizy.googleMap', 'add', false)) {
         $rootComponent = $this->getRootComponent();
         $rootComponent->addOutputCode(org_glizy_helpers_JS::linkJSfile('http://maps.google.com/maps/api/js?sensor=false'), 'head');
     }
 }
Exemple #3
0
    /**
     * Render
     *
     * @return	void
     * @access	public
     */
    function render_html()
    {
        $folder = $this->getAttribute('folder');
        $src = $this->getAttribute('src');
        $type = $this->getAttribute('type');
        $language = $this->_application->getLanguage();
        $language2 = $language . '-' . strtoupper($language);
        $src = str_replace(array('##LANG##', '##LANG2##'), array($language, $language2), $src);
        if ($folder) {
            if (!org_glizy_ObjectValues::get('org.glizy.JS', 'run', false)) {
                org_glizy_ObjectValues::set('org.glizy.JS', 'run', true);
                $pageType = $this->_application->getPageType();
                $state = __Request::get('action', '');
                $params = __Request::getAllAsArray();
                unset($params['__params__']);
                unset($params['__routingName__']);
                unset($params['__routingPattern__']);
                unset($params['__url__']);
                unset($params['__back__url__']);
                $params = json_encode($params);
                $jsCode = <<<EOD
var GlizyApp = {};
GlizyApp.pages = {};
jQuery( function(){
\tif ( typeof( GlizyApp.pages[ '{$pageType}' ] ) != 'undefined' )
\t{
\t\tGlizyApp.pages[ '{$pageType}' ]( '{$state}', {$params} );
\t}
})
EOD;
                $this->addOutputCode(org_glizy_helpers_JS::JScode($jsCode), 'head');
            }
            // include tutta una cartella
            $jsFileName = $this->includeFolder($folder);
            if ($this->getAttribute('inline')) {
                $js = file_get_contents($jsFileName);
                if (strpos($js, '<script') !== false) {
                    $this->addOutputCode($js);
                } else {
                    $this->addOutputCode(org_glizy_helpers_JS::JScode($js, $type));
                }
            } else {
                $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jsFileName . (__Config::get('DEBUG') ? '?' . microtime(true) : ''), null, $type));
            }
        } else {
            if ($src) {
                $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($src, null, $type));
            } else {
                $this->addOutputCode(org_glizy_helpers_JS::JScode($this->replaceLocale($this->getText()), $type));
            }
        }
    }
Exemple #4
0
 public function render_html_onStart()
 {
     if ($this->getAttribute('mode') == 'container') {
         $this->addOutputCode('<iframe id="js-glizycmsPageEdit" src="" data-emptysrc="' . $this->emptySrc . '" data-editsrc="' . $this->editSrc . '"></iframe>');
         $corePath = __Paths::get('CORE');
         $jQueryPath = $corePath . 'classes/org/glizycms/js/jquery/';
         $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'jquery.pnotify/jquery.pnotify.min.js'));
         $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'jquery.pnotify/jquery.pnotify.default.css'));
     } else {
         $this->addOutputCode('<div id="message-box"></div>');
         parent::render_html_onStart();
     }
 }
Exemple #5
0
    public function render_html_onEnd($value = '')
    {
        parent::render_html_onEnd();
        $corePath = __Paths::get('CORE');
        $jQueryPath = $corePath . 'classes/org/glizycms/js/jquery/';
        $languageCode = $this->_application->getLanguage();
        $language = $languageCode . '-' . strtoupper($languageCode);
        if ($this->getAttribute('newCode')) {
            $formEditPath = $corePath . 'classes/org/glizycms/js/formEdit2/';
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($corePath . 'classes/org/glizycms/js/underscore/underscore-min.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEdit.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditStandard.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditCheckbox.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditRepeat.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditDate.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditDateTime.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-datetimepicker-master/js/locales/bootstrap-datetimepicker.it.js'));
            $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'bootstrap-datetimepicker-master/css/datetimepicker.css'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditColorPicker.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-colorpicker/js/bootstrap-colorpicker.min.js'));
            $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'bootstrap-colorpicker/css/bootstrap-colorpicker.min.css'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditGUID.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditSelectFrom.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'select2/select2.min.js'));
            $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'select2/select2.css'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditTINYMCE.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditMediaPicker.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditFile.js'));
            //$this->addOutputCode( org_glizy_helpers_JS::linkJSfile( $jQueryPath.'fineuploader.jquery/jquery.fineuploader.js' ) );
            //$this->addOutputCode( org_glizy_helpers_CSS::linkCSSfile( $jQueryPath.'fineuploader.jquery/fineuploader.css' ) );
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'jquery.validVal-packed.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditPermission.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditPhotoGalleryCategory.js'));
            // $this->addOutputCode( org_glizy_helpers_JS::linkJSfile( $formEditPath.'GlizyFormEditGoogleMaps.js' ) );
            // $this->addOutputCode(org_glizy_helpers_JS::linkJSfile( 'http://maps.google.com/maps/api/js?sensor=false' ));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditCmsPagePicker.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditSelectPageType.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditUrl.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditModalPage.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($corePath . 'classes/org/glizycms/js/glizy-locale/' . $language . '.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'jquery.pnotify/jquery.pnotify.min.js'));
            $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'jquery.pnotify/jquery.pnotify.default.css'));
            $id = $this->getId();
            $mediaPicker = $this->getMediaPickerUrl();
            $AJAXAtion = $this->getAttribute('controllerName') ? $this->getAjaxUrl() : '';
            $customValidation = $this->getAttribute('customValidation');
            if ($customValidation) {
                $customValidation = 'customValidation: "' . $customValidation . '",';
            }
            $tinyMceUrls = json_encode($this->getTinyMceUrls());
            $jsCode = <<<EOD
jQuery(function(){
    if ( Glizy.tinyMCE_options )
    {
        Glizy.tinyMCE_options.urls = {$tinyMceUrls};
    }

    var myFormEdit = Glizy.oop.create("glizy.FormEdit", '{$id}', {
        AJAXAction: "{$AJAXAtion}",
        mediaPicker: {$mediaPicker},
        formData: {$this->data},
        {$customValidation}
        lang: GlizyLocale.FormEdit
    });
});
EOD;
        } else {
            $formEditPath = $corePath . 'classes/org/glizycms/js/formEdit/';
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($corePath . 'classes/org/glizycms/js/underscore/underscore-min.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEdit.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditTINYMCE.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditFile.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditMediaPicker.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditGoogleMaps.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditGUID.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditColorPicker.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditValuesPreset.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditDate.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditDatetime.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-datetimepicker-master/js/locales/bootstrap-datetimepicker.it.js'));
            $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'bootstrap-datetimepicker-master/css/datetimepicker.css'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-colorpicker/js/bootstrap-colorpicker.min.js'));
            $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'bootstrap-colorpicker/css/bootstrap-colorpicker.min.css'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($corePath . 'classes/org/glizycms/js/glizy-locale/' . $language . '.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'dropzone/dropzone.min.js'));
            $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'dropzone/css/basic2.css'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'jquery.validVal-packed.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditCmsPagePicker.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditSelectFrom.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'select2/select2.min.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'jquery.pnotify/jquery.pnotify.min.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditPermission.js'));
            $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'select2/select2.css'));
            $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'jquery.pnotify/jquery.pnotify.default.css'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditCheckbox.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile('http://maps.google.com/maps/api/js?sensor=false'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditSelectPageType.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditPhotoGalleryCategory.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditImageHotspot.js'));
            // $this->addOutputCode( org_glizy_helpers_JS::linkJSfile( $formEditPath.'GlizyFormEditTreeSelect.js' ) );
            // $this->addOutputCode( org_glizy_helpers_JS::linkJSfile( $jQueryPath.'fancytree/jquery.fancytree-all.min.js' ) );
            // $this->addOutputCode( org_glizy_helpers_CSS::linkCSSfile( $jQueryPath.'fancytree/skin-win7/ui.fancytree.min.css' ) );
            $id = $this->getId();
            $mediaPicker = $this->getMediaPickerUrl();
            $AJAXAtion = $this->getAttribute('controllerName') ? $this->getAjaxUrl() : '';
            $customValidation = $this->getAttribute('customValidation');
            if ($customValidation) {
                $customValidation = 'customValidation: "' . $customValidation . '",';
            }
            $tinyMceUrls = json_encode($this->getTinyMceUrls());
            $jsCode = <<<EOD
jQuery(function(){
    if ( Glizy.tinyMCE_options )
    {
        Glizy.tinyMCE_options.urls = {$tinyMceUrls};
    }

    var ajaxUrl = "{$AJAXAtion}";
    jQuery( "#{$id}" ).GlizyFormEdit({
        AJAXAction: ajaxUrl ? ajaxUrl : Glizy.ajaxUrl,
        mediaPicker: {$mediaPicker},
        formData: {$this->data},
        {$customValidation}
        lang: GlizyLocale.FormEdit
    });
});
EOD;
        }
        $this->addOutputCode(org_glizy_helpers_JS::JScode($jsCode));
    }
Exemple #6
0
    public function render_html()
    {
        $graphCode = '';
        $entityTypeId = $this->getAttribute('entityTypeId') ? $this->getAttribute('entityTypeId') : __Request::get('entityTypeId');
        if ($entityTypeId) {
            $visited = array();
            $edges = array();
            $graphCode = $this->getGraph($entityTypeId, $visited, $edges);
        }
        if (!$this->getAttribute('generateLinks')) {
            $this->language = $this->_application->getEditingLanguage();
            $this->localeService = $this->_application->retrieveProxy('movio.modules.ontologybuilder.service.LocaleService');
            $html = '<form id="myForm" method="post" class="form-horizontal row-fluid" >';
            $html .= '<label for="entityTypeId" class="control-label required">' . __T('Entity') . '</label>';
            $html .= '<select id="entityTypeId" name="entityTypeId">';
            $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.Entity', 'all');
            foreach ($it as $ar) {
                $selected = __Request::get('entityTypeId') == $ar->getId() ? 'selected="selected"' : '';
                $html .= '<option value="' . $ar->getId() . '" ' . $selected . '>' . $this->localeService->getTranslation($this->language, $ar->entity_name) . '</option>';
            }
            $html .= '</select>';
            $html .= '<input class="submit btn btn-primary" type="submit" value="' . __T('Draw') . '">';
            $html .= '</form>';
        }
        $graphCode = <<<EOD
digraph "" {
    {$graphCode}
}
EOD;
        $graphCode = str_replace(array("\r", "\n"), '', addslashes($graphCode));
        $html .= <<<EOD
<div style="text-align: center; position: relative; width: 100%;">
    <svg width="800" height="600">
      <g transform="translate(20, 20)"/>
    </svg>
</div>
<script>
        function tryDraw() {
            var result;
            try {
                result = graphlibDot.parse('{$graphCode}');
            } catch (e) {
                alert('Errore di caricamento del grafo!');
                throw e;
            }

            if (result) {
                var svg = d3.select("svg");
                var svgGroup = svg.append('g');

                var renderer = new dagreD3.Renderer();

                var layout = renderer.run(result, svgGroup);

                var parentWidth = 800;
                svg.attr('width', parentWidth);
                svg.attr('height', layout.graph().height + 250);
                var xCenterOffset = (svg.attr('width') - layout.graph().width) / 2;
                svgGroup.attr('transform', 'translate(' + xCenterOffset + ', 100)');
            }
        }

        function fixBaseTagProblem() {
            \$('g[class^="edgePaths"]').find('path').each(function() {
                \$(this).attr('marker-end', 'url(' + window.location + '#arrowhead)');
            });
        }

        function selectRootNode() {
            \$('div[class="main-node"]').parent().parent().parent().parent().children('rect').attr('class', 'main-node');
        }

        \$(window).bind('load', function() {
            tryDraw();
            fixBaseTagProblem();
            selectRootNode();
        });
</script>
EOD;
        if ($this->getAttribute('addGraphJsLibs.js')) {
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/d3.v3.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/dagre-d3.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/graphlib-dot.min.js'));
        }
        $this->addOutputCode($html);
    }
Exemple #7
0
    public function render_html()
    {
        $graphCode = '';
        $entityTypeId = $this->getAttribute('entityTypeId') ? $this->getAttribute('entityTypeId') : __Request::get('entityTypeId');
        $documentId = $this->getAttribute('documentId') ? $this->getAttribute('documentId') : __Request::get('document_id');
        if ($entityTypeId && $documentId) {
            $graphCode = $this->getDocumentGraph($entityTypeId, $documentId);
        }
        if (empty($graphCode)) {
            return;
        }
        $title = __T('Relations');
        $id = $this->getId();
        $graphCode = <<<EOD
digraph "" {
    {$graphCode}
}
EOD;
        $graphCode = str_replace(array("\r", "\n"), '', addslashes($graphCode));
        $html .= <<<EOD
<article class="box collapsible big">
    <h1>{$title}</h1>
    <button data-toggle="collapse" class="show-content-box" type="button" data-target="#{$id}"></button>
    <div id="{$id}" style="text-align: center;">
        <svg width="800" height="600">
          <g transform="translate(20, 20)"/>
        </svg>
    </div>
</article>
<script>
        function tryDraw() {
            var result;
            try {
                result = graphlibDot.parse('{$graphCode}');
            } catch (e) {
                alert('Errore di caricamento del grafo!');
                throw e;
            }

            if (result) {
                var svg = d3.select("svg");
                var svgGroup = svg.append('g');
                var renderer = new dagreD3.Renderer();
                var layout = renderer.run(result, svgGroup);

                //var parentWidth = parseInt(\$(svg).parent().css('width').replace('px', '')) - 250;
                var parentWidth = 800;
                svg.attr('width', parentWidth);
                svg.attr('height', layout.graph().height + 250);
                var xCenterOffset = (svg.attr('width') - layout.graph().width) / 2;
                svgGroup.attr('transform', 'translate(' + xCenterOffset + ', 100)');
            }
        }

        function fixBaseTagProblem() {
            \$('g[class^="edgePaths"]').find('path').each(function() {
                \$(this).attr('marker-end', 'url(' + window.location + '#arrowhead)');
            });
        }

        function selectRootNode() {
            \$('div[class="main-node"]').parent().parent().parent().parent().children('rect').attr('class', 'main-node');
        }

        \$(window).bind('load', function() {
            tryDraw();
            fixBaseTagProblem();
            selectRootNode();
            \$('.collapsible').children('div').addClass('collapse');
        });
</script>
EOD;
        if ($this->getAttribute('addGraphJsLibs.js')) {
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/d3.v3.js'), 'head');
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/dagre-d3.js'), 'head');
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/graphlib-dot.min.js'), 'head');
        }
        $this->addOutputCode($html);
    }
Exemple #8
0
    public function render_html()
    {
        $graphCode = '';
        $entityTypeId = $this->getAttribute('entityTypeId') ? $this->getAttribute('entityTypeId') : __Request::get('entityTypeId');
        $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.Entity', 'all');
        if ($it->count()) {
            $visited = array();
            $edges = array();
            foreach ($it as $ar) {
                if (!in_array($ar->getId(), array_keys($visited))) {
                    $graphCode .= $this->getGraph($ar->getId(), $visited, $edges, true);
                }
            }
        }
        $graphCode = <<<EOD
digraph "" {
    {$graphCode}
}
EOD;
        $graphCode = str_replace(array("\r", "\n"), '', addslashes($graphCode));
        $html .= <<<EOD
<div style="text-align: center;">
    <svg width="800" height="600">
      <g transform="translate(20, 20)"/>
    </svg>
</div>
        <style>
        svg {
            overflow: hidden;
        }
        
        /* Stile testo delle entità */
        g.nodes tspan {
            font-family: Helvetica, sans-serif;
            font-size: 14px;
        }
        /* Stile testo delle entità in HTML */
        g.nodes div {
            white-space: nowrap;
            padding: 4px;
            font-family: Helvetica, sans-serif;
            font-size: 13px;
        }
        
        /* Stile testo delle entità principali in HTML */
        div.main-node {
            padding: 2px 7px 2px 7px;
            font-family: Helvetica, sans-serif;
            font-size: 14px;
        }
        
        /* Stile testo delle relazioni */
        g.edgeLabels tspan {
            
        }

        /* Stile riquadro delle entità */
        .node rect {
            stroke: #cfced3;
            stroke-width: 2px;
            fill: none;
        }

        /* Stile delle frecce */
        .edgePath path {
            stroke: black;
            stroke-width: 1.5px;
            fill: none;
        }
        </style>
<script>
        function tryDraw() {
            var result;
            try {
                result = graphlibDot.parse('{$graphCode}');
            } catch (e) {
                alert('Errore di caricamento del grafo!');
                throw e;
            }

            if (result) {
                var svg = d3.select("svg");
                var svgGroup = svg.append('g');

                var renderer = new dagreD3.Renderer();

                var layout = renderer.run(result, svgGroup);

                var parentWidth = parseInt(\$(svg).parent().css('width').replace('px', '')) - 250;
                svg.attr('width', parentWidth);
                svg.attr('height', layout.graph().height + 250);
                var xCenterOffset = (svg.attr('width') - layout.graph().width) / 2;
                svgGroup.attr('transform', 'translate(' + xCenterOffset + ', 100)');
            }
        }
        
        function fixBaseTagProblem() {
            \$('g[class^="edgePaths"]').find('path').each(function() {
                \$(this).attr('marker-end', 'url(' + window.location + '#arrowhead)');
            });
        }
        
        function adjustEntityContainers() {
            \$('foreignObject').each(function() {
                var width = parseInt(\$(this).attr('width'));
                \$(this).attr('width', width + 25);
            });
        }

        \$(window).bind('load', function() {
            tryDraw();
            fixBaseTagProblem();
            adjustEntityContainers();
        });
</script>
EOD;
        if ($this->getAttribute('addGraphJsLibs.js')) {
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/d3.v3.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/dagre-d3.js'));
            $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/graphlib-dot.min.js'));
        }
        $this->addOutputCode($html);
    }
Exemple #9
0
 public function render_html_onEnd($value = '')
 {
     parent::render_html_onEnd($value);
     $language = $this->_application->getLanguage();
     $language = $language . '-' . strtoupper($language);
     $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('APPLICATION') . 'classes/movio/modules/ontologybuilder/views/js/locale/' . $language . '.js'));
     $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('APPLICATION') . 'classes/movio/modules/ontologybuilder/views/js/EntityFormEditEntitySelect.js'));
 }