protected function addBlogCommentForm()
        {
	    $form = Form::load('logbook.views.AddBlogComment');
            $form->setInputValue('author_id',Application::param('author_id'));
            $form->setInputValue('entry_id',Application::param('entry_id'));
            return $form;
        }
 public function setAuthorId($id = '')
 {
     if (!$id) {
         $id = Application::param('author_id');
     }
     $this->author_id = $id;
 }
 private function generateRss()
 {
     $author = new Author();
     $author->clause('author_id', Application::param('author_id'));
     $posts = $author->also('Entry');
     $posts->order('entry_timestamp');
     $posts->descending();
     $posts->limit(10);
     $blog_entries = $posts->fetch();
     echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     echo '<rss version="2.0">' . "\n";
     echo '    <channel>' . "\n";
     echo '        <title>' . $this->title() . '</title>' . "\n";
     echo '        <description>' . $this->description() . '</description>' . "\n";
     echo '        <link>' . $this->url() . '</link>' . "\n";
     foreach ($blog_entries as $entry) {
         echo '        <item>' . "\n";
         echo '            <title>' . $entry->get('entry_title') . '</title>' . "\n";
         echo '            <description>' . $entry->get('entry_body') . '</description>' . "\n";
         echo "            <link>'.{$this->url}().'/index.php?h=ViewBlogEntry</link>\n";
         echo '            <guid isPermalink="true">' . $this->url() . '/index.php?h=ViewBlogEntry&author_id=' . $entry->get('author_id') . '&entry_id=' . $entry->get('entry_id') . '</guid>' . "\n";
         echo '            <pubDate>' . $entry->entryDate() . '</pubDate>' . "\n";
         echo '        </item>' . "\n";
     }
     echo '    </channel>' . "\n";
     echo '</rss>' . "\n";
 }
 public function performHandlerTasks()
 {
     if(Application::formPosted())
     {
         if(Application::param('edit_about_me'))
             $this->editAboutMe();
     }
 }
 private function mapView()
 {
     $form = Form::load('sys.views.rsml_test.RsmlMapForm');
     if ($form->validate()) {
         $view = new RsmlView(Application::param('path'));
         $this->map = $view->documentObject();
     }
 }
 public function performHandlerTasks()
 {
     $comment = new Comment();
     $comment->clauseSafe('author_id', Logbook::current()->authorId());
     $comment->clauseSafe('entry_id', Application::param('entry_id'));
     $comment->clauseSafe('comment_id', Application::param('comment_id'));
     $comment->delete();
     Application::setParam('author_id', Logbook::current()->authorId());
     $this->redirectOnSave();
 }
 public static function validate()
 {
     $data = file_get_contents(Application::host() . 'ext/hn_captcha/hn_captcha.x1.example.php?hncaptcha=' . Application::param('hncaptcha') . '&public_key=' . Application::param('public_key') . '&private_key=' . Application::param('private_key'));
     if (strpos($data, 'Congratulation') !== FALSE) {
         $ret = true;
     } else {
         FormErrors::add('captcha', 'Invalid captcha entry, please try again');
         $ret = false;
     }
     return $ret;
 }
 function validate($value)
 {
     $ret = true;
     if ($value && !Application::param('user_id')) {
         $user = new User();
         $user->clause('user_email', $value);
         if ($user->id()) {
             $ret = false;
             $this->setErrorMessage('A user with that email already exists');
         }
     }
     return $ret;
 }
    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 static function blogEntry($author_id = '',$entry_id = '')
	{
	    $entry = new Entry();
        $min_access = Application::user()->minAccessLevel();
        $access = $entry->also('Access');
        $access->clause('access_level',$min_access,Clause::GTE);
	    
	    if(Application::user()->id())
	    {
	        $lbk_user = $entry->also('LogbookUser');
                $lbk_user->clauseSafe('user_id',Application::user()->id());
	    }

	    if($author_id)
	        $entry->clauseSafe('author_id',Logbook::current()->authorId());

	        $entry->maybe('BlogTag');
            
            if(!$entry_id)
                $entry_id = Application::param('entry_id');

            if($entry_id&&$author_id)
	        $entry->clauseSafe('entry_id',$entry_id);

            $entry->order('entry_date');
            
            /*$entry->order('author_id');
            $entry->order('entry_id');*/
            $entry->maybe('Comment');
            $entry->descending();
            
            try
            {
	        $page = $entry->page(1,1);
	        $ret = current($page->objects());
	        Logbook::current()->setAuthorId($ret->get('author_id'));
            }
            
            catch(Exception $exc)
            {
                $ret = new Entry();
            }
	    
	    return $ret;
        }
