/** * * * @param \LTI_Tool_Provider $toolProvider * @return bool|string */ public function doLaunch($toolProvider) { tklog('---> doLaunch() '); // Check the user has an appropriate role if ($toolProvider->user->isLearner() || $toolProvider->user->isStaff() || $toolProvider->user->isAdmin()) { // Initialise the user/Lti session $permissions = array(); if ($toolProvider->user->isLearner()) { $permissions[] = 'student'; } if ($toolProvider->user->isStaff()) { $permissions[] = 'staff'; } if ($toolProvider->user->isAdmin()) { $permissions[] = 'admin'; } $ldapUser = null; if (isset($_POST['lis_person_contact_email_primary'])) { // Enable if using LDAP for extra data // $ldapUser = $this->getLdapUser($_POST['lis_person_contact_email_primary']); } $data = array('consumerKey' => $toolProvider->consumer->getKey(), 'resourceId' => $toolProvider->resource_link->getId(), 'userConsumerKey' => $toolProvider->user->getResourceLink()->getConsumer()->getKey(), 'userId' => $toolProvider->user->getId(), 'permissions' => $permissions, 'ldapUser' => $ldapUser, 'launchRequest' => array_merge($_POST, $_GET)); \Ext\LtiSession::getInstance($data); \Tk\Url::create('/lti/index.html')->redirect(); } $toolProvider->reason = 'Invalid role.'; return false; }
/** * init */ public function init() { $ff = \Form\Factory::getInstance(); $this->form = $ff->createForm('Contact'); $this->form->attach(new Send('send'), 'send')->setRedirectUrl(\Tk\Url::create('/contactUs.html')); $this->form->attach($ff->createEventLink('cancel'), 'cancel')->setRedirectUrl(\Tk\Url::create('/index.html')); $this->form->addField($ff->createFieldText('name'))->setRequired(); $this->form->addField($ff->createFieldText('email'))->setRequired(); $this->form->addField($ff->createFieldTextarea('comments'))->setRequired(); $this->form->addField($ff->createFieldCaptcha('valid'))->setRequired(); $this->addChild($ff->createFormRenderer($this->form), $this->form->getId()); }
/** * * show */ public function render() { $template = $this->getTemplate(); $template->setTitleText($this->getConfig()->getSiteTitle() . ' - ' . $template->getTitleText()); $template->insertText('__pageTitle__', $this->getTitle()); $template->insertText('__siteTitle__', $this->getConfig()->getSiteTitle()); $template->insertText('__version__', $this->getConfig()->get('system.site.version')); if ($this->getConfig()->getUser() && is_object($this->getConfig()->getUser())) { $template->insertText('__username__', $this->getConfig()->getUser()->username); $template->insertText('__public__', $this->getConfig()->getUser()->username); $template->setAttr('__home__', 'href', \Tk\Url::create($this->getConfig()->getUser()->getHomePath() . '/index.html')); $template->setChoice('__logged-in__'); } else { $template->setChoice('__logged-out__'); } $siteUrl = $this->getConfig()->getSiteUrl(); $tplUrl = $this->getConfig()->getSelectedThemeUrl(); $dataUrl = $this->getConfig()->getDataUrl(); // Deprecated, should not have public access to lib folder $libUrl = $this->getConfig()->getLibUrl(); // Show general javascripts and styles. $js = <<<JS // PROJECT CONSTANTS var config = { siteUrl : "{$siteUrl}", dataUrl : "{$dataUrl}", libUrl : "{$libUrl}", themeUrl : "{$tplUrl}" }; JS; $template->appendJs($js); $ret = parent::render(); if ($this->getConfig()->exists('system.releaseMode')) { $template->setChoice($this->getConfig()->get('system.releaseMode')); } // Any Page Debug Settings if ($this->getConfig()->isDebug() && !$this->getConfig()->isLive()) { $template->setTitleText('DBG - ' . $template->getTitleText()); if ($this->getConfig()->isDev()) { $template->setTitleText('DEV - ' . $template->getTitleText()); } else { if ($this->getConfig()->isTest()) { $template->setTitleText('TEST - ' . $template->getTitleText()); } } } return $ret; }
/** * iterate * * @param array $list * @param integer $nest * @return Dom\Template */ protected function iterate($list, $nest = 0) { if ($this->maxDepth > 0 && $nest >= $this->maxDepth) { return; } $ul = $this->getTemplate()->getRepeat('ul'); /* @var $item \Mod\Menu\Item */ foreach ($list as $item) { $request = $this->getRequest()->getRequestUri(); $url = \Tk\Url::create($item->url); $li = $ul->getRepeat('li'); if ($item->findByHref($request, true)) { //$li->addClass('li', 'active'); } if ($item->title) { $li->setAttr('a', 'title', $item->title); } if ($item->target) { $li->setAttr('a', 'target', $item->target); } if ($item->rel) { $li->setAttr('a', 'rel', $item->rel); } if ($item->cssClass) { $li->addClass('a', $item->cssClass); } if ($item->icon) { $li->addClass('icon', $item->icon); $li->setChoice('icon'); } $li->insertText('a-text', $item->text); $li->setAttr('a', 'href', $url->toString()); // if ($item->hasChildren()) { // $li->addClass('li', 'parent'); // $ul2 = $this->iterate($item->children, $nest++); // $li->appendTemplate('li', $ul2); // } $li->appendRepeat(); } return $ul; }
/** * Background image Size: 1343x929 (Aspect ratio: 1.45:1) * * * @param \stdClass $obj * @param string $dateFrom * @param string $dateTo * @param string $bgImage * @param string $tpl * @param string $paperSize * @param string $paperOrientation * @return Dompdf */ protected function makeCert($obj, $dateFrom = '', $dateTo = '', $bgImage = '', $tpl = '', $paperSize = 'A4', $paperOrientation = 'landscape') { $now = \Tk\Date::create(); if (!$dateFrom) { $dateFrom = \Tk\Date::create($now->getYear() . '-01-01')->floor()->toString(\Tk\Date::LONG_DATE); } if (!$dateTo) { $dateTo = \Tk\Date::create($now->getYear() . '-12-31')->ceil()->toString(\Tk\Date::LONG_DATE); } if (!$bgImage) { $bgImage = \Tk\Url::create('/data/pdfTestBg.png')->toString(); } if (!$tpl) { $tpl = '<div class="content"> <p class="med">Certificate of Appreciation</p> <p class="med">The Faculty of Veterinary Science gratefully acknowledges the support of</p> <p class="lg bld">{name}</p> <p class="med">for mentoring and training veterinary students from</p> <p class="med">The University of Melbourne</p> <p class="med">{dateFrom} - {dateTo}</p> </div>'; } // Format content template $tpl = str_replace('{name}', $obj->name, $tpl); $tpl = str_replace('{date}', $now->format(\Tk\Date::LONG_DATE), $tpl); $tpl = str_replace('{dateFrom}', $dateFrom, $tpl); $tpl = str_replace('{dateTo}', $dateTo, $tpl); $tpl = str_replace('{year}', $now->toString('Y'), $tpl); $tpl = str_replace('{totalUnits}', $obj->totalUnits, $tpl); $tpl = str_replace('{totalPlaces}', $obj->totalPlaces, $tpl); $html = <<<ENDHTML <html> <head> <title>Test HTML2PDF</title> <style> @page { margin: 0px; } body { font-family: sans-serif; font-size: 10pt; margin: 0px; } div.cert { width: 1122px; position: absolute; top: 0; left: 0; } div.cert img { width: 100%; } div.content { position: absolute; top: {$this->setup->pdfTopMargin}px; left: 0; line-height: 1.2em; text-align: center; } .lg { font-size: 20pt; } .med { font-size: 16pt; } .sml { font-size: 8pt } .bld { font-weight: bold; } </style> </head> <body> <div class="cert"> <img src="{$bgImage}" alt="" /> </div> {$tpl} </body> </html> ENDHTML; set_time_limit(300); ini_set('memory_limit', '-1'); $dompdf = new Dompdf(array('enable_remote' => true)); $dompdf->setPaper($paperSize, $paperOrientation); $dompdf->loadHtml($html); $dompdf->render(); return $dompdf; }
/** * This is the path to the page that the administrator * can configure/manage the plugin. * * @return \Tk\Url */ public function getConfigUrl() { return \Tk\Url::create('/admin/plugin/coa/config.html'); }