• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Util\toNumericArray函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中CB\Util\toNumericArray函数的典型用法代码示例。如果您正苦于以下问题:PHP toNumericArray函数的具体用法?PHP toNumericArray怎么用?PHP toNumericArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了toNumericArray函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
 }
开发者ID:ameliefranco,项目名称:casebox,代码行数:34,代码来源:Objects.php


示例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']);
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:36,代码来源:Listeners.php


示例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;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:18,代码来源:Log.php


示例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;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:51,代码来源:Calendar.php


示例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) . ')';
         }
     }
 }
开发者ID:austinvernsonger,项目名称:casebox,代码行数:15,代码来源:RecentActivity.php


示例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;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:20,代码来源:Users.php


示例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;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:24,代码来源:Files.php


示例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;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:20,代码来源:ContentItems.php


示例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);
     }
 }
开发者ID:austinvernsonger,项目名称:casebox,代码行数:57,代码来源:Graph.php


示例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;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:39,代码来源:SystemProperties.php


示例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);
     }
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:22,代码来源:File.php


示例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;
 }
开发者ID:youprofit,项目名称:casebox,代码行数:91,代码来源:Task.php


示例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());
     }
 }
开发者ID:austinvernsonger,项目名称:casebox,代码行数:19,代码来源:Notifications.php


示例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;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:20,代码来源:CreateMenu.php


示例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;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:33,代码来源:Tree.php


