Ejemplo n.º 1
0
 /**
  * init
  */
 public function init()
 {
     $ff = \Form\Factory::getInstance();
     $arr = $this->getConfig()->exportFormArray();
     $this->form = $ff->createForm('Settings', $arr);
     $se = new SettingsSaveEvent('update', 'icon-arrow-left icon-white');
     $this->form->attach($se->setRedirectUrl(\Tk\Url::createHomeUrl('/index.html')), 'update');
     $se = new SettingsSaveEvent('save');
     $this->form->attach($se->setRedirectUrl(\Tk\Request::getInstance()->getRequestUri()), 'save');
     $this->form->attach($ff->createEventLink('cancel'), 'cancel')->setRedirectUrl(\Tk\Url::createHomeUrl('/index.html'));
     // Site
     $this->form->addField($ff->createFieldText('system-site-title'))->setTabGroup('Site')->setRequired()->setLabel('Site Title');
     $this->form->addField($ff->createFieldText('system-site-email'))->setTabGroup('Site')->setLabel('Site Email')->setRequired()->setNotes('This email is used for site notifications like user sign-up, contact forms, etc.');
     $this->form->addField($ff->createFieldText('system-site-email-support'))->setTabGroup('Site')->setLabel('Support Email')->setRequired()->setNotes('This email is used for any site support forms or errors that are generated.');
     $this->form->addField($ff->createFieldText('system-site-email-dev'))->setTabGroup('Site')->setLabel('Developer Email')->setRequired()->setNotes('This email is used for any site error emails and notifications to developers.');
     $this->form->addField($ff->createFieldText('system-google-apikey'))->setTabGroup('Site')->setRequired()->setLabel('Google API Key');
     $this->form->addField($ff->createFieldTimezoneSelect('system-timezone'))->setTabGroup('Site')->setRequired()->prependOption('-- Select --', '')->setLabel('Timezone');
     $this->form->addField($ff->createFieldText('system-site-proxy'))->setTabGroup('Site')->setLabel('Site Proxy')->setNotes('Only set this if you require a proxy to access the outside network.');
     $this->form->addField($ff->createFieldCheckbox('system-enableSsl'))->setTabGroup('Site')->setLabel('Enable SSL')->setNotes('Only check this option if you have a valid SSL cert installed.');
     // Maintenance
     $this->form->addField($ff->createFieldCheckbox('system-maintenance-enable'))->setTabGroup('Maintenance')->setLabel('Enable')->setNotes('If enabled, the site is disabled with only the access given to those below.');
     $this->form->addField($ff->createFieldTextarea('system-maintenance-message'))->addStyle('width', '600px')->addStyle('height', '100px')->setTabGroup('Maintenance')->setLabel('Message')->setNotes('Enter the message (HTML) that will be displayed when in maintenance mode.');
     $this->form->addField($ff->createFieldText('system-maintenance-access-ip'))->setTabGroup('Maintenance')->setLabel('IP Access')->setNotes('Enter a comma separated list of allowable IP addresses in maintenance mode');
     $list = array(array('Admin', \Tk\Auth\Auth::P_ADMIN), array('User', \Tk\Auth\Auth::P_USER));
     $this->form->addField($ff->createFieldCheckbox('system-maintenance-access-permission', $list))->setTabGroup('Maintenance')->setLabel('Permission Access')->setNotes('Select user permissions allowed to access the site in maintenance mode');
     $this->addChild($ff->createFormRenderer($this->form), $this->form->getId());
 }
Ejemplo n.º 2
0
 /**
  *
  *
  * @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;
 }
Ejemplo n.º 3
0
 /**
  * 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());
 }
Ejemplo n.º 4
0
 /**
  * init
  */
 public function init()
 {
     $fac = $this->getConfig()->getPluginFactory();
     $this->plugin = $fac->getPlugin($this->getNamespace());
     $arr = $this->plugin->getDataArray()->exportFormArray();
     $backUrl = \Tk\Url::createHomeUrl('/plugin/manager.html');
     $ff = \Form\Factory::getInstance();
     $this->form = $ff->createForm('Config', $arr);
     $this->form->attach(new Save('update'))->setRedirectUrl($backUrl);
     $this->form->attach($ff->createEventLink('cancel'), 'cancel')->setRedirectUrl($backUrl);
     $courseList = \Ext\Db\Course::findAll(\Tk\Db\Tool::create('`name`'));
     $this->form->addField($ff->createFieldDualSelect('coa-course-enable', $courseList))->setLabel('Enable Courses')->setRequired();
     $this->addChild($ff->createFormRenderer($this->form), $this->form->getId());
 }
Ejemplo n.º 5
0
    /**
     *
     * 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;
    }
Ejemplo n.º 6
0
 /**
  * init
  */
 public function init()
 {
     $this->tool = $this->getConfig()->getLtiToolProvider();
     // Create Table structure
     $ff = \Form\Factory::getInstance();
     $tf = \Table\Factory::getInstance();
     $this->table = $tf->createTable('Manager');
     $this->table->addCell(Checkbox::create());
     $this->table->addCell(NameCell::create('name'))->setKey()->setUrl(\Tk\Url::createHomeUrl('/consumer/edit.html'));
     $this->table->addCell(KeyCell::create('key'));
     $this->table->addCell($tf->createCellString('secret'));
     //$this->table->addCell($tf->createCellString('consumer_version'))->setLabel('Version');
     $this->table->addCell($tf->createCellBoolean('enabled'));
     $this->table->addCell($tf->createCellBoolean('protected'));
     $this->table->addCell(DateCell::create('updated'));
     $this->table->addCell(DateCell::create('created'));
     $this->table->addAction(DeleteAction::create());
     $this->addChild($tf->createTableRenderer($this->table), 'Manager');
 }
Ejemplo n.º 7
0
 /**
  * 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;
 }
Ejemplo n.º 8
0
    /**
     * 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;
    }
Ejemplo n.º 9
0
 /**
  * @return \Tk\Url
  */
 public function getPdfBgImageUrl()
 {
     return \Tk\Url::createDataUrl($this->pdfBgImage);
 }
Ejemplo n.º 10
0
 /**
  * @param \Ext\Module\Company\Manager  $obj
  */
 public function update($obj)
 {
     $obj->getPage()->getActionPanel()->addItem(\Mod\Menu\Item::create('Certificates', \Tk\Url::createHomeUrl('/term/coa/send.html'), 'fa fa-certificate'));
 }