コード例 #1
0
ファイル: Source.php プロジェクト: tunandras/webtrees
 /**
  * Each object type may have its own special rules, and re-implement this function.
  *
  * @param int $access_level
  *
  * @return bool
  */
 protected function canShowByType($access_level)
 {
     // Hide sources if they are attached to private repositories ...
     preg_match_all('/\\n1 REPO @(.+)@/', $this->gedcom, $matches);
     foreach ($matches[1] as $match) {
         $repo = Repository::getInstance($match, $this->tree);
         if ($repo && !$repo->canShow($access_level)) {
             return false;
         }
     }
     // ... otherwise apply default behaviour
     return parent::canShowByType($access_level);
 }
コード例 #2
0
ファイル: autocomplete.php プロジェクト: tronsmit/webtrees
     }
 }
 // Fetch all data, regardless of privacy
 $rows = get_SOUR_rows($WT_TREE, $term);
 // Filter for privacy
 foreach ($rows as $row) {
     $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
     if ($source->canShowName()) {
         $data[] = array('value' => $source->getXref(), 'label' => $source->getFullName());
     }
 }
 // Fetch all data, regardless of privacy
 $rows = get_REPO_rows($WT_TREE, $term);
 // Filter for privacy
 foreach ($rows as $row) {
     $repository = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
     if ($repository->canShowName()) {
         $data[] = array('value' => $repository->getXref(), 'label' => $repository->getFullName());
     }
 }
 // Fetch all data, regardless of privacy
 $rows = get_OBJE_rows($WT_TREE, $term);
 // Filter for privacy
 foreach ($rows as $row) {
     $media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
     if ($media->canShowName()) {
         $data[] = array('value' => $media->getXref(), 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName());
     }
 }
 // Fetch all data, regardless of privacy
 $rows = get_FAM_rows($WT_TREE, $term);
コード例 #3
0
ファイル: SqlRepository.php プロジェクト: junkings/techlog
 public static function getCategoryInfos()
 {
     // {{{
     $sql = 'select category.category_id, category.category, count(*) as total' . ' from article, category' . ' where article.category_id = category.category_id' . ' group by article.category_id';
     $pdo = Repository::getInstance();
     $stmt = $pdo->query($sql);
     $ret = $stmt->fetchAll();
     return $ret;
 }
