<?php require_once "lib/Wix.php"; require_once "lib/Logic.php"; $wix = new Wix(); $instance = $wix->getDecodedInstance(); // LOAD POSTS $posts = new Posts(); $posts->loadList(); // LOAD SETTINGS $widgetSettings = new WidgetSettings($instance ? $instance['instanceId'] : "sample-instance"); $widgetSettings->readSettings(); ?> <!-- POSTS LIST --> <div style="width: <?php print getWixWidth(); ?> "> <div style="padding: 10px"> <?php foreach ($posts as $post) { ?> <ul> <li> <a href="<?php echo $wix->getSectionUrl(); ?> /post.show.php?title=<?php echo $post->getTitle();
function getWixWidth() { $wix = new Wix(); // this only works with contants, but this logic is for this application only. return $wix->getWidth() ? $wix->getWidth() . "px" : "auto"; }
<?php require_once "lib/Wix.php"; require_once "lib/Logic.php"; $wix = new Wix(); $instance = $wix->getDecodedInstance(); // LOAD SETTINGS $instanceId = $instance ? $instance['instanceId'] : "sample-instance"; $settings = new Settings($instanceId); $widgetSettings = new WidgetSettings($instanceId); // READ SETTINGS $settings->readSettings(); $widgetSettings->readSettings(); // CHECK IF POSTED CHANGES if ($_SERVER['REQUEST_METHOD'] == "POST") { $postedSectionSettings = isset($_POST['section']) ? $_POST['section'] : array(); $postedWidgetSettings = isset($_POST['widget']) ? $_POST['widget'] : array(); // update function, this will update the settings for &$settings with $arr. $postedSettingsUpdate = function (array $arr, &$settings) { $postedSettingsCheckboxs = array("withImages", "withDescription", "withPostedBy"); // the checkbox input name in the html foreach ($postedSettingsCheckboxs as $key) { $settings->setSetting($key, false); // clean checkboxs values } foreach ($arr as $key => $value) { if (in_array($key, $postedSettingsCheckboxs)) { // checkbox support if ($value == "on") { $value = true; } else {