fix saveToCache() usage; move hook controllers around
[pharext/pharext.org] / app / views / github / repo.phtml
index 4477e8af54cd71f93fb893d19f8d734c510c87a2..6000cf7e976f563952a949c8dd70876c70817960 100644 (file)
        </h1>
 </div>
 
-<?php if (isset($exception)) : ?>
-       <?= $this->fetch("alert") ?>
-<?php elseif (isset($repo)) : ?>
-
 <div class="row">
        <div class="col-md-6">
                <div class="well">
                                <p>Has a <code>config*.m4</code> file?</p>
                        </div>
                        <div class="col-md-4 text-center">
-                               <p><span class="label label-info">YES</span></p>
+                               <p>
+                                       <?php if (!empty($repo->config_m4)) : ?>
+                                       <span class="label label-info">YES</span>
+                                       <?php else : ?>
+                                       <span class="label label-warning">NO</span>
+                                       <?php endif; ?>
+                               </p>
                        </div>
                </div>
 
                                <p>Has a <code>package*.xml</code> file?</p>
                        </div>
                        <div class="col-md-4 text-center">
-                               <p><span class="label label-warning">NO</span></p>
+                               <p>
+                                       <?php if (!empty($repo->package_xml)) : ?>
+                                       <span class="label label-info">YES</span>
+                                       <?php else : ?>
+                                       <span class="label label-warning">NO</span>
+                                       <?php endif; ?>
+                               </p>
                        </div>
                </div>
 
                                <p>Has a <code>pharext_package.php</code> file?</p>
                        </div>
                        <div class="col-md-4 text-center">
-                               <p><span class="label label-info">YES</span></p>
+                               <p>
+                                       <?php if (!empty($repo->pharext_package_php)) : ?>
+                                       <span class="label label-info">YES</span>
+                                       <?php else : ?>
+                                       <span class="label label-warning">NO</span>
+                                       <?php endif; ?>
+                               </p>
                        </div>
                </div>
 
                                <p>Is the <code>pharext</code> hook enabled?</p>
                        </div>
                        <div class="col-md-4 text-center">
-                               <p><span class="label label-warning">NO</span></p>
+                                       <?php if ($this->check($repo)) : ?>
+                                       <span class="label label-info">YES</span>
+                                       <?php else : ?>
+                                       <span class="label label-warning">NO</span>
+                                       <?php endif; ?>
                        </div>
                </div>
        </div>
 
        <div class="col-md-6">
-               <div class="row text-center">
-                       <div class="col-md-6">
-                               <button class="btn btn-lg btn-block btn-success">Enable Hook</button>
-                       </div>
+               <div class="row">
+                       <form method="post" action="<?= $baseUrl->mod("./github/repo/". $repo->full_name ."/hook/" . ($this->check($repo) ? "upd" : "add")) ?>">
+                               <div class="col-md-12">
+                                               <div class="checkbox">
+                                                       <label for="hook-tag">
+                                                               <input id="hook-tag" type="checkbox" name="tag" value="1" <?= ($hook = $this->check($repo)) && in_array("create", $hook->events) ? "checked":"" ?>>
+                                                               Automatically create a release when I push a tag.
+                                                       </label>
+                                               </div>
+                                               <div class="checkbox">
+                                                       <label for="hook-release">
+                                                               <input id="hook-release" type="checkbox" name="release" value="1" <?= ($hook = $this->check($repo)) && in_array("release", $hook->events) ? "checked":"" ?>>
+                                                               Automatically upload a PHARext package as an asset to a release.
+                                                       </label>
+                                               </div>
+                               </div>
+                               <?php if ($this->check($repo)) : ?>
+                               <div class="col-md-6">
+                                       <button type="submit" class="btn btn-lg btn-block btn-info">
+                                               <span class="glyphicon glyphicon-ok-circle"></span>
+                                               Update Hook
+                                       </button>
+                               </div>
+                               <?php else : ?>
+                               <div class="col-md-12">
+                                       <button type="submit" class="btn btn-lg btn-block btn-success">
+                                               <span class="octicon octicon-plug"></span>
+                                               Enable Hook
+                                       </button>
+                               </div>
+                               <?php endif; ?>
+                       </form>
+                       <!-- column wrapping! -->
+                       <?php if ($this->check($repo)) : ?>
                        <div class="col-md-6">
-                               <button class="btn btn-lg btn-block btn-danger disabled">Disable Hook</button>
+                               <form method="post" action="<?= $baseUrl->mod("./github/repo/". $repo->full_name ."/hook/del") ?>"> 
+                               <button class="btn btn-lg btn-block btn-danger">
+                                       <span class="glyphicon glyphicon-remove-circle"></span>
+                                       Remove Hook
+                               </button>
+                               </form>
                        </div>
+                       <?php endif; ?>
                </div>
        </div>
 </div>
 
 <h2>Release History</h2>
+<?php if (empty($repo->tags) || !count((array) $repo->tags)) : ?>
+<div class="alert alert-warning" role="alert">
+       <p class="text-danger">No releases or tags found.</p>
+</div>
+<?php endif; ?>
 
 <?php foreach ($repo->tags as $name => $v) : ?>
 <div class="panel panel-<?= empty($v->release) ? "info": "primary" ?>">
                                <?= $this->e($v->tag->name) ?>
                                <span class="label label-default pull-right">Tag</span>
                        <?php else : ?>
-                               <?= $this->e($v->release->name) ?>
-                               <span class="label label-default pull-right">Release</span>
+                               <?= $this->e($v->release->name ?: $v->tag->name) ?>
+                               <span class="label label-info pull-right">Release</span>
                        <?php endif; ?>
                </h3>
        </div>
 </div>
 <?php endforeach; ?>
 
-<pre><?php var_dump($repo) ?></pre>
-
-<?php endif; ?>