示例16: markAsRead

 /**
  * mark user notifications as read
  * @param  int   $userId
  * @param  int[] $ids
  * @return void
  */
 public static function markAsRead($userId, $ids)
 {
     //validate params
     \CB\raiseErrorIf(!is_numeric($userId), 'ErroneousInputData');
     $ids = Util\toNumericArray($ids);
     if (!empty($ids)) {
         DB\dbQuery('UPDATE `' . static::getTableName() . '`
             SET `read` = 1
             WHERE user_id = $1 AND id IN (' . implode(',', $ids) . ')', $userId) or die(DB\dbQueryError());
     }
 }
开发者ID:ameliefranco,项目名称:casebox,代码行数:17,代码来源:Notifications.php


示例17: prepareValueforSolr

 /**
  * prepare a given value for solr according to its type
  * @param  varchar $type  (checkbox,combo,date,datetime,float,html,int,memo,_objects,text,time,timeunits,varchar)
  * @param  variant $value
  * @return variant
  */
 protected function prepareValueforSolr($type, $value)
 {
     if (empty($value) || empty($value['value'])) {
         return null;
     }
     $value = $value['value'];
     switch ($type) {
         case 'boolean':
             //not used
         //not used
         case 'checkbox':
             $value = empty($value) ? false : true;
             break;
         case 'date':
         case 'datetime':
             if (!empty($value)) {
                 //check if there is only date, without time
                 if (strlen($value) == 10) {
                     $value .= 'T00:00:00';
                 }
                 if (substr($value, -1) != 'Z') {
                     $value .= 'Z';
                 }
                 if (@$value[10] == ' ') {
                     $value[10] = 'T';
                 }
             }
             break;
             /** time values are stored as seconds representation in solr */
         /** time values are stored as seconds representation in solr */
         case 'time':
             if (!empty($value)) {
                 $a = explode(':', $value);
                 @($value = $a[0] * 3600 + $a[1] * 60 + $a[2]);
             }
             break;
         case 'combo':
         case 'int':
         case '_objects':
             $arr = Util\toNumericArray($value);
             $value = array();
             //remove zero values
             foreach ($arr as $v) {
                 if (!empty($v)) {
                     $value[] = $v;
                 }
             }
             $value = array_unique($value);
             if (empty($value)) {
                 $value = null;
             } elseif (sizeof($value) == 1) {
                 //set just value if 1 element array
                 $value = array_shift($value);
             }
             break;
         case 'html':
             $value = strip_tags($value);
             break;
     }
     return $value;
 }
开发者ID:ameliefranco,项目名称:casebox,代码行数:67,代码来源:Object.php


示例18: getDiff

 /**
  * get diff html for given log record data
  * @param  array $logData
  * @return array
  */
 public function getDiff($logData)
 {
     $old = empty($logData['old']) ? array() : $logData['old'];
     $new = empty($logData['new']) ? array() : $logData['new'];
     $rez = array();
     $template = $this->getTemplate();
     $ld = $this->getLinearData(true);
     foreach ($ld as $f) {
         $ov = empty($old[$f['name']]) ? '' : $old[$f['name']][0];
         $nv = empty($new[$f['name']]) ? '' : $new[$f['name']][0];
         if ($ov != $nv) {
             $field = $template->getField($f['name']);
             if ($field['type'] == '_objects') {
                 $a = empty($ov['value']) ? array() : Util\toNumericArray($ov['value']);
                 $b = empty($nv['value']) ? array() : Util\toNumericArray($nv['value']);
                 $c = array_intersect($a, $b);
                 if (!empty($c)) {
                     $a = array_diff($a, $c);
                     $b = array_diff($b, $c);
                     $ov['value'] = implode(',', $a);
                     $nv['value'] = implode(',', $b);
                 }
             }
             $title = Util\coalesce($field['title'], $field['name']);
             $value = empty($ov) ? '' : '<div class="old-value">' . $template->formatValueForDisplay($field, $ov, false) . '</div>';
             $value .= empty($nv) ? '' : '<div class="new-value">' . $template->formatValueForDisplay($field, $nv, false) . '</div>';
             $rez[$title] = $value;
         }
     }
     return $rez;
 }
开发者ID:youprofit,项目名称:casebox,代码行数:36,代码来源:Object.php


示例19: getMenuForPath

 /**
  * get the menu config for a given path or id
  * @param  varchar | int $path path string or node id
  * @return [type]        [description]
  */
 public static function getMenuForPath($path)
 {
     $rez = '';
     //get item path if id specified
     if (is_numeric($path)) {
         $tmp = \CB\Path::getPath($path);
         $path = '/' . $tmp['path'];
     }
     if (is_string($path)) {
         $path = explode('/', $path);
     }
     $path = array_reverse(array_filter($path, 'is_numeric'));
     $path = Util\toNumericArray($path);
     // get templates for each path elements
     $nodeTemplate = array();
     $res = DB\dbQuery('SELECT id, template_id
         FROM tree
         WHERE id in (0' . implode(',', $path) . ')') or die(DB\dbQueryError());
     while ($r = $res->fetch_assoc()) {
         $nodeTemplate[$r['id']] = $r['template_id'];
     }
     $res->close();
     //get db menu into variable
     $menu = array();
     $res = DB\dbQuery('SELECT
             node_ids `nids`
             ,node_template_ids `ntids`
             ,user_group_ids `ugids`
             ,menu
         FROM menu') or die(DB\dbQueryError());
     while ($r = $res->fetch_assoc()) {
         $r['nids'] = Util\toNumericArray($r['nids']);
         $r['ntids'] = Util\toNumericArray($r['ntids']);
         $r['ugids'] = Util\toNumericArray($r['ugids']);
         $menu[] = $r;
     }
     $res->close();
     $ugids = $_SESSION['user']['groups'];
     $ugids[] = $_SESSION['user']['id'];
     // we have 3 main criterias for detecting needed menu:
     //  - user_group_ids - records for specific users or groups
     //  - node_ids
     //  - template_ids
     //
     // we'll iterate the path from the end and detect the menu
     $lastWeight = 0;
     for ($i = 0; $i < sizeof($path); $i++) {
         //firstly we'll check if we find a menu row with id or template of the node
         foreach ($menu as $m) {
             $weight = 0;
             if (in_array($path[$i], $m['nids'])) {
                 $weight += 50;
             } elseif (empty($m['nids'])) {
                 $weight += 1;
             } else {
                 //skip this record because it contain nids and not contain this node id
                 continue;
             }
             if (in_array($nodeTemplate[$path[$i]], $m['ntids'])) {
                 $weight += 50;
             } elseif (empty($m['ntids'])) {
                 $weight += 1;
             } else {
                 //skip this record because it has ntids specified and not contain this node template id
                 continue;
             }
             if (empty($m['ugids'])) {
                 $weight += 1;
             } else {
                 $int = array_intersect($ugids, $m['ugids']);
                 if (empty($int)) {
                     continue;
                 } else {
                     $weight += 10;
                 }
             }
             if ($weight > $lastWeight) {
                 $lastWeight = $weight;
                 $rez = $m['menu'];
             }
         }
         //if nid matched or template matched then dont iterate further
         if ($lastWeight > 50) {
             return $rez;
         }
     }
     return $rez;
 }
开发者ID:austinvernsonger,项目名称:casebox,代码行数:93,代码来源:CreateMenu.php


示例20: updateParentFollowers

 /**
  * function to update parent followers when adding a comment
  * with this user and referenced users from comment
  * @return void
  */
 protected function updateParentFollowers()
 {
     $p =& $this->data;
     $posd = $this->parentObj->getSysData();
     $newUserIds = array();
     $posd['lastComment'] = array('user_id' => User::getId(), 'date' => Util\dateMysqlToISO('now'));
     $fu = empty($posd['fu']) ? array() : $posd['fu'];
     $uid = User::getId();
     if (!in_array($uid, $fu)) {
         $newUserIds[] = intval($uid);
     }
     //analize comment text and get referenced users
     if (preg_match_all('/@([^@\\s,!\\?]+)/', $p['data']['_title'], $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             $uid = DM\User::getIdByName($match[1]);
             if (is_numeric($uid) && !in_array($uid, $fu) && !in_array($uid, $newUserIds)) {
                 $newUserIds[] = $uid;
             }
         }
     }
     //update only if new users added
     if (!empty($newUserIds)) {
         $fu = array_merge($fu, $newUserIds);
         $fu = Util\toNumericArray($fu);
         $posd['fu'] = array_unique($fu);
     }
     //always update sys_data to change lastComment date
     $this->parentObj->updateSysData($posd);
 }
开发者ID:ameliefranco,项目名称:casebox,代码行数:34,代码来源:Comment.php



注:本文中的CB\Util\toNumericArray函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Application\Application类代码示例发布时间:2022-05-23
下一篇:
PHP L\get函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap