Exemplo n.º 1
0
 /**
  * Get persistent URL vars
  *
  * @param string $action action to override Naf::currentAction()
  * @param bool $asHidden when set to TRUE, return value is a string containing HTML hiddent inputs list
  * @return array | string
  */
 function getPersistent($action = null, $asHidden = false)
 {
     if ($asHidden) {
         $tmp = $this->_persistent;
         $tmp['ctrl'] = $action ? $action : Naf::currentAction();
         $html = "";
         foreach ($tmp as $name => $value) {
             if (is_scalar($value)) {
                 $html .= '<input type="hidden" name="' . htmlspecialchars($name, ENT_QUOTES) . '" value="' . htmlspecialchars($value, ENT_QUOTES) . '" />';
             }
         }
         return $html;
     }
     return $this->_persistent;
 }
Exemplo n.º 2
0
 public static function setRouter($router)
 {
     self::$router = $router;
 }
Exemplo n.º 3
0
 /**
  * Create error logger
  *
  * @return Naf_ErrorLog_Interface
  */
 private static function _logger()
 {
     if (null === self::$_logger) {
         $class = empty(self::$settings['logger']) ? 'Naf_ErrorLog_Null' : self::$settings['logger'];
         self::$_logger = new $class();
     }
     return self::$_logger;
 }
Exemplo n.º 4
0
 /**
  * @return string
  */
 function getView()
 {
     return null === $this->_view ? Naf::currentAction() : $this->_view;
 }
Exemplo n.º 5
0
 private function ensureConnection()
 {
     if ($this->connection) {
         return;
     }
     if (self::$defaultConnection) {
         $this->connection = self::$defaultConnection;
         return;
     }
     Naf::dbConnect();
     self::setDefaultConnection(Naf::$pdo);
     $this->connection = self::$defaultConnection;
 }
Exemplo n.º 6
0
$list = Branch::enlist($gitWorkingCopyDir, isset($opts->remote), isset($opts->merged));
$charInput = new SttyCharInput();
$confirmed = true;
foreach (new PregMatchIterator('~^(.*)/task-([0-9]+)(-.+)?$~', $list) as $matches) {
    $issueId = $matches[2];
    if (isset($opts->before) && $issueId >= $opts->before) {
        continue;
    }
    $branchFullName = $matches[0];
    echo $issueId . ': ' . $branchFullName . ' ';
    $branch = new Branch($gitWorkingCopyDir, $branchFullName);
    $issue = new Issue();
    $issue->find($issueId);
    if ($issue->count()) {
        echo '[' . $issue->status['name'] . '] ';
        if (in_array($issue->status['id'], Naf::config('redmine.closed_issue_status_ids'))) {
            if (!$opts->force) {
                echo 'Delete ' . ($branch->isRemote() ? 'remote' : 'local') . ' branch? (y/N) ';
                $confirmed = $charInput->confirm();
            }
            if ($confirmed) {
                try {
                    $branch->delete();
                    echo ' Deleted';
                } catch (ShellCmd\Fault $e) {
                    echo $e->getMessage();
                }
            }
        }
    } else {
        echo 'Issue not found';
Exemplo n.º 7
0
<?php

if (is_file(dirname(__FILE__) . '/setup.override.php')) {
    include dirname(__FILE__) . '/setup.override.php';
}
if (!defined('APPMODE')) {
    /* in production mode by default */
    define('APPMODE', 'production');
}
define('ROOT', dirname(__FILE__) . '/');
if (!defined('NAF_ROOT')) {
    define('NAF_ROOT', ROOT . 'naf/');
}
define('APP_CONF_ROOT', ROOT . 'conf/');
define('APP_LIB_ROOT', ROOT . 'lib/');
include NAF_ROOT . 'Naf.php';
Naf::setUp(APPMODE);
Exemplo n.º 8
0
 /**
  * @return PDO
  */
 static function getConnection()
 {
     if (null === static::$connection) {
         ActiveRecord::setConnection(\Naf::pdo());
     }
     return static::$connection;
 }
Exemplo n.º 9
0
 /**
  * Generate URL
  *
  * @param int $page
  * @return string
  */
 function url($page)
 {
     $this->queryParams['page'] = $page;
     return Naf::currentUrlXml($this->queryParams, $this->separator) . $this->getAnchor();
 }
Exemplo n.º 10
0
if ($ts) {
    $date = date('Y-m-d', $ts);
} else {
    echo "Cannot recognize date format\n\n";
    exit(2);
}
$redmineTagId = Db::assertTagId(Naf::config('hamster.tag_text'));
foreach (Db::selectFactsByDate($date)->fetchAll() as $fact) {
    echo $fact['name'] . ' ..';
    $matches = null;
    if (!preg_match('~#([0-9]+)~', $fact['name'], $matches)) {
        echo " skipping\n";
        continue;
    }
    $issue_id = $matches[1];
    if (Db::isFactTaggedBy($fact['id'], $redmineTagId)) {
        echo " allready logged\n";
        continue;
    }
    $hours = round($fact['hours'], 1);
    $entry = new TimeEntry(array('issue_id' => $issue_id, 'spent_on' => $date, 'hours' => (string) $hours, 'comments' => '', 'activity_id' => (string) Naf::config('redmine.activity.development')));
    $entry->save();
    if (!$entry->id) {
        //id property is served by __get() method
        echo " error\n";
        continue;
    }
    echo ' ' . $hours . 'H';
    Db::tagFactBy($fact['id'], $redmineTagId);
    echo " ok\n";
}
Exemplo n.º 11
0
<?php

if (is_file(__DIR__ . '/setup.override.php')) {
    // setup.override.php usually defines APPMODE constant due to choose a config file to use
    include __DIR__ . '/setup.override.php';
}
if (!defined('APPMODE')) {
    define('APPMODE', 'sample');
}
define('ROOT', __DIR__ . '/');
if (!defined('NAF_ROOT')) {
    define('NAF_ROOT', ROOT . 'ext/naf/');
}
define('APP_CONF_ROOT', ROOT . 'conf/');
define('APP_LIB_ROOT', ROOT . 'lib/');
require_once NAF_ROOT . 'Naf.php';
Naf::loadConfig(APP_CONF_ROOT . '/' . APPMODE . '.php');
Naf::setDefaultLibraryRoot(APP_LIB_ROOT);
Naf::setUp();