/** * Check that form ID exists * * @return object */ public function assertExistentForm() { $pdf = new PdfForm($this->assertFormId()); if (!$pdf->isStored()) { App::abort(404, Lang::txt('COM_COURSES_ERROR_UNKNOWN_IDENTIFIER')); } return $pdf; }
echo Lang::txt('COM_COURSES_HEADER_TITLE'); ?> </th> <th><?php echo Lang::txt('COM_COURSES_HEADER_CREATED'); ?> </th> <th><?php echo Lang::txt('COM_COURSES_HEADER_UPDATED'); ?> </th> </tr> </thead> <tbody> <?php foreach (\Components\Courses\Models\PdfForm::getActiveList() as $form) { ?> <tr> <td> <span class="title"><?php echo $form['title']; ?> </span> <form action="<?php echo Route::url('index.php?option=com_courses&controller=form'); ?> " method="get"> <input type="hidden" name="task" value="deploy" /> <input type="hidden" name="formId" value="<?php echo $form['id']; ?>
/** * Preview method for this handler * * @param object $asset - asset * @return array((string) type, (string) text) **/ public function preview($asset) { // Get form object require_once dirname(__DIR__) . DS . 'form.php'; $form = PdfForm::loadByAssetId($asset->get('id')); // Make sure we got a proper object if (!is_object($form)) { return array('error' => "Asset " . $asset->get('id') . " is not associated with a valid form."); } $gid = Request::getVar('course_id'); $oid = Request::getVar('offering'); // Compile our return var $js = "// Open up forms in a lightbox\n\t\t\t\$.fancybox({\n\t\t\t\tfitToView: false,\n\t\t\t\tautoResize: false,\n\t\t\t\tautoSize: false,\n\t\t\t\theight: (\$(window).height())*2/3,\n\t\t\t\tcloseBtn: false,\n\t\t\t\tmodal: true,\n\t\t\t\ttype: 'iframe',\n\t\t\t\thref: '/courses/" . $gid . "/" . $oid . "/form.layout?formId=" . $form->getId() . "&readonly=1&tmpl=component',\n\t\t\t\tafterShow: function() {\n\t\t\t\t\tvar frameContents = \$('.fancybox-iframe').contents();\n\n\t\t\t\t\tvar navHeight = frameContents.find('.navbar').height();\n\t\t\t\t\tframeContents.find('.main.section.courses-form').css('margin-bottom', navHeight);\n\n\t\t\t\t\t// Highjack the 'done' button to close the iframe\n\t\t\t\t\tframeContents.find('#done').bind('click', function(e) {\n\t\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t\t\$.fancybox.close();\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});"; return array('type' => 'js', 'value' => $js); }
/** * Copy an entry and associated data * * @param bool $forms whether or not to duplicate forms as well * @return bool */ public function copy($forms = true) { // Keep track of the original id $originalId = $this->get('id'); // Reset the ID. This will force store() to create a new record. $this->set('id', 0); if (!$this->store()) { return false; } // If this is a form... if ($forms && $this->get('type') == 'form') { require_once __DIR__ . DS . 'form.php'; require_once __DIR__ . DS . 'formDeployment.php'; require_once __DIR__ . DS . 'formRespondent.php'; // Copy the form as well...look up by asset_id if ($form = PdfForm::loadByAssetId($originalId)) { // This will either return the form id or the deployment crumb $identifier = $form->copy(); $form->setAssetId($this->get('id')); $this->set('url', $identifier); $this->store(); } } return true; }