public static function run() { JxWui::begin_http_session(); /* if the request method might indicate form url-encoded data and the content type is not JSON, we need to first transcode the request from HTTP to JSON */ if ($_SERVER['REQUEST_METHOD'] != 'GET' && $_SERVER['CONTENT_TYPE'] != 'application/json') { JxWui::load_screen($_SESSION['prev_screen']); JxWui::load_layout(JxWui::$screen_manifest['layout']); $null = NULL; JxWui::$screen_layout->configure(JxWui::$screen_manifest, $null); $request = JxWui::$screen_layout->generate_rest(); } else { $request = array(); } JxWuiRestHandler::adorn_request_desc($request); $response = JxWuiRestHandler::get_appication_response($request); JxWui::load_screen($response['screen']); JxWui::load_layout(JxWui::$screen_manifest['layout']); JxWui::$screen_layout->configure(JxWui::$screen_manifest, $response); JxWui::$screen_layout->generate_screen($response); }
public static function respond($in_request) { $response = JxWuiRestHandler::get_rest_app_response($in_request); $response['resource-id'] = $request['resource-id']; return $response; }
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ require dirname(__FILE__) . '/jx-wui/init.php'; function url_base_admin() { return dirname($_SERVER['PHP_SELF']) . '/'; } // application registers various things with the WUI toolkit JxWui::configure('jx-cms', url_base_admin(), dirname(__FILE__) . '/'); //JxWuiRestHandler::register('/articles/*/attrs', array('admin', 'handler_articles')); JxWuiRestHandler::register('/articles/*', array('admin', 'handler_articles')); JxWuiRestHandler::register('/', array('admin', 'handler_default')); // the other way a request can come in is as ajax, but we're not going to do that yet // so we just want to handle a HTTP request GET/POST // and identify that it's not JSON (origin the WUI form) JxWui::run(); class Admin { public static function handler_default($request) { $response = array('screen' => 'articles-list'); $response['row-map'] = array('id', 'title', 'status', 'date', 'author'); $response['row-data'] = array(array(1, 'Hello World!', 'Published', '2015-12-16', 'Josh Hawcroft'), array(2, 'Second Article', 'Draft', '2015-12-17', 'Josh Hawcroft')); return $response; } public static function handler_articles($request) {