function _in_ignore($p, $ignore) { if (!$ignore) { return FALSE; } foreach ($ignore as $ig) { $ig = ISPATH($ig) ? $ig : PATH($p, $ig); if ($p->issub($ig, TRUE)) { return TRUE; } } return FALSE; }
function _process_value($v, &$pick_db, $db, $path = NULL) { if (is_callable($v)) { return $v($pick_db, $db, $path); } if (ISPICK($v)) { if (ISPATH($path)) { return $v->rand($path); } else { return $v->rand($db); } } if (is_array($v)) { $res = []; foreach ($v as $k => $_) { $res[$k] = _process_value($_, $pick_db, $db, $path); } return $res; } return $v; }
function attrs() { global $sql_stmts; if ($this->issql and $this->_id !== NULL) { $added = []; # id's returned sql_getmany(sql_stmt("word_id->attr_tag"), $added, ["i", $this->_id]); foreach ($added as $attr) { $cont = FALSE; foreach ($this->_attrs as $_attr) { if (ISPATH($_attr) ? $_attr->tag() == $attr : $_attr == $attr) { $cont = TRUE; break; } } if (!$cont) { $this->_attrs[] = ATTR($this, $attr); } } } return $this->_attrs; }
function add2() { $recurse = NULL; $recurse = function ($vec) use(&$recurse) { foreach ($vec as $a) { if (is_callable($a)) { $a = $a(); } if (ISPATH($a)) { $a = (string) $a; } if (!$a) { } elseif (is_string($a)) { foreach (explode("/", trim($a)) as $_) { if ($_) { $this->add($_); } } } elseif (is_array($a)) { if (count($a) === 2 and is_string($a[0]) and $this->mgr()->is_key($a[0])) { $this->add($a); } else { $recurse($a); } } else { _die("bad PATH.add2 argument of type " . gettype($a)); } } }; $recurse(func_get_args()); return $this; }
function format_word($w, $lang = NULL, $all = false) { if (ISPATH($w)) { $id = " data-path='{$w}'"; $w = $w->get(); } else { $id = ""; } if (!strlen($w)) { return '<abbr' . $id . ' class="symbolic" title="This form does not exist">—</abbr>'; } # em-dash if (!is_string($lang)) { $lang = "la"; } if (!$all) { $w = explode("\n", $w)[0]; } if ($lang) { return '<span' . $id . ' class="format-word-' . $lang . '">' . $w . '</span>'; } return $w; }