public function testChainability()
 {
     $params = array('hi' => 'yo');
     $this->tpl->setParams($params)->setStatus(Http::STATUS_NOT_FOUND);
     $this->assertEquals(Http::STATUS_NOT_FOUND, $this->tpl->getStatus());
     $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams());
 }
Esempio n. 2
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     if (defined('DEBUG') && DEBUG) {
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular');
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular-route');
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular-animate');
         \OCP\Util::addScript('tasks', 'vendor/momentjs/moment');
         \OCP\Util::addScript('tasks', 'vendor/bootstrap/ui-bootstrap-custom-tpls-0.10.0');
     } else {
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular.min');
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular-route.min');
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular-animate.min');
         \OCP\Util::addScript('tasks', 'vendor/momentjs/moment.min');
         \OCP\Util::addScript('tasks', 'vendor/bootstrap/ui-bootstrap-custom-tpls-0.10.0.min');
     }
     \OCP\Util::addScript('tasks', 'public/app');
     \OCP\Util::addScript('tasks', 'vendor/appframework/app');
     \OCP\Util::addScript('tasks', 'vendor/timepicker/jquery.ui.timepicker');
     \OCP\Util::addStyle('tasks', 'style');
     \OCP\Util::addStyle('tasks', 'vendor/bootstrap/bootstrap');
     $date = new \DateTimeZone(\OC_Calendar_App::getTimezone());
     $day = new \DateTime('today', $date);
     $day = $day->format('d');
     // TODO: Make a HTMLTemplateResponse class
     $response = new TemplateResponse('tasks', 'main');
     $response->setParams(array('DOM' => $day));
     return $response;
 }
Esempio n. 3
0
	/**
	 * @NoAdminRequired
	 * @NoCSRFRequired
	 */
	public function index() {
		\OC::$server->getNavigationManager()->setActiveEntry($this->appName);

		$importManager = new ImportManager();
		$imppTypes = Properties::getTypesForProperty('IMPP');
		$adrTypes = Properties::getTypesForProperty('ADR');
		$phoneTypes = Properties::getTypesForProperty('TEL');
		$emailTypes = Properties::getTypesForProperty('EMAIL');
		$ims = Properties::getIMOptions();
		$imProtocols = array();
		foreach($ims as $name => $values) {
			$imProtocols[$name] = $values['displayname'];
		}

		$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');

		$response = new TemplateResponse($this->appName, 'contacts');
		$response->setParams(array(
			'uploadMaxFilesize' => $maxUploadFilesize,
			'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
			'phoneTypes' => $phoneTypes,
			'emailTypes' => $emailTypes,
			'adrTypes' => $adrTypes,
			'imppTypes' => $imppTypes,
			'imProtocols' => $imProtocols,
			'importManager' => $importManager,
		));

		return $response;
	}
Esempio n. 4
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     \OCP\Util::addscript('core', 'tags');
     \OCP\Util::addStyle($this->appName, 'style');
     \OCP\Util::addStyle($this->appName, 'jquery.Jcrop');
     \OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/animation');
     \OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/fontello');
     \OCP\Util::addStyle($this->appName, '3rdparty/jquery.webui-popover');
     \OCP\Util::addscript($this->appName, 'app');
     \OCP\Util::addscript($this->appName, '3rdparty/jquery.webui-popover');
     \OCP\Util::addscript($this->appName, 'settings');
     \OCP\Util::addscript($this->appName, 'loader');
     \OCP\Util::addscript($this->appName, 'jquery.scrollTo.min');
     \OCP\Util::addscript($this->appName, 'jquery.nicescroll.min');
     \OCP\Util::addscript('files', 'jquery.fileupload');
     \OCP\Util::addscript($this->appName, 'jquery.Jcrop');
     $iosSupport = $this->configInfo->getUserValue($this->userId, $this->appName, 'iossupport');
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $addressbooks = Addressbook::all($this->userId);
     if (count($addressbooks) == 0) {
         Addressbook::addDefault($this->userId);
         $addressbooks = Addressbook::all($this->userId);
     }
     //ContactsApp::addingDummyContacts(50);
     $params = ['uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'iossupport' => $iosSupport, 'addressbooks' => $addressbooks];
     $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedImageDomain('*');
     $csp->addAllowedFrameDomain('*');
     $response = new TemplateResponse($this->appName, 'index');
     $response->setContentSecurityPolicy($csp);
     $response->setParams($params);
     return $response;
 }
