repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.messageGroupPublish | public function messageGroupPublish($fromUserId, $toGroupId = array(), $objectName, $content, $pushContent='', $pushData = '') {
try{
if(empty($fromUserId))
throw new Exception('发送人用户 Id 不能为空');
if(empty($toGroupId))
throw new Exception('接收群Id 不能为空');
if(empty($objectName))
throw new Exception('消息类型 不能为空');
if(empty($content))
throw new Exception('发送消息内容 不能为空');
$params = array(
'fromUserId'=>$fromUserId,
'objectName'=>$objectName,
'content'=>$content,
'pushContent'=>$pushContent,
'pushData'=>$pushData,
'toGroupId' => $toGroupId
);
$ret = $this->curl('/message/group/publish',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function messageGroupPublish($fromUserId, $toGroupId = array(), $objectName, $content, $pushContent='', $pushData = '') {
try{
if(empty($fromUserId))
throw new Exception('发送人用户 Id 不能为空');
if(empty($toGroupId))
throw new Exception('接收群Id 不能为空');
if(empty($objectName))
throw new Exception('消息类型 不能为空');
if(empty($content))
throw new Exception('发送消息内容 不能为空');
$params = array(
'fromUserId'=>$fromUserId,
'objectName'=>$objectName,
'content'=>$content,
'pushContent'=>$pushContent,
'pushData'=>$pushData,
'toGroupId' => $toGroupId
);
$ret = $this->curl('/message/group/publish',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"messageGroupPublish",
"(",
"$",
"fromUserId",
",",
"$",
"toGroupId",
"=",
"array",
"(",
")",
",",
"$",
"objectName",
",",
"$",
"content",
",",
"$",
"pushContent",
"=",
"''",
",",
"$",
"pushData",
"=",
"''",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"fromUserId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'发送人用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"toGroupId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'接收群Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"objectName",
")",
")",
"throw",
"new",
"Exception",
"(",
"'消息类型 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"content",
")",
")",
"throw",
"new",
"Exception",
"(",
"'发送消息内容 不能为空');",
"",
"",
"$",
"params",
"=",
"array",
"(",
"'fromUserId'",
"=>",
"$",
"fromUserId",
",",
"'objectName'",
"=>",
"$",
"objectName",
",",
"'content'",
"=>",
"$",
"content",
",",
"'pushContent'",
"=>",
"$",
"pushContent",
",",
"'pushData'",
"=>",
"$",
"pushData",
",",
"'toGroupId'",
"=>",
"$",
"toGroupId",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/message/group/publish'",
",",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 以一个用户身份向群组发送消息
@param $fromUserId 发送人用户 Id。(必传)
@param $toGroupId 接收群Id,提供多个本参数可以实现向多群发送消息。(必传)
@param $objectName 消息类型,参考融云消息类型表.消息标志;可自定义消息类型。(必传)
@param $content 发送消息内容,参考融云消息类型表.示例说明;如果 objectName 为自定义消息类型,该参数可自定义格式。(必传)
@param string $pushContent 如果为自定义消息,定义显示的 Push 内容。(可选)
@param string $pushData 针对 iOS 平台,Push 通知附加的 payload 字段,字段名为 appData。(可选)
@return json|xml | [
"以一个用户身份向群组发送消息"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L122-L149 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.messageChatroomPublish | public function messageChatroomPublish($fromUserId, $toChatroomId = array(), $objectName, $content) {
try{
if(empty($fromUserId))
throw new Exception('发送人用户 Id 不能为空');
if(empty($toChatroomId))
throw new Exception('接收聊天室Id 不能为空');
if(empty($objectName))
throw new Exception('消息类型 不能为空');
if(empty($content))
throw new Exception('发送消息内容 不能为空');
$params = array(
'fromUserId' => $fromUserId,
'objectName' => $objectName,
'content' => $content,
'toChatroomId' => $toChatroomId
);
$ret = $this->curl('/message/chatroom/publish',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function messageChatroomPublish($fromUserId, $toChatroomId = array(), $objectName, $content) {
try{
if(empty($fromUserId))
throw new Exception('发送人用户 Id 不能为空');
if(empty($toChatroomId))
throw new Exception('接收聊天室Id 不能为空');
if(empty($objectName))
throw new Exception('消息类型 不能为空');
if(empty($content))
throw new Exception('发送消息内容 不能为空');
$params = array(
'fromUserId' => $fromUserId,
'objectName' => $objectName,
'content' => $content,
'toChatroomId' => $toChatroomId
);
$ret = $this->curl('/message/chatroom/publish',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"messageChatroomPublish",
"(",
"$",
"fromUserId",
",",
"$",
"toChatroomId",
"=",
"array",
"(",
")",
",",
"$",
"objectName",
",",
"$",
"content",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"fromUserId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'发送人用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"toChatroomId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'接收聊天室Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"objectName",
")",
")",
"throw",
"new",
"Exception",
"(",
"'消息类型 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"content",
")",
")",
"throw",
"new",
"Exception",
"(",
"'发送消息内容 不能为空');",
"",
"",
"$",
"params",
"=",
"array",
"(",
"'fromUserId'",
"=>",
"$",
"fromUserId",
",",
"'objectName'",
"=>",
"$",
"objectName",
",",
"'content'",
"=>",
"$",
"content",
",",
"'toChatroomId'",
"=>",
"$",
"toChatroomId",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/message/chatroom/publish'",
",",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 一个用户向聊天室发送消息
@param $fromUserId 发送人用户 Id。(必传)
@param $toChatroomId 接收聊天室Id,提供多个本参数可以实现向多个聊天室发送消息。(必传)
@param $objectName 消息类型,参考融云消息类型表.消息标志;可自定义消息类型。(必传)
@param $content 发送消息内容,参考融云消息类型表.示例说明;如果 objectName 为自定义消息类型,该参数可自定义格式。(必传)
@return json|xml | [
"一个用户向聊天室发送消息"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L160-L184 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.messageDiscussionPublish | public function messageDiscussionPublish($fromUserId,$toDiscussionId,$objectName,$content,$pushContent='',$pushData='') {
try{
if(empty($fromUserId))
throw new Exception('发送人用户 Id 不能为空');
if(empty($toDiscussionId))
throw new Exception('接收讨论组 Id 不能为空');
if(empty($objectName))
throw new Exception('消息类型 不能为空');
if(empty($content))
throw new Exception('发送消息内容 不能为空');
$params = array(
'fromUserId'=>$fromUserId,
'toDiscussionId'=>$toDiscussionId,
'objectName'=>$objectName,
'content'=>$content,
'pushContent'=>$pushContent,
'pushData'=>$pushData
);
$paramsString = http_build_query($params);
$ret = $this->curl('/message/discussion/publish',$paramsString);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function messageDiscussionPublish($fromUserId,$toDiscussionId,$objectName,$content,$pushContent='',$pushData='') {
try{
if(empty($fromUserId))
throw new Exception('发送人用户 Id 不能为空');
if(empty($toDiscussionId))
throw new Exception('接收讨论组 Id 不能为空');
if(empty($objectName))
throw new Exception('消息类型 不能为空');
if(empty($content))
throw new Exception('发送消息内容 不能为空');
$params = array(
'fromUserId'=>$fromUserId,
'toDiscussionId'=>$toDiscussionId,
'objectName'=>$objectName,
'content'=>$content,
'pushContent'=>$pushContent,
'pushData'=>$pushData
);
$paramsString = http_build_query($params);
$ret = $this->curl('/message/discussion/publish',$paramsString);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"messageDiscussionPublish",
"(",
"$",
"fromUserId",
",",
"$",
"toDiscussionId",
",",
"$",
"objectName",
",",
"$",
"content",
",",
"$",
"pushContent",
"=",
"''",
",",
"$",
"pushData",
"=",
"''",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"fromUserId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'发送人用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"toDiscussionId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'接收讨论组 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"objectName",
")",
")",
"throw",
"new",
"Exception",
"(",
"'消息类型 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"content",
")",
")",
"throw",
"new",
"Exception",
"(",
"'发送消息内容 不能为空');",
"",
"",
"$",
"params",
"=",
"array",
"(",
"'fromUserId'",
"=>",
"$",
"fromUserId",
",",
"'toDiscussionId'",
"=>",
"$",
"toDiscussionId",
",",
"'objectName'",
"=>",
"$",
"objectName",
",",
"'content'",
"=>",
"$",
"content",
",",
"'pushContent'",
"=>",
"$",
"pushContent",
",",
"'pushData'",
"=>",
"$",
"pushData",
")",
";",
"$",
"paramsString",
"=",
"http_build_query",
"(",
"$",
"params",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/message/discussion/publish'",
",",
"$",
"paramsString",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 发送讨论组消息
@param $fromUserId 发送人用户 Id。(必传)
@param $toDiscussionId 接收讨论组 Id。(必传)
@param $objectName 消息类型,参考融云消息类型表.消息标志;可自定义消息类型。(必传)
@param $content 发送消息内容,参考融云消息类型表.示例说明;如果 objectName 为自定义消息类型,该参数可自定义格式。(必传)
@param string $pushContent 如果为自定义消息,定义显示的 Push 内容。(可选)
@param string $pushData 针对 iOS 平台,Push 通知附加的 payload 字段,字段名为 appData。(可选)
@return json|xml | [
"发送讨论组消息"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L196-L223 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.messageBroadcast | public function messageBroadcast($fromUserId,$objectName,$content) {
try{
if(empty($fromUserId))
throw new Exception('发送人用户 Id 不能为空');
if(empty($objectName))
throw new Exception('消息类型不能为空');
if(empty($content))
throw new Exception('发送消息内容不能为空');
$ret = $this->curl(
'/message/broadcast',
array(
'fromUserId' => $fromUserId,
'objectName' => $objectName,
'content' => $content
)
);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function messageBroadcast($fromUserId,$objectName,$content) {
try{
if(empty($fromUserId))
throw new Exception('发送人用户 Id 不能为空');
if(empty($objectName))
throw new Exception('消息类型不能为空');
if(empty($content))
throw new Exception('发送消息内容不能为空');
$ret = $this->curl(
'/message/broadcast',
array(
'fromUserId' => $fromUserId,
'objectName' => $objectName,
'content' => $content
)
);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"messageBroadcast",
"(",
"$",
"fromUserId",
",",
"$",
"objectName",
",",
"$",
"content",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"fromUserId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'发送人用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"objectName",
")",
")",
"throw",
"new",
"Exception",
"(",
"'消息类型不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"content",
")",
")",
"throw",
"new",
"Exception",
"(",
"'发送消息内容不能为空');",
"",
"",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/message/broadcast'",
",",
"array",
"(",
"'fromUserId'",
"=>",
"$",
"fromUserId",
",",
"'objectName'",
"=>",
"$",
"objectName",
",",
"'content'",
"=>",
"$",
"content",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 某发送消息给一个应用下的所有注册用户。
@param $fromUserId 发送人用户 Id。(必传)
@param $objectName 消息类型,参考融云消息类型表.消息标志;可自定义消息类型。(必传)
@param $content 发送消息内容,参考融云消息类型表.示例说明;如果 objectName 为自定义消息类型,该参数可自定义格式。(必传)
@return json|xml | [
"某发送消息给一个应用下的所有注册用户。"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L271-L293 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.messageHistory | public function messageHistory($date) {
try{
if(empty($date))
throw new Exception('时间不能为空');
$ret = $this->curl('/message/history', array('date' => $date));
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function messageHistory($date) {
try{
if(empty($date))
throw new Exception('时间不能为空');
$ret = $this->curl('/message/history', array('date' => $date));
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"messageHistory",
"(",
"$",
"date",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"date",
")",
")",
"throw",
"new",
"Exception",
"(",
"'时间不能为空');",
"",
"",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/message/history'",
",",
"array",
"(",
"'date'",
"=>",
"$",
"date",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 获取 APP 内指定某天某小时内的所有会话消息记录的下载地址
@param $date 指定北京时间某天某小时,格式为:2014010101,表示:2014年1月1日凌晨1点。(必传)
@return json|xml | [
"获取",
"APP",
"内指定某天某小时内的所有会话消息记录的下载地址"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L300-L311 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.groupSync | public function groupSync($userId, $data = array()) {
try{
if(empty($userId))
throw new Exception('被同步群信息的用户 Id 不能为空');
if(empty($data))
throw new Exception('该用户的群信息 不能为空');
$arrKey = array_keys($data);
$arrVal = array_values($data);
$params = array(
'userId' => $userId
);
foreach ($data as $key => $value) {
$params['group[' . $key . ']'] = $value;
}
$ret = $this->curl('/group/sync', $params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function groupSync($userId, $data = array()) {
try{
if(empty($userId))
throw new Exception('被同步群信息的用户 Id 不能为空');
if(empty($data))
throw new Exception('该用户的群信息 不能为空');
$arrKey = array_keys($data);
$arrVal = array_values($data);
$params = array(
'userId' => $userId
);
foreach ($data as $key => $value) {
$params['group[' . $key . ']'] = $value;
}
$ret = $this->curl('/group/sync', $params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"groupSync",
"(",
"$",
"userId",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'被同步群信息的用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"throw",
"new",
"Exception",
"(",
"'该用户的群信息 不能为空');",
"",
"",
"$",
"arrKey",
"=",
"array_keys",
"(",
"$",
"data",
")",
";",
"$",
"arrVal",
"=",
"array_values",
"(",
"$",
"data",
")",
";",
"$",
"params",
"=",
"array",
"(",
"'userId'",
"=>",
"$",
"userId",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"params",
"[",
"'group['",
".",
"$",
"key",
".",
"']'",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/group/sync'",
",",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 向融云服务器提交 userId 对应的用户当前所加入的所有群组。
@param $userId 被同步群信息的用户Id。(必传)
@param array $data 该用户的群信息。(必传)array('key'=>'val')
@return json|xml | [
"向融云服务器提交",
"userId",
"对应的用户当前所加入的所有群组。"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L338-L360 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.groupJoin | public function groupJoin($userId, $groupId, $groupName) {
try{
if(empty($userId))
throw new Exception('被同步群信息的用户 Id 不能为空');
if(empty($groupId))
throw new Exception('加入的群 Id 不能为空');
if(empty($groupName))
throw new Exception('加入的群 Id 对应的名称不能为空');
$ret = $this->curl('/group/join',
array(
'userId' => $userId,
'groupId' => $groupId,
'groupName' => $groupName
)
);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function groupJoin($userId, $groupId, $groupName) {
try{
if(empty($userId))
throw new Exception('被同步群信息的用户 Id 不能为空');
if(empty($groupId))
throw new Exception('加入的群 Id 不能为空');
if(empty($groupName))
throw new Exception('加入的群 Id 对应的名称不能为空');
$ret = $this->curl('/group/join',
array(
'userId' => $userId,
'groupId' => $groupId,
'groupName' => $groupName
)
);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"groupJoin",
"(",
"$",
"userId",
",",
"$",
"groupId",
",",
"$",
"groupName",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'被同步群信息的用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"groupId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'加入的群 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"groupName",
")",
")",
"throw",
"new",
"Exception",
"(",
"'加入的群 Id 对应的名称不能为空');",
"",
"",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/group/join'",
",",
"array",
"(",
"'userId'",
"=>",
"$",
"userId",
",",
"'groupId'",
"=>",
"$",
"groupId",
",",
"'groupName'",
"=>",
"$",
"groupName",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 将用户加入指定群组,用户将可以收到该群的消息。
@param $userId 要加入群的用户 Id。(必传)
@param $groupId 要加入的群 Id。(必传)
@param $groupName 要加入的群 Id 对应的名称。(可选)
@return json|xml | [
"将用户加入指定群组,用户将可以收到该群的消息。"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L370-L391 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.groupQuit | public function groupQuit($userId, $groupId) {
try{
if(empty($userId))
throw new Exception('被同步群信息的用户 Id 不能为空');
if(empty($groupId))
throw new Exception('加入的群 Id 不能为空');
$ret = $this->curl('/group/quit',
array('userId' => $userId, "groupId" => $groupId)
);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function groupQuit($userId, $groupId) {
try{
if(empty($userId))
throw new Exception('被同步群信息的用户 Id 不能为空');
if(empty($groupId))
throw new Exception('加入的群 Id 不能为空');
$ret = $this->curl('/group/quit',
array('userId' => $userId, "groupId" => $groupId)
);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"groupQuit",
"(",
"$",
"userId",
",",
"$",
"groupId",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'被同步群信息的用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"groupId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'加入的群 Id 不能为空');",
"",
"",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/group/quit'",
",",
"array",
"(",
"'userId'",
"=>",
"$",
"userId",
",",
"\"groupId\"",
"=>",
"$",
"groupId",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 将用户从群中移除,不再接收该群组的消息。
@param $userId 要退出群的用户 Id。(必传)
@param $groupId 要退出的群 Id。(必传)
@return mixed | [
"将用户从群中移除,不再接收该群组的消息。"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L400-L415 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.groupUserQuery | public function groupUserQuery( $groupId ) {
try{
if(empty($groupId))
throw new Exception('要加入的群 Id 不能为空');
$ret = $this->curl('/group/user/query',
array('groupId' => $groupId)
);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function groupUserQuery( $groupId ) {
try{
if(empty($groupId))
throw new Exception('要加入的群 Id 不能为空');
$ret = $this->curl('/group/user/query',
array('groupId' => $groupId)
);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"groupUserQuery",
"(",
"$",
"groupId",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"groupId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'要加入的群 Id 不能为空');",
"",
"",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/group/user/query'",
",",
"array",
"(",
"'groupId'",
"=>",
"$",
"groupId",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 查询群成员 方法
@param $groupId 群 Id。(必传)
@return json|xml | [
"查询群成员",
"方法"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L471-L484 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.chatroomCreate | public function chatroomCreate($data = array()) {
try{
if(empty($data))
throw new Exception('要加入群的用户 Id 不能为空');
$params = array();
foreach($data as $key=>$val) {
$k = 'chatroom['.$key.']';
$params["$k"] = $val;
}
$ret = $this->curl('/chatroom/create', $params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function chatroomCreate($data = array()) {
try{
if(empty($data))
throw new Exception('要加入群的用户 Id 不能为空');
$params = array();
foreach($data as $key=>$val) {
$k = 'chatroom['.$key.']';
$params["$k"] = $val;
}
$ret = $this->curl('/chatroom/create', $params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"chatroomCreate",
"(",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"throw",
"new",
"Exception",
"(",
"'要加入群的用户 Id 不能为空');",
"",
"",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"k",
"=",
"'chatroom['",
".",
"$",
"key",
".",
"']'",
";",
"$",
"params",
"[",
"\"$k\"",
"]",
"=",
"$",
"val",
";",
"}",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/chatroom/create'",
",",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 创建聊天室
@param array $data key:要创建的聊天室的id;val:要创建的聊天室的name。(必传)
@return json|xml | [
"创建聊天室"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L492-L508 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.chatroomQuery | public function chatroomQuery($chatroomId) {
try{
if(empty($chatroomId))
throw new Exception('要查询的聊天室 Id 不能为空');
$ret = $this->curl('/chatroom/query', array('chatroomId' => $chatroomId));
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function chatroomQuery($chatroomId) {
try{
if(empty($chatroomId))
throw new Exception('要查询的聊天室 Id 不能为空');
$ret = $this->curl('/chatroom/query', array('chatroomId' => $chatroomId));
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"chatroomQuery",
"(",
"$",
"chatroomId",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"chatroomId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'要查询的聊天室 Id 不能为空');",
"",
"",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/chatroom/query'",
",",
"array",
"(",
"'chatroomId'",
"=>",
"$",
"chatroomId",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 查询聊天室信息 方法
@param $chatroomId 要查询的聊天室id(必传)
@return json|xml | [
"查询聊天室信息",
"方法"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L533-L544 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.userBlock | public function userBlock($userId,$minute) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($minute))
throw new Exception('封禁时长不能为空');
$ret = $this->curl('/user/block', array('userId' => $userId, 'minute' => $minute));
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function userBlock($userId,$minute) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($minute))
throw new Exception('封禁时长不能为空');
$ret = $this->curl('/user/block', array('userId' => $userId, 'minute' => $minute));
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"userBlock",
"(",
"$",
"userId",
",",
"$",
"minute",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"minute",
")",
")",
"throw",
"new",
"Exception",
"(",
"'封禁时长不能为空');",
"",
"",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/user/block'",
",",
"array",
"(",
"'userId'",
"=>",
"$",
"userId",
",",
"'minute'",
"=>",
"$",
"minute",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 封禁用户 方法
@param $userId 用户 Id。(必传)
@param $minute 封禁时长,单位为分钟,最大值为43200分钟。(必传)
@return mixed | [
"封禁用户",
"方法"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L591-L604 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.userBlockQuery | public function userBlockQuery() {
try{
$ret = $this->curl('/user/block/query','');
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function userBlockQuery() {
try{
$ret = $this->curl('/user/block/query','');
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"userBlockQuery",
"(",
")",
"{",
"try",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/user/block/query'",
",",
"''",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 获取被封禁用户 方法
@return mixed | [
"获取被封禁用户",
"方法"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L629-L638 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.userRefresh | public function userRefresh($userId,$name='',$portraitUri='') {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($name))
throw new Exception('用户名称不能为空');
if(empty($portraitUri))
throw new Exception('用户头像 URI 不能为空');
$ret = $this->curl('/user/refresh',
array('userId' => $userId, 'name' => $name, 'portraitUri' => $portraitUri));
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function userRefresh($userId,$name='',$portraitUri='') {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($name))
throw new Exception('用户名称不能为空');
if(empty($portraitUri))
throw new Exception('用户头像 URI 不能为空');
$ret = $this->curl('/user/refresh',
array('userId' => $userId, 'name' => $name, 'portraitUri' => $portraitUri));
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"userRefresh",
"(",
"$",
"userId",
",",
"$",
"name",
"=",
"''",
",",
"$",
"portraitUri",
"=",
"''",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"throw",
"new",
"Exception",
"(",
"'用户名称不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"portraitUri",
")",
")",
"throw",
"new",
"Exception",
"(",
"'用户头像 URI 不能为空');",
"",
"",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/user/refresh'",
",",
"array",
"(",
"'userId'",
"=>",
"$",
"userId",
",",
"'name'",
"=>",
"$",
"name",
",",
"'portraitUri'",
"=>",
"$",
"portraitUri",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 刷新用户信息 方法 说明:当您的用户昵称和头像变更时,您的 App Server 应该调用此接口刷新在融云侧保存的用户信息,以便融云发送推送消息的时候,能够正确显示用户信息
@param $userId 用户 Id,最大长度 32 字节。是用户在 App 中的唯一标识码,必须保证在同一个 App 内不重复,重复的用户 Id 将被当作是同一用户。(必传)
@param string $name 用户名称,最大长度 128 字节。用来在 Push 推送时,或者客户端没有提供用户信息时,显示用户的名称。
@param string $portraitUri 用户头像 URI,最大长度 1024 字节
@return mixed | [
"刷新用户信息",
"方法",
"说明:当您的用户昵称和头像变更时,您的",
"App",
"Server",
"应该调用此接口刷新在融云侧保存的用户信息,以便融云发送推送消息的时候,能够正确显示用户信息"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L648-L664 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.userBlacklistQuery | public function userBlacklistQuery($userId) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
$ret = $this->curl('/user/blacklist/query', array('userId' => $userId));
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function userBlacklistQuery($userId) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
$ret = $this->curl('/user/blacklist/query', array('userId' => $userId));
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"userBlacklistQuery",
"(",
"$",
"userId",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'用户 Id 不能为空');",
"",
"",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/user/blacklist/query'",
",",
"array",
"(",
"'userId'",
"=>",
"$",
"userId",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 获取某个用户的黑名单列表
@param $userId 用户 Id。(必传)
@return mixed | [
"获取某个用户的黑名单列表"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L700-L711 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.userBlacklistRemove | public function userBlacklistRemove($userId, $blackUserId = array()) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($blackUserId))
throw new Exception('被移除的用户 Id 不能为空');
$params = array(
'userId' => $userId,
'blackUserId' => $blackUserId
);
$ret = $this->curl('/user/blacklist/remove', $params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function userBlacklistRemove($userId, $blackUserId = array()) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($blackUserId))
throw new Exception('被移除的用户 Id 不能为空');
$params = array(
'userId' => $userId,
'blackUserId' => $blackUserId
);
$ret = $this->curl('/user/blacklist/remove', $params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"userBlacklistRemove",
"(",
"$",
"userId",
",",
"$",
"blackUserId",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"blackUserId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'被移除的用户 Id 不能为空');",
"",
"",
"$",
"params",
"=",
"array",
"(",
"'userId'",
"=>",
"$",
"userId",
",",
"'blackUserId'",
"=>",
"$",
"blackUserId",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/user/blacklist/remove'",
",",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 从黑名单中移除用户
@param $userId 用户 Id。(必传)
@param array $blackUserId 被移除的用户Id。(必传)
@return mixed | [
"从黑名单中移除用户"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L720-L740 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.groupUserGagRollback | public function groupUserGagRollback($userId,$groupId) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($groupId))
throw new Exception('群组 Id 不能为空');
$params['userId'] = $userId;
$params['groupId'] = $groupId;
$ret = $this->curl('/group/user/gag/rollback',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function groupUserGagRollback($userId,$groupId) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($groupId))
throw new Exception('群组 Id 不能为空');
$params['userId'] = $userId;
$params['groupId'] = $groupId;
$ret = $this->curl('/group/user/gag/rollback',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"groupUserGagRollback",
"(",
"$",
"userId",
",",
"$",
"groupId",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"groupId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'群组 Id 不能为空');",
"",
"",
"$",
"params",
"[",
"'userId'",
"]",
"=",
"$",
"userId",
";",
"$",
"params",
"[",
"'groupId'",
"]",
"=",
"$",
"groupId",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/group/user/gag/rollback'",
",",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 移除禁言群成员
@param $userId 用户 Id。(必传)
@param $groupId 群组 Id。(必传)
@return mixed | [
"移除禁言群成员"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L776-L791 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.groupUserGagList | public function groupUserGagList($groupId) {
try{
if(empty($groupId))
throw new Exception('群组 Id 不能为空');
$params['groupId'] = $groupId;
$ret = $this->curl('/group/user/gag/list',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function groupUserGagList($groupId) {
try{
if(empty($groupId))
throw new Exception('群组 Id 不能为空');
$params['groupId'] = $groupId;
$ret = $this->curl('/group/user/gag/list',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"groupUserGagList",
"(",
"$",
"groupId",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"groupId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'群组 Id 不能为空');",
"",
"",
"$",
"params",
"[",
"'groupId'",
"]",
"=",
"$",
"groupId",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/group/user/gag/list'",
",",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 查询被禁言群成员
@param $groupId 群组 Id。(必传)
@return mixed | [
"查询被禁言群成员"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L798-L810 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.wordfilterAdd | public function wordfilterAdd($word) {
try{
if(empty($word))
throw new Exception('敏感词不能为空');
$params['word'] = $word;
$ret = $this->curl('/wordfilter/add',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function wordfilterAdd($word) {
try{
if(empty($word))
throw new Exception('敏感词不能为空');
$params['word'] = $word;
$ret = $this->curl('/wordfilter/add',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"wordfilterAdd",
"(",
"$",
"word",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"word",
")",
")",
"throw",
"new",
"Exception",
"(",
"'敏感词不能为空');",
"",
"",
"$",
"params",
"[",
"'word'",
"]",
"=",
"$",
"word",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/wordfilter/add'",
",",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 添加敏感词
@param $word 敏感词,最长不超过 32 个字符。(必传)
@return mixed | [
"添加敏感词"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L817-L829 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.chatroomUserGagAdd | public function chatroomUserGagAdd($userId,$chatroomId,$minute) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($chatroomId))
throw new Exception('聊天室 Id 不能为空');
if(empty($minute) || intval($minute)>43200)
throw new Exception('禁言时长不能为空,且最大值为43200');
$params['userId'] = $userId;
$params['chatroomId'] = $chatroomId;
$params['minute'] = $minute;
$ret = $this->curl('/chatroom/user/gag/add',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function chatroomUserGagAdd($userId,$chatroomId,$minute) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($chatroomId))
throw new Exception('聊天室 Id 不能为空');
if(empty($minute) || intval($minute)>43200)
throw new Exception('禁言时长不能为空,且最大值为43200');
$params['userId'] = $userId;
$params['chatroomId'] = $chatroomId;
$params['minute'] = $minute;
$ret = $this->curl('/chatroom/user/gag/add',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"chatroomUserGagAdd",
"(",
"$",
"userId",
",",
"$",
"chatroomId",
",",
"$",
"minute",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"chatroomId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'聊天室 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"minute",
")",
"||",
"intval",
"(",
"$",
"minute",
")",
">",
"43200",
")",
"throw",
"new",
"Exception",
"(",
"'禁言时长不能为空,且最大值为43200');",
"",
"",
"$",
"params",
"[",
"'userId'",
"]",
"=",
"$",
"userId",
";",
"$",
"params",
"[",
"'chatroomId'",
"]",
"=",
"$",
"chatroomId",
";",
"$",
"params",
"[",
"'minute'",
"]",
"=",
"$",
"minute",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/chatroom/user/gag/add'",
",",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 添加禁言聊天室成员 方法
@param $userId 用户 Id。(必传)
@param $chatroomId 聊天室 Id。(必传)
@param $minute 禁言时长,以分钟为单位,最大值为43200分钟。(必传)
@return mixed | [
"添加禁言聊天室成员",
"方法"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L871-L889 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.chatroomUserGagRollback | public function chatroomUserGagRollback($userId,$chatroomId) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($chatroomId))
throw new Exception('聊天室 Id 不能为空');
$params['userId'] = $userId;
$params['chatroomId'] = $chatroomId;
$ret = $this->curl('/chatroom/user/gag/rollback',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function chatroomUserGagRollback($userId,$chatroomId) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($chatroomId))
throw new Exception('聊天室 Id 不能为空');
$params['userId'] = $userId;
$params['chatroomId'] = $chatroomId;
$ret = $this->curl('/chatroom/user/gag/rollback',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"chatroomUserGagRollback",
"(",
"$",
"userId",
",",
"$",
"chatroomId",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"chatroomId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'聊天室 Id 不能为空');",
"",
"",
"$",
"params",
"[",
"'userId'",
"]",
"=",
"$",
"userId",
";",
"$",
"params",
"[",
"'chatroomId'",
"]",
"=",
"$",
"chatroomId",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/chatroom/user/gag/rollback'",
",",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 移除禁言聊天室成员 方法
@param $userId 用户 Id。(必传)
@param $chatroomId 聊天室 Id。(必传)
@return mixed | [
"移除禁言聊天室成员",
"方法"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L897-L912 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.chatroomUserGagList | public function chatroomUserGagList($chatroomId) {
try{
if(empty($chatroomId))
throw new Exception('聊天室 Id 不能为空');
$params['chatroomId'] = $chatroomId;
$ret = $this->curl('/chatroom/user/gag/list',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function chatroomUserGagList($chatroomId) {
try{
if(empty($chatroomId))
throw new Exception('聊天室 Id 不能为空');
$params['chatroomId'] = $chatroomId;
$ret = $this->curl('/chatroom/user/gag/list',$params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"chatroomUserGagList",
"(",
"$",
"chatroomId",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"chatroomId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'聊天室 Id 不能为空');",
"",
"",
"$",
"params",
"[",
"'chatroomId'",
"]",
"=",
"$",
"chatroomId",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/chatroom/user/gag/list'",
",",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 查询被禁言聊天室成员 方法
@param $chatroomId 聊天室 Id。(必传)
@return mixed | [
"查询被禁言聊天室成员",
"方法"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L918-L930 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.pushUserTagSet | public function pushUserTagSet($userId,$tags) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($tags))
throw new Exception('用户标签不能为空');
$params['userId'] = $userId;
$params['tags'] = $tags;
$ret = $this->curl('/user/tag/set',$params,'json');
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function pushUserTagSet($userId,$tags) {
try{
if(empty($userId))
throw new Exception('用户 Id 不能为空');
if(empty($tags))
throw new Exception('用户标签不能为空');
$params['userId'] = $userId;
$params['tags'] = $tags;
$ret = $this->curl('/user/tag/set',$params,'json');
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"pushUserTagSet",
"(",
"$",
"userId",
",",
"$",
"tags",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"userId",
")",
")",
"throw",
"new",
"Exception",
"(",
"'用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"tags",
")",
")",
"throw",
"new",
"Exception",
"(",
"'用户标签不能为空');",
"",
"",
"$",
"params",
"[",
"'userId'",
"]",
"=",
"$",
"userId",
";",
"$",
"params",
"[",
"'tags'",
"]",
"=",
"$",
"tags",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/user/tag/set'",
",",
"$",
"params",
",",
"'json'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 推送服务 添加标签 方法
@param string $userId 用户 Id。(必传)
@param array $tags 用户标签,一个用户最多添加 20 个标签,每个 tags 最大不能超过 40 个字节,标签中不能包含特殊字符。(必传)
@return mixed | [
"推送服务",
"添加标签",
"方法"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L1006-L1021 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.push | public function push( $platform,$audience,$notification ) {
try{
if(empty($platform))
throw new Exception('目标操作系统,ios、android 最少传递一个');
if(empty($audience))
throw new Exception('推送条件不能为空');
if( !isset($audience['is_to_all']) )
throw new Exception('是否全部推送不能为空');
if(empty($notification))
throw new Exception('推送消息内容不能为空');
if(empty($notification['alert']))
throw new Exception(' 默认推送消息内容不能为空');
$params['platform'] = $platform;
$params['audience'] = $audience;
$params['notification'] = $notification;
$ret = $this->curl('/push',$params,'json');
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function push( $platform,$audience,$notification ) {
try{
if(empty($platform))
throw new Exception('目标操作系统,ios、android 最少传递一个');
if(empty($audience))
throw new Exception('推送条件不能为空');
if( !isset($audience['is_to_all']) )
throw new Exception('是否全部推送不能为空');
if(empty($notification))
throw new Exception('推送消息内容不能为空');
if(empty($notification['alert']))
throw new Exception(' 默认推送消息内容不能为空');
$params['platform'] = $platform;
$params['audience'] = $audience;
$params['notification'] = $notification;
$ret = $this->curl('/push',$params,'json');
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"push",
"(",
"$",
"platform",
",",
"$",
"audience",
",",
"$",
"notification",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"platform",
")",
")",
"throw",
"new",
"Exception",
"(",
"'目标操作系统,ios、android 最少传递一个');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"audience",
")",
")",
"throw",
"new",
"Exception",
"(",
"'推送条件不能为空');",
"",
"",
"if",
"(",
"!",
"isset",
"(",
"$",
"audience",
"[",
"'is_to_all'",
"]",
")",
")",
"throw",
"new",
"Exception",
"(",
"'是否全部推送不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"notification",
")",
")",
"throw",
"new",
"Exception",
"(",
"'推送消息内容不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"notification",
"[",
"'alert'",
"]",
")",
")",
"throw",
"new",
"Exception",
"(",
"'\t默认推送消息内容不能为空');",
"",
"",
"$",
"params",
"[",
"'platform'",
"]",
"=",
"$",
"platform",
";",
"$",
"params",
"[",
"'audience'",
"]",
"=",
"$",
"audience",
";",
"$",
"params",
"[",
"'notification'",
"]",
"=",
"$",
"notification",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/push'",
",",
"$",
"params",
",",
"'json'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 推送服务 推送 方法
@param $platform 目标操作系统,ios、android 最少传递一个。如果需要给两个系统推送消息时,则需要全部填写。(必传)
@param $audience 推送条件,包括: tag 、 userid 、 is_to_all。(必传)
@param $audience[ tag ] 用户标签,每次发送时最多发送 20 个标签,标签之间为与的关系,is_to_all 为 true 时可不传。(非必传)
@param $audience[ userid ] 用户 Id,每次发送时最多发送 1000 个用户,如果 tag 和 userid 两个条件同时存在时,则以 userid 为准,如果 userid 有值时,则 platform 参数无效,is_to_all 为 true 时可不传。(非必传)
@param $audience[ is_to_all ] 是否全部推送,false 表示按 tag 或 userid 条件推送,true 表示向所有用户推送,tag 和 userid 两个条件无效。(必传)
@param $notification 按操作系统类型推送消息内容,如 platform 中设置了给 ios 和 android 系统推送消息,而在 notifications 中只设置了 ios 的推送内容,则 android 的推送内容为最初 alert 设置的内容。(非必传)
@param $notification[ alert ] 默认推送消息内容,如填写了 ios 或 android 下的 alert 时,则推送内容以对应平台系统的 alert 为准。(必传)
@param $notification[ ios ] 设置 iOS 平台下的推送及附加信息。(非必传)
@param $notification[ android ] 设置 Android 平台下的推送及附加信息。(非必传)
@param $notification[ ios ][ alert ] ios平台下的推送消息内容,传入后默认的推送消息内容失效,不能为空。(非必传)
@param $notification[ ios ][ extras ] ios平台下的附加信息,如果开发者自己需要,可以自己在 App 端进行解析。(非必传)
@param $notification[ android ][ alert ] android平台下的推送消息内容,传入后默认的推送消息内容失效,不能为空。(非必传)
@param $notification[ android ][ extras ] android平台下的附加信息,如果开发者自己需要,可以自己在 App 端进行解析。(非必传)
@return mixed | [
"推送服务",
"推送",
"方法"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L1040-L1062 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.pushMessage | public function pushMessage( $platform,$fromuserid,$audience,$message,$notification ) {
try{
if(empty($platform))
throw new Exception('目标操作系统,ios、android 最少传递一个');
if(empty($fromuserid))
throw new Exception('发送人用户 Id 不能为空');
if(empty($audience))
throw new Exception('推送条件不能为空');
if( !isset($audience['is_to_all']) )
throw new Exception('是否全部推送不能为空');
if(empty($message))
throw new Exception('消息内容不能为空');
if(empty($message['content']))
throw new Exception('发送消息内容不能为空');
if(empty($message['objectName']))
throw new Exception('消息类型不能为空');
if(empty($notification))
throw new Exception('推送消息内容不能为空');
if(empty($notification['alert']))
throw new Exception(' 默认推送消息内容不能为空');
$params['platform'] = $platform;
$params['audience'] = $audience;
$params['notification'] = $notification;
$ret = $this->curl('/push',$params,'json');
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | php | public function pushMessage( $platform,$fromuserid,$audience,$message,$notification ) {
try{
if(empty($platform))
throw new Exception('目标操作系统,ios、android 最少传递一个');
if(empty($fromuserid))
throw new Exception('发送人用户 Id 不能为空');
if(empty($audience))
throw new Exception('推送条件不能为空');
if( !isset($audience['is_to_all']) )
throw new Exception('是否全部推送不能为空');
if(empty($message))
throw new Exception('消息内容不能为空');
if(empty($message['content']))
throw new Exception('发送消息内容不能为空');
if(empty($message['objectName']))
throw new Exception('消息类型不能为空');
if(empty($notification))
throw new Exception('推送消息内容不能为空');
if(empty($notification['alert']))
throw new Exception(' 默认推送消息内容不能为空');
$params['platform'] = $platform;
$params['audience'] = $audience;
$params['notification'] = $notification;
$ret = $this->curl('/push',$params,'json');
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
} | [
"public",
"function",
"pushMessage",
"(",
"$",
"platform",
",",
"$",
"fromuserid",
",",
"$",
"audience",
",",
"$",
"message",
",",
"$",
"notification",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"platform",
")",
")",
"throw",
"new",
"Exception",
"(",
"'目标操作系统,ios、android 最少传递一个');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"fromuserid",
")",
")",
"throw",
"new",
"Exception",
"(",
"'发送人用户 Id 不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"audience",
")",
")",
"throw",
"new",
"Exception",
"(",
"'推送条件不能为空');",
"",
"",
"if",
"(",
"!",
"isset",
"(",
"$",
"audience",
"[",
"'is_to_all'",
"]",
")",
")",
"throw",
"new",
"Exception",
"(",
"'是否全部推送不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"message",
")",
")",
"throw",
"new",
"Exception",
"(",
"'消息内容不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"message",
"[",
"'content'",
"]",
")",
")",
"throw",
"new",
"Exception",
"(",
"'发送消息内容不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"message",
"[",
"'objectName'",
"]",
")",
")",
"throw",
"new",
"Exception",
"(",
"'消息类型不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"notification",
")",
")",
"throw",
"new",
"Exception",
"(",
"'推送消息内容不能为空');",
"",
"",
"if",
"(",
"empty",
"(",
"$",
"notification",
"[",
"'alert'",
"]",
")",
")",
"throw",
"new",
"Exception",
"(",
"'\t默认推送消息内容不能为空');",
"",
"",
"$",
"params",
"[",
"'platform'",
"]",
"=",
"$",
"platform",
";",
"$",
"params",
"[",
"'audience'",
"]",
"=",
"$",
"audience",
";",
"$",
"params",
"[",
"'notification'",
"]",
"=",
"$",
"notification",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"curl",
"(",
"'/push'",
",",
"$",
"params",
",",
"'json'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ret",
")",
")",
"throw",
"new",
"Exception",
"(",
"'请求失败');",
"",
"",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | 推送服务 推送消息 方法
@param $platform 目标操作系统,ios、android 最少传递一个。如果需要给两个系统推送消息时,则需要全部填写。(必传)
@param $fromuserid 发送人用户 Id。(必传)
@param $audience 推送条件,包括: tag 、 userid 、 is_to_all。(必传)
@param $audience[ tag ] 用户标签,每次发送时最多发送 20 个标签,标签之间为与的关系,is_to_all 为 true 时可不传。(非必传)
@param $audience[ userid ] 用户 Id,每次发送时最多发送 1000 个用户,如果 tag 和 userid 两个条件同时存在时,则以 userid 为准,如果 userid 有值时,则 platform 参数无效,is_to_all 为 true 时可不传。(非必传)
@param $audience[ is_to_all ] 是否全部推送,false 表示按 tag 或 userid 条件推送,true 表示向所有用户推送,tag 和 userid 两个条件无效。(必传)
@param $message[ content ] 发送消息内容,参考融云 Server API 消息类型表.示例说明;如果 objectName 为自定义消息类型,该参数可自定义格式。(必传)
@param $message[ objectName ] 消息类型,参考融云 Server API 消息类型表.消息标志;可自定义消息类型。(必传)
@param $notification 按操作系统类型推送消息内容,如 platform 中设置了给 ios 和 android 系统推送消息,而在 notifications 中只设置了 ios 的推送内容,则 android 的推送内容为最初 alert 设置的内容。(非必传)
@param $notification[ alert ] 默认推送消息内容,如填写了 ios 或 android 下的 alert 时,则推送内容以对应平台系统的 alert 为准。(必传)
@param $notification[ ios ] 设置 iOS 平台下的推送及附加信息。(非必传)
@param $notification[ android ] 设置 Android 平台下的推送及附加信息。(非必传)
@param $notification[ ios ][ alert ] ios平台下的推送消息内容,传入后默认的推送消息内容失效,不能为空。(非必传)
@param $notification[ ios ][ extras ] ios平台下的附加信息,如果开发者自己需要,可以自己在 App 端进行解析。(非必传)
@param $notification[ android ][ alert ] android平台下的推送消息内容,传入后默认的推送消息内容失效,不能为空。(非必传)
@param $notification[ android ][ extras ] android平台下的附加信息,如果开发者自己需要,可以自己在 App 端进行解析。(非必传)
@return mixed | [
"推送服务",
"推送消息",
"方法"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L1084-L1114 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.build_query | private function build_query($formData, $numericPrefix = '', $argSeparator = '&', $prefixKey = '') {
$str = '';
foreach ($formData as $key => $val) {
if (!is_array($val)) {
$str .= $argSeparator;
if ($prefixKey === '') {
if (is_int($key)) {
$str .= $numericPrefix;
}
$str .= urlencode($key) . '=' . urlencode($val);
} else {
$str .= urlencode($prefixKey) . '=' . urlencode($val);
}
} else {
if ($prefixKey == '') {
$prefixKey .= $key;
}
if (is_array($val[0])) {
$arr = array();
$arr[$key] = $val[0];
$str .= $argSeparator . http_build_query($arr);
} else {
$str .= $argSeparator . $this->build_query($val, $numericPrefix, $argSeparator, $prefixKey);
}
$prefixKey = '';
}
}
return substr($str, strlen($argSeparator));
} | php | private function build_query($formData, $numericPrefix = '', $argSeparator = '&', $prefixKey = '') {
$str = '';
foreach ($formData as $key => $val) {
if (!is_array($val)) {
$str .= $argSeparator;
if ($prefixKey === '') {
if (is_int($key)) {
$str .= $numericPrefix;
}
$str .= urlencode($key) . '=' . urlencode($val);
} else {
$str .= urlencode($prefixKey) . '=' . urlencode($val);
}
} else {
if ($prefixKey == '') {
$prefixKey .= $key;
}
if (is_array($val[0])) {
$arr = array();
$arr[$key] = $val[0];
$str .= $argSeparator . http_build_query($arr);
} else {
$str .= $argSeparator . $this->build_query($val, $numericPrefix, $argSeparator, $prefixKey);
}
$prefixKey = '';
}
}
return substr($str, strlen($argSeparator));
} | [
"private",
"function",
"build_query",
"(",
"$",
"formData",
",",
"$",
"numericPrefix",
"=",
"''",
",",
"$",
"argSeparator",
"=",
"'&'",
",",
"$",
"prefixKey",
"=",
"''",
")",
"{",
"$",
"str",
"=",
"''",
";",
"foreach",
"(",
"$",
"formData",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"$",
"str",
".=",
"$",
"argSeparator",
";",
"if",
"(",
"$",
"prefixKey",
"===",
"''",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"$",
"str",
".=",
"$",
"numericPrefix",
";",
"}",
"$",
"str",
".=",
"urlencode",
"(",
"$",
"key",
")",
".",
"'='",
".",
"urlencode",
"(",
"$",
"val",
")",
";",
"}",
"else",
"{",
"$",
"str",
".=",
"urlencode",
"(",
"$",
"prefixKey",
")",
".",
"'='",
".",
"urlencode",
"(",
"$",
"val",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"prefixKey",
"==",
"''",
")",
"{",
"$",
"prefixKey",
".=",
"$",
"key",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"val",
"[",
"0",
"]",
")",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"$",
"arr",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
"[",
"0",
"]",
";",
"$",
"str",
".=",
"$",
"argSeparator",
".",
"http_build_query",
"(",
"$",
"arr",
")",
";",
"}",
"else",
"{",
"$",
"str",
".=",
"$",
"argSeparator",
".",
"$",
"this",
"->",
"build_query",
"(",
"$",
"val",
",",
"$",
"numericPrefix",
",",
"$",
"argSeparator",
",",
"$",
"prefixKey",
")",
";",
"}",
"$",
"prefixKey",
"=",
"''",
";",
"}",
"}",
"return",
"substr",
"(",
"$",
"str",
",",
"strlen",
"(",
"$",
"argSeparator",
")",
")",
";",
"}"
] | 重写实现 http_build_query 提交实现(同名key)key=val1&key=val2
@param array $formData 数据数组
@param string $numericPrefix 数字索引时附加的Key前缀
@param string $argSeparator 参数分隔符(默认为&)
@param string $prefixKey Key 数组参数,实现同名方式调用接口
@return string | [
"重写实现",
"http_build_query",
"提交实现",
"(",
"同名key",
")",
"key",
"=",
"val1&key",
"=",
"val2"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L1141-L1169 |
aobozhang/rongcloud-facades | src/RongCloudClass.php | RongCloudClass.curl | public function curl($action, $params,$contentType='urlencoded') {
$action = self::SERVERAPIURL.$action.'.'.$this->format;
$httpHeader = $this->createHttpHeader();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $action);
curl_setopt($ch, CURLOPT_POST, 1);
if ($contentType=='urlencoded') {
$httpHeader[] = 'Content-Type:application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->build_query($params));
}
if ($contentType=='json') {
$httpHeader[] = 'Content-Type:Application/json';
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params) );
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false); //处理http证书问题
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$ret = curl_exec($ch);
if (false === $ret) {
$ret = curl_errno($ch);
}
curl_close($ch);
return $ret;
} | php | public function curl($action, $params,$contentType='urlencoded') {
$action = self::SERVERAPIURL.$action.'.'.$this->format;
$httpHeader = $this->createHttpHeader();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $action);
curl_setopt($ch, CURLOPT_POST, 1);
if ($contentType=='urlencoded') {
$httpHeader[] = 'Content-Type:application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->build_query($params));
}
if ($contentType=='json') {
$httpHeader[] = 'Content-Type:Application/json';
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params) );
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false); //处理http证书问题
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$ret = curl_exec($ch);
if (false === $ret) {
$ret = curl_errno($ch);
}
curl_close($ch);
return $ret;
} | [
"public",
"function",
"curl",
"(",
"$",
"action",
",",
"$",
"params",
",",
"$",
"contentType",
"=",
"'urlencoded'",
")",
"{",
"$",
"action",
"=",
"self",
"::",
"SERVERAPIURL",
".",
"$",
"action",
".",
"'.'",
".",
"$",
"this",
"->",
"format",
";",
"$",
"httpHeader",
"=",
"$",
"this",
"->",
"createHttpHeader",
"(",
")",
";",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"action",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POST",
",",
"1",
")",
";",
"if",
"(",
"$",
"contentType",
"==",
"'urlencoded'",
")",
"{",
"$",
"httpHeader",
"[",
"]",
"=",
"'Content-Type:application/x-www-form-urlencoded'",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"this",
"->",
"build_query",
"(",
"$",
"params",
")",
")",
";",
"}",
"if",
"(",
"$",
"contentType",
"==",
"'json'",
")",
"{",
"$",
"httpHeader",
"[",
"]",
"=",
"'Content-Type:Application/json'",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"json_encode",
"(",
"$",
"params",
")",
")",
";",
"}",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"httpHeader",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"false",
")",
";",
"//处理http证书问题",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HEADER",
",",
"false",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_TIMEOUT",
",",
"30",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_DNS_USE_GLOBAL_CACHE",
",",
"false",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"$",
"ret",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"false",
"===",
"$",
"ret",
")",
"{",
"$",
"ret",
"=",
"curl_errno",
"(",
"$",
"ch",
")",
";",
"}",
"curl_close",
"(",
"$",
"ch",
")",
";",
"return",
"$",
"ret",
";",
"}"
] | 发起 server 请求
@param $action
@param $params
@param $httpHeader
@return mixed | [
"发起",
"server",
"请求"
] | train | https://github.com/aobozhang/rongcloud-facades/blob/8b9a86f69f6fbf84ca204a7faeb6744edc910b8a/src/RongCloudClass.php#L1178-L1204 |
OKTOTV/OktolabMediaBundle | Controller/StreamController.php | StreamController.newAction | public function newAction(Request $request)
{
$stream = $this->get('oktolab_media_stream')->createStream();
$form = $this->createForm(StreamType::class, $stream);
$form->add(
'submit',
SubmitType::class,
[
'label' => 'oktolab_media.new_stream_button',
'attr' => ['class' => 'btn btn-primary']
]
);
if ($request->getMethod() == "POST") {
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($stream);
$em->flush();
$this->get('session')->getFlashBag()->add(
'success',
'oktolab_media.success_create_stream'
);
return $this->redirect(
$this->generateUrl(
'oktolab_media_stream_show',
['uniqID' => $stream->getUniqID()]
)
);
} else {
$this->get('session')->getFlashBag()->add(
'error',
'oktolab_media.error_create_stream'
);
}
}
return ['form' => $form->createView()];
} | php | public function newAction(Request $request)
{
$stream = $this->get('oktolab_media_stream')->createStream();
$form = $this->createForm(StreamType::class, $stream);
$form->add(
'submit',
SubmitType::class,
[
'label' => 'oktolab_media.new_stream_button',
'attr' => ['class' => 'btn btn-primary']
]
);
if ($request->getMethod() == "POST") {
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($stream);
$em->flush();
$this->get('session')->getFlashBag()->add(
'success',
'oktolab_media.success_create_stream'
);
return $this->redirect(
$this->generateUrl(
'oktolab_media_stream_show',
['uniqID' => $stream->getUniqID()]
)
);
} else {
$this->get('session')->getFlashBag()->add(
'error',
'oktolab_media.error_create_stream'
);
}
}
return ['form' => $form->createView()];
} | [
"public",
"function",
"newAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"stream",
"=",
"$",
"this",
"->",
"get",
"(",
"'oktolab_media_stream'",
")",
"->",
"createStream",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"StreamType",
"::",
"class",
",",
"$",
"stream",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'submit'",
",",
"SubmitType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"'oktolab_media.new_stream_button'",
",",
"'attr'",
"=>",
"[",
"'class'",
"=>",
"'btn btn-primary'",
"]",
"]",
")",
";",
"if",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
"==",
"\"POST\"",
")",
"{",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"stream",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'success'",
",",
"'oktolab_media.success_create_stream'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'oktolab_media_stream_show'",
",",
"[",
"'uniqID'",
"=>",
"$",
"stream",
"->",
"getUniqID",
"(",
")",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'error'",
",",
"'oktolab_media.error_create_stream'",
")",
";",
"}",
"}",
"return",
"[",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
"]",
";",
"}"
] | Creates a new Episode entity.
@Route("/", name="oktolab_media_stream_new")
@Method({"GET", "POST"})
@Template() | [
"Creates",
"a",
"new",
"Episode",
"entity",
"."
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Controller/StreamController.php#L32-L72 |
OKTOTV/OktolabMediaBundle | Controller/StreamController.php | StreamController.showAction | public function showAction($uniqID)
{
$em = $this->getDoctrine()->getManager();
$entity = $this->get('oktolab_media_stream')->getStream($uniqID);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Stream entity.');
}
return ['stream' => $entity];
} | php | public function showAction($uniqID)
{
$em = $this->getDoctrine()->getManager();
$entity = $this->get('oktolab_media_stream')->getStream($uniqID);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Stream entity.');
}
return ['stream' => $entity];
} | [
"public",
"function",
"showAction",
"(",
"$",
"uniqID",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"get",
"(",
"'oktolab_media_stream'",
")",
"->",
"getStream",
"(",
"$",
"uniqID",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find Stream entity.'",
")",
";",
"}",
"return",
"[",
"'stream'",
"=>",
"$",
"entity",
"]",
";",
"}"
] | Finds and displays a Episode entity.
@Route("/show/{uniqID}", name="oktolab_media_stream_show")
@Method("GET")
@Template() | [
"Finds",
"and",
"displays",
"a",
"Episode",
"entity",
"."
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Controller/StreamController.php#L99-L109 |
OKTOTV/OktolabMediaBundle | Controller/StreamController.php | StreamController.editAction | public function editAction(Request $request, $uniqID)
{
$stream = $this->get('oktolab_media_stream')->getStream($uniqID);
$form = $this->createForm(StreamType::class, $stream);
$form->add(
'submit',
SubmitType::class,
[
'label' => 'oktolab_media.edit_stream_button',
'attr' => ['class' => 'btn btn-primary']
]
);
$form->add(
'delete',
SubmitType::class,
[
'label' => 'oktolab_media.delete_stream_button',
'attr' => ['class' => 'btn btn-link']
]
);
if ($request->getMethod() == "POST") {
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
if ($form->get('submit')->isClicked()) {
$em->persist($stream);
$em->flush();
$this->get('session')->getFlashBag()->add(
'success',
'oktolab_media.success_edit_stream'
);
return $this->redirect(
$this->generateUrl(
'oktolab_media_stream_show',
['uniqID' => $stream->getUniqID()]
)
);
} elseif ($form->get('delete')->isClicked()) {
$em->remove(stream);
$em->flush();
$this->get('session')->getFlashBag()->add(
'error',
'oktolab_media.success_delete_stream'
);
return $this->redirect(
$this->generateUrl(
'oktolab_media_stream_index'
)
);
}
} else {
$this->get('session')->getFlashBag()->add(
'error',
'oktolab_media.error_edit_stream'
);
}
}
return ['form' => $form->createView()];
} | php | public function editAction(Request $request, $uniqID)
{
$stream = $this->get('oktolab_media_stream')->getStream($uniqID);
$form = $this->createForm(StreamType::class, $stream);
$form->add(
'submit',
SubmitType::class,
[
'label' => 'oktolab_media.edit_stream_button',
'attr' => ['class' => 'btn btn-primary']
]
);
$form->add(
'delete',
SubmitType::class,
[
'label' => 'oktolab_media.delete_stream_button',
'attr' => ['class' => 'btn btn-link']
]
);
if ($request->getMethod() == "POST") {
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
if ($form->get('submit')->isClicked()) {
$em->persist($stream);
$em->flush();
$this->get('session')->getFlashBag()->add(
'success',
'oktolab_media.success_edit_stream'
);
return $this->redirect(
$this->generateUrl(
'oktolab_media_stream_show',
['uniqID' => $stream->getUniqID()]
)
);
} elseif ($form->get('delete')->isClicked()) {
$em->remove(stream);
$em->flush();
$this->get('session')->getFlashBag()->add(
'error',
'oktolab_media.success_delete_stream'
);
return $this->redirect(
$this->generateUrl(
'oktolab_media_stream_index'
)
);
}
} else {
$this->get('session')->getFlashBag()->add(
'error',
'oktolab_media.error_edit_stream'
);
}
}
return ['form' => $form->createView()];
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"$",
"uniqID",
")",
"{",
"$",
"stream",
"=",
"$",
"this",
"->",
"get",
"(",
"'oktolab_media_stream'",
")",
"->",
"getStream",
"(",
"$",
"uniqID",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"StreamType",
"::",
"class",
",",
"$",
"stream",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'submit'",
",",
"SubmitType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"'oktolab_media.edit_stream_button'",
",",
"'attr'",
"=>",
"[",
"'class'",
"=>",
"'btn btn-primary'",
"]",
"]",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'delete'",
",",
"SubmitType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"'oktolab_media.delete_stream_button'",
",",
"'attr'",
"=>",
"[",
"'class'",
"=>",
"'btn btn-link'",
"]",
"]",
")",
";",
"if",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
"==",
"\"POST\"",
")",
"{",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"if",
"(",
"$",
"form",
"->",
"get",
"(",
"'submit'",
")",
"->",
"isClicked",
"(",
")",
")",
"{",
"$",
"em",
"->",
"persist",
"(",
"$",
"stream",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'success'",
",",
"'oktolab_media.success_edit_stream'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'oktolab_media_stream_show'",
",",
"[",
"'uniqID'",
"=>",
"$",
"stream",
"->",
"getUniqID",
"(",
")",
"]",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"form",
"->",
"get",
"(",
"'delete'",
")",
"->",
"isClicked",
"(",
")",
")",
"{",
"$",
"em",
"->",
"remove",
"(",
"stream",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'error'",
",",
"'oktolab_media.success_delete_stream'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'oktolab_media_stream_index'",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'error'",
",",
"'oktolab_media.error_edit_stream'",
")",
";",
"}",
"}",
"return",
"[",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
"]",
";",
"}"
] | Displays a form to edit an existing Episode entity.
@Route("/edit/{uniqID}", name="oktolab_media_stream_edit")
@Method("GET")
@Template() | [
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"Episode",
"entity",
"."
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Controller/StreamController.php#L118-L180 |
SergioMadness/query-builder | src/abstraction/UpdateBuilder.php | UpdateBuilder.generate | public function generate()
{
$result = '';
$table = $this->buildTable();
$fields = $this->buildFields();
$where = $this->buildWhere();
$result.='UPDATE '.$table.' SET '.$fields;
if ($where != '') {
$result.=' '.$where;
}
return $result;
} | php | public function generate()
{
$result = '';
$table = $this->buildTable();
$fields = $this->buildFields();
$where = $this->buildWhere();
$result.='UPDATE '.$table.' SET '.$fields;
if ($where != '') {
$result.=' '.$where;
}
return $result;
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"buildTable",
"(",
")",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"buildFields",
"(",
")",
";",
"$",
"where",
"=",
"$",
"this",
"->",
"buildWhere",
"(",
")",
";",
"$",
"result",
".=",
"'UPDATE '",
".",
"$",
"table",
".",
"' SET '",
".",
"$",
"fields",
";",
"if",
"(",
"$",
"where",
"!=",
"''",
")",
"{",
"$",
"result",
".=",
"' '",
".",
"$",
"where",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Generate query
@return string | [
"Generate",
"query"
] | train | https://github.com/SergioMadness/query-builder/blob/95b7a46bba4c4d369101c6f0d37f133fecb3956d/src/abstraction/UpdateBuilder.php#L20-L35 |
alevilar/ristorantino-vendor | Fidelization/Controller/ClientesController.php | ClientesController.index | public function index() {
$this->Prg->commonProcess();
$conds = $this->Cliente->parseCriteria( $this->Prg->parsedParams() );
$this->Cliente->recursive = 0;
$descuentoMaximo = Configure::read('Mozo.descuento_maximo');
$currentRole = $this->Session->read('Auth.User.role');
if ( strtolower($currentRole) == 'mozo' && is_numeric( $descuentoMaximo ) ) {
$conds['OR'] = array(
"Descuento.porcentaje <= $descuentoMaximo",
'Descuento.porcentaje IS NULL'
);
}
$this->Paginator->settings['conditions'] = $conds;
$descuentos = $this->Cliente->Descuento->find('list');
$tipoDocumentos = $this->Cliente->TipoDocumento->find('list');
$ivaResponsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
$this->set(compact('descuentos', 'tipoDocumentos', 'ivaResponsabilidades'));
$this->set('clientes', $this->Paginator->paginate());
$this->set('_serialize', array('clientes'));
} | php | public function index() {
$this->Prg->commonProcess();
$conds = $this->Cliente->parseCriteria( $this->Prg->parsedParams() );
$this->Cliente->recursive = 0;
$descuentoMaximo = Configure::read('Mozo.descuento_maximo');
$currentRole = $this->Session->read('Auth.User.role');
if ( strtolower($currentRole) == 'mozo' && is_numeric( $descuentoMaximo ) ) {
$conds['OR'] = array(
"Descuento.porcentaje <= $descuentoMaximo",
'Descuento.porcentaje IS NULL'
);
}
$this->Paginator->settings['conditions'] = $conds;
$descuentos = $this->Cliente->Descuento->find('list');
$tipoDocumentos = $this->Cliente->TipoDocumento->find('list');
$ivaResponsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
$this->set(compact('descuentos', 'tipoDocumentos', 'ivaResponsabilidades'));
$this->set('clientes', $this->Paginator->paginate());
$this->set('_serialize', array('clientes'));
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"this",
"->",
"Prg",
"->",
"commonProcess",
"(",
")",
";",
"$",
"conds",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"parseCriteria",
"(",
"$",
"this",
"->",
"Prg",
"->",
"parsedParams",
"(",
")",
")",
";",
"$",
"this",
"->",
"Cliente",
"->",
"recursive",
"=",
"0",
";",
"$",
"descuentoMaximo",
"=",
"Configure",
"::",
"read",
"(",
"'Mozo.descuento_maximo'",
")",
";",
"$",
"currentRole",
"=",
"$",
"this",
"->",
"Session",
"->",
"read",
"(",
"'Auth.User.role'",
")",
";",
"if",
"(",
"strtolower",
"(",
"$",
"currentRole",
")",
"==",
"'mozo'",
"&&",
"is_numeric",
"(",
"$",
"descuentoMaximo",
")",
")",
"{",
"$",
"conds",
"[",
"'OR'",
"]",
"=",
"array",
"(",
"\"Descuento.porcentaje <= $descuentoMaximo\"",
",",
"'Descuento.porcentaje IS NULL'",
")",
";",
"}",
"$",
"this",
"->",
"Paginator",
"->",
"settings",
"[",
"'conditions'",
"]",
"=",
"$",
"conds",
";",
"$",
"descuentos",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"Descuento",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"tipoDocumentos",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"TipoDocumento",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"ivaResponsabilidades",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"IvaResponsabilidad",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'descuentos'",
",",
"'tipoDocumentos'",
",",
"'ivaResponsabilidades'",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'clientes'",
",",
"$",
"this",
"->",
"Paginator",
"->",
"paginate",
"(",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'_serialize'",
",",
"array",
"(",
"'clientes'",
")",
")",
";",
"}"
] | index method
@return void | [
"index",
"method"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Fidelization/Controller/ClientesController.php#L25-L48 |
alevilar/ristorantino-vendor | Fidelization/Controller/ClientesController.php | ClientesController.simple_add | function simple_add() {
$this->pageTitle = 'Agregar Factura A';
$this->layout = false;
if (!empty($this->request->data)) {
$this->Cliente->create();
if ($this->Cliente->save($this->request->data)) {
$this->Session->setFlash(__('Se agregó un nuevo %s', Configure::read('Mesa.tituloCliente') ));
$this->set('cliente_id', $this->Cliente->id);
$this->Cliente->contain( array('Descuento', 'IvaResponsabilidad', 'TipoDocumento') );
$this->request->data = $this->Cliente->read();
$this->render('jqm_result');
} else {
$this->Session->setFlash(__('El %s no pudo ser gardado, intente nuevamente.', Configure::read('Mesa.tituloCliente')), 'Risto.flash_error');
throw new InternalErrorException("Error al guardar el cliente");
}
}
$tipo_documentos = $this->Cliente->TipoDocumento->find('list');
$iva_responsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
$descuentos = $this->Cliente->Descuento->find('list');
$tipoDocumentos = $this->Cliente->TipoDocumento->find('list');
$ivaResponsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
$this->set(compact('descuentos', 'tipoDocumentos', 'ivaResponsabilidades'));
} | php | function simple_add() {
$this->pageTitle = 'Agregar Factura A';
$this->layout = false;
if (!empty($this->request->data)) {
$this->Cliente->create();
if ($this->Cliente->save($this->request->data)) {
$this->Session->setFlash(__('Se agregó un nuevo %s', Configure::read('Mesa.tituloCliente') ));
$this->set('cliente_id', $this->Cliente->id);
$this->Cliente->contain( array('Descuento', 'IvaResponsabilidad', 'TipoDocumento') );
$this->request->data = $this->Cliente->read();
$this->render('jqm_result');
} else {
$this->Session->setFlash(__('El %s no pudo ser gardado, intente nuevamente.', Configure::read('Mesa.tituloCliente')), 'Risto.flash_error');
throw new InternalErrorException("Error al guardar el cliente");
}
}
$tipo_documentos = $this->Cliente->TipoDocumento->find('list');
$iva_responsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
$descuentos = $this->Cliente->Descuento->find('list');
$tipoDocumentos = $this->Cliente->TipoDocumento->find('list');
$ivaResponsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
$this->set(compact('descuentos', 'tipoDocumentos', 'ivaResponsabilidades'));
} | [
"function",
"simple_add",
"(",
")",
"{",
"$",
"this",
"->",
"pageTitle",
"=",
"'Agregar Factura A'",
";",
"$",
"this",
"->",
"layout",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
")",
"{",
"$",
"this",
"->",
"Cliente",
"->",
"create",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Cliente",
"->",
"save",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
")",
"{",
"$",
"this",
"->",
"Session",
"->",
"setFlash",
"(",
"__",
"(",
"'Se agregó un nuevo %s',",
" ",
"onfigure:",
":r",
"ead(",
"'",
"Mesa.tituloCliente')",
" ",
")",
";",
"",
"$",
"this",
"->",
"set",
"(",
"'cliente_id'",
",",
"$",
"this",
"->",
"Cliente",
"->",
"id",
")",
";",
"$",
"this",
"->",
"Cliente",
"->",
"contain",
"(",
"array",
"(",
"'Descuento'",
",",
"'IvaResponsabilidad'",
",",
"'TipoDocumento'",
")",
")",
";",
"$",
"this",
"->",
"request",
"->",
"data",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"read",
"(",
")",
";",
"$",
"this",
"->",
"render",
"(",
"'jqm_result'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Session",
"->",
"setFlash",
"(",
"__",
"(",
"'El %s no pudo ser gardado, intente nuevamente.'",
",",
"Configure",
"::",
"read",
"(",
"'Mesa.tituloCliente'",
")",
")",
",",
"'Risto.flash_error'",
")",
";",
"throw",
"new",
"InternalErrorException",
"(",
"\"Error al guardar el cliente\"",
")",
";",
"}",
"}",
"$",
"tipo_documentos",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"TipoDocumento",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"iva_responsabilidades",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"IvaResponsabilidad",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"descuentos",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"Descuento",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"tipoDocumentos",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"TipoDocumento",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"ivaResponsabilidades",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"IvaResponsabilidad",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'descuentos'",
",",
"'tipoDocumentos'",
",",
"'ivaResponsabilidades'",
")",
")",
";",
"}"
] | addFacturaA | [
"addFacturaA"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Fidelization/Controller/ClientesController.php#L66-L91 |
alevilar/ristorantino-vendor | Fidelization/Controller/ClientesController.php | ClientesController.add | public function add() {
if ($this->request->is('post')) {
$this->Cliente->create();
if ($this->Cliente->save($this->request->data)) {
$this->Session->setFlash(__('The %s has been saved.', Configure::read('Mesa.tituloCliente')));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The %s could not be saved. Please, try again.', Configure::read('Mesa.tituloCliente')));
}
}
$descuentos = $this->Cliente->Descuento->find('list');
$tipoDocumentos = $this->Cliente->TipoDocumento->find('list');
$ivaResponsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
$this->set(compact('descuentos', 'tipoDocumentos', 'ivaResponsabilidades'));
$this->render('form');
} | php | public function add() {
if ($this->request->is('post')) {
$this->Cliente->create();
if ($this->Cliente->save($this->request->data)) {
$this->Session->setFlash(__('The %s has been saved.', Configure::read('Mesa.tituloCliente')));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The %s could not be saved. Please, try again.', Configure::read('Mesa.tituloCliente')));
}
}
$descuentos = $this->Cliente->Descuento->find('list');
$tipoDocumentos = $this->Cliente->TipoDocumento->find('list');
$ivaResponsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
$this->set(compact('descuentos', 'tipoDocumentos', 'ivaResponsabilidades'));
$this->render('form');
} | [
"public",
"function",
"add",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'post'",
")",
")",
"{",
"$",
"this",
"->",
"Cliente",
"->",
"create",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Cliente",
"->",
"save",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
")",
"{",
"$",
"this",
"->",
"Session",
"->",
"setFlash",
"(",
"__",
"(",
"'The %s has been saved.'",
",",
"Configure",
"::",
"read",
"(",
"'Mesa.tituloCliente'",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"array",
"(",
"'action'",
"=>",
"'index'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Session",
"->",
"setFlash",
"(",
"__",
"(",
"'The %s could not be saved. Please, try again.'",
",",
"Configure",
"::",
"read",
"(",
"'Mesa.tituloCliente'",
")",
")",
")",
";",
"}",
"}",
"$",
"descuentos",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"Descuento",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"tipoDocumentos",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"TipoDocumento",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"ivaResponsabilidades",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"IvaResponsabilidad",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'descuentos'",
",",
"'tipoDocumentos'",
",",
"'ivaResponsabilidades'",
")",
")",
";",
"$",
"this",
"->",
"render",
"(",
"'form'",
")",
";",
"}"
] | add method
@return void | [
"add",
"method"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Fidelization/Controller/ClientesController.php#L100-L115 |
alevilar/ristorantino-vendor | Fidelization/Controller/ClientesController.php | ClientesController.edit | public function edit($id = null) {
if (!$this->Cliente->exists($id)) {
throw new NotFoundException(__('Invalid %s', Configure::read('Mesa.tituloCliente')));
}
if ($this->request->is(array('post', 'put'))) {
if ($this->Cliente->save($this->request->data)) {
$this->Session->setFlash(__('The %s has been saved.', Configure::read('Mesa.tituloCliente')));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The %s could not be saved. Please, try again.', Configure::read('Mesa.tituloCliente')));
}
} else {
$options = array('conditions' => array('Cliente.' . $this->Cliente->primaryKey => $id));
$this->request->data = $this->Cliente->find('first', $options);
}
$descuentos = $this->Cliente->Descuento->find('list');
$tipoDocumentos = $this->Cliente->TipoDocumento->find('list');
$ivaResponsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
$this->set(compact('descuentos', 'tipoDocumentos', 'ivaResponsabilidades'));
$this->render('form');
} | php | public function edit($id = null) {
if (!$this->Cliente->exists($id)) {
throw new NotFoundException(__('Invalid %s', Configure::read('Mesa.tituloCliente')));
}
if ($this->request->is(array('post', 'put'))) {
if ($this->Cliente->save($this->request->data)) {
$this->Session->setFlash(__('The %s has been saved.', Configure::read('Mesa.tituloCliente')));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The %s could not be saved. Please, try again.', Configure::read('Mesa.tituloCliente')));
}
} else {
$options = array('conditions' => array('Cliente.' . $this->Cliente->primaryKey => $id));
$this->request->data = $this->Cliente->find('first', $options);
}
$descuentos = $this->Cliente->Descuento->find('list');
$tipoDocumentos = $this->Cliente->TipoDocumento->find('list');
$ivaResponsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
$this->set(compact('descuentos', 'tipoDocumentos', 'ivaResponsabilidades'));
$this->render('form');
} | [
"public",
"function",
"edit",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"Cliente",
"->",
"exists",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"__",
"(",
"'Invalid %s'",
",",
"Configure",
"::",
"read",
"(",
"'Mesa.tituloCliente'",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"array",
"(",
"'post'",
",",
"'put'",
")",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"Cliente",
"->",
"save",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
")",
"{",
"$",
"this",
"->",
"Session",
"->",
"setFlash",
"(",
"__",
"(",
"'The %s has been saved.'",
",",
"Configure",
"::",
"read",
"(",
"'Mesa.tituloCliente'",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"array",
"(",
"'action'",
"=>",
"'index'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Session",
"->",
"setFlash",
"(",
"__",
"(",
"'The %s could not be saved. Please, try again.'",
",",
"Configure",
"::",
"read",
"(",
"'Mesa.tituloCliente'",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"options",
"=",
"array",
"(",
"'conditions'",
"=>",
"array",
"(",
"'Cliente.'",
".",
"$",
"this",
"->",
"Cliente",
"->",
"primaryKey",
"=>",
"$",
"id",
")",
")",
";",
"$",
"this",
"->",
"request",
"->",
"data",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"find",
"(",
"'first'",
",",
"$",
"options",
")",
";",
"}",
"$",
"descuentos",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"Descuento",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"tipoDocumentos",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"TipoDocumento",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"ivaResponsabilidades",
"=",
"$",
"this",
"->",
"Cliente",
"->",
"IvaResponsabilidad",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'descuentos'",
",",
"'tipoDocumentos'",
",",
"'ivaResponsabilidades'",
")",
")",
";",
"$",
"this",
"->",
"render",
"(",
"'form'",
")",
";",
"}"
] | edit method
@throws NotFoundException
@param string $id
@return void | [
"edit",
"method"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Fidelization/Controller/ClientesController.php#L124-L144 |
Danzabar/config-builder | src/Files/ConfigFile.php | ConfigFile.init | public function init($file)
{
try {
$this->load($file);
} catch (Exceptions\FileNotExists $e) {
$this->create($file);
}
} | php | public function init($file)
{
try {
$this->load($file);
} catch (Exceptions\FileNotExists $e) {
$this->create($file);
}
} | [
"public",
"function",
"init",
"(",
"$",
"file",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"load",
"(",
"$",
"file",
")",
";",
"}",
"catch",
"(",
"Exceptions",
"\\",
"FileNotExists",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"create",
"(",
"$",
"file",
")",
";",
"}",
"}"
] | Attempts loading a file, if its not there, it create its.
@param String $file
@return ConfigFile
@author Dan Cox | [
"Attempts",
"loading",
"a",
"file",
"if",
"its",
"not",
"there",
"it",
"create",
"its",
"."
] | train | https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/ConfigFile.php#L96-L106 |
Danzabar/config-builder | src/Files/ConfigFile.php | ConfigFile.load | public function load($file)
{
if(!$this->fs->exists($file))
{
throw new Exceptions\FileNotExists($file);
}
$this->file = $file;
$this->info->load($file);
$this->extension = $this->info->extension;
$this->directory = $this->info->directory;
$this->filename = $this->info->filename;
$this->extracter->load($file, $this->extension)
->extract();
$this->params = $this->extracter->params();
} | php | public function load($file)
{
if(!$this->fs->exists($file))
{
throw new Exceptions\FileNotExists($file);
}
$this->file = $file;
$this->info->load($file);
$this->extension = $this->info->extension;
$this->directory = $this->info->directory;
$this->filename = $this->info->filename;
$this->extracter->load($file, $this->extension)
->extract();
$this->params = $this->extracter->params();
} | [
"public",
"function",
"load",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fs",
"->",
"exists",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"FileNotExists",
"(",
"$",
"file",
")",
";",
"}",
"$",
"this",
"->",
"file",
"=",
"$",
"file",
";",
"$",
"this",
"->",
"info",
"->",
"load",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"extension",
"=",
"$",
"this",
"->",
"info",
"->",
"extension",
";",
"$",
"this",
"->",
"directory",
"=",
"$",
"this",
"->",
"info",
"->",
"directory",
";",
"$",
"this",
"->",
"filename",
"=",
"$",
"this",
"->",
"info",
"->",
"filename",
";",
"$",
"this",
"->",
"extracter",
"->",
"load",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"extension",
")",
"->",
"extract",
"(",
")",
";",
"$",
"this",
"->",
"params",
"=",
"$",
"this",
"->",
"extracter",
"->",
"params",
"(",
")",
";",
"}"
] | Loads the file and its details
@param String $file
@return ConfigFile
@author Dan Cox
@throws Exceptions\FileNotExists | [
"Loads",
"the",
"file",
"and",
"its",
"details"
] | train | https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/ConfigFile.php#L131-L148 |
Danzabar/config-builder | src/Files/ConfigFile.php | ConfigFile.saveAs | public function saveAs($extension = NULL)
{
$extension = (!is_null($extension) ? $extension : $this->extension);
$converter = $this->extracter->converter();
$converter->setExtension($extension);
$data = $converter->toNative($this->params);
// We need to rename the file's extension
$this->rename(NULL, $extension);
$this->fs->dumpFile($this->file, $data);
} | php | public function saveAs($extension = NULL)
{
$extension = (!is_null($extension) ? $extension : $this->extension);
$converter = $this->extracter->converter();
$converter->setExtension($extension);
$data = $converter->toNative($this->params);
// We need to rename the file's extension
$this->rename(NULL, $extension);
$this->fs->dumpFile($this->file, $data);
} | [
"public",
"function",
"saveAs",
"(",
"$",
"extension",
"=",
"NULL",
")",
"{",
"$",
"extension",
"=",
"(",
"!",
"is_null",
"(",
"$",
"extension",
")",
"?",
"$",
"extension",
":",
"$",
"this",
"->",
"extension",
")",
";",
"$",
"converter",
"=",
"$",
"this",
"->",
"extracter",
"->",
"converter",
"(",
")",
";",
"$",
"converter",
"->",
"setExtension",
"(",
"$",
"extension",
")",
";",
"$",
"data",
"=",
"$",
"converter",
"->",
"toNative",
"(",
"$",
"this",
"->",
"params",
")",
";",
"// We need to rename the file's extension",
"$",
"this",
"->",
"rename",
"(",
"NULL",
",",
"$",
"extension",
")",
";",
"$",
"this",
"->",
"fs",
"->",
"dumpFile",
"(",
"$",
"this",
"->",
"file",
",",
"$",
"data",
")",
";",
"}"
] | Save as a different extension
@param String $extension
@return void
@author Dan Cox | [
"Save",
"as",
"a",
"different",
"extension"
] | train | https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/ConfigFile.php#L168-L180 |
Danzabar/config-builder | src/Files/ConfigFile.php | ConfigFile.rename | public function rename($file = NULL, $extension = NULL)
{
$target = (!is_null($file) ? $this->filename : $this->extension);
$replacement = (!is_null($file) ? $file .'.'. $this->extension : $extension);
$this->file = str_replace($target, $replacement, $this->file);
} | php | public function rename($file = NULL, $extension = NULL)
{
$target = (!is_null($file) ? $this->filename : $this->extension);
$replacement = (!is_null($file) ? $file .'.'. $this->extension : $extension);
$this->file = str_replace($target, $replacement, $this->file);
} | [
"public",
"function",
"rename",
"(",
"$",
"file",
"=",
"NULL",
",",
"$",
"extension",
"=",
"NULL",
")",
"{",
"$",
"target",
"=",
"(",
"!",
"is_null",
"(",
"$",
"file",
")",
"?",
"$",
"this",
"->",
"filename",
":",
"$",
"this",
"->",
"extension",
")",
";",
"$",
"replacement",
"=",
"(",
"!",
"is_null",
"(",
"$",
"file",
")",
"?",
"$",
"file",
".",
"'.'",
".",
"$",
"this",
"->",
"extension",
":",
"$",
"extension",
")",
";",
"$",
"this",
"->",
"file",
"=",
"str_replace",
"(",
"$",
"target",
",",
"$",
"replacement",
",",
"$",
"this",
"->",
"file",
")",
";",
"}"
] | Renames a file or changes files extension
@param String $file
@param String $extension
@return void
@author Dan Cox | [
"Renames",
"a",
"file",
"or",
"changes",
"files",
"extension"
] | train | https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/ConfigFile.php#L190-L196 |
Danzabar/config-builder | src/Files/ConfigFile.php | ConfigFile.save | public function save()
{
$converter = $this->extracter->converter();
$data = $converter->toNative($this->params);
$this->fs->dumpFile($this->file, $data);
} | php | public function save()
{
$converter = $this->extracter->converter();
$data = $converter->toNative($this->params);
$this->fs->dumpFile($this->file, $data);
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"converter",
"=",
"$",
"this",
"->",
"extracter",
"->",
"converter",
"(",
")",
";",
"$",
"data",
"=",
"$",
"converter",
"->",
"toNative",
"(",
"$",
"this",
"->",
"params",
")",
";",
"$",
"this",
"->",
"fs",
"->",
"dumpFile",
"(",
"$",
"this",
"->",
"file",
",",
"$",
"data",
")",
";",
"}"
] | Saves the current params to the file
@return void
@author Dan Cox | [
"Saves",
"the",
"current",
"params",
"to",
"the",
"file"
] | train | https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/ConfigFile.php#L204-L210 |
hametuha/wpametu | src/WPametu/API/Rest/RestTemplate.php | RestTemplate.set_data | final protected function set_data($data, $key = ''){
if( empty($key) ){
if( is_array($data) ){
$this->data = array_merge($this->data, $data);
}
}else{
$this->data[$key] = $data;
}
} | php | final protected function set_data($data, $key = ''){
if( empty($key) ){
if( is_array($data) ){
$this->data = array_merge($this->data, $data);
}
}else{
$this->data[$key] = $data;
}
} | [
"final",
"protected",
"function",
"set_data",
"(",
"$",
"data",
",",
"$",
"key",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"data",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"data",
";",
"}",
"}"
] | Set data
@param array|mixed $data
@param string $key | [
"Set",
"data"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Rest/RestTemplate.php#L50-L58 |
hametuha/wpametu | src/WPametu/API/Rest/RestTemplate.php | RestTemplate.load_template | public function load_template($slug, $name = '', array $args = []){
if( !did_action('template_redirect') ){
do_action('template_redirect');
}
if( !$this->filtered ){
add_filter('wp_title', [$this, 'wp_title'], 10, 3);
}
parent::load_template($slug, $name, $this->data, $args);
} | php | public function load_template($slug, $name = '', array $args = []){
if( !did_action('template_redirect') ){
do_action('template_redirect');
}
if( !$this->filtered ){
add_filter('wp_title', [$this, 'wp_title'], 10, 3);
}
parent::load_template($slug, $name, $this->data, $args);
} | [
"public",
"function",
"load_template",
"(",
"$",
"slug",
",",
"$",
"name",
"=",
"''",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"did_action",
"(",
"'template_redirect'",
")",
")",
"{",
"do_action",
"(",
"'template_redirect'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"filtered",
")",
"{",
"add_filter",
"(",
"'wp_title'",
",",
"[",
"$",
"this",
",",
"'wp_title'",
"]",
",",
"10",
",",
"3",
")",
";",
"}",
"parent",
"::",
"load_template",
"(",
"$",
"slug",
",",
"$",
"name",
",",
"$",
"this",
"->",
"data",
",",
"$",
"args",
")",
";",
"}"
] | Template loader
@param string $slug
@param string $name
@param array $args | [
"Template",
"loader"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Rest/RestTemplate.php#L67-L75 |
hametuha/wpametu | src/WPametu/API/Rest/RestTemplate.php | RestTemplate.wp_title | public function wp_title($title, $sep, $location){
if( !empty($this->title) ){
$array = [$this->title];
$sep = ' '.trim($sep).' ';
if( 'right' == $location ){
$array[] = $sep;
}else{
array_unshift($array, $sep);
}
$title = implode('', $array);
}
return $title;
} | php | public function wp_title($title, $sep, $location){
if( !empty($this->title) ){
$array = [$this->title];
$sep = ' '.trim($sep).' ';
if( 'right' == $location ){
$array[] = $sep;
}else{
array_unshift($array, $sep);
}
$title = implode('', $array);
}
return $title;
} | [
"public",
"function",
"wp_title",
"(",
"$",
"title",
",",
"$",
"sep",
",",
"$",
"location",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"title",
")",
")",
"{",
"$",
"array",
"=",
"[",
"$",
"this",
"->",
"title",
"]",
";",
"$",
"sep",
"=",
"' '",
".",
"trim",
"(",
"$",
"sep",
")",
".",
"' '",
";",
"if",
"(",
"'right'",
"==",
"$",
"location",
")",
"{",
"$",
"array",
"[",
"]",
"=",
"$",
"sep",
";",
"}",
"else",
"{",
"array_unshift",
"(",
"$",
"array",
",",
"$",
"sep",
")",
";",
"}",
"$",
"title",
"=",
"implode",
"(",
"''",
",",
"$",
"array",
")",
";",
"}",
"return",
"$",
"title",
";",
"}"
] | Filter wp title
@param string $title
@param string $sep
@param string $location
@return string | [
"Filter",
"wp",
"title"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Rest/RestTemplate.php#L85-L97 |
hametuha/wpametu | src/WPametu/API/Rest/RestTemplate.php | RestTemplate.print_file | protected function print_file($path, $mime_type, $file_name = ''){
set_time_limit(0);
if( !$file_name ){
$file_name = basename($path);
}
foreach( array_merge(wp_get_nocache_headers(), [
'Content-Type' => $mime_type,
'Content-Disposition' => sprintf('attachment; filename="%s"', $file_name),
'Content-Length' => filesize($path),
]) as $header => $value){
header("{$header}: {$value}");
}
readfile($path);
exit;
} | php | protected function print_file($path, $mime_type, $file_name = ''){
set_time_limit(0);
if( !$file_name ){
$file_name = basename($path);
}
foreach( array_merge(wp_get_nocache_headers(), [
'Content-Type' => $mime_type,
'Content-Disposition' => sprintf('attachment; filename="%s"', $file_name),
'Content-Length' => filesize($path),
]) as $header => $value){
header("{$header}: {$value}");
}
readfile($path);
exit;
} | [
"protected",
"function",
"print_file",
"(",
"$",
"path",
",",
"$",
"mime_type",
",",
"$",
"file_name",
"=",
"''",
")",
"{",
"set_time_limit",
"(",
"0",
")",
";",
"if",
"(",
"!",
"$",
"file_name",
")",
"{",
"$",
"file_name",
"=",
"basename",
"(",
"$",
"path",
")",
";",
"}",
"foreach",
"(",
"array_merge",
"(",
"wp_get_nocache_headers",
"(",
")",
",",
"[",
"'Content-Type'",
"=>",
"$",
"mime_type",
",",
"'Content-Disposition'",
"=>",
"sprintf",
"(",
"'attachment; filename=\"%s\"'",
",",
"$",
"file_name",
")",
",",
"'Content-Length'",
"=>",
"filesize",
"(",
"$",
"path",
")",
",",
"]",
")",
"as",
"$",
"header",
"=>",
"$",
"value",
")",
"{",
"header",
"(",
"\"{$header}: {$value}\"",
")",
";",
"}",
"readfile",
"(",
"$",
"path",
")",
";",
"exit",
";",
"}"
] | Output file
@param string $path
@param string $mime_type
@param string $file_name | [
"Output",
"file"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Rest/RestTemplate.php#L128-L142 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.addBooleanField | public function addBooleanField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new BooleanField($propertyName, $dbFieldName));
} | php | public function addBooleanField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new BooleanField($propertyName, $dbFieldName));
} | [
"public",
"function",
"addBooleanField",
"(",
"string",
"$",
"propertyName",
",",
"string",
"$",
"dbFieldName",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addField",
"(",
"new",
"BooleanField",
"(",
"$",
"propertyName",
",",
"$",
"dbFieldName",
")",
")",
";",
"}"
] | @param string $propertyName
@param string|null $dbFieldName
@return $this | [
"@param",
"string",
"$propertyName",
"@param",
"string|null",
"$dbFieldName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L96-L99 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.addListField | public function addListField(
FieldMetadataInterface $itemMetadata,
string $propertyName,
string $dbFieldName = null
) {
return $this->addField(new ListField($itemMetadata, $propertyName, $dbFieldName));
} | php | public function addListField(
FieldMetadataInterface $itemMetadata,
string $propertyName,
string $dbFieldName = null
) {
return $this->addField(new ListField($itemMetadata, $propertyName, $dbFieldName));
} | [
"public",
"function",
"addListField",
"(",
"FieldMetadataInterface",
"$",
"itemMetadata",
",",
"string",
"$",
"propertyName",
",",
"string",
"$",
"dbFieldName",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addField",
"(",
"new",
"ListField",
"(",
"$",
"itemMetadata",
",",
"$",
"propertyName",
",",
"$",
"dbFieldName",
")",
")",
";",
"}"
] | @param FieldMetadataInterface $itemMetadata
@param string $propertyName
@param string|null $dbFieldName
@return $this | [
"@param",
"FieldMetadataInterface",
"$itemMetadata",
"@param",
"string",
"$propertyName",
"@param",
"string|null",
"$dbFieldName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L108-L114 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.addHashField | public function addHashField(
FieldMetadataInterface $itemMetadata,
string $propertyName,
string $dbFieldName = null
) {
return $this->addField(new HashField($itemMetadata, $propertyName, $dbFieldName));
} | php | public function addHashField(
FieldMetadataInterface $itemMetadata,
string $propertyName,
string $dbFieldName = null
) {
return $this->addField(new HashField($itemMetadata, $propertyName, $dbFieldName));
} | [
"public",
"function",
"addHashField",
"(",
"FieldMetadataInterface",
"$",
"itemMetadata",
",",
"string",
"$",
"propertyName",
",",
"string",
"$",
"dbFieldName",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addField",
"(",
"new",
"HashField",
"(",
"$",
"itemMetadata",
",",
"$",
"propertyName",
",",
"$",
"dbFieldName",
")",
")",
";",
"}"
] | @param FieldMetadataInterface $itemMetadata
@param string $propertyName
@param string|null $dbFieldName
@return ClassMetadata | [
"@param",
"FieldMetadataInterface",
"$itemMetadata",
"@param",
"string",
"$propertyName",
"@param",
"string|null",
"$dbFieldName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L123-L129 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.addDateField | public function addDateField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new DateField($propertyName, $dbFieldName));
} | php | public function addDateField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new DateField($propertyName, $dbFieldName));
} | [
"public",
"function",
"addDateField",
"(",
"string",
"$",
"propertyName",
",",
"string",
"$",
"dbFieldName",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addField",
"(",
"new",
"DateField",
"(",
"$",
"propertyName",
",",
"$",
"dbFieldName",
")",
")",
";",
"}"
] | @param string $propertyName
@param string $dbFieldName
@return $this | [
"@param",
"string",
"$propertyName",
"@param",
"string",
"$dbFieldName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L137-L140 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.addDocumentField | public function addDocumentField(string $documentClass, string $propertyName, string $dbFieldName = null)
{
return $this->addField(new DocumentField($documentClass, $propertyName, $dbFieldName));
} | php | public function addDocumentField(string $documentClass, string $propertyName, string $dbFieldName = null)
{
return $this->addField(new DocumentField($documentClass, $propertyName, $dbFieldName));
} | [
"public",
"function",
"addDocumentField",
"(",
"string",
"$",
"documentClass",
",",
"string",
"$",
"propertyName",
",",
"string",
"$",
"dbFieldName",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addField",
"(",
"new",
"DocumentField",
"(",
"$",
"documentClass",
",",
"$",
"propertyName",
",",
"$",
"dbFieldName",
")",
")",
";",
"}"
] | @param string $documentClass
@param string $propertyName
@param string $dbFieldName
@return $this | [
"@param",
"string",
"$documentClass",
"@param",
"string",
"$propertyName",
"@param",
"string",
"$dbFieldName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L149-L152 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.addFloatField | public function addFloatField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new FloatField($propertyName, $dbFieldName));
} | php | public function addFloatField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new FloatField($propertyName, $dbFieldName));
} | [
"public",
"function",
"addFloatField",
"(",
"string",
"$",
"propertyName",
",",
"string",
"$",
"dbFieldName",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addField",
"(",
"new",
"FloatField",
"(",
"$",
"propertyName",
",",
"$",
"dbFieldName",
")",
")",
";",
"}"
] | @param string $propertyName
@param string|null $dbFieldName
@return $this | [
"@param",
"string",
"$propertyName",
"@param",
"string|null",
"$dbFieldName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L160-L163 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.addObjectIdField | public function addObjectIdField(string $propertyName, string $dbFieldName = null, bool $generateIfNotSet = false)
{
return $this->addField(
new ObjectIdField($propertyName, $dbFieldName, $generateIfNotSet)
);
} | php | public function addObjectIdField(string $propertyName, string $dbFieldName = null, bool $generateIfNotSet = false)
{
return $this->addField(
new ObjectIdField($propertyName, $dbFieldName, $generateIfNotSet)
);
} | [
"public",
"function",
"addObjectIdField",
"(",
"string",
"$",
"propertyName",
",",
"string",
"$",
"dbFieldName",
"=",
"null",
",",
"bool",
"$",
"generateIfNotSet",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"addField",
"(",
"new",
"ObjectIdField",
"(",
"$",
"propertyName",
",",
"$",
"dbFieldName",
",",
"$",
"generateIfNotSet",
")",
")",
";",
"}"
] | @param string $propertyName
@param string $dbFieldName
@param bool $generateIfNotSet
@return $this | [
"@param",
"string",
"$propertyName",
"@param",
"string",
"$dbFieldName",
"@param",
"bool",
"$generateIfNotSet"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L172-L177 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.addIntegerField | public function addIntegerField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new IntegerField($propertyName, $dbFieldName));
} | php | public function addIntegerField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new IntegerField($propertyName, $dbFieldName));
} | [
"public",
"function",
"addIntegerField",
"(",
"string",
"$",
"propertyName",
",",
"string",
"$",
"dbFieldName",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addField",
"(",
"new",
"IntegerField",
"(",
"$",
"propertyName",
",",
"$",
"dbFieldName",
")",
")",
";",
"}"
] | @param string $propertyName
@param string|null $dbFieldName
@return $this | [
"@param",
"string",
"$propertyName",
"@param",
"string|null",
"$dbFieldName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L185-L188 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.addStringField | public function addStringField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new StringField($propertyName, $dbFieldName));
} | php | public function addStringField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new StringField($propertyName, $dbFieldName));
} | [
"public",
"function",
"addStringField",
"(",
"string",
"$",
"propertyName",
",",
"string",
"$",
"dbFieldName",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addField",
"(",
"new",
"StringField",
"(",
"$",
"propertyName",
",",
"$",
"dbFieldName",
")",
")",
";",
"}"
] | @param string $propertyName
@param string|null $dbFieldName
@return $this | [
"@param",
"string",
"$propertyName",
"@param",
"string|null",
"$dbFieldName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L196-L199 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.addRawField | public function addRawField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new RawField($propertyName, $dbFieldName));
} | php | public function addRawField(string $propertyName, string $dbFieldName = null)
{
return $this->addField(new RawField($propertyName, $dbFieldName));
} | [
"public",
"function",
"addRawField",
"(",
"string",
"$",
"propertyName",
",",
"string",
"$",
"dbFieldName",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addField",
"(",
"new",
"RawField",
"(",
"$",
"propertyName",
",",
"$",
"dbFieldName",
")",
")",
";",
"}"
] | @param string $propertyName
@param string|null $dbFieldName
@return ClassMetadata | [
"@param",
"string",
"$propertyName",
"@param",
"string|null",
"$dbFieldName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L207-L210 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.setNested | public function setNested(bool $nested = true)
{
if ($nested && (null !== $this->collectionName || null !== $this->collectionOptions)) {
$err = 'Document class "%s" cannot be nested if collection name or collection options had been specified.';
throw new LogicException(sprintf($err, $this->documentClass));
}
$this->nested = $nested;
return $this;
} | php | public function setNested(bool $nested = true)
{
if ($nested && (null !== $this->collectionName || null !== $this->collectionOptions)) {
$err = 'Document class "%s" cannot be nested if collection name or collection options had been specified.';
throw new LogicException(sprintf($err, $this->documentClass));
}
$this->nested = $nested;
return $this;
} | [
"public",
"function",
"setNested",
"(",
"bool",
"$",
"nested",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"nested",
"&&",
"(",
"null",
"!==",
"$",
"this",
"->",
"collectionName",
"||",
"null",
"!==",
"$",
"this",
"->",
"collectionOptions",
")",
")",
"{",
"$",
"err",
"=",
"'Document class \"%s\" cannot be nested if collection name or collection options had been specified.'",
";",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"$",
"err",
",",
"$",
"this",
"->",
"documentClass",
")",
")",
";",
"}",
"$",
"this",
"->",
"nested",
"=",
"$",
"nested",
";",
"return",
"$",
"this",
";",
"}"
] | @param bool $nested
@return $this | [
"@param",
"bool",
"$nested"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L225-L236 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.getFieldByPropertyName | public function getFieldByPropertyName(string $propertyName): ?FieldMetadataInterface
{
foreach ($this->fieldsMetadata as $fieldMetadata) {
if ($propertyName === $fieldMetadata->getPropertyName()) {
return $fieldMetadata;
}
}
return null;
} | php | public function getFieldByPropertyName(string $propertyName): ?FieldMetadataInterface
{
foreach ($this->fieldsMetadata as $fieldMetadata) {
if ($propertyName === $fieldMetadata->getPropertyName()) {
return $fieldMetadata;
}
}
return null;
} | [
"public",
"function",
"getFieldByPropertyName",
"(",
"string",
"$",
"propertyName",
")",
":",
"?",
"FieldMetadataInterface",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fieldsMetadata",
"as",
"$",
"fieldMetadata",
")",
"{",
"if",
"(",
"$",
"propertyName",
"===",
"$",
"fieldMetadata",
"->",
"getPropertyName",
"(",
")",
")",
"{",
"return",
"$",
"fieldMetadata",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | @param string $propertyName
@return FieldMetadataInterface | [
"@param",
"string",
"$propertyName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L243-L252 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.getFieldByDbName | public function getFieldByDbName(string $dbFieldName): ?FieldMetadataInterface
{
foreach ($this->fieldsMetadata as $fieldMetadata) {
if ($dbFieldName === $fieldMetadata->getDbFieldName()) {
return $fieldMetadata;
}
}
return null;
} | php | public function getFieldByDbName(string $dbFieldName): ?FieldMetadataInterface
{
foreach ($this->fieldsMetadata as $fieldMetadata) {
if ($dbFieldName === $fieldMetadata->getDbFieldName()) {
return $fieldMetadata;
}
}
return null;
} | [
"public",
"function",
"getFieldByDbName",
"(",
"string",
"$",
"dbFieldName",
")",
":",
"?",
"FieldMetadataInterface",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fieldsMetadata",
"as",
"$",
"fieldMetadata",
")",
"{",
"if",
"(",
"$",
"dbFieldName",
"===",
"$",
"fieldMetadata",
"->",
"getDbFieldName",
"(",
")",
")",
"{",
"return",
"$",
"fieldMetadata",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | @param string $dbFieldName
@return FieldMetadataInterface | [
"@param",
"string",
"$dbFieldName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L259-L268 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.setCollectionName | public function setCollectionName(string $collectionName)
{
if ($this->nested) {
throw new LogicException(
sprintf(
'Collection name cannot be set for nested document class "%s".',
$this->documentClass
)
);
}
$this->collectionName = $collectionName;
return $this;
} | php | public function setCollectionName(string $collectionName)
{
if ($this->nested) {
throw new LogicException(
sprintf(
'Collection name cannot be set for nested document class "%s".',
$this->documentClass
)
);
}
$this->collectionName = $collectionName;
return $this;
} | [
"public",
"function",
"setCollectionName",
"(",
"string",
"$",
"collectionName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"nested",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"'Collection name cannot be set for nested document class \"%s\".'",
",",
"$",
"this",
"->",
"documentClass",
")",
")",
";",
"}",
"$",
"this",
"->",
"collectionName",
"=",
"$",
"collectionName",
";",
"return",
"$",
"this",
";",
"}"
] | @param string $collectionName
@return $this | [
"@param",
"string",
"$collectionName"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L301-L315 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.setCollectionOptions | public function setCollectionOptions(array $collectionOptions)
{
if ($this->nested) {
throw new LogicException(
sprintf(
'Collection options cannot be set for nested document class "%s".',
$this->documentClass
)
);
}
$this->collectionOptions = $collectionOptions;
return $this;
} | php | public function setCollectionOptions(array $collectionOptions)
{
if ($this->nested) {
throw new LogicException(
sprintf(
'Collection options cannot be set for nested document class "%s".',
$this->documentClass
)
);
}
$this->collectionOptions = $collectionOptions;
return $this;
} | [
"public",
"function",
"setCollectionOptions",
"(",
"array",
"$",
"collectionOptions",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"nested",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"'Collection options cannot be set for nested document class \"%s\".'",
",",
"$",
"this",
"->",
"documentClass",
")",
")",
";",
"}",
"$",
"this",
"->",
"collectionOptions",
"=",
"$",
"collectionOptions",
";",
"return",
"$",
"this",
";",
"}"
] | @param array $collectionOptions
@return $this | [
"@param",
"array",
"$collectionOptions"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L346-L360 |
tequila/mongodb-odm | src/Metadata/ClassMetadata.php | ClassMetadata.getReflection | public function getReflection(): ClassReflection
{
if (null === $this->reflection) {
$this->reflection = new ClassReflection($this->documentClass);
}
return $this->reflection;
} | php | public function getReflection(): ClassReflection
{
if (null === $this->reflection) {
$this->reflection = new ClassReflection($this->documentClass);
}
return $this->reflection;
} | [
"public",
"function",
"getReflection",
"(",
")",
":",
"ClassReflection",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"reflection",
")",
"{",
"$",
"this",
"->",
"reflection",
"=",
"new",
"ClassReflection",
"(",
"$",
"this",
"->",
"documentClass",
")",
";",
"}",
"return",
"$",
"this",
"->",
"reflection",
";",
"}"
] | @return ClassReflection
@throws \ReflectionException | [
"@return",
"ClassReflection"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/ClassMetadata.php#L407-L414 |
dstuecken/notify | src/NotificationCenter.php | NotificationCenter.getRegisteredHandler | public function getRegisteredHandler($byClassName)
{
foreach ($this->handlers as $handler)
{
if (is_a($handler, $byClassName))
{
return $handler;
}
}
throw new \InvalidArgumentException('There is no handler named "' . $byClassName . '" registered.');
} | php | public function getRegisteredHandler($byClassName)
{
foreach ($this->handlers as $handler)
{
if (is_a($handler, $byClassName))
{
return $handler;
}
}
throw new \InvalidArgumentException('There is no handler named "' . $byClassName . '" registered.');
} | [
"public",
"function",
"getRegisteredHandler",
"(",
"$",
"byClassName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"handler",
",",
"$",
"byClassName",
")",
")",
"{",
"return",
"$",
"handler",
";",
"}",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'There is no handler named \"'",
".",
"$",
"byClassName",
".",
"'\" registered.'",
")",
";",
"}"
] | @param $byClassName
@return HandlerInterface | [
"@param",
"$byClassName"
] | train | https://github.com/dstuecken/notify/blob/abccf0a6a272caf66baea74323f18e2212c6e11e/src/NotificationCenter.php#L136-L147 |
dstuecken/notify | src/NotificationCenter.php | NotificationCenter.notify | public function notify(NotificationInterface $notification, $level = self::INFO)
{
if (!$this->handlers)
{
$this->addHandler(new NullHandler());
}
foreach ($this->getHandlers() as $handler)
{
if ($handler->shouldHandle($notification, $level))
{
if (false === $handler->handle($notification, $level))
{
return false;
}
}
}
return true;
} | php | public function notify(NotificationInterface $notification, $level = self::INFO)
{
if (!$this->handlers)
{
$this->addHandler(new NullHandler());
}
foreach ($this->getHandlers() as $handler)
{
if ($handler->shouldHandle($notification, $level))
{
if (false === $handler->handle($notification, $level))
{
return false;
}
}
}
return true;
} | [
"public",
"function",
"notify",
"(",
"NotificationInterface",
"$",
"notification",
",",
"$",
"level",
"=",
"self",
"::",
"INFO",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"handlers",
")",
"{",
"$",
"this",
"->",
"addHandler",
"(",
"new",
"NullHandler",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getHandlers",
"(",
")",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"->",
"shouldHandle",
"(",
"$",
"notification",
",",
"$",
"level",
")",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"handler",
"->",
"handle",
"(",
"$",
"notification",
",",
"$",
"level",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Handles notification for every handler
@param NotificationInterface $notification the notification instanceitself
@param int $level Level of this notification
@return bool | [
"Handles",
"notification",
"for",
"every",
"handler"
] | train | https://github.com/dstuecken/notify/blob/abccf0a6a272caf66baea74323f18e2212c6e11e/src/NotificationCenter.php#L157-L176 |
dstuecken/notify | src/NotificationCenter.php | NotificationCenter.log | public function log($level, $message, array $context = [])
{
return $this->notify(
new DetailedNotification($message, '', $context),
$level
);
} | php | public function log($level, $message, array $context = [])
{
return $this->notify(
new DetailedNotification($message, '', $context),
$level
);
} | [
"public",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"notify",
"(",
"new",
"DetailedNotification",
"(",
"$",
"message",
",",
"''",
",",
"$",
"context",
")",
",",
"$",
"level",
")",
";",
"}"
] | Adds a new notification message to the queue as an attribute aware notification
@param mixed $level The log level
@param string $message notification message (body)
@param array $context notification parameters
@return bool record processed or not? | [
"Adds",
"a",
"new",
"notification",
"message",
"to",
"the",
"queue",
"as",
"an",
"attribute",
"aware",
"notification"
] | train | https://github.com/dstuecken/notify/blob/abccf0a6a272caf66baea74323f18e2212c6e11e/src/NotificationCenter.php#L187-L193 |
tigron/skeleton-file | migration/20180626_141100_innodb.php | Migration_20180626_141100_Innodb.up | public function up() {
$db = Database::get();
$result = $db->get_row('show table status where NAME="file"', []);
if (isset($result['engine']) and $result['engine'] == 'InnoDB') {
return;
}
if (isset($result['Engine']) and $result['Engine'] == 'InnoDB') {
return;
}
$db->query("
ALTER TABLE `file` ENGINE='InnoDB';
", []);
} | php | public function up() {
$db = Database::get();
$result = $db->get_row('show table status where NAME="file"', []);
if (isset($result['engine']) and $result['engine'] == 'InnoDB') {
return;
}
if (isset($result['Engine']) and $result['Engine'] == 'InnoDB') {
return;
}
$db->query("
ALTER TABLE `file` ENGINE='InnoDB';
", []);
} | [
"public",
"function",
"up",
"(",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"get",
"(",
")",
";",
"$",
"result",
"=",
"$",
"db",
"->",
"get_row",
"(",
"'show table status where NAME=\"file\"'",
",",
"[",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'engine'",
"]",
")",
"and",
"$",
"result",
"[",
"'engine'",
"]",
"==",
"'InnoDB'",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'Engine'",
"]",
")",
"and",
"$",
"result",
"[",
"'Engine'",
"]",
"==",
"'InnoDB'",
")",
"{",
"return",
";",
"}",
"$",
"db",
"->",
"query",
"(",
"\"\n\t\t\tALTER TABLE `file` ENGINE='InnoDB';\n\t\t\"",
",",
"[",
"]",
")",
";",
"}"
] | Migrate up
@access public | [
"Migrate",
"up"
] | train | https://github.com/tigron/skeleton-file/blob/97978d49f179f07c76380ddc8919b8a7d56dee61/migration/20180626_141100_innodb.php#L21-L36 |
ekuiter/feature-php | FeaturePhp/Generator/RuntimeGenerator.php | RuntimeGenerator.encodeFeatureNames | private function encodeFeatureNames($artifacts) {
$featureNames = array();
foreach ($artifacts as $artifact) {
$featureName = $artifact->getFeature()->getName();
$featureNames[] = $featureName;
$this->logFile->log($artifact, "added runtime information in \"$this->target\"");
}
return str_replace("'", "\'", json_encode($featureNames));
} | php | private function encodeFeatureNames($artifacts) {
$featureNames = array();
foreach ($artifacts as $artifact) {
$featureName = $artifact->getFeature()->getName();
$featureNames[] = $featureName;
$this->logFile->log($artifact, "added runtime information in \"$this->target\"");
}
return str_replace("'", "\'", json_encode($featureNames));
} | [
"private",
"function",
"encodeFeatureNames",
"(",
"$",
"artifacts",
")",
"{",
"$",
"featureNames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"artifacts",
"as",
"$",
"artifact",
")",
"{",
"$",
"featureName",
"=",
"$",
"artifact",
"->",
"getFeature",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"featureNames",
"[",
"]",
"=",
"$",
"featureName",
";",
"$",
"this",
"->",
"logFile",
"->",
"log",
"(",
"$",
"artifact",
",",
"\"added runtime information in \\\"$this->target\\\"\"",
")",
";",
"}",
"return",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"json_encode",
"(",
"$",
"featureNames",
")",
")",
";",
"}"
] | Returns the JSON-encoded names of the corresponding features of some artifacts.
The JSON is assumed to then be enclosed in single quotes (').
@param \FeaturePhp\Artifact\Artifact[]
@return string | [
"Returns",
"the",
"JSON",
"-",
"encoded",
"names",
"of",
"the",
"corresponding",
"features",
"of",
"some",
"artifacts",
".",
"The",
"JSON",
"is",
"assumed",
"to",
"then",
"be",
"enclosed",
"in",
"single",
"quotes",
"(",
")",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/RuntimeGenerator.php#L71-L79 |
ekuiter/feature-php | FeaturePhp/Generator/RuntimeGenerator.php | RuntimeGenerator._generateFiles | protected function _generateFiles() {
if ($this->feature && !$this->isSelectedFeature($this->feature)) {
$this->logFile->log(null, "did not add runtime information because \"$this->feature\" is not selected");
return;
}
$this->files[] = fphp\File\TemplateFile::fromSpecification(
fphp\Specification\TemplateSpecification::fromArrayAndSettings(
array(
"source" => "Runtime.php.template",
"target" => $this->target,
"rules" => array(
array("assign" => "class", "to" => $this->class),
array("assign" => "getter", "to" => $this->getter),
array("assign" => "selectedFeatures", "to" => $this->encodeFeatureNames($this->selectedArtifacts)),
array("assign" => "deselectedFeatures", "to" => $this->encodeFeatureNames($this->deselectedArtifacts))
)
), Settings::inDirectory(__DIR__))
);
} | php | protected function _generateFiles() {
if ($this->feature && !$this->isSelectedFeature($this->feature)) {
$this->logFile->log(null, "did not add runtime information because \"$this->feature\" is not selected");
return;
}
$this->files[] = fphp\File\TemplateFile::fromSpecification(
fphp\Specification\TemplateSpecification::fromArrayAndSettings(
array(
"source" => "Runtime.php.template",
"target" => $this->target,
"rules" => array(
array("assign" => "class", "to" => $this->class),
array("assign" => "getter", "to" => $this->getter),
array("assign" => "selectedFeatures", "to" => $this->encodeFeatureNames($this->selectedArtifacts)),
array("assign" => "deselectedFeatures", "to" => $this->encodeFeatureNames($this->deselectedArtifacts))
)
), Settings::inDirectory(__DIR__))
);
} | [
"protected",
"function",
"_generateFiles",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"feature",
"&&",
"!",
"$",
"this",
"->",
"isSelectedFeature",
"(",
"$",
"this",
"->",
"feature",
")",
")",
"{",
"$",
"this",
"->",
"logFile",
"->",
"log",
"(",
"null",
",",
"\"did not add runtime information because \\\"$this->feature\\\" is not selected\"",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"files",
"[",
"]",
"=",
"fphp",
"\\",
"File",
"\\",
"TemplateFile",
"::",
"fromSpecification",
"(",
"fphp",
"\\",
"Specification",
"\\",
"TemplateSpecification",
"::",
"fromArrayAndSettings",
"(",
"array",
"(",
"\"source\"",
"=>",
"\"Runtime.php.template\"",
",",
"\"target\"",
"=>",
"$",
"this",
"->",
"target",
",",
"\"rules\"",
"=>",
"array",
"(",
"array",
"(",
"\"assign\"",
"=>",
"\"class\"",
",",
"\"to\"",
"=>",
"$",
"this",
"->",
"class",
")",
",",
"array",
"(",
"\"assign\"",
"=>",
"\"getter\"",
",",
"\"to\"",
"=>",
"$",
"this",
"->",
"getter",
")",
",",
"array",
"(",
"\"assign\"",
"=>",
"\"selectedFeatures\"",
",",
"\"to\"",
"=>",
"$",
"this",
"->",
"encodeFeatureNames",
"(",
"$",
"this",
"->",
"selectedArtifacts",
")",
")",
",",
"array",
"(",
"\"assign\"",
"=>",
"\"deselectedFeatures\"",
",",
"\"to\"",
"=>",
"$",
"this",
"->",
"encodeFeatureNames",
"(",
"$",
"this",
"->",
"deselectedArtifacts",
")",
")",
")",
")",
",",
"Settings",
"::",
"inDirectory",
"(",
"__DIR__",
")",
")",
")",
";",
"}"
] | Generates the runtime file.
Internally, this uses a template file and assigns the given variables.
You can override this to add runtime information for other languages.
If a feature was supplied, only generates if that feature is selected. | [
"Generates",
"the",
"runtime",
"file",
".",
"Internally",
"this",
"uses",
"a",
"template",
"file",
"and",
"assigns",
"the",
"given",
"variables",
".",
"You",
"can",
"override",
"this",
"to",
"add",
"runtime",
"information",
"for",
"other",
"languages",
".",
"If",
"a",
"feature",
"was",
"supplied",
"only",
"generates",
"if",
"that",
"feature",
"is",
"selected",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/RuntimeGenerator.php#L87-L106 |
ekuiter/feature-php | FeaturePhp/Generator/RuntimeGenerator.php | RuntimeGenerator.traceRuntimeCalls | public function traceRuntimeCalls($files, $productLine) {
$runtimeCalls = array();
foreach ($files as $file) {
$content = $file->getContent();
if ($content instanceof fphp\File\StoredFileContent) {
$fileSource = $content->getFileSource();
$content = file_get_contents($fileSource);
} else {
$fileSource = "(text file)";
$content = $content->getSummary();
}
foreach (explode("\n", $content) as $idx => $line)
if (strstr($line, "$this->class::$this->getter")) {
preg_match("/$this->class::$this->getter\(.*?[\"'](.*?)[\"'].*?\)/", $line, $matches);
try {
$feature = $productLine->getFeature($matches[1]);
} catch (fphp\Model\ModelException $e) {
throw new RuntimeGeneratorException("invalid runtime feature \"$matches[1]\"");
}
$runtimeCalls[] = new fphp\Artifact\TracingLink(
"runtime",
$productLine->getArtifact($feature),
new fphp\Artifact\LinePlace($fileSource, $idx + 1),
new fphp\Artifact\LinePlace($file->getTarget(), $idx + 1));
}
}
return $runtimeCalls;
} | php | public function traceRuntimeCalls($files, $productLine) {
$runtimeCalls = array();
foreach ($files as $file) {
$content = $file->getContent();
if ($content instanceof fphp\File\StoredFileContent) {
$fileSource = $content->getFileSource();
$content = file_get_contents($fileSource);
} else {
$fileSource = "(text file)";
$content = $content->getSummary();
}
foreach (explode("\n", $content) as $idx => $line)
if (strstr($line, "$this->class::$this->getter")) {
preg_match("/$this->class::$this->getter\(.*?[\"'](.*?)[\"'].*?\)/", $line, $matches);
try {
$feature = $productLine->getFeature($matches[1]);
} catch (fphp\Model\ModelException $e) {
throw new RuntimeGeneratorException("invalid runtime feature \"$matches[1]\"");
}
$runtimeCalls[] = new fphp\Artifact\TracingLink(
"runtime",
$productLine->getArtifact($feature),
new fphp\Artifact\LinePlace($fileSource, $idx + 1),
new fphp\Artifact\LinePlace($file->getTarget(), $idx + 1));
}
}
return $runtimeCalls;
} | [
"public",
"function",
"traceRuntimeCalls",
"(",
"$",
"files",
",",
"$",
"productLine",
")",
"{",
"$",
"runtimeCalls",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"content",
"=",
"$",
"file",
"->",
"getContent",
"(",
")",
";",
"if",
"(",
"$",
"content",
"instanceof",
"fphp",
"\\",
"File",
"\\",
"StoredFileContent",
")",
"{",
"$",
"fileSource",
"=",
"$",
"content",
"->",
"getFileSource",
"(",
")",
";",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"fileSource",
")",
";",
"}",
"else",
"{",
"$",
"fileSource",
"=",
"\"(text file)\"",
";",
"$",
"content",
"=",
"$",
"content",
"->",
"getSummary",
"(",
")",
";",
"}",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"content",
")",
"as",
"$",
"idx",
"=>",
"$",
"line",
")",
"if",
"(",
"strstr",
"(",
"$",
"line",
",",
"\"$this->class::$this->getter\"",
")",
")",
"{",
"preg_match",
"(",
"\"/$this->class::$this->getter\\(.*?[\\\"'](.*?)[\\\"'].*?\\)/\"",
",",
"$",
"line",
",",
"$",
"matches",
")",
";",
"try",
"{",
"$",
"feature",
"=",
"$",
"productLine",
"->",
"getFeature",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"catch",
"(",
"fphp",
"\\",
"Model",
"\\",
"ModelException",
"$",
"e",
")",
"{",
"throw",
"new",
"RuntimeGeneratorException",
"(",
"\"invalid runtime feature \\\"$matches[1]\\\"\"",
")",
";",
"}",
"$",
"runtimeCalls",
"[",
"]",
"=",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"TracingLink",
"(",
"\"runtime\"",
",",
"$",
"productLine",
"->",
"getArtifact",
"(",
"$",
"feature",
")",
",",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"LinePlace",
"(",
"$",
"fileSource",
",",
"$",
"idx",
"+",
"1",
")",
",",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"LinePlace",
"(",
"$",
"file",
"->",
"getTarget",
"(",
")",
",",
"$",
"idx",
"+",
"1",
")",
")",
";",
"}",
"}",
"return",
"$",
"runtimeCalls",
";",
"}"
] | Returns tracing links for all calls of the runtime class.
@param \FeaturePhp\File\File[] $files
@param \FeaturePhp\ProductLine\ProductLine $productLine
@return \FeaturePhp\Artifact\TracingLink[] | [
"Returns",
"tracing",
"links",
"for",
"all",
"calls",
"of",
"the",
"runtime",
"class",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/RuntimeGenerator.php#L114-L144 |
oroinc/OroLayoutComponent | Extension/DependencyInjection/DependencyInjectionExtension.php | DependencyInjectionExtension.getLayoutUpdates | public function getLayoutUpdates(LayoutItemInterface $item)
{
$idOrAlias = $item->getAlias() ?: $item->getId();
$layoutUpdates = [];
if (isset($this->layoutUpdateServiceIds[$idOrAlias])) {
foreach ($this->layoutUpdateServiceIds[$idOrAlias] as $serviceId) {
$layoutUpdates[] = $this->container->get($serviceId);
}
}
return $layoutUpdates;
} | php | public function getLayoutUpdates(LayoutItemInterface $item)
{
$idOrAlias = $item->getAlias() ?: $item->getId();
$layoutUpdates = [];
if (isset($this->layoutUpdateServiceIds[$idOrAlias])) {
foreach ($this->layoutUpdateServiceIds[$idOrAlias] as $serviceId) {
$layoutUpdates[] = $this->container->get($serviceId);
}
}
return $layoutUpdates;
} | [
"public",
"function",
"getLayoutUpdates",
"(",
"LayoutItemInterface",
"$",
"item",
")",
"{",
"$",
"idOrAlias",
"=",
"$",
"item",
"->",
"getAlias",
"(",
")",
"?",
":",
"$",
"item",
"->",
"getId",
"(",
")",
";",
"$",
"layoutUpdates",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"layoutUpdateServiceIds",
"[",
"$",
"idOrAlias",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"layoutUpdateServiceIds",
"[",
"$",
"idOrAlias",
"]",
"as",
"$",
"serviceId",
")",
"{",
"$",
"layoutUpdates",
"[",
"]",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"serviceId",
")",
";",
"}",
"}",
"return",
"$",
"layoutUpdates",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/DependencyInjection/DependencyInjectionExtension.php#L155-L167 |
oroinc/OroLayoutComponent | Extension/DependencyInjection/DependencyInjectionExtension.php | DependencyInjectionExtension.hasLayoutUpdates | public function hasLayoutUpdates(LayoutItemInterface $item)
{
$idOrAlias = $item->getAlias() ?: $item->getId();
return isset($this->layoutUpdateServiceIds[$idOrAlias]);
} | php | public function hasLayoutUpdates(LayoutItemInterface $item)
{
$idOrAlias = $item->getAlias() ?: $item->getId();
return isset($this->layoutUpdateServiceIds[$idOrAlias]);
} | [
"public",
"function",
"hasLayoutUpdates",
"(",
"LayoutItemInterface",
"$",
"item",
")",
"{",
"$",
"idOrAlias",
"=",
"$",
"item",
"->",
"getAlias",
"(",
")",
"?",
":",
"$",
"item",
"->",
"getId",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"layoutUpdateServiceIds",
"[",
"$",
"idOrAlias",
"]",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/DependencyInjection/DependencyInjectionExtension.php#L172-L177 |
oroinc/OroLayoutComponent | Extension/DependencyInjection/DependencyInjectionExtension.php | DependencyInjectionExtension.getContextConfigurators | public function getContextConfigurators()
{
$configurators = [];
foreach ($this->contextConfiguratorServiceIds as $serviceId) {
$configurators[] = $this->container->get($serviceId);
}
return $configurators;
} | php | public function getContextConfigurators()
{
$configurators = [];
foreach ($this->contextConfiguratorServiceIds as $serviceId) {
$configurators[] = $this->container->get($serviceId);
}
return $configurators;
} | [
"public",
"function",
"getContextConfigurators",
"(",
")",
"{",
"$",
"configurators",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"contextConfiguratorServiceIds",
"as",
"$",
"serviceId",
")",
"{",
"$",
"configurators",
"[",
"]",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"serviceId",
")",
";",
"}",
"return",
"$",
"configurators",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/DependencyInjection/DependencyInjectionExtension.php#L182-L191 |
oroinc/OroLayoutComponent | Extension/DependencyInjection/DependencyInjectionExtension.php | DependencyInjectionExtension.getDataProvider | public function getDataProvider($name)
{
if (!isset($this->dataProviderServiceIds[$name])) {
throw new Exception\InvalidArgumentException(
sprintf('The data provider "%s" is not registered with the service container.', $name)
);
}
return $this->container->get($this->dataProviderServiceIds[$name]);
} | php | public function getDataProvider($name)
{
if (!isset($this->dataProviderServiceIds[$name])) {
throw new Exception\InvalidArgumentException(
sprintf('The data provider "%s" is not registered with the service container.', $name)
);
}
return $this->container->get($this->dataProviderServiceIds[$name]);
} | [
"public",
"function",
"getDataProvider",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"dataProviderServiceIds",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The data provider \"%s\" is not registered with the service container.'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"this",
"->",
"dataProviderServiceIds",
"[",
"$",
"name",
"]",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/DependencyInjection/DependencyInjectionExtension.php#L204-L213 |
mustardandrew/muan-laravel-acl | src/Commands/Role/ClearPermissionCommand.php | ClearPermissionCommand.handle | public function handle()
{
$roleName = $this->argument('role');
if (! $role = Role::whereName($roleName)->first()) {
$this->warn("Role {$roleName} not exists.");
return 1;
}
$role->clearPermissions();
echo "Clear permissions. Done!", PHP_EOL;
return 0;
} | php | public function handle()
{
$roleName = $this->argument('role');
if (! $role = Role::whereName($roleName)->first()) {
$this->warn("Role {$roleName} not exists.");
return 1;
}
$role->clearPermissions();
echo "Clear permissions. Done!", PHP_EOL;
return 0;
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"roleName",
"=",
"$",
"this",
"->",
"argument",
"(",
"'role'",
")",
";",
"if",
"(",
"!",
"$",
"role",
"=",
"Role",
"::",
"whereName",
"(",
"$",
"roleName",
")",
"->",
"first",
"(",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Role {$roleName} not exists.\"",
")",
";",
"return",
"1",
";",
"}",
"$",
"role",
"->",
"clearPermissions",
"(",
")",
";",
"echo",
"\"Clear permissions. Done!\"",
",",
"PHP_EOL",
";",
"return",
"0",
";",
"}"
] | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Commands/Role/ClearPermissionCommand.php#L34-L47 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Model/Layout.php | Aoe_Layout_Model_Layout.generateXml | public function generateXml()
{
$xml = $this->getUpdate()->asSimplexml();
$removeInstructions = $xml->xpath("//remove");
if (is_array($removeInstructions)) {
foreach ($removeInstructions as $infoNode) {
/** @var Mage_Core_Model_Layout_Element $infoNode */
if (!$this->checkConditionals($infoNode, false)) {
continue;
}
$blockName = trim((string)$infoNode['name']);
if ($blockName) {
$ignoreNodes = $xml->xpath("//block[@name='" . $blockName . "'] | //reference[@name='" . $blockName . "']");
if (is_array($ignoreNodes)) {
foreach ($ignoreNodes as $ignoreNode) {
/** @var Mage_Core_Model_Layout_Element $ignoreNode */
$ignoreNode['ignore'] = true;
}
}
}
}
}
$this->setXml($xml);
return $this;
} | php | public function generateXml()
{
$xml = $this->getUpdate()->asSimplexml();
$removeInstructions = $xml->xpath("//remove");
if (is_array($removeInstructions)) {
foreach ($removeInstructions as $infoNode) {
/** @var Mage_Core_Model_Layout_Element $infoNode */
if (!$this->checkConditionals($infoNode, false)) {
continue;
}
$blockName = trim((string)$infoNode['name']);
if ($blockName) {
$ignoreNodes = $xml->xpath("//block[@name='" . $blockName . "'] | //reference[@name='" . $blockName . "']");
if (is_array($ignoreNodes)) {
foreach ($ignoreNodes as $ignoreNode) {
/** @var Mage_Core_Model_Layout_Element $ignoreNode */
$ignoreNode['ignore'] = true;
}
}
}
}
}
$this->setXml($xml);
return $this;
} | [
"public",
"function",
"generateXml",
"(",
")",
"{",
"$",
"xml",
"=",
"$",
"this",
"->",
"getUpdate",
"(",
")",
"->",
"asSimplexml",
"(",
")",
";",
"$",
"removeInstructions",
"=",
"$",
"xml",
"->",
"xpath",
"(",
"\"//remove\"",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"removeInstructions",
")",
")",
"{",
"foreach",
"(",
"$",
"removeInstructions",
"as",
"$",
"infoNode",
")",
"{",
"/** @var Mage_Core_Model_Layout_Element $infoNode */",
"if",
"(",
"!",
"$",
"this",
"->",
"checkConditionals",
"(",
"$",
"infoNode",
",",
"false",
")",
")",
"{",
"continue",
";",
"}",
"$",
"blockName",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"infoNode",
"[",
"'name'",
"]",
")",
";",
"if",
"(",
"$",
"blockName",
")",
"{",
"$",
"ignoreNodes",
"=",
"$",
"xml",
"->",
"xpath",
"(",
"\"//block[@name='\"",
".",
"$",
"blockName",
".",
"\"'] | //reference[@name='\"",
".",
"$",
"blockName",
".",
"\"']\"",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"ignoreNodes",
")",
")",
"{",
"foreach",
"(",
"$",
"ignoreNodes",
"as",
"$",
"ignoreNode",
")",
"{",
"/** @var Mage_Core_Model_Layout_Element $ignoreNode */",
"$",
"ignoreNode",
"[",
"'ignore'",
"]",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"setXml",
"(",
"$",
"xml",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Layout XML generation
@return Aoe_Layout_Model_Layout | [
"Layout",
"XML",
"generation"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L14-L38 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Model/Layout.php | Aoe_Layout_Model_Layout.generateBlocks | public function generateBlocks($parent = null)
{
if ($parent instanceof Mage_Core_Model_Layout_Element) {
// This prevents processing child blocks if the parent block fails a conditional check
if (!$this->checkConditionals($parent)) {
return;
}
// This is handled here so it catches 'block' and 'reference' elements
$this->processOutputAttribute($parent);
}
parent::generateBlocks($parent);
} | php | public function generateBlocks($parent = null)
{
if ($parent instanceof Mage_Core_Model_Layout_Element) {
// This prevents processing child blocks if the parent block fails a conditional check
if (!$this->checkConditionals($parent)) {
return;
}
// This is handled here so it catches 'block' and 'reference' elements
$this->processOutputAttribute($parent);
}
parent::generateBlocks($parent);
} | [
"public",
"function",
"generateBlocks",
"(",
"$",
"parent",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parent",
"instanceof",
"Mage_Core_Model_Layout_Element",
")",
"{",
"// This prevents processing child blocks if the parent block fails a conditional check",
"if",
"(",
"!",
"$",
"this",
"->",
"checkConditionals",
"(",
"$",
"parent",
")",
")",
"{",
"return",
";",
"}",
"// This is handled here so it catches 'block' and 'reference' elements",
"$",
"this",
"->",
"processOutputAttribute",
"(",
"$",
"parent",
")",
";",
"}",
"parent",
"::",
"generateBlocks",
"(",
"$",
"parent",
")",
";",
"}"
] | Create layout blocks hierarchy from layout xml configuration
@param Mage_Core_Model_Layout_Element|null $parent | [
"Create",
"layout",
"blocks",
"hierarchy",
"from",
"layout",
"xml",
"configuration"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L45-L58 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Model/Layout.php | Aoe_Layout_Model_Layout._generateBlock | protected function _generateBlock($node, $parent)
{
if ($node instanceof Mage_Core_Model_Layout_Element) {
if (!$this->checkConditionals($node)) {
return $this;
}
}
return parent::_generateBlock($node, $parent);
} | php | protected function _generateBlock($node, $parent)
{
if ($node instanceof Mage_Core_Model_Layout_Element) {
if (!$this->checkConditionals($node)) {
return $this;
}
}
return parent::_generateBlock($node, $parent);
} | [
"protected",
"function",
"_generateBlock",
"(",
"$",
"node",
",",
"$",
"parent",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Mage_Core_Model_Layout_Element",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"checkConditionals",
"(",
"$",
"node",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"}",
"return",
"parent",
"::",
"_generateBlock",
"(",
"$",
"node",
",",
"$",
"parent",
")",
";",
"}"
] | Add block object to layout based on xml node data
@param Varien_Simplexml_Element $node
@param Varien_Simplexml_Element $parent
@return Aoe_Layout_Model_Layout | [
"Add",
"block",
"object",
"to",
"layout",
"based",
"on",
"xml",
"node",
"data"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L68-L77 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Model/Layout.php | Aoe_Layout_Model_Layout._generateAction | protected function _generateAction($node, $parent)
{
if ($node instanceof Mage_Core_Model_Layout_Element) {
if (!$this->checkConditionals($node)) {
return $this;
}
}
$method = (string)$node['method'];
if (!empty($node['block'])) {
$parentName = (string)$node['block'];
} else {
$parentName = $parent->getBlockName();
}
$_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
Varien_Profiler::start($_profilerKey);
if (!empty($parentName)) {
$block = $this->getBlock($parentName);
}
if (!empty($block)) {
$args = (array)$node->children();
$jsonArgs = (isset($node['json']) ? explode(' ', (string)$node['json']) : []);
$jsonHelper = Mage::helper('core');
$translateArgs = (isset($node['translate']) ? explode(' ', (string)$node['translate']) : []);
$translateHelper = Mage::helper(isset($node['module']) ? (string)$node['module'] : 'core');
$args = $this->processActionArgs($args, $jsonArgs, $jsonHelper, $translateArgs, $translateHelper);
call_user_func_array([$block, $method], $args);
}
Varien_Profiler::stop($_profilerKey);
return $this;
} | php | protected function _generateAction($node, $parent)
{
if ($node instanceof Mage_Core_Model_Layout_Element) {
if (!$this->checkConditionals($node)) {
return $this;
}
}
$method = (string)$node['method'];
if (!empty($node['block'])) {
$parentName = (string)$node['block'];
} else {
$parentName = $parent->getBlockName();
}
$_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
Varien_Profiler::start($_profilerKey);
if (!empty($parentName)) {
$block = $this->getBlock($parentName);
}
if (!empty($block)) {
$args = (array)$node->children();
$jsonArgs = (isset($node['json']) ? explode(' ', (string)$node['json']) : []);
$jsonHelper = Mage::helper('core');
$translateArgs = (isset($node['translate']) ? explode(' ', (string)$node['translate']) : []);
$translateHelper = Mage::helper(isset($node['module']) ? (string)$node['module'] : 'core');
$args = $this->processActionArgs($args, $jsonArgs, $jsonHelper, $translateArgs, $translateHelper);
call_user_func_array([$block, $method], $args);
}
Varien_Profiler::stop($_profilerKey);
return $this;
} | [
"protected",
"function",
"_generateAction",
"(",
"$",
"node",
",",
"$",
"parent",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Mage_Core_Model_Layout_Element",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"checkConditionals",
"(",
"$",
"node",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"}",
"$",
"method",
"=",
"(",
"string",
")",
"$",
"node",
"[",
"'method'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"node",
"[",
"'block'",
"]",
")",
")",
"{",
"$",
"parentName",
"=",
"(",
"string",
")",
"$",
"node",
"[",
"'block'",
"]",
";",
"}",
"else",
"{",
"$",
"parentName",
"=",
"$",
"parent",
"->",
"getBlockName",
"(",
")",
";",
"}",
"$",
"_profilerKey",
"=",
"'BLOCK ACTION: '",
".",
"$",
"parentName",
".",
"' -> '",
".",
"$",
"method",
";",
"Varien_Profiler",
"::",
"start",
"(",
"$",
"_profilerKey",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parentName",
")",
")",
"{",
"$",
"block",
"=",
"$",
"this",
"->",
"getBlock",
"(",
"$",
"parentName",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"block",
")",
")",
"{",
"$",
"args",
"=",
"(",
"array",
")",
"$",
"node",
"->",
"children",
"(",
")",
";",
"$",
"jsonArgs",
"=",
"(",
"isset",
"(",
"$",
"node",
"[",
"'json'",
"]",
")",
"?",
"explode",
"(",
"' '",
",",
"(",
"string",
")",
"$",
"node",
"[",
"'json'",
"]",
")",
":",
"[",
"]",
")",
";",
"$",
"jsonHelper",
"=",
"Mage",
"::",
"helper",
"(",
"'core'",
")",
";",
"$",
"translateArgs",
"=",
"(",
"isset",
"(",
"$",
"node",
"[",
"'translate'",
"]",
")",
"?",
"explode",
"(",
"' '",
",",
"(",
"string",
")",
"$",
"node",
"[",
"'translate'",
"]",
")",
":",
"[",
"]",
")",
";",
"$",
"translateHelper",
"=",
"Mage",
"::",
"helper",
"(",
"isset",
"(",
"$",
"node",
"[",
"'module'",
"]",
")",
"?",
"(",
"string",
")",
"$",
"node",
"[",
"'module'",
"]",
":",
"'core'",
")",
";",
"$",
"args",
"=",
"$",
"this",
"->",
"processActionArgs",
"(",
"$",
"args",
",",
"$",
"jsonArgs",
",",
"$",
"jsonHelper",
",",
"$",
"translateArgs",
",",
"$",
"translateHelper",
")",
";",
"call_user_func_array",
"(",
"[",
"$",
"block",
",",
"$",
"method",
"]",
",",
"$",
"args",
")",
";",
"}",
"Varien_Profiler",
"::",
"stop",
"(",
"$",
"_profilerKey",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Convert an action node into a method call on the parent block
@param Varien_Simplexml_Element $node
@param Varien_Simplexml_Element $parent
@return Aoe_Layout_Model_Layout | [
"Convert",
"an",
"action",
"node",
"into",
"a",
"method",
"call",
"on",
"the",
"parent",
"block"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L87-L123 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Model/Layout.php | Aoe_Layout_Model_Layout.processActionArgs | protected function processActionArgs(array $args, $jsonArgs = [], $jsonHelper = null, $transArgs = [], $transHelper = null, $currentPath = '')
{
$jsonHelper = ((!is_null($jsonHelper) && method_exists($jsonHelper, 'jsonDecode')) ? $jsonHelper : Mage::helper('core'));
$transHelper = ((!is_null($transHelper) && method_exists($transHelper, '__')) ? $transHelper : Mage::helper('core'));
foreach ($args as $key => $arg) {
$path = $currentPath . $key;
if ($arg instanceof Mage_Core_Model_Layout_Element) {
// Process depth-first
if ($arg->hasChildren()) {
$children = $this->processActionArgs((array)$arg->children(), $jsonArgs, $jsonHelper, $transArgs, $transHelper, $path . '.');
}
// Attempt to process helpers
if (isset($children)) {
$tempArg = $children;
} else {
$tempArg = (string)$arg;
}
if (isset($arg['helper'])) {
$args[$key] = $this->getHelperMethodValue($arg['helper'], $tempArg);
} else {
$args[$key] = $tempArg;
}
unset($children);
}
if (is_string($args[$key]) && in_array($path, $jsonArgs)) {
$args[$key] = $jsonHelper->jsonDecode($args[$key]);
}
if (in_array($path, $transArgs)) {
if (is_string($args[$key])) {
$args[$key] = $transHelper->__($args[$key]);
} else {
$args[$key] = call_user_func_array([$transHelper, '__'], $args[$key]);
}
}
}
return $args;
} | php | protected function processActionArgs(array $args, $jsonArgs = [], $jsonHelper = null, $transArgs = [], $transHelper = null, $currentPath = '')
{
$jsonHelper = ((!is_null($jsonHelper) && method_exists($jsonHelper, 'jsonDecode')) ? $jsonHelper : Mage::helper('core'));
$transHelper = ((!is_null($transHelper) && method_exists($transHelper, '__')) ? $transHelper : Mage::helper('core'));
foreach ($args as $key => $arg) {
$path = $currentPath . $key;
if ($arg instanceof Mage_Core_Model_Layout_Element) {
// Process depth-first
if ($arg->hasChildren()) {
$children = $this->processActionArgs((array)$arg->children(), $jsonArgs, $jsonHelper, $transArgs, $transHelper, $path . '.');
}
// Attempt to process helpers
if (isset($children)) {
$tempArg = $children;
} else {
$tempArg = (string)$arg;
}
if (isset($arg['helper'])) {
$args[$key] = $this->getHelperMethodValue($arg['helper'], $tempArg);
} else {
$args[$key] = $tempArg;
}
unset($children);
}
if (is_string($args[$key]) && in_array($path, $jsonArgs)) {
$args[$key] = $jsonHelper->jsonDecode($args[$key]);
}
if (in_array($path, $transArgs)) {
if (is_string($args[$key])) {
$args[$key] = $transHelper->__($args[$key]);
} else {
$args[$key] = call_user_func_array([$transHelper, '__'], $args[$key]);
}
}
}
return $args;
} | [
"protected",
"function",
"processActionArgs",
"(",
"array",
"$",
"args",
",",
"$",
"jsonArgs",
"=",
"[",
"]",
",",
"$",
"jsonHelper",
"=",
"null",
",",
"$",
"transArgs",
"=",
"[",
"]",
",",
"$",
"transHelper",
"=",
"null",
",",
"$",
"currentPath",
"=",
"''",
")",
"{",
"$",
"jsonHelper",
"=",
"(",
"(",
"!",
"is_null",
"(",
"$",
"jsonHelper",
")",
"&&",
"method_exists",
"(",
"$",
"jsonHelper",
",",
"'jsonDecode'",
")",
")",
"?",
"$",
"jsonHelper",
":",
"Mage",
"::",
"helper",
"(",
"'core'",
")",
")",
";",
"$",
"transHelper",
"=",
"(",
"(",
"!",
"is_null",
"(",
"$",
"transHelper",
")",
"&&",
"method_exists",
"(",
"$",
"transHelper",
",",
"'__'",
")",
")",
"?",
"$",
"transHelper",
":",
"Mage",
"::",
"helper",
"(",
"'core'",
")",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"key",
"=>",
"$",
"arg",
")",
"{",
"$",
"path",
"=",
"$",
"currentPath",
".",
"$",
"key",
";",
"if",
"(",
"$",
"arg",
"instanceof",
"Mage_Core_Model_Layout_Element",
")",
"{",
"// Process depth-first",
"if",
"(",
"$",
"arg",
"->",
"hasChildren",
"(",
")",
")",
"{",
"$",
"children",
"=",
"$",
"this",
"->",
"processActionArgs",
"(",
"(",
"array",
")",
"$",
"arg",
"->",
"children",
"(",
")",
",",
"$",
"jsonArgs",
",",
"$",
"jsonHelper",
",",
"$",
"transArgs",
",",
"$",
"transHelper",
",",
"$",
"path",
".",
"'.'",
")",
";",
"}",
"// Attempt to process helpers",
"if",
"(",
"isset",
"(",
"$",
"children",
")",
")",
"{",
"$",
"tempArg",
"=",
"$",
"children",
";",
"}",
"else",
"{",
"$",
"tempArg",
"=",
"(",
"string",
")",
"$",
"arg",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"arg",
"[",
"'helper'",
"]",
")",
")",
"{",
"$",
"args",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"getHelperMethodValue",
"(",
"$",
"arg",
"[",
"'helper'",
"]",
",",
"$",
"tempArg",
")",
";",
"}",
"else",
"{",
"$",
"args",
"[",
"$",
"key",
"]",
"=",
"$",
"tempArg",
";",
"}",
"unset",
"(",
"$",
"children",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
")",
"&&",
"in_array",
"(",
"$",
"path",
",",
"$",
"jsonArgs",
")",
")",
"{",
"$",
"args",
"[",
"$",
"key",
"]",
"=",
"$",
"jsonHelper",
"->",
"jsonDecode",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"path",
",",
"$",
"transArgs",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"args",
"[",
"$",
"key",
"]",
"=",
"$",
"transHelper",
"->",
"__",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"$",
"args",
"[",
"$",
"key",
"]",
"=",
"call_user_func_array",
"(",
"[",
"$",
"transHelper",
",",
"'__'",
"]",
",",
"$",
"args",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"args",
";",
"}"
] | @param array $args
@param array $jsonArgs
@param null $jsonHelper
@param array $transArgs
@param null $transHelper
@param string $currentPath
@return array | [
"@param",
"array",
"$args",
"@param",
"array",
"$jsonArgs",
"@param",
"null",
"$jsonHelper",
"@param",
"array",
"$transArgs",
"@param",
"null",
"$transHelper",
"@param",
"string",
"$currentPath"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L135-L178 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Model/Layout.php | Aoe_Layout_Model_Layout.getHelperMethodValue | protected function getHelperMethodValue($helperMethodString, $args = null)
{
$helperName = explode('/', (string)$helperMethodString);
$helperMethod = array_pop($helperName);
$helperName = implode('/', $helperName);
$helperArgs = [];
if (!is_array($args)) {
$helperArgs[] = $args;
} else {
$helperArgs = $args;
}
return call_user_func_array([Mage::helper($helperName), $helperMethod], $helperArgs);
} | php | protected function getHelperMethodValue($helperMethodString, $args = null)
{
$helperName = explode('/', (string)$helperMethodString);
$helperMethod = array_pop($helperName);
$helperName = implode('/', $helperName);
$helperArgs = [];
if (!is_array($args)) {
$helperArgs[] = $args;
} else {
$helperArgs = $args;
}
return call_user_func_array([Mage::helper($helperName), $helperMethod], $helperArgs);
} | [
"protected",
"function",
"getHelperMethodValue",
"(",
"$",
"helperMethodString",
",",
"$",
"args",
"=",
"null",
")",
"{",
"$",
"helperName",
"=",
"explode",
"(",
"'/'",
",",
"(",
"string",
")",
"$",
"helperMethodString",
")",
";",
"$",
"helperMethod",
"=",
"array_pop",
"(",
"$",
"helperName",
")",
";",
"$",
"helperName",
"=",
"implode",
"(",
"'/'",
",",
"$",
"helperName",
")",
";",
"$",
"helperArgs",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"args",
")",
")",
"{",
"$",
"helperArgs",
"[",
"]",
"=",
"$",
"args",
";",
"}",
"else",
"{",
"$",
"helperArgs",
"=",
"$",
"args",
";",
"}",
"return",
"call_user_func_array",
"(",
"[",
"Mage",
"::",
"helper",
"(",
"$",
"helperName",
")",
",",
"$",
"helperMethod",
"]",
",",
"$",
"helperArgs",
")",
";",
"}"
] | Gets the value of a helper method from the helper method string
@param $helperMethodString
@param array|string $args
@return mixed | [
"Gets",
"the",
"value",
"of",
"a",
"helper",
"method",
"from",
"the",
"helper",
"method",
"string"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L188-L202 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Model/Layout.php | Aoe_Layout_Model_Layout.processOutputAttribute | protected function processOutputAttribute(Mage_Core_Model_Layout_Element $node)
{
if (isset($node['output'])) {
$blockName = (string)$node['name'];
if (empty($blockName)) {
return;
}
$method = trim((string)$node['output']);
if (empty($method)) {
$this->removeOutputBlock($blockName);
} else {
$this->addOutputBlock($blockName, $method);
}
}
} | php | protected function processOutputAttribute(Mage_Core_Model_Layout_Element $node)
{
if (isset($node['output'])) {
$blockName = (string)$node['name'];
if (empty($blockName)) {
return;
}
$method = trim((string)$node['output']);
if (empty($method)) {
$this->removeOutputBlock($blockName);
} else {
$this->addOutputBlock($blockName, $method);
}
}
} | [
"protected",
"function",
"processOutputAttribute",
"(",
"Mage_Core_Model_Layout_Element",
"$",
"node",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"node",
"[",
"'output'",
"]",
")",
")",
"{",
"$",
"blockName",
"=",
"(",
"string",
")",
"$",
"node",
"[",
"'name'",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"blockName",
")",
")",
"{",
"return",
";",
"}",
"$",
"method",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"node",
"[",
"'output'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"method",
")",
")",
"{",
"$",
"this",
"->",
"removeOutputBlock",
"(",
"$",
"blockName",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addOutputBlock",
"(",
"$",
"blockName",
",",
"$",
"method",
")",
";",
"}",
"}",
"}"
] | Process the 'output' attribute of a node
This is an extension that allows the output attribute to be specified on reference elements.
It also adds the ability to disable output of the node by setting the value to an empty string.
@param Mage_Core_Model_Layout_Element $node | [
"Process",
"the",
"output",
"attribute",
"of",
"a",
"node"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L212-L226 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Model/Layout.php | Aoe_Layout_Model_Layout.checkConditionals | protected function checkConditionals(Mage_Core_Model_Layout_Element $node, $aclDefault = true)
{
return $this->checkConfigConditional($node)
&& ($aclDefault ? $this->checkAclConditional($node, $aclDefault) : !$this->checkAclConditional($node, $aclDefault))
&& $this->checkHelperConditional($node);
} | php | protected function checkConditionals(Mage_Core_Model_Layout_Element $node, $aclDefault = true)
{
return $this->checkConfigConditional($node)
&& ($aclDefault ? $this->checkAclConditional($node, $aclDefault) : !$this->checkAclConditional($node, $aclDefault))
&& $this->checkHelperConditional($node);
} | [
"protected",
"function",
"checkConditionals",
"(",
"Mage_Core_Model_Layout_Element",
"$",
"node",
",",
"$",
"aclDefault",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"checkConfigConditional",
"(",
"$",
"node",
")",
"&&",
"(",
"$",
"aclDefault",
"?",
"$",
"this",
"->",
"checkAclConditional",
"(",
"$",
"node",
",",
"$",
"aclDefault",
")",
":",
"!",
"$",
"this",
"->",
"checkAclConditional",
"(",
"$",
"node",
",",
"$",
"aclDefault",
")",
")",
"&&",
"$",
"this",
"->",
"checkHelperConditional",
"(",
"$",
"node",
")",
";",
"}"
] | Checks all conditionals for a given layout node
@param Mage_Core_Model_Layout_Element $node
@param bool $aclDefault
@return bool | [
"Checks",
"all",
"conditionals",
"for",
"a",
"given",
"layout",
"node"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L236-L241 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Model/Layout.php | Aoe_Layout_Model_Layout.checkConfigConditional | protected function checkConfigConditional(Mage_Core_Model_Layout_Element $node)
{
if (isset($node['ifconfig']) && ($configPath = trim((string)$node['ifconfig']))) {
$negativeCheck = (substr($configPath, 0, 1) === '!');
$configPath = ($negativeCheck ? substr($configPath, 1) : $configPath);
if (Mage::getStoreConfigFlag($configPath) === $negativeCheck) {
return false;
}
}
// This is to support compatibility with the Aoe_LayoutConditions module
if (isset($node['unlessconfig']) && ($configPath = trim((string)$node['unlessconfig']))) {
if (Mage::getStoreConfigFlag($configPath)) {
return false;
}
}
return true;
} | php | protected function checkConfigConditional(Mage_Core_Model_Layout_Element $node)
{
if (isset($node['ifconfig']) && ($configPath = trim((string)$node['ifconfig']))) {
$negativeCheck = (substr($configPath, 0, 1) === '!');
$configPath = ($negativeCheck ? substr($configPath, 1) : $configPath);
if (Mage::getStoreConfigFlag($configPath) === $negativeCheck) {
return false;
}
}
// This is to support compatibility with the Aoe_LayoutConditions module
if (isset($node['unlessconfig']) && ($configPath = trim((string)$node['unlessconfig']))) {
if (Mage::getStoreConfigFlag($configPath)) {
return false;
}
}
return true;
} | [
"protected",
"function",
"checkConfigConditional",
"(",
"Mage_Core_Model_Layout_Element",
"$",
"node",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"node",
"[",
"'ifconfig'",
"]",
")",
"&&",
"(",
"$",
"configPath",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"node",
"[",
"'ifconfig'",
"]",
")",
")",
")",
"{",
"$",
"negativeCheck",
"=",
"(",
"substr",
"(",
"$",
"configPath",
",",
"0",
",",
"1",
")",
"===",
"'!'",
")",
";",
"$",
"configPath",
"=",
"(",
"$",
"negativeCheck",
"?",
"substr",
"(",
"$",
"configPath",
",",
"1",
")",
":",
"$",
"configPath",
")",
";",
"if",
"(",
"Mage",
"::",
"getStoreConfigFlag",
"(",
"$",
"configPath",
")",
"===",
"$",
"negativeCheck",
")",
"{",
"return",
"false",
";",
"}",
"}",
"// This is to support compatibility with the Aoe_LayoutConditions module",
"if",
"(",
"isset",
"(",
"$",
"node",
"[",
"'unlessconfig'",
"]",
")",
"&&",
"(",
"$",
"configPath",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"node",
"[",
"'unlessconfig'",
"]",
")",
")",
")",
"{",
"if",
"(",
"Mage",
"::",
"getStoreConfigFlag",
"(",
"$",
"configPath",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Process the 'ifconfig' and 'unlessconfig' attributes to possibly disable a block/reference/action
@param Mage_Core_Model_Layout_Element $node
@return bool | [
"Process",
"the",
"ifconfig",
"and",
"unlessconfig",
"attributes",
"to",
"possibly",
"disable",
"a",
"block",
"/",
"reference",
"/",
"action"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L250-L268 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Model/Layout.php | Aoe_Layout_Model_Layout.checkAclConditional | protected function checkAclConditional(Mage_Core_Model_Layout_Element $node, $default = true)
{
if (isset($node['acl']) && ($aclPath = trim((string)$node['acl']))) {
$negativeCheck = (substr($aclPath, 0, 1) === '!');
$aclPath = ($negativeCheck ? substr($aclPath, 1) : $aclPath);
if (Mage::getSingleton('admin/session')->isAllowed($aclPath) === $negativeCheck) {
return false;
} else {
return true;
}
}
return (bool)$default;
} | php | protected function checkAclConditional(Mage_Core_Model_Layout_Element $node, $default = true)
{
if (isset($node['acl']) && ($aclPath = trim((string)$node['acl']))) {
$negativeCheck = (substr($aclPath, 0, 1) === '!');
$aclPath = ($negativeCheck ? substr($aclPath, 1) : $aclPath);
if (Mage::getSingleton('admin/session')->isAllowed($aclPath) === $negativeCheck) {
return false;
} else {
return true;
}
}
return (bool)$default;
} | [
"protected",
"function",
"checkAclConditional",
"(",
"Mage_Core_Model_Layout_Element",
"$",
"node",
",",
"$",
"default",
"=",
"true",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"node",
"[",
"'acl'",
"]",
")",
"&&",
"(",
"$",
"aclPath",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"node",
"[",
"'acl'",
"]",
")",
")",
")",
"{",
"$",
"negativeCheck",
"=",
"(",
"substr",
"(",
"$",
"aclPath",
",",
"0",
",",
"1",
")",
"===",
"'!'",
")",
";",
"$",
"aclPath",
"=",
"(",
"$",
"negativeCheck",
"?",
"substr",
"(",
"$",
"aclPath",
",",
"1",
")",
":",
"$",
"aclPath",
")",
";",
"if",
"(",
"Mage",
"::",
"getSingleton",
"(",
"'admin/session'",
")",
"->",
"isAllowed",
"(",
"$",
"aclPath",
")",
"===",
"$",
"negativeCheck",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"(",
"bool",
")",
"$",
"default",
";",
"}"
] | Process the 'acl' attributes to possibly disable a block/reference/action
@param Mage_Core_Model_Layout_Element $node
@param bool $default
@return bool | [
"Process",
"the",
"acl",
"attributes",
"to",
"possibly",
"disable",
"a",
"block",
"/",
"reference",
"/",
"action"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L278-L291 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Model/Layout.php | Aoe_Layout_Model_Layout.checkHelperConditional | protected function checkHelperConditional(Mage_Core_Model_Layout_Element $node)
{
if (isset($node['ifhelper']) && ($helperString = trim((string)$node['ifhelper']))) {
$negativeCheck = (substr($helperString, 0, 1) === '!');
$helperString = ($negativeCheck ? substr($helperString, 1) : $helperString);
if ((bool)$this->getHelperMethodValue($helperString) === $negativeCheck) {
return false;
}
}
return true;
} | php | protected function checkHelperConditional(Mage_Core_Model_Layout_Element $node)
{
if (isset($node['ifhelper']) && ($helperString = trim((string)$node['ifhelper']))) {
$negativeCheck = (substr($helperString, 0, 1) === '!');
$helperString = ($negativeCheck ? substr($helperString, 1) : $helperString);
if ((bool)$this->getHelperMethodValue($helperString) === $negativeCheck) {
return false;
}
}
return true;
} | [
"protected",
"function",
"checkHelperConditional",
"(",
"Mage_Core_Model_Layout_Element",
"$",
"node",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"node",
"[",
"'ifhelper'",
"]",
")",
"&&",
"(",
"$",
"helperString",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"node",
"[",
"'ifhelper'",
"]",
")",
")",
")",
"{",
"$",
"negativeCheck",
"=",
"(",
"substr",
"(",
"$",
"helperString",
",",
"0",
",",
"1",
")",
"===",
"'!'",
")",
";",
"$",
"helperString",
"=",
"(",
"$",
"negativeCheck",
"?",
"substr",
"(",
"$",
"helperString",
",",
"1",
")",
":",
"$",
"helperString",
")",
";",
"if",
"(",
"(",
"bool",
")",
"$",
"this",
"->",
"getHelperMethodValue",
"(",
"$",
"helperString",
")",
"===",
"$",
"negativeCheck",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Process the 'ifhelper' attributes to possibly disable a block/reference/action
@param Mage_Core_Model_Layout_Element $node
@return bool | [
"Process",
"the",
"ifhelper",
"attributes",
"to",
"possibly",
"disable",
"a",
"block",
"/",
"reference",
"/",
"action"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L300-L311 |
mustardandrew/muan-laravel-acl | src/Commands/Permission/ListCommand.php | ListCommand.handle | public function handle()
{
$permissions = Permission::all(['id', 'name', 'created_at', 'updated_at']);
if ($permissions->count()) {
$this->table(
['ID', 'Permission', 'Created At', 'Updated At'],
$permissions->toArray()
);
} else {
$this->warn("Not found any permissions!");
}
return 0;
} | php | public function handle()
{
$permissions = Permission::all(['id', 'name', 'created_at', 'updated_at']);
if ($permissions->count()) {
$this->table(
['ID', 'Permission', 'Created At', 'Updated At'],
$permissions->toArray()
);
} else {
$this->warn("Not found any permissions!");
}
return 0;
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"permissions",
"=",
"Permission",
"::",
"all",
"(",
"[",
"'id'",
",",
"'name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
")",
";",
"if",
"(",
"$",
"permissions",
"->",
"count",
"(",
")",
")",
"{",
"$",
"this",
"->",
"table",
"(",
"[",
"'ID'",
",",
"'Permission'",
",",
"'Created At'",
",",
"'Updated At'",
"]",
",",
"$",
"permissions",
"->",
"toArray",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Not found any permissions!\"",
")",
";",
"}",
"return",
"0",
";",
"}"
] | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Commands/Permission/ListCommand.php#L34-L48 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/reader.php | ezcDbSchemaMysqlReader.fetchTableFields | protected function fetchTableFields( $tableName )
{
$fields = array();
$resultArray = $this->db->query( "DESCRIBE `$tableName`" );
$resultArray->setFetchMode( PDO::FETCH_ASSOC );
foreach ( $resultArray as $row )
{
$row = $this->lowercase($row);
$fieldLength = false;
// bool and boolean is synonyms for TINYINT(1) in MySQL
if ( $row['type'] == 'tinyint(1)' )
{
$fieldType = 'boolean';
}
else
{
$fieldType = self::convertToGenericType( $row['type'], $fieldLength, $fieldPrecision );
if ( !$fieldLength )
{
$fieldLength = false;
}
}
$fieldNotNull = false;
if ( strlen( $row['null'] ) == 0 || $row['null'][0] != 'Y' || $fieldType == 'timestamp' )
{
$fieldNotNull = true;
}
$fieldDefault = null;
if ( strlen( $row['default'] ) != 0 )
{
if ( $fieldType == 'boolean' )
{
$fieldDefault = ( $row['default'] == '0' ) ? 'false' : 'true';
}
else if ( $fieldType != 'timestamp' )
{
$fieldDefault = $row['default'];
}
}
if ( $fieldType == 'integer' && $row['default'] !== null )
{
$fieldDefault = (int) $fieldDefault;
}
$fieldAutoIncrement = false;
if ( strstr ( $row['extra'], 'auto_increment' ) !== false )
{
$fieldAutoIncrement = true;
}
// FIXME: unsigned needs to be implemented
$fieldUnsigned = false;
$fields[$row['field']] = ezcDbSchema::createNewField( $fieldType, $fieldLength, $fieldNotNull, $fieldDefault, $fieldAutoIncrement, $fieldUnsigned );
}
return $fields;
} | php | protected function fetchTableFields( $tableName )
{
$fields = array();
$resultArray = $this->db->query( "DESCRIBE `$tableName`" );
$resultArray->setFetchMode( PDO::FETCH_ASSOC );
foreach ( $resultArray as $row )
{
$row = $this->lowercase($row);
$fieldLength = false;
// bool and boolean is synonyms for TINYINT(1) in MySQL
if ( $row['type'] == 'tinyint(1)' )
{
$fieldType = 'boolean';
}
else
{
$fieldType = self::convertToGenericType( $row['type'], $fieldLength, $fieldPrecision );
if ( !$fieldLength )
{
$fieldLength = false;
}
}
$fieldNotNull = false;
if ( strlen( $row['null'] ) == 0 || $row['null'][0] != 'Y' || $fieldType == 'timestamp' )
{
$fieldNotNull = true;
}
$fieldDefault = null;
if ( strlen( $row['default'] ) != 0 )
{
if ( $fieldType == 'boolean' )
{
$fieldDefault = ( $row['default'] == '0' ) ? 'false' : 'true';
}
else if ( $fieldType != 'timestamp' )
{
$fieldDefault = $row['default'];
}
}
if ( $fieldType == 'integer' && $row['default'] !== null )
{
$fieldDefault = (int) $fieldDefault;
}
$fieldAutoIncrement = false;
if ( strstr ( $row['extra'], 'auto_increment' ) !== false )
{
$fieldAutoIncrement = true;
}
// FIXME: unsigned needs to be implemented
$fieldUnsigned = false;
$fields[$row['field']] = ezcDbSchema::createNewField( $fieldType, $fieldLength, $fieldNotNull, $fieldDefault, $fieldAutoIncrement, $fieldUnsigned );
}
return $fields;
} | [
"protected",
"function",
"fetchTableFields",
"(",
"$",
"tableName",
")",
"{",
"$",
"fields",
"=",
"array",
"(",
")",
";",
"$",
"resultArray",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"DESCRIBE `$tableName`\"",
")",
";",
"$",
"resultArray",
"->",
"setFetchMode",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"foreach",
"(",
"$",
"resultArray",
"as",
"$",
"row",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"lowercase",
"(",
"$",
"row",
")",
";",
"$",
"fieldLength",
"=",
"false",
";",
"// bool and boolean is synonyms for TINYINT(1) in MySQL",
"if",
"(",
"$",
"row",
"[",
"'type'",
"]",
"==",
"'tinyint(1)'",
")",
"{",
"$",
"fieldType",
"=",
"'boolean'",
";",
"}",
"else",
"{",
"$",
"fieldType",
"=",
"self",
"::",
"convertToGenericType",
"(",
"$",
"row",
"[",
"'type'",
"]",
",",
"$",
"fieldLength",
",",
"$",
"fieldPrecision",
")",
";",
"if",
"(",
"!",
"$",
"fieldLength",
")",
"{",
"$",
"fieldLength",
"=",
"false",
";",
"}",
"}",
"$",
"fieldNotNull",
"=",
"false",
";",
"if",
"(",
"strlen",
"(",
"$",
"row",
"[",
"'null'",
"]",
")",
"==",
"0",
"||",
"$",
"row",
"[",
"'null'",
"]",
"[",
"0",
"]",
"!=",
"'Y'",
"||",
"$",
"fieldType",
"==",
"'timestamp'",
")",
"{",
"$",
"fieldNotNull",
"=",
"true",
";",
"}",
"$",
"fieldDefault",
"=",
"null",
";",
"if",
"(",
"strlen",
"(",
"$",
"row",
"[",
"'default'",
"]",
")",
"!=",
"0",
")",
"{",
"if",
"(",
"$",
"fieldType",
"==",
"'boolean'",
")",
"{",
"$",
"fieldDefault",
"=",
"(",
"$",
"row",
"[",
"'default'",
"]",
"==",
"'0'",
")",
"?",
"'false'",
":",
"'true'",
";",
"}",
"else",
"if",
"(",
"$",
"fieldType",
"!=",
"'timestamp'",
")",
"{",
"$",
"fieldDefault",
"=",
"$",
"row",
"[",
"'default'",
"]",
";",
"}",
"}",
"if",
"(",
"$",
"fieldType",
"==",
"'integer'",
"&&",
"$",
"row",
"[",
"'default'",
"]",
"!==",
"null",
")",
"{",
"$",
"fieldDefault",
"=",
"(",
"int",
")",
"$",
"fieldDefault",
";",
"}",
"$",
"fieldAutoIncrement",
"=",
"false",
";",
"if",
"(",
"strstr",
"(",
"$",
"row",
"[",
"'extra'",
"]",
",",
"'auto_increment'",
")",
"!==",
"false",
")",
"{",
"$",
"fieldAutoIncrement",
"=",
"true",
";",
"}",
"// FIXME: unsigned needs to be implemented",
"$",
"fieldUnsigned",
"=",
"false",
";",
"$",
"fields",
"[",
"$",
"row",
"[",
"'field'",
"]",
"]",
"=",
"ezcDbSchema",
"::",
"createNewField",
"(",
"$",
"fieldType",
",",
"$",
"fieldLength",
",",
"$",
"fieldNotNull",
",",
"$",
"fieldDefault",
",",
"$",
"fieldAutoIncrement",
",",
"$",
"fieldUnsigned",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
] | Fetch fields definition for the table $tableName
This method loops over all the fields in the table $tableName and
returns an array with the field specification. The key in the returned
array is the name of the field.
@param string $tableName
@return array(string=>ezcDbSchemaField) | [
"Fetch",
"fields",
"definition",
"for",
"the",
"table",
"$tableName"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/reader.php#L85-L148 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/reader.php | ezcDbSchemaMysqlReader.fetchTableIndexes | protected function fetchTableIndexes( $tableName )
{
$indexBuffer = array();
$resultArray = $this->db->query( "SHOW INDEX FROM `$tableName`" );
foreach ( $resultArray as $row )
{
$keyName = $row['key_name'];
if ( $keyName == 'PRIMARY' )
{
$keyName = 'primary';
}
$indexBuffer[$keyName]['primary'] = false;
$indexBuffer[$keyName]['unique'] = true;
if ( $keyName == 'primary' )
{
$indexBuffer[$keyName]['primary'] = true;
$indexBuffer[$keyName]['unique'] = true;
}
else
{
$indexBuffer[$keyName]['unique'] = $row['non_unique'] ? false : true;
}
$indexBuffer[$keyName]['fields'][$row['column_name']] = ezcDbSchema::createNewIndexField();
// if ( $row['sub_part'] )
// {
// $indexBuffer[$keyName]['options']['limitations'][$row['column_name']] = $row['sub_part'];
// }
}
$indexes = array();
foreach ( $indexBuffer as $indexName => $indexInfo )
{
$indexes[$indexName] = ezcDbSchema::createNewIndex( $indexInfo['fields'], $indexInfo['primary'], $indexInfo['unique'] );
}
return $indexes;
} | php | protected function fetchTableIndexes( $tableName )
{
$indexBuffer = array();
$resultArray = $this->db->query( "SHOW INDEX FROM `$tableName`" );
foreach ( $resultArray as $row )
{
$keyName = $row['key_name'];
if ( $keyName == 'PRIMARY' )
{
$keyName = 'primary';
}
$indexBuffer[$keyName]['primary'] = false;
$indexBuffer[$keyName]['unique'] = true;
if ( $keyName == 'primary' )
{
$indexBuffer[$keyName]['primary'] = true;
$indexBuffer[$keyName]['unique'] = true;
}
else
{
$indexBuffer[$keyName]['unique'] = $row['non_unique'] ? false : true;
}
$indexBuffer[$keyName]['fields'][$row['column_name']] = ezcDbSchema::createNewIndexField();
// if ( $row['sub_part'] )
// {
// $indexBuffer[$keyName]['options']['limitations'][$row['column_name']] = $row['sub_part'];
// }
}
$indexes = array();
foreach ( $indexBuffer as $indexName => $indexInfo )
{
$indexes[$indexName] = ezcDbSchema::createNewIndex( $indexInfo['fields'], $indexInfo['primary'], $indexInfo['unique'] );
}
return $indexes;
} | [
"protected",
"function",
"fetchTableIndexes",
"(",
"$",
"tableName",
")",
"{",
"$",
"indexBuffer",
"=",
"array",
"(",
")",
";",
"$",
"resultArray",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"SHOW INDEX FROM `$tableName`\"",
")",
";",
"foreach",
"(",
"$",
"resultArray",
"as",
"$",
"row",
")",
"{",
"$",
"keyName",
"=",
"$",
"row",
"[",
"'key_name'",
"]",
";",
"if",
"(",
"$",
"keyName",
"==",
"'PRIMARY'",
")",
"{",
"$",
"keyName",
"=",
"'primary'",
";",
"}",
"$",
"indexBuffer",
"[",
"$",
"keyName",
"]",
"[",
"'primary'",
"]",
"=",
"false",
";",
"$",
"indexBuffer",
"[",
"$",
"keyName",
"]",
"[",
"'unique'",
"]",
"=",
"true",
";",
"if",
"(",
"$",
"keyName",
"==",
"'primary'",
")",
"{",
"$",
"indexBuffer",
"[",
"$",
"keyName",
"]",
"[",
"'primary'",
"]",
"=",
"true",
";",
"$",
"indexBuffer",
"[",
"$",
"keyName",
"]",
"[",
"'unique'",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"indexBuffer",
"[",
"$",
"keyName",
"]",
"[",
"'unique'",
"]",
"=",
"$",
"row",
"[",
"'non_unique'",
"]",
"?",
"false",
":",
"true",
";",
"}",
"$",
"indexBuffer",
"[",
"$",
"keyName",
"]",
"[",
"'fields'",
"]",
"[",
"$",
"row",
"[",
"'column_name'",
"]",
"]",
"=",
"ezcDbSchema",
"::",
"createNewIndexField",
"(",
")",
";",
"// if ( $row['sub_part'] )",
"// {",
"// $indexBuffer[$keyName]['options']['limitations'][$row['column_name']] = $row['sub_part'];",
"// }",
"}",
"$",
"indexes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"indexBuffer",
"as",
"$",
"indexName",
"=>",
"$",
"indexInfo",
")",
"{",
"$",
"indexes",
"[",
"$",
"indexName",
"]",
"=",
"ezcDbSchema",
"::",
"createNewIndex",
"(",
"$",
"indexInfo",
"[",
"'fields'",
"]",
",",
"$",
"indexInfo",
"[",
"'primary'",
"]",
",",
"$",
"indexInfo",
"[",
"'unique'",
"]",
")",
";",
"}",
"return",
"$",
"indexes",
";",
"}"
] | Loops over all the indexes in the table $table and extracts information.
This method extracts information about the table $tableName's indexes
from the database and returns this schema as an array of
ezcDbSchemaIndex objects. The key in the array is the index' name.
@param string $tableName
@return array(string=>ezcDbSchemaIndex) | [
"Loops",
"over",
"all",
"the",
"indexes",
"in",
"the",
"table",
"$table",
"and",
"extracts",
"information",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/reader.php#L234-L277 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/index.php | TinyImageManager.AccessDir | private function AccessDir($requestDirectory)
{
$full_request_images_dir = realpath($this->dir['images'] . $requestDirectory);
if (strpos($full_request_images_dir, $this->dir['images']) === 0)
{
return $full_request_images_dir;
}
return false;
} | php | private function AccessDir($requestDirectory)
{
$full_request_images_dir = realpath($this->dir['images'] . $requestDirectory);
if (strpos($full_request_images_dir, $this->dir['images']) === 0)
{
return $full_request_images_dir;
}
return false;
} | [
"private",
"function",
"AccessDir",
"(",
"$",
"requestDirectory",
")",
"{",
"$",
"full_request_images_dir",
"=",
"realpath",
"(",
"$",
"this",
"->",
"dir",
"[",
"'images'",
"]",
".",
"$",
"requestDirectory",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"full_request_images_dir",
",",
"$",
"this",
"->",
"dir",
"[",
"'images'",
"]",
")",
"===",
"0",
")",
"{",
"return",
"$",
"full_request_images_dir",
";",
"}",
"return",
"false",
";",
"}"
] | Проверка на разрешение записи в папку (не системное)
@param string $requestDirectory Запрашиваемая папка (относительно DIR_IMAGES)
@return string|bool | [
"Проверка",
"на",
"разрешение",
"записи",
"в",
"папку",
"(",
"не",
"системное",
")"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/index.php#L233-L243 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/index.php | TinyImageManager.Tree | function Tree($beginFolder)
{
$struct = array();
$handle = opendir($beginFolder);
if ($handle)
{
$struct[$beginFolder]['path'] = str_replace(array($this->dir['files'], $this->dir['images']), '', $beginFolder);
$tmp = preg_split('[\\/]', $beginFolder);
$tmp = array_filter($tmp);
end($tmp);
$struct[$beginFolder]['name'] = current($tmp);
$struct[$beginFolder]['count'] = 0;
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && $file != '.thumbs')
{
if (is_dir($beginFolder . '/' . $file))
{
$struct[$beginFolder]['childs'][] = $this->Tree($beginFolder . '/' . $file);
}
else
{
$struct[$beginFolder]['count']++;
}
}
}
closedir($handle);
asort($struct);
return $struct;
}
return false;
} | php | function Tree($beginFolder)
{
$struct = array();
$handle = opendir($beginFolder);
if ($handle)
{
$struct[$beginFolder]['path'] = str_replace(array($this->dir['files'], $this->dir['images']), '', $beginFolder);
$tmp = preg_split('[\\/]', $beginFolder);
$tmp = array_filter($tmp);
end($tmp);
$struct[$beginFolder]['name'] = current($tmp);
$struct[$beginFolder]['count'] = 0;
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && $file != '.thumbs')
{
if (is_dir($beginFolder . '/' . $file))
{
$struct[$beginFolder]['childs'][] = $this->Tree($beginFolder . '/' . $file);
}
else
{
$struct[$beginFolder]['count']++;
}
}
}
closedir($handle);
asort($struct);
return $struct;
}
return false;
} | [
"function",
"Tree",
"(",
"$",
"beginFolder",
")",
"{",
"$",
"struct",
"=",
"array",
"(",
")",
";",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"beginFolder",
")",
";",
"if",
"(",
"$",
"handle",
")",
"{",
"$",
"struct",
"[",
"$",
"beginFolder",
"]",
"[",
"'path'",
"]",
"=",
"str_replace",
"(",
"array",
"(",
"$",
"this",
"->",
"dir",
"[",
"'files'",
"]",
",",
"$",
"this",
"->",
"dir",
"[",
"'images'",
"]",
")",
",",
"''",
",",
"$",
"beginFolder",
")",
";",
"$",
"tmp",
"=",
"preg_split",
"(",
"'[\\\\/]'",
",",
"$",
"beginFolder",
")",
";",
"$",
"tmp",
"=",
"array_filter",
"(",
"$",
"tmp",
")",
";",
"end",
"(",
"$",
"tmp",
")",
";",
"$",
"struct",
"[",
"$",
"beginFolder",
"]",
"[",
"'name'",
"]",
"=",
"current",
"(",
"$",
"tmp",
")",
";",
"$",
"struct",
"[",
"$",
"beginFolder",
"]",
"[",
"'count'",
"]",
"=",
"0",
";",
"while",
"(",
"false",
"!==",
"(",
"$",
"file",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
")",
"{",
"if",
"(",
"$",
"file",
"!=",
"\".\"",
"&&",
"$",
"file",
"!=",
"\"..\"",
"&&",
"$",
"file",
"!=",
"'.thumbs'",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"beginFolder",
".",
"'/'",
".",
"$",
"file",
")",
")",
"{",
"$",
"struct",
"[",
"$",
"beginFolder",
"]",
"[",
"'childs'",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"Tree",
"(",
"$",
"beginFolder",
".",
"'/'",
".",
"$",
"file",
")",
";",
"}",
"else",
"{",
"$",
"struct",
"[",
"$",
"beginFolder",
"]",
"[",
"'count'",
"]",
"++",
";",
"}",
"}",
"}",
"closedir",
"(",
"$",
"handle",
")",
";",
"asort",
"(",
"$",
"struct",
")",
";",
"return",
"$",
"struct",
";",
"}",
"return",
"false",
";",
"}"
] | Дерево каталогов
функция рекурсивная
@return array | [
"Дерево",
"каталогов",
"функция",
"рекурсивная"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/index.php#L251-L282 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/index.php | TinyImageManager.DirStructure | public function DirStructure($type, $innerDirs = 'first', $currentDir = '', $level = 0)
{
//Пока отключим файлы
if ($type == 'files')
{
return '';
}
$currentDirArr = array();
if (!empty($currentDir))
{
$currentDirArr = preg_split('[\\/]',
str_replace($this->dir[$type], '', realpath($currentDir)));
$currentDirArr = array_filter($currentDirArr);
}
if ($innerDirs == 'first')
{
$innerDirs = $this->Tree($this->dir[$type]);
if (realpath($currentDir) == $this->dir[$type] && !$this->firstAct)
{
$firstAct = 'folderAct';
$this->firstAct = true;
}
else
{
$firstAct = '';
}
$ret = '';
if ($innerDirs == false)
{
return 'Неверно задана корневая директория (' . DIR_IMAGES . ')';
}
foreach ($innerDirs as $v)
{
$ret = '<div class="folder' . ucfirst($type) . ' ' . $firstAct . '" path="" pathtype="' . $type . '">' . ($type == 'images' ? 'Изображения' : 'Файлы') . ($v['count'] > 0 ? ' (' . $v['count'] . ')' : '') . '</div><div class="folderOpenSection" style="display:block;">';
if (isset($v['childs']))
{
$ret .= $this->DirStructure($type, $v['childs'], $currentDir, $level);
}
break;
}
$ret .= '</div>';
return $ret;
}
if (sizeof($innerDirs) == 0)
{
return false;
}
$ret = '';
foreach ($innerDirs as $v)
{
// TODO: Нафига?!
foreach ($v as $v)
{
}
if (isset($v['count']))
{
$files = 'Файлов: ' . $v['count'];
$count_childs = isset($v['childs']) ? sizeof($v['childs']) : 0;
if ($count_childs != 0)
{
$files .= ', папок: ' . $count_childs;
}
}
else
{
$files = '';
}
if (isset($v['childs']))
{
$folderOpen = '';
$folderAct = '';
$folderClass = 'folderS';
if (isset($currentDirArr[$level + 1]))
{
if ($currentDirArr[$level + 1] == $v['name'])
{
$folderOpen = 'style="display:block;"';
$folderClass = 'folderOpened';
if ($currentDirArr[sizeof($currentDirArr)] == $v['name'] && !$this->folderAct)
{
$folderAct = 'folderAct';
$this->folderAct = true;
}
else
{
$folderAct = '';
}
}
}
$ret .= '<div class="' . $folderClass . ' ' . $folderAct . '" path="' . $v['path'] . '" title="' . $files . '" pathtype="' . $type . '">' . $v['name'] . ($v['count'] > 0 ? ' (' . $v['count'] . ')' : '') . '</div><div class="folderOpenSection" ' . $folderOpen . '>';
$ret .= $this->DirStructure($type, $v['childs'], $currentDir, $level + 1);
$ret .= '</div>';
}
else
{
$soc = sizeof($currentDirArr);
if ($soc > 0 && $currentDirArr[$soc] == $v['name'])
{
$folderAct = 'folderAct';
}
else
{
$folderAct = '';
}
$ret .= '<div class="folderClosed ' . $folderAct . '" path="' . $v['path'] . '" title="' . $files . '" pathtype="' . $type . '">' . $v['name'] . ($v['count'] > 0 ? ' (' . $v['count'] . ')' : '') . '</div>';
}
}
return $ret;
} | php | public function DirStructure($type, $innerDirs = 'first', $currentDir = '', $level = 0)
{
//Пока отключим файлы
if ($type == 'files')
{
return '';
}
$currentDirArr = array();
if (!empty($currentDir))
{
$currentDirArr = preg_split('[\\/]',
str_replace($this->dir[$type], '', realpath($currentDir)));
$currentDirArr = array_filter($currentDirArr);
}
if ($innerDirs == 'first')
{
$innerDirs = $this->Tree($this->dir[$type]);
if (realpath($currentDir) == $this->dir[$type] && !$this->firstAct)
{
$firstAct = 'folderAct';
$this->firstAct = true;
}
else
{
$firstAct = '';
}
$ret = '';
if ($innerDirs == false)
{
return 'Неверно задана корневая директория (' . DIR_IMAGES . ')';
}
foreach ($innerDirs as $v)
{
$ret = '<div class="folder' . ucfirst($type) . ' ' . $firstAct . '" path="" pathtype="' . $type . '">' . ($type == 'images' ? 'Изображения' : 'Файлы') . ($v['count'] > 0 ? ' (' . $v['count'] . ')' : '') . '</div><div class="folderOpenSection" style="display:block;">';
if (isset($v['childs']))
{
$ret .= $this->DirStructure($type, $v['childs'], $currentDir, $level);
}
break;
}
$ret .= '</div>';
return $ret;
}
if (sizeof($innerDirs) == 0)
{
return false;
}
$ret = '';
foreach ($innerDirs as $v)
{
// TODO: Нафига?!
foreach ($v as $v)
{
}
if (isset($v['count']))
{
$files = 'Файлов: ' . $v['count'];
$count_childs = isset($v['childs']) ? sizeof($v['childs']) : 0;
if ($count_childs != 0)
{
$files .= ', папок: ' . $count_childs;
}
}
else
{
$files = '';
}
if (isset($v['childs']))
{
$folderOpen = '';
$folderAct = '';
$folderClass = 'folderS';
if (isset($currentDirArr[$level + 1]))
{
if ($currentDirArr[$level + 1] == $v['name'])
{
$folderOpen = 'style="display:block;"';
$folderClass = 'folderOpened';
if ($currentDirArr[sizeof($currentDirArr)] == $v['name'] && !$this->folderAct)
{
$folderAct = 'folderAct';
$this->folderAct = true;
}
else
{
$folderAct = '';
}
}
}
$ret .= '<div class="' . $folderClass . ' ' . $folderAct . '" path="' . $v['path'] . '" title="' . $files . '" pathtype="' . $type . '">' . $v['name'] . ($v['count'] > 0 ? ' (' . $v['count'] . ')' : '') . '</div><div class="folderOpenSection" ' . $folderOpen . '>';
$ret .= $this->DirStructure($type, $v['childs'], $currentDir, $level + 1);
$ret .= '</div>';
}
else
{
$soc = sizeof($currentDirArr);
if ($soc > 0 && $currentDirArr[$soc] == $v['name'])
{
$folderAct = 'folderAct';
}
else
{
$folderAct = '';
}
$ret .= '<div class="folderClosed ' . $folderAct . '" path="' . $v['path'] . '" title="' . $files . '" pathtype="' . $type . '">' . $v['name'] . ($v['count'] > 0 ? ' (' . $v['count'] . ')' : '') . '</div>';
}
}
return $ret;
} | [
"public",
"function",
"DirStructure",
"(",
"$",
"type",
",",
"$",
"innerDirs",
"=",
"'first'",
",",
"$",
"currentDir",
"=",
"''",
",",
"$",
"level",
"=",
"0",
")",
"{",
"//Пока отключим файлы",
"if",
"(",
"$",
"type",
"==",
"'files'",
")",
"{",
"return",
"''",
";",
"}",
"$",
"currentDirArr",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"currentDir",
")",
")",
"{",
"$",
"currentDirArr",
"=",
"preg_split",
"(",
"'[\\\\/]'",
",",
"str_replace",
"(",
"$",
"this",
"->",
"dir",
"[",
"$",
"type",
"]",
",",
"''",
",",
"realpath",
"(",
"$",
"currentDir",
")",
")",
")",
";",
"$",
"currentDirArr",
"=",
"array_filter",
"(",
"$",
"currentDirArr",
")",
";",
"}",
"if",
"(",
"$",
"innerDirs",
"==",
"'first'",
")",
"{",
"$",
"innerDirs",
"=",
"$",
"this",
"->",
"Tree",
"(",
"$",
"this",
"->",
"dir",
"[",
"$",
"type",
"]",
")",
";",
"if",
"(",
"realpath",
"(",
"$",
"currentDir",
")",
"==",
"$",
"this",
"->",
"dir",
"[",
"$",
"type",
"]",
"&&",
"!",
"$",
"this",
"->",
"firstAct",
")",
"{",
"$",
"firstAct",
"=",
"'folderAct'",
";",
"$",
"this",
"->",
"firstAct",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"firstAct",
"=",
"''",
";",
"}",
"$",
"ret",
"=",
"''",
";",
"if",
"(",
"$",
"innerDirs",
"==",
"false",
")",
"{",
"return",
"'Неверно задана корневая директория (' . DIR_IMAGES . ')';",
"",
"",
"",
"",
"",
"}",
"foreach",
"(",
"$",
"innerDirs",
"as",
"$",
"v",
")",
"{",
"$",
"ret",
"=",
"'<div class=\"folder'",
".",
"ucfirst",
"(",
"$",
"type",
")",
".",
"' '",
".",
"$",
"firstAct",
".",
"'\" path=\"\" pathtype=\"'",
".",
"$",
"type",
".",
"'\">'",
".",
"(",
"$",
"type",
"==",
"'images'",
"?",
"'Изображения' : 'Файлы')",
".",
"($v['count']",
" ",
" ",
" ",
"?",
" ",
"'",
" (' . $",
"v",
"'",
"o",
"n",
"'] .",
"'",
"'",
" ",
":",
" '') . ",
"'",
"/",
"iv>",
"d",
"v ",
"c",
"a",
"s=\"folderOpenSection\" style=\"display:block;\">';",
"",
"if",
"(",
"isset",
"(",
"$",
"v",
"[",
"'childs'",
"]",
")",
")",
"{",
"$",
"ret",
".=",
"$",
"this",
"->",
"DirStructure",
"(",
"$",
"type",
",",
"$",
"v",
"[",
"'childs'",
"]",
",",
"$",
"currentDir",
",",
"$",
"level",
")",
";",
"}",
"break",
";",
"}",
"$",
"ret",
".=",
"'</div>'",
";",
"return",
"$",
"ret",
";",
"}",
"if",
"(",
"sizeof",
"(",
"$",
"innerDirs",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"ret",
"=",
"''",
";",
"foreach",
"(",
"$",
"innerDirs",
"as",
"$",
"v",
")",
"{",
"// TODO: Нафига?!",
"foreach",
"(",
"$",
"v",
"as",
"$",
"v",
")",
"{",
"}",
"if",
"(",
"isset",
"(",
"$",
"v",
"[",
"'count'",
"]",
")",
")",
"{",
"$",
"files",
"=",
"'Файлов: ' . $v[",
"c",
"u",
"n",
"t",
"'];",
"",
"",
"$",
"count_childs",
"=",
"isset",
"(",
"$",
"v",
"[",
"'childs'",
"]",
")",
"?",
"sizeof",
"(",
"$",
"v",
"[",
"'childs'",
"]",
")",
":",
"0",
";",
"if",
"(",
"$",
"count_childs",
"!=",
"0",
")",
"{",
"$",
"files",
".=",
"', папок: ' . $c",
"u",
"t",
"_childs;",
"",
"}",
"}",
"else",
"{",
"$",
"files",
"=",
"''",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"v",
"[",
"'childs'",
"]",
")",
")",
"{",
"$",
"folderOpen",
"=",
"''",
";",
"$",
"folderAct",
"=",
"''",
";",
"$",
"folderClass",
"=",
"'folderS'",
";",
"if",
"(",
"isset",
"(",
"$",
"currentDirArr",
"[",
"$",
"level",
"+",
"1",
"]",
")",
")",
"{",
"if",
"(",
"$",
"currentDirArr",
"[",
"$",
"level",
"+",
"1",
"]",
"==",
"$",
"v",
"[",
"'name'",
"]",
")",
"{",
"$",
"folderOpen",
"=",
"'style=\"display:block;\"'",
";",
"$",
"folderClass",
"=",
"'folderOpened'",
";",
"if",
"(",
"$",
"currentDirArr",
"[",
"sizeof",
"(",
"$",
"currentDirArr",
")",
"]",
"==",
"$",
"v",
"[",
"'name'",
"]",
"&&",
"!",
"$",
"this",
"->",
"folderAct",
")",
"{",
"$",
"folderAct",
"=",
"'folderAct'",
";",
"$",
"this",
"->",
"folderAct",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"folderAct",
"=",
"''",
";",
"}",
"}",
"}",
"$",
"ret",
".=",
"'<div class=\"'",
".",
"$",
"folderClass",
".",
"' '",
".",
"$",
"folderAct",
".",
"'\" path=\"'",
".",
"$",
"v",
"[",
"'path'",
"]",
".",
"'\" title=\"'",
".",
"$",
"files",
".",
"'\" pathtype=\"'",
".",
"$",
"type",
".",
"'\">'",
".",
"$",
"v",
"[",
"'name'",
"]",
".",
"(",
"$",
"v",
"[",
"'count'",
"]",
">",
"0",
"?",
"' ('",
".",
"$",
"v",
"[",
"'count'",
"]",
".",
"')'",
":",
"''",
")",
".",
"'</div><div class=\"folderOpenSection\" '",
".",
"$",
"folderOpen",
".",
"'>'",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"DirStructure",
"(",
"$",
"type",
",",
"$",
"v",
"[",
"'childs'",
"]",
",",
"$",
"currentDir",
",",
"$",
"level",
"+",
"1",
")",
";",
"$",
"ret",
".=",
"'</div>'",
";",
"}",
"else",
"{",
"$",
"soc",
"=",
"sizeof",
"(",
"$",
"currentDirArr",
")",
";",
"if",
"(",
"$",
"soc",
">",
"0",
"&&",
"$",
"currentDirArr",
"[",
"$",
"soc",
"]",
"==",
"$",
"v",
"[",
"'name'",
"]",
")",
"{",
"$",
"folderAct",
"=",
"'folderAct'",
";",
"}",
"else",
"{",
"$",
"folderAct",
"=",
"''",
";",
"}",
"$",
"ret",
".=",
"'<div class=\"folderClosed '",
".",
"$",
"folderAct",
".",
"'\" path=\"'",
".",
"$",
"v",
"[",
"'path'",
"]",
".",
"'\" title=\"'",
".",
"$",
"files",
".",
"'\" pathtype=\"'",
".",
"$",
"type",
".",
"'\">'",
".",
"$",
"v",
"[",
"'name'",
"]",
".",
"(",
"$",
"v",
"[",
"'count'",
"]",
">",
"0",
"?",
"' ('",
".",
"$",
"v",
"[",
"'count'",
"]",
".",
"')'",
":",
"''",
")",
".",
"'</div>'",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Визуализация дерева каталогов
функция рекурсивная
@param string $type images|files
@param string $innerDirs
@param string $currentDir
@param int $level
@return string html | [
"Визуализация",
"дерева",
"каталогов",
"функция",
"рекурсивная"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/index.php#L294-L406 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/index.php | TinyImageManager.DirPath | function DirPath($type, $path = '')
{
if (!empty($path))
{
$path = explode('[\\/]', str_replace($this->dir[$type], '', realpath($path)));
$path = array_filter($path);
}
$ret = '<div class="addrItem" path="" pathtype="' . $type . '" title=""><img src="img/' . ($type == 'images' ? 'folder_open_image' : 'folder_open_document') . '.png" width="16" height="16" alt="Корневая директория" /></div>';
$i = 0;
$addPath = '';
if (is_array($path))
{
foreach ($path as $v)
{
$i++;
$addPath .= '/' . $v;
if (sizeof($path) == $i)
{
$ret .= '<div class="addrItemEnd" path="' . $addPath . '" pathtype="' . $type . '" title=""><div>' . $v . '</div></div>';
}
else
{
$ret .= '<div class="addrItem" path="' . $addPath . '" pathtype="' . $type . '" title=""><div>' . $v . '</div></div>';
}
}
}
return $ret;
} | php | function DirPath($type, $path = '')
{
if (!empty($path))
{
$path = explode('[\\/]', str_replace($this->dir[$type], '', realpath($path)));
$path = array_filter($path);
}
$ret = '<div class="addrItem" path="" pathtype="' . $type . '" title=""><img src="img/' . ($type == 'images' ? 'folder_open_image' : 'folder_open_document') . '.png" width="16" height="16" alt="Корневая директория" /></div>';
$i = 0;
$addPath = '';
if (is_array($path))
{
foreach ($path as $v)
{
$i++;
$addPath .= '/' . $v;
if (sizeof($path) == $i)
{
$ret .= '<div class="addrItemEnd" path="' . $addPath . '" pathtype="' . $type . '" title=""><div>' . $v . '</div></div>';
}
else
{
$ret .= '<div class="addrItem" path="' . $addPath . '" pathtype="' . $type . '" title=""><div>' . $v . '</div></div>';
}
}
}
return $ret;
} | [
"function",
"DirPath",
"(",
"$",
"type",
",",
"$",
"path",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'[\\\\/]'",
",",
"str_replace",
"(",
"$",
"this",
"->",
"dir",
"[",
"$",
"type",
"]",
",",
"''",
",",
"realpath",
"(",
"$",
"path",
")",
")",
")",
";",
"$",
"path",
"=",
"array_filter",
"(",
"$",
"path",
")",
";",
"}",
"$",
"ret",
"=",
"'<div class=\"addrItem\" path=\"\" pathtype=\"'",
".",
"$",
"type",
".",
"'\" title=\"\"><img src=\"img/'",
".",
"(",
"$",
"type",
"==",
"'images'",
"?",
"'folder_open_image'",
":",
"'folder_open_document'",
")",
".",
"'.png\" width=\"16\" height=\"16\" alt=\"Корневая директория\" /></div>';",
"",
"$",
"i",
"=",
"0",
";",
"$",
"addPath",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"path",
")",
")",
"{",
"foreach",
"(",
"$",
"path",
"as",
"$",
"v",
")",
"{",
"$",
"i",
"++",
";",
"$",
"addPath",
".=",
"'/'",
".",
"$",
"v",
";",
"if",
"(",
"sizeof",
"(",
"$",
"path",
")",
"==",
"$",
"i",
")",
"{",
"$",
"ret",
".=",
"'<div class=\"addrItemEnd\" path=\"'",
".",
"$",
"addPath",
".",
"'\" pathtype=\"'",
".",
"$",
"type",
".",
"'\" title=\"\"><div>'",
".",
"$",
"v",
".",
"'</div></div>'",
";",
"}",
"else",
"{",
"$",
"ret",
".=",
"'<div class=\"addrItem\" path=\"'",
".",
"$",
"addPath",
".",
"'\" pathtype=\"'",
".",
"$",
"type",
".",
"'\" title=\"\"><div>'",
".",
"$",
"v",
".",
"'</div></div>'",
";",
"}",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Путь (хлебные крошки)
@param string $type images|files
@param string $path
@return string html | [
"Путь",
"(",
"хлебные",
"крошки",
")"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/index.php#L415-L446 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/index.php | TinyImageManager.CallDir | private function CallDir($dir)
{
$dir = $this->AccessDir($dir);
if (!$dir)
{
return false;
}
set_time_limit(120);
if (!is_dir($dir . '/.thumbs'))
{
$umask = umask(0000);
mkdir($dir . '/.thumbs', 0777);
umask($umask);
}
$dbfile = $dir . '/.thumbs/.db';
if (is_file($dbfile))
{
$dbfilehandle = fopen($dbfile, "r");
$dblength = filesize($dbfile);
if ($dblength > 0)
{
$dbdata = fread($dbfilehandle, $dblength);
}
fclose($dbfilehandle);
$dbfilehandle = fopen($dbfile, "w");
}
else
{
$dbfilehandle = fopen($dbfile, "w");
chmod($dbfile, 0666);
}
if (!empty($dbdata))
{
$files = unserialize($dbdata);
}
else
{
$files = array();
}
$handle = opendir($dir);
if ($handle)
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
if (isset($files[$file]))
{
continue;
}
if (is_file($dir . '/' . $file))
{
$file_info = pathinfo($dir . '/' . $file);
$file_info['extension'] = strtolower($file_info['extension']);
if (!in_array(strtolower($file_info['extension']), $this->ALLOWED_IMAGES))
{
continue;
}
$link = str_replace(array('/\\', '//', '\\\\', '\\'), '/', '/' . str_replace(realpath(DIR_ROOT), '', realpath($dir . '/' . $file)));
$path = pathinfo($link);
$path = $path['dirname'];
if ($file_info['extension'] == 'jpg' || $file_info['extension'] == 'jpeg')
{
$er = new phpExifReader($dir . '/' . $file);
$files[$file]['exifinfo'] = $er->getImageInfo();
$files[$file]['imageinfo'] = getimagesize($dir . '/' . $file);
$files[$file]['general'] = array(
'filename' => $file,
'name' => basename(strtolower($file_info['basename']), '.' . $file_info['extension']),
'ext' => $file_info['extension'],
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => md5_file($dir . '/' . $file)
);
}
else
{
$files[$file]['imageinfo'] = getimagesize($dir . '/' . $file);
$files[$file]['general'] = array(
'filename' => $file,
'name' => basename(strtolower($file_info['basename']), '.' . $file_info['extension']),
'ext' => $file_info['extension'],
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => md5_file($dir . '/' . $file)
);
}
}
}
}
closedir($handle);
}
fwrite($dbfilehandle, serialize($files));
fclose($dbfilehandle);
return $files;
} | php | private function CallDir($dir)
{
$dir = $this->AccessDir($dir);
if (!$dir)
{
return false;
}
set_time_limit(120);
if (!is_dir($dir . '/.thumbs'))
{
$umask = umask(0000);
mkdir($dir . '/.thumbs', 0777);
umask($umask);
}
$dbfile = $dir . '/.thumbs/.db';
if (is_file($dbfile))
{
$dbfilehandle = fopen($dbfile, "r");
$dblength = filesize($dbfile);
if ($dblength > 0)
{
$dbdata = fread($dbfilehandle, $dblength);
}
fclose($dbfilehandle);
$dbfilehandle = fopen($dbfile, "w");
}
else
{
$dbfilehandle = fopen($dbfile, "w");
chmod($dbfile, 0666);
}
if (!empty($dbdata))
{
$files = unserialize($dbdata);
}
else
{
$files = array();
}
$handle = opendir($dir);
if ($handle)
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
if (isset($files[$file]))
{
continue;
}
if (is_file($dir . '/' . $file))
{
$file_info = pathinfo($dir . '/' . $file);
$file_info['extension'] = strtolower($file_info['extension']);
if (!in_array(strtolower($file_info['extension']), $this->ALLOWED_IMAGES))
{
continue;
}
$link = str_replace(array('/\\', '//', '\\\\', '\\'), '/', '/' . str_replace(realpath(DIR_ROOT), '', realpath($dir . '/' . $file)));
$path = pathinfo($link);
$path = $path['dirname'];
if ($file_info['extension'] == 'jpg' || $file_info['extension'] == 'jpeg')
{
$er = new phpExifReader($dir . '/' . $file);
$files[$file]['exifinfo'] = $er->getImageInfo();
$files[$file]['imageinfo'] = getimagesize($dir . '/' . $file);
$files[$file]['general'] = array(
'filename' => $file,
'name' => basename(strtolower($file_info['basename']), '.' . $file_info['extension']),
'ext' => $file_info['extension'],
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => md5_file($dir . '/' . $file)
);
}
else
{
$files[$file]['imageinfo'] = getimagesize($dir . '/' . $file);
$files[$file]['general'] = array(
'filename' => $file,
'name' => basename(strtolower($file_info['basename']), '.' . $file_info['extension']),
'ext' => $file_info['extension'],
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => md5_file($dir . '/' . $file)
);
}
}
}
}
closedir($handle);
}
fwrite($dbfilehandle, serialize($files));
fclose($dbfilehandle);
return $files;
} | [
"private",
"function",
"CallDir",
"(",
"$",
"dir",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"AccessDir",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"!",
"$",
"dir",
")",
"{",
"return",
"false",
";",
"}",
"set_time_limit",
"(",
"120",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
".",
"'/.thumbs'",
")",
")",
"{",
"$",
"umask",
"=",
"umask",
"(",
"0000",
")",
";",
"mkdir",
"(",
"$",
"dir",
".",
"'/.thumbs'",
",",
"0777",
")",
";",
"umask",
"(",
"$",
"umask",
")",
";",
"}",
"$",
"dbfile",
"=",
"$",
"dir",
".",
"'/.thumbs/.db'",
";",
"if",
"(",
"is_file",
"(",
"$",
"dbfile",
")",
")",
"{",
"$",
"dbfilehandle",
"=",
"fopen",
"(",
"$",
"dbfile",
",",
"\"r\"",
")",
";",
"$",
"dblength",
"=",
"filesize",
"(",
"$",
"dbfile",
")",
";",
"if",
"(",
"$",
"dblength",
">",
"0",
")",
"{",
"$",
"dbdata",
"=",
"fread",
"(",
"$",
"dbfilehandle",
",",
"$",
"dblength",
")",
";",
"}",
"fclose",
"(",
"$",
"dbfilehandle",
")",
";",
"$",
"dbfilehandle",
"=",
"fopen",
"(",
"$",
"dbfile",
",",
"\"w\"",
")",
";",
"}",
"else",
"{",
"$",
"dbfilehandle",
"=",
"fopen",
"(",
"$",
"dbfile",
",",
"\"w\"",
")",
";",
"chmod",
"(",
"$",
"dbfile",
",",
"0666",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"dbdata",
")",
")",
"{",
"$",
"files",
"=",
"unserialize",
"(",
"$",
"dbdata",
")",
";",
"}",
"else",
"{",
"$",
"files",
"=",
"array",
"(",
")",
";",
"}",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"$",
"handle",
")",
"{",
"while",
"(",
"false",
"!==",
"(",
"$",
"file",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
")",
"{",
"if",
"(",
"$",
"file",
"!=",
"\".\"",
"&&",
"$",
"file",
"!=",
"\"..\"",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"files",
"[",
"$",
"file",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
")",
"{",
"$",
"file_info",
"=",
"pathinfo",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
";",
"$",
"file_info",
"[",
"'extension'",
"]",
"=",
"strtolower",
"(",
"$",
"file_info",
"[",
"'extension'",
"]",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"strtolower",
"(",
"$",
"file_info",
"[",
"'extension'",
"]",
")",
",",
"$",
"this",
"->",
"ALLOWED_IMAGES",
")",
")",
"{",
"continue",
";",
"}",
"$",
"link",
"=",
"str_replace",
"(",
"array",
"(",
"'/\\\\'",
",",
"'//'",
",",
"'\\\\\\\\'",
",",
"'\\\\'",
")",
",",
"'/'",
",",
"'/'",
".",
"str_replace",
"(",
"realpath",
"(",
"DIR_ROOT",
")",
",",
"''",
",",
"realpath",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
")",
")",
";",
"$",
"path",
"=",
"pathinfo",
"(",
"$",
"link",
")",
";",
"$",
"path",
"=",
"$",
"path",
"[",
"'dirname'",
"]",
";",
"if",
"(",
"$",
"file_info",
"[",
"'extension'",
"]",
"==",
"'jpg'",
"||",
"$",
"file_info",
"[",
"'extension'",
"]",
"==",
"'jpeg'",
")",
"{",
"$",
"er",
"=",
"new",
"phpExifReader",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
";",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'exifinfo'",
"]",
"=",
"$",
"er",
"->",
"getImageInfo",
"(",
")",
";",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"=",
"getimagesize",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
";",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'general'",
"]",
"=",
"array",
"(",
"'filename'",
"=>",
"$",
"file",
",",
"'name'",
"=>",
"basename",
"(",
"strtolower",
"(",
"$",
"file_info",
"[",
"'basename'",
"]",
")",
",",
"'.'",
".",
"$",
"file_info",
"[",
"'extension'",
"]",
")",
",",
"'ext'",
"=>",
"$",
"file_info",
"[",
"'extension'",
"]",
",",
"'path'",
"=>",
"$",
"path",
",",
"'link'",
"=>",
"$",
"link",
",",
"'size'",
"=>",
"filesize",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'date'",
"=>",
"filemtime",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'width'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"0",
"]",
",",
"'height'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"1",
"]",
",",
"'md5'",
"=>",
"md5_file",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
")",
";",
"}",
"else",
"{",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"=",
"getimagesize",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
";",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'general'",
"]",
"=",
"array",
"(",
"'filename'",
"=>",
"$",
"file",
",",
"'name'",
"=>",
"basename",
"(",
"strtolower",
"(",
"$",
"file_info",
"[",
"'basename'",
"]",
")",
",",
"'.'",
".",
"$",
"file_info",
"[",
"'extension'",
"]",
")",
",",
"'ext'",
"=>",
"$",
"file_info",
"[",
"'extension'",
"]",
",",
"'path'",
"=>",
"$",
"path",
",",
"'link'",
"=>",
"$",
"link",
",",
"'size'",
"=>",
"filesize",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'date'",
"=>",
"filemtime",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'width'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"0",
"]",
",",
"'height'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"1",
"]",
",",
"'md5'",
"=>",
"md5_file",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
")",
";",
"}",
"}",
"}",
"}",
"closedir",
"(",
"$",
"handle",
")",
";",
"}",
"fwrite",
"(",
"$",
"dbfilehandle",
",",
"serialize",
"(",
"$",
"files",
")",
")",
";",
"fclose",
"(",
"$",
"dbfilehandle",
")",
";",
"return",
"$",
"files",
";",
"}"
] | ???
@param string $dir | [
"???"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/index.php#L455-L567 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/index.php | TinyImageManager.UploadFile | function UploadFile($dir, $type)
{
$dir = $this->AccessDir($dir, $type);
if (!$dir)
{
return false;
}
if (!is_dir($dir . '/.thumbs'))
{
$umask = umask(0000);
mkdir($dir . '/.thumbs', 0777);
umask($umask);
}
$dbfile = $dir . '/.thumbs/.db';
if (is_file($dbfile))
{
$dbdata = file_get_contents($dbfile);
}
if (!empty($dbdata))
{
$files = unserialize($dbdata);
}
else
{
$files = array();
}
/* Файл из flash-мультизагрузки */
if (isset($_POST['Filename']))
{
//Тип (изображение/файл)
$pathtype = $_POST['pathtype'];
if (strpos($_POST['Filename'], '.') !== false)
{
$extension = end(explode('.', $_POST['Filename']));
$filename = substr($_POST['Filename'], 0, strlen($_POST['Filename']) - strlen($extension) - 1);
}
else
{
header('HTTP/1.1 403 Forbidden');
exit();
}
if ($pathtype == 'images')
{
$allowed = $this->ALLOWED_IMAGES;
}
elseif ($pathtype == 'files')
{
$allowed = $this->ALLOWED_FILES;
}
else
{
$allowed = array();
}
//Если не подходит разрешение файла
if (!in_array(strtolower($extension), $allowed))
{
header('HTTP/1.1 403 Forbidden');
exit();
}
$md5 = md5_file($_FILES['Filedata']['tmp_name']);
$file = $md5 . '.' . $extension;
//Проверка на изображение
if ($pathtype == 'images')
{
$files[$file]['imageinfo'] = getimagesize($_FILES['Filedata']['tmp_name']);
if (empty($files[$file]['imageinfo']))
{
header('HTTP/1.1 403 Forbidden');
exit();
}
}
if (!copy($_FILES['Filedata']['tmp_name'], $dir . '/' . $file))
{
header('HTTP/1.0 500 Internal Server Error');
exit();
}
$link = str_replace(array('/\\', '//', '\\\\', '\\'), '/', '/' . str_replace(realpath(DIR_ROOT), '', realpath($dir . '/' . $file)));
$path = pathinfo($link);
$path = $path['dirname'];
if ($extension == 'jpg' || $extension == 'jpeg')
{
$er = new phpExifReader($dir . '/' . $file);
$files[$file]['exifinfo'] = $er->getImageInfo();
$files[$file]['general'] = array(
'filename' => $file,
'name' => $filename,
'ext' => $extension,
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => $md5
);
}
else
{
$files[$file]['general'] = array(
'filename' => $file,
'name' => $filename,
'ext' => $extension,
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => $md5
);
}
}
else
{
/*
* Файлы из обычной загрузки
*/
sort($_FILES);
$ufiles = $_FILES[0];
foreach ($ufiles['name'] as $k => $v)
{
if ($ufiles['error'][$k] != 0)
{
continue;
}
//Тип (изображение/файл)
$pathtype = $_POST['pathtype'];
if (strpos($ufiles['name'][$k], '.') !== false)
{
$extension = end(explode('.', $ufiles['name'][$k]));
$filename = substr($ufiles['name'][$k], 0, strlen($ufiles['name'][$k]) - strlen($extension) - 1);
}
else
{
continue;
}
if ($pathtype == 'images')
{
$allowed = $this->ALLOWED_IMAGES;
}
elseif ($pathtype == 'files')
{
$allowed = $this->ALLOWED_FILES;
}
else
{
$allowed = array();
}
//Если не подходит расширение файла
if (!in_array(strtolower($extension), $allowed))
{
continue;
}
$md5 = md5_file($ufiles['tmp_name'][$k]);
$file = Translit(iconv('utf-8', 'cp1251', $ufiles['name'][$k]));
//Проверка на изображение
if ($pathtype == 'images')
{
$files[$file]['imageinfo'] = getimagesize($ufiles['tmp_name'][$k]);
if (empty($files[$file]['imageinfo']))
{
header('HTTP/1.1 403 Forbidden');
exit();
}
}
if (!copy($ufiles['tmp_name'][$k], $dir . '/' . $file))
{
continue;
}
$link = str_replace(array('/\\', '//', '\\\\', '\\'), '/', '/' . str_replace(realpath(DIR_ROOT), '', realpath($dir . '/' . $file)));
if (option('filesModeSetOnUpload'))
{
$mode = option('filesModeDefault');
$mode = empty($mode) ? 0666 : octdec($mode);
@chmod($dir . '/' . $file, $mode);
}
$path = pathinfo($link);
$path = $path['dirname'];
if ($extension == 'jpg' || $extension == 'jpeg')
{
$er = new phpExifReader($dir . '/' . $file);
$files[$file]['exifinfo'] = $er->getImageInfo();
$files[$file]['general'] = array(
'filename' => $file,
'name' => $file,
'ext' => $extension,
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => $md5
);
}
else
{
$files[$file]['general'] = array(
'filename' => $file,
'name' => $file,
'ext' => $extension,
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => $md5
);
}
}
}
$dbfilehandle = fopen($dbfile, "w");
fwrite($dbfilehandle, serialize($files));
fclose($dbfilehandle);
return '';
} | php | function UploadFile($dir, $type)
{
$dir = $this->AccessDir($dir, $type);
if (!$dir)
{
return false;
}
if (!is_dir($dir . '/.thumbs'))
{
$umask = umask(0000);
mkdir($dir . '/.thumbs', 0777);
umask($umask);
}
$dbfile = $dir . '/.thumbs/.db';
if (is_file($dbfile))
{
$dbdata = file_get_contents($dbfile);
}
if (!empty($dbdata))
{
$files = unserialize($dbdata);
}
else
{
$files = array();
}
/* Файл из flash-мультизагрузки */
if (isset($_POST['Filename']))
{
//Тип (изображение/файл)
$pathtype = $_POST['pathtype'];
if (strpos($_POST['Filename'], '.') !== false)
{
$extension = end(explode('.', $_POST['Filename']));
$filename = substr($_POST['Filename'], 0, strlen($_POST['Filename']) - strlen($extension) - 1);
}
else
{
header('HTTP/1.1 403 Forbidden');
exit();
}
if ($pathtype == 'images')
{
$allowed = $this->ALLOWED_IMAGES;
}
elseif ($pathtype == 'files')
{
$allowed = $this->ALLOWED_FILES;
}
else
{
$allowed = array();
}
//Если не подходит разрешение файла
if (!in_array(strtolower($extension), $allowed))
{
header('HTTP/1.1 403 Forbidden');
exit();
}
$md5 = md5_file($_FILES['Filedata']['tmp_name']);
$file = $md5 . '.' . $extension;
//Проверка на изображение
if ($pathtype == 'images')
{
$files[$file]['imageinfo'] = getimagesize($_FILES['Filedata']['tmp_name']);
if (empty($files[$file]['imageinfo']))
{
header('HTTP/1.1 403 Forbidden');
exit();
}
}
if (!copy($_FILES['Filedata']['tmp_name'], $dir . '/' . $file))
{
header('HTTP/1.0 500 Internal Server Error');
exit();
}
$link = str_replace(array('/\\', '//', '\\\\', '\\'), '/', '/' . str_replace(realpath(DIR_ROOT), '', realpath($dir . '/' . $file)));
$path = pathinfo($link);
$path = $path['dirname'];
if ($extension == 'jpg' || $extension == 'jpeg')
{
$er = new phpExifReader($dir . '/' . $file);
$files[$file]['exifinfo'] = $er->getImageInfo();
$files[$file]['general'] = array(
'filename' => $file,
'name' => $filename,
'ext' => $extension,
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => $md5
);
}
else
{
$files[$file]['general'] = array(
'filename' => $file,
'name' => $filename,
'ext' => $extension,
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => $md5
);
}
}
else
{
/*
* Файлы из обычной загрузки
*/
sort($_FILES);
$ufiles = $_FILES[0];
foreach ($ufiles['name'] as $k => $v)
{
if ($ufiles['error'][$k] != 0)
{
continue;
}
//Тип (изображение/файл)
$pathtype = $_POST['pathtype'];
if (strpos($ufiles['name'][$k], '.') !== false)
{
$extension = end(explode('.', $ufiles['name'][$k]));
$filename = substr($ufiles['name'][$k], 0, strlen($ufiles['name'][$k]) - strlen($extension) - 1);
}
else
{
continue;
}
if ($pathtype == 'images')
{
$allowed = $this->ALLOWED_IMAGES;
}
elseif ($pathtype == 'files')
{
$allowed = $this->ALLOWED_FILES;
}
else
{
$allowed = array();
}
//Если не подходит расширение файла
if (!in_array(strtolower($extension), $allowed))
{
continue;
}
$md5 = md5_file($ufiles['tmp_name'][$k]);
$file = Translit(iconv('utf-8', 'cp1251', $ufiles['name'][$k]));
//Проверка на изображение
if ($pathtype == 'images')
{
$files[$file]['imageinfo'] = getimagesize($ufiles['tmp_name'][$k]);
if (empty($files[$file]['imageinfo']))
{
header('HTTP/1.1 403 Forbidden');
exit();
}
}
if (!copy($ufiles['tmp_name'][$k], $dir . '/' . $file))
{
continue;
}
$link = str_replace(array('/\\', '//', '\\\\', '\\'), '/', '/' . str_replace(realpath(DIR_ROOT), '', realpath($dir . '/' . $file)));
if (option('filesModeSetOnUpload'))
{
$mode = option('filesModeDefault');
$mode = empty($mode) ? 0666 : octdec($mode);
@chmod($dir . '/' . $file, $mode);
}
$path = pathinfo($link);
$path = $path['dirname'];
if ($extension == 'jpg' || $extension == 'jpeg')
{
$er = new phpExifReader($dir . '/' . $file);
$files[$file]['exifinfo'] = $er->getImageInfo();
$files[$file]['general'] = array(
'filename' => $file,
'name' => $file,
'ext' => $extension,
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => $md5
);
}
else
{
$files[$file]['general'] = array(
'filename' => $file,
'name' => $file,
'ext' => $extension,
'path' => $path,
'link' => $link,
'size' => filesize($dir . '/' . $file),
'date' => filemtime($dir . '/' . $file),
'width' => $files[$file]['imageinfo'][0],
'height' => $files[$file]['imageinfo'][1],
'md5' => $md5
);
}
}
}
$dbfilehandle = fopen($dbfile, "w");
fwrite($dbfilehandle, serialize($files));
fclose($dbfilehandle);
return '';
} | [
"function",
"UploadFile",
"(",
"$",
"dir",
",",
"$",
"type",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"AccessDir",
"(",
"$",
"dir",
",",
"$",
"type",
")",
";",
"if",
"(",
"!",
"$",
"dir",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
".",
"'/.thumbs'",
")",
")",
"{",
"$",
"umask",
"=",
"umask",
"(",
"0000",
")",
";",
"mkdir",
"(",
"$",
"dir",
".",
"'/.thumbs'",
",",
"0777",
")",
";",
"umask",
"(",
"$",
"umask",
")",
";",
"}",
"$",
"dbfile",
"=",
"$",
"dir",
".",
"'/.thumbs/.db'",
";",
"if",
"(",
"is_file",
"(",
"$",
"dbfile",
")",
")",
"{",
"$",
"dbdata",
"=",
"file_get_contents",
"(",
"$",
"dbfile",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"dbdata",
")",
")",
"{",
"$",
"files",
"=",
"unserialize",
"(",
"$",
"dbdata",
")",
";",
"}",
"else",
"{",
"$",
"files",
"=",
"array",
"(",
")",
";",
"}",
"/* Файл из flash-мультизагрузки */",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'Filename'",
"]",
")",
")",
"{",
"//Тип (изображение/файл)",
"$",
"pathtype",
"=",
"$",
"_POST",
"[",
"'pathtype'",
"]",
";",
"if",
"(",
"strpos",
"(",
"$",
"_POST",
"[",
"'Filename'",
"]",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"extension",
"=",
"end",
"(",
"explode",
"(",
"'.'",
",",
"$",
"_POST",
"[",
"'Filename'",
"]",
")",
")",
";",
"$",
"filename",
"=",
"substr",
"(",
"$",
"_POST",
"[",
"'Filename'",
"]",
",",
"0",
",",
"strlen",
"(",
"$",
"_POST",
"[",
"'Filename'",
"]",
")",
"-",
"strlen",
"(",
"$",
"extension",
")",
"-",
"1",
")",
";",
"}",
"else",
"{",
"header",
"(",
"'HTTP/1.1 403 Forbidden'",
")",
";",
"exit",
"(",
")",
";",
"}",
"if",
"(",
"$",
"pathtype",
"==",
"'images'",
")",
"{",
"$",
"allowed",
"=",
"$",
"this",
"->",
"ALLOWED_IMAGES",
";",
"}",
"elseif",
"(",
"$",
"pathtype",
"==",
"'files'",
")",
"{",
"$",
"allowed",
"=",
"$",
"this",
"->",
"ALLOWED_FILES",
";",
"}",
"else",
"{",
"$",
"allowed",
"=",
"array",
"(",
")",
";",
"}",
"//Если не подходит разрешение файла",
"if",
"(",
"!",
"in_array",
"(",
"strtolower",
"(",
"$",
"extension",
")",
",",
"$",
"allowed",
")",
")",
"{",
"header",
"(",
"'HTTP/1.1 403 Forbidden'",
")",
";",
"exit",
"(",
")",
";",
"}",
"$",
"md5",
"=",
"md5_file",
"(",
"$",
"_FILES",
"[",
"'Filedata'",
"]",
"[",
"'tmp_name'",
"]",
")",
";",
"$",
"file",
"=",
"$",
"md5",
".",
"'.'",
".",
"$",
"extension",
";",
"//Проверка на изображение",
"if",
"(",
"$",
"pathtype",
"==",
"'images'",
")",
"{",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"=",
"getimagesize",
"(",
"$",
"_FILES",
"[",
"'Filedata'",
"]",
"[",
"'tmp_name'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
")",
")",
"{",
"header",
"(",
"'HTTP/1.1 403 Forbidden'",
")",
";",
"exit",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"copy",
"(",
"$",
"_FILES",
"[",
"'Filedata'",
"]",
"[",
"'tmp_name'",
"]",
",",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
")",
"{",
"header",
"(",
"'HTTP/1.0 500 Internal Server Error'",
")",
";",
"exit",
"(",
")",
";",
"}",
"$",
"link",
"=",
"str_replace",
"(",
"array",
"(",
"'/\\\\'",
",",
"'//'",
",",
"'\\\\\\\\'",
",",
"'\\\\'",
")",
",",
"'/'",
",",
"'/'",
".",
"str_replace",
"(",
"realpath",
"(",
"DIR_ROOT",
")",
",",
"''",
",",
"realpath",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
")",
")",
";",
"$",
"path",
"=",
"pathinfo",
"(",
"$",
"link",
")",
";",
"$",
"path",
"=",
"$",
"path",
"[",
"'dirname'",
"]",
";",
"if",
"(",
"$",
"extension",
"==",
"'jpg'",
"||",
"$",
"extension",
"==",
"'jpeg'",
")",
"{",
"$",
"er",
"=",
"new",
"phpExifReader",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
";",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'exifinfo'",
"]",
"=",
"$",
"er",
"->",
"getImageInfo",
"(",
")",
";",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'general'",
"]",
"=",
"array",
"(",
"'filename'",
"=>",
"$",
"file",
",",
"'name'",
"=>",
"$",
"filename",
",",
"'ext'",
"=>",
"$",
"extension",
",",
"'path'",
"=>",
"$",
"path",
",",
"'link'",
"=>",
"$",
"link",
",",
"'size'",
"=>",
"filesize",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'date'",
"=>",
"filemtime",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'width'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"0",
"]",
",",
"'height'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"1",
"]",
",",
"'md5'",
"=>",
"$",
"md5",
")",
";",
"}",
"else",
"{",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'general'",
"]",
"=",
"array",
"(",
"'filename'",
"=>",
"$",
"file",
",",
"'name'",
"=>",
"$",
"filename",
",",
"'ext'",
"=>",
"$",
"extension",
",",
"'path'",
"=>",
"$",
"path",
",",
"'link'",
"=>",
"$",
"link",
",",
"'size'",
"=>",
"filesize",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'date'",
"=>",
"filemtime",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'width'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"0",
"]",
",",
"'height'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"1",
"]",
",",
"'md5'",
"=>",
"$",
"md5",
")",
";",
"}",
"}",
"else",
"{",
"/*\n * Файлы из обычной загрузки\n */",
"sort",
"(",
"$",
"_FILES",
")",
";",
"$",
"ufiles",
"=",
"$",
"_FILES",
"[",
"0",
"]",
";",
"foreach",
"(",
"$",
"ufiles",
"[",
"'name'",
"]",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"ufiles",
"[",
"'error'",
"]",
"[",
"$",
"k",
"]",
"!=",
"0",
")",
"{",
"continue",
";",
"}",
"//Тип (изображение/файл)",
"$",
"pathtype",
"=",
"$",
"_POST",
"[",
"'pathtype'",
"]",
";",
"if",
"(",
"strpos",
"(",
"$",
"ufiles",
"[",
"'name'",
"]",
"[",
"$",
"k",
"]",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"extension",
"=",
"end",
"(",
"explode",
"(",
"'.'",
",",
"$",
"ufiles",
"[",
"'name'",
"]",
"[",
"$",
"k",
"]",
")",
")",
";",
"$",
"filename",
"=",
"substr",
"(",
"$",
"ufiles",
"[",
"'name'",
"]",
"[",
"$",
"k",
"]",
",",
"0",
",",
"strlen",
"(",
"$",
"ufiles",
"[",
"'name'",
"]",
"[",
"$",
"k",
"]",
")",
"-",
"strlen",
"(",
"$",
"extension",
")",
"-",
"1",
")",
";",
"}",
"else",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"pathtype",
"==",
"'images'",
")",
"{",
"$",
"allowed",
"=",
"$",
"this",
"->",
"ALLOWED_IMAGES",
";",
"}",
"elseif",
"(",
"$",
"pathtype",
"==",
"'files'",
")",
"{",
"$",
"allowed",
"=",
"$",
"this",
"->",
"ALLOWED_FILES",
";",
"}",
"else",
"{",
"$",
"allowed",
"=",
"array",
"(",
")",
";",
"}",
"//Если не подходит расширение файла",
"if",
"(",
"!",
"in_array",
"(",
"strtolower",
"(",
"$",
"extension",
")",
",",
"$",
"allowed",
")",
")",
"{",
"continue",
";",
"}",
"$",
"md5",
"=",
"md5_file",
"(",
"$",
"ufiles",
"[",
"'tmp_name'",
"]",
"[",
"$",
"k",
"]",
")",
";",
"$",
"file",
"=",
"Translit",
"(",
"iconv",
"(",
"'utf-8'",
",",
"'cp1251'",
",",
"$",
"ufiles",
"[",
"'name'",
"]",
"[",
"$",
"k",
"]",
")",
")",
";",
"//Проверка на изображение",
"if",
"(",
"$",
"pathtype",
"==",
"'images'",
")",
"{",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"=",
"getimagesize",
"(",
"$",
"ufiles",
"[",
"'tmp_name'",
"]",
"[",
"$",
"k",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
")",
")",
"{",
"header",
"(",
"'HTTP/1.1 403 Forbidden'",
")",
";",
"exit",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"copy",
"(",
"$",
"ufiles",
"[",
"'tmp_name'",
"]",
"[",
"$",
"k",
"]",
",",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
")",
"{",
"continue",
";",
"}",
"$",
"link",
"=",
"str_replace",
"(",
"array",
"(",
"'/\\\\'",
",",
"'//'",
",",
"'\\\\\\\\'",
",",
"'\\\\'",
")",
",",
"'/'",
",",
"'/'",
".",
"str_replace",
"(",
"realpath",
"(",
"DIR_ROOT",
")",
",",
"''",
",",
"realpath",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
")",
")",
";",
"if",
"(",
"option",
"(",
"'filesModeSetOnUpload'",
")",
")",
"{",
"$",
"mode",
"=",
"option",
"(",
"'filesModeDefault'",
")",
";",
"$",
"mode",
"=",
"empty",
"(",
"$",
"mode",
")",
"?",
"0666",
":",
"octdec",
"(",
"$",
"mode",
")",
";",
"@",
"chmod",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
",",
"$",
"mode",
")",
";",
"}",
"$",
"path",
"=",
"pathinfo",
"(",
"$",
"link",
")",
";",
"$",
"path",
"=",
"$",
"path",
"[",
"'dirname'",
"]",
";",
"if",
"(",
"$",
"extension",
"==",
"'jpg'",
"||",
"$",
"extension",
"==",
"'jpeg'",
")",
"{",
"$",
"er",
"=",
"new",
"phpExifReader",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
";",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'exifinfo'",
"]",
"=",
"$",
"er",
"->",
"getImageInfo",
"(",
")",
";",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'general'",
"]",
"=",
"array",
"(",
"'filename'",
"=>",
"$",
"file",
",",
"'name'",
"=>",
"$",
"file",
",",
"'ext'",
"=>",
"$",
"extension",
",",
"'path'",
"=>",
"$",
"path",
",",
"'link'",
"=>",
"$",
"link",
",",
"'size'",
"=>",
"filesize",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'date'",
"=>",
"filemtime",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'width'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"0",
"]",
",",
"'height'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"1",
"]",
",",
"'md5'",
"=>",
"$",
"md5",
")",
";",
"}",
"else",
"{",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'general'",
"]",
"=",
"array",
"(",
"'filename'",
"=>",
"$",
"file",
",",
"'name'",
"=>",
"$",
"file",
",",
"'ext'",
"=>",
"$",
"extension",
",",
"'path'",
"=>",
"$",
"path",
",",
"'link'",
"=>",
"$",
"link",
",",
"'size'",
"=>",
"filesize",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'date'",
"=>",
"filemtime",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
",",
"'width'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"0",
"]",
",",
"'height'",
"=>",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'imageinfo'",
"]",
"[",
"1",
"]",
",",
"'md5'",
"=>",
"$",
"md5",
")",
";",
"}",
"}",
"}",
"$",
"dbfilehandle",
"=",
"fopen",
"(",
"$",
"dbfile",
",",
"\"w\"",
")",
";",
"fwrite",
"(",
"$",
"dbfilehandle",
",",
"serialize",
"(",
"$",
"files",
")",
")",
";",
"fclose",
"(",
"$",
"dbfilehandle",
")",
";",
"return",
"''",
";",
"}"
] | Выполняет загрузку файла на сервер
@param string $dir
@param string $type
@return string
@since 2.14 | [
"Выполняет",
"загрузку",
"файла",
"на",
"сервер"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/index.php#L580-L816 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/index.php | TinyImageManager.RenameFile | function RenameFile($type, $dir, $filename, $newname)
{
$dir = $this->AccessDir($dir, $type);
if (!$dir)
{
return false;
}
$filename = trim($filename);
if (empty($filename))
{
return 'error';
}
if (!is_dir($dir . '/.thumbs'))
{
return 'error';
}
$dbfile = $dir . '/.thumbs/.db';
if (is_file($dbfile))
{
$dbfilehandle = fopen($dbfile, "r");
$dblength = filesize($dbfile);
if ($dblength > 0)
{
$dbdata = fread($dbfilehandle, $dblength);
}
else
{
$dbdata = '';
}
fclose($dbfilehandle);
}
else
{
return 'error';
}
$files = unserialize($dbdata);
foreach ($files as $file => $fdata)
{
if ($file == $filename)
{
$files[$file]['general']['name'] = $newname;
break;
}
}
$dbfilehandle = fopen($dbfile, "w");
fwrite($dbfilehandle, serialize($files));
fclose($dbfilehandle);
return 'ok';
} | php | function RenameFile($type, $dir, $filename, $newname)
{
$dir = $this->AccessDir($dir, $type);
if (!$dir)
{
return false;
}
$filename = trim($filename);
if (empty($filename))
{
return 'error';
}
if (!is_dir($dir . '/.thumbs'))
{
return 'error';
}
$dbfile = $dir . '/.thumbs/.db';
if (is_file($dbfile))
{
$dbfilehandle = fopen($dbfile, "r");
$dblength = filesize($dbfile);
if ($dblength > 0)
{
$dbdata = fread($dbfilehandle, $dblength);
}
else
{
$dbdata = '';
}
fclose($dbfilehandle);
}
else
{
return 'error';
}
$files = unserialize($dbdata);
foreach ($files as $file => $fdata)
{
if ($file == $filename)
{
$files[$file]['general']['name'] = $newname;
break;
}
}
$dbfilehandle = fopen($dbfile, "w");
fwrite($dbfilehandle, serialize($files));
fclose($dbfilehandle);
return 'ok';
} | [
"function",
"RenameFile",
"(",
"$",
"type",
",",
"$",
"dir",
",",
"$",
"filename",
",",
"$",
"newname",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"AccessDir",
"(",
"$",
"dir",
",",
"$",
"type",
")",
";",
"if",
"(",
"!",
"$",
"dir",
")",
"{",
"return",
"false",
";",
"}",
"$",
"filename",
"=",
"trim",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"'error'",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
".",
"'/.thumbs'",
")",
")",
"{",
"return",
"'error'",
";",
"}",
"$",
"dbfile",
"=",
"$",
"dir",
".",
"'/.thumbs/.db'",
";",
"if",
"(",
"is_file",
"(",
"$",
"dbfile",
")",
")",
"{",
"$",
"dbfilehandle",
"=",
"fopen",
"(",
"$",
"dbfile",
",",
"\"r\"",
")",
";",
"$",
"dblength",
"=",
"filesize",
"(",
"$",
"dbfile",
")",
";",
"if",
"(",
"$",
"dblength",
">",
"0",
")",
"{",
"$",
"dbdata",
"=",
"fread",
"(",
"$",
"dbfilehandle",
",",
"$",
"dblength",
")",
";",
"}",
"else",
"{",
"$",
"dbdata",
"=",
"''",
";",
"}",
"fclose",
"(",
"$",
"dbfilehandle",
")",
";",
"}",
"else",
"{",
"return",
"'error'",
";",
"}",
"$",
"files",
"=",
"unserialize",
"(",
"$",
"dbdata",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
"=>",
"$",
"fdata",
")",
"{",
"if",
"(",
"$",
"file",
"==",
"$",
"filename",
")",
"{",
"$",
"files",
"[",
"$",
"file",
"]",
"[",
"'general'",
"]",
"[",
"'name'",
"]",
"=",
"$",
"newname",
";",
"break",
";",
"}",
"}",
"$",
"dbfilehandle",
"=",
"fopen",
"(",
"$",
"dbfile",
",",
"\"w\"",
")",
";",
"fwrite",
"(",
"$",
"dbfilehandle",
",",
"serialize",
"(",
"$",
"files",
")",
")",
";",
"fclose",
"(",
"$",
"dbfilehandle",
")",
";",
"return",
"'ok'",
";",
"}"
] | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/index.php#L821-L877 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/index.php | TinyImageManager.ShowDir | private function ShowDir($dir, $type)
{
$dir = $this->CallDir($dir, $type);
if (!$dir)
{
//echo 'Ошибка чтения, возможно нет доступа.';
exit();
}
$ret = '';
foreach ($dir as $v)
{
$thumb = $this->GetThumb($v['general']['path'], $v['general']['md5'], $v['general']['filename'], 2, 100, 100);
if ($v['general']['width'] > WIDTH_TO_LINK || $v['general']['height'] > HEIGHT_TO_LINK)
{
if ($v['general']['width'] > $v['general']['height'])
{
$middle_thumb = $this->GetThumb($v['general']['path'], $v['general']['md5'], $v['general']['filename'], 0, WIDTH_TO_LINK, 0);
}
else
{
$middle_thumb = $this->GetThumb($v['general']['path'], $v['general']['md5'], $v['general']['filename'], 0, 0, HEIGHT_TO_LINK);
}
list($middle_width, $middle_height) = getimagesize(DIR_ROOT . $middle_thumb);
$middle_thumb_attr = 'fmiddle="' . $middle_thumb . '" fmiddlewidth="' . $middle_width . '" fmiddleheight="' . $middle_height . '" fclass="' . CLASS_LINK . '" frel="' . REL_LINK . '"';
}
else
{
$middle_thumb = '';
$middle_thumb_attr = '';
}
$ret .= '
<table class="imageBlock0" cellpadding="0" cellspacing="0" filename="' . $v['general']['filename'] . '" fname="' . $v['general']['name'] . '" ext="' . strtoupper($v['general']['ext']) . '" path="' . $v['general']['path'] . '" linkto="' . $v['general']['link'] . '" fsize="' . $v['general']['size'] . '" date="' . date('d.m.Y H:i', $v['general']['date']) . '" fwidth="' . $v['general']['width'] . '" fheight="' . $v['general']['height'] . '" md5="' . $v['general']['md5'] . '" ' . $middle_thumb_attr . '><tr><td valign="bottom" align="center">
<div class="imageBlock1">
<div class="imageImage">
<img src="' . substr(Eresus_CMS::getLegacyKernel()->root, 0, -1) . $thumb . '" width="100" height="100" alt="' . $v['general']['name'] . '" />
</div>
<div class="imageName">' . $v['general']['name'] . '</div>
</div>
</td></tr></table>
';
}
return $ret;
} | php | private function ShowDir($dir, $type)
{
$dir = $this->CallDir($dir, $type);
if (!$dir)
{
//echo 'Ошибка чтения, возможно нет доступа.';
exit();
}
$ret = '';
foreach ($dir as $v)
{
$thumb = $this->GetThumb($v['general']['path'], $v['general']['md5'], $v['general']['filename'], 2, 100, 100);
if ($v['general']['width'] > WIDTH_TO_LINK || $v['general']['height'] > HEIGHT_TO_LINK)
{
if ($v['general']['width'] > $v['general']['height'])
{
$middle_thumb = $this->GetThumb($v['general']['path'], $v['general']['md5'], $v['general']['filename'], 0, WIDTH_TO_LINK, 0);
}
else
{
$middle_thumb = $this->GetThumb($v['general']['path'], $v['general']['md5'], $v['general']['filename'], 0, 0, HEIGHT_TO_LINK);
}
list($middle_width, $middle_height) = getimagesize(DIR_ROOT . $middle_thumb);
$middle_thumb_attr = 'fmiddle="' . $middle_thumb . '" fmiddlewidth="' . $middle_width . '" fmiddleheight="' . $middle_height . '" fclass="' . CLASS_LINK . '" frel="' . REL_LINK . '"';
}
else
{
$middle_thumb = '';
$middle_thumb_attr = '';
}
$ret .= '
<table class="imageBlock0" cellpadding="0" cellspacing="0" filename="' . $v['general']['filename'] . '" fname="' . $v['general']['name'] . '" ext="' . strtoupper($v['general']['ext']) . '" path="' . $v['general']['path'] . '" linkto="' . $v['general']['link'] . '" fsize="' . $v['general']['size'] . '" date="' . date('d.m.Y H:i', $v['general']['date']) . '" fwidth="' . $v['general']['width'] . '" fheight="' . $v['general']['height'] . '" md5="' . $v['general']['md5'] . '" ' . $middle_thumb_attr . '><tr><td valign="bottom" align="center">
<div class="imageBlock1">
<div class="imageImage">
<img src="' . substr(Eresus_CMS::getLegacyKernel()->root, 0, -1) . $thumb . '" width="100" height="100" alt="' . $v['general']['name'] . '" />
</div>
<div class="imageName">' . $v['general']['name'] . '</div>
</div>
</td></tr></table>
';
}
return $ret;
} | [
"private",
"function",
"ShowDir",
"(",
"$",
"dir",
",",
"$",
"type",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"CallDir",
"(",
"$",
"dir",
",",
"$",
"type",
")",
";",
"if",
"(",
"!",
"$",
"dir",
")",
"{",
"//echo 'Ошибка чтения, возможно нет доступа.';",
"exit",
"(",
")",
";",
"}",
"$",
"ret",
"=",
"''",
";",
"foreach",
"(",
"$",
"dir",
"as",
"$",
"v",
")",
"{",
"$",
"thumb",
"=",
"$",
"this",
"->",
"GetThumb",
"(",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'path'",
"]",
",",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'md5'",
"]",
",",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'filename'",
"]",
",",
"2",
",",
"100",
",",
"100",
")",
";",
"if",
"(",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'width'",
"]",
">",
"WIDTH_TO_LINK",
"||",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'height'",
"]",
">",
"HEIGHT_TO_LINK",
")",
"{",
"if",
"(",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'width'",
"]",
">",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'height'",
"]",
")",
"{",
"$",
"middle_thumb",
"=",
"$",
"this",
"->",
"GetThumb",
"(",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'path'",
"]",
",",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'md5'",
"]",
",",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'filename'",
"]",
",",
"0",
",",
"WIDTH_TO_LINK",
",",
"0",
")",
";",
"}",
"else",
"{",
"$",
"middle_thumb",
"=",
"$",
"this",
"->",
"GetThumb",
"(",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'path'",
"]",
",",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'md5'",
"]",
",",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'filename'",
"]",
",",
"0",
",",
"0",
",",
"HEIGHT_TO_LINK",
")",
";",
"}",
"list",
"(",
"$",
"middle_width",
",",
"$",
"middle_height",
")",
"=",
"getimagesize",
"(",
"DIR_ROOT",
".",
"$",
"middle_thumb",
")",
";",
"$",
"middle_thumb_attr",
"=",
"'fmiddle=\"'",
".",
"$",
"middle_thumb",
".",
"'\" fmiddlewidth=\"'",
".",
"$",
"middle_width",
".",
"'\" fmiddleheight=\"'",
".",
"$",
"middle_height",
".",
"'\" fclass=\"'",
".",
"CLASS_LINK",
".",
"'\" frel=\"'",
".",
"REL_LINK",
".",
"'\"'",
";",
"}",
"else",
"{",
"$",
"middle_thumb",
"=",
"''",
";",
"$",
"middle_thumb_attr",
"=",
"''",
";",
"}",
"$",
"ret",
".=",
"'\n <table class=\"imageBlock0\" cellpadding=\"0\" cellspacing=\"0\" filename=\"'",
".",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'filename'",
"]",
".",
"'\" fname=\"'",
".",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'name'",
"]",
".",
"'\" ext=\"'",
".",
"strtoupper",
"(",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'ext'",
"]",
")",
".",
"'\" path=\"'",
".",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'path'",
"]",
".",
"'\" linkto=\"'",
".",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'link'",
"]",
".",
"'\" fsize=\"'",
".",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'size'",
"]",
".",
"'\" date=\"'",
".",
"date",
"(",
"'d.m.Y H:i'",
",",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'date'",
"]",
")",
".",
"'\" fwidth=\"'",
".",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'width'",
"]",
".",
"'\" fheight=\"'",
".",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'height'",
"]",
".",
"'\" md5=\"'",
".",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'md5'",
"]",
".",
"'\" '",
".",
"$",
"middle_thumb_attr",
".",
"'><tr><td valign=\"bottom\" align=\"center\">\n <div class=\"imageBlock1\">\n <div class=\"imageImage\">\n <img src=\"'",
".",
"substr",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
",",
"0",
",",
"-",
"1",
")",
".",
"$",
"thumb",
".",
"'\" width=\"100\" height=\"100\" alt=\"'",
".",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'name'",
"]",
".",
"'\" />\n </div>\n <div class=\"imageName\">'",
".",
"$",
"v",
"[",
"'general'",
"]",
"[",
"'name'",
"]",
".",
"'</div>\n </div>\n </td></tr></table>\n\t\t\t'",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Возвращает содержимое для области файлов
@param string $dir
@param string $type
@return string | [
"Возвращает",
"содержимое",
"для",
"области",
"файлов"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/index.php#L888-L932 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/index.php | TinyImageManager.GetThumb | function GetThumb($dir, $md5, $filename, $mode, $width = 100, $height = 100)
{
$path = realpath(DIR_ROOT . '/' . $dir);
if (is_file($path . '/.thumbs/' . $md5 . '_' . $width . '_' . $height . '_' . $mode . '.jpg'))
{
return $dir . '/.thumbs/' . $md5 . '_' . $width . '_' . $height . '_' . $mode . '.jpg';
}
$t = new Image_Toolbox($path . '/' . $filename);
$t->newOutputSize($width, $height, $mode, false, '#FFFFFF');
$filename = '/.thumbs/' . $md5 . '_' . $width . '_' . $height . '_' . $mode . '.jpg';
$t->save($path . $filename, 'jpg', 80);
chmod($path . $filename, 0666);
return $dir . $filename;
} | php | function GetThumb($dir, $md5, $filename, $mode, $width = 100, $height = 100)
{
$path = realpath(DIR_ROOT . '/' . $dir);
if (is_file($path . '/.thumbs/' . $md5 . '_' . $width . '_' . $height . '_' . $mode . '.jpg'))
{
return $dir . '/.thumbs/' . $md5 . '_' . $width . '_' . $height . '_' . $mode . '.jpg';
}
$t = new Image_Toolbox($path . '/' . $filename);
$t->newOutputSize($width, $height, $mode, false, '#FFFFFF');
$filename = '/.thumbs/' . $md5 . '_' . $width . '_' . $height . '_' . $mode . '.jpg';
$t->save($path . $filename, 'jpg', 80);
chmod($path . $filename, 0666);
return $dir . $filename;
} | [
"function",
"GetThumb",
"(",
"$",
"dir",
",",
"$",
"md5",
",",
"$",
"filename",
",",
"$",
"mode",
",",
"$",
"width",
"=",
"100",
",",
"$",
"height",
"=",
"100",
")",
"{",
"$",
"path",
"=",
"realpath",
"(",
"DIR_ROOT",
".",
"'/'",
".",
"$",
"dir",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"path",
".",
"'/.thumbs/'",
".",
"$",
"md5",
".",
"'_'",
".",
"$",
"width",
".",
"'_'",
".",
"$",
"height",
".",
"'_'",
".",
"$",
"mode",
".",
"'.jpg'",
")",
")",
"{",
"return",
"$",
"dir",
".",
"'/.thumbs/'",
".",
"$",
"md5",
".",
"'_'",
".",
"$",
"width",
".",
"'_'",
".",
"$",
"height",
".",
"'_'",
".",
"$",
"mode",
".",
"'.jpg'",
";",
"}",
"$",
"t",
"=",
"new",
"Image_Toolbox",
"(",
"$",
"path",
".",
"'/'",
".",
"$",
"filename",
")",
";",
"$",
"t",
"->",
"newOutputSize",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"mode",
",",
"false",
",",
"'#FFFFFF'",
")",
";",
"$",
"filename",
"=",
"'/.thumbs/'",
".",
"$",
"md5",
".",
"'_'",
".",
"$",
"width",
".",
"'_'",
".",
"$",
"height",
".",
"'_'",
".",
"$",
"mode",
".",
"'.jpg'",
";",
"$",
"t",
"->",
"save",
"(",
"$",
"path",
".",
"$",
"filename",
",",
"'jpg'",
",",
"80",
")",
";",
"chmod",
"(",
"$",
"path",
".",
"$",
"filename",
",",
"0666",
")",
";",
"return",
"$",
"dir",
".",
"$",
"filename",
";",
"}"
] | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/index.php#L937-L951 |
Eresus/EresusCMS | src/core/CMS/Page/Content.php | Eresus_CMS_Page_Content.render | public function render()
{
$tmpl = new Eresus_Template();
$tmpl->setSource($this->content);
$event = new Eresus_Event_Render($tmpl->compile());
Eresus_Kernel::app()->getEventDispatcher()
->dispatch('cms.client.render_content', $event);
return $event->getText();
} | php | public function render()
{
$tmpl = new Eresus_Template();
$tmpl->setSource($this->content);
$event = new Eresus_Event_Render($tmpl->compile());
Eresus_Kernel::app()->getEventDispatcher()
->dispatch('cms.client.render_content', $event);
return $event->getText();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"tmpl",
"=",
"new",
"Eresus_Template",
"(",
")",
";",
"$",
"tmpl",
"->",
"setSource",
"(",
"$",
"this",
"->",
"content",
")",
";",
"$",
"event",
"=",
"new",
"Eresus_Event_Render",
"(",
"$",
"tmpl",
"->",
"compile",
"(",
")",
")",
";",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getEventDispatcher",
"(",
")",
"->",
"dispatch",
"(",
"'cms.client.render_content'",
",",
"$",
"event",
")",
";",
"return",
"$",
"event",
"->",
"getText",
"(",
")",
";",
"}"
] | Отрисовывает контент
Контент обрабатывается как шаблон, в него подставляются глобальные переменные, и проводится
обработка модулями расширений в соответствии с зарегистрированными обработчиками событий.
@return string
@since 3.01 | [
"Отрисовывает",
"контент"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS/Page/Content.php#L96-L105 |
phpnfe/tools | src/XML.php | XML.get | public function get($key)
{
if (Str::contains($key, '|')) {
$opcoes = explode('|', $key);
foreach ($opcoes as $op) {
$achado = $this->get($op);
if (! $achado->isNull()) {
return $achado;
}
}
return new XMLGet(null);
}
$base = $this;
$niveis = ($key == '') ? [] : explode('.', $key);
foreach ($niveis as $i => $nivel) {
// Verificar se base eh nula
if (is_null($base)) {
return new XMLGet(null);
}
$elem = $base->getElementsByTagName($nivel);
$base = ($elem->length > 0) ? $elem->item(0) : null;
}
// Retornar o conteúdo do ultimo nível
if (! is_null($base)) {
return new XMLGet($base);
}
return new XMLGet(null);
} | php | public function get($key)
{
if (Str::contains($key, '|')) {
$opcoes = explode('|', $key);
foreach ($opcoes as $op) {
$achado = $this->get($op);
if (! $achado->isNull()) {
return $achado;
}
}
return new XMLGet(null);
}
$base = $this;
$niveis = ($key == '') ? [] : explode('.', $key);
foreach ($niveis as $i => $nivel) {
// Verificar se base eh nula
if (is_null($base)) {
return new XMLGet(null);
}
$elem = $base->getElementsByTagName($nivel);
$base = ($elem->length > 0) ? $elem->item(0) : null;
}
// Retornar o conteúdo do ultimo nível
if (! is_null($base)) {
return new XMLGet($base);
}
return new XMLGet(null);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"Str",
"::",
"contains",
"(",
"$",
"key",
",",
"'|'",
")",
")",
"{",
"$",
"opcoes",
"=",
"explode",
"(",
"'|'",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"opcoes",
"as",
"$",
"op",
")",
"{",
"$",
"achado",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"op",
")",
";",
"if",
"(",
"!",
"$",
"achado",
"->",
"isNull",
"(",
")",
")",
"{",
"return",
"$",
"achado",
";",
"}",
"}",
"return",
"new",
"XMLGet",
"(",
"null",
")",
";",
"}",
"$",
"base",
"=",
"$",
"this",
";",
"$",
"niveis",
"=",
"(",
"$",
"key",
"==",
"''",
")",
"?",
"[",
"]",
":",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"niveis",
"as",
"$",
"i",
"=>",
"$",
"nivel",
")",
"{",
"// Verificar se base eh nula",
"if",
"(",
"is_null",
"(",
"$",
"base",
")",
")",
"{",
"return",
"new",
"XMLGet",
"(",
"null",
")",
";",
"}",
"$",
"elem",
"=",
"$",
"base",
"->",
"getElementsByTagName",
"(",
"$",
"nivel",
")",
";",
"$",
"base",
"=",
"(",
"$",
"elem",
"->",
"length",
">",
"0",
")",
"?",
"$",
"elem",
"->",
"item",
"(",
"0",
")",
":",
"null",
";",
"}",
"// Retornar o conteúdo do ultimo nível",
"if",
"(",
"!",
"is_null",
"(",
"$",
"base",
")",
")",
"{",
"return",
"new",
"XMLGet",
"(",
"$",
"base",
")",
";",
"}",
"return",
"new",
"XMLGet",
"(",
"null",
")",
";",
"}"
] | Retorna informações do XML com base no caminho separado por ponto.
@param $key
@return XMLGet | [
"Retorna",
"informações",
"do",
"XML",
"com",
"base",
"no",
"caminho",
"separado",
"por",
"ponto",
"."
] | train | https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/XML.php#L25-L59 |
phpnfe/tools | src/XML.php | XML.getDup | public function getDup($contador)
{
$dup = $this->getElementsByTagName('dup')->item($contador);
return self::createByXml($dup->C14N());
} | php | public function getDup($contador)
{
$dup = $this->getElementsByTagName('dup')->item($contador);
return self::createByXml($dup->C14N());
} | [
"public",
"function",
"getDup",
"(",
"$",
"contador",
")",
"{",
"$",
"dup",
"=",
"$",
"this",
"->",
"getElementsByTagName",
"(",
"'dup'",
")",
"->",
"item",
"(",
"$",
"contador",
")",
";",
"return",
"self",
"::",
"createByXml",
"(",
"$",
"dup",
"->",
"C14N",
"(",
")",
")",
";",
"}"
] | Pega a propriedade do Dup.
@param $contador
@return XMLGet
@deprecated | [
"Pega",
"a",
"propriedade",
"do",
"Dup",
"."
] | train | https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/XML.php#L77-L82 |
phpnfe/tools | src/XML.php | XML.makeFileName | public static function makeFileName($cnpj, $serie, $nnf, $ext, $modelo = '-Nfe')
{
$nome = $cnpj;
$nome .= '_S' . str_pad($serie, 3, '0', STR_PAD_LEFT);
$nome .= '_N' . str_pad($nnf, 9, '0', STR_PAD_LEFT);
$nome .= $modelo . '.' . $ext;
return $nome;
} | php | public static function makeFileName($cnpj, $serie, $nnf, $ext, $modelo = '-Nfe')
{
$nome = $cnpj;
$nome .= '_S' . str_pad($serie, 3, '0', STR_PAD_LEFT);
$nome .= '_N' . str_pad($nnf, 9, '0', STR_PAD_LEFT);
$nome .= $modelo . '.' . $ext;
return $nome;
} | [
"public",
"static",
"function",
"makeFileName",
"(",
"$",
"cnpj",
",",
"$",
"serie",
",",
"$",
"nnf",
",",
"$",
"ext",
",",
"$",
"modelo",
"=",
"'-Nfe'",
")",
"{",
"$",
"nome",
"=",
"$",
"cnpj",
";",
"$",
"nome",
".=",
"'_S'",
".",
"str_pad",
"(",
"$",
"serie",
",",
"3",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
";",
"$",
"nome",
".=",
"'_N'",
".",
"str_pad",
"(",
"$",
"nnf",
",",
"9",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
";",
"$",
"nome",
".=",
"$",
"modelo",
".",
"'.'",
".",
"$",
"ext",
";",
"return",
"$",
"nome",
";",
"}"
] | Monta o nome padrão do arquivo XML e PDF.
@param $cnpj
@param $serie
@param $nnf
@param $ext
@param string $modelo
@return string
@deprecated | [
"Monta",
"o",
"nome",
"padrão",
"do",
"arquivo",
"XML",
"e",
"PDF",
"."
] | train | https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/XML.php#L117-L125 |
SergioMadness/query-builder | src/abstraction/SelectBuilder.php | SelectBuilder.generate | public function generate()
{
$result = '';
$table = $this->buildTable();
$select = $this->buildSelectFields();
$where = $this->buildWhere();
$having = $this->buildHaving();
$join = $this->buildJoin();
$limit = $this->buildLimit();
$group = $this->buildGroup();
$union = $this->buildUnion();
$order = $this->buildOrder();
$result .= 'SELECT '.$select.' FROM '.$table;
if ($join != '') {
$result .= ' '.$join;
}
if ($where != '') {
$result .= ' '.$where;
}
if ($group != '') {
$result .= ' '.$group;
}
if ($order != '') {
$result .= ' '.$order;
}
if ($limit != '') {
$result .= ' '.$limit;
}
if ($having != '') {
$result .= ' '.$having;
}
if ($union != '') {
$result = '('.$result.')'.$union;
}
if ($this->isForUpdate()) {
$result .= ' FOR UPDATE';
}
return $result;
} | php | public function generate()
{
$result = '';
$table = $this->buildTable();
$select = $this->buildSelectFields();
$where = $this->buildWhere();
$having = $this->buildHaving();
$join = $this->buildJoin();
$limit = $this->buildLimit();
$group = $this->buildGroup();
$union = $this->buildUnion();
$order = $this->buildOrder();
$result .= 'SELECT '.$select.' FROM '.$table;
if ($join != '') {
$result .= ' '.$join;
}
if ($where != '') {
$result .= ' '.$where;
}
if ($group != '') {
$result .= ' '.$group;
}
if ($order != '') {
$result .= ' '.$order;
}
if ($limit != '') {
$result .= ' '.$limit;
}
if ($having != '') {
$result .= ' '.$having;
}
if ($union != '') {
$result = '('.$result.')'.$union;
}
if ($this->isForUpdate()) {
$result .= ' FOR UPDATE';
}
return $result;
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"buildTable",
"(",
")",
";",
"$",
"select",
"=",
"$",
"this",
"->",
"buildSelectFields",
"(",
")",
";",
"$",
"where",
"=",
"$",
"this",
"->",
"buildWhere",
"(",
")",
";",
"$",
"having",
"=",
"$",
"this",
"->",
"buildHaving",
"(",
")",
";",
"$",
"join",
"=",
"$",
"this",
"->",
"buildJoin",
"(",
")",
";",
"$",
"limit",
"=",
"$",
"this",
"->",
"buildLimit",
"(",
")",
";",
"$",
"group",
"=",
"$",
"this",
"->",
"buildGroup",
"(",
")",
";",
"$",
"union",
"=",
"$",
"this",
"->",
"buildUnion",
"(",
")",
";",
"$",
"order",
"=",
"$",
"this",
"->",
"buildOrder",
"(",
")",
";",
"$",
"result",
".=",
"'SELECT '",
".",
"$",
"select",
".",
"' FROM '",
".",
"$",
"table",
";",
"if",
"(",
"$",
"join",
"!=",
"''",
")",
"{",
"$",
"result",
".=",
"' '",
".",
"$",
"join",
";",
"}",
"if",
"(",
"$",
"where",
"!=",
"''",
")",
"{",
"$",
"result",
".=",
"' '",
".",
"$",
"where",
";",
"}",
"if",
"(",
"$",
"group",
"!=",
"''",
")",
"{",
"$",
"result",
".=",
"' '",
".",
"$",
"group",
";",
"}",
"if",
"(",
"$",
"order",
"!=",
"''",
")",
"{",
"$",
"result",
".=",
"' '",
".",
"$",
"order",
";",
"}",
"if",
"(",
"$",
"limit",
"!=",
"''",
")",
"{",
"$",
"result",
".=",
"' '",
".",
"$",
"limit",
";",
"}",
"if",
"(",
"$",
"having",
"!=",
"''",
")",
"{",
"$",
"result",
".=",
"' '",
".",
"$",
"having",
";",
"}",
"if",
"(",
"$",
"union",
"!=",
"''",
")",
"{",
"$",
"result",
"=",
"'('",
".",
"$",
"result",
".",
"')'",
".",
"$",
"union",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isForUpdate",
"(",
")",
")",
"{",
"$",
"result",
".=",
"' FOR UPDATE'",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Generate query
@return string | [
"Generate",
"query"
] | train | https://github.com/SergioMadness/query-builder/blob/95b7a46bba4c4d369101c6f0d37f133fecb3956d/src/abstraction/SelectBuilder.php#L104-L146 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.