Ejemplo n.º 1
0
             $sections[$section['metadata']['id']] = $section;
         }
         $section = array();
         $section['metadata']['id'] = $d['CourseID'];
         foreach ($d as $column => $value) {
             switch ($column) {
                 case 'ClassName':
                     $section['metadata']['name'] = DataUtilities::titleCase($value);
                     break;
                 case 'TeacherName':
                     $section['metadata']['teacher'] = $value;
                     break;
                 default:
                     if (preg_match('/Book\\d+/', $column)) {
                         if (!empty($value)) {
                             $section['books'][] = DataUtilities::titleCase($value);
                         }
                     }
             }
         }
     }
     $section['students'][] = $d['StudentName'];
 }
 if (!empty($section['metadata']['id'])) {
     $sections[$section['metadata']['id']] = $section;
 }
 $smarty->assign('teacherDeadline', date('l, F j', strtotime($_REQUEST['teacher-deadline'])));
 $smarty->assign('deptDeadline', date('l, F j', strtotime($_REQUEST['dept-deadline'])));
 $smarty->assign('blanks', isset($_REQUEST['blanks']) ? $_REQUEST['blanks'] : 0);
 $smarty->assign('sections', $sections);
 $smarty->display('book-list/sheet.tpl');
Ejemplo n.º 2
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/constants.inc.php';
use smtech\CanvasManagement\Toolbox;
use smtech\ReflexiveCanvasLTI\LTI\ToolProvider;
use Battis\DataUtilities;
@session_start();
// TODO suppressing warnings is wrong
/* prepare the toolbox */
if (empty($_SESSION[Toolbox::class])) {
    $_SESSION[Toolbox::class] = Toolbox::fromConfiguration(CONFIG_FILE);
}
$toolbox =& $_SESSION[Toolbox::class];
/* set the Tool Consumer's instance URL, if present */
if (empty($_SESSION[CANVAS_INSTANCE_URL])) {
    if (!empty($_SESSION[ToolProvider::class]['canvas']['api_domain'])) {
        $_SESSION[CANVAS_INSTANCE_URL] = 'https://' . $_SESSION[ToolProvider::class]['canvas']['api_domain'];
    } else {
        $_SESSION[CANVAS_INSTANCE_URL] = $toolbox->config('TOOL_CANVAS_API')['url'];
    }
}
/* cache per-instance */
$toolbox->cache_pushKey(parse_url($_SESSION[CANVAS_INSTANCE_URL], PHP_URL_HOST));
/* Configure smarty templating */
/* FIXME this is sometimes superfluous overhead (e.g. action=config) */
$toolbox->smarty_prependTemplateDir(__DIR__ . '/templates', basename(__DIR__));
$toolbox->getSmarty()->addStylesheet(DataUtilities::URLfromPath(__DIR__ . '/css/canvas-management.css'), basename(__DIR__));
$toolbox->smarty_assign(['title' => $toolbox->config('TOOL_NAME'), 'category' => DataUtilities::titleCase(preg_replace('/[\\-_]+/', ' ', basename(__DIR__))), 'APP_URL' => $toolbox->config('APP_URL'), 'CANVAS_INSTANCE_URL' => $_SESSION[CANVAS_INSTANCE_URL], 'navbarActive' => basename(dirname($_SERVER['REQUEST_URI']))]);
Ejemplo n.º 3
0
 /**
  * Construct the singleton instance of BootstrapSmarty
  *
  * @deprecated Use singleton pattern BootstrapSmarty::getSmarty()
  *
  * @param string|string[] $template (Optional) Additional Smarty template
  *        directories
  * @param string|string[] $config (Optional) Additional Smarty config
  *        directories
  * @param string $compile (Optional) Alternative Smarty compiled template
  *        directory
  * @param string $cache (Optional) Alternative Smarty cache directory
  *
  * @return void
  *
  * @throws BootstrapSmarty_Exception SINGLETON If an instance of BootstrapSmarty already exists
  *
  * @see BootstrapSmarty::getSmarty() BootstrapSmarty::getSmarty()
  * @see http://www.phptherightway.com/pages/Design-Patterns.html#singleton Singleton Design Pattern
  **/
 public function __construct($template = null, $config = null, $compile = null, $cache = null)
 {
     if (static::$singleton !== null) {
         throw new BootstrapSmarty_Exception('BootstrapSmarty is a singleton class, use the factory method ' . 'BootstrapSmarty::getSmarty() instead of ' . __METHOD__, BootstrapSmarty_Exception::SINGLETON);
     } else {
         parent::__construct();
         static::$singleton = $this;
     }
     /* Default to local directories for use by Smarty */
     $this->setTemplateDir([static::UI_KEY => realpath(__DIR__ . '/../templates')]);
     $this->setConfigDir([static::UI_KEY => realpath(__DIR__ . '/../configs')]);
     /* Apply user additions and alternates */
     if (!empty($template)) {
         $this->prependTemplateDir($template);
     }
     if (!empty($config)) {
         $this->addConfigDir($config);
     }
     $this->setCompileDir(empty($compile) ? realpath(__DIR__ . '/../templates_c') : $compile);
     $this->setCacheDir(empty($cache) ? realpath(__DIR__ . '/../cache') : $cache);
     /* Test all directories for use by Smarty */
     foreach ($this->getTemplateDir() as $key => $dir) {
         static::testAccess($dir);
     }
     foreach ($this->getConfigDir() as $key => $dir) {
         static::testAccess($dir);
     }
     static::testAccess($this->getCompileDir(), true);
     static::testAccess($this->getCacheDir(), true);
     /* set some reasonable defaults */
     $this->url = DataUtilities::URLfromPath(dirname(__DIR__));
     $this->assign('BOOTSTRAPSMARTY_URL', $this->url);
     $this->addStylesheet("{$this->url}/css/BootstrapSmarty.css", static::UI_KEY);
     $this->assign(['name' => DataUtilities::titleCase(preg_replace('/[\\-_]+/', ' ', urldecode(basename($_SERVER['REQUEST_URI'], '.php')))), 'category' => DataUtilities::titleCase(preg_replace('/[\\-_]+/', ' ', urldecode(basename(dirname($_SERVER['REQUEST_URI']))))), 'navbarActive' => false, 'MODULE_COLORPICKER' => static::MODULE_COLORPICKER, 'MODULE_DATEPICKER' => static::MODULE_DATEPICKER, 'MODULE_SORTABLE' => static::MODULE_SORTABLE]);
 }
