Esempio n. 1
0
/**
 * Anypage Widgets convert
 *
 * Convers a description/text into content with widgets.
 * It replaces BBCode tags with content from widgets, for example:
 * [WIDGET:home]
 *
 * @param string $description Description to transform
 *
 * @return string Transformed description
 */
function anypage_widgets_convert($description)
{
    return preg_replace_callback('/\\[WIDGET:[^]]+\\]/', function ($matches) {
        $paramsString = substr(strip_tags($matches[0]), 8, -1);
        $params = (array) explode(':', $paramsString);
        if (!isset($params[0])) {
            return 'Widget ID not defined.';
        }
        $widget = get_entity($params[0]);
        if (!myvox_instanceof($widget, 'object', 'widget')) {
            return 'Widget not found.';
        }
        $style = '';
        foreach ($params as $param) {
            $subparam = explode('|', $param);
            switch ($subparam[0]) {
                case 'style':
                    if (isset($subparam[1]) && isset($subparam[2])) {
                        $style .= $subparam[1] . ': ' . $subparam[2] . ';';
                    }
                    break;
            }
        }
        return myvox_view('anypage_widgets/widget', array('body' => myvox_view_entity($widget), 'style' => $style));
    }, $description);
}
Esempio n. 2
0
</div>

<div id="anypage-description" <?php 
echo $desc_class;
?>
>
	<label><?php 
echo myvox_echo('anypage:body');
?>
</label><br />
	<?php 
echo myvox_view('page/layouts/widgets/add_button');
echo myvox_view('input/longtext', array('name' => 'description', 'value' => $description));
?>
</div>

<div class="myvox-foot">
<?php 
if ($guid) {
    echo myvox_view('input/hidden', array('name' => 'guid', 'value' => $guid));
    echo myvox_view('output/confirmlink', array('class' => 'float myvox-button myvox-button-action', 'text' => myvox_echo('delete'), 'href' => 'action/anypage/delete?guid=' . $guid));
}
echo myvox_view('input/submit', array('value' => myvox_echo("save"), 'class' => 'float-alt myvox-button myvox-button-action'));
?>
</div>
<div class="anypage_widgets_panel">
	<?php 
echo myvox_view('page/layouts/widgets/add_panel', array('context' => 'index'));
?>
</div>
Esempio n. 3
0
    forward('', 404);
}
if (!isset($CONFIG->widgets->handlers[$handler])) {
    forward('', 404);
}
$widgetGuid = myvox_create_widget(myvox_get_logged_in_user_guid(), $handler, 'all');
?>
<div style="width: 400px;">
    <?php 
echo myvox_view('page/elements/title', array('title' => myvox_echo('anypage_widgets:title')));
echo myvox_view('input/hidden', array('name' => 'widget', 'value' => $widgetGuid));
echo '<p>' . myvox_echo('anypage_widgets:description') . '</p>';
echo myvox_view('input/text', array('name' => 'widget-result', 'value' => '[WIDGET:' . $widgetGuid . ']', 'style' => 'width: 350px;', 'readonly' => 'yes'));
?>

    <fieldset style="border: 1px solid; padding: 15px; margin: 0 10px 0 10px">
        <legend><?php 
echo myvox_echo('anypage_widgets:title:style');
?>
</legend>

        <?php 
echo myvox_echo('anypage_widgets:input:style:height');
echo myvox_view('input/text', array('name' => 'style-height', 'class' => 'widget-param'));
echo myvox_echo('anypage_widgets:input:style:width');
echo myvox_view('input/text', array('name' => 'style-width', 'class' => 'widget-param'));
echo myvox_echo('anypage_widgets:input:style:float') . '<br/>';
echo myvox_view('input/dropdown', array('name' => 'style-float', 'options' => array('left', 'right'), 'class' => 'widget-param', 'data-default' => 'left'));
?>
    </fieldset>
</div>