Beispiel #1
0
 /**
  * @brief Widget name and argument and produce a result and Return the results
  * Tags used in templateHandler $this-> execute() will be replaced by the code running
  *
  * $Javascript_mode is true when editing your page by the code for handling Includes photos
  */
 function execute($widget, $args, $javascript_mode = false, $escaped = true)
 {
     // Save for debug run-time widget
     $start = microtime(true);
     // urldecode the value of args haejum
     $object_vars = get_object_vars($args);
     if (count($object_vars)) {
         foreach ($object_vars as $key => $val) {
             if (in_array($key, array('widgetbox_content', 'body', 'class', 'style', 'widget_sequence', 'widget', 'widget_padding_left', 'widget_padding_top', 'widget_padding_bottom', 'widget_padding_right', 'widgetstyle', 'document_srl'))) {
                 continue;
             }
             if ($escaped) {
                 $args->{$key} = utf8RawUrlDecode($val);
             }
         }
     }
     /**
      * Widgets widgetContent/widgetBox Wanted If you are not content
      */
     $widget_content = '';
     if ($widget != 'widgetContent' && $widget != 'widgetBox') {
         if (!is_dir(sprintf(_XE_PATH_ . 'widgets/%s/', $widget))) {
             return;
         }
         // Hold the contents of the widget parameter
         $widget_content = $this->getCache($widget, $args);
     }
     if ($widget == 'widgetBox') {
         $widgetbox_content = $args->widgetbox_content;
     }
     /**
      * Wanted specified by the administrator of the widget style
      */
     // Sometimes the wrong code, background-image: url (none) can be heard but none in this case, the request for the url so unconditionally Removed
     $style = preg_replace('/url\\((.+)(\\/?)none\\)/is', '', $args->style);
     // Find a style statement that based on the internal margin dropping pre-change
     $widget_padding_left = $args->widget_padding_left;
     $widget_padding_right = $args->widget_padding_right;
     $widget_padding_top = $args->widget_padding_top;
     $widget_padding_bottom = $args->widget_padding_bottom;
     $inner_style = sprintf("padding:%dpx %dpx %dpx %dpx !important;", $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left);
     /**
      * Wanted widget output
      */
     $widget_content_header = '';
     $widget_content_body = '';
     $widget_content_footer = '';
     // If general call is given on page styles should return immediately dreamin '
     if (!$javascript_mode) {
         if ($args->id) {
             $args->id = ' id="' . $args->id . '" ';
         }
         switch ($widget) {
             // If a direct orthogonal addition information
             case 'widgetContent':
                 if ($args->document_srl) {
                     $oDocumentModel = getModel('document');
                     $oDocument = $oDocumentModel->getDocument($args->document_srl, false, false, false);
                     $body = $oDocument->getContent(false, false, false, false);
                 } else {
                     $body = base64_decode($args->body);
                 }
                 // Change the editor component
                 $oEditorController = getController('editor');
                 $body = $oEditorController->transComponent($body);
                 $widget_content_header = sprintf('<div class="xe_content xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s"><div style="%s">', $args->id, $style, $inner_style);
                 $widget_content_body = $body;
                 $widget_content_footer = '</div></div>';
                 break;
                 // If the widget box; it could
             // If the widget box; it could
             case 'widgetBox':
                 $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s;"><div style="%s"><div>', $args->id, $style, $inner_style);
                 $widget_content_body = $widgetbox_content;
                 break;
                 // If the General wijetil
             // If the General wijetil
             default:
                 $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s">', $args->id, $style);
                 $widget_content_body = sprintf('<div style="*zoom:1;%s">%s</div>', $inner_style, $widget_content);
                 $widget_content_footer = '</div>';
                 break;
         }
         // Edit page is called when a widget if you add the code for handling
     } else {
         switch ($widget) {
             // If a direct orthogonal addition information
             case 'widgetContent':
                 if ($args->document_srl) {
                     $oDocumentModel = getModel('document');
                     $oDocument = $oDocumentModel->getDocument($args->document_srl, false, false, false);
                     $body = $oDocument->getContent(false, false, false);
                 } else {
                     $body = base64_decode($args->body);
                 }
                 // by args
                 $attribute = array();
                 if ($args) {
                     foreach ($args as $key => $val) {
                         if (in_array($key, array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget', 'widgetstyle', 'document_srl'))) {
                             continue;
                         }
                         if (strpos($val, '|@|') > 0) {
                             $val = str_replace('|@|', ',', $val);
                         }
                         $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
                     }
                 }
                 $oWidgetController = getController('widget');
                 $widget_content_header = sprintf('<div class="xe_content widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent" document_srl="%d" %s>' . '<div class="widgetResize"></div>' . '<div class="widgetResizeLeft"></div>' . '<div class="widgetBorder">' . '<div style="%s">', $args->widgetstyle, $style, $args->widget_padding_left, $args->widget_padding_right, $args->widget_padding_top, $args->widget_padding_bottom, $args->document_srl, implode(' ', $attribute), $inner_style);
                 $widget_content_body = $body;
                 $widget_content_footer = sprintf('</div>' . '</div>' . '<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>' . '</div>', base64_encode($body));
                 break;
                 // If the widget box; it could
             // If the widget box; it could
             case 'widgetBox':
                 // by args
                 $attribute = array();
                 if ($args) {
                     foreach ($args as $key => $val) {
                         if (in_array($key, array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget', 'widgetstyle', 'document_srl'))) {
                             continue;
                         }
                         if (!is_numeric($val) && (!is_string($val) || strlen($val) == 0)) {
                             continue;
                         }
                         if (strpos($val, '|@|') > 0) {
                             $val = str_replace('|@|', ',', $val);
                         }
                         $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
                     }
                 }
                 $widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" %s >' . '<div class="widgetBoxResize"></div>' . '<div class="widgetBoxResizeLeft"></div>' . '<div class="widgetBoxBorder"><div class="nullWidget" style="%s">', $args->widgetstyle, $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, implode(' ', $attribute), $inner_style);
                 $widget_content_body = $widgetbox_content;
                 break;
                 // If the General wijetil
             // If the General wijetil
             default:
                 // by args
                 $attribute = array();
                 if ($args) {
                     $allowed_key = array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget');
                     foreach ($args as $key => $val) {
                         if (in_array($key, $allowed_key)) {
                             continue;
                         }
                         if (!is_numeric($val) && (!is_string($val) || strlen($val) == 0)) {
                             continue;
                         }
                         if (strpos($val, '|@|') > 0) {
                             $val = str_replace('|@|', ',', $val);
                         }
                         $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
                     }
                 }
                 $widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >' . '<div class="widgetResize"></div>' . '<div class="widgetResizeLeft"></div>' . '<div class="widgetBorder">', $args->widgetstyle, $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $widget, implode(' ', $attribute));
                 $widget_content_body = sprintf('<div style="%s">%s</div>', $inner_style, $widget_content);
                 $widget_content_footer = '</div></div>';
                 break;
         }
     }
     // Compile the widget style.
     if ($args->widgetstyle) {
         $widget_content_body = $this->compileWidgetStyle($args->widgetstyle, $widget, $widget_content_body, $args, $javascript_mode);
     }
     $output = $widget_content_header . $widget_content_body . $widget_content_footer;
     // Debug widget creation time information added to the results
     $elapsed_time = microtime(true) - $start;
     $GLOBALS['__widget_excute_elapsed__'] += $elapsed_time;
     Rhymix\Framework\Debug::addWidget(array('name' => $widget, 'elapsed_time' => $elapsed_time));
     // Return result
     return $output;
 }