Explorar el Código

change so templates are checked via contents not modified date

sirjeff hace 1 mes
padre
commit
aadd5fe1ff

+ 31 - 34
Controller/TemplateController.php

@@ -14,15 +14,11 @@ class TemplateController extends BaseController {
   * Show all the available templates.
   */
   public function show() {
-    $appTemplates = $this->getCoreTemplates();
-    $pluginTemplates = $this->getPluginTemplates();
-    
-    $templates = $this->getEditableTemplates();
-    
-    $missingTemplates = array_diff($appTemplates, $pluginTemplates);
-    $extraTemplates = array_diff($pluginTemplates, $appTemplates);
-    $modifiedStatus = $this->getModifiedStatus();
-    
+        $templates = $this->getEditableTemplates();
+        $missingTemplates = array_diff($this->getCoreTemplates(), $this->getPluginTemplates());
+        $extraTemplates = array_diff($this->getPluginTemplates(), $this->getCoreTemplates());
+        $modifiedStatus = $this->getModifiedStatus();
+
     $this->response->html($this->helper->layout->config("OMITemplateModder:config/index", [
       "title" => t("OMI - Notification Template Modder"),
       "templates" => $templates,
@@ -82,34 +78,35 @@ class TemplateController extends BaseController {
     return $templates;
   }
   
-  /**
-  * Compares core and plugin templates to check for modifications.
-  *
-  * @return array
-  */
-  private function getModifiedStatus() {
-    $modified = [];
-    $pluginTemplateDir = ETM_PLUGIN_ROOT_DIR . '/Template/notification';
-    $coreTemplateDir = KB_APP_DIR . '/Template/notification';
-  
-    foreach (glob($pluginTemplateDir . '/*.php') as $filename) {
-        $templateName = basename($filename);
-        $pluginFile = $pluginTemplateDir . '/' . $templateName;
-        $coreFile = $coreTemplateDir . '/' . $templateName;
-  
-        // Only compare if the core file exists
-        if (file_exists($coreFile)) {
-            $pluginContent = file_get_contents($pluginFile);
-            $coreContent = file_get_contents($coreFile);
-            
-            // Compare the file contents
-            if ($pluginContent !== $coreContent) {
-                $modified[$templateName] = true;
+    /**
+     * Compares core and plugin templates by file content to check for modifications.
+     *
+     * @return array
+     */
+    private function getModifiedStatus()
+    {
+        $modified = [];
+        $pluginTemplateDir = ETM_PLUGIN_ROOT_DIR . '/Template/notification';
+        $coreTemplateDir = KB_APP_DIR . '/Template/notification';
+
+        foreach (glob($pluginTemplateDir . '/*.php') as $filename) {
+            $templateName = basename($filename);
+            $pluginFile = $pluginTemplateDir . '/' . $templateName;
+            $coreFile = $coreTemplateDir . '/' . $templateName;
+
+            // Only compare if the core file exists
+            if (file_exists($coreFile)) {
+                $pluginContent = file_get_contents($pluginFile);
+                $coreContent = file_get_contents($coreFile);
+                
+                // Compare the file contents
+                if ($pluginContent !== $coreContent) {
+                    $modified[$templateName] = true;
+                }
             }
         }
+        return $modified;
     }
-    return $modified;
-  }
   
   /**
    * Show the form to edit a template

+ 2 - 2
Plugin.php

@@ -48,11 +48,11 @@ class Plugin extends Base {
   }
   
   public function getPluginAuthor() {
-    return "OMI";
+    return "OMI NZ";
   }
   
   public function getPluginVersion() {
-    return "1.0.2";
+    return "1.0.3";
   }
   
   public function getPluginHomepage() {

+ 4 - 0
Template/config/index.php

@@ -2,6 +2,10 @@
   <h2><?= $title ?></h2>
 </div>
 
+<p style="margin-bottom:1em;">
+  <span style="color:red;font-weight:bold;">*</span><i>Indicates a template that has been modified from the core version.</i>
+</p>
+
 <?php /* Display notices about missing/extra templates */ ?>
 <?php if (!empty($missing_templates)): ?>
 <div class="alert alert-info">

+ 1 - 1
Template/notification/footer.php

@@ -1,5 +1,5 @@
 <hr/>
-OMI Tasks
+Kanboard
 
 <?php if ($this->app->config('application_url') != ''): ?>
     <?php if (isset($task['id'])): ?>

+ 0 - 3
Template/notification/task_create.php

@@ -43,8 +43,5 @@
 <?php endif ?>
 
 <?= $this->render('notification/footer', array('task' => $task)) ?>
-
-TEST TEST TEST
-
 </body>
 </html>