コード例 #4
0
ファイル: build_model.php プロジェクト: aleafboat/techlog
if (!isset($options['t'])) {
    echo 'usage: php create_model.php' . ' -t table' . PHP_EOL;
    exit;
}
$table = $options['t'];
$table_class = ucfirst(StringOpt::unlinetocamel($table) . 'Model');
$file = MODEL_PATH . '/' . $table_class . '.php';
if (file_exists($file)) {
    echo '文件已存在,是否替换 [y/N]';
    $sure = fgets(STDIN);
    if (trim($sure[0]) != 'Y' && trim($sure[0]) != 'y') {
        exit;
    }
}
$rp = new Repository('db', true);
$pdo = $rp->getInstance();
$sql = 'describe ' . $table;
$rs = $pdo->query($sql);
$model = '<?php' . PHP_EOL . 'class ' . $table_class . PHP_EOL . '{' . PHP_EOL;
$rows = $rs->fetchAll();
foreach ($rows as $row) {
    $model .= "\t" . 'private $' . $row['Field'] . ';' . PHP_EOL;
}
$model .= PHP_EOL;
$model .= "\t" . 'public function __construct($params = array())' . PHP_EOL . "\t{" . PHP_EOL . "\t\t" . 'foreach (get_object_vars($this) as $key=>$value)' . PHP_EOL . "\t\t" . '{' . PHP_EOL . "\t\t\t" . 'if ($key != $this->get_pri_key() && isset($params[$key]))' . PHP_EOL . "\t\t\t\t" . '$this->$key = $params[$key];' . PHP_EOL . "\t\t\t" . 'else if (empty($this->$key))' . PHP_EOL . "\t\t\t\t" . '$this->$key = "";' . PHP_EOL . "\t\t}" . PHP_EOL . "\t}" . PHP_EOL . PHP_EOL;
$model .= "\t" . 'public function get_model_fields()' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . 'return array_keys(get_object_vars($this));' . PHP_EOL . "\t" . '}' . PHP_EOL;
foreach ($rows as $row) {
    $model .= "\t" . 'public function get_' . $row['Field'] . '()' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . 'return $this->' . $row['Field'] . ';' . PHP_EOL . "\t" . '}' . PHP_EOL;
    if ($row['Key'] != 'PRI') {
        $model .= "\t" . 'public function set_' . $row['Field'] . '($value)' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . '$this->' . $row['Field'] . ' = $value;' . PHP_EOL . "\t\t" . 'return $this;' . PHP_EOL . "\t" . '}' . PHP_EOL;
    } else {
コード例 #5
0
ファイル: article_creater.php プロジェクト: aleafboat/techlog
    return;
}
foreach ($tags as $tag) {
    $tag = trim($tag);
    if ($tag == '') {
        continue;
    }
    $tag_id = Repository::findTagIdFromTags(array('eq' => array('tag_name' => $tag)));
    if ($tag_id == false) {
        $tag = new TagsModel(array('tag_name' => $tag, 'inserttime' => 'now()'));
        $tag_id = Repository::persist($tag);
        if ($tag_id == false) {
            LogOpt::set('exception', 'tag 添加失败');
            continue;
        }
    }
    $article_tag_relation = new ArticleTagRelationModel(array('article_id' => $article_id, 'tag_id' => $tag_id, 'inserttime' => 'now()'));
    try {
        $relation_id = Repository::persist($article_tag_relation);
    } catch (PDOException $e) {
        LogOpt::set('exception', 'article_tag_relation 已存在', 'article_id', $article_id, 'tag_id', $tag_id);
        $pdo = Repository::getInstance();
        $pdo->rollback();
        continue;
    }
    if ($relation_id == false) {
        LogOpt::set('exception', 'article_tag_relation 更新失败', 'article_id', $article_id, 'tag_id', $tag_id);
        continue;
    }
    LogOpt::set('info', 'article_tag_relation 更新成功', 'relation_id', $relation_id);
}
コード例 #6
0
/**
* returns REPO:NAME matching filter
* @return Array of string
*/
function autocomplete_REPO_NAME($FILTER)
{
    $rows = get_autocomplete_REPO_NAME($FILTER);
    $data = array();
    foreach ($rows as $row) {
        $repository = Repository::getInstance($row);
        if ($repository->canDisplayName()) {
            $data[] = $repository->getFullName();
        }
    }
    return $data;
}
コード例 #7
0
ファイル: autocomplete.php プロジェクト: bitweaver/phpgedview
/**
* returns REPO:NAME matching filter
* @return Array of string
*/
function autocomplete_REPO_NAME($FILTER)
{
    global $TBLPREFIX, $gBitDb;
    $sql = "SELECT o_type AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec" . " FROM {$TBLPREFIX}other" . " WHERE o_gedcom LIKE ? AND o_file=? AND o_type='REPO'";
    $rows = $gBitDb->query($sql, array("%1 NAME %{$FILTER}%", PGV_GED_ID), PGV_AUTOCOMPLETE_LIMIT);
    $data = array();
    while ($row = $rows->fetchRows()) {
        $repository = Repository::getInstance($row);
        if ($repository->canDisplayName()) {
            $data[] = $repository->getFullName();
        }
    }
    return $data;
}
コード例 #8
0
ファイル: functions_db.php プロジェクト: bitweaver/phpgedview
function get_repo_list($ged_id)
{
    global $TBLPREFIX, $gBitDb;
    $rows = $gBitDb->GetAssoc("SELECT 'REPO' AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec FROM {$TBLPREFIX}other WHERE o_type='REPO' AND o_file=?", array($ged_id));
    $list = array();
    foreach ($rows as $row) {
        $list[] = Repository::getInstance($row);
    }
    usort($list, array('GedcomRecord', 'Compare'));
    return $list;
}