protected function editAboutMe() { $form = Form::load('logbook.views.EditBlogAuthorDetails'); if($form->validate()) { $item = new Author(); $item->clause('user_id',Application::current()->user()->id()); $item->parse(); $item->synch(); Application::setParam('author_id',$item->id()); $this->redirectOnSave(); } }
public function save() { $form = Form::load('logbook.views.AddBlogEntry'); if($form->validate()) { $auth = new Author(); $auth->clause('user_id',Application::current()->user()->id()); if($auth->id()) { $item = new Entry(); $item->parse(); $item->set('author_id',$auth->id()); if(!Application::param('entry_date')) $item->set('entry_date',date('Y-m-d H:i:s')); $item->synch(); Entry::setTagsAndSave($item,Application::param('entry_tags')); $group = new Group(); $group->noForeign(); $author_id = $item->get('author_id'); $entry_id = $item->get('entry_id'); if($groups = $group->fetch()) { foreach($groups as $group) { if(file_exists(Application::MANAGED_CODE.'lbk_default_access_'.$group->get('access_id'))) { $data = file_get_contents(Application::MANAGED_CODE.'lbk_default_access_'.$group->get('access_id')); $perms = unserialize($data); ManageGroupAccess::setPermissionsOnEntryForGroup($author_id,$entry_id,$group->id(),$perms); } } } Application::setUrlParam('author_id',Application::param('author_id')); Application::setUrlParam('entry_id',Application::param('entry_id')); LogbookAccess::publishLookupTables(); $this->redirectOnSave(); } else die('You are not an author!'); } }
public function display() { $disp = Display::current(); $disp->setValue('tree_menu', $disp->treeMenu()); $disp->addView('page_content', 'frost.views.cms.part.text.TextAdd'); $form = Form::load('frost.views.cms.part.text.TextAdd'); $form->setInputValue('module_id', Application::param('module_id')); $form->setInputValue('media_type', Application::param('media_type')); $form->setInputValue('label', 'Plain text item'); $form->setInputValue('weight', '1000'); $disp->setValue('module_id', Application::param('module_id')); $disp->setValue('login_error', $this->login_error); $disp->setValue('current_handler', Application::current()->handler()->getClass()); $disp->addForm($form); $disp->displaySiteTemplate(); }
public function RemoteDisplay() { $this->Display(); $this->responses = array(); $this->remote_num = ''; $this->ignore_ajax = ''; $this->called = ''; $this->chunks = array(); $this->previous_display = ''; JsRegister::current()->setPluginPath('ext/js/'); JsRegister::current()->registerScript('prototype'); JsRegister::current()->registerScript('scriptaculous'); $args = array(); $args['remote_num'] = $this->remoteNum(); JsRegister::current()->setPluginPath('packages/remote/'); JsRegister::current()->registerScript('remote_form'); JsRegister::current()->registerScript('remote_num', $args); Application::current()->setRedirectionListener($this); $this->expireRemoteDisplays(); }
protected function saveSiteFunction() { $form = Form::load('pilot.views.SiteFunctionMain'); $site_function = new SiteFunction(); if ($site_function_id = Application::param('site_function_id')) { $site_function->clauseSafe('site_function_id', $site_function_id); } $this->saveObject($form, $site_function, $this->siteFunctionTitle()); SiteNavigation::init(Application::current()->user()->getHandlerTree()); if (!Application::current()->user()->authorise($this->getClass())) { throw new AccessDeniedException('You cannot access this function'); } }
/** * Check if this application is running on the command line * * Some reasons why you might need to do this is to throw an exception * if a function is _not_ being run from the command line. For example * your access control system depends on the session to store a valid * user, but the session is not available from the command line, then you * need to make your handlers that run from the command line publicly * available, however, you don't want them run from a browser, only= * via the command line by cron, for example * @return boolean - true if this script is being executed from the * command line * @access public * @static */ public static function isCommandLine() { $ret = false; $app = Application::current(); if (is_object($app)) { $ret = $app->is_command_line; } return $ret; }
public function runHandlerTest() { $redir = Application::current()->redirection_listener; Application::current()->setRedirectionListener($this); Application::alterParam('h', $this->test_handler->getClass()); try { ob_start(); Application::current()->run(); $cached = ob_get_clean(); } catch (RedirectionException $exc) { $this->setResult('Redirected to: ' . $exc->handler() . ' with vars: ' . $exc->varString(), MurphyTest::REDIRECT); Application::current()->setRedirectionLister($redir); } catch (AccessDeniedException $exc) { $this->setResult('Access denied to ' . $this->test_handler->getClass() . ' for user: '******' in test: ' . $this->name, MurphyTest::ACCESS_DENIED); Application::current()->setRedirectionLister($redir); } catch (Exception $exc) { $this->setResult('Exception of type ' . get_class($exc) . ': ' . $exc->getMessage(), MurphyTest::EXCEPTION); Application::current()->setRedirectionLister($redir); } $this->setResult('Completed handler test for: ' . $this->name, MurphyTest::COMPLETE); }
public function display() { //echo "<br />DEBUG: HERE<br />"; header('Content-type: application/x-javascript'); readfile("http://" . $_SERVER['HTTP_HOST'] . "/packages/seeingsystem/views/js/ss_prototype.js"); readfile("http://" . $_SERVER['HTTP_HOST'] . "/packages/seeingsystem/views/js/ss_effects.js"); $disp = Display::current(); if (Application::current()->user()->authorise('SeeingsystemSetup')) { $disp->setValue('logged_in', true); } else { $disp->setValue('login_error', $this->login_error); $login_form = Form::load('seeingsystem.views.Login'); $disp->addForm($login_form); } // Write to the log $fh = fopen('access_logs/access.log', 'a') or die("can't open file"); $stringData = time() . "," . $_SERVER['HTTP_REFERER'] . "\n"; fwrite($fh, $stringData); fclose($fh); $params = $this->getParams(); if ($params['user_id']) { $disp->setValue('user_tags', $this->getFlickrTags($params['api_key'], $params['user_id'])); } else { $disp->setValue('user_tags', ''); } $disp->setValue('timeout_interval', $params['timeout_interval']); $disp->setValue('fade_speed', $params['fade_speed']); $disp->setValue('domain', $_SERVER['HTTP_HOST']); $disp->setValue('ss_key', $params['key']); $disp->setValue('slide_div_width', $params['width']); $disp->setValue('slide_div_height', $params['height']); $disp->setValue('api_key', $params['api_key']); // Change the method if there is no user and no tags if (!$params['user_id'] && !$params['tags']) { $disp->setValue('method', 'flickr.photos.getrecent'); } else { $disp->setValue('method', $params['method']); } // user_id (Optional) - The NSID of the user who's photo to search. // If this parameter isn't passed then everybody's public photos will be searched. // A value of "me" will search against the calling user's photos for authenticated calls. $disp->setValue('user_id', $params['user_id']); //photoset_id (Optional) - The id of the photoset $disp->setValue('photoset_id', $params['photoset_id']); //tags (Optional) - A comma-delimited list of tags. Photos with one or more of the tags listed will be returned. $disp->setValue('tags', $params['tags']); // tag_mode (Optional) - Either 'any' for an OR combination of tags, or 'all' for an AND combination. // Defaults to 'any' if not specified. $disp->setValue('tag_mode', $params['tag_mode']); //sort (Optional) - The order in which to sort returned photos. Deafults to date-posted-desc. // The possible values are: date-posted-asc, date-posted-desc, date-taken-asc, date-taken-desc, // interestingness-desc, interestingness-asc, and relevance. $disp->setValue('sort', $params['sort']); //extras (Optional) - A comma-delimited list of extra information to fetch for each returned record. // Currently supported fields are: license, date_upload, date_taken, owner_name, icon_server, original_format, // last_update, geo, tags, machine_tags. $disp->setValue('extras', $params['extras']); //content_type (Optional) - Content Type setting: 1 for photos only. 2 for screenshots only. // 3 for 'other' only. 4 for all types. $disp->setValue('content_type', '1'); //per_page (Optional) - Number of photos to return per page. If this argument is omitted, it defaults to 100. // The maximum allowed value is 500. $disp->setValue('per_page', $params['per_page']); //page (Optional) - The page of results to return. If this argument is omitted, it defaults to 1. $disp->setValue('page', 1); $disp->setValue('format', $params['format']); //header('Content-type: application/x-javascript'); $disp->displayPage('packages/seeingsystem/views/flickr_json_slideshow01.php'); // Load the view that is specific to the 'display' parameter in the databse configuration. The 'default' // display is just a call to the init() function of the generic object. $disp->displayPage('packages/seeingsystem/views/flickr_json_slideshow01_' . $params['display'] . '.php'); }
/** * Display a page, with the variables that have been previously * assigned using the {@link Display::addView()} method. * * This method should be called by the programmer during a * {@link Display::current()} execution with the top level 'site template' * that the programmer has set. * * The url to display must be a valid RocketSled template. At present * this means that it is an HTML page with embedded php that calls * the necessary methods of the display class to plug the required * values into the template. * * This method will throw an exception when a view is attempted to * display without first being added. * @param name - the name passed to {@link Display::addView()} * @see RsmlView */ public function view($view_name, $optional = false) { if ($view = $this->getView($view_name)) { if ($view instanceof RsmlView) { $view->display($this); } else { throw new Exception('The view: ' . $view_name . ' is not an RsmlView, it is: ' . $view->getClass()); } } else { if (!$optional) { throw new Exception('No view with name: ' . $view_name . ' was registered with this display object. FULL DEBUG for ' . Application::current()->handler()->getClass() . ': ' . $data); } } }
public function display() { $disp = Display::current(); if (Application::current()->user()->authorise('SeeingsystemSetup')) { $disp->setValue('logged_in', true); } else { $disp->setValue('login_error', $this->login_error); $login_form = Form::load('seeingsystem.views.Login'); $disp->addForm($login_form); } if (Application::param('tags')) { $tags = Application::param('tags'); } else { $tags = 'seeingsystem'; } $page = 0; if (Application::param('static') && Application::param('page')) { $page = Application::param('page'); # # build the API URL to call # $params = array('api_key' => '1cd28ef9270b9dad6d02734d6a8d88a9', 'method' => 'flickr.photos.search', 'user_id' => '77411642@N00', 'tags' => $tags, 'tag_mode' => 'all', 'sort' => 'date-posted-desc', 'extras' => 'original_format', 'content_type' => '1', 'per_page' => '1', 'page' => $page, 'format' => 'php_serial'); $rsp_obj = $this->getFlickrPhotos($params); # # display the photo title (or an error if it failed) # if ($rsp_obj['stat'] == 'ok') { /* Photo Source URLs ----------------- You can construct the source URL to a photo once you know its ID, server ID, farm ID and secret, as returned by many API methods. The URL takes the following format: http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}.jpg http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{o-secret}_o.(jpg|gif|png) Size Suffixes: The letter suffixes are as follows: s small square 75x75 t thumbnail, 100 on longest side m small, 240 on longest side - medium, 500 on longest side b large, 1024 on longest side (only exists for very large original images) o original image, either a jpg, gif or png, depending on source format Note: Original photos behave a little differently. They have their own secret (called originalsecret in responses) and a variable file extension (called originalformat in responses). These values are returned via the API only when the caller has permission to view the original size (based on a user preference and various other criteria). The values are returned by the flickr.photos.getInfo method and by any method that returns a list of photos and allows an extras parameter (with a value of original_format), such as flickr.photos.search. The flickr.photos.getSizes method, as always, will return the full original URL where permissions allow. Example: http://farm1.static.flickr.com/2/1418878_1e92283336_m.jpg farm-id: 1 server-id: 2 photo-id: 1418878 secret: 1e92283336 size: m */ //print_r($rsp_obj['photos']['photo'][0]); //Using - http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg $photo_id = $rsp_obj['photos']['photo'][0]['id']; $farm_id = $rsp_obj['photos']['photo'][0]['farm']; $server_id = $rsp_obj['photos']['photo'][0]['server']; $secret = $rsp_obj['photos']['photo'][0]['secret']; //$file_name = $rsp_obj['photos']['photo'][0]['title']; $photo_url = "http://farm{$farm_id}.static.flickr.com/{$server_id}/{$photo_id}_{$secret}.jpg"; $size = getimagesize($photo_url); $width = $size[0]; $height = $size[1]; $top_border = (704 - $height) / 2; $bottom_border = (704 - $height) / 2 - 1; $left_border = (704 - $width) / 2; $right_border = (704 - $width) / 2 - 1; $style = "width:{$width}px;height:{$height}px;border-top:{$top_border}px solid black;border-bottom:{$bottom_border}px solid black;border-left:{$left_border}px solid black;border-right:{$right_border}px solid black;"; } else { echo "Call failed!"; } $disp->setValue('photo_url', $photo_url); $disp->setValue('style', $style); } else { $disp->setValue('photo_url', "/assets/start.jpg"); //$disp->setValue('photo_url', ""); } $disp->setTitle('Seeing System - Slideshow'); $disp->setValue('page', ++$page); $disp->setValue('tags', $tags); $disp->addView('page_content', 'seeingsystem.views.Seeingsystem'); $disp->displaySiteTemplate(); }