Esempio n. 5
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     if (\OC::$server->getAppManager()->isEnabledForUser('calendarplus')) {
         $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
         $csp->addAllowedImageDomain(':data');
         $config = \OC::$server->getConfig();
         $response = new TemplateResponse($this->appName, 'index');
         $response->setParams(array('allowShareWithLink' => $config->getAppValue('core', 'shareapi_allow_links', 'yes'), 'mailNotificationEnabled' => $config->getAppValue('core', 'shareapi_allow_mail_notification', 'no'), 'mailPublicNotificationEnabled' => $config->getAppValue('core', 'shareapi_allow_public_notification', 'no'), 'appname' => TasksApp::$appname, 'calappname' => CalendarApp::$appname));
         $response->setContentSecurityPolicy($csp);
     } else {
         \OCP\Util::addStyle($this->appName, 'style');
         $response = new TemplateResponse($this->appName, 'no-calendar-app');
     }
     return $response;
 }
Esempio n. 6
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     $iosSupport = $this->configInfo->getUserValue($this->userId, $this->appName, 'iossupport');
     $activeView = $this->configInfo->getUserValue($this->userId, $this->appName, 'view', 'listview');
     $lastSelectedBook = $this->configInfo->getUserValue($this->userId, $this->appName, 'currentbook', 0);
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $addressbooks = Addressbook::all($this->userId);
     if (count($addressbooks) == 0) {
         Addressbook::addDefault($this->userId);
         $addressbooks = Addressbook::all($this->userId);
     }
     //ContactsApp::addingDummyContacts(1000);
     $params = ['uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'iossupport' => $iosSupport, 'addressbooks' => $addressbooks, 'activeView' => $activeView, 'lastSelectedBook' => $lastSelectedBook];
     $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedImageDomain('*');
     $csp->addAllowedFrameDomain('*');
     $response = new TemplateResponse($this->appName, 'index');
     $response->setContentSecurityPolicy($csp);
     $response->setParams($params);
     return $response;
 }
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     $imppTypes = Properties::getTypesForProperty('IMPP');
     $adrTypes = Properties::getTypesForProperty('ADR');
     $phoneTypes = Properties::getTypesForProperty('TEL');
     $emailTypes = Properties::getTypesForProperty('EMAIL');
     $cloudTypes = Properties::getTypesForProperty('CLOUD');
     $ims = Properties::getIMOptions();
     $imProtocols = array();
     foreach ($ims as $name => $values) {
         $imProtocols[$name] = $values['displayname'];
     }
     $maxUploadFilesize = $this->utilFactory->maxUploadFilesize('/');
     \OCP\Util::addScript('placeholder', null);
     \OCP\Util::addScript('../vendor/blueimp-md5/js/md5', null);
     \OCP\Util::addScript('jquery.avatar', null);
     \OCP\Util::addScript('avatar', null);
     $response = new TemplateResponse($this->appName, 'contacts');
     $response->setParams(['uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => $this->utilFactory->humanFileSize($maxUploadFilesize), 'phoneTypes' => $phoneTypes, 'emailTypes' => $emailTypes, 'cloudTypes' => $cloudTypes, 'adrTypes' => $adrTypes, 'imppTypes' => $imppTypes, 'imProtocols' => $imProtocols, 'importManager' => $this->importManager]);
     return $response;
 }
Esempio n. 8
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     \OC::$server->getNavigationManager()->setActiveEntry($this->appName);
     $importManager = new ImportManager();
     $imppTypes = Properties::getTypesForProperty('IMPP');
     $adrTypes = Properties::getTypesForProperty('ADR');
     $phoneTypes = Properties::getTypesForProperty('TEL');
     $emailTypes = Properties::getTypesForProperty('EMAIL');
     $ims = Properties::getIMOptions();
     $imProtocols = array();
     foreach ($ims as $name => $values) {
         $imProtocols[$name] = $values['displayname'];
     }
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     \OCP\Util::addScript('', 'jquery.multiselect');
     \OCP\Util::addScript('', 'tags');
     \OCP\Util::addScript('placeholder');
     \OCP\Util::addScript('3rdparty', 'md5/md5.min');
     \OCP\Util::addScript('jquery.avatar');
     \OCP\Util::addScript('avatar');
     \OCP\Util::addScript('contacts', 'jquery.combobox');
     \OCP\Util::addScript('contacts', 'modernizr.custom');
     \OCP\Util::addScript('contacts', 'app');
     \OCP\Util::addScript('contacts', 'addressbooks');
     \OCP\Util::addScript('contacts', 'contacts');
     \OCP\Util::addScript('contacts', 'storage');
     \OCP\Util::addScript('contacts', 'groups');
     \OCP\Util::addScript('contacts', 'jquery.ocaddnew');
     \OCP\Util::addScript('contacts', 'otherbackendconfig');
     \OCP\Util::addScript('files', 'jquery.fileupload');
     \OCP\Util::addScript('3rdparty/Jcrop', 'jquery.Jcrop');
     \OCP\Util::addStyle('', 'jquery.multiselect');
     \OCP\Util::addStyle('contacts', 'jquery.combobox');
     \OCP\Util::addStyle('contacts', 'jquery.ocaddnew');
     \OCP\Util::addStyle('3rdparty/Jcrop', 'jquery.Jcrop');
     \OCP\Util::addStyle('contacts', 'contacts');
     $response = new TemplateResponse($this->appName, 'contacts');
     $response->setParams(array('uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'phoneTypes' => $phoneTypes, 'emailTypes' => $emailTypes, 'adrTypes' => $adrTypes, 'imppTypes' => $imppTypes, 'imProtocols' => $imProtocols, 'importManager' => $importManager));
     return $response;
 }
Esempio n. 9
0
 /**
  * Shortcut for rendering a template
  * @deprecated 7.0.0 return a template response instead
  * @param string $templateName the name of the template
  * @param array $params the template parameters in key => value structure
  * @param string $renderAs user renders a full page, blank only your template
  *                          admin an entry in the admin settings
  * @param string[] $headers set additional headers in name/value pairs
  * @return \OCP\AppFramework\Http\TemplateResponse containing the page
  * @since 6.0.0
  */
 public function render($templateName, array $params = array(), $renderAs = 'user', array $headers = array())
 {
     $response = new TemplateResponse($this->appName, $templateName);
     $response->setParams($params);
     $response->renderAs($renderAs);
     foreach ($headers as $name => $value) {
         $response->addHeader($name, $value);
     }
     return $response;
 }
Esempio n. 10
0
 public function testIndex()
 {
     $expected = new TemplateResponse($this->appName, 'contacts');
     $expected->setParams(['uploadMaxFilesize' => null, 'uploadMaxHumanFilesize' => null, 'phoneTypes' => ['HOME' => 'Home', 'CELL' => 'Mobile', 'WORK' => 'Work', 'TEXT' => 'Text', 'VOICE' => 'Voice', 'MSG' => 'Message', 'FAX' => 'Fax', 'VIDEO' => 'Video', 'PAGER' => 'Pager', 'OTHER' => 'Other'], 'emailTypes' => ['WORK' => 'Work', 'HOME' => 'Home', 'INTERNET' => 'Internet', 'OTHER' => 'Other'], 'adrTypes' => ['WORK' => 'Work', 'HOME' => 'Home', 'OTHER' => 'Other'], 'imppTypes' => ['WORK' => 'Work', 'HOME' => 'Home', 'OTHER' => 'Other'], 'imProtocols' => ['jabber' => 'Jabber', 'sip' => 'Internet call', 'aim' => 'AIM', 'msn' => 'MSN', 'twitter' => 'Twitter', 'googletalk' => 'GoogleTalk', 'facebook' => 'Facebook', 'xmpp' => 'XMPP', 'icq' => 'ICQ', 'yahoo' => 'Yahoo', 'skype' => 'Skype', 'qq' => 'QQ', 'gadugadu' => 'GaduGadu', 'owncloud-handle' => 'ownCloud'], 'importManager' => $this->importManager, 'cloudTypes' => ['HOME' => 'Home', 'WORK' => 'Work', 'OTHER' => 'Other']]);
     $this->assertEquals($expected, $this->controller->index());
 }
Esempio n. 11
0
 /**
  * If an AmpacheException is being caught, the appropiate ampache
  * exception response is rendered
  * @param Controller $controller the controller that is being called
  * @param string $methodName the name of the method that will be called on
  *                           the controller
  * @param \Exception $exception the thrown exception
  * @throws \Exception the passed in exception if it cant handle it
  * @return Response a Response object or null in case that the exception could not be handled
  */
 public function afterException($controller, $methodName, \Exception $exception)
 {
     if ($exception instanceof AmpacheException && $this->isAmpacheCall) {
         $response = new TemplateResponse($this->appname, 'ampache/error');
         $response->renderAs('blank');
         $response->addHeader('Content-Type', 'text/xml; charset=UTF-8');
         $response->setParams(array('code' => $exception->getCode(), 'message' => $exception->getMessage()));
         return $response;
     }
     throw $exception;
 }