本文整理汇总了PHP中CB\Config类的典型用法代码示例。如果您正苦于以下问题:PHP Config类的具体用法?PHP Config怎么用?PHP Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _doRpc
/**
* Remote procedure call.
*
* Execute api function.
*
* @param \stdObject $cdata
* @return array
* @throws \CB\Controller\Exception
*/
private function _doRpc($cdata)
{
$api = \CB\Config::getApiFunctions();
if (!isset($api[$cdata['action']])) {
throw new \CB\Controller\Exception('Call to undefined action: ' . $cdata['action']);
}
$action = $cdata['action'];
$a = $api[$action];
$this->_doAroundCalls($a['before'], $cdata);
$method = $cdata['method'];
$mdef = $a['methods'][$method];
if (!$mdef) {
throw new \CB\Controller\Exception('Call to undefined method: ' . $method . ' on action $action');
}
$this->_doAroundCalls($mdef['before'], $cdata);
$r = array('type' => 'rpc', 'tid' => $cdata['tid'], 'action' => $action, 'method' => $method);
// load api controller
$Class = '\\CB\\Api\\' . $action;
$Controller = $Class::getInstance();
// build function params
if (isset($mdef['len'])) {
$params = isset($cdata['data']) && is_array($cdata['data']) ? $cdata['data'] : array();
} else {
$params = array($cdata['data']);
}
// prepare fields and values
array_walk($params, function ($param) {
(array) $param;
});
// call api controller function
$r['result'] = call_user_func_array(array($Controller, $method), $params);
$this->_doAroundCalls($mdef['after'], $cdata, $r);
$this->_doAroundCalls($a['after'], $cdata, $r);
return $r;
}
示例2: getData
public function getData($id = false)
{
$rez = array('success' => true, 'data' => array());
parent::getData($id);
$o = $this->getObjectClass();
if (empty($o)) {
return $rez;
}
$data = $o->getData();
//dont display thumb for images less then 1MB
$maxDisplaySize = Util\coalesce(Config::get('images_display_size'), 1024 * 1024);
if (substr($data['content_type'], 0, 5) == 'image' && $data['size'] < $maxDisplaySize) {
$preview = Files::generatePreview($data['id']);
if (!empty($preview['filename'])) {
$fn = Config::get('files_preview_dir') . $preview['filename'];
$rez['data']['html'] = $fn;
if (file_exists($fn)) {
$rez['data']['html'] = str_replace('fit-img', 'click fit-img', file_get_contents($fn));
}
}
} else {
$rez['data']['cls'] = 'pr-th-' . \CB\Files::getExtension($data['name']);
}
return $rez;
}
示例3: getContentItems
public function getContentItems()
{
$p =& $this->requestParams;
$folderTemplates = \CB\Config::get('folder_templates');
$p['fl'] = 'id,system,path,name,case,date,date_end,size,cid,oid,cdate,uid,udate,template_id,acl_count,cls,status,task_status,dstatus';
if (@$p['from'] == 'tree') {
$p['templates'] = $folderTemplates;
}
if (is_numeric($this->lastNode->id)) {
$p['pid'] = $pid;
}
$p['dstatus'] = 1;
$p['fq'] = $this->fq;
$s = new \CB\Search();
$rez = $s->query($p);
if (!empty($rez['data'])) {
for ($i = 0; $i < sizeof($rez['data']); $i++) {
$d =& $rez['data'][$i];
$r = DM\Tree::read($d['id']);
if (!empty($r)) {
$d['cfg'] = $r['cfg'];
$r = DM\Tree::getChildCount($d['id'], @$p['from'] == 'tree' ? $folderTemplates : false);
$d['has_childs'] = !empty($r[$d['id']]);
}
}
}
return $rez;
}
示例4: __construct
/**
* constructor
*
* @param string[] $p {
* @type boolean $host custom Solr host or default will be used from config
* @type string $port Solr port
* @type string $core Solr core
* }
*/
public function __construct($p = array())
{
if (empty($p)) {
// get params from core config
$this->host = \CB\Config::get('solr_host', '127.0.0.1');
$this->port = \CB\Config::get('solr_port', 8983);
$this->core = \CB\Config::get('solr_core');
} else {
//get params from specified arguments
$this->host = empty($p['host']) ? '127.0.0.1' : $p['host'];
$this->port = empty($p['port']) ? 8983 : $p['port'];
$this->core = @$p['core'];
if (isset($p['SOLR_CLIENT'])) {
$this->client = $p['SOLR_CLIENT'];
}
if (isset($p['fireEvents'])) {
$this->fireEvents = $p['fireEvents'];
}
}
if (empty($this->client)) {
$this->client = \CB\Config::get('SOLR_CLIENT');
}
if (substr($this->core, 0, 6) != '/solr/') {
$this->core = '/solr/' . $this->core;
}
$this->connect();
}
示例5: getContentItems
public function getContentItems()
{
$p =& $this->requestParams;
$folderTemplates = \CB\Config::get('folder_templates');
$p['fl'] = 'id,system,path,name,case,date,date_end,size,cid,oid,cdate,uid,udate,template_id,acl_count,cls,status,task_status,dstatus';
if (@$p['from'] == 'tree') {
$p['templates'] = $folderTemplates;
}
if (is_numeric($this->lastNode->id)) {
$p['pid'] = $pid;
}
$p['dstatus'] = 1;
$p['fq'] = $this->fq;
$s = new \CB\Search();
$rez = $s->query($p);
if (!empty($rez['data'])) {
for ($i = 0; $i < sizeof($rez['data']); $i++) {
$d =& $rez['data'][$i];
$res = DB\dbQuery('SELECT cfg
, (SELECT 1
FROM tree
WHERE pid = $1' . (@$p['from'] == 'tree' ? ' AND `template_id` IN (0' . implode(',', $folderTemplates) . ')' : '') . ' LIMIT 1) has_childs
FROM tree
WHERE id = $1', $d['id']) or die(DB\dbQueryError());
if ($r = $res->fetch_assoc()) {
$d['cfg'] = Util\toJSONArray($r['cfg']);
$d['has_childs'] = !empty($r['has_childs']);
}
$res->close();
}
}
return $rez;
}
示例6: _getFile
/**
* Get SQL log file.
*
* @access private
* @return string
*/
private function _getFile()
{
if (!$this->_file) {
$this->_file = \CB\Config::get('path.root') . '/logs/doctrine_sql_' . date('Y-m-d') . '.log';
}
return $this->_file;
}
示例7: sendUserMails
function sendUserMails($u)
{
$uid = $u['id'];
if (empty($u['email'])) {
return;
}
$sendType = User::canSendNotifications($uid);
if ($sendType == false) {
return;
}
$coreName = Config::get('core_name');
// $coreUrl = Config::get('core_url');
$languages = Config::get('languages');
$lang = $languages[$u['language_id'] - 1];
if (filter_var($u['email'], FILTER_VALIDATE_EMAIL)) {
//group mails into digest and separate ones (where user is mentioned)
$mails = array('digest' => array(), 'separate' => array());
foreach ($u['mails'] as $notificationId => $notification) {
//[$core #$nodeId] $action_type $template_name: $object_title
$templateId = Objects::getTemplateId($notification['object_id']);
$templateName = Objects::getName($templateId);
$subject = '[' . $coreName . ' #' . $notification['object_id'] . '] ' . Notifications::getActionDeclination($notification['action_type'], $lang) . ' ' . $templateName . ' "' . htmlspecialchars_decode($notification['data']['name']) . '"';
$sender = Notifications::getSender($notification['from_user_id']);
//divide notification into separate number of actions it consist of
$actions = getNotificationActions($notification);
for ($i = 0; $i < sizeof($actions); $i++) {
$a = $actions[$i];
$message = Notifications::getMailBodyForAction($a, $u);
$isMentioned = !empty($a['data']['mentioned']) && in_array($uid, $a['data']['mentioned']);
$mails[$isMentioned ? 'separate' : 'digest'][] = array('subject' => $subject, 'body' => $message, 'sender' => $sender, 'nId' => $notificationId);
}
}
//merge digest emails group into one email and put it into separate group
if (sizeof($mails['digest']) == 1) {
$mails['separate'][] = $mails['digest'][0];
} elseif (!empty($mails['digest'])) {
$mail = array();
$ids = array();
$sender = '';
foreach ($mails['digest'] as $m) {
$mail[] = $m['body'];
$sender = $m['sender'];
$ids[] = $m['nId'];
}
$mails['separate'][] = array('subject' => '[' . $coreName . '] Notifications digest', 'body' => implode('<hr />', $mail), 'sender' => $sender, 'nId' => $ids);
}
foreach ($mails['separate'] as $mail) {
echo $u['email'] . ': ' . $mail['subject'] . "\n";
if (!mail($u['email'], $mail['subject'], $mail['body'], "Content-type: text/html; charset=utf-8\r\nFrom: " . $mail['sender'] . "\r\n")) {
System::notifyAdmin('CaseBox cron notification: Cant send notification (' . $mail['nId'] . ') mail to "' . $u['email'] . '"', $mail['body']);
} else {
DM\Notifications::markAsSeen($mail['nId'], $uid);
}
}
if (!empty($mails['digest'])) {
User::setUserConfigParam('lastNotifyTime', Util\dateISOToMysql('now'), $uid);
}
}
}
示例8: getChildren
public function getChildren(&$pathArray, $requestParams)
{
$pid = null;
/* should start with path check and see if child request is for a real db node*/
if (empty($pathArray)) {
if (empty($requestParams['query'])) {
return;
}
} else {
$lastNode = @$pathArray[sizeof($pathArray) - 1];
if ($lastNode instanceof Dbnode || get_class($lastNode) == 'CB\\TreeNode\\Base') {
$pid = $lastNode->id;
} else {
//we are under another node type
$cfg = $lastNode->getConfig();
if (!empty($cfg['realNodeId']) && $lastNode instanceof RealSubnode) {
$pid = $cfg['realNodeId'];
} else {
return array();
}
}
}
if (empty($pid)) {
return array();
}
/* end of check */
$p =& $requestParams;
$folderTemplates = \CB\Config::get('folder_templates');
$p['fl'] = 'id,pid,system,path,name,case_id,date,date_end,size,cid,' . 'oid,cdate,uid,udate,template_id,acl_count,cls,status,task_status,versions,' . 'comment_user_id,comment_date';
if (empty($p['showFoldersContent'])) {
$p['templates'] = $folderTemplates;
}
if (empty($p['descendants'])) {
$p['pid'] = $pid;
} else {
$p['pids'] = $pid;
}
$s = new \CB\Search();
$rez = $s->query($p);
if (!empty($rez['data'])) {
for ($i = 0; $i < sizeof($rez['data']); $i++) {
$d =& $rez['data'][$i];
$r = DM\Tree::read($d['id']);
if (!empty($r['cfg']) && $p['from'] == 'tree') {
if (isset($r['cfg']['loaded'])) {
$d['loaded'] = $r['cfg']['loaded'];
}
if (isset($r['cfg']['expanded'])) {
$d['expanded'] = $r['cfg']['expanded'];
}
if (isset($r['cfg']['leaf'])) {
$d['leaf'] = $r['cfg']['leaf'];
}
}
}
\CB\Tasks::setTasksActionFlags($rez['data']);
}
return $rez;
}
示例9: testCreateSolrConfigsetsSymlinks
public function testCreateSolrConfigsetsSymlinks()
{
$cfg = \CB\Config::loadConfigFile(\CB_DOC_ROOT . 'config.ini');
$result = \CB\Install\createSolrConfigsetsSymlinks($cfg);
$this->assertTrue($result['success'], ' creates symplink return errors');
$this->assertTrue(file_exists($result['links']['log']), 'solr logs configset symlink not created : ' . $result['links']['log']);
$this->assertTrue(file_exists($result['links']['default']), 'solr default configset symlink not created : ' . $result['links']['default']);
}
示例10: read
/**
* Get app configuration.
*
* Send configuration to the client.
*
* @access public
* @return array
*/
public function read()
{
try {
$config = ['cb.version' => \CB\Config::get('cb.version'), 'cb.build' => \CB\Config::get('cb.build'), 'cb.environment' => \CB\Config::get('cb.environment'), 'url.root' => \CB\Config::get('url.root'), 'url.uploads' => \CB\Config::get('url.uploads'), 'url.resources' => \CB\Config::get('url.resources'), 'folder.root' => \CB\Config::get('folder.root'), 'folder.uploads' => \CB\Config::get('folder.uploads'), 'folder.resources' => \CB\Config::get('folder.resources')];
return $this->success('Read configuration successful.', $config);
} catch (\CB\Exception $e) {
return $this->error($e->getMessage());
}
}
示例11: loadAll
/**
* load all templates from database
* @param boolean $reload reload even if already all loaded
* @return void
*/
public function loadAll($reload = false)
{
//skip loading if already loaded and reload not true
if ($this->loadedAll && !$reload) {
return;
}
$this->reset();
/* collecting template_fields */
$template_fields = array();
$res = DB\dbQuery('SELECT
ts.id
,ts.pid
,ts.template_id
,ts.name
,ts.l' . \CB\Config::get('user_language_index') . ' `title`
,ts.`type`
,ts.cfg
,ts.order
,ts.solr_column_name
FROM templates_structure ts
JOIN tree t on ts.id = t.id AND t.dstatus = 0') or die(DB\dbQueryError());
while ($r = $res->fetch_assoc()) {
$template_id = $r['template_id'];
unset($r['template_id']);
$r['cfg'] = Util\toJSONArray($r['cfg']);
$template_fields[$template_id][$r['id']] = $r;
}
$res->close();
/* loading templates */
$res = DB\dbQuery('SELECT t.id
,t.pid
,t.is_folder
,t.`type`
,t.name
,t.`order`
,t.`visible`
,t.iconCls
,t.default_field
,t.cfg
,t.title_template
,t.info_template
,o.data
FROM templates t
LEFT JOIN objects o
ON t.id = o.id
WHERE t.is_folder = 0') or die(DB\dbQueryError());
while ($r = $res->fetch_assoc()) {
$r['cfg'] = Util\toJSONArray($r['cfg']);
$r['data'] = Util\toJSONArray($r['data']);
$r['fields'] = empty($template_fields[$r['id']]) ? array() : $template_fields[$r['id']];
/* store template in collection */
$this->templates[$r['id']] = new \CB\Objects\Template($r['id'], false);
$this->templates[$r['id']]->setData($r);
}
$res->close();
$this->loadedAll = true;
}
示例12: setUp
public function setUp()
{
$config['solr_port'] = \CB\Config::get('solr_port');
$config['solr_host'] = \CB\Config::get('solr_host');
$config['solr_core'] = \CB\Config::get('prefix') . '_' . \CB\Config::get('core_name');
// print_r($config);
$layer = new \Apache_Solr_Compatibility_Solr4CompatibilityLayer();
$this->solr = $solr = new \Apache_Solr_Service($this->config['solr_host'], $this->config['solr_port'], "/solr/" . $this->config['solr_core'] . "/", false, $layer);
}
示例13: update
/**
* update file
* @param array $p optional properties. If not specified then $this-data is used
* @return boolean
*/
public function update($p = false)
{
//disable default log from parent Object class
\CB\Config::setFlag('disableActivityLog', true);
$rez = parent::update($p);
\CB\Config::setFlag('disableActivityLog', false);
$p =& $this->data;
$this->logAction('file_update', array('file' => array('id' => $p['id'], 'name' => $p['name'])));
return $rez;
}
示例14: saveGridViewState
/**
* save state for grid view of the browser
* @return Ext.Direct responce
*/
public function saveGridViewState($p)
{
$rez = array('success' => true);
$guid = false;
/* incomming params example
p: {params:{id:251, view:grid, path:1/114/101/251, query:null, start:0},…}
params: {id:251, view:grid, path:1/114/101/251, query:null, start:0}
id: 251
path: "1/114/101/251"
query: null
start: 0
view: "grid"
state: {columns:{nid:{id:0, width:80, hidden:true, sortable:true}, name:{id:1, width:160, sortable:true},…}}
columns: {nid:{id:0, width:80, hidden:true, sortable:true}, name:{id:1, width:160, sortable:true},…}
case: {id:3, width:150, sortable:true}
cdate: {id:8, width:120, hidden:true, sortable:true}
cid: {id:6, width:200, hidden:true, sortable:true}
date: {id:4, width:120, sortable:true}
name: {id:1, width:160, sortable:true}
nid: {id:0, width:80, hidden:true, sortable:true}
oid: {id:7, width:200, sortable:true}
path: {id:2, width:150, hidden:true, sortable:true}
size: {id:5, width:80, sortable:true}
udate: {id:9, width:120, hidden:true, sortable:true}
*/
if (!empty($p['params']['search']['template_id'])) {
$guid = 'template_' . $p['params']['search']['template_id'];
} elseif (!empty($p['params']['query'])) {
$guid = 'search';
} else {
$path = empty($p['params']['path']) ? $p['params']['id'] : $p['params']['path'];
if (!empty($path)) {
$treeNodeConfigs = Config::get('treeNodes', array('Dbnode' => array()));
$treeNodeClasses = Path::getNodeClasses($treeNodeConfigs);
$treeNodeGUIDConfigs = array();
foreach ($treeNodeClasses as $nodeClass) {
$cfg = $nodeClass->getConfig();
$treeNodeGUIDConfigs[$cfg['guid']] = $cfg;
}
$nodesPath = Path::createNodesPath($path, $treeNodeGUIDConfigs);
if (!empty($nodesPath)) {
$lastNode = array_pop($nodesPath);
$DCConfig = $lastNode->getDC();
$guid = empty($DCConfig['from']) ? 'default' : $DCConfig['from'];
}
}
}
if ($guid) {
DB\dbQuery('INSERT INTO tree_user_config
(guid, user_id, cfg)
VALUES($1, $2, $3)
ON DUPLICATE KEY UPDATE cfg = $3', array($guid, User::getId(), Util\jsonEncode($p['state'])));
}
return $rez;
}
示例15: __construct
/**
* Api info controller
*
* @access public
* @return void
*/
public function __construct()
{
// convert API functions to Ext.Direct specs
$actions = array();
$api = \CB\Config::getApiFunctions();
foreach ($api as $aname => &$a) {
$methods = array();
foreach ($a['methods'] as $mname => &$m) {
if (isset($m['len'])) {
$md = array('name' => $mname, 'len' => $m['len']);
} else {
$md = array('name' => $mname, 'params' => $m['params']);
}
if (isset($m['formHandler']) && $m['formHandler']) {
$md['formHandler'] = true;
}
$methods[] = $md;
}
$actions[$aname] = $methods;
}
// API specs
$api = array('url' => \CB\Config::get('folder.root') . '/api/router/', 'namespace' => 'CB.api', 'type' => 'remoting', 'actions' => $actions);
// send javascript headers
header('Content-Type: text/javascript');
// init api
$response = 'var CB = {}; CB.init = {};';
$response .= 'CB.init.API=' . json_encode($api) . ';';
// init config
$config = $this->getApiController('Config')->read();
if ($config['success']) {
$response .= 'CB.init.Config=' . json_encode($config['data']) . ';';
}
// init session user
$user = $this->getApiController('User')->readSession();
if ($user['success']) {
$response .= 'CB.init.User=' . json_encode($user['data']) . ';';
}
/*
$countries = $this->getApiController('Country')->read()['data'];
$response .= 'CB.init.Countries=' . json_encode($countries) . ';';
$locations = $this->getApiController('Location')->read()['data'];
$response .= 'CB.init.Locations=' . json_encode($locations) . ';';
$locationTypes = $this->getApiController('LocationType')->read()['data'];
$response .= 'CB.init.LocationTypes=' . json_encode($locationTypes) . ';';
$gradeTypes = $this->getApiController('GradeTypes')->read()['data'];
$response .= 'CB.init.GradeTypes=' . json_encode($gradeTypes) . ';';
*/
echo $response;
exit;
die;
}