Skip to content

Commit

Permalink
spaces to tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardPosselt committed Dec 5, 2012
1 parent a902056 commit fbd7efa
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 41 deletions.
38 changes: 19 additions & 19 deletions apptemplate_advanced/controllers/index.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@ class IndexController extends Controller {
/**
* @param Request $request: an instance of the request
* @param API $api: an api wrapper instance
* @param ItemMapper $itemMapper: an itemwrapper instance
* @param ItemMapper $itemMapper: an itemwrapper instance
*/
public function __construct($api, $request, $itemMapper){
public function __construct($api, $request, $itemMapper){
parent::__construct($api, $request);

// this will set the current navigation entry of the app, use this only
// for normal HTML requests and not for AJAX requests
$this->api->activateNavigationEntry();

$this->itemMapper = $itemMapper;
$this->itemMapper = $itemMapper;
}


/**
* @brief renders the index page
* @param array $urlParams: an array with the values, which were matched in
* the routes file
* @return an instance of a Response implementation
* @return an instance of a Response implementation
*/
public function index($urlParams=array(), $container=null){
public function index($urlParams=array(), $container=null){

// thirdparty stuff
$this->api->add3rdPartyScript('angular/angular.min');
Expand All @@ -60,23 +60,23 @@ public function index($urlParams=array(), $container=null){

$this->api->addScript('app');

// example database access
// check if an entry with the current user is in the database, if not
// create a new entry
try {
$item = $this->itemMapper->findByUserId($this->api->getUserId());
} catch (DoesNotExistException $e) {
$item = new Item();
$item->setUser($this->api->getUserId());
$item->setPath('/home/path');
$item->setName('john');
$item = $this->itemMapper->save($item);
}
// example database access
// check if an entry with the current user is in the database, if not
// create a new entry
try {
$item = $this->itemMapper->findByUserId($this->api->getUserId());
} catch (DoesNotExistException $e) {
$item = new Item();
$item->setUser($this->api->getUserId());
$item->setPath('/home/path');
$item->setName('john');
$item = $this->itemMapper->save($item);
}

$templateName = 'main';
$params = array(
'somesetting' => $this->api->getSystemValue('somesetting'),
'item' => $item
'somesetting' => $this->api->getSystemValue('somesetting'),
'item' => $item
);
return $this->render($templateName, $params);
}
Expand Down
20 changes: 10 additions & 10 deletions apptemplate_advanced/lib/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,23 @@ public function setSystemValue($key, $value){
* @param $key the key under which the value is being stored
* @param $value the value that you want to store
*/
public function setUserValue($key, $value, $user=null){
if($user === null){
$user = $this->getUserId();
}
\OCP\Config::setUserValue($user, $this->appName, $key, $value);
public function setUserValue($key, $value, $user=null){
if($user === null){
$user = $this->getUserId();
}
\OCP\Config::setUserValue($user, $this->appName, $key, $value);
}


/**
* Shortcut for getting a user defined value
* @param $key the key under which the value is being stored
*/
public function getUserValue($key, $user=null){
if($user === null){
$user = $this->getUserId();
}
return \OCP\Config::getUserValue($user, $this->appName, $key);
public function getUserValue($key, $user=null){
if($user === null){
$user = $this->getUserId();
}
return \OCP\Config::getUserValue($user, $this->appName, $key);
}


Expand Down
23 changes: 11 additions & 12 deletions apptemplate_advanced/templates/main.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<div id="app"
ng-app="AppTemplateAdvanced"
ng-controller="ExampleController"
ng-init="name='<?php p($_['somesetting']) ?>'">
ng-app="AppTemplateAdvanced"
ng-controller="ExampleController"
ng-init="name='<?php p($_['somesetting']) ?>'">

<h1 class="heading">This is an advanced app template</h1>
<h1 class="heading">This is an advanced app template</h1>

<p ng-show="name">Welcome home {{name | leetIt}}!</p>
<p ng-show="name">Welcome home {{name | leetIt}}!</p>

<form class="centered">
My name is <input type="text" placeholder="anonymous" ng-model="name">
<button ng-click="saveName(name)">Remember my name</button>
</form>

<p>Your username is <?php p($_['item']->getUser()) ?></p>
<p>Your username entry was saved with the path <?php p($_['item']->getPath()) ?></p>
<form class="centered">
My name is <input type="text" placeholder="anonymous" ng-model="name">
<button ng-click="saveName(name)">Remember my name</button>
</form>

<p>Your username is <?php p($_['item']->getUser()) ?></p>
<p>Your username entry was saved with the path <?php p($_['item']->getPath()) ?></p>
</div>


Expand Down

0 comments on commit fbd7efa

Please sign in to comment.