本文整理汇总了PHP中CB\Util\toNumericArray函数的典型用法代码示例。如果您正苦于以下问题:PHP toNumericArray函数的具体用法?PHP toNumericArray怎么用?PHP toNumericArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了toNumericArray函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read
/**
* read objects data in bulk manner
* @param array $ids
* @return array
*/
public static function read($ids)
{
$rez = array();
$ids = Util\toNumericArray($ids);
if (!empty($ids)) {
$sql = 'SELECT t.*
,ti.pids
,ti.path
,ti.case_id
,ti.acl_count
,ti.security_set_id
,o.data
,o.sys_data
FROM tree t
JOIN tree_info ti
ON t.id = ti.id
LEFT JOIN objects o
ON t.id = o.id
WHERE t.id in (' . implode(',', $ids) . ')';
$res = DB\dbQuery($sql) or die(DB\dbQueryError());
while ($r = $res->fetch_assoc()) {
$r['data'] = Util\jsonDecode($r['data']);
$r['sys_data'] = Util\jsonDecode($r['sys_data']);
$rez[] = $r;
}
$res->close();
}
return $rez;
}
示例2: onNodeDbCreate
/**
* create system folders specified in created objects template config as system_folders property
* @param object $o
* @return void
*/
public function onNodeDbCreate($o)
{
if (!is_object($o)) {
return;
}
$template = $o->getTemplate();
if (empty($template)) {
return;
}
$templateData = $template->getData();
if (empty($templateData['cfg']['system_folders'])) {
return;
}
$folderIds = Util\toNumericArray($templateData['cfg']['system_folders']);
if (empty($folderIds)) {
return;
}
$p = array('sourceIds' => array(), 'targetId' => $o->getData()['id']);
$browserActionsClass = new Browser\Actions();
$res = DB\dbQuery('SELECT id
FROM tree
WHERE pid in (' . implode(',', $folderIds) . ')
AND dstatus = 0');
while ($r = $res->fetch_assoc()) {
$p['sourceIds'][] = $r['id'];
}
$res->close();
// $browserActionsClass->copy($p);
$browserActionsClass->objectsClass = new \CB\Objects();
$browserActionsClass->doRecursiveAction('copy', $p['sourceIds'], $p['targetId']);
}
示例3: getRecords
/**
* update a record
* @param array $p array with properties
* @return array
*/
public static function getRecords($ids)
{
$rez = array();
$ids = Util\toNumericArray($ids);
$res = DB\dbQuery('SELECT *
FROM `' . static::getTableName() . '`
WHERE id in (0' . implode(',', $ids) . ')');
while ($r = $res->fetch_assoc()) {
$rez[] = $r;
}
$res->close();
return $rez;
}
示例4: onSolrQuery
public function onSolrQuery(&$p)
{
$result =& $p['result'];
$data =& $result['data'];
$ip =& $p['inputParams'];
$view =& $ip['view'];
$facets =& $ip['facets'];
$coloring = empty($view['coloring']) ? array() : Util\toTrimmedArray($view['coloring']);
$view['coloring'] = $coloring;
// detect active coloring facet
$coloringField = $this->getActiveColoringField($p);
$activeFacetClass = null;
$types = array();
foreach ($coloring as $facetAlias) {
if (!empty($facets[$facetAlias]->field)) {
$types[] = $facets[$facetAlias]->field;
if ($coloringField == $facets[$facetAlias]->field) {
$activeFacetClass =& $facets[$facetAlias];
}
}
}
$result['view']['coloring'] = $types;
$coloringItems = array();
if (!empty($activeFacetClass)) {
$cf = $activeFacetClass->getClientData(array('colors' => true));
$result['facets'][$activeFacetClass->field] = $cf;
$coloringItems = $cf['items'];
}
$rez = array();
foreach ($data as $r) {
$fv = empty($r[$coloringField]) ? array() : Util\toNumericArray($r[$coloringField]);
if (empty($fv)) {
$r['cls'] = 'user-color-' . $r['cid'];
$rez[] = $r;
} else {
foreach ($fv as $v) {
if (!empty($coloringItems[$v])) {
$c = $coloringItems[$v];
if (!empty($c['cls'])) {
$r['cls'] = $c['cls'];
}
if (!empty($c['color'])) {
$r['style'] = 'background-color: ' . $c['color'];
}
}
$rez[] = $r;
}
}
}
$result['data'] = $rez;
}
示例5: createDefaultFilter
protected function createDefaultFilter()
{
$this->fq = array();
if (!empty($this->config['includeTemplates'])) {
$ids = Util\toNumericArray($this->config['includeTemplates']);
if (!empty($ids)) {
$this->fq[] = 'template_id:(' . implode(' OR ', $ids) . ')';
}
} elseif (!empty($this->config['excludeTemplates'])) {
$ids = Util\toNumericArray($this->config['excludeTemplates']);
if (!empty($ids)) {
$this->fq[] = '!template_id:(' . implode(' OR ', $ids) . ')';
}
}
}
示例6: delete
/**
* delete a record by its id
* @param []int $ids
* @return boolean
*/
public static function delete($ids)
{
$sql = 'DELETE from ' . static::getTableName() . ' WHERE `type` = $1 and id';
if (is_scalar($ids)) {
static::validateParamTypes(array('id' => $ids));
DB\dbQuery($sql . ' = $2', array(static::$type, $ids));
} else {
$ids = Util\toNumericArray($ids);
if (!empty($ids)) {
DB\dbQuery($sql . ' IN (' . implode(',', $ids) . ')', static::$type);
}
}
$rez = DB\dbAffectedRows() > 0;
return $rez;
}
示例7: getContentPaths
/**
* get relative content paths for given file ids
* path is relative to casebox files directory
* @param array $ids
* @return array associative array (id => relative_content_path)
*/
public static function getContentPaths($ids)
{
$rez = array();
$ids = Util\toNumericArray($ids);
if (!empty($ids)) {
$sql = 'SELECT f.id, c.`path`, f.content_id
FROM files f
JOIN files_content c
ON f.content_id = c.id
WHERE f.id in (' . implode(',', $ids) . ')';
$res = DB\dbQuery($sql);
while ($r = $res->fetch_assoc()) {
$rez[$r['id']] = $r['path'] . DIRECTORY_SEPARATOR . $r['content_id'];
}
$res->close();
}
return $rez;
}
示例8: getData
public function getData($id = false)
{
$rez = array('success' => true);
if (empty(parent::getData($id))) {
return $rez;
}
$params = array('pid' => $this->id, 'fq' => array('(template_type:object) OR (target_type:object)'), 'fl' => 'id,pid,name,template_id,cdate,cid', 'sort' => 'cdate', 'dir' => 'desc');
$folderTemplates = \CB\Config::get('folder_templates');
if (!empty($folderTemplates)) {
$params['fq'][] = '!template_id:(' . implode(' OR ', Util\toNumericArray($folderTemplates)) . ')';
}
$s = new \CB\Search();
$sr = $s->query($params);
foreach ($sr['data'] as $d) {
$d['ago_text'] = Util\formatAgoTime($d['cdate']);
$d['user'] = @User::getDisplayName($d['cid']);
$rez['data'][] = $d;
}
return $rez;
}
示例9: prepareGraphNodes
/**
* This function is designed to prepeare all necessary nodes properties for graph rendering.
*
* used properties for graph:
* id
* ,$this->labelField - will be used as node label
* ,hint = $this->hintField
* ,date = $this->dateField
* ,shape - node shape
* ,style - custom node style
* ,fillcolor
* ,margin
* ,penwith
* ,leftSideNodes - for decisions with associated violations
* ,rightSideNodes
*/
private function prepareGraphNodes(&$nodesArray)
{
for ($i = 0; $i < sizeof($nodesArray); $i++) {
/* define a reference for easy use */
$node =& $nodesArray[$i];
/* adjust title field if needed */
$t = trim($node[$this->labelField]);
$node[$this->hintField] = nl2br($t);
$node[$this->labelField] = strlen($t) > 30 ? substr($t, 0, 30) . ' ...' : $t;
/* adjusting date field format */
if (!empty($node[$this->dateField])) {
$node[$this->dateField] = substr($node[$this->dateField], 0, 10);
$node[$this->dateField] = implode('.', array_reverse(explode('-', $node[$this->dateField])));
}
/* end of adjusting date field format */
/* SETTING NODE STYLE (SHAPE AND COLOR) */
/* getting node object */
$o = Objects::getCachedObject($node['id']);
$node['style'] = 'filled';
$color = $o->getFieldValue('color', 0)['value'];
if (!empty($color)) {
$t = $o->getTemplate();
$color = $t->formatValueForDisplay($t->getField('color'), $color, false);
$node['fillcolor'] = @$this->colors[$color];
} else {
$node['fillcolor'] = $this->colors['gray'];
}
$inLinks = Util\toNumericArray($o->getFieldValue('in_links', 0)['value']);
$outLinks = Util\toNumericArray($o->getFieldValue('out_links', 0)['value']);
foreach ($inLinks as $inNode) {
$this->links[$inNode][$node['id']] = 1;
}
foreach ($outLinks as $outNode) {
$this->links[$node['id']][$outNode] = 1;
}
/* setting node shape */
$node['shape'] = "box";
//set default shape
// $this->switchNodeShowTitles($node);
}
}
示例10: getData
public function getData($id = false)
{
$rez = array('success' => true, 'data' => array());
parent::getData($id);
$obj = $this->getObjectClass();
if (!is_object($obj)) {
return $rez;
}
$data = $obj->getData();
$rez['data'] = array_intersect_key($data, array('id' => 1, 'name' => 1, 'template_id' => 1, 'cid' => 1, 'cdate' => 1, 'uid' => 1, 'udate' => 1, 'dstatus' => 1, 'did' => 1, 'ddate' => 1, 'size' => 1));
$d =& $rez['data'];
$pids = Util\toNumericArray($data['pids']);
array_pop($pids);
$d['pids'] = $d['path'] = implode('/', $pids);
$arr = array(&$d);
Search::setPaths($arr);
$d['template_name'] = Objects::getName($d['template_id']);
$sd = $obj->getSysData();
$userId = User::getId();
$d['subscription'] = 'ignore';
if (!empty($sd['fu']) && in_array($userId, $sd['fu'])) {
$d['subscription'] = 'watch';
//follow
}
if (!empty($sd['wu']) && in_array($userId, $sd['wu'])) {
$d['subscription'] = 'watch';
}
$d['cid_text'] = User::getDisplayName($d['cid']);
$d['cdate_ago_text'] = Util\formatAgoTime($d['cdate']);
$d['cdate'] = Util\dateMysqlToISO($d['cdate']);
$d['udate'] = Util\dateMysqlToISO($d['udate']);
$d['uid_text'] = User::getDisplayName($d['uid']);
$d['udate_ago_text'] = Util\formatAgoTime($d['udate']);
if (!empty($d['dstatus'])) {
$d['did_text'] = User::getDisplayName($d['did']);
$d['ddate_text'] = Util\formatAgoTime($d['ddate']);
}
return $rez;
}
示例11: updateParentFollowers
/**
* function to update parent followers when uploading a file
* with this user
* @return void
*/
protected function updateParentFollowers()
{
$posd = $this->parentObj->getSysData();
$newUserIds = array();
$wu = empty($posd['wu']) ? array() : $posd['wu'];
$uid = User::getId();
if (!in_array($uid, $wu)) {
$newUserIds[] = intval($uid);
}
//update only if new users added
if (!empty($newUserIds)) {
$wu = array_merge($wu, $newUserIds);
$wu = Util\toNumericArray($wu);
$posd['wu'] = array_unique($wu);
$this->parentObj->updateSysData($posd);
}
}
示例12: getPreviewBlocks
/**
* generate html preview for a task
* @param int $id task id
* @return array
*/
public function getPreviewBlocks()
{
$pb = parent::getPreviewBlocks();
$data = $this->getData();
$sd =& $data['sys_data'];
$template = $this->getTemplate();
$actionsLine = 'Actions<hr />';
$dateLines = '';
$ownerRow = '';
$assigneeRow = '';
$contentRow = '';
//create actions line
$flags = $this->getActionFlags();
$actions = array();
if (!empty($flags['complete'])) {
$actions[] = '<a action="complete" class="task-action ib-done">' . L\get('Complete') . '</a>';
}
if (!empty($flags['close'])) {
$actions[] = '<a action="close" class="task-action ib-done-all">' . L\get('Close') . '</a>';
}
if (!empty($flags['reopen'])) {
$actions[] = '<a action="reopen" class="task-action ib-repeat">' . L\get('Reopen') . '</a>';
}
$actionsLine = '<div class="task-actions">' . implode(' ', $actions) . '</div>';
//create date and status row
$ed = $this->getEndDate();
$status = $this->getStatus();
if (!empty($ed)) {
$endDate = Util\formatTaskTime($ed, !$sd['task_allday']);
// $endDate = empty($sd['task_allday'])
// ? Util\formatDateTimePeriod($ed, null, @$_SESSION['user']['cfg']['timezone'])
// : Util\formatDatePeriod($ed, null, @$_SESSION['user']['cfg']['timezone']);
$dateLines = '<tr><td class="prop-key">' . L\get('Due') . ':</td><td>' . $endDate . '</td></tr>';
// $dateLine .= '<div class="date">' . $endDate . '</div>';
}
if (!empty($sd['task_d_closed'])) {
$dateLines .= '<tr><td class="prop-key">' . L\get('Completed') . ':</td><td>' . Util\formatAgoTime($sd['task_d_closed']) . '</td></tr>';
}
//create owner row
$v = $this->getOwner();
if (!empty($v)) {
$cn = User::getDisplayName($v);
$cdt = Util\formatAgoTime($data['cdate']);
$cd = Util\formatDateTimePeriod($data['cdate'], null, @$_SESSION['user']['cfg']['timezone']);
$ownerRow = '<tr><td class="prop-key">' . L\get('Owner') . ':</td><td>' . '<table class="prop-val people"><tbody>' . '<tr><td class="user"><img class="photo32" src="photo/' . $v . '.jpg?32=' . User::getPhotoParam($v) . '" style="width:32px; height: 32px" alt="' . $cn . '" title="' . $cn . '"></td>' . '<td><b>' . $cn . '</b><p class="gr">' . L\get('Created') . ': ' . '<span class="dttm" title="' . $cd . '">' . $cdt . '</span></p></td></tr></tbody></table>' . '</td></tr>';
}
//create assignee row
$v = $this->getFieldValue('assigned', 0);
if (!empty($v['value'])) {
$isOwner = $this->isOwner();
$assigneeRow .= '<tr><td class="prop-key">' . L\get('TaskAssigned') . ':</td><td><table class="prop-val people"><tbody>';
$v = Util\toNumericArray($v['value']);
$dateFormat = \CB\getOption('long_date_format') . ' H:i:s';
foreach ($v as $id) {
$un = User::getDisplayName($id);
$completed = $this->getUserStatus($id) == static::$USERSTATUS_DONE;
$flags = $this->getActionFlags($id);
$cdt = '';
//completed date title
$dateText = '';
if ($completed && !empty($sd['task_u_d_closed'][$id])) {
$cdt = Util\formatMysqlDate($sd['task_u_d_closed'][$id], $dateFormat);
$dateText = ': ' . Util\formatAgoTime($sd['task_u_d_closed'][$id]);
}
$assigneeRow .= '<tr><td class="user"><div style="position: relative">' . '<img class="photo32" src="photo/' . $id . '.jpg?32=' . User::getPhotoParam($id) . '" style="width:32px; height: 32px" alt="' . $un . '" title="' . $un . '">' . ($completed ? '<img class="done icon icon-tick-circle" src="/css/i/s.gif" />' : "") . '</div></td><td><b>' . $un . '</b>' . '<p class="gr" title="' . $cdt . '">' . ($completed ? L\get('Completed') . $dateText . ($isOwner ? ' <a class="bt task-action click" action="markincomplete" uid="' . $id . '">' . L\get('revoke') . '</a>' : '') : L\get('waitingForAction') . ($isOwner ? ' <a class="bt task-action click" action="markcomplete" uid="' . $id . '">' . L\get('complete') . '</a>' : '')) . '</p></td></tr>';
}
$assigneeRow .= '</tbody></table></td></tr>';
}
//create description row
$v = $this->getFieldValue('description', 0);
if (!empty($v['value'])) {
$tf = $template->getField('description');
$v = $template->formatValueForDisplay($tf, $v);
$contentRow = '<tr><td class="prop-val" colspan="2">' . $v . '</td></tr>';
}
//insert rows
$p = $pb[0];
$pos = strrpos($p, '<tbody>');
$p = substr($p, $pos + 7);
$pos = strrpos($p, '</tbody>');
if ($pos !== false) {
$p = substr($p, 0, $pos);
}
$pb[0] = $actionsLine . '<table class="obj-preview"><tbody>' . $dateLines . $p . $ownerRow . $assigneeRow . $contentRow . '<tbody></table>';
return $pb;
}
示例13: markAsRead
/**
* mark user notifications as read
* @param int $userId
* @param int[] $ids
* @return void
*/
public static function markAsRead($userId, $ids)
{
//validate params
if (!is_numeric($userId)) {
trigger_error(L\get('ErroneousInputData'), E_USER_ERROR);
}
$ids = Util\toNumericArray($ids);
if (!empty($ids)) {
DB\dbQuery('UPDATE `' . static::$tableName . '`
SET `read` = 1
WHERE user_id = $1 AND id IN (' . implode(',', $ids) . ')', $userId) or die(DB\dbQueryError());
}
}
示例14: getMenuRules
protected static function getMenuRules()
{
$rez = Cache::get('CreateMenuRules', array());
if (!empty($rez)) {
return $rez;
}
$s = new Search();
$ids = array();
$sr = $s->query(array('fl' => 'id', 'template_types' => 'menu', 'skipSecurity' => true));
foreach ($sr['data'] as $r) {
$ids[] = $r['id'];
}
$arr = Objects::getCachedObjects($ids);
foreach ($arr as $o) {
$d = $o->getData()['data'];
$rez[] = array('nids' => empty($d['node_ids']) ? array() : Util\toNumericArray($d['node_ids']), 'ntids' => empty($d['template_ids']) ? array() : Util\toNumericArray($d['template_ids']), 'ugids' => empty($d['user_group_ids']) ? array() : Util\toNumericArray($d['user_group_ids']), 'menu' => $d['menu']);
}
Cache::set('CreateMenuRules', $rez);
return $rez;
}
示例15: getChildCount
/**
* get children count for given item ids
* @param array $ids
* @param array $templateIds filter children by template ids
* @return array associative array of children per id
*/
public static function getChildCount($ids, $templateIds = false)
{
$rez = array();
$ids = Util\toNumericArray($ids);
if (empty($ids)) {
return $rez;
}
if (empty($templateIds)) {
$templateIds = '';
} else {
$templateIds = Util\toNumericArray($templateIds);
if (!empty($templateIds)) {
$templateIds = ' AND template_id in (' . implode(',', $templateIds) . ')';
}
}
$sql = 'SELECT pid, count(*) `children`
FROM tree
WHERE pid in (' . implode(',', $ids) . ')
AND dstatus = 0' . $templateIds . '
GROUP BY pid';
$res = DB\dbQuery($sql);
while ($r = $res->fetch_assoc()) {
$rez[$r['pid']] = $r['children'];
}
$res->close();
return $rez;
}