Ejemplo n.º 4
0
require_once __DIR__ . '/vendor/autoload.php';
use smtech\CanvasHack\Toolbox;
use smtech\ReflexiveCanvasLTI\LTI\ToolProvider;
use Battis\DataUtilities;
define('CONFIG_FILE', __DIR__ . '/config.xml');
define('CANVAS_INSTANCE_URL', 'canvasInstanceUrl');
@session_start();
// TODO I don't feel good about suppressing warnings
/* prepare the toolbox */
if (empty($_SESSION[Toolbox::class])) {
    $_SESSION[Toolbox::class] =& Toolbox::fromConfiguration(CONFIG_FILE);
}
$toolbox =& $_SESSION[Toolbox::class];
if (php_sapi_name() !== 'cli') {
    $toolbox->smarty_prependTemplateDir(__DIR__ . '/templates', basename(__DIR__));
    $toolbox->smarty_assign(['category' => DataUtilities::titleCase(preg_replace('/[\\-_]+/', ' ', basename(__DIR__)))]);
    $smarty =& $toolbox->getSmarty();
    // FIXME
}
/*
 * FIXME convience variables until plugins are all updated
 */
$api =& $toolbox->getAPI();
$sql =& $toolbox->getMySQL();
$customPrefs =& $toolbox->getCustomPrefs();
/* set the Tool Consumer's instance URL, if present */
if (empty($_SESSION[CANVAS_INSTANCE_URL])) {
    if (!empty($_SESSION[ToolProvider::class]['canvas']['api_domain'])) {
        $_SESSION[CANVAS_INSTANCE_URL] = 'https://' . $_SESSION[ToolProvider::class]['canvas']['api_domain'];
    } else {
        $_SESSION[CANVAS_INSTANCE_URL] = $toolbox->config('TOOL_CANVAS_API')['url'];
function titleCase($s)
{
    return DataUtilities::titleCase(str_replace('_', ' ', $s));
}