public function init($params) { self::requireLogin(); if (!isset($params['qr-data'])) { $params['qr-data'] = Application::getBaseURL()->build(); } $hParams = new HttpParams($params); $this->currentParams = $hParams; $this->doGenerateCode = $hParams->hasValues(array('qr-data', 'qr-size', 'qr-fgcolor', 'qr-bgcolor')); }
public function init($params) { self::requireLogin(); $dbc = Application::dbConnection(); if ($lid = $this->linkId) { $this->linkInfo = $dbc->links()->getLink($lid); if ($this->linkInfo) { if ($this->editMode) { $allowed = self::hasPermission('link.edit_links'); $allowed |= $this->linkInfo->owner_id === Authorization::user()->id && self::hasPermission('link.edit_own_links'); if ($allowed) { $postData = \tniessen\tinyIt\HttpParams::_POST(); if ($postData && !$postData->isEmpty()) { $this->currentParams = $postData; $this->tryProcessEditPostData($postData); } } else { $this->editMode = false; $this->errorMessage = 'You are not permitted to edit this link.'; } } elseif ($this->deleteMode) { self::requireNonce(); $allowed = self::hasPermission('link.delete_links'); $allowed |= $this->linkInfo->owner_id === Authorization::user()->id && self::hasPermission('link.delete_own_links'); if ($allowed) { if ($dbc->links()->removeLink($lid)) { self::redirectTo('links/list'); exit; } else { $this->errorMessage = 'Internal error while deleting link'; } } else { $this->errorMessage = 'You are not permitted to delete this link.'; } } if ($oid = $this->linkInfo->owner_id) { $this->linkInfo->userInfo = $dbc->users()->getUser($oid); } if ($this->linkInfo->type === 'static') { $this->linkInfo->fullURL = Application::getBaseURL()->build() . $this->linkInfo->path; } } } }
<?php } ?> </a> <?php if ($r->opt('editMode')) { ?> <button class="btn btn-primary" type="submit"><span class="glyphicon glyphicon-ok"></span> Save</button> <?php } ?> <button type="button" class="btn btn-danger" data-toggle="modal" data-target=".confirm-deletion-modal"> <span class="glyphicon glyphicon-trash"></span> Delete </button> <a href="<?php echo $r->escapeAttr($pageURL('tools/qr-code', array('qr-data' => isset($l->fullURL) ? $l->fullURL : \tniessen\tinyIt\Application::getBaseURL()->build()))); ?> " class="btn btn-info"> <span class="glyphicon glyphicon-qrcode"></span> QR code </a> </form> <div class="modal fade confirm-deletion-modal" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog modal-sm"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Delete link</h4> </div> <div class="modal-body"> <p>Do you really want to delete this link?</p> <p><code><?php
if ($page->hasPermission('link.custom')) { ?> <div class="checkbox"> <label> <input type="checkbox" value="1" name="use_custom_path" <?php if ($r->opt('current:use_custom_path')) { echo 'checked'; } ?> > Use custom short URL </label> </div> <div class="input-group"> <span class="input-group-addon"><?php echo $r->escapeHtml(\tniessen\tinyIt\Application::getBaseURL()->build()); ?> </span> <input type="text" class="form-control" name="custom_path" placeholder="Custom path" value="<?php echo $r->escapeAttrOpt('current:custom_path'); ?> " /> </div> <?php } ?> <?php if ($r->opt('allowOverrideWildcards')) { ?> <div class="checkbox"> <label>
/** * Returns a URL pointing to a page. * * @param mixed $path * @param array $params * @return \tniessen\tinyIt\URL */ public static final function getURL($path, $params = array()) { if (is_array($path)) { $path = implode('/', $path); } $url = Application::getBaseURL(); if (defined('TI_ADMIN_PATH')) { $url->path .= TI_ADMIN_PATH . '/'; } if (defined('TI_ROUTING_ENABLED')) { $url->path .= $path; } else { $params['_webuipath'] = $path; } $url->query = URL::buildQuery($params); return $url; }