Example #11
0
 public function performHandlerTasks()
 {
     if (Application::formPosted()) {
         $form = Form::load('seeingsystem.views.Login');
         if ($form->validate()) {
             try {
                 PilotApplication::login(Application::param('user_email'), Application::param('user_password'));
             } catch (UserNotFoundException $exc) {
                 $this->login_error = 'No user with that email is registered';
             } catch (InvalidPasswordException $exc) {
                 $this->login_error = 'The password was incorrect';
             }
         }
     } else {
         if (Application::param('logout')) {
             PIlotApplication::logout();
         }
     }
 }
        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 parseForm()
 {
     $reserved = array('form_name', 'return_url', 'mail_to', 'Submit');
     $form_name = Application::param('form_name');
     $mail_to = Application::param('mail_to');
     $return_url = Application::param('return_url');
     $submission_no_query = SimpleQuery::create('SELECT COUNT(DISTINCT submission_no) AS count FROM ant_antenna_data WHERE form_name=\'' . $form_name . '\'');
     $submission_no_results = $submission_no_query->next();
     $submission_no = $submission_no_results['count'];
     $form_data = array();
     foreach (Application::post() as $key => $value) {
         if (!in_array($key, $reserved)) {
             $data = new AntennaData();
             $data->construct('', $form_name, $submission_no, $key, $value, '0');
             $data->saveLater();
             $form_data[$key] = $value;
         }
     }
     $data->purge();
     $this->emailSubmission($form_name, $mail_to, $form_data, $submission_no[count]);
 }
 public function manageAccess()
 {
     $form = Form::load('logbook.views.ManageGroupAccess');
     if ($form->validate()) {
         $group_access_options = Application::param('group_access_options');
         $set_as_default = Application::param('set_as_default');
         $author_id = $this->entry_to_manage_for->get('author_id');
         $entry_id = $this->entry_to_manage_for->get('entry_id');
         if (is_object($this->group_to_manage_for)) {
             $group_id = $this->group_to_manage_for->id();
             ManageGroupAccess::setPermissionsOnEntryForGroup($author_id, $entry_id, $group_id, $group_access_options);
             if (Application::param('set_as_default')) {
                 $group = $this->group_to_manage_for->restrict();
                 $group->noForeign();
                 reset($group_access_options);
                 $data = serialize($group_access_options);
                 file_put_contents(Application::MANAGED_CODE . 'lbk_default_access_' . $group->get('access_id'), $data);
             }
         }
     }
     LogbookAccess::publishLookupTables();
     $this->redirectOnSave();
 }
Example #15
0
	protected function blogEntries()
	{
            $entry = new Entry();
            $entry->clause('author_id',Application::param('author_id'));
	    $entry->order($this->order_by);
	    
	    if($this->descending)
	        $entry->descending();

	    $entry->maybe('Comment');

            try
            {
                $ret = $entry->page($this->page_num,$this->num_per_page);
            }
            
            catch(Exception $e)
            {
                $ret = false;
            }

	    return $ret;
	}
        protected function doEdit()
	{
	    $form = $this->editForm();

	    if($form->validate())
	    {
            $item = $this->entryToEdit();
            $test = $item->restrict();

	        if(LogbookAccess::currentUserCanEdit($test))
	        {
                $item = $this->entryToEdit();
    		    $item->parse();
    		    $item->synch();
    		    Entry::setTagsAndSave($item,Application::param('entry_tags'));
                Application::setParam('author_id',Application::param('author_id'));
                Application::setParam('entry_id',Application::param('entry_id'));
	        }
                
            LogbookAccess::publishLookupTables();
    		$this->redirectOnSave();
	    }
	}
 public function ajaxResponse()
 {
     $ret = false;
     if (Application::param('ajax') && !$this->ignore_ajax) {
         $ret = true;
     }
     return $ret;
 }
 /**
  * Collect does it's best to load objects from passed array or it's environment
  *
  * This method is useful to avoid writing out lots of clause statements. If 
  * called with no arguments, it tries to get it's primary keys from the argments
  * to the application, so if you had author_id and book_id in the $_GET super 
  * global, then you could do:
  *
  * <code>
  * $book = new Book();
  * $books = $book->collect();
  * </code>
  *
  * You can also pass variables to collect, although this behaviour is not yet
  * stable and should not be used. The only supported argument is a complete
  * key (see {@link completeKey()} for more details.)
  *
  * @param vars - not stable, do not use except with a complete key
  * @return array - an array of DbObjects
  * @access public
  * @see fetch,load,collectSingle
  */
 function collect($vars = '')
 {
     $keys = $this->primaryKeys();
     if (!$vars) {
         foreach ($keys as $key) {
             if ($val = Application::param($key->name())) {
                 if (is_array($val)) {
                     throw new Exception('You can\'t use arrays or objects as arguments to collect(). I found: ' . print_r($val) . ' in Application::param()');
                 }
                 $this->clauseSafe($key->name(), $val);
             }
         }
     } else {
         if (is_array($vars)) {
             $first = ArrayUtility::firstElement($keys);
             if ($val = ArrayUtility::getArrayValue($vars, $first->name())) {
                 foreach ($keys as $key) {
                     if ($val = ArrayUtility::getArrayValue($vars, $key->name())) {
                         if (is_array($val) && !is_object($val)) {
                             $type = Clause::IN;
                         } else {
                             $type = Clause::EQUALS;
                         }
                         $this->clauseSafe($key->name(), $val, $type);
                     }
                 }
             } else {
                 if (ArrayUtility::firstElement($vars)) {
                     foreach ($vars as $element) {
                         if (is_array($element)) {
                             $cur_clause = new Clause();
                             foreach ($keys as $key) {
                                 if (list($unused, $val) = each($element)) {
                                     $cur_clause->addConditionSafe($this->tableName() . '.' . $key->name(), $val);
                                 }
                             }
                             $this->subClause($cur_clause, Clause::OR_REL);
                         } else {
                             $key = ArrayUtility::firstElement($keys);
                             $this->clauseSafe($key->name(), $element, Clause::EQUALS, Clause::LAST, Clause::OR_REL);
                             while (list($unused, $element) = each($vars)) {
                                 $this->clauseSafe($key->name(), $element, Clause::EQUALS, Clause::LAST, Clause::OR_REL);
                             }
                         }
                     }
                 } else {
                     throw new Exception('You\'ve passed an array to the collect() method of: ' . $this->getClass() . ' that I can\'t do anything with. When you pass an array to collect() of a DbObject, it has to either be a key value pair array where the key is the name of at least one primary key field for the DbObject and the element is the desired value for that field, or it needs to be an array where each element is either a single key or an array of keys which are in the same order that they are in the database table. You gave me: ' . print_r($vars));
                 }
             }
         } else {
             $arr = $this->deCompleteKey($vars);
             foreach ($this->primaryKeys() as $key) {
                 if ($val = ArrayUtility::getArrayValue($arr, $key->name())) {
                     $this->clauseSafe($key->name(), $val);
                 }
             }
         }
     }
     if ($this->db_clause) {
         $ret = $this->fetch();
     } else {
         $ret = '';
     }
     return $ret;
 }
 protected function delete($object, $class, $type, $title)
 {
     $this->objects_to_delete = $object->collect(Application::param('objects'));
     $this->delete_class = $class;
     $this->delete_label = $title;
     $this->delete_command = 'done';
     $this->state = 'delete';
     if ($this->objects_to_delete) {
         foreach ($this->objects_to_delete as $obj) {
             $obj->deleteLater();
         }
         $obj->purge();
     } else {
         $this->state = 'main';
     }
 }
 public function dbTest()
 {
     $test = new DbTest(Application::param('package_name'));
     $test->run();
     return $test->passed();
 }
 function validate($value)
 {
     $ret = true;
     switch ($this->type) {
         case 'REQUIRED':
             if ($value || is_numeric($value)) {
                 $ret = true;
             } else {
                 $ret = false;
             }
             break;
         case 'NOT':
             if ($value) {
                 $match = preg_replace('/\\\\/', '\\\\', $this->value);
                 $ret = !preg_match('/' . $match . '/', $value);
             }
             break;
         case 'MATCH':
             if ($value) {
                 $match = preg_replace('/\\\\/', '\\\\', $this->value);
                 $ret = preg_match('/' . $match . '/', $value);
             }
             break;
         case 'GREATER':
             if ($value) {
                 if (is_numeric($value)) {
                     $ret = $value > $this->value;
                 } else {
                     $ret = false;
                 }
             } else {
                 $ret = false;
             }
             break;
         case 'LESS':
             if ($value) {
                 if (is_numeric($value)) {
                     $ret = $value < $this->value;
                 } else {
                     $ret = false;
                 }
             }
             break;
         case 'EQUALS':
             if ($value) {
                 if (is_numeric($value)) {
                     $ret = $value == $this->value;
                 } else {
                     $ret = false;
                 }
             }
             break;
         case 'NOT_EQUALS':
             if ($value) {
                 if (is_numeric($value)) {
                     $ret = $value != $this->value;
                 } else {
                     $ret = false;
                 }
             }
             break;
         case 'NUMBER':
             $ret = is_numeric($value);
             break;
         case 'EMAIL':
             if ($value) {
                 $ret = FormValidationRequirement::validateEmail($value);
             }
             break;
         case 'PASSWORD':
             if ($value) {
                 $confirm = Application::param($this->name . '_confirm');
                 $ret = $value == $confirm;
             }
             break;
         case 'DATE':
             if ($value) {
                 $ret = true;
             } else {
                 $ret = false;
             }
             break;
         case 'CUSTOM':
             $class = $this->value;
             $obj = new $class();
             $ret = $obj->validate($value);
             if (!$ret) {
                 $this->error_message = $obj->errorMessage();
             }
             break;
         default:
             throw new Exception('Unsupported validation type: ' . $this->type . ' passed to validate in FormValidationRequirement');
             break;
     }
     if (!$ret) {
         FormErrors::add($this->name, $this->error_message);
     }
     return $ret;
 }
 /**
  * Generate the output for this Application
  *
  * This method is called from the class returned by {@link Application::errorHandlerInit} 
  * and loads the necessary handler classes to produce required output.
  * @access public
  * @see index.php,Handler,ErrorHandler
  */
 public function run()
 {
     /*check for a functionid in the $_GET super global*/
     $this->handler_class = Application::param('h');
     if (!$this->handler_class) {
         if (defined(Application::domain())) {
             $this->handler_class = constant(Application::domain());
         }
         if (!$this->handler_class) {
             $this->handler_class = constant('DEFAULT_HANDLER');
         }
     }
     if ($this->authoriseUser($this->handler_class)) {
         $handler = $this->loadHandler($this->handler_class);
         if ($handler instanceof Handler) {
             $this->handler = $handler;
             /*execute the current function*/
             $handler->performHandlerTasks();
             $handler->display();
         } else {
             throw new Exception('The loadHandler function must return a class of type Handler. I got: ' . $handler->getClass());
         }
     } else {
         throw new AccessDeniedException('You do not have authority to access this function');
     }
 }
    protected function getParams()
    {
        // TOTO: Rewrite this as a select from a temporary table populated by a select on the ss_system_data table
        $key = Query::clean(Application::param('key'));
        $sql = <<<EOF

\t\t\tSELECT ss_system.key,
\t\t\tapi_key.value AS api_key,
\t\t\tmethod.value AS method,
\t\t\tuser_id.value AS user_id,
\t\t\tphotoset_id.value AS photoset_id,
\t\t\tdisplay.value AS display,
\t\t\ttags.value AS tags,
\t\t\ttag_mode.value AS tag_mode,
\t\t\tsort.value AS sort,
\t\t\textras.value AS extras,
\t\t\tper_page.value AS per_page,
\t\t\tformat.value AS format,
\t\t\twidth.value AS width,
\t\t\theight.value AS height,
\t\t\tfade_speed.value AS fade_speed,
\t\t\ttimeout_interval.value AS timeout_interval 
\t\t\tFROM ss_system 
\t\t\tJOIN ss_system_type ON ss_system.system_type_id=ss_system_type.system_type_id  
\t\t\tJOIN ss_system_data AS api_key ON api_key.key = 'api_key' AND ss_system.system_id=api_key.system_id 
\t\t\tJOIN ss_system_data AS method ON method.key='method'  AND ss_system.system_id=method.system_id 
\t\t\tJOIN ss_system_data AS user_id ON user_id.key='user_id'  AND ss_system.system_id=user_id.system_id 
\t\t\tJOIN ss_system_data AS photoset_id ON photoset_id.key='photoset_id'  AND ss_system.system_id=photoset_id.system_id 
\t\t\tJOIN ss_system_data AS display ON display.key='display'  AND ss_system.system_id= display.system_id 
\t\t\tJOIN ss_system_data AS tags ON tags.key='tags'  AND ss_system.system_id= tags.system_id 
\t\t\tJOIN ss_system_data AS tag_mode ON tag_mode.key='tag_mode'  AND ss_system.system_id= tag_mode.system_id 
\t\t\tJOIN ss_system_data AS sort ON sort.key='sort'  AND ss_system.system_id= sort.system_id 
\t\t\tJOIN ss_system_data AS extras ON extras.key='extras'  AND ss_system.system_id= extras.system_id 
\t\t\tJOIN ss_system_data AS per_page ON per_page.key='per_page'  AND ss_system.system_id= per_page.system_id 
\t\t\tJOIN ss_system_data AS format ON format.key='format'  AND ss_system.system_id= format.system_id 
\t\t\tJOIN ss_system_data AS width ON width.key='width'  AND ss_system.system_id= width.system_id 
\t\t\tJOIN ss_system_data AS height ON height.key='height' AND ss_system.system_id= height.system_id 
\t\t\tJOIN ss_system_data AS fade_speed ON fade_speed.key='fade_speed' AND ss_system.system_id= fade_speed.system_id 
\t\t\tJOIN ss_system_data AS timeout_interval ON timeout_interval.key='timeout_interval' AND ss_system.system_id= timeout_interval.system_id 
\t\t\tWHERE ss_system.key = '{$key}' LIMIT 0,1
EOF;
        //echo "<br />DEBUG \$sql == $sql<br />\n";
        $system_query = SimpleQuery::create($sql);
        // Set the params
        $params = array();
        //echo "<br />DEBUG api_key: ".$system_query->fieldValue('api_key')."<br />\n";
        if ($key = Query::clean(Application::param('key'))) {
            $params['key'] = $key;
        } else {
            $params['key'] = $system_query->fieldValue('key');
        }
        if ($api_key = Query::clean(Application::param('api_key'))) {
            $params['api_key'] = $api_key;
        } else {
            $params['api_key'] = $system_query->fieldValue('api_key');
        }
        if ($method = Query::clean(Application::param('method'))) {
            $params['method'] = $method;
        } else {
            $params['method'] = $system_query->fieldValue('method');
        }
        if ($user_id = Query::clean(Application::param('user_id'))) {
            $params['user_id'] = $user_id;
        } else {
            $params['user_id'] = $system_query->fieldValue('user_id');
        }
        if ($photoset_id = Query::clean(Application::param('photoset_id'))) {
            $params['photoset_id'] = $photoset_id;
        } else {
            $params['photoset_id'] = $system_query->fieldValue('photoset_id');
        }
        if ($display = Query::clean(Application::param('display'))) {
            $params['display'] = $display;
        } else {
            $params['display'] = $system_query->fieldValue('display');
        }
        if ($tags = Query::clean(Application::param('tags'))) {
            $params['tags'] = $tags;
        } else {
            $params['tags'] = $system_query->fieldValue('tags');
        }
        if ($tag_mode = Query::clean(Application::param('tag_mode'))) {
            $params['tag_mode'] = $tag_mode;
        } else {
            $params['tag_mode'] = $system_query->fieldValue('tag_mode');
        }
        if ($sort = Query::clean(Application::param('sort'))) {
            $params['sort'] = $sort;
        } else {
            $params['sort'] = $system_query->fieldValue('sort');
        }
        if ($extras = Query::clean(Application::param('extras'))) {
            $params['extras'] = $extras;
        } else {
            $params['extras'] = $system_query->fieldValue('extras');
        }
        if ($per_page = Query::clean(Application::param('per_page'))) {
            $params['per_page'] = $per_page;
        } else {
            $params['per_page'] = $system_query->fieldValue('per_page');
        }
        if ($format = Query::clean(Application::param('format'))) {
            $params['format'] = $format;
        } else {
            $params['format'] = $system_query->fieldValue('format');
        }
        if ($width = Query::clean(Application::param('width'))) {
            $params['width'] = $width;
        } else {
            $params['width'] = $system_query->fieldValue('width');
        }
        if ($height = Query::clean(Application::param('height'))) {
            $params['height'] = $height;
        } else {
            $params['height'] = $system_query->fieldValue('height');
        }
        if ($fade_speed = Query::clean(Application::param('fade_speed'))) {
            $params['fade_speed'] = $fade_speed;
        } else {
            $params['fade_speed'] = $system_query->fieldValue('fade_speed');
        }
        if ($timeout_interval = Query::clean(Application::param('timeout_interval'))) {
            $params['timeout_interval'] = $timeout_interval;
        } else {
            $params['timeout_interval'] = $system_query->fieldValue('timeout_interval');
        }
        return $params;
    }
 public function redirectOnAccessDenied()
 {
     Application::setParam('author_id', Logbook::current()->authorId());
     Application::setParam('entry_id', Application::param('entry_id'));
     Application::redirect(Application::defaultHandler());
 }
 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();
 }