/**
  * Function responsible to delete a template.
  *
  * @access public
  * @param string $templatename
  * @return void
  */
 public function delete($templatename)
 {
     if (!Permission::model()->hasGlobalPermission('templates', 'delete')) {
         die('No permission');
     }
     Yii::app()->loadHelper("admin/template");
     if (is_template_editable($templatename) == true) {
         $clang = $this->getController()->lang;
         if (rmdirr(Yii::app()->getConfig('usertemplaterootdir') . "/" . $templatename) == true) {
             $surveys = Survey::model()->findAllByAttributes(array('template' => $templatename));
             foreach ($surveys as $s) {
                 $s->template = Yii::app()->getConfig('defaulttemplate');
                 $s->save();
             }
             Template::model()->deleteAllByAttributes(array('folder' => $templatename));
             Permission::model()->deleteAllByAttributes(array('permission' => $templatename, 'entity' => 'template'));
             Yii::app()->setFlashMessage(sprintf($clang->gT("Template '%s' was successfully deleted."), $templatename));
         } else {
             Yii::app()->setFlashMessage(sprintf($clang->gT("There was a problem deleting the template '%s'. Please check your directory/file permissions."), $templatename), 'error');
         }
     }
     // Redirect with default templatename, editfile and screenname
     $this->getController()->redirect(array("admin/templates/sa/view"));
 }
            <?php } else {?>
                <input class="btn btn-success" type='button' value='<?php eT("Import") ?>' onclick='if (validatefilename(this.form,"<?php eT('Please select a file to import!', 'js') ?>")) { this.form.submit();}' />
            <?php }?>
            <button type="button" class="btn btn-default" data-dismiss="modal"><?php eT("Close");?></button>
          </div>
          </form>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
<?php endif;?>

<div class="col-lg-12 templateeditor">
    <h3><?php eT("Template editor:"); ?> <i><?php echo $templatename; ?></i></h3>


<?php if(!is_template_editable($templatename)):?>
    <div class="alert alert-info alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span >&times;</span></button>
        <span class="glyphicon glyphicon-info-sign" ></span>&nbsp;&nbsp;&nbsp;
        <strong>
            <?php eT('Note: This is a standard template.');?>
        </strong>
        <?php
            printf(gT('If you want to edit it %s please copy it first%s.'),"<a href='#' title=\"".gT("Copy Template")."\""
            ." onclick=\"javascript: copyprompt('".gT("Please enter the name for the copied template:")."', '".gT("copy_of_")."$templatename', '$templatename', 'copy')\">",'</a>');
        ?>
    </div>
<?php endif;?>


</div>
        ?>

                    <?php 
        echo CHtml::form(array('admin/templates/sa/uploadfile'), 'post', array('id' => 'importtemplatefile', 'name' => 'importtemplatefile', 'enctype' => 'multipart/form-data'));
        ?>
                    <?php 
        printf(gT("Upload a file (maximum size: %d MB):"), getMaximumFileUploadSize() / 1024 / 1024);
        ?>
                    <br>
                    <input name='upload_file' id="upload_file" type="file" required="required"/>
                    <input type='submit' value='<?php 
        eT("Upload");
        ?>
' class='btn btn-default'
                        <?php 
        if (!is_template_editable($templatename)) {
            ?>
                            disabled='disabled'
                            <?php 
        }
        ?>
                        />
                    <input type='hidden' name='editfile' value='<?php 
        echo $editfile;
        ?>
' />
                    <input type='hidden' name='screenname' value='<?php 
        echo HTMLEscape($screenname);
        ?>
' />
                    <input type='hidden' name='templatename' value='<?php 
Beispiel #4
0
 /**
  * Function responsible to delete a template.
  *
  * @access public
  * @param string $templatename
  * @return void
  */
 public function delete($templatename)
 {
     Yii::app()->loadHelper("admin/template");
     if (is_template_editable($templatename) == true) {
         $clang = $this->getController()->lang;
         if (rmdirr(Yii::app()->getConfig('usertemplaterootdir') . "/" . $templatename) == true) {
             $surveys = Survey::model()->findAllByAttributes(array('template' => $templatename));
             foreach ($surveys as $s) {
                 $s->template = Yii::app()->getConfig('defaulttemplate');
                 $s->save();
             }
             Template::model()->deleteAllByAttributes(array('folder' => $templatename));
             Templates_rights::model()->deleteAllByAttributes(array('folder' => $templatename));
             Yii::app()->session['flashmessage'] = sprintf($clang->gT("Template '%s' was successfully deleted."), $templatename);
         } else {
             Yii::app()->session['flashmessage'] = sprintf($clang->gT("There was a problem deleting the template '%s'. Please check your directory/file permissions."), $templatename);
         }
     }
     // Redirect with default templatename, editfile and screenname
     $this->getController()->redirect($this->getController()->createUrl("admin/templates/view"));
 }