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 listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
reportico-web/reportico | src/Reportico.php | Reportico.generateDropdownMenu | public function generateDropdownMenu(&$menu)
{
foreach ($menu as $k => $v) {
$project = $v["project"];
$initproject = $v["project"];
$projtitle = "<AUTO>";
if (isset($v["title"])) {
$projtitle = $v["title"];
}
$menu[$k]["title"] = ReporticoLang::translate($projtitle);
foreach ($v["items"] as $k1 => $menuitem) {
if (!isset($menuitem["reportname"]) || $menuitem["reportname"] == "<AUTO>") {
// Generate Menu from XML files
if (is_dir($this->projects_folder)) {
$proj_parent = $this->projects_folder;
} else {
$proj_parent = ReporticoUtility::findBestLocationInIncludePath($this->projects_folder);
}
$project = $initproject;
if (isset($menuitem["project"])) {
$project = $menuitem["project"];
}
$filename = $proj_parent . "/" . $project . "/" . $menuitem["reportfile"];
if (!preg_match("/\.xml/", $filename)) {
$filename .= ".xml";
}
if (is_file($filename)) {
$query = false;
$repxml = new XmlReader($query, $filename, false, "ReportTitle");
$menu[$k]["items"][$k1]["reportname"] = ReporticoLang::translate($repxml->search_response);
$menu[$k]["items"][$k1]["project"] = $project;
}
}
}
}
} | php | public function generateDropdownMenu(&$menu)
{
foreach ($menu as $k => $v) {
$project = $v["project"];
$initproject = $v["project"];
$projtitle = "<AUTO>";
if (isset($v["title"])) {
$projtitle = $v["title"];
}
$menu[$k]["title"] = ReporticoLang::translate($projtitle);
foreach ($v["items"] as $k1 => $menuitem) {
if (!isset($menuitem["reportname"]) || $menuitem["reportname"] == "<AUTO>") {
// Generate Menu from XML files
if (is_dir($this->projects_folder)) {
$proj_parent = $this->projects_folder;
} else {
$proj_parent = ReporticoUtility::findBestLocationInIncludePath($this->projects_folder);
}
$project = $initproject;
if (isset($menuitem["project"])) {
$project = $menuitem["project"];
}
$filename = $proj_parent . "/" . $project . "/" . $menuitem["reportfile"];
if (!preg_match("/\.xml/", $filename)) {
$filename .= ".xml";
}
if (is_file($filename)) {
$query = false;
$repxml = new XmlReader($query, $filename, false, "ReportTitle");
$menu[$k]["items"][$k1]["reportname"] = ReporticoLang::translate($repxml->search_response);
$menu[$k]["items"][$k1]["project"] = $project;
}
}
}
}
} | [
"public",
"function",
"generateDropdownMenu",
"(",
"&",
"$",
"menu",
")",
"{",
"foreach",
"(",
"$",
"menu",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"project",
"=",
"$",
"v",
"[",
"\"project\"",
"]",
";",
"$",
"initproject",
"=",
"$",
"v",
... | Function generate_dropdown_menu
Writes new admin password to the admin config.php | [
"Function",
"generate_dropdown_menu"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/Reportico.php#L5517-L5556 |
reportico-web/reportico | src/Reportico.php | Reportico.saveAdminPassword | public function saveAdminPassword($password1, $password2, $language)
{
$sessionClass = ReporticoSession();
if ($language) {
ReporticoApp::setConfig("language", $language);
}
if ($password1 != $password2) {
return ReporticoLang::translate("The passwords are not identical please reenter");
}
if (strlen($password1) == 0) {
return ReporticoLang::translate("The password may not be blank");
}
$source_parent = ReporticoUtility::findBestLocationInIncludePath($this->admin_projects_folder);
$source_dir = $source_parent . "/admin";
$source_conf = $source_dir . "/config.php";
$source_template = $source_dir . "/adminconfig.template";
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler", 0);
if (!@file_exists($source_parent)) {
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return "Projects area $source_parent does not exist - cannot write project";
}
$target_parent = $source_parent;
$target_dir = $source_dir;
$target_conf = $source_conf;
// If projects area different to source admin, create admin project in projects folder to store config.php
if ( $this->admin_projects_folder != $this->projects_folder ) {
$target_parent = ReporticoUtility::findBestLocationInIncludePath($this->projects_folder);
$target_dir = $target_parent . "/admin";
$target_conf = $target_dir . "/config.php";
}
if (!@is_dir($target_dir)) {
@mkdir($target_dir, 0755, true);
if (!is_dir($target_dir)) {
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return "Could not create admin config folder $target_conf - check permissions and continue";
}
}
if (@file_exists($target_conf)) {
if (!is_writeable($target_conf)) {
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return "Admin config file $target_conf is not writeable - cannot write config file - change permissions to continue";
}
}
if (!is_writeable($target_dir)) {
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return "Projects area $target_dir is not writeable - cannot write project password in config.php - change permissions to continue";
}
if (!@file_exists($source_conf)) {
if (!@file_exists($source_template)) {
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return "Projects config template file $source_template does not exist - please contact reportico.org";
}
}
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
if (@file_exists($target_conf)) {
$txt = file_get_contents($target_conf);
} else {
$txt = file_get_contents($source_template);
}
$proj_language = ReporticoUtility::findBestLocationInIncludePath("language");
$lang_dir = $proj_language . "/" . $language;
if (!is_dir($lang_dir)) {
return "Language directory $language does not exist within the language folder";
}
$txt = preg_replace("/(define.*?SW_ADMIN_PASSWORD',).*\);/", "$1'$password1');", $txt);
$txt = preg_replace ( "/(ReporticoApp::setConfig\(.admin_password.,).*/", "$1'$password1');", $txt);
$txt = preg_replace ( "/(ReporticoApp::setConfig\(.language.,).*/", "$1'$language');", $txt);
$sessionClass::unsetReporticoSessionParam('admin_password');
$retval = file_put_contents($target_conf, $txt);
// Password is saved so use it so user can login
if (!ReporticoApp::isSetConfig('admin_password')) {
ReporticoApp::setConfig("admin_password", $password1);
} else {
ReporticoApp::setConfig("admin_password_reset", $password1);
}
return;
} | php | public function saveAdminPassword($password1, $password2, $language)
{
$sessionClass = ReporticoSession();
if ($language) {
ReporticoApp::setConfig("language", $language);
}
if ($password1 != $password2) {
return ReporticoLang::translate("The passwords are not identical please reenter");
}
if (strlen($password1) == 0) {
return ReporticoLang::translate("The password may not be blank");
}
$source_parent = ReporticoUtility::findBestLocationInIncludePath($this->admin_projects_folder);
$source_dir = $source_parent . "/admin";
$source_conf = $source_dir . "/config.php";
$source_template = $source_dir . "/adminconfig.template";
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler", 0);
if (!@file_exists($source_parent)) {
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return "Projects area $source_parent does not exist - cannot write project";
}
$target_parent = $source_parent;
$target_dir = $source_dir;
$target_conf = $source_conf;
// If projects area different to source admin, create admin project in projects folder to store config.php
if ( $this->admin_projects_folder != $this->projects_folder ) {
$target_parent = ReporticoUtility::findBestLocationInIncludePath($this->projects_folder);
$target_dir = $target_parent . "/admin";
$target_conf = $target_dir . "/config.php";
}
if (!@is_dir($target_dir)) {
@mkdir($target_dir, 0755, true);
if (!is_dir($target_dir)) {
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return "Could not create admin config folder $target_conf - check permissions and continue";
}
}
if (@file_exists($target_conf)) {
if (!is_writeable($target_conf)) {
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return "Admin config file $target_conf is not writeable - cannot write config file - change permissions to continue";
}
}
if (!is_writeable($target_dir)) {
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return "Projects area $target_dir is not writeable - cannot write project password in config.php - change permissions to continue";
}
if (!@file_exists($source_conf)) {
if (!@file_exists($source_template)) {
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
return "Projects config template file $source_template does not exist - please contact reportico.org";
}
}
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
if (@file_exists($target_conf)) {
$txt = file_get_contents($target_conf);
} else {
$txt = file_get_contents($source_template);
}
$proj_language = ReporticoUtility::findBestLocationInIncludePath("language");
$lang_dir = $proj_language . "/" . $language;
if (!is_dir($lang_dir)) {
return "Language directory $language does not exist within the language folder";
}
$txt = preg_replace("/(define.*?SW_ADMIN_PASSWORD',).*\);/", "$1'$password1');", $txt);
$txt = preg_replace ( "/(ReporticoApp::setConfig\(.admin_password.,).*/", "$1'$password1');", $txt);
$txt = preg_replace ( "/(ReporticoApp::setConfig\(.language.,).*/", "$1'$language');", $txt);
$sessionClass::unsetReporticoSessionParam('admin_password');
$retval = file_put_contents($target_conf, $txt);
// Password is saved so use it so user can login
if (!ReporticoApp::isSetConfig('admin_password')) {
ReporticoApp::setConfig("admin_password", $password1);
} else {
ReporticoApp::setConfig("admin_password_reset", $password1);
}
return;
} | [
"public",
"function",
"saveAdminPassword",
"(",
"$",
"password1",
",",
"$",
"password2",
",",
"$",
"language",
")",
"{",
"$",
"sessionClass",
"=",
"ReporticoSession",
"(",
")",
";",
"if",
"(",
"$",
"language",
")",
"{",
"ReporticoApp",
"::",
"setConfig",
"... | Function save_admin_password
Writes new admin password to the admin project config.php. If the projects area is in a different location
than the admin area, then place the config.php in the projects area | [
"Function",
"save_admin_password"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/Reportico.php#L5576-L5671 |
reportico-web/reportico | src/Reportico.php | Reportico.setProjectEnvironment | public function setProjectEnvironment($initial_project = false, $project_folder = "projects", $admin_project_folder = "projects")
{
$sessionClass = ReporticoSession();
$target_menu = "";
$project = "";
$last_project = "";
if ($sessionClass::issetReporticoSessionParam("project")) {
if ($sessionClass::getReporticoSessionParam("project")) {
$last_project = $sessionClass::getReporticoSessionParam("project");
}
}
if (!$project && array_key_exists("submit_delete_project", $_REQUEST)) {
$project = ReporticoUtility::getRequestItem("jump_to_delete_project", "");
$_REQUEST["xmlin"] = "deleteproject.xml";
$sessionClass::setReporticoSessionParam("project", $project);
}
if (!$project && array_key_exists("submit_configure_project", $_REQUEST)) {
$project = ReporticoUtility::getRequestItem("jump_to_configure_project", "");
$_REQUEST["xmlin"] = "configureproject.xml";
$sessionClass::setReporticoSessionParam("project", $project);
}
if (!$project && array_key_exists("submit_menu_project", $_REQUEST)) {
$project = ReporticoUtility::getRequestItem("jump_to_menu_project", "");
$sessionClass::setReporticoSessionParam("project", $project);
}
if (!$project && array_key_exists("submit_design_project", $_REQUEST)) {
$project = ReporticoUtility::getRequestItem("jump_to_design_project", "");
$sessionClass::setReporticoSessionParam("project", $project);
}
if ($initial_project) {
$project = $initial_project;
$sessionClass::setReporticoSessionParam("project", $project);
}
if (!$project) {
$project = $sessionClass::sessionRequestItem("project", "admin");
}
if (!$target_menu) {
$target_menu = $sessionClass::sessionRequestItem("target_menu", "");
}
$menu = false;
$menu_title = "Set Menu Title";
// Now we now the project include the relevant config.php
$projpath = $project_folder . "/" . $project;
$admin_projpath = $admin_project_folder . "/" . $project;
$configfile = $projpath . "/config.php";
$configtemplatefile = $admin_projpath . "/adminconfig.template";
$menufile = $projpath . "/menu.php";
if ($target_menu != "") {
$menufile = $projpath . "/menu_" . $target_menu . ".php";
}
if (!is_file($projpath)) {
ReporticoUtility::findFileToInclude($projpath, $projpath);
}
$sessionClass::setReporticoSessionParam("project_path", $projpath);
$this->reports_path = $projpath;
if (!$projpath) {
ReporticoUtility::findFileToInclude("config.php", $configfile);
if (ReporticoApp::get("included_config") && ReporticoApp::get("included_config") != $configfile) {
ReporticoApp::handleError("Cannot load two different instances on a single page from different projects.", E_USER_ERROR);
} else {
ReporticoApp::set("included_config", $configfile);
include_once $configfile;
}
ReporticoApp::set("projpath", false);
ReporticoApp::set("project", false);
ReporticoApp::set("static_menu", false);
ReporticoApp::set("admin_menu", false);
ReporticoApp::set('menu_title', '');
ReporticoApp::set("dropdown_menu", false);
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
ReporticoApp::handleError("Project Directory $project not found. Check INCLUDE_PATH or project name");
return;
}
ReporticoApp::set("projpath", $projpath);
if (!is_file($configfile)) {
ReporticoUtility::findFileToInclude($configfile, $configfile);
}
if (!is_file($menufile)) {
ReporticoUtility::findFileToInclude($menufile, $menufile);
}
if ($project == "admin" && !is_file($configfile)) {
ReporticoUtility::findFileToInclude($configtemplatefile, $configfile);
}
if ($configfile) {
if (!is_file($configfile)) {
ReporticoApp::handleError("Config file $configfile not found in project $project", E_USER_WARNING);
}
if (ReporticoApp::get("included_config") && ReporticoApp::get("included_config") != $configfile) {
ReporticoApp::handleError("Cannot load two different instances on a single page from different projects.", E_USER_ERROR);
} else {
include_once $configfile;
ReporticoApp::set("included_config", $configfile);
}
if (is_file($menufile)) {
include $menufile;
}
//else
//ReporticoApp::handleError("Menu Definition file $menufile not found in project $project", E_USER_WARNING);
} else {
ReporticoUtility::findFileToInclude("config.php", $configfile);
if ($configfile) {
if (ReporticoApp::get("included_config") && ReporticoApp::get("included_config") != $configfile) {
ReporticoApp::handleError("Cannot load two different instances on a single page from different projects.", E_USER_ERROR);
} else {
include_once $configfile;
ReporticoApp::set("included_config", $configfile);
}
}
ReporticoApp::set('project', false);
ReporticoApp::set("static_menu", false);
ReporticoApp::set("admin_menu", false);
ReporticoApp::set("projpath", false);
ReporticoApp::set('menu_title', '');
ReporticoApp::set("dropdown_menu", false);
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
ReporticoApp::handleError("Configuration Definition file config.php not found in project $project", E_USER_ERROR);
}
// Ensure a Database and Output Character Set Encoding is set
if (!ReporticoApp::isSetConfig("db_encoding")) {
ReporticoApp::setConfig("db_encoding", "UTF8");
}
if (!ReporticoApp::isSetConfig("output_encoding")) {
ReporticoApp::setConfig("output_encoding", "UTF8");
}
// Ensure a language is set
if (!ReporticoApp::isSetConfig("language")) {
ReporticoApp::setConfig("language", "en_gb");
}
if (!ReporticoApp::isSetConfig('project')) {
ReporticoApp::setConfig('project', $project);
}
$sessionClass::setReporticoSessionParam("project", $project);
$language = "en_gb";
// Default language to first language in avaible_languages
$langs = ReporticoLang::availableLanguages();
if (count($langs) > 0) {
$language = $langs[0]["value"];
}
$config_language = ReporticoApp::getConfig("language", false);
if ($config_language && $config_language != "PROMPT") {
$language = $sessionClass::sessionRequestItem("reportico_language", $config_language);
} else {
$language = $sessionClass::sessionRequestItem("reportico_language", "en_gb");
}
// language not found the default to first
$found = false;
foreach ($langs as $k => $v) {
if ($v["value"] == $language) {
$found = true;
break;
}
}
if (!$found && count($langs) > 0) {
$language = $langs[0]["value"];
}
if (array_key_exists("submit_language", $_REQUEST)) {
$language = $_REQUEST["jump_to_language"];
$sessionClass::setReporticoSessionParam("reportico_language", $language);
}
ReporticoApp::setConfig("language", $language);
if (isset($menu) && !ReporticoApp::get("static_menu")) {
ReporticoApp::set("static_menu", $menu);
}
if (isset($menu) && !ReporticoApp::get("admin_menu")) {
ReporticoApp::set("admin_menu", $menu);
}
if (isset($menu_title) && !ReporticoApp::get("menu_title"))
ReporticoApp::set('menu_title', $menu_title);
if (isset($dropdown_menu) && !ReporticoApp::get("dropdown_menu") ) {
ReporticoApp::set("dropdown_menu", $dropdown_menu);
}
// Include project specific language translations
ReporticoLang::loadProjectLanguagePack($project, ReporticoLocale::outputCharsetToPhpCharset(ReporticoApp::getConfig("output_encoding", "UTF8")));
return $project;
} | php | public function setProjectEnvironment($initial_project = false, $project_folder = "projects", $admin_project_folder = "projects")
{
$sessionClass = ReporticoSession();
$target_menu = "";
$project = "";
$last_project = "";
if ($sessionClass::issetReporticoSessionParam("project")) {
if ($sessionClass::getReporticoSessionParam("project")) {
$last_project = $sessionClass::getReporticoSessionParam("project");
}
}
if (!$project && array_key_exists("submit_delete_project", $_REQUEST)) {
$project = ReporticoUtility::getRequestItem("jump_to_delete_project", "");
$_REQUEST["xmlin"] = "deleteproject.xml";
$sessionClass::setReporticoSessionParam("project", $project);
}
if (!$project && array_key_exists("submit_configure_project", $_REQUEST)) {
$project = ReporticoUtility::getRequestItem("jump_to_configure_project", "");
$_REQUEST["xmlin"] = "configureproject.xml";
$sessionClass::setReporticoSessionParam("project", $project);
}
if (!$project && array_key_exists("submit_menu_project", $_REQUEST)) {
$project = ReporticoUtility::getRequestItem("jump_to_menu_project", "");
$sessionClass::setReporticoSessionParam("project", $project);
}
if (!$project && array_key_exists("submit_design_project", $_REQUEST)) {
$project = ReporticoUtility::getRequestItem("jump_to_design_project", "");
$sessionClass::setReporticoSessionParam("project", $project);
}
if ($initial_project) {
$project = $initial_project;
$sessionClass::setReporticoSessionParam("project", $project);
}
if (!$project) {
$project = $sessionClass::sessionRequestItem("project", "admin");
}
if (!$target_menu) {
$target_menu = $sessionClass::sessionRequestItem("target_menu", "");
}
$menu = false;
$menu_title = "Set Menu Title";
// Now we now the project include the relevant config.php
$projpath = $project_folder . "/" . $project;
$admin_projpath = $admin_project_folder . "/" . $project;
$configfile = $projpath . "/config.php";
$configtemplatefile = $admin_projpath . "/adminconfig.template";
$menufile = $projpath . "/menu.php";
if ($target_menu != "") {
$menufile = $projpath . "/menu_" . $target_menu . ".php";
}
if (!is_file($projpath)) {
ReporticoUtility::findFileToInclude($projpath, $projpath);
}
$sessionClass::setReporticoSessionParam("project_path", $projpath);
$this->reports_path = $projpath;
if (!$projpath) {
ReporticoUtility::findFileToInclude("config.php", $configfile);
if (ReporticoApp::get("included_config") && ReporticoApp::get("included_config") != $configfile) {
ReporticoApp::handleError("Cannot load two different instances on a single page from different projects.", E_USER_ERROR);
} else {
ReporticoApp::set("included_config", $configfile);
include_once $configfile;
}
ReporticoApp::set("projpath", false);
ReporticoApp::set("project", false);
ReporticoApp::set("static_menu", false);
ReporticoApp::set("admin_menu", false);
ReporticoApp::set('menu_title', '');
ReporticoApp::set("dropdown_menu", false);
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
ReporticoApp::handleError("Project Directory $project not found. Check INCLUDE_PATH or project name");
return;
}
ReporticoApp::set("projpath", $projpath);
if (!is_file($configfile)) {
ReporticoUtility::findFileToInclude($configfile, $configfile);
}
if (!is_file($menufile)) {
ReporticoUtility::findFileToInclude($menufile, $menufile);
}
if ($project == "admin" && !is_file($configfile)) {
ReporticoUtility::findFileToInclude($configtemplatefile, $configfile);
}
if ($configfile) {
if (!is_file($configfile)) {
ReporticoApp::handleError("Config file $configfile not found in project $project", E_USER_WARNING);
}
if (ReporticoApp::get("included_config") && ReporticoApp::get("included_config") != $configfile) {
ReporticoApp::handleError("Cannot load two different instances on a single page from different projects.", E_USER_ERROR);
} else {
include_once $configfile;
ReporticoApp::set("included_config", $configfile);
}
if (is_file($menufile)) {
include $menufile;
}
//else
//ReporticoApp::handleError("Menu Definition file $menufile not found in project $project", E_USER_WARNING);
} else {
ReporticoUtility::findFileToInclude("config.php", $configfile);
if ($configfile) {
if (ReporticoApp::get("included_config") && ReporticoApp::get("included_config") != $configfile) {
ReporticoApp::handleError("Cannot load two different instances on a single page from different projects.", E_USER_ERROR);
} else {
include_once $configfile;
ReporticoApp::set("included_config", $configfile);
}
}
ReporticoApp::set('project', false);
ReporticoApp::set("static_menu", false);
ReporticoApp::set("admin_menu", false);
ReporticoApp::set("projpath", false);
ReporticoApp::set('menu_title', '');
ReporticoApp::set("dropdown_menu", false);
$old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
ReporticoApp::handleError("Configuration Definition file config.php not found in project $project", E_USER_ERROR);
}
// Ensure a Database and Output Character Set Encoding is set
if (!ReporticoApp::isSetConfig("db_encoding")) {
ReporticoApp::setConfig("db_encoding", "UTF8");
}
if (!ReporticoApp::isSetConfig("output_encoding")) {
ReporticoApp::setConfig("output_encoding", "UTF8");
}
// Ensure a language is set
if (!ReporticoApp::isSetConfig("language")) {
ReporticoApp::setConfig("language", "en_gb");
}
if (!ReporticoApp::isSetConfig('project')) {
ReporticoApp::setConfig('project', $project);
}
$sessionClass::setReporticoSessionParam("project", $project);
$language = "en_gb";
// Default language to first language in avaible_languages
$langs = ReporticoLang::availableLanguages();
if (count($langs) > 0) {
$language = $langs[0]["value"];
}
$config_language = ReporticoApp::getConfig("language", false);
if ($config_language && $config_language != "PROMPT") {
$language = $sessionClass::sessionRequestItem("reportico_language", $config_language);
} else {
$language = $sessionClass::sessionRequestItem("reportico_language", "en_gb");
}
// language not found the default to first
$found = false;
foreach ($langs as $k => $v) {
if ($v["value"] == $language) {
$found = true;
break;
}
}
if (!$found && count($langs) > 0) {
$language = $langs[0]["value"];
}
if (array_key_exists("submit_language", $_REQUEST)) {
$language = $_REQUEST["jump_to_language"];
$sessionClass::setReporticoSessionParam("reportico_language", $language);
}
ReporticoApp::setConfig("language", $language);
if (isset($menu) && !ReporticoApp::get("static_menu")) {
ReporticoApp::set("static_menu", $menu);
}
if (isset($menu) && !ReporticoApp::get("admin_menu")) {
ReporticoApp::set("admin_menu", $menu);
}
if (isset($menu_title) && !ReporticoApp::get("menu_title"))
ReporticoApp::set('menu_title', $menu_title);
if (isset($dropdown_menu) && !ReporticoApp::get("dropdown_menu") ) {
ReporticoApp::set("dropdown_menu", $dropdown_menu);
}
// Include project specific language translations
ReporticoLang::loadProjectLanguagePack($project, ReporticoLocale::outputCharsetToPhpCharset(ReporticoApp::getConfig("output_encoding", "UTF8")));
return $project;
} | [
"public",
"function",
"setProjectEnvironment",
"(",
"$",
"initial_project",
"=",
"false",
",",
"$",
"project_folder",
"=",
"\"projects\"",
",",
"$",
"admin_project_folder",
"=",
"\"projects\"",
")",
"{",
"$",
"sessionClass",
"=",
"ReporticoSession",
"(",
")",
";",... | Function setProjectEnvironment
Analyses configuration and current session to identify which project area
is to be used.
If a project is specified in the HTTP parameters then that is used, otherwise
the current SESSION
"reports" project is used | [
"Function",
"setProjectEnvironment"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/Reportico.php#L5682-L5898 |
reportico-web/reportico | src/Reportico.php | Reportico.loadPlugins | public function loadPlugins()
{
$plugin_dir = ReporticoUtility::findBestLocationInIncludePath("plugins");
if (is_dir($plugin_dir)) {
if ($dh = opendir($plugin_dir)) {
while (($file = readdir($dh)) !== false) {
$plugin = $plugin_dir . "/" . $file;
if (is_dir($plugin)) {
$plugin_file = $plugin . "/global.php";
if (is_file($plugin_file)) {
require_once $plugin_file;
}
$plugin_file = $plugin . "/" . strtolower($this->execute_mode) . ".php";
if (is_file($plugin_file)) {
require_once $plugin_file;
}
}
}
}
}
// Call any plugin initialisation
$this->applyPlugins("initialize", $this);
} | php | public function loadPlugins()
{
$plugin_dir = ReporticoUtility::findBestLocationInIncludePath("plugins");
if (is_dir($plugin_dir)) {
if ($dh = opendir($plugin_dir)) {
while (($file = readdir($dh)) !== false) {
$plugin = $plugin_dir . "/" . $file;
if (is_dir($plugin)) {
$plugin_file = $plugin . "/global.php";
if (is_file($plugin_file)) {
require_once $plugin_file;
}
$plugin_file = $plugin . "/" . strtolower($this->execute_mode) . ".php";
if (is_file($plugin_file)) {
require_once $plugin_file;
}
}
}
}
}
// Call any plugin initialisation
$this->applyPlugins("initialize", $this);
} | [
"public",
"function",
"loadPlugins",
"(",
")",
"{",
"$",
"plugin_dir",
"=",
"ReporticoUtility",
"::",
"findBestLocationInIncludePath",
"(",
"\"plugins\"",
")",
";",
"if",
"(",
"is_dir",
"(",
"$",
"plugin_dir",
")",
")",
"{",
"if",
"(",
"$",
"dh",
"=",
"ope... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/Reportico.php#L5904-L5928 |
reportico-web/reportico | src/Reportico.php | Reportico.applyPlugins | public function applyPlugins($section, $params)
{
foreach ($this->plugins as $k => $plugin) {
if (isset($plugin[$section])) {
if (isset($plugin[$section]["function"])) {
return $plugin[$section]["function"]($params);
} else if (isset($plugin[$section]["file"])) {
require_once $plugin["file"];
}
}
}
} | php | public function applyPlugins($section, $params)
{
foreach ($this->plugins as $k => $plugin) {
if (isset($plugin[$section])) {
if (isset($plugin[$section]["function"])) {
return $plugin[$section]["function"]($params);
} else if (isset($plugin[$section]["file"])) {
require_once $plugin["file"];
}
}
}
} | [
"public",
"function",
"applyPlugins",
"(",
"$",
"section",
",",
"$",
"params",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"plugins",
"as",
"$",
"k",
"=>",
"$",
"plugin",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"plugin",
"[",
"$",
"section",
"]",
... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/Reportico.php#L5935-L5946 |
reportico-web/reportico | src/Reportico.php | Reportico.getTemplatePath | public function getTemplatePath($template)
{
$reportname = preg_replace("/.xml/", "", $this->xmloutfile . '_' . $template);
// Some calling frameworks require output to be returned
// for rendering inside web pages .. in this case
// return_output_to_caller will be set to true
if (preg_match("/$reportname/", ReporticoUtility::findBestLocationInIncludePath("templates/" . $this->getTheme() . $reportname))) {
$template = $reportname;
}
if (preg_match("/$reportname/", ReporticoUtility::findBestLocationInIncludePath("templates/" . $reportname))) {
$template = $reportname;
} else if ($this->user_template) {
$template = $this->user_template . "_$template";
}
return $template;
//return $this->getTheme() . '/' . $template;
} | php | public function getTemplatePath($template)
{
$reportname = preg_replace("/.xml/", "", $this->xmloutfile . '_' . $template);
// Some calling frameworks require output to be returned
// for rendering inside web pages .. in this case
// return_output_to_caller will be set to true
if (preg_match("/$reportname/", ReporticoUtility::findBestLocationInIncludePath("templates/" . $this->getTheme() . $reportname))) {
$template = $reportname;
}
if (preg_match("/$reportname/", ReporticoUtility::findBestLocationInIncludePath("templates/" . $reportname))) {
$template = $reportname;
} else if ($this->user_template) {
$template = $this->user_template . "_$template";
}
return $template;
//return $this->getTheme() . '/' . $template;
} | [
"public",
"function",
"getTemplatePath",
"(",
"$",
"template",
")",
"{",
"$",
"reportname",
"=",
"preg_replace",
"(",
"\"/.xml/\"",
",",
"\"\"",
",",
"$",
"this",
"->",
"xmloutfile",
".",
"'_'",
".",
"$",
"template",
")",
";",
"// Some calling frameworks requi... | Get the path to the template
@param $template stricng name of template foile (eg. prepare.tpl)
@return string Path to the template including template / custom file. | [
"Get",
"the",
"path",
"to",
"the",
"template"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/Reportico.php#L5978-L5998 |
reportico-web/reportico | src/ReportTCPDF.php | ReportTCPDF.setDefaultStyles | public function setDefaultStyles()
{
Report::setDefaultStyles();
// Default column headers to underlined if not specified
if (!$this->query->output_header_styles) {
$this->query->output_header_styles["requires-before"] = "0";
$this->query->output_header_styles["border-style"] = "solid";
$this->query->output_header_styles["border-width"] = "0 0 1 0";
$this->query->output_header_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_before_form_row_styles) {
$this->query->output_before_form_row_styles["border-style"] = "solid";
$this->query->output_before_form_row_styles["border-width"] = "0 0 0 0";
$this->query->output_before_form_row_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_criteria_styles) {
$this->query->output_criteria_styles["border-style"] = "solid";
$this->query->output_criteria_styles["background-color"] = "#aaaaaa";
$this->query->output_criteria_styles["border-width"] = "1px 1px 1px 1px";
$this->query->output_criteria_styles["border-color"] = array(0, 0, 0);
$this->query->output_criteria_styles["margin"] = "0px 5px 10px 5px";
$this->query->output_criteria_styles["padding"] = "0px 5px 0px 5px";
}
if (!$this->query->output_after_form_row_styles) {
$this->query->output_after_form_row_styles["border-style"] = "solid";
$this->query->output_after_form_row_styles["border-width"] = "1 0 0 0";
$this->query->output_after_form_row_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_group_header_styles) {
$this->query->output_group_header_styles["requires-before"] = "0";
}
if (!$this->query->output_group_trailer_styles) {
$this->query->output_group_trailer_styles["border-style"] = "solid";
$this->query->output_group_trailer_styles["border-width"] = "1 0 1 0";
$this->query->output_group_trailer_styles["border-color"] = array(0, 0, 0);
}
// Turn off page header and body background as its too complicated for now
if (isset($this->query->output_reportbody_styles["background-color"])) {
unset($this->query->output_reportbody_styles["background-color"]);
}
if (isset($this->all_page_page_styles["background-color"])) {
unset($this->all_page_page_styles["background-color"]);
}
} | php | public function setDefaultStyles()
{
Report::setDefaultStyles();
// Default column headers to underlined if not specified
if (!$this->query->output_header_styles) {
$this->query->output_header_styles["requires-before"] = "0";
$this->query->output_header_styles["border-style"] = "solid";
$this->query->output_header_styles["border-width"] = "0 0 1 0";
$this->query->output_header_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_before_form_row_styles) {
$this->query->output_before_form_row_styles["border-style"] = "solid";
$this->query->output_before_form_row_styles["border-width"] = "0 0 0 0";
$this->query->output_before_form_row_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_criteria_styles) {
$this->query->output_criteria_styles["border-style"] = "solid";
$this->query->output_criteria_styles["background-color"] = "#aaaaaa";
$this->query->output_criteria_styles["border-width"] = "1px 1px 1px 1px";
$this->query->output_criteria_styles["border-color"] = array(0, 0, 0);
$this->query->output_criteria_styles["margin"] = "0px 5px 10px 5px";
$this->query->output_criteria_styles["padding"] = "0px 5px 0px 5px";
}
if (!$this->query->output_after_form_row_styles) {
$this->query->output_after_form_row_styles["border-style"] = "solid";
$this->query->output_after_form_row_styles["border-width"] = "1 0 0 0";
$this->query->output_after_form_row_styles["border-color"] = array(0, 0, 0);
}
if (!$this->query->output_group_header_styles) {
$this->query->output_group_header_styles["requires-before"] = "0";
}
if (!$this->query->output_group_trailer_styles) {
$this->query->output_group_trailer_styles["border-style"] = "solid";
$this->query->output_group_trailer_styles["border-width"] = "1 0 1 0";
$this->query->output_group_trailer_styles["border-color"] = array(0, 0, 0);
}
// Turn off page header and body background as its too complicated for now
if (isset($this->query->output_reportbody_styles["background-color"])) {
unset($this->query->output_reportbody_styles["background-color"]);
}
if (isset($this->all_page_page_styles["background-color"])) {
unset($this->all_page_page_styles["background-color"]);
}
} | [
"public",
"function",
"setDefaultStyles",
"(",
")",
"{",
"Report",
"::",
"setDefaultStyles",
"(",
")",
";",
"// Default column headers to underlined if not specified",
"if",
"(",
"!",
"$",
"this",
"->",
"query",
"->",
"output_header_styles",
")",
"{",
"$",
"this",
... | For each line reset styles to default values | [
"For",
"each",
"line",
"reset",
"styles",
"to",
"default",
"values"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReportTCPDF.php#L176-L228 |
reportico-web/reportico | src/ReportTCPDF.php | ReportTCPDF.drawCellContainer | public function drawCellContainer($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $valign = "T")
{
// Set custom width
$custom_width = end($this->stylestack["width"]);
if ($custom_width) {
$w = $custom_width;
}
// Get margins and position
$position = end($this->stylestack["margin-top"]);
$margin_top = end($this->stylestack["margin-top"]);
$margin_left = end($this->stylestack["margin-left"]);
// Get Justification
$justify = end($this->stylestack["text-align"]);
if ($justify) {
switch ($justify) {
case "centre":
case "center":
$align = "C";
break;
case "justify":
$align = "J";
break;
case "right":
$align = "R";
break;
case "left":
$align = "L";
break;
}
}
// Add padding
$padding = end($this->stylestack["padding"]);
$toppad = $padding[0];
$bottompad = $padding[2];
// Add border and bg color
$fill = end($this->stylestack["isfilling"]);
$borderwidth = end($this->stylestack["border-edges"]);
$border = end($this->stylestack["border-style"]);
if ($border != "none") {
$border = 1;
} else {
$borderwidth = "false";
}
// Store current position so we can jump back after cell draw
$x = $this->document->GetX();
$y = $this->document->GetY();
if ($margin_top) {
$this->setPosition($false, $y + $margin_top);
}
if ($margin_left) {
$this->setPosition($x + $margin_left, false);
}
//$background_image = end( $this->stylestack["background-image"] );
//if ( $background_image )
//$h = $this->document->Image($background_image, $this->document->GetX(), $this->document->GetY(), $w *2);
$this->drawMulticell($w, $this->max_line_height, "", $borderwidth, false, $fill);
$cell_height = $this->document->GetY() - $y;
// Jump back
$this->setPosition($x, $y);
} | php | public function drawCellContainer($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $valign = "T")
{
// Set custom width
$custom_width = end($this->stylestack["width"]);
if ($custom_width) {
$w = $custom_width;
}
// Get margins and position
$position = end($this->stylestack["margin-top"]);
$margin_top = end($this->stylestack["margin-top"]);
$margin_left = end($this->stylestack["margin-left"]);
// Get Justification
$justify = end($this->stylestack["text-align"]);
if ($justify) {
switch ($justify) {
case "centre":
case "center":
$align = "C";
break;
case "justify":
$align = "J";
break;
case "right":
$align = "R";
break;
case "left":
$align = "L";
break;
}
}
// Add padding
$padding = end($this->stylestack["padding"]);
$toppad = $padding[0];
$bottompad = $padding[2];
// Add border and bg color
$fill = end($this->stylestack["isfilling"]);
$borderwidth = end($this->stylestack["border-edges"]);
$border = end($this->stylestack["border-style"]);
if ($border != "none") {
$border = 1;
} else {
$borderwidth = "false";
}
// Store current position so we can jump back after cell draw
$x = $this->document->GetX();
$y = $this->document->GetY();
if ($margin_top) {
$this->setPosition($false, $y + $margin_top);
}
if ($margin_left) {
$this->setPosition($x + $margin_left, false);
}
//$background_image = end( $this->stylestack["background-image"] );
//if ( $background_image )
//$h = $this->document->Image($background_image, $this->document->GetX(), $this->document->GetY(), $w *2);
$this->drawMulticell($w, $this->max_line_height, "", $borderwidth, false, $fill);
$cell_height = $this->document->GetY() - $y;
// Jump back
$this->setPosition($x, $y);
} | [
"public",
"function",
"drawCellContainer",
"(",
"$",
"w",
",",
"$",
"h",
"=",
"0",
",",
"$",
"txt",
"=",
"''",
",",
"$",
"border",
"=",
"0",
",",
"$",
"ln",
"=",
"0",
",",
"$",
"align",
"=",
"''",
",",
"$",
"valign",
"=",
"\"T\"",
")",
"{",
... | Cell with horizontal scaling if text is too wide | [
"Cell",
"with",
"horizontal",
"scaling",
"if",
"text",
"is",
"too",
"wide"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReportTCPDF.php#L1127-L1199 |
reportico-web/reportico | src/ReportTCPDF.php | ReportTCPDF.drawCell | public function drawCell($w, $h = 0, $txt = '', $implied_styles = "PBF", $ln = 0, $align = '', $valign = "T", $link = '')
{
if (end($this->stylestack["display"]) == "none") {
return;
}
// Set custom width
$custom_width = end($this->stylestack["width"]);
if ($custom_width) {
$w = $this->absMetric($custom_width);
}
// Set custom width
$custom_height = end($this->stylestack["height"]);
if ($custom_height) {
$h = $this->absMetric($custom_height, "height");
}
// Get margins and position
$position = end($this->stylestack["position"]);
$margin_top = $this->absMetric(end($this->stylestack["margin-top"]));
$margin_left = $this->absMetric(end($this->stylestack["margin-left"]));
$margin_right = $this->absMetric(end($this->stylestack["margin-right"]));
$margin_bottom = $this->absMetric(end($this->stylestack["margin-bottom"]));
// If a cell contains a line break like a "<BR>" then convert it to new line
$txt = preg_replace("/<BR>/i", "\n", $txt);
// Calculate cell height as string width divided by width
// Add margin
$topmargin = 0;
$bottommargin = 0;
$leftmargin = 0;
$rightmargin = 0;
$margin = end($this->stylestack["margin"]);
if ($margin) {
$topmargin = $this->absMetric($margin[0]);
$rightmargin = $this->absMetric($margin[1]);
$bottommargin = $this->absMetric($margin[2]);
$leftmargin = $this->absMetric($margin[3]);
}
//$this->debugFile(print_r($this->stylestack["margin"], true));
//$this->debugFile("here we go T:$this->abs_top_margin, L:$this->abs_left_margin R:$this->abs_right_margin $this->page_type $this->abs_page_width/$this->abs_page_height $w $leftmargin");
// Add padding
$toppad = 0;
$bottompad = 0;
$leftpad = 0;
$rightpad = 0;
if (strstr($implied_styles, "P") || $this->pdfDriver == "tcpdf") {
$padding = end($this->stylestack["padding"]);
$toppad = $this->absMetric($padding[0]);
$rightpad = $this->absMetric($padding[1]);
$bottompad = $this->absMetric($padding[2]);
$leftpad = $this->absMetric($padding[3]);
}
if ($this->pdfDriver == "fpdf") {
$oldLineWidth = $this->document->LineWidth;
} else {
$oldLineWidth = $this->document->getLineWidth();
}
$fill = false;
if (strstr($implied_styles, "F") || $this->pdfDriver == "tcpdf") {
// Add border and bg color
$fill = end($this->stylestack["isfilling"]);
}
// Get Justification
$justify = end($this->stylestack["text-align"]);
if ($justify) {
switch ($justify) {
case "centre":
case "center":
$align = "C";
break;
case "justify":
$align = "J";
break;
case "right":
$align = "R";
break;
case "left":
$align = "L";
break;
}
}
$borderstyle = false;
$borderedges = false;
$borderwidth = false;
$topborderadditiontoheight = 0;
$botborderadditiontoheight = 0;
$leftborderadditiontoheight = 0;
$rightborderadditiontoheight = 0;
if (strstr($implied_styles, "B") || $this->pdfDriver == "tcpdf") {
$borderedges = end($this->stylestack["border-edges"]);
$borderwidth = end($this->stylestack["border-width"]);
$border = end($this->stylestack["border-style"]);
if ($border != "none") {
$borderstyle = 1;
} else {
$borderedges = "false";
}
if ($borderwidth) {
$borderwidth = $this->absMetric($borderwidth);
}
// Add extra padding in cell to avoid text conficting with border
//if ( $borderwidth && preg_match("/T/", $borderedges) ) $toppad += $borderwidth;
//if ( $borderwidth && preg_match("/B/", $borderedges) ) $bottompad += $borderwidth;
//if ( $borderwidth && preg_match("/L/", $borderedges) ) $leftpad += $borderwidth;
//if ( $borderwidth && preg_match("/R/", $borderedges) ) $rightpad += $borderwidth;
// Calulate addition cellheight caused by top and bottom borders
if ($borderwidth && preg_match("/T/", $borderedges)) {
$topborderadditiontoheight = $borderwidth / 2;
}
if ($borderwidth && preg_match("/B/", $borderedges)) {
$botborderadditiontoheight = $borderwidth / 2;
}
if ($borderwidth && preg_match("/L/", $borderedges)) {
$leftborderadditiontoheight = $borderwidth / 2;
}
if ($borderwidth && preg_match("/R/", $borderedges)) {
$rightborderadditiontoheight = $borderwidth / 2;
}
//$topborderadditiontoheight = $borderwidth;
//$botborderadditiontoheight = $borderwidth;
}
// Store current position so we can jump back after cell draw
$storey = $this->document->GetY();
$storex = $this->document->GetX();
// If position is absolute position at page start
if ($position == "absolute") {
$this->setPosition(1, 1);
}
// Store current position so we can jump back after cell draw
$y = $this->document->GetY();
$x = $this->document->GetX();
// Cells with borders draw with half border appearing outside the text box so mode text down by half to give it space
if ($topborderadditiontoheight) {
$topmargin += $topborderadditiontoheight;
//if ( $this->document->GetFontSizePt() == 0 )
//$toppad +=$topborderadditiontoheight;
}
// Cells with borders draw with half border appearing outside the text box so mode text down by half to give it space
if ($botborderadditiontoheight) {
$bottommargin += $botborderadditiontoheight;
//if ( $this->document->GetFontSizePt() == 0 )
$bottompad += $botborderadditiontoheight;
}
if ($leftborderadditiontoheight) {
$leftmargin += $leftborderadditiontoheight;
}
if ($rightborderadditiontoheight) {
$rightmargin += $rightborderadditiontoheight;
}
//if ( $leftborderadditiontoheight )
//$w -= $leftborderadditiontoheight;
//if ( $rightborderadditiontoheight )
//$w -= $rightborderadditiontoheight;
// TCPDF ignores a right margin if a width is specified.. we always specify a width, so
// to use a right margin reduce the width by the right margin instead also widht
// must be reduced by left margin because TCPDF does not reduce with by the margin
if ($rightmargin) {
$w -= $rightmargin;
}
if ($leftmargin) {
$w -= $leftmargin;
}
// Add to top/bottom margin space require by surrounding row border
$topmargin += $this->cell_row_top_addition;
$bottommargin += $this->cell_row_bottom_addition;
$borderaddition = $botborderadditiontoheight + $topborderadditiontoheight;
//$paddingaddition = $toppad + $bottompad;
if ($this->draw_mode == "CALCULATE") {
$this->document->startTransaction();
//$fill_line_height = $margin_top + $toppad + $this->calculated_line_height + $bottompad;
//if ( $this->max_line_height < $fill_line_height )
$cellvaluewidth = $w;
$cellvaluefromy = $this->document->GetY();
$this->document->SetCellPaddings($leftpad, $toppad, $rightpad, $bottompad);
$this->document->SetCellMargins($leftmargin, $topmargin, $rightmargin, $bottommargin);
$cellborder = false;
if ($borderedges) {
$margin_top = end($this->stylestack["margin-top"]);
$border_color = end($this->stylestack["border-color"]);
$border_style = end($this->stylestack["border-style"]);
if ($border_style == "none") {
$cellborder = false;
} else {
if ($border_style == "solid") {
$border_style = 0;
} else if ($border_style == "dotted") {
$border_style = 1;
} else if ($border_style == "dashed") {
$border_style = 2;
}
$cellborder = array(
//'mode' => "int",
$borderedges => array(
'width' => $borderwidth,
'color' => $border_color,
'dash' => $border_style,
));
}
}
$ht = $this->drawMulticell($cellvaluewidth, 0, "$txt", $cellborder, false, false, false, false);
$this->document->SetCellPadding(0);
$this->document->SetCellMargins(0, 0);
if ($cellvaluewidth < 0) {
$cellvaluewidth = 20;
$txt = "Padding too large / Width too small - $txt";
}
$cellheight = $ht;
if ($custom_height) {
$cellheight = $h;
}
$requiredheight = $cellheight - $borderaddition;
$cellheight += $topmargin;
$cellheight += $bottommargin;
if ($cellheight > $this->max_line_height) {
$this->max_line_height = $cellheight;
}
if ($requiredheight > $this->required_line_height) {
$this->required_line_height = $requiredheight;
}
$this->document = $this->document->rollbackTransaction();
return;
}
// To cater for multiline values, jump to bottom of line + padding -
// cell height
$jumpy = 0;
if ($toppad && $this->pdfDriver == "fpdf") {
if ($valign == "T") {
$jumpy = $toppad;
} else if ($valign == "B") {
$jumpy = $toppad + $this->calculated_line_height - $cellheight;
} else if ($valign == "C") {
$jumpy = (($toppad + $this->calculated_line_height + $bottompad) - $cellheight) / 2;
}
}
if ($margin_top) {
$this->setPosition(false, $y + $margin_top);
}
if ($margin_left) {
$this->setPosition($x + $margin_left, false);
}
$prevx = $this->document->GetX();
// Top Padding
if ($toppad && $this->pdfDriver == "fpdf") {
$tmpborder = $borderedges;
$tmpborder = preg_replace("/B/", "", $borderedges);
$pady = $this->document->GetY() - 1;
$this->setPosition(false, $pady + 2);
$prevx = $this->document->GetX();
if ($borderwidth) {
$this->document->setLineWidth($borderwidth);
}
$this->drawMulticell($w, $toppad, "", $tmpborder, $align, $fill, $link);
if ($borderwidth) {
$this->document->setLineWidth($oldLineWidth);
}
$this->setPosition($prevx, false);
}
$this->setPosition(false, $margin_top + $y + $jumpy);
// Link in a PDF must include a full URL contain http:// element
// drilldown link of web url can be relative .. so prepend required elements
if ($link) {
if (!preg_match("/^http:\/\//", $link) && !preg_match("/^\//", $link)) {
$link = "http://" . $_SERVER["HTTP_HOST"] . dirname($this->query->url_path_to_reportico_runner) . "/" . $link;
}
if (preg_match("/^\//", $link)) {
$link = ReporticoApp::getConfig("http_urlhost") . "/" . $link;
}
}
// Cell Side Borders
$tmpborder = $borderedges;
if ($toppad) {
$tmpborder = preg_replace("/T/", "", $tmpborder);
}
if ($bottompad) {
$tmpborder = preg_replace("/B/", "", $tmpborder);
}
$cellborder = $tmpborder;
if ($leftpad) {
$cellborder = preg_replace("/L/", "", $cellborder);
}
if ($rightpad) {
$cellborder = preg_replace("/R/", "", $cellborder);
}
$storeX = $this->document->GetX();
if ($this->pdfDriver == "fpdf") {
if ($leftpad) {
$this->setPosition($storeX + $leftpad - 1, false);
}
}
$storeY = $this->document->GetY();
$cellvaluewidth = $w - $leftpad - $rightpad;
$cellvaluewidth = $w;
if ($cellvaluewidth < 0) {
$cellvaluewidth = 20;
$txt = "Padding too large / Width too small - $txt";
}
// Cell image
$background_image = end($this->stylestack["background-image"]);
$cell_height = 0;
$last_draw_end_y = 0;
if ($background_image) {
$preimageX = $this->document->GetX();
$preimageY = $this->document->GetY();
//$this->debugFile("$this->draw_mode $margin_top t $topmargin txt <$txt> align $align image cur $cellvaluewidth / $h vs $custom_height/$custom_width $p\n");
// If text prvoded then background image covers text else set to custom height/width
//$cellvaluewidth = "200";
//if ( $txt )
$p = $this->drawImage($background_image, $this->document->GetX() + $leftmargin, $this->document->GetY() + $topmargin, $cellvaluewidth, $h, false, $align);
//else
//$p = $this->drawImage($background_image, $this->document->GetX() + $leftmargin, $this->document->GetY() + $topmargin, $custom_width, $custom_height, false, $align);
$p += $topmargin;
//echo "$last_draw_end_y $storeY $background_image ".$p."<BR>";
//if ($this->document->GetY() + $p > $this->group_header_end )
//$this->group_header_end = $this->document->GetY() + $p;
$cell_height = $p;
$last_draw_end_y = $storeY + $p;
$this->setPosition($preimageX, $preimageY);
//$this->last_draw_end_y = $storeY + $p;
//return;
}
// Cell value
$cellvaluefromy = $this->document->GetY();
$actcellvaluewidth = $cellvaluewidth;
if ($this->pdfDriver == "fpdf") {
// with left pad and right pad there can be some odd lines left on side so force a bigger width
if ($leftpad) {
$actcellvaluewidth += 1;
}
if ($rightpad) {
$actcellvaluewidth += 1;
}
if ($borderwidth) {
$this->document->setLineWidth($borderwidth);
}
}
if ($this->pdfDriver == "tcpdf") {
$this->document->SetCellPaddings($leftpad, $toppad, $rightpad, $bottompad);
$this->document->SetCellMargins($leftmargin, $topmargin, $rightmargin, $bottommargin);
$cellborder = false;
if ($borderedges) {
$margin_top = end($this->stylestack["margin-top"]);
$border_color = end($this->stylestack["border-color"]);
$border_style = end($this->stylestack["border-style"]);
if ($border_style == "none") {
$cellborder = false;
} else {
if ($border_style == "solid") {
$border_style = 0;
} else if ($border_style == "dotted") {
$border_style = 1;
} else if ($border_style == "dashed") {
$border_style = 2;
}
$cellborder = array(
//'mode' => "int",
$borderedges => array(
'width' => $borderwidth,
'color' => $border_color,
'dash' => $border_style,
));
}
}
}
$this->last_cell_xpos = $this->document->GetX();
$this->last_cell_width = $actcellvaluewidth;
if ($background_image) {
$ht = $this->drawMulticell($actcellvaluewidth, $h, $txt, $cellborder, $align, false, $link);
} else {
$ht = $this->drawMulticell($actcellvaluewidth, $h, $txt, $cellborder, $align, $fill, $link);
}
if ($borderwidth) {
$this->document->setLineWidth($oldLineWidth);
}
$text_cell_height = $ht;
if ($text_cell_height > $cell_height) {
$cell_height = $text_cell_height;
}
// Store reach of cells for headers unless we are in absolute position
// in which case we allow other stuff to pverwrite it
if ($position != "absolute") {
if ($this->document->GetY() > $this->group_header_end) {
$this->group_header_end = $this->document->GetY();
}
if ($cell_height > $this->current_line_height && !$this->ignore_height_checking) {
$this->current_line_height = $cell_height;
}
$this->last_draw_end_y = $this->document->GetY();
if ($this->last_draw_end_y < $last_draw_end_y) {
$this->last_draw_end_y = $last_draw_end_y;
}
}
// Jump back
$this->setPosition(false, $storey);
} | php | public function drawCell($w, $h = 0, $txt = '', $implied_styles = "PBF", $ln = 0, $align = '', $valign = "T", $link = '')
{
if (end($this->stylestack["display"]) == "none") {
return;
}
// Set custom width
$custom_width = end($this->stylestack["width"]);
if ($custom_width) {
$w = $this->absMetric($custom_width);
}
// Set custom width
$custom_height = end($this->stylestack["height"]);
if ($custom_height) {
$h = $this->absMetric($custom_height, "height");
}
// Get margins and position
$position = end($this->stylestack["position"]);
$margin_top = $this->absMetric(end($this->stylestack["margin-top"]));
$margin_left = $this->absMetric(end($this->stylestack["margin-left"]));
$margin_right = $this->absMetric(end($this->stylestack["margin-right"]));
$margin_bottom = $this->absMetric(end($this->stylestack["margin-bottom"]));
// If a cell contains a line break like a "<BR>" then convert it to new line
$txt = preg_replace("/<BR>/i", "\n", $txt);
// Calculate cell height as string width divided by width
// Add margin
$topmargin = 0;
$bottommargin = 0;
$leftmargin = 0;
$rightmargin = 0;
$margin = end($this->stylestack["margin"]);
if ($margin) {
$topmargin = $this->absMetric($margin[0]);
$rightmargin = $this->absMetric($margin[1]);
$bottommargin = $this->absMetric($margin[2]);
$leftmargin = $this->absMetric($margin[3]);
}
//$this->debugFile(print_r($this->stylestack["margin"], true));
//$this->debugFile("here we go T:$this->abs_top_margin, L:$this->abs_left_margin R:$this->abs_right_margin $this->page_type $this->abs_page_width/$this->abs_page_height $w $leftmargin");
// Add padding
$toppad = 0;
$bottompad = 0;
$leftpad = 0;
$rightpad = 0;
if (strstr($implied_styles, "P") || $this->pdfDriver == "tcpdf") {
$padding = end($this->stylestack["padding"]);
$toppad = $this->absMetric($padding[0]);
$rightpad = $this->absMetric($padding[1]);
$bottompad = $this->absMetric($padding[2]);
$leftpad = $this->absMetric($padding[3]);
}
if ($this->pdfDriver == "fpdf") {
$oldLineWidth = $this->document->LineWidth;
} else {
$oldLineWidth = $this->document->getLineWidth();
}
$fill = false;
if (strstr($implied_styles, "F") || $this->pdfDriver == "tcpdf") {
// Add border and bg color
$fill = end($this->stylestack["isfilling"]);
}
// Get Justification
$justify = end($this->stylestack["text-align"]);
if ($justify) {
switch ($justify) {
case "centre":
case "center":
$align = "C";
break;
case "justify":
$align = "J";
break;
case "right":
$align = "R";
break;
case "left":
$align = "L";
break;
}
}
$borderstyle = false;
$borderedges = false;
$borderwidth = false;
$topborderadditiontoheight = 0;
$botborderadditiontoheight = 0;
$leftborderadditiontoheight = 0;
$rightborderadditiontoheight = 0;
if (strstr($implied_styles, "B") || $this->pdfDriver == "tcpdf") {
$borderedges = end($this->stylestack["border-edges"]);
$borderwidth = end($this->stylestack["border-width"]);
$border = end($this->stylestack["border-style"]);
if ($border != "none") {
$borderstyle = 1;
} else {
$borderedges = "false";
}
if ($borderwidth) {
$borderwidth = $this->absMetric($borderwidth);
}
// Add extra padding in cell to avoid text conficting with border
//if ( $borderwidth && preg_match("/T/", $borderedges) ) $toppad += $borderwidth;
//if ( $borderwidth && preg_match("/B/", $borderedges) ) $bottompad += $borderwidth;
//if ( $borderwidth && preg_match("/L/", $borderedges) ) $leftpad += $borderwidth;
//if ( $borderwidth && preg_match("/R/", $borderedges) ) $rightpad += $borderwidth;
// Calulate addition cellheight caused by top and bottom borders
if ($borderwidth && preg_match("/T/", $borderedges)) {
$topborderadditiontoheight = $borderwidth / 2;
}
if ($borderwidth && preg_match("/B/", $borderedges)) {
$botborderadditiontoheight = $borderwidth / 2;
}
if ($borderwidth && preg_match("/L/", $borderedges)) {
$leftborderadditiontoheight = $borderwidth / 2;
}
if ($borderwidth && preg_match("/R/", $borderedges)) {
$rightborderadditiontoheight = $borderwidth / 2;
}
//$topborderadditiontoheight = $borderwidth;
//$botborderadditiontoheight = $borderwidth;
}
// Store current position so we can jump back after cell draw
$storey = $this->document->GetY();
$storex = $this->document->GetX();
// If position is absolute position at page start
if ($position == "absolute") {
$this->setPosition(1, 1);
}
// Store current position so we can jump back after cell draw
$y = $this->document->GetY();
$x = $this->document->GetX();
// Cells with borders draw with half border appearing outside the text box so mode text down by half to give it space
if ($topborderadditiontoheight) {
$topmargin += $topborderadditiontoheight;
//if ( $this->document->GetFontSizePt() == 0 )
//$toppad +=$topborderadditiontoheight;
}
// Cells with borders draw with half border appearing outside the text box so mode text down by half to give it space
if ($botborderadditiontoheight) {
$bottommargin += $botborderadditiontoheight;
//if ( $this->document->GetFontSizePt() == 0 )
$bottompad += $botborderadditiontoheight;
}
if ($leftborderadditiontoheight) {
$leftmargin += $leftborderadditiontoheight;
}
if ($rightborderadditiontoheight) {
$rightmargin += $rightborderadditiontoheight;
}
//if ( $leftborderadditiontoheight )
//$w -= $leftborderadditiontoheight;
//if ( $rightborderadditiontoheight )
//$w -= $rightborderadditiontoheight;
// TCPDF ignores a right margin if a width is specified.. we always specify a width, so
// to use a right margin reduce the width by the right margin instead also widht
// must be reduced by left margin because TCPDF does not reduce with by the margin
if ($rightmargin) {
$w -= $rightmargin;
}
if ($leftmargin) {
$w -= $leftmargin;
}
// Add to top/bottom margin space require by surrounding row border
$topmargin += $this->cell_row_top_addition;
$bottommargin += $this->cell_row_bottom_addition;
$borderaddition = $botborderadditiontoheight + $topborderadditiontoheight;
//$paddingaddition = $toppad + $bottompad;
if ($this->draw_mode == "CALCULATE") {
$this->document->startTransaction();
//$fill_line_height = $margin_top + $toppad + $this->calculated_line_height + $bottompad;
//if ( $this->max_line_height < $fill_line_height )
$cellvaluewidth = $w;
$cellvaluefromy = $this->document->GetY();
$this->document->SetCellPaddings($leftpad, $toppad, $rightpad, $bottompad);
$this->document->SetCellMargins($leftmargin, $topmargin, $rightmargin, $bottommargin);
$cellborder = false;
if ($borderedges) {
$margin_top = end($this->stylestack["margin-top"]);
$border_color = end($this->stylestack["border-color"]);
$border_style = end($this->stylestack["border-style"]);
if ($border_style == "none") {
$cellborder = false;
} else {
if ($border_style == "solid") {
$border_style = 0;
} else if ($border_style == "dotted") {
$border_style = 1;
} else if ($border_style == "dashed") {
$border_style = 2;
}
$cellborder = array(
//'mode' => "int",
$borderedges => array(
'width' => $borderwidth,
'color' => $border_color,
'dash' => $border_style,
));
}
}
$ht = $this->drawMulticell($cellvaluewidth, 0, "$txt", $cellborder, false, false, false, false);
$this->document->SetCellPadding(0);
$this->document->SetCellMargins(0, 0);
if ($cellvaluewidth < 0) {
$cellvaluewidth = 20;
$txt = "Padding too large / Width too small - $txt";
}
$cellheight = $ht;
if ($custom_height) {
$cellheight = $h;
}
$requiredheight = $cellheight - $borderaddition;
$cellheight += $topmargin;
$cellheight += $bottommargin;
if ($cellheight > $this->max_line_height) {
$this->max_line_height = $cellheight;
}
if ($requiredheight > $this->required_line_height) {
$this->required_line_height = $requiredheight;
}
$this->document = $this->document->rollbackTransaction();
return;
}
// To cater for multiline values, jump to bottom of line + padding -
// cell height
$jumpy = 0;
if ($toppad && $this->pdfDriver == "fpdf") {
if ($valign == "T") {
$jumpy = $toppad;
} else if ($valign == "B") {
$jumpy = $toppad + $this->calculated_line_height - $cellheight;
} else if ($valign == "C") {
$jumpy = (($toppad + $this->calculated_line_height + $bottompad) - $cellheight) / 2;
}
}
if ($margin_top) {
$this->setPosition(false, $y + $margin_top);
}
if ($margin_left) {
$this->setPosition($x + $margin_left, false);
}
$prevx = $this->document->GetX();
// Top Padding
if ($toppad && $this->pdfDriver == "fpdf") {
$tmpborder = $borderedges;
$tmpborder = preg_replace("/B/", "", $borderedges);
$pady = $this->document->GetY() - 1;
$this->setPosition(false, $pady + 2);
$prevx = $this->document->GetX();
if ($borderwidth) {
$this->document->setLineWidth($borderwidth);
}
$this->drawMulticell($w, $toppad, "", $tmpborder, $align, $fill, $link);
if ($borderwidth) {
$this->document->setLineWidth($oldLineWidth);
}
$this->setPosition($prevx, false);
}
$this->setPosition(false, $margin_top + $y + $jumpy);
// Link in a PDF must include a full URL contain http:// element
// drilldown link of web url can be relative .. so prepend required elements
if ($link) {
if (!preg_match("/^http:\/\//", $link) && !preg_match("/^\//", $link)) {
$link = "http://" . $_SERVER["HTTP_HOST"] . dirname($this->query->url_path_to_reportico_runner) . "/" . $link;
}
if (preg_match("/^\//", $link)) {
$link = ReporticoApp::getConfig("http_urlhost") . "/" . $link;
}
}
// Cell Side Borders
$tmpborder = $borderedges;
if ($toppad) {
$tmpborder = preg_replace("/T/", "", $tmpborder);
}
if ($bottompad) {
$tmpborder = preg_replace("/B/", "", $tmpborder);
}
$cellborder = $tmpborder;
if ($leftpad) {
$cellborder = preg_replace("/L/", "", $cellborder);
}
if ($rightpad) {
$cellborder = preg_replace("/R/", "", $cellborder);
}
$storeX = $this->document->GetX();
if ($this->pdfDriver == "fpdf") {
if ($leftpad) {
$this->setPosition($storeX + $leftpad - 1, false);
}
}
$storeY = $this->document->GetY();
$cellvaluewidth = $w - $leftpad - $rightpad;
$cellvaluewidth = $w;
if ($cellvaluewidth < 0) {
$cellvaluewidth = 20;
$txt = "Padding too large / Width too small - $txt";
}
// Cell image
$background_image = end($this->stylestack["background-image"]);
$cell_height = 0;
$last_draw_end_y = 0;
if ($background_image) {
$preimageX = $this->document->GetX();
$preimageY = $this->document->GetY();
//$this->debugFile("$this->draw_mode $margin_top t $topmargin txt <$txt> align $align image cur $cellvaluewidth / $h vs $custom_height/$custom_width $p\n");
// If text prvoded then background image covers text else set to custom height/width
//$cellvaluewidth = "200";
//if ( $txt )
$p = $this->drawImage($background_image, $this->document->GetX() + $leftmargin, $this->document->GetY() + $topmargin, $cellvaluewidth, $h, false, $align);
//else
//$p = $this->drawImage($background_image, $this->document->GetX() + $leftmargin, $this->document->GetY() + $topmargin, $custom_width, $custom_height, false, $align);
$p += $topmargin;
//echo "$last_draw_end_y $storeY $background_image ".$p."<BR>";
//if ($this->document->GetY() + $p > $this->group_header_end )
//$this->group_header_end = $this->document->GetY() + $p;
$cell_height = $p;
$last_draw_end_y = $storeY + $p;
$this->setPosition($preimageX, $preimageY);
//$this->last_draw_end_y = $storeY + $p;
//return;
}
// Cell value
$cellvaluefromy = $this->document->GetY();
$actcellvaluewidth = $cellvaluewidth;
if ($this->pdfDriver == "fpdf") {
// with left pad and right pad there can be some odd lines left on side so force a bigger width
if ($leftpad) {
$actcellvaluewidth += 1;
}
if ($rightpad) {
$actcellvaluewidth += 1;
}
if ($borderwidth) {
$this->document->setLineWidth($borderwidth);
}
}
if ($this->pdfDriver == "tcpdf") {
$this->document->SetCellPaddings($leftpad, $toppad, $rightpad, $bottompad);
$this->document->SetCellMargins($leftmargin, $topmargin, $rightmargin, $bottommargin);
$cellborder = false;
if ($borderedges) {
$margin_top = end($this->stylestack["margin-top"]);
$border_color = end($this->stylestack["border-color"]);
$border_style = end($this->stylestack["border-style"]);
if ($border_style == "none") {
$cellborder = false;
} else {
if ($border_style == "solid") {
$border_style = 0;
} else if ($border_style == "dotted") {
$border_style = 1;
} else if ($border_style == "dashed") {
$border_style = 2;
}
$cellborder = array(
//'mode' => "int",
$borderedges => array(
'width' => $borderwidth,
'color' => $border_color,
'dash' => $border_style,
));
}
}
}
$this->last_cell_xpos = $this->document->GetX();
$this->last_cell_width = $actcellvaluewidth;
if ($background_image) {
$ht = $this->drawMulticell($actcellvaluewidth, $h, $txt, $cellborder, $align, false, $link);
} else {
$ht = $this->drawMulticell($actcellvaluewidth, $h, $txt, $cellborder, $align, $fill, $link);
}
if ($borderwidth) {
$this->document->setLineWidth($oldLineWidth);
}
$text_cell_height = $ht;
if ($text_cell_height > $cell_height) {
$cell_height = $text_cell_height;
}
// Store reach of cells for headers unless we are in absolute position
// in which case we allow other stuff to pverwrite it
if ($position != "absolute") {
if ($this->document->GetY() > $this->group_header_end) {
$this->group_header_end = $this->document->GetY();
}
if ($cell_height > $this->current_line_height && !$this->ignore_height_checking) {
$this->current_line_height = $cell_height;
}
$this->last_draw_end_y = $this->document->GetY();
if ($this->last_draw_end_y < $last_draw_end_y) {
$this->last_draw_end_y = $last_draw_end_y;
}
}
// Jump back
$this->setPosition(false, $storey);
} | [
"public",
"function",
"drawCell",
"(",
"$",
"w",
",",
"$",
"h",
"=",
"0",
",",
"$",
"txt",
"=",
"''",
",",
"$",
"implied_styles",
"=",
"\"PBF\"",
",",
"$",
"ln",
"=",
"0",
",",
"$",
"align",
"=",
"''",
",",
"$",
"valign",
"=",
"\"T\"",
",",
"... | Cell with horizontal scaling if text is too wide | [
"Cell",
"with",
"horizontal",
"scaling",
"if",
"text",
"is",
"too",
"wide"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReportTCPDF.php#L1202-L1685 |
reportico-web/reportico | src/ReportTCPDF.php | ReportTCPDF.endLine | public function endLine($h = false)
{
// Dont draw line ends in draw mode
if ($this->draw_mode == "CALCULATE") {
return;
}
if ($this->current_line_height) {
$this->document->Ln($this->current_line_height - $this->max_line_border_addition);
//$this->setPosition(false, $this->current_line_start_y + $this->current_line_height);
} else {
if ($h !== false) {
$this->document->Ln($h);
} else {
$this->document->Ln();
}
}
$y = $this->document->GetY();
$this->setPosition(false, $y);
$this->current_line_start_y = $this->document->GetY();
$this->current_line_height = 0;
$this->max_line_height = 0;
$this->required_line_height = 0;
$this->max_line_border_addition = 0;
$this->max_line_padding_addition = 0;
$this->calculated_line_height = 0;
} | php | public function endLine($h = false)
{
// Dont draw line ends in draw mode
if ($this->draw_mode == "CALCULATE") {
return;
}
if ($this->current_line_height) {
$this->document->Ln($this->current_line_height - $this->max_line_border_addition);
//$this->setPosition(false, $this->current_line_start_y + $this->current_line_height);
} else {
if ($h !== false) {
$this->document->Ln($h);
} else {
$this->document->Ln();
}
}
$y = $this->document->GetY();
$this->setPosition(false, $y);
$this->current_line_start_y = $this->document->GetY();
$this->current_line_height = 0;
$this->max_line_height = 0;
$this->required_line_height = 0;
$this->max_line_border_addition = 0;
$this->max_line_padding_addition = 0;
$this->calculated_line_height = 0;
} | [
"public",
"function",
"endLine",
"(",
"$",
"h",
"=",
"false",
")",
"{",
"// Dont draw line ends in draw mode",
"if",
"(",
"$",
"this",
"->",
"draw_mode",
"==",
"\"CALCULATE\"",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"current_line_height"... | record of current line height | [
"record",
"of",
"current",
"line",
"height"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReportTCPDF.php#L1689-L1715 |
reportico-web/reportico | src/ReportTCPDF.php | ReportTCPDF.checkForDetailPageStart | public function checkForDetailPageStart() // PDF
{
//if ( $this->inOverflow )
//return;
if ($this->page_detail_started) {
return;
}
$this->draw_mode = "CALCULATE";
$this->newReportPageLineByStyle("RMB1", $this->mid_page_reportbody_styles, false);
$this->newReportPageLineByStyle("HMP1", $this->top_page_page_styles, true);
$this->draw_mode = "DRAW";
$this->newReportPageLineByStyle("RMB1", $this->mid_page_reportbody_styles, false);
$this->newReportPageLineByStyle("HMP1", $this->top_page_page_styles, true);
$this->page_detail_started = true;
} | php | public function checkForDetailPageStart() // PDF
{
//if ( $this->inOverflow )
//return;
if ($this->page_detail_started) {
return;
}
$this->draw_mode = "CALCULATE";
$this->newReportPageLineByStyle("RMB1", $this->mid_page_reportbody_styles, false);
$this->newReportPageLineByStyle("HMP1", $this->top_page_page_styles, true);
$this->draw_mode = "DRAW";
$this->newReportPageLineByStyle("RMB1", $this->mid_page_reportbody_styles, false);
$this->newReportPageLineByStyle("HMP1", $this->top_page_page_styles, true);
$this->page_detail_started = true;
} | [
"public",
"function",
"checkForDetailPageStart",
"(",
")",
"// PDF",
"{",
"//if ( $this->inOverflow )",
"//return;",
"if",
"(",
"$",
"this",
"->",
"page_detail_started",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"draw_mode",
"=",
"\"CALCULATE\"",
";",
"$"... | /*
Checks if page changed and we need a new start of page block | [
"/",
"*",
"Checks",
"if",
"page",
"changed",
"and",
"we",
"need",
"a",
"new",
"start",
"of",
"page",
"block"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReportTCPDF.php#L2399-L2416 |
reportico-web/reportico | src/ReportTCPDF.php | ReportTCPDF.checkForDetailPageEnd | public function checkForDetailPageEnd() // PDF
{
//if ( $this->inOverflow )
//return;
if (!$this->page_detail_started) {
return;
}
$this->draw_mode = "CALCULATE";
$this->newReportPageLineByStyle("RMB1", $this->mid_page_reportbody_styles, false);
$this->newReportPageLineByStyle("HMP1", $this->bottom_page_page_styles, true);
$this->draw_mode = "DRAW";
$this->newReportPageLineByStyle("RMB1", $this->mid_page_reportbody_styles, false);
$this->newReportPageLineByStyle("HMP1", $this->bottom_page_page_styles, true);
$this->page_detail_started = false;
} | php | public function checkForDetailPageEnd() // PDF
{
//if ( $this->inOverflow )
//return;
if (!$this->page_detail_started) {
return;
}
$this->draw_mode = "CALCULATE";
$this->newReportPageLineByStyle("RMB1", $this->mid_page_reportbody_styles, false);
$this->newReportPageLineByStyle("HMP1", $this->bottom_page_page_styles, true);
$this->draw_mode = "DRAW";
$this->newReportPageLineByStyle("RMB1", $this->mid_page_reportbody_styles, false);
$this->newReportPageLineByStyle("HMP1", $this->bottom_page_page_styles, true);
$this->page_detail_started = false;
} | [
"public",
"function",
"checkForDetailPageEnd",
"(",
")",
"// PDF",
"{",
"//if ( $this->inOverflow )",
"//return;",
"if",
"(",
"!",
"$",
"this",
"->",
"page_detail_started",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"draw_mode",
"=",
"\"CALCULATE\"",
";",
... | /*
Checks if page changed and we need a new start of page block | [
"/",
"*",
"Checks",
"if",
"page",
"changed",
"and",
"we",
"need",
"a",
"new",
"start",
"of",
"page",
"block"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReportTCPDF.php#L2421-L2438 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.executeCriteriaLookup | public function executeCriteriaLookup($in_is_expanding = false, $no_warnings = false)
{
ReporticoApp::set("code_area", "Criteria " . $this->query_name);
$rep = new ReportArray();
$this->lookup_query->rowselection = true;
$this->lookup_query->setDatasource($this->datasource);
$this->lookup_query->targets = array();
$this->lookup_query->addTarget($rep);
$this->lookup_query->buildQuery($in_is_expanding, $this->query_name, false, $no_warnings);
$this->lookup_query->executeQuery($this->query_name);
ReporticoApp::set("code_area", "");
} | php | public function executeCriteriaLookup($in_is_expanding = false, $no_warnings = false)
{
ReporticoApp::set("code_area", "Criteria " . $this->query_name);
$rep = new ReportArray();
$this->lookup_query->rowselection = true;
$this->lookup_query->setDatasource($this->datasource);
$this->lookup_query->targets = array();
$this->lookup_query->addTarget($rep);
$this->lookup_query->buildQuery($in_is_expanding, $this->query_name, false, $no_warnings);
$this->lookup_query->executeQuery($this->query_name);
ReporticoApp::set("code_area", "");
} | [
"public",
"function",
"executeCriteriaLookup",
"(",
"$",
"in_is_expanding",
"=",
"false",
",",
"$",
"no_warnings",
"=",
"false",
")",
"{",
"ReporticoApp",
"::",
"set",
"(",
"\"code_area\"",
",",
"\"Criteria \"",
".",
"$",
"this",
"->",
"query_name",
")",
";",
... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L88-L100 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.criteriaSummaryText | public function criteriaSummaryText(&$label, &$value)
{
$label = "";
$value = "";
$name = $this->query_name;
if (isset($this->criteria_summary) && $this->criteria_summary) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$value = $this->criteria_summary;
} else {
if (ReporticoUtility::getRequestItem($this->query_name . "_FROMDATE_DAY", "")) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$label = ReporticoLang::translate($label);
$mth = ReporticoUtility::getRequestItem($name . "_FROMDATE_MONTH", "") + 1;
$value = ReporticoUtility::getRequestItem($name . "_FROMDATE_DAY", "") . "/" .
$mth . "/" .
ReporticoUtility::getRequestItem($name . "_FROMDATE_YEAR", "");
if (ReporticoUtility::getRequestItem($name . "_TODATE_DAY", "")) {
$mth = ReporticoUtility::getRequestItem($name . "_TODATE_MONTH", "") + 1;
$value .= "-";
$value .= ReporticoUtility::getRequestItem($name . "_TODATE_DAY", "") . "/" .
$mth . "/" .
ReporticoUtility::getRequestItem($name . "_TODATE_YEAR", "");
}
} else if (ReporticoUtility::getRequestItem("MANUAL_" . $name . "_FROMDATE", "")) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$label = ReporticoLang::translate($label);
$value = ReporticoUtility::getRequestItem("MANUAL_" . $name . "_FROMDATE", "");
if (ReporticoUtility::getRequestItem("MANUAL_" . $name . "_TODATE", "")) {
$value .= "-";
$value .= ReporticoUtility::getRequestItem("MANUAL_" . $name . "_TODATE");
}
} else if (ReporticoUtility::getRequestItem("HIDDEN_" . $name . "_FROMDATE", "")) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$label = ReporticoLang::translate($label);
$value = ReporticoUtility::getRequestItem("HIDDEN_" . $name . "_FROMDATE", "");
if (ReporticoUtility::getRequestItem("HIDDEN_" . $name . "_TODATE", "")) {
$value .= "-";
$value .= ReporticoUtility::getRequestItem("HIDDEN_" . $name . "_TODATE");
}
} else if (ReporticoUtility::getRequestItem("EXPANDED_" . $name, "")) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$label = ReporticoLang::translate($label);
$value .= implode(ReporticoUtility::getRequestItem("EXPANDED_" . $name, ""), ",");
} else if (ReporticoUtility::getRequestItem("MANUAL_" . $name, "")) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$label = ReporticoLang::translate($label);
$value .= ReporticoUtility::getRequestItem("MANUAL_" . $name, "");
}
}
} | php | public function criteriaSummaryText(&$label, &$value)
{
$label = "";
$value = "";
$name = $this->query_name;
if (isset($this->criteria_summary) && $this->criteria_summary) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$value = $this->criteria_summary;
} else {
if (ReporticoUtility::getRequestItem($this->query_name . "_FROMDATE_DAY", "")) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$label = ReporticoLang::translate($label);
$mth = ReporticoUtility::getRequestItem($name . "_FROMDATE_MONTH", "") + 1;
$value = ReporticoUtility::getRequestItem($name . "_FROMDATE_DAY", "") . "/" .
$mth . "/" .
ReporticoUtility::getRequestItem($name . "_FROMDATE_YEAR", "");
if (ReporticoUtility::getRequestItem($name . "_TODATE_DAY", "")) {
$mth = ReporticoUtility::getRequestItem($name . "_TODATE_MONTH", "") + 1;
$value .= "-";
$value .= ReporticoUtility::getRequestItem($name . "_TODATE_DAY", "") . "/" .
$mth . "/" .
ReporticoUtility::getRequestItem($name . "_TODATE_YEAR", "");
}
} else if (ReporticoUtility::getRequestItem("MANUAL_" . $name . "_FROMDATE", "")) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$label = ReporticoLang::translate($label);
$value = ReporticoUtility::getRequestItem("MANUAL_" . $name . "_FROMDATE", "");
if (ReporticoUtility::getRequestItem("MANUAL_" . $name . "_TODATE", "")) {
$value .= "-";
$value .= ReporticoUtility::getRequestItem("MANUAL_" . $name . "_TODATE");
}
} else if (ReporticoUtility::getRequestItem("HIDDEN_" . $name . "_FROMDATE", "")) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$label = ReporticoLang::translate($label);
$value = ReporticoUtility::getRequestItem("HIDDEN_" . $name . "_FROMDATE", "");
if (ReporticoUtility::getRequestItem("HIDDEN_" . $name . "_TODATE", "")) {
$value .= "-";
$value .= ReporticoUtility::getRequestItem("HIDDEN_" . $name . "_TODATE");
}
} else if (ReporticoUtility::getRequestItem("EXPANDED_" . $name, "")) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$label = ReporticoLang::translate($label);
$value .= implode(ReporticoUtility::getRequestItem("EXPANDED_" . $name, ""), ",");
} else if (ReporticoUtility::getRequestItem("MANUAL_" . $name, "")) {
$label = $this->deriveAttribute("column_title", $this->query_name);
$label = ReporticoLang::translate($label);
$value .= ReporticoUtility::getRequestItem("MANUAL_" . $name, "");
}
}
} | [
"public",
"function",
"criteriaSummaryText",
"(",
"&",
"$",
"label",
",",
"&",
"$",
"value",
")",
"{",
"$",
"label",
"=",
"\"\"",
";",
"$",
"value",
"=",
"\"\"",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"query_name",
";",
"if",
"(",
"isset",
"(",
... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L104-L156 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.criteriaSummaryDisplay | public function criteriaSummaryDisplay()
{
$text = "";
$type = $this->criteria_display;
$value_string = "";
$params = array();
$manual_params = array();
$hidden_params = array();
$expanded_params = array();
$manual_override = false;
if (ReporticoUtility::getRequestItem("MANUAL_" . $this->query_name . "_FROMDATE", "")) {
$this->criteria_summary = ReporticoUtility::getRequestItem("MANUAL_" . $this->query_name . "_FROMDATE", "");
if (ReporticoUtility::getRequestItem("MANUAL_" . $this->query_name . "_TODATE", "")) {
$this->criteria_summary .= "-";
$this->criteria_summary .= ReporticoUtility::getRequestItem("MANUAL_" . $this->query_name . "_TODATE");
}
return;
}
if (ReporticoUtility::getRequestItem("HIDDEN_" . $this->query_name . "_FROMDATE", "")) {
$this->criteria_summary = ReporticoUtility::getRequestItem("HIDDEN_" . $this->query_name . "_FROMDATE", "");
if (ReporticoUtility::getRequestItem("HIDDEN_" . $this->query_name . "_TODATE", "")) {
$this->criteria_summary .= "-";
$this->criteria_summary .= ReporticoUtility::getRequestItem("HIDDEN_" . $this->query_name . "_TODATE");
}
return;
}
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists($this->query_name, $_REQUEST)) {
$params = $_REQUEST[$this->query_name];
if (!is_array($params)) {
$params = array($params);
}
}
}
$hidden_params = array();
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists("HIDDEN_" . $this->query_name, $_REQUEST)) {
$hidden_params = $_REQUEST["HIDDEN_" . $this->query_name];
if (!is_array($hidden_params)) {
$hidden_params = array($hidden_params);
}
}
}
$manual_params = array();
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists("MANUAL_" . $this->query_name, $_REQUEST)) {
$manual_params = explode(',', $_REQUEST["MANUAL_" . $this->query_name]);
if ($manual_params) {
$hidden_params = $manual_params;
$manual_override = true;
$value_string = $_REQUEST["MANUAL_" . $this->query_name];
}
}
}
$expanded_params = array();
if (array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
$expanded_params = $_REQUEST["EXPANDED_" . $this->query_name];
if (!is_array($expanded_params)) {
$expanded_params = array($expanded_params);
}
}
if ($this->criteria_type == "LIST") {
$checkedct = 0;
$res = &$this->list_values;
$text = "";
if (!$res) {
$text = "";
} else {
reset($res);
$k = key($res);
for ($i = 0; $i < count($res); $i++) {
$line = &$res[$i];
$lab = $res[$i]["label"];
$ret = $res[$i]["value"];
$checked = false;
if (in_array($ret, $params)) {
$checked = true;
}
if (in_array($ret, $hidden_params)) {
$checked = true;
}
if (in_array($ret, $expanded_params)) {
$checked = true;
}
if ($checked) {
if ($checkedct++) {
$text .= ",";
}
$text .= $lab;
}
}
$this->criteria_summary = $text;
return;
}
}
$txt = "";
$res = &$this->lookup_query->targets[0]->results;
if (!$res) {
$res = array();
$k = 0;
} else {
reset($res);
$k = key($res);
$checkedct = 0;
for ($i = 0; $i < count($res[$k]); $i++) {
$line = &$res[$i];
foreach ($this->lookup_query->columns as $ky => $col) {
if ($col->lookup_display_flag) {
$lab = $res[$col->query_name][$i];
}
if ($col->lookup_return_flag) {
$ret = $res[$col->query_name][$i];
}
if ($col->lookup_abbrev_flag) {
$abb = $res[$col->query_name][$i];
}
}
$checked = false;
if (in_array($ret, $params)) {
$checked = true;
}
if (in_array($ret, $hidden_params) && !$manual_override) {
$checked = true;
}
if (in_array($ret, $expanded_params)) {
$checked = true;
}
if (in_array($abb, $hidden_params) && $manual_override) {
$checked = true;
}
if ($checked) {
if ($checkedct++) {
$text .= ",";
}
$text .= $lab;
}
}
}
if (array_key_exists("EXPAND_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDCLEAR_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDSELECTALL_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDSEARCH_" . $this->query_name, $_REQUEST) ||
$this->criteria_display == "NOINPUT") {
$tag = $value_string;
if (strlen($tag) > 40) {
$tag = substr($tag, 0, 40) . "...";
}
if (!$tag) {
$tag = "ANY";
}
$text .= $tag;
} else if ($this->criteria_display == "ANYCHAR" || $this->criteria_display == "TEXTFIELD") {
$txt = $value_string;
}
$this->criteria_summary = $text;
} | php | public function criteriaSummaryDisplay()
{
$text = "";
$type = $this->criteria_display;
$value_string = "";
$params = array();
$manual_params = array();
$hidden_params = array();
$expanded_params = array();
$manual_override = false;
if (ReporticoUtility::getRequestItem("MANUAL_" . $this->query_name . "_FROMDATE", "")) {
$this->criteria_summary = ReporticoUtility::getRequestItem("MANUAL_" . $this->query_name . "_FROMDATE", "");
if (ReporticoUtility::getRequestItem("MANUAL_" . $this->query_name . "_TODATE", "")) {
$this->criteria_summary .= "-";
$this->criteria_summary .= ReporticoUtility::getRequestItem("MANUAL_" . $this->query_name . "_TODATE");
}
return;
}
if (ReporticoUtility::getRequestItem("HIDDEN_" . $this->query_name . "_FROMDATE", "")) {
$this->criteria_summary = ReporticoUtility::getRequestItem("HIDDEN_" . $this->query_name . "_FROMDATE", "");
if (ReporticoUtility::getRequestItem("HIDDEN_" . $this->query_name . "_TODATE", "")) {
$this->criteria_summary .= "-";
$this->criteria_summary .= ReporticoUtility::getRequestItem("HIDDEN_" . $this->query_name . "_TODATE");
}
return;
}
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists($this->query_name, $_REQUEST)) {
$params = $_REQUEST[$this->query_name];
if (!is_array($params)) {
$params = array($params);
}
}
}
$hidden_params = array();
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists("HIDDEN_" . $this->query_name, $_REQUEST)) {
$hidden_params = $_REQUEST["HIDDEN_" . $this->query_name];
if (!is_array($hidden_params)) {
$hidden_params = array($hidden_params);
}
}
}
$manual_params = array();
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists("MANUAL_" . $this->query_name, $_REQUEST)) {
$manual_params = explode(',', $_REQUEST["MANUAL_" . $this->query_name]);
if ($manual_params) {
$hidden_params = $manual_params;
$manual_override = true;
$value_string = $_REQUEST["MANUAL_" . $this->query_name];
}
}
}
$expanded_params = array();
if (array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
$expanded_params = $_REQUEST["EXPANDED_" . $this->query_name];
if (!is_array($expanded_params)) {
$expanded_params = array($expanded_params);
}
}
if ($this->criteria_type == "LIST") {
$checkedct = 0;
$res = &$this->list_values;
$text = "";
if (!$res) {
$text = "";
} else {
reset($res);
$k = key($res);
for ($i = 0; $i < count($res); $i++) {
$line = &$res[$i];
$lab = $res[$i]["label"];
$ret = $res[$i]["value"];
$checked = false;
if (in_array($ret, $params)) {
$checked = true;
}
if (in_array($ret, $hidden_params)) {
$checked = true;
}
if (in_array($ret, $expanded_params)) {
$checked = true;
}
if ($checked) {
if ($checkedct++) {
$text .= ",";
}
$text .= $lab;
}
}
$this->criteria_summary = $text;
return;
}
}
$txt = "";
$res = &$this->lookup_query->targets[0]->results;
if (!$res) {
$res = array();
$k = 0;
} else {
reset($res);
$k = key($res);
$checkedct = 0;
for ($i = 0; $i < count($res[$k]); $i++) {
$line = &$res[$i];
foreach ($this->lookup_query->columns as $ky => $col) {
if ($col->lookup_display_flag) {
$lab = $res[$col->query_name][$i];
}
if ($col->lookup_return_flag) {
$ret = $res[$col->query_name][$i];
}
if ($col->lookup_abbrev_flag) {
$abb = $res[$col->query_name][$i];
}
}
$checked = false;
if (in_array($ret, $params)) {
$checked = true;
}
if (in_array($ret, $hidden_params) && !$manual_override) {
$checked = true;
}
if (in_array($ret, $expanded_params)) {
$checked = true;
}
if (in_array($abb, $hidden_params) && $manual_override) {
$checked = true;
}
if ($checked) {
if ($checkedct++) {
$text .= ",";
}
$text .= $lab;
}
}
}
if (array_key_exists("EXPAND_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDCLEAR_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDSELECTALL_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDSEARCH_" . $this->query_name, $_REQUEST) ||
$this->criteria_display == "NOINPUT") {
$tag = $value_string;
if (strlen($tag) > 40) {
$tag = substr($tag, 0, 40) . "...";
}
if (!$tag) {
$tag = "ANY";
}
$text .= $tag;
} else if ($this->criteria_display == "ANYCHAR" || $this->criteria_display == "TEXTFIELD") {
$txt = $value_string;
}
$this->criteria_summary = $text;
} | [
"public",
"function",
"criteriaSummaryDisplay",
"(",
")",
"{",
"$",
"text",
"=",
"\"\"",
";",
"$",
"type",
"=",
"$",
"this",
"->",
"criteria_display",
";",
"$",
"value_string",
"=",
"\"\"",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"manual_... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L165-L351 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.setCriteriaList | public function setCriteriaList($in_list)
{
// Replace external parameters specified by {USER_PARAM,xxxxx}
// With external values
$matches = [];
if ($this->parent_reportico->execute_mode != "MAINTAIN" && preg_match_all("/{USER_PARAM,([^}]*)}/", $in_list, $matches)) {
foreach ($matches[0] as $k => $v) {
$param = $matches[1][$k];
if (isset($this->parent_reportico->user_parameters[$param]["function"]) ) {
$function = $this->parent_reportico->user_parameters[$param]["function"];
if ( !isset($this->parent_reportico->user_functions[$function] )) {
trigger_error("User function $function required but not defined in user_functions array", E_USER_ERROR);
return;
}
$result = $this->parent_reportico->user_functions[$function]();
$in_list = implode(',', array_map(
function ($v, $k) { return sprintf("%s=%s", $k, $v); },
$result,
array_keys($result)
));
} else
if (isset($this->parent_reportico->user_parameters[$param]["values"]) &&
is_array($this->parent_reportico->user_parameters[$param]["values"])
) {
$in_list = implode(',', array_map(
function ($v, $k) { return sprintf("%s=%s", $k, $v); },
$this->parent_reportico->user_parameters[$param]["values"],
array_keys($this->parent_reportico->user_parameters[$param]["values"])
));
} else {
trigger_error("User parameter $param, specified but not provided to reportico in user_parameters array", E_USER_ERROR);
}
}
}
if ($in_list) {
$choices = array();
if ($in_list == "{connections}" && $this->parent_reportico->framework_parent == "october" ) {
$choices[] = "Existing October Connection=existingconnection";
if (isset($this->parent_reportico) && $this->parent_reportico->available_connections) {
foreach ($this->parent_reportico->available_connections as $k => $v) {
$choices[] = "Database '$k'=byname_$k";
}
}
$this->criteria_list = $in_list;
} else
if ($in_list == "{connections}" && $this->parent_reportico->framework_parent == "laravel" ) {
$choices[] = "Existing Laravel Connection=existingconnection";
if (isset($this->parent_reportico) && $this->parent_reportico->available_connections) {
foreach ($this->parent_reportico->available_connections as $k => $v) {
$choices[] = "Database '$k'=byname_$k";
}
}
$this->criteria_list = $in_list;
} else
if ($in_list == "{connections}") {
if ( !isset($this->available_connections) ) {
$this->available_connections = array(
"pdo_mysql" => "MySQL",
"pdo_pgsql" => "PostgreSQL with PDO",
"oci8" => "Oracle without PDO (Beta)",
"pdo_oci" => "Oracle with PDO (Beta)",
"pdo_mssql" => "Mssql (with DBLIB/MSSQL PDO)",
"pdo_sqlsrv" => "Mssql (with SQLSRV PDO)",
"pdo_sqlite3" => "SQLite3",
"framework" => "Framework(e.g. Joomla)",
);
}
// For Yii, Laravel etc show framework option as first option relating to the framework name
if ( $this->parent_reportico->framework_parent ) {
$ftype = ucwords($this->parent_reportico->framework_parent);
$choices[] = "My $ftype Connection=framework";
unset ( $this->available_connections["framework"] );
$this->setCriteriaDefaults("framework");
}
foreach ($this->available_connections as $k => $v) {
$choices[] = $v . "=" . $k;
}
$this->criteria_list = $in_list;
} else
if ($in_list == "{languages}") {
$langs = ReporticoLang::availableLanguages();
foreach ($langs as $k => $v) {
$choices[] = ReporticoLang::templateXlate($v["value"]) . "=" . $v["value"];
}
$this->criteria_list = $in_list;
} else {
$this->criteria_list = $in_list;
if (!is_array($in_list)) {
$choices = explode(',', $in_list);
}
}
foreach ($choices as $items) {
$itemval = explode('=', $items);
if (count($itemval) > 1) {
$this->list_values[] = array("label" => $itemval[0],
"value" => $itemval[1]);
}
}
}
} | php | public function setCriteriaList($in_list)
{
// Replace external parameters specified by {USER_PARAM,xxxxx}
// With external values
$matches = [];
if ($this->parent_reportico->execute_mode != "MAINTAIN" && preg_match_all("/{USER_PARAM,([^}]*)}/", $in_list, $matches)) {
foreach ($matches[0] as $k => $v) {
$param = $matches[1][$k];
if (isset($this->parent_reportico->user_parameters[$param]["function"]) ) {
$function = $this->parent_reportico->user_parameters[$param]["function"];
if ( !isset($this->parent_reportico->user_functions[$function] )) {
trigger_error("User function $function required but not defined in user_functions array", E_USER_ERROR);
return;
}
$result = $this->parent_reportico->user_functions[$function]();
$in_list = implode(',', array_map(
function ($v, $k) { return sprintf("%s=%s", $k, $v); },
$result,
array_keys($result)
));
} else
if (isset($this->parent_reportico->user_parameters[$param]["values"]) &&
is_array($this->parent_reportico->user_parameters[$param]["values"])
) {
$in_list = implode(',', array_map(
function ($v, $k) { return sprintf("%s=%s", $k, $v); },
$this->parent_reportico->user_parameters[$param]["values"],
array_keys($this->parent_reportico->user_parameters[$param]["values"])
));
} else {
trigger_error("User parameter $param, specified but not provided to reportico in user_parameters array", E_USER_ERROR);
}
}
}
if ($in_list) {
$choices = array();
if ($in_list == "{connections}" && $this->parent_reportico->framework_parent == "october" ) {
$choices[] = "Existing October Connection=existingconnection";
if (isset($this->parent_reportico) && $this->parent_reportico->available_connections) {
foreach ($this->parent_reportico->available_connections as $k => $v) {
$choices[] = "Database '$k'=byname_$k";
}
}
$this->criteria_list = $in_list;
} else
if ($in_list == "{connections}" && $this->parent_reportico->framework_parent == "laravel" ) {
$choices[] = "Existing Laravel Connection=existingconnection";
if (isset($this->parent_reportico) && $this->parent_reportico->available_connections) {
foreach ($this->parent_reportico->available_connections as $k => $v) {
$choices[] = "Database '$k'=byname_$k";
}
}
$this->criteria_list = $in_list;
} else
if ($in_list == "{connections}") {
if ( !isset($this->available_connections) ) {
$this->available_connections = array(
"pdo_mysql" => "MySQL",
"pdo_pgsql" => "PostgreSQL with PDO",
"oci8" => "Oracle without PDO (Beta)",
"pdo_oci" => "Oracle with PDO (Beta)",
"pdo_mssql" => "Mssql (with DBLIB/MSSQL PDO)",
"pdo_sqlsrv" => "Mssql (with SQLSRV PDO)",
"pdo_sqlite3" => "SQLite3",
"framework" => "Framework(e.g. Joomla)",
);
}
// For Yii, Laravel etc show framework option as first option relating to the framework name
if ( $this->parent_reportico->framework_parent ) {
$ftype = ucwords($this->parent_reportico->framework_parent);
$choices[] = "My $ftype Connection=framework";
unset ( $this->available_connections["framework"] );
$this->setCriteriaDefaults("framework");
}
foreach ($this->available_connections as $k => $v) {
$choices[] = $v . "=" . $k;
}
$this->criteria_list = $in_list;
} else
if ($in_list == "{languages}") {
$langs = ReporticoLang::availableLanguages();
foreach ($langs as $k => $v) {
$choices[] = ReporticoLang::templateXlate($v["value"]) . "=" . $v["value"];
}
$this->criteria_list = $in_list;
} else {
$this->criteria_list = $in_list;
if (!is_array($in_list)) {
$choices = explode(',', $in_list);
}
}
foreach ($choices as $items) {
$itemval = explode('=', $items);
if (count($itemval) > 1) {
$this->list_values[] = array("label" => $itemval[0],
"value" => $itemval[1]);
}
}
}
} | [
"public",
"function",
"setCriteriaList",
"(",
"$",
"in_list",
")",
"{",
"// Replace external parameters specified by {USER_PARAM,xxxxx}",
"// With external values",
"$",
"matches",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"parent_reportico",
"->",
"execute_mode... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L359-L467 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.setCriteriaDefaults | public function setCriteriaDefaults($in_default, $in_delimiter = false)
{
if (!$in_delimiter) {
$in_delimiter = ",";
}
$this->defaults_raw = $in_default;
$this->defaults = preg_split("/" . $in_delimiter . "/", $this->deriveMetaValue($in_default));
} | php | public function setCriteriaDefaults($in_default, $in_delimiter = false)
{
if (!$in_delimiter) {
$in_delimiter = ",";
}
$this->defaults_raw = $in_default;
$this->defaults = preg_split("/" . $in_delimiter . "/", $this->deriveMetaValue($in_default));
} | [
"public",
"function",
"setCriteriaDefaults",
"(",
"$",
"in_default",
",",
"$",
"in_delimiter",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"in_delimiter",
")",
"{",
"$",
"in_delimiter",
"=",
"\",\"",
";",
"}",
"$",
"this",
"->",
"defaults_raw",
"=",
"$"... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L472-L479 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.setCriteriaInput | public function setCriteriaInput($in_source, $in_display, $in_expand_display = false, $use = "")
{
$this->criteria_type = $in_source;
$this->criteria_display = $in_display;
$this->expand_display = $in_expand_display;
$this->_use = $use;
} | php | public function setCriteriaInput($in_source, $in_display, $in_expand_display = false, $use = "")
{
$this->criteria_type = $in_source;
$this->criteria_display = $in_display;
$this->expand_display = $in_expand_display;
$this->_use = $use;
} | [
"public",
"function",
"setCriteriaInput",
"(",
"$",
"in_source",
",",
"$",
"in_display",
",",
"$",
"in_expand_display",
"=",
"false",
",",
"$",
"use",
"=",
"\"\"",
")",
"{",
"$",
"this",
"->",
"criteria_type",
"=",
"$",
"in_source",
";",
"$",
"this",
"->... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L541-L547 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.collateRequestDate | public function collateRequestDate($in_query_name, $in_tag, $in_default, $in_format)
{
$retval = $in_default;
if (array_key_exists($this->query_name . "_" . $in_tag . "_DAY", $_REQUEST)) {
if (!class_exists("DateTime", false)) {
ReporticoApp::handleError("This version of PHP does not have the DateTime class. Must be PHP >= 5.3 to use date criteria");
return $retval;
}
$dy = $_REQUEST[$this->query_name . "_" . $in_tag . "_DAY"];
$mn = $_REQUEST[$this->query_name . "_" . $in_tag . "_MONTH"] + 1;
$yr = $_REQUEST[$this->query_name . "_" . $in_tag . "_YEAR"];
$retval = sprintf("%02d-%02d-%04d", $dy, $mn, $yr);
$datetime = DateTime::createFromFormat("d-m-Y", $retval);
$in_format = ReporticoLocale::getLocaleDateFormat($in_format);
$retval = $datetime->format($in_format);
}
return ($retval);
} | php | public function collateRequestDate($in_query_name, $in_tag, $in_default, $in_format)
{
$retval = $in_default;
if (array_key_exists($this->query_name . "_" . $in_tag . "_DAY", $_REQUEST)) {
if (!class_exists("DateTime", false)) {
ReporticoApp::handleError("This version of PHP does not have the DateTime class. Must be PHP >= 5.3 to use date criteria");
return $retval;
}
$dy = $_REQUEST[$this->query_name . "_" . $in_tag . "_DAY"];
$mn = $_REQUEST[$this->query_name . "_" . $in_tag . "_MONTH"] + 1;
$yr = $_REQUEST[$this->query_name . "_" . $in_tag . "_YEAR"];
$retval = sprintf("%02d-%02d-%04d", $dy, $mn, $yr);
$datetime = DateTime::createFromFormat("d-m-Y", $retval);
$in_format = ReporticoLocale::getLocaleDateFormat($in_format);
$retval = $datetime->format($in_format);
}
return ($retval);
} | [
"public",
"function",
"collateRequestDate",
"(",
"$",
"in_query_name",
",",
"$",
"in_tag",
",",
"$",
"in_default",
",",
"$",
"in_format",
")",
"{",
"$",
"retval",
"=",
"$",
"in_default",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"this",
"->",
"query_na... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L552-L570 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.& | public function &date_display()
{
$text = "";
$this->range_start = $this->range_end = "";
$this->range_start = $this->column_value;
if (!array_key_exists("clearform", $_REQUEST) && array_key_exists("MANUAL_" . $this->query_name . "_FROMDATE", $_REQUEST)) {
$this->range_start = $_REQUEST["MANUAL_" . $this->query_name . "_FROMDATE"];
$this->range_start = $this->collateRequestDate($this->query_name, "FROMDATE", $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
} else
if (!array_key_exists("clearform", $_REQUEST) && array_key_exists("HIDDEN_" . $this->query_name . "_FROMDATE", $_REQUEST)) {
$this->range_start = $_REQUEST["HIDDEN_" . $this->query_name . "_FROMDATE"];
$this->range_start = $this->collateRequestDate($this->query_name, "FROMDATE", $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
} else {
if (count($this->defaults) == 0) {
$this->defaults[0] = "TODAY";
}
if ($this->defaults[0]) {
$dummy = "";
if (!ReporticoLocale::convertDateRangeDefaultsToDates("DATE", $this->defaults[0], $this->range_start, $dummy)) {
trigger_error("Date default '" . $this->defaults[0] . "' is not a valid date. Should be in date format (e.g. yyyy-mm-dd, dd/mm/yyyy) or a date type (TODAY, TOMMORROW etc", E_USER_ERROR);
}
}
unset($_REQUEST["HIDDEN_" . $this->query_name . "_FROMDATE"]);
unset($_REQUEST["HIDDEN_" . $this->query_name . "_TODATE"]);
}
$this->range_start = ReporticoLocale::parseDate($this->range_start, false, ReporticoApp::getConfig("prep_dateformat"));
$text .= $this->formatDateValue($this->query_name . '_FROMDATE', $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
return $text;
} | php | public function &date_display()
{
$text = "";
$this->range_start = $this->range_end = "";
$this->range_start = $this->column_value;
if (!array_key_exists("clearform", $_REQUEST) && array_key_exists("MANUAL_" . $this->query_name . "_FROMDATE", $_REQUEST)) {
$this->range_start = $_REQUEST["MANUAL_" . $this->query_name . "_FROMDATE"];
$this->range_start = $this->collateRequestDate($this->query_name, "FROMDATE", $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
} else
if (!array_key_exists("clearform", $_REQUEST) && array_key_exists("HIDDEN_" . $this->query_name . "_FROMDATE", $_REQUEST)) {
$this->range_start = $_REQUEST["HIDDEN_" . $this->query_name . "_FROMDATE"];
$this->range_start = $this->collateRequestDate($this->query_name, "FROMDATE", $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
} else {
if (count($this->defaults) == 0) {
$this->defaults[0] = "TODAY";
}
if ($this->defaults[0]) {
$dummy = "";
if (!ReporticoLocale::convertDateRangeDefaultsToDates("DATE", $this->defaults[0], $this->range_start, $dummy)) {
trigger_error("Date default '" . $this->defaults[0] . "' is not a valid date. Should be in date format (e.g. yyyy-mm-dd, dd/mm/yyyy) or a date type (TODAY, TOMMORROW etc", E_USER_ERROR);
}
}
unset($_REQUEST["HIDDEN_" . $this->query_name . "_FROMDATE"]);
unset($_REQUEST["HIDDEN_" . $this->query_name . "_TODATE"]);
}
$this->range_start = ReporticoLocale::parseDate($this->range_start, false, ReporticoApp::getConfig("prep_dateformat"));
$text .= $this->formatDateValue($this->query_name . '_FROMDATE', $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
return $text;
} | [
"public",
"function",
"&",
"date_display",
"(",
")",
"{",
"$",
"text",
"=",
"\"\"",
";",
"$",
"this",
"->",
"range_start",
"=",
"$",
"this",
"->",
"range_end",
"=",
"\"\"",
";",
"$",
"this",
"->",
"range_start",
"=",
"$",
"this",
"->",
"column_value",
... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L575-L609 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.& | public function &daterange_display()
{
$text = "";
$this->range_start = $this->range_end = "";
if (!array_key_exists("clearform", $_REQUEST) && array_key_exists("MANUAL_" . $this->query_name . "_FROMDATE", $_REQUEST)) {
$this->range_start = $_REQUEST["MANUAL_" . $this->query_name . "_FROMDATE"];
$this->range_start = $this->collateRequestDate($this->query_name, "FROMDATE", $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
} else
if (!array_key_exists("clearform", $_REQUEST) && array_key_exists("HIDDEN_" . $this->query_name . "_FROMDATE", $_REQUEST)) {
$this->range_start = $_REQUEST["HIDDEN_" . $this->query_name . "_FROMDATE"];
$this->range_start = $this->collateRequestDate($this->query_name, "FROMDATE", $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
} else {
// User reset form or first time in, set defaults and clear existing form info
if (count($this->defaults) == 0) {
$this->defaults[0] = "TODAY-TODAY";
}
if ($this->defaults[0]) {
if (!ReporticoLocale::convertDateRangeDefaultsToDates("DATERANGE", $this->defaults[0], $this->range_start, $this->range_end)) {
trigger_error("Date default '" . $this->defaults[0] . "' is not a valid date range. Should be 2 values separated by '-'. Each one should be in date format (e.g. yyyy-mm-dd, dd/mm/yyyy) or a date type (TODAY, TOMMORROW etc", E_USER_ERROR);
}
unset($_REQUEST["MANUAL_" . $this->query_name . "_FROMDATE"]);
unset($_REQUEST["MANUAL_" . $this->query_name . "_TODATE"]);
unset($_REQUEST["HIDDEN_" . $this->query_name . "_FROMDATE"]);
unset($_REQUEST["HIDDEN_" . $this->query_name . "_TODATE"]);
}
}
if (!$this->range_start) {
$this->range_end = "TODAY";
}
$this->range_start = ReporticoLocale::parseDate($this->range_start, false, ReporticoApp::getConfig("prep_dateformat"));
$text .= $this->formatDateValue($this->query_name . '_FROMDATE', $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
$text .= " - ";
if (array_key_exists("MANUAL_" . $this->query_name . "_TODATE", $_REQUEST)) {
$this->range_end = $_REQUEST["MANUAL_" . $this->query_name . "_TODATE"];
$this->range_end = $this->collateRequestDate($this->query_name, "TODATE", $this->range_end, ReporticoApp::getConfig("prep_dateformat"));
} else if (array_key_exists("HIDDEN_" . $this->query_name . "_TODATE", $_REQUEST)) {
$this->range_end = $_REQUEST["HIDDEN_" . $this->query_name . "_TODATE"];
$this->range_end = $this->collateRequestDate($this->query_name, "TODATE", $this->range_end, ReporticoApp::getConfig("prep_dateformat"));
}
if (!$this->range_end) {
$this->range_end = "TODAY";
}
$this->range_end = ReporticoLocale::parseDate($this->range_end, false, ReporticoApp::getConfig("prep_dateformat"));
$text .= $this->formatDateValue($this->query_name . '_TODATE', $this->range_end, ReporticoApp::getConfig("prep_dateformat"));
return $text;
} | php | public function &daterange_display()
{
$text = "";
$this->range_start = $this->range_end = "";
if (!array_key_exists("clearform", $_REQUEST) && array_key_exists("MANUAL_" . $this->query_name . "_FROMDATE", $_REQUEST)) {
$this->range_start = $_REQUEST["MANUAL_" . $this->query_name . "_FROMDATE"];
$this->range_start = $this->collateRequestDate($this->query_name, "FROMDATE", $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
} else
if (!array_key_exists("clearform", $_REQUEST) && array_key_exists("HIDDEN_" . $this->query_name . "_FROMDATE", $_REQUEST)) {
$this->range_start = $_REQUEST["HIDDEN_" . $this->query_name . "_FROMDATE"];
$this->range_start = $this->collateRequestDate($this->query_name, "FROMDATE", $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
} else {
// User reset form or first time in, set defaults and clear existing form info
if (count($this->defaults) == 0) {
$this->defaults[0] = "TODAY-TODAY";
}
if ($this->defaults[0]) {
if (!ReporticoLocale::convertDateRangeDefaultsToDates("DATERANGE", $this->defaults[0], $this->range_start, $this->range_end)) {
trigger_error("Date default '" . $this->defaults[0] . "' is not a valid date range. Should be 2 values separated by '-'. Each one should be in date format (e.g. yyyy-mm-dd, dd/mm/yyyy) or a date type (TODAY, TOMMORROW etc", E_USER_ERROR);
}
unset($_REQUEST["MANUAL_" . $this->query_name . "_FROMDATE"]);
unset($_REQUEST["MANUAL_" . $this->query_name . "_TODATE"]);
unset($_REQUEST["HIDDEN_" . $this->query_name . "_FROMDATE"]);
unset($_REQUEST["HIDDEN_" . $this->query_name . "_TODATE"]);
}
}
if (!$this->range_start) {
$this->range_end = "TODAY";
}
$this->range_start = ReporticoLocale::parseDate($this->range_start, false, ReporticoApp::getConfig("prep_dateformat"));
$text .= $this->formatDateValue($this->query_name . '_FROMDATE', $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
$text .= " - ";
if (array_key_exists("MANUAL_" . $this->query_name . "_TODATE", $_REQUEST)) {
$this->range_end = $_REQUEST["MANUAL_" . $this->query_name . "_TODATE"];
$this->range_end = $this->collateRequestDate($this->query_name, "TODATE", $this->range_end, ReporticoApp::getConfig("prep_dateformat"));
} else if (array_key_exists("HIDDEN_" . $this->query_name . "_TODATE", $_REQUEST)) {
$this->range_end = $_REQUEST["HIDDEN_" . $this->query_name . "_TODATE"];
$this->range_end = $this->collateRequestDate($this->query_name, "TODATE", $this->range_end, ReporticoApp::getConfig("prep_dateformat"));
}
if (!$this->range_end) {
$this->range_end = "TODAY";
}
$this->range_end = ReporticoLocale::parseDate($this->range_end, false, ReporticoApp::getConfig("prep_dateformat"));
$text .= $this->formatDateValue($this->query_name . '_TODATE', $this->range_end, ReporticoApp::getConfig("prep_dateformat"));
return $text;
} | [
"public",
"function",
"&",
"daterange_display",
"(",
")",
"{",
"$",
"text",
"=",
"\"\"",
";",
"$",
"this",
"->",
"range_start",
"=",
"$",
"this",
"->",
"range_end",
"=",
"\"\"",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"\"clearform\"",
",",
"$",
"... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L614-L670 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.formatDateValue | public function formatDateValue($in_tag, $in_value, $in_label)
{
$text = "";
if (!$in_value) {
return $text;
}
$in_label = ReporticoLocale::getLocaleDateFormat($in_label);
$dy_tag = $in_tag . "_DAY";
$mn_tag = $in_tag . "_MONTH";
$yr_tag = $in_tag . "_YEAR";
$tag = "";
$tag .= '<input type="hidden" name="HIDDEN_' . $in_tag . '"';
$tag .= ' size="' . ($this->column_length) . '"';
$tag .= ' maxlength="' . $this->column_length . '"';
$tag .= ' value="' . $in_value . '">';
$text .= $tag;
if (AJAX_ENABLED) {
$tag = "";
if (preg_match("/TODATE/", $in_tag)) {
$tag .= "";
}
$tag .= '<input class="' . $this->lookup_query->getBootstrapStyle('textfield') . 'reportico-date-field" id="reportico-date-field_' . $in_tag . '" style="z-index: 1000" type="text" name="MANUAL_' . $in_tag . '"';
$tag .= ' size="20"';
$tag .= ' maxlength="20"';
$tag .= ' value="' . $in_value . '">';
$text .= $tag;
return $text;
}
$dy = "FIXTHIS";
$mn = "FIXTHIS";
$yr = "FIXTHIS";
switch ($this->criteria_display) {
case "YMDFIELD":
case "MDYFIELD":
case "DMYFIELD":
case "DMYFORM":
$dyinput = '<SELECT name="' . $dy_tag . '">';
for ($ct = 1; $ct <= 31; $ct++) {
$checked = "";
if ($ct == (int) $dy) {
$checked = "selected";
}
$dyinput .= '<OPTION ' . $checked . ' label="' . $ct . '" value="' . $ct . '">' . $ct . '</OPTION>';
}
$dyinput .= '</SELECT>';
$mtinput = '<SELECT name="' . $mn_tag . '">';
$cal = array(ReporticoLang::translate('January'), ReporticoLang::translate('February'), ReporticoLang::translate('March'), ReporticoLang::translate('April'), ReporticoLang::translate('May'), ReporticoLang::translate('June'),
ReporticoLang::translate('July'), ReporticoLang::translate('August'), ReporticoLang::translate('September'), ReporticoLang::translate('October'), ReporticoLang::translate('November'), ReporticoLang::translate('December'));
for ($ct = 0; $ct <= 11; $ct++) {
$checked = "";
if ($ct == $mn - 1) {
$checked = "selected";
}
$mtinput .= '<OPTION ' . $checked . ' label="' . $cal[$ct] . '" value="' . $ct . '">' . $cal[$ct] . '</OPTION>';
}
$mtinput .= '</SELECT>';
$yrinput = '<SELECT name="' . $yr_tag . '">';
for ($ct = 2000; $ct <= 2020; $ct++) {
$checked = "";
if ($ct == $yr) {
$checked = "selected";
}
$yrinput .= '<OPTION ' . $checked . ' label="' . $ct . '" value="' . $ct . '">' . $ct . '</OPTION>';
}
$yrinput .= '</SELECT>';
switch ($this->criteria_display) {
case "YMDFIELD":
$text .= $yrinput . $mtinput . $dyinput;
break;
case "MDYFIELD":
$text .= $mtinput . $dyinput . $yrinput;
break;
case "DMYFIELD":
case "DMYFORM":
default:
$text .= $dyinput . $mtinput . $yrinput;
break;
}
break;
default:
$tag = "";
if (preg_match("/TODATE/", $in_tag)) {
$tag .= "";
}
$tag .= '<input type="text" name="MANUAL_' . $in_tag . '"';
$tag .= ' size="20"';
//$tag .= ' maxlength="'.$this->column_length.'"';
$tag .= ' maxlength="20"';
$tag .= ' value="' . $in_value . '">';
$text .= $tag;
}
return $text;
} | php | public function formatDateValue($in_tag, $in_value, $in_label)
{
$text = "";
if (!$in_value) {
return $text;
}
$in_label = ReporticoLocale::getLocaleDateFormat($in_label);
$dy_tag = $in_tag . "_DAY";
$mn_tag = $in_tag . "_MONTH";
$yr_tag = $in_tag . "_YEAR";
$tag = "";
$tag .= '<input type="hidden" name="HIDDEN_' . $in_tag . '"';
$tag .= ' size="' . ($this->column_length) . '"';
$tag .= ' maxlength="' . $this->column_length . '"';
$tag .= ' value="' . $in_value . '">';
$text .= $tag;
if (AJAX_ENABLED) {
$tag = "";
if (preg_match("/TODATE/", $in_tag)) {
$tag .= "";
}
$tag .= '<input class="' . $this->lookup_query->getBootstrapStyle('textfield') . 'reportico-date-field" id="reportico-date-field_' . $in_tag . '" style="z-index: 1000" type="text" name="MANUAL_' . $in_tag . '"';
$tag .= ' size="20"';
$tag .= ' maxlength="20"';
$tag .= ' value="' . $in_value . '">';
$text .= $tag;
return $text;
}
$dy = "FIXTHIS";
$mn = "FIXTHIS";
$yr = "FIXTHIS";
switch ($this->criteria_display) {
case "YMDFIELD":
case "MDYFIELD":
case "DMYFIELD":
case "DMYFORM":
$dyinput = '<SELECT name="' . $dy_tag . '">';
for ($ct = 1; $ct <= 31; $ct++) {
$checked = "";
if ($ct == (int) $dy) {
$checked = "selected";
}
$dyinput .= '<OPTION ' . $checked . ' label="' . $ct . '" value="' . $ct . '">' . $ct . '</OPTION>';
}
$dyinput .= '</SELECT>';
$mtinput = '<SELECT name="' . $mn_tag . '">';
$cal = array(ReporticoLang::translate('January'), ReporticoLang::translate('February'), ReporticoLang::translate('March'), ReporticoLang::translate('April'), ReporticoLang::translate('May'), ReporticoLang::translate('June'),
ReporticoLang::translate('July'), ReporticoLang::translate('August'), ReporticoLang::translate('September'), ReporticoLang::translate('October'), ReporticoLang::translate('November'), ReporticoLang::translate('December'));
for ($ct = 0; $ct <= 11; $ct++) {
$checked = "";
if ($ct == $mn - 1) {
$checked = "selected";
}
$mtinput .= '<OPTION ' . $checked . ' label="' . $cal[$ct] . '" value="' . $ct . '">' . $cal[$ct] . '</OPTION>';
}
$mtinput .= '</SELECT>';
$yrinput = '<SELECT name="' . $yr_tag . '">';
for ($ct = 2000; $ct <= 2020; $ct++) {
$checked = "";
if ($ct == $yr) {
$checked = "selected";
}
$yrinput .= '<OPTION ' . $checked . ' label="' . $ct . '" value="' . $ct . '">' . $ct . '</OPTION>';
}
$yrinput .= '</SELECT>';
switch ($this->criteria_display) {
case "YMDFIELD":
$text .= $yrinput . $mtinput . $dyinput;
break;
case "MDYFIELD":
$text .= $mtinput . $dyinput . $yrinput;
break;
case "DMYFIELD":
case "DMYFORM":
default:
$text .= $dyinput . $mtinput . $yrinput;
break;
}
break;
default:
$tag = "";
if (preg_match("/TODATE/", $in_tag)) {
$tag .= "";
}
$tag .= '<input type="text" name="MANUAL_' . $in_tag . '"';
$tag .= ' size="20"';
//$tag .= ' maxlength="'.$this->column_length.'"';
$tag .= ' maxlength="20"';
$tag .= ' value="' . $in_value . '">';
$text .= $tag;
}
return $text;
} | [
"public",
"function",
"formatDateValue",
"(",
"$",
"in_tag",
",",
"$",
"in_value",
",",
"$",
"in_label",
")",
"{",
"$",
"text",
"=",
"\"\"",
";",
"if",
"(",
"!",
"$",
"in_value",
")",
"{",
"return",
"$",
"text",
";",
"}",
"$",
"in_label",
"=",
"Rep... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L675-L791 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.& | public function &lookup_ajax($in_is_expanding)
{
$sessionClass = ReporticoSession();
$text = "";
if ($in_is_expanding) {
$tag_pref = "EXPANDED_";
$type = $this->expand_display;
} else {
$tag_pref = "";
$type = $this->criteria_display;
}
$value_string = "";
$params = array();
$manual_params = array();
$hidden_params = array();
$expanded_params = array();
$manual_override = false;
if (!array_key_exists("clearform", $_REQUEST)) {
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists($this->query_name, $_REQUEST)) {
$params = $_REQUEST[$this->query_name];
if (!is_array($params)) {
$params = array($params);
}
}
}
$hidden_params = array();
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists("HIDDEN_" . $this->query_name, $_REQUEST)) {
$hidden_params = $_REQUEST["HIDDEN_" . $this->query_name];
if (!is_array($hidden_params)) {
$hidden_params = array($hidden_params);
}
}
}
$manual_params = array();
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists("MANUAL_" . $this->query_name, $_REQUEST)) {
$manual_params = explode(',', $_REQUEST["MANUAL_" . $this->query_name]);
if ($manual_params) {
$hidden_params = $manual_params;
$manual_override = true;
}
}
}
// If this is first time into screen and we have defaults then
// use these instead
if (!$hidden_params && $sessionClass::getReporticoSessionParam("firstTimeIn")) {
$hidden_params = $this->defaults;
$manual_params = $this->defaults;
}
$expanded_params = array();
if (array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
$expanded_params = $_REQUEST["EXPANDED_" . $this->query_name];
if (!is_array($expanded_params)) {
$expanded_params = array($expanded_params);
}
}
} else {
$hidden_params = $this->defaults;
$manual_params = $this->defaults;
$params = $this->defaults;
}
switch ($type) {
case "NOINPUT":
case "ANYCHAR":
case "TEXTFIELD":
$text .= '<SELECT style="display:none" name="' . "HIDDEN_" . $this->query_name . '[]" size="0" multiple>';
break;
case "SELECT2MULTIPLE":
case "SELECT2SINGLE":
$text .= '{"items": [';
break;
case "MULTI":
$multisize = 12;
$res = &$this->lookup_query->targets[0]->results;
$k = key($res);
$multisize = 4;
if ($res && count($res[$k]) > 4) {
$multisize = count($res[$k]);
}
if (isset($res[$k])) {
if (count($res[$k]) >= 10) {
$multisize = 10;
}
}
if ($in_is_expanding) {
$multisize = 12;
}
$text .= '<SELECT class="' . $this->lookup_query->getBootstrapStyle('design_dropdown') . 'reportico-prepare-drop-select" name="' . $tag_pref . $this->query_name . '[]" size="' . $multisize . '" multiple>';
break;
case "CHECKBOX":
case "RADIO":
break;
default:
$text .= '<SELECT class="' . $this->lookup_query->getBootstrapStyle('design_dropdown') . 'reportico-drop-select-regular" name="' . $tag_pref . $this->query_name . '">';
break;
}
$check_text = "";
switch ($type) {
case "MULTI":
case "DROPDOWN":
case "ANYCHAR":
case "TEXTFIELD":
case "NOINPUT":
$check_text = "selected";
break;
default:
$check_text = "checked";
break;
}
// If clear has been pressed we dont want any list items selected
if ($this->submitted('EXPANDCLEAR_' . $this->query_name)) {
$check_text = "";
}
// If select all has been pressed we want all highlighted
$selectall = false;
if ($this->submitted('EXPANDSELECTALL_' . $this->query_name)) {
$selectall = true;
}
$res = &$this->lookup_query->targets[0]->results;
if (!$res) {
$res = array();
$k = 0;
} else {
reset($res);
$k = key($res);
for ($i = 0; $i < count($res[$k]); $i++) {
$line = &$res[$i];
foreach ($this->lookup_query->columns as $ky => $col) {
if ($col->lookup_display_flag) {
$lab = $res[$col->query_name][$i];
}
if ($col->lookup_return_flag) {
$ret = $res[$col->query_name][$i];
}
if ($col->lookup_abbrev_flag) {
$abb = $res[$col->query_name][$i];
}
}
//$text .= '<OPTION label="'.$ret.'" value="'.$ret.'">'.$lab.'</OPTION>';
$checked = "";
if (in_array($ret, $params)) {
$checked = $check_text;
}
if (in_array($ret, $hidden_params) && !$manual_override) {
$checked = $check_text;
}
if (in_array($ret, $expanded_params)) {
$checked = $check_text;
}
if (in_array($abb, $hidden_params) && $manual_override) {
$checked = $check_text;
}
if ($selectall) {
$checked = $check_text;
}
if ($checked != "") {
if (!$value_string && $value_string != "0") {
$value_string = $abb;
} else {
$value_string .= "," . $abb;
}
}
switch ($type) {
case "MULTI":
$text .= '<OPTION label="' . $lab . '" value="' . $ret . '" ' . $checked . '>' . $lab . '</OPTION>';
break;
case "SELECT2MULTIPLE":
case "SELECT2SINGLE":
if ($i > 0) {
$text .= ",";
}
$text .= "{\"id\":\"$ret\", \"text\":\"$lab\"}";
break;
case "RADIO":
$text .= '<INPUT type="radio" name="' . $tag_pref . $this->query_name . '" value="' . $ret . '" ' . $checked . '>' . $lab . '<BR>';
break;
case "CHECKBOX":
$text .= '<INPUT type="checkbox" name="' . $tag_pref . $this->query_name . '[]" value="' . $ret . '" ' . $checked . '>' . $lab . '<BR>';
break;
default:
if ($i == 0) {
$text .= '<OPTION label="" value=""></OPTION>';
}
$text .= '<OPTION label="' . $lab . '" value="' . $ret . '" ' . $checked . '>' . $lab . '</OPTION>';
break;
}
}
}
switch ($type) {
case "MULTI":
$text .= '</SELECT>';
break;
case "SELECT2MULTIPLE":
case "SELECT2SINGLE":
$text .= ']}';
break;
case "CHECKBOX":
case "RADIO":
break;
default:
$text .= '</SELECT>';
break;
}
if (!$in_is_expanding) {
if (array_key_exists("EXPAND_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDCLEAR_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDSELECTALL_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDSEARCH_" . $this->query_name, $_REQUEST) ||
$this->criteria_display == "NOINPUT")
//if ( $this->criteria_display == "NOINPUT" )
{
$tag = $value_string;
if (strlen($tag) > 40) {
$tag = substr($tag, 0, 40) . "...";
}
if (!$tag) {
$tag = "ANY";
}
$text .= $tag;
} else if ($this->criteria_display == "ANYCHAR" || $this->criteria_display == "TEXTFIELD") {
if ($manual_override && !$value_string) {
$value_string = $_REQUEST["MANUAL_" . $this->query_name];
}
$tag = "";
$tag .= '<input type="text" class="' . $this->lookup_query->getBootstrapStyle('textfield') . 'reportico-prepare-text-field" name="MANUAL_' . $this->query_name . '"';
$tag .= ' value="' . $value_string . '">';
$text .= $tag;
}
}
return $text;
} | php | public function &lookup_ajax($in_is_expanding)
{
$sessionClass = ReporticoSession();
$text = "";
if ($in_is_expanding) {
$tag_pref = "EXPANDED_";
$type = $this->expand_display;
} else {
$tag_pref = "";
$type = $this->criteria_display;
}
$value_string = "";
$params = array();
$manual_params = array();
$hidden_params = array();
$expanded_params = array();
$manual_override = false;
if (!array_key_exists("clearform", $_REQUEST)) {
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists($this->query_name, $_REQUEST)) {
$params = $_REQUEST[$this->query_name];
if (!is_array($params)) {
$params = array($params);
}
}
}
$hidden_params = array();
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists("HIDDEN_" . $this->query_name, $_REQUEST)) {
$hidden_params = $_REQUEST["HIDDEN_" . $this->query_name];
if (!is_array($hidden_params)) {
$hidden_params = array($hidden_params);
}
}
}
$manual_params = array();
if (!array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
if (array_key_exists("MANUAL_" . $this->query_name, $_REQUEST)) {
$manual_params = explode(',', $_REQUEST["MANUAL_" . $this->query_name]);
if ($manual_params) {
$hidden_params = $manual_params;
$manual_override = true;
}
}
}
// If this is first time into screen and we have defaults then
// use these instead
if (!$hidden_params && $sessionClass::getReporticoSessionParam("firstTimeIn")) {
$hidden_params = $this->defaults;
$manual_params = $this->defaults;
}
$expanded_params = array();
if (array_key_exists("EXPANDED_" . $this->query_name, $_REQUEST)) {
$expanded_params = $_REQUEST["EXPANDED_" . $this->query_name];
if (!is_array($expanded_params)) {
$expanded_params = array($expanded_params);
}
}
} else {
$hidden_params = $this->defaults;
$manual_params = $this->defaults;
$params = $this->defaults;
}
switch ($type) {
case "NOINPUT":
case "ANYCHAR":
case "TEXTFIELD":
$text .= '<SELECT style="display:none" name="' . "HIDDEN_" . $this->query_name . '[]" size="0" multiple>';
break;
case "SELECT2MULTIPLE":
case "SELECT2SINGLE":
$text .= '{"items": [';
break;
case "MULTI":
$multisize = 12;
$res = &$this->lookup_query->targets[0]->results;
$k = key($res);
$multisize = 4;
if ($res && count($res[$k]) > 4) {
$multisize = count($res[$k]);
}
if (isset($res[$k])) {
if (count($res[$k]) >= 10) {
$multisize = 10;
}
}
if ($in_is_expanding) {
$multisize = 12;
}
$text .= '<SELECT class="' . $this->lookup_query->getBootstrapStyle('design_dropdown') . 'reportico-prepare-drop-select" name="' . $tag_pref . $this->query_name . '[]" size="' . $multisize . '" multiple>';
break;
case "CHECKBOX":
case "RADIO":
break;
default:
$text .= '<SELECT class="' . $this->lookup_query->getBootstrapStyle('design_dropdown') . 'reportico-drop-select-regular" name="' . $tag_pref . $this->query_name . '">';
break;
}
$check_text = "";
switch ($type) {
case "MULTI":
case "DROPDOWN":
case "ANYCHAR":
case "TEXTFIELD":
case "NOINPUT":
$check_text = "selected";
break;
default:
$check_text = "checked";
break;
}
// If clear has been pressed we dont want any list items selected
if ($this->submitted('EXPANDCLEAR_' . $this->query_name)) {
$check_text = "";
}
// If select all has been pressed we want all highlighted
$selectall = false;
if ($this->submitted('EXPANDSELECTALL_' . $this->query_name)) {
$selectall = true;
}
$res = &$this->lookup_query->targets[0]->results;
if (!$res) {
$res = array();
$k = 0;
} else {
reset($res);
$k = key($res);
for ($i = 0; $i < count($res[$k]); $i++) {
$line = &$res[$i];
foreach ($this->lookup_query->columns as $ky => $col) {
if ($col->lookup_display_flag) {
$lab = $res[$col->query_name][$i];
}
if ($col->lookup_return_flag) {
$ret = $res[$col->query_name][$i];
}
if ($col->lookup_abbrev_flag) {
$abb = $res[$col->query_name][$i];
}
}
//$text .= '<OPTION label="'.$ret.'" value="'.$ret.'">'.$lab.'</OPTION>';
$checked = "";
if (in_array($ret, $params)) {
$checked = $check_text;
}
if (in_array($ret, $hidden_params) && !$manual_override) {
$checked = $check_text;
}
if (in_array($ret, $expanded_params)) {
$checked = $check_text;
}
if (in_array($abb, $hidden_params) && $manual_override) {
$checked = $check_text;
}
if ($selectall) {
$checked = $check_text;
}
if ($checked != "") {
if (!$value_string && $value_string != "0") {
$value_string = $abb;
} else {
$value_string .= "," . $abb;
}
}
switch ($type) {
case "MULTI":
$text .= '<OPTION label="' . $lab . '" value="' . $ret . '" ' . $checked . '>' . $lab . '</OPTION>';
break;
case "SELECT2MULTIPLE":
case "SELECT2SINGLE":
if ($i > 0) {
$text .= ",";
}
$text .= "{\"id\":\"$ret\", \"text\":\"$lab\"}";
break;
case "RADIO":
$text .= '<INPUT type="radio" name="' . $tag_pref . $this->query_name . '" value="' . $ret . '" ' . $checked . '>' . $lab . '<BR>';
break;
case "CHECKBOX":
$text .= '<INPUT type="checkbox" name="' . $tag_pref . $this->query_name . '[]" value="' . $ret . '" ' . $checked . '>' . $lab . '<BR>';
break;
default:
if ($i == 0) {
$text .= '<OPTION label="" value=""></OPTION>';
}
$text .= '<OPTION label="' . $lab . '" value="' . $ret . '" ' . $checked . '>' . $lab . '</OPTION>';
break;
}
}
}
switch ($type) {
case "MULTI":
$text .= '</SELECT>';
break;
case "SELECT2MULTIPLE":
case "SELECT2SINGLE":
$text .= ']}';
break;
case "CHECKBOX":
case "RADIO":
break;
default:
$text .= '</SELECT>';
break;
}
if (!$in_is_expanding) {
if (array_key_exists("EXPAND_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDCLEAR_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDSELECTALL_" . $this->query_name, $_REQUEST) ||
array_key_exists("EXPANDSEARCH_" . $this->query_name, $_REQUEST) ||
$this->criteria_display == "NOINPUT")
//if ( $this->criteria_display == "NOINPUT" )
{
$tag = $value_string;
if (strlen($tag) > 40) {
$tag = substr($tag, 0, 40) . "...";
}
if (!$tag) {
$tag = "ANY";
}
$text .= $tag;
} else if ($this->criteria_display == "ANYCHAR" || $this->criteria_display == "TEXTFIELD") {
if ($manual_override && !$value_string) {
$value_string = $_REQUEST["MANUAL_" . $this->query_name];
}
$tag = "";
$tag .= '<input type="text" class="' . $this->lookup_query->getBootstrapStyle('textfield') . 'reportico-prepare-text-field" name="MANUAL_' . $this->query_name . '"';
$tag .= ' value="' . $value_string . '">';
$text .= $tag;
}
}
return $text;
} | [
"public",
"function",
"&",
"lookup_ajax",
"(",
"$",
"in_is_expanding",
")",
"{",
"$",
"sessionClass",
"=",
"ReporticoSession",
"(",
")",
";",
"$",
"text",
"=",
"\"\"",
";",
"if",
"(",
"$",
"in_is_expanding",
")",
"{",
"$",
"tag_pref",
"=",
"\"EXPANDED_\"",... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L1083-L1366 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.getCriteriaValue | public function getCriteriaValue($in_type, $use_del = true)
{
$cls = "";
switch ($in_type) {
case "RANGE1":
$cls = $this->getCriteriaClause(false, false, false, true, false, $use_del);
break;
case "RANGE2":
$cls = $this->getCriteriaClause(false, false, false, false, true, $use_del);
break;
case "FULL":
$cls = $this->getCriteriaClause(true, true, true, false, false, $use_del);
break;
case "VALUE":
$cls = $this->getCriteriaClause(false, false, true, false, false, $use_del);
break;
default:
ReporticoApp::handleError("Unknown Criteria clause type $in_type for criteria " . $this->query_name);
break;
}
return $cls;
} | php | public function getCriteriaValue($in_type, $use_del = true)
{
$cls = "";
switch ($in_type) {
case "RANGE1":
$cls = $this->getCriteriaClause(false, false, false, true, false, $use_del);
break;
case "RANGE2":
$cls = $this->getCriteriaClause(false, false, false, false, true, $use_del);
break;
case "FULL":
$cls = $this->getCriteriaClause(true, true, true, false, false, $use_del);
break;
case "VALUE":
$cls = $this->getCriteriaClause(false, false, true, false, false, $use_del);
break;
default:
ReporticoApp::handleError("Unknown Criteria clause type $in_type for criteria " . $this->query_name);
break;
}
return $cls;
} | [
"public",
"function",
"getCriteriaValue",
"(",
"$",
"in_type",
",",
"$",
"use_del",
"=",
"true",
")",
"{",
"$",
"cls",
"=",
"\"\"",
";",
"switch",
"(",
"$",
"in_type",
")",
"{",
"case",
"\"RANGE1\"",
":",
"$",
"cls",
"=",
"$",
"this",
"->",
"getCrite... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L1670-L1695 |
reportico-web/reportico | src/CriteriaColumn.php | CriteriaColumn.getCriteriaClause | public function getCriteriaClause($lhs = true, $operand = true, $rhs = true, $rhs1 = false, $rhs2 = false, $add_del = true)
{
$cls = "";
if ($this->_use == "SHOW/HIDE-and-GROUPBY") {
$add_del = false;
}
if ($this->column_value == "(ALL)") {
return $cls;
}
if ($this->column_value == "(NOTFOUND)") {
$cls = " AND 1 = 0";
return $cls;
}
if (!$this->column_value) {
return ($cls);
}
$del = '';
switch ($this->criteria_type) {
case "ANY":
case "ANYCHAR":
case "TEXTFIELD":
if ($add_del) {
$del = $this->getValueDelimiter();
}
$extract = explode(',', $this->column_value);
if (is_array($extract)) {
$ct = 0;
foreach ($extract as $col) {
if (is_string($col)) {
$col = trim($col);
}
if (!$col) {
continue;
}
if ($col == "(ALL)") {
continue;
}
if ($ct == 0) {
if ($lhs) {
//$cls .= " XX".$this->table_name.".".$this->column_name;
$cls .= " AND " . $this->column_name;
}
if ($rhs) {
if ($operand) {
$cls .= " IN (";
}
$cls .= $del . $col . $del;
}
} else
if ($rhs) {
$cls .= "," . $del . $col . $del;
}
$ct++;
}
if ($ct > 0 && $rhs) {
if ($operand) {
$cls .= " )";
}
}
} else {
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($rhs) {
if ($operand) {
$cls .= " =" . $del . $this->column_value . $del;
} else {
$cls .= $del . $this->column_value . $del;
}
}
}
break;
case "LIST":
if ($add_del) {
$del = $this->getValueDelimiter();
}
if (!is_array($this->column_value)) {
$this->column_value = explode(',', $this->column_value);
}
if (is_array($this->column_value)) {
$ct = 0;
foreach ($this->column_value as $col) {
if (is_string($col)) {
$col = trim($col);
}
if ($col == "(ALL)") {
continue;
}
if ($ct == 0) {
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($rhs) {
if ($operand) {
$cls .= " IN (";
}
$cls .= $del . $col . $del;
}
} else
if ($rhs) {
$cls .= "," . $del . $col . $del;
}
$ct++;
}
if ($ct > 0) {
if ($operand) {
$cls .= " )";
}
}
} else {
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($rhs) {
if ($operand) {
$cls .= " =" . $del . $this->column_value . $del;
} else {
$cls .= $del . $this->column_value . $del;
}
}
}
break;
case "DATE":
$cls = "";
if ($this->column_value) {
$val1 = ReporticoLocale::parseDate($this->column_value, false, ReporticoApp::getConfig("prep_dateformat"));
$val1 = ReporticoLocale::convertYMDtoLocal($val1, ReporticoApp::getConfig("prep_dateformat"), ReporticoApp::getConfig("db_dateformat"));
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($add_del) {
$del = $this->getValueDelimiter();
}
if ($rhs) {
if ($operand) {
$cls .= " = ";
}
$cls .= $del . $val1 . $del;
}
}
break;
case "DATERANGE":
$cls = "";
if ($this->column_value) {
// If daterange value here is a range in a single value then its been
// run directly from command line and needs splitting up using "-"
$val1 = ReporticoLocale::parseDate($this->column_value, false, ReporticoApp::getConfig("prep_dateformat"));
$val2 = ReporticoLocale::parseDate($this->column_value2, false, ReporticoApp::getConfig("prep_dateformat"));
$val1 = ReporticoLocale::convertYMDtoLocal($val1, ReporticoApp::getConfig("prep_dateformat"), ReporticoApp::getConfig("db_dateformat"));
$val2 = ReporticoLocale::convertYMDtoLocal($val2, ReporticoApp::getConfig("prep_dateformat"), ReporticoApp::getConfig("db_dateformat"));
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($add_del) {
$del = $this->getValueDelimiter();
}
if ($rhs) {
$cls .= " BETWEEN ";
//$cls .= $del.$this->column_value.$del;
$cls .= $del . $val1 . $del;
$cls .= " AND ";
//$cls .= $del.$this->column_value2.$del;
$cls .= $del . $val2 . $del;
}
if ($rhs1) {
$cls = $del . $val1 . $del;
}
if ($rhs2) {
$cls = $del . $val2 . $del;
}
}
break;
case "LOOKUP":
if ($add_del) {
$del = $this->getValueDelimiter();
}
if (!is_array($this->column_value)) {
$this->column_value = explode(',', $this->column_value);
}
if (is_array($this->column_value)) {
$ct = 0;
foreach ($this->column_value as $col) {
if (is_string($col)) {
$col = trim($col);
}
if ($col == "(ALL)") {
continue;
}
if ($ct == 0) {
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($rhs) {
if ($operand) {
$cls .= " IN (";
}
$cls .= $del . $col . $del;
}
} else
if ($rhs) {
$cls .= "," . $del . $col . $del;
}
$ct++;
}
if ($ct > 0) {
if ($operand) {
$cls .= " )";
}
}
} else {
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($rhs) {
if ($operand) {
$cls .= " =" . $del . $this->column_value . $del;
} else {
$cls .= $del . $this->column_value . $del;
}
}
}
break;
default:
break;
}
return ($cls);
} | php | public function getCriteriaClause($lhs = true, $operand = true, $rhs = true, $rhs1 = false, $rhs2 = false, $add_del = true)
{
$cls = "";
if ($this->_use == "SHOW/HIDE-and-GROUPBY") {
$add_del = false;
}
if ($this->column_value == "(ALL)") {
return $cls;
}
if ($this->column_value == "(NOTFOUND)") {
$cls = " AND 1 = 0";
return $cls;
}
if (!$this->column_value) {
return ($cls);
}
$del = '';
switch ($this->criteria_type) {
case "ANY":
case "ANYCHAR":
case "TEXTFIELD":
if ($add_del) {
$del = $this->getValueDelimiter();
}
$extract = explode(',', $this->column_value);
if (is_array($extract)) {
$ct = 0;
foreach ($extract as $col) {
if (is_string($col)) {
$col = trim($col);
}
if (!$col) {
continue;
}
if ($col == "(ALL)") {
continue;
}
if ($ct == 0) {
if ($lhs) {
//$cls .= " XX".$this->table_name.".".$this->column_name;
$cls .= " AND " . $this->column_name;
}
if ($rhs) {
if ($operand) {
$cls .= " IN (";
}
$cls .= $del . $col . $del;
}
} else
if ($rhs) {
$cls .= "," . $del . $col . $del;
}
$ct++;
}
if ($ct > 0 && $rhs) {
if ($operand) {
$cls .= " )";
}
}
} else {
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($rhs) {
if ($operand) {
$cls .= " =" . $del . $this->column_value . $del;
} else {
$cls .= $del . $this->column_value . $del;
}
}
}
break;
case "LIST":
if ($add_del) {
$del = $this->getValueDelimiter();
}
if (!is_array($this->column_value)) {
$this->column_value = explode(',', $this->column_value);
}
if (is_array($this->column_value)) {
$ct = 0;
foreach ($this->column_value as $col) {
if (is_string($col)) {
$col = trim($col);
}
if ($col == "(ALL)") {
continue;
}
if ($ct == 0) {
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($rhs) {
if ($operand) {
$cls .= " IN (";
}
$cls .= $del . $col . $del;
}
} else
if ($rhs) {
$cls .= "," . $del . $col . $del;
}
$ct++;
}
if ($ct > 0) {
if ($operand) {
$cls .= " )";
}
}
} else {
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($rhs) {
if ($operand) {
$cls .= " =" . $del . $this->column_value . $del;
} else {
$cls .= $del . $this->column_value . $del;
}
}
}
break;
case "DATE":
$cls = "";
if ($this->column_value) {
$val1 = ReporticoLocale::parseDate($this->column_value, false, ReporticoApp::getConfig("prep_dateformat"));
$val1 = ReporticoLocale::convertYMDtoLocal($val1, ReporticoApp::getConfig("prep_dateformat"), ReporticoApp::getConfig("db_dateformat"));
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($add_del) {
$del = $this->getValueDelimiter();
}
if ($rhs) {
if ($operand) {
$cls .= " = ";
}
$cls .= $del . $val1 . $del;
}
}
break;
case "DATERANGE":
$cls = "";
if ($this->column_value) {
// If daterange value here is a range in a single value then its been
// run directly from command line and needs splitting up using "-"
$val1 = ReporticoLocale::parseDate($this->column_value, false, ReporticoApp::getConfig("prep_dateformat"));
$val2 = ReporticoLocale::parseDate($this->column_value2, false, ReporticoApp::getConfig("prep_dateformat"));
$val1 = ReporticoLocale::convertYMDtoLocal($val1, ReporticoApp::getConfig("prep_dateformat"), ReporticoApp::getConfig("db_dateformat"));
$val2 = ReporticoLocale::convertYMDtoLocal($val2, ReporticoApp::getConfig("prep_dateformat"), ReporticoApp::getConfig("db_dateformat"));
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($add_del) {
$del = $this->getValueDelimiter();
}
if ($rhs) {
$cls .= " BETWEEN ";
//$cls .= $del.$this->column_value.$del;
$cls .= $del . $val1 . $del;
$cls .= " AND ";
//$cls .= $del.$this->column_value2.$del;
$cls .= $del . $val2 . $del;
}
if ($rhs1) {
$cls = $del . $val1 . $del;
}
if ($rhs2) {
$cls = $del . $val2 . $del;
}
}
break;
case "LOOKUP":
if ($add_del) {
$del = $this->getValueDelimiter();
}
if (!is_array($this->column_value)) {
$this->column_value = explode(',', $this->column_value);
}
if (is_array($this->column_value)) {
$ct = 0;
foreach ($this->column_value as $col) {
if (is_string($col)) {
$col = trim($col);
}
if ($col == "(ALL)") {
continue;
}
if ($ct == 0) {
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($rhs) {
if ($operand) {
$cls .= " IN (";
}
$cls .= $del . $col . $del;
}
} else
if ($rhs) {
$cls .= "," . $del . $col . $del;
}
$ct++;
}
if ($ct > 0) {
if ($operand) {
$cls .= " )";
}
}
} else {
if ($lhs) {
if ($this->table_name && $this->column_name) {
$cls .= " AND " . $this->table_name . "." . $this->column_name;
} else
if ($this->column_name) {
$cls .= " AND " . $this->column_name;
}
}
if ($rhs) {
if ($operand) {
$cls .= " =" . $del . $this->column_value . $del;
} else {
$cls .= $del . $this->column_value . $del;
}
}
}
break;
default:
break;
}
return ($cls);
} | [
"public",
"function",
"getCriteriaClause",
"(",
"$",
"lhs",
"=",
"true",
",",
"$",
"operand",
"=",
"true",
",",
"$",
"rhs",
"=",
"true",
",",
"$",
"rhs1",
"=",
"false",
",",
"$",
"rhs2",
"=",
"false",
",",
"$",
"add_del",
"=",
"true",
")",
"{",
"... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/CriteriaColumn.php#L1700-L2014 |
reportico-web/reportico | src/ReporticoTemplateTwig.php | ReporticoTemplateTwig.fetch | function fetch($template_file) {
$template = $this->twig->load($template_file);
return $template->render($this->twig_vars);
} | php | function fetch($template_file) {
$template = $this->twig->load($template_file);
return $template->render($this->twig_vars);
} | [
"function",
"fetch",
"(",
"$",
"template_file",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"twig",
"->",
"load",
"(",
"$",
"template_file",
")",
";",
"return",
"$",
"template",
"->",
"render",
"(",
"$",
"this",
"->",
"twig_vars",
")",
";",
"}... | Assign a template variable
@param mixed $var Config variable name
@return void | [
"Assign",
"a",
"template",
"variable"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoTemplateTwig.php#L86-L89 |
reportico-web/reportico | src/ReporticoTemplateTwig.php | ReporticoTemplateTwig.display | function display($template_file) {
$template = $this->twig->load($template_file);
echo $template->render($this->twig_vars);
} | php | function display($template_file) {
$template = $this->twig->load($template_file);
echo $template->render($this->twig_vars);
} | [
"function",
"display",
"(",
"$",
"template_file",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"twig",
"->",
"load",
"(",
"$",
"template_file",
")",
";",
"echo",
"$",
"template",
"->",
"render",
"(",
"$",
"this",
"->",
"twig_vars",
")",
";",
"}... | Render a template
@param mixed $var Config variable name
@return void | [
"Render",
"a",
"template"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoTemplateTwig.php#L98-L101 |
reportico-web/reportico | src/ReporticoSession.php | ReporticoSession.switchToRequestedNamespace | static function switchToRequestedNamespace($default_namespace)
{
$session_name = $default_namespace;
// Check for Posted Session Name and use that if specified
if (isset($_REQUEST['reportico_session_name'])) {
$session_name = $_REQUEST['reportico_session_name'];
if (preg_match("/_/", $session_name)) {
$ar = explode("_", $session_name);
ReporticoApp::set("session_namespace", $ar[1]);
if (ReporticoApp::get("session_namespace")) {
ReporticoApp::set("session_namespace_key", "reportico_" . ReporticoApp::get("session_namespace"));
}
// Set session to join only if it is not NS meaning its called from framework and existing session
// should be used
//if ($ar[0] != "NS") {
$session_name = $ar[1];
//}
}
}
return $session_name;
} | php | static function switchToRequestedNamespace($default_namespace)
{
$session_name = $default_namespace;
// Check for Posted Session Name and use that if specified
if (isset($_REQUEST['reportico_session_name'])) {
$session_name = $_REQUEST['reportico_session_name'];
if (preg_match("/_/", $session_name)) {
$ar = explode("_", $session_name);
ReporticoApp::set("session_namespace", $ar[1]);
if (ReporticoApp::get("session_namespace")) {
ReporticoApp::set("session_namespace_key", "reportico_" . ReporticoApp::get("session_namespace"));
}
// Set session to join only if it is not NS meaning its called from framework and existing session
// should be used
//if ($ar[0] != "NS") {
$session_name = $ar[1];
//}
}
}
return $session_name;
} | [
"static",
"function",
"switchToRequestedNamespace",
"(",
"$",
"default_namespace",
")",
"{",
"$",
"session_name",
"=",
"$",
"default_namespace",
";",
"// Check for Posted Session Name and use that if specified",
"if",
"(",
"isset",
"(",
"$",
"_REQUEST",
"[",
"'reportico_s... | sessionid_namespacej | [
"sessionid_namespacej"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoSession.php#L20-L44 |
reportico-web/reportico | src/ReporticoSession.php | ReporticoSession.setUpReporticoSession | static function setUpReporticoSession($namespace)
{
// Get current session
$session_name = session_id();
// Check for Posted Session Name and use that if specified
if (isset($_REQUEST['reportico_session_name'])) {
$session_name = $_REQUEST['reportico_session_name'];
if (preg_match("/_/", $session_name)) {
$ar = explode("_", $session_name);
ReporticoApp::set("session_namespace", $ar[1]);
if (ReporticoApp::get("session_namespace")) {
ReporticoApp::set("session_namespace_key", "reportico_" . ReporticoApp::get("session_namespace"));
}
// Set session to join only if it is not NS meaning its called from framework and existing session
// should be used
if ($ar[0] != "NS") {
$session_name = $ar[0];
}
}
}
// If the session_name starts with NS_ then it is a namespace for reportico
// embedded in a framework or for multiple concurrent reportico instances
// , so set the current namespace. All sessiion variables for this namespace
// will be stored in a namspaces specific session array
if (strlen($session_name) >= 3 && substr($session_name, 0, 3) == "NS_") {
if (!$session_name || !isset($_SESSION)) {
session_start();
}
ReporticoApp::set("session_namespace", substr($session_name, 3));
// IF NS_NEW passed then autogenerate session namespace from current time
if (ReporticoApp::get("session_namespace") == "NEW") {
ReporticoApp::set("session_namespace", date("YmdHis"));
}
if (ReporticoApp::get("session_namespace")) {
ReporticoApp::set("session_namespace_key", "reportico_" . ReporticoApp::get("session_namespace"));
}
if (isset($_REQUEST['clear_session']) && isset($_SESSION)) {
self::initializeReporticoNamespace(self::reporticoNamespace());
}
return;
}
// If no current or specified session start one, or if request to clear session (it really means clear namespace)
// then clear this out
if (!$session_name || isset($_REQUEST['clear_session'])) {
// If no session current then create a new one
if (!$session_name || !isset($_SESSION)) {
session_start();
}
if (isset($_REQUEST['new_session']) && $_REQUEST['new_session']) {
session_regenerate_id(false);
}
//unsetReporticoSessionParam("template");
//session_regenerate_id(false);
$session_name = session_id();
// If no session set ( a new session ) set the namespace to be called default
if ( !$namespace ) {
$namespace = "default";
}
if (isset($_REQUEST['clear_session'])) {
ReporticoApp::set("session_namespace", $namespace);
ReporticoApp::set("session_namespace_key", "reportico_" . ReporticoApp::get("session_namespace"));
self::initializeReporticoNamespace(self::reporticoNamespace());
}
} else {
if (session_id() != $session_name) {
session_id($session_name);
session_start();
}
if ( !$namespace ) {
$namespace = "default";
}
//ReporticoApp::set("session_namespace", $namespace);
ReporticoApp::set("session_namespace_key", "reportico_" . ReporticoApp::get("session_namespace"));
$namespace = ReporticoApp::get("session_namespace");
$session_name = session_id();
}
ReporticoLog::debug("Final session name : $session_name");
} | php | static function setUpReporticoSession($namespace)
{
// Get current session
$session_name = session_id();
// Check for Posted Session Name and use that if specified
if (isset($_REQUEST['reportico_session_name'])) {
$session_name = $_REQUEST['reportico_session_name'];
if (preg_match("/_/", $session_name)) {
$ar = explode("_", $session_name);
ReporticoApp::set("session_namespace", $ar[1]);
if (ReporticoApp::get("session_namespace")) {
ReporticoApp::set("session_namespace_key", "reportico_" . ReporticoApp::get("session_namespace"));
}
// Set session to join only if it is not NS meaning its called from framework and existing session
// should be used
if ($ar[0] != "NS") {
$session_name = $ar[0];
}
}
}
// If the session_name starts with NS_ then it is a namespace for reportico
// embedded in a framework or for multiple concurrent reportico instances
// , so set the current namespace. All sessiion variables for this namespace
// will be stored in a namspaces specific session array
if (strlen($session_name) >= 3 && substr($session_name, 0, 3) == "NS_") {
if (!$session_name || !isset($_SESSION)) {
session_start();
}
ReporticoApp::set("session_namespace", substr($session_name, 3));
// IF NS_NEW passed then autogenerate session namespace from current time
if (ReporticoApp::get("session_namespace") == "NEW") {
ReporticoApp::set("session_namespace", date("YmdHis"));
}
if (ReporticoApp::get("session_namespace")) {
ReporticoApp::set("session_namespace_key", "reportico_" . ReporticoApp::get("session_namespace"));
}
if (isset($_REQUEST['clear_session']) && isset($_SESSION)) {
self::initializeReporticoNamespace(self::reporticoNamespace());
}
return;
}
// If no current or specified session start one, or if request to clear session (it really means clear namespace)
// then clear this out
if (!$session_name || isset($_REQUEST['clear_session'])) {
// If no session current then create a new one
if (!$session_name || !isset($_SESSION)) {
session_start();
}
if (isset($_REQUEST['new_session']) && $_REQUEST['new_session']) {
session_regenerate_id(false);
}
//unsetReporticoSessionParam("template");
//session_regenerate_id(false);
$session_name = session_id();
// If no session set ( a new session ) set the namespace to be called default
if ( !$namespace ) {
$namespace = "default";
}
if (isset($_REQUEST['clear_session'])) {
ReporticoApp::set("session_namespace", $namespace);
ReporticoApp::set("session_namespace_key", "reportico_" . ReporticoApp::get("session_namespace"));
self::initializeReporticoNamespace(self::reporticoNamespace());
}
} else {
if (session_id() != $session_name) {
session_id($session_name);
session_start();
}
if ( !$namespace ) {
$namespace = "default";
}
//ReporticoApp::set("session_namespace", $namespace);
ReporticoApp::set("session_namespace_key", "reportico_" . ReporticoApp::get("session_namespace"));
$namespace = ReporticoApp::get("session_namespace");
$session_name = session_id();
}
ReporticoLog::debug("Final session name : $session_name");
} | [
"static",
"function",
"setUpReporticoSession",
"(",
"$",
"namespace",
")",
"{",
"// Get current session",
"$",
"session_name",
"=",
"session_id",
"(",
")",
";",
"// Check for Posted Session Name and use that if specified",
"if",
"(",
"isset",
"(",
"$",
"_REQUEST",
"[",
... | target separate SESSION_ID | [
"target",
"separate",
"SESSION_ID"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoSession.php#L48-L141 |
reportico-web/reportico | src/ReporticoSession.php | ReporticoSession.issetReporticoSessionParam | static function issetReporticoSessionParam($param, $session_name = false)
{
if (!$session_name)
$session_name = ReporticoApp::get("session_namespace_key");
return isset($_SESSION[$session_name][$param]);
} | php | static function issetReporticoSessionParam($param, $session_name = false)
{
if (!$session_name)
$session_name = ReporticoApp::get("session_namespace_key");
return isset($_SESSION[$session_name][$param]);
} | [
"static",
"function",
"issetReporticoSessionParam",
"(",
"$",
"param",
",",
"$",
"session_name",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"session_name",
")",
"$",
"session_name",
"=",
"ReporticoApp",
"::",
"get",
"(",
"\"session_namespace_key\"",
")",
";"... | Check if a particular reeportico session parameter is set
using current session namespace
@param string $param Session parameter name
@param string $session_name Session name
@return bool | [
"Check",
"if",
"a",
"particular",
"reeportico",
"session",
"parameter",
"is",
"set",
"using",
"current",
"session",
"namespace"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoSession.php#L219-L225 |
reportico-web/reportico | src/ReporticoSession.php | ReporticoSession.setReporticoSessionParam | static function setReporticoSessionParam($param, $value, $namespace = false, $array = false)
{
if (!$namespace)
$namespace = ReporticoApp::get("session_namespace_key");
if (!$array) {
$_SESSION[$namespace][$param] = $value;
} else {
$_SESSION[$namespace][$array][$param] = $value;
}
} | php | static function setReporticoSessionParam($param, $value, $namespace = false, $array = false)
{
if (!$namespace)
$namespace = ReporticoApp::get("session_namespace_key");
if (!$array) {
$_SESSION[$namespace][$param] = $value;
} else {
$_SESSION[$namespace][$array][$param] = $value;
}
} | [
"static",
"function",
"setReporticoSessionParam",
"(",
"$",
"param",
",",
"$",
"value",
",",
"$",
"namespace",
"=",
"false",
",",
"$",
"array",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"namespace",
")",
"$",
"namespace",
"=",
"ReporticoApp",
"::",
... | Sets a reportico session_param using current session namespace
@param string $param Session parameter name
@param mixed $value Session parameter value
@param string $namespace Namespace session
@param array|bool ????
@return void | [
"Sets",
"a",
"reportico",
"session_param",
"using",
"current",
"session",
"namespace"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoSession.php#L237-L248 |
reportico-web/reportico | src/ReporticoSession.php | ReporticoSession.getReporticoSessionParam | static function getReporticoSessionParam($param)
{
if(self::issetReporticoSessionParam($param))
return $_SESSION[ReporticoApp::get("session_namespace_key")][$param];
else
return false;
} | php | static function getReporticoSessionParam($param)
{
if(self::issetReporticoSessionParam($param))
return $_SESSION[ReporticoApp::get("session_namespace_key")][$param];
else
return false;
} | [
"static",
"function",
"getReporticoSessionParam",
"(",
"$",
"param",
")",
"{",
"if",
"(",
"self",
"::",
"issetReporticoSessionParam",
"(",
"$",
"param",
")",
")",
"return",
"$",
"_SESSION",
"[",
"ReporticoApp",
"::",
"get",
"(",
"\"session_namespace_key\"",
")",... | Return the value of a reportico session_param
using current session namespace
@param string $param Session parameter name
@return mixed | [
"Return",
"the",
"value",
"of",
"a",
"reportico",
"session_param",
"using",
"current",
"session",
"namespace"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoSession.php#L258-L264 |
reportico-web/reportico | src/ReporticoSession.php | ReporticoSession.unsetReporticoSessionParam | static function unsetReporticoSessionParam($param)
{
if (isset($_SESSION[ReporticoApp::get("session_namespace_key")][$param])) {
unset($_SESSION[ReporticoApp::get("session_namespace_key")][$param]);
}
} | php | static function unsetReporticoSessionParam($param)
{
if (isset($_SESSION[ReporticoApp::get("session_namespace_key")][$param])) {
unset($_SESSION[ReporticoApp::get("session_namespace_key")][$param]);
}
} | [
"static",
"function",
"unsetReporticoSessionParam",
"(",
"$",
"param",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"ReporticoApp",
"::",
"get",
"(",
"\"session_namespace_key\"",
")",
"]",
"[",
"$",
"param",
"]",
")",
")",
"{",
"unset",
"(",
... | Clears a reportico session_param using current session namespace
@param string $param Session parameter name
@return void | [
"Clears",
"a",
"reportico",
"session_param",
"using",
"current",
"session",
"namespace"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoSession.php#L272-L277 |
reportico-web/reportico | src/ReporticoSession.php | ReporticoSession.registerSessionParam | static function registerSessionParam($param, $value)
{
if (!self::issetReporticoSessionParam($param)) {
self::setReporticoSessionParam($param, $value);
}
return self::getReporticoSessionParam($param);
} | php | static function registerSessionParam($param, $value)
{
if (!self::issetReporticoSessionParam($param)) {
self::setReporticoSessionParam($param, $value);
}
return self::getReporticoSessionParam($param);
} | [
"static",
"function",
"registerSessionParam",
"(",
"$",
"param",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"issetReporticoSessionParam",
"(",
"$",
"param",
")",
")",
"{",
"self",
"::",
"setReporticoSessionParam",
"(",
"$",
"param",
",",
"$... | /*
*
* Register a session variable which will remain persistent throughout session | [
"/",
"*",
"*",
"*",
"Register",
"a",
"session",
"variable",
"which",
"will",
"remain",
"persistent",
"throughout",
"session"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoSession.php#L283-L290 |
reportico-web/reportico | src/ReporticoSession.php | ReporticoSession.initializeReporticoNamespace | static function initializeReporticoNamespace($namespace)
{
$namespace = ReporticoApp::get("session_namespace_key");
if (isset($_SESSION[$namespace])) {
unset($_SESSION[$namespace]);
}
ReporticoSession::setReporticoSessionParam("awaiting_initial_defaults", true);
ReporticoSession::setReporticoSessionParam("firsttimeIn", true);
} | php | static function initializeReporticoNamespace($namespace)
{
$namespace = ReporticoApp::get("session_namespace_key");
if (isset($_SESSION[$namespace])) {
unset($_SESSION[$namespace]);
}
ReporticoSession::setReporticoSessionParam("awaiting_initial_defaults", true);
ReporticoSession::setReporticoSessionParam("firsttimeIn", true);
} | [
"static",
"function",
"initializeReporticoNamespace",
"(",
"$",
"namespace",
")",
"{",
"$",
"namespace",
"=",
"ReporticoApp",
"::",
"get",
"(",
"\"session_namespace_key\"",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"namespace",
"]",
")",
... | /*
* initializes a reportico namespace
* | [
"/",
"*",
"*",
"initializes",
"a",
"reportico",
"namespace",
"*"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoSession.php#L320-L329 |
reportico-web/reportico | src/ReporticoLang.php | ReporticoLang.& | static function &translate($in_string)
{
$out_string = &$in_string;
$langage = ReporticoApp::getConfig("language");
$translations = ReporticoApp::get("translations");
if ($translations) {
if (array_key_exists($langage, $translations)) {
$langset = &$translations[$langage];
if (isset($langset[$in_string])) {
$out_string = &$langset[$in_string];
}
}
}
return $out_string;
} | php | static function &translate($in_string)
{
$out_string = &$in_string;
$langage = ReporticoApp::getConfig("language");
$translations = ReporticoApp::get("translations");
if ($translations) {
if (array_key_exists($langage, $translations)) {
$langset = &$translations[$langage];
if (isset($langset[$in_string])) {
$out_string = &$langset[$in_string];
}
}
}
return $out_string;
} | [
"static",
"function",
"&",
"translate",
"(",
"$",
"in_string",
")",
"{",
"$",
"out_string",
"=",
"&",
"$",
"in_string",
";",
"$",
"langage",
"=",
"ReporticoApp",
"::",
"getConfig",
"(",
"\"language\"",
")",
";",
"$",
"translations",
"=",
"ReporticoApp",
":... | Translate string into another language using the (ReporticoApp::get("translations")) array | [
"Translate",
"string",
"into",
"another",
"language",
"using",
"the",
"(",
"ReporticoApp",
"::",
"get",
"(",
"translations",
"))",
"array"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoLang.php#L10-L29 |
reportico-web/reportico | src/ReporticoLang.php | ReporticoLang.& | static function &translateReportDesc($in_report)
{
$in_report = preg_replace("/\.xml$/", "", $in_report);
$out_string = false;
$langage = ReporticoApp::getConfig("language");
$report_desc = ReporticoApp::get("report_desc");
if ($report_desc) {
if (array_key_exists($langage, $report_desc)) {
$langset = &$report_desc[$langage];
if (isset($langset[$in_report])) {
$out_string = &$langset[$in_report];
}
}
}
return $out_string;
} | php | static function &translateReportDesc($in_report)
{
$in_report = preg_replace("/\.xml$/", "", $in_report);
$out_string = false;
$langage = ReporticoApp::getConfig("language");
$report_desc = ReporticoApp::get("report_desc");
if ($report_desc) {
if (array_key_exists($langage, $report_desc)) {
$langset = &$report_desc[$langage];
if (isset($langset[$in_report])) {
$out_string = &$langset[$in_report];
}
}
}
return $out_string;
} | [
"static",
"function",
"&",
"translateReportDesc",
"(",
"$",
"in_report",
")",
"{",
"$",
"in_report",
"=",
"preg_replace",
"(",
"\"/\\.xml$/\"",
",",
"\"\"",
",",
"$",
"in_report",
")",
";",
"$",
"out_string",
"=",
"false",
";",
"$",
"langage",
"=",
"Report... | Translate string into another language using the (ReporticoApp::get("translations")) array | [
"Translate",
"string",
"into",
"another",
"language",
"using",
"the",
"(",
"ReporticoApp",
"::",
"get",
"(",
"translations",
"))",
"array"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoLang.php#L32-L51 |
reportico-web/reportico | src/ReporticoLang.php | ReporticoLang.loadModeLanguagePack | static function loadModeLanguagePack($mode, $output_encoding = "utf-8", $replace = false)
{
$langfile = ReporticoUtility::findBestLocationInIncludePath("language");
// Look for encoding specific language file
if (ReporticoApp::isSetConfig("SW_OUTPUT_ENCODING") && ReporticoApp::getConfig("SW_OUTPUT_ENCODING") != "UTF8" && is_dir($langfile . "/" . ReporticoApp::getConfig("language") . "/" . ReporticoApp::getConfig("SW_OUTPUT_ENCODING") . "/" . $mode)) {
$langfile = $langfile . "/" . ReporticoApp::getConfig("language") . "/" . ReporticoApp::isSetConfig("SW_OUTPUT_ENCODING") . "/" . $mode . ".php";
require $langfile;
} else {
$langfile = $langfile . "/" . ReporticoApp::getConfig("language") . "/" . $mode . ".php";
if (!is_file($langfile)) {
trigger_error("Language pack for mode $mode, language " . ReporticoApp::getConfig("language") . " not found", E_USER_ERROR);
} else {
require $langfile;
// Convert UTF-8 mode to output character set if differen from native language pack
if (strtolower($output_encoding) != "utf-8") {
foreach ($locale_arr["template"] as $k => $v) {
$locale_arr["template"][$k] = iconv("utf-8", $output_encoding, $v);
}
}
$local = ReporticoApp::get("locale");
if (!($local) || !is_array(($local)) || $replace) {
ReporticoApp::set("locale", $locale_arr);
} else {
if (is_array($local["template"]) && is_array($locale_arr) && is_array($locale_arr["template"])) {
$arr = array("template" => array_merge($local["template"], $locale_arr["template"]));
ReporticoApp::set("locale", $arr);
}
}
}
}
} | php | static function loadModeLanguagePack($mode, $output_encoding = "utf-8", $replace = false)
{
$langfile = ReporticoUtility::findBestLocationInIncludePath("language");
// Look for encoding specific language file
if (ReporticoApp::isSetConfig("SW_OUTPUT_ENCODING") && ReporticoApp::getConfig("SW_OUTPUT_ENCODING") != "UTF8" && is_dir($langfile . "/" . ReporticoApp::getConfig("language") . "/" . ReporticoApp::getConfig("SW_OUTPUT_ENCODING") . "/" . $mode)) {
$langfile = $langfile . "/" . ReporticoApp::getConfig("language") . "/" . ReporticoApp::isSetConfig("SW_OUTPUT_ENCODING") . "/" . $mode . ".php";
require $langfile;
} else {
$langfile = $langfile . "/" . ReporticoApp::getConfig("language") . "/" . $mode . ".php";
if (!is_file($langfile)) {
trigger_error("Language pack for mode $mode, language " . ReporticoApp::getConfig("language") . " not found", E_USER_ERROR);
} else {
require $langfile;
// Convert UTF-8 mode to output character set if differen from native language pack
if (strtolower($output_encoding) != "utf-8") {
foreach ($locale_arr["template"] as $k => $v) {
$locale_arr["template"][$k] = iconv("utf-8", $output_encoding, $v);
}
}
$local = ReporticoApp::get("locale");
if (!($local) || !is_array(($local)) || $replace) {
ReporticoApp::set("locale", $locale_arr);
} else {
if (is_array($local["template"]) && is_array($locale_arr) && is_array($locale_arr["template"])) {
$arr = array("template" => array_merge($local["template"], $locale_arr["template"]));
ReporticoApp::set("locale", $arr);
}
}
}
}
} | [
"static",
"function",
"loadModeLanguagePack",
"(",
"$",
"mode",
",",
"$",
"output_encoding",
"=",
"\"utf-8\"",
",",
"$",
"replace",
"=",
"false",
")",
"{",
"$",
"langfile",
"=",
"ReporticoUtility",
"::",
"findBestLocationInIncludePath",
"(",
"\"language\"",
")",
... | Load the relevant localisation strings from the language folder | [
"Load",
"the",
"relevant",
"localisation",
"strings",
"from",
"the",
"language",
"folder"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoLang.php#L54-L86 |
reportico-web/reportico | src/ReporticoLang.php | ReporticoLang.loadProjectLanguagePack | static function loadProjectLanguagePack($project, $output_encoding = "utf-8")
{
ReporticoApp::set("translations", array());
// Include project specific language translations these could be
// held in the file lang.php or lang_<language>.php
$langfile = "projects/$project/lang_" . ReporticoApp::getConfig("language") . ".php";
if (is_file($langfile)) {
include $langfile;
} else {
ReporticoUtility::findFileToInclude($langfile, $langfile);
if (is_file($langfile)) {
include $langfile;
} else {
$langfile = "projects/$project/lang.php";
if (!is_file($langfile)) {
ReporticoUtility::findFileToInclude($langfile, $langfile);
}
if (is_file($langfile)) {
include $langfile;
}
}
}
$translation = ReporticoApp::get("translations");
$langage = ReporticoApp::getConfig("language");
if (isset($translation[$langage]) && is_array($translation[$langage])) {
// Convert UTF-8 mode to output character set if differen from native language pack
if (strtolower($output_encoding) != "utf-8") {
foreach ($translation[$langage] as $k => $v) {
$translation["template"][$k] = iconv("utf-8", $output_encoding, $v);
}
}
}
} | php | static function loadProjectLanguagePack($project, $output_encoding = "utf-8")
{
ReporticoApp::set("translations", array());
// Include project specific language translations these could be
// held in the file lang.php or lang_<language>.php
$langfile = "projects/$project/lang_" . ReporticoApp::getConfig("language") . ".php";
if (is_file($langfile)) {
include $langfile;
} else {
ReporticoUtility::findFileToInclude($langfile, $langfile);
if (is_file($langfile)) {
include $langfile;
} else {
$langfile = "projects/$project/lang.php";
if (!is_file($langfile)) {
ReporticoUtility::findFileToInclude($langfile, $langfile);
}
if (is_file($langfile)) {
include $langfile;
}
}
}
$translation = ReporticoApp::get("translations");
$langage = ReporticoApp::getConfig("language");
if (isset($translation[$langage]) && is_array($translation[$langage])) {
// Convert UTF-8 mode to output character set if differen from native language pack
if (strtolower($output_encoding) != "utf-8") {
foreach ($translation[$langage] as $k => $v) {
$translation["template"][$k] = iconv("utf-8", $output_encoding, $v);
}
}
}
} | [
"static",
"function",
"loadProjectLanguagePack",
"(",
"$",
"project",
",",
"$",
"output_encoding",
"=",
"\"utf-8\"",
")",
"{",
"ReporticoApp",
"::",
"set",
"(",
"\"translations\"",
",",
"array",
"(",
")",
")",
";",
"// Include project specific language translations th... | Load the users custom translations strings from the project | [
"Load",
"the",
"users",
"custom",
"translations",
"strings",
"from",
"the",
"project"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoLang.php#L89-L125 |
reportico-web/reportico | src/ReporticoLang.php | ReporticoLang.localiseTemplateStrings | static function localiseTemplateStrings(&$in_template)
{
$local = ReporticoApp::get("locale");
if ($local) {
foreach ($local["template"] as $key => $string) {
$in_template->assign($key, $string);
}
}
// Now set the HTML META tag for identifying the HTML encoding character set
$in_template->assign("OUTPUT_ENCODING", ReporticoLocale::getOutputEncodingHtml());
} | php | static function localiseTemplateStrings(&$in_template)
{
$local = ReporticoApp::get("locale");
if ($local) {
foreach ($local["template"] as $key => $string) {
$in_template->assign($key, $string);
}
}
// Now set the HTML META tag for identifying the HTML encoding character set
$in_template->assign("OUTPUT_ENCODING", ReporticoLocale::getOutputEncodingHtml());
} | [
"static",
"function",
"localiseTemplateStrings",
"(",
"&",
"$",
"in_template",
")",
"{",
"$",
"local",
"=",
"ReporticoApp",
"::",
"get",
"(",
"\"locale\"",
")",
";",
"if",
"(",
"$",
"local",
")",
"{",
"foreach",
"(",
"$",
"local",
"[",
"\"template\"",
"]... | Set local language strings in templates | [
"Set",
"local",
"language",
"strings",
"in",
"templates"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoLang.php#L128-L139 |
reportico-web/reportico | src/ReporticoLang.php | ReporticoLang.templateXlate | static function templateXlate($in_string)
{
if (!$in_string) {
return $in_string;
}
$out_string = "T_" . $in_string;
$local = ReporticoApp::get("locale");
if ($local) {
if (array_key_exists($out_string, $local["template"])) {
$out_string = $local["template"][$out_string];
}
else
$out_string = $in_string;
}
else
$out_string = $in_string;
return $out_string;
} | php | static function templateXlate($in_string)
{
if (!$in_string) {
return $in_string;
}
$out_string = "T_" . $in_string;
$local = ReporticoApp::get("locale");
if ($local) {
if (array_key_exists($out_string, $local["template"])) {
$out_string = $local["template"][$out_string];
}
else
$out_string = $in_string;
}
else
$out_string = $in_string;
return $out_string;
} | [
"static",
"function",
"templateXlate",
"(",
"$",
"in_string",
")",
"{",
"if",
"(",
"!",
"$",
"in_string",
")",
"{",
"return",
"$",
"in_string",
";",
"}",
"$",
"out_string",
"=",
"\"T_\"",
".",
"$",
"in_string",
";",
"$",
"local",
"=",
"ReporticoApp",
"... | Fetched translation for a template string | [
"Fetched",
"translation",
"for",
"a",
"template",
"string"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoLang.php#L142-L160 |
reportico-web/reportico | src/ReporticoLang.php | ReporticoLang.availableLanguages | static function availableLanguages()
{
$langs = array();
$lang_dir = ReporticoUtility::findBestLocationInIncludePath("language");
//echo $lang_dir; die;
if (is_dir($lang_dir)) {
// Place english at the start
if ($dh = opendir($lang_dir)) {
while (($file = readdir($dh)) !== false) {
if ($file == "en_gb" || $file == "en_us") {
if (is_dir($lang_dir . "/" . $file)) {
$langs[] = array("label" => self::templateXlate($file), "value" => $file, "active" => ($file == ReporticoApp::getConfig("language")));
}
}
}
closedir($dh);
}
if ($dh = opendir($lang_dir)) {
while (($file = readdir($dh)) !== false) {
if ($file != "." && $file != ".." && $file != "CVS" && $file != "packs" && $file != "en_us" && $file != "en_gb") {
if (is_dir($lang_dir . "/" . $file)) {
$langs[] = array("label" => self::templateXlate($file), "value" => $file, "active" => ($file == ReporticoApp::getConfig("language")));
}
}
}
closedir($dh);
}
}
// No languages found at all - default to en_gb
if (count($langs) == 0) {
$langs[] = array("label" => self::templateXlate("en_gb"), "value" => "en_gb");
}
return $langs;
} | php | static function availableLanguages()
{
$langs = array();
$lang_dir = ReporticoUtility::findBestLocationInIncludePath("language");
//echo $lang_dir; die;
if (is_dir($lang_dir)) {
// Place english at the start
if ($dh = opendir($lang_dir)) {
while (($file = readdir($dh)) !== false) {
if ($file == "en_gb" || $file == "en_us") {
if (is_dir($lang_dir . "/" . $file)) {
$langs[] = array("label" => self::templateXlate($file), "value" => $file, "active" => ($file == ReporticoApp::getConfig("language")));
}
}
}
closedir($dh);
}
if ($dh = opendir($lang_dir)) {
while (($file = readdir($dh)) !== false) {
if ($file != "." && $file != ".." && $file != "CVS" && $file != "packs" && $file != "en_us" && $file != "en_gb") {
if (is_dir($lang_dir . "/" . $file)) {
$langs[] = array("label" => self::templateXlate($file), "value" => $file, "active" => ($file == ReporticoApp::getConfig("language")));
}
}
}
closedir($dh);
}
}
// No languages found at all - default to en_gb
if (count($langs) == 0) {
$langs[] = array("label" => self::templateXlate("en_gb"), "value" => "en_gb");
}
return $langs;
} | [
"static",
"function",
"availableLanguages",
"(",
")",
"{",
"$",
"langs",
"=",
"array",
"(",
")",
";",
"$",
"lang_dir",
"=",
"ReporticoUtility",
"::",
"findBestLocationInIncludePath",
"(",
"\"language\"",
")",
";",
"//echo $lang_dir; die;",
"if",
"(",
"is_dir",
"... | Used to generate language selection box | [
"Used",
"to",
"generate",
"language",
"selection",
"box"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoLang.php#L165-L201 |
reportico-web/reportico | src/ReporticoLog.php | ReporticoLog.activeDebugMode | public static function activeDebugMode($TrueOrFalse = true){
$log = new ReporticoLog();
$log->getI()->setDebugMode($TrueOrFalse);
if($TrueOrFalse)
ReporticoLog::debug("*** Debug activation ****");
else
ReporticoLog::debug("*** Debug desactivation ****");
} | php | public static function activeDebugMode($TrueOrFalse = true){
$log = new ReporticoLog();
$log->getI()->setDebugMode($TrueOrFalse);
if($TrueOrFalse)
ReporticoLog::debug("*** Debug activation ****");
else
ReporticoLog::debug("*** Debug desactivation ****");
} | [
"public",
"static",
"function",
"activeDebugMode",
"(",
"$",
"TrueOrFalse",
"=",
"true",
")",
"{",
"$",
"log",
"=",
"new",
"ReporticoLog",
"(",
")",
";",
"$",
"log",
"->",
"getI",
"(",
")",
"->",
"setDebugMode",
"(",
"$",
"TrueOrFalse",
")",
";",
"if",... | /*
Shortcut function to activate debug mode | [
"/",
"*",
"Shortcut",
"function",
"to",
"activate",
"debug",
"mode"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoLog.php#L54-L61 |
reportico-web/reportico | src/ReporticoObject.php | ReporticoObject.& | public function &deriveMetaValue($to_parse)
{
$parsed = $to_parse;
if (preg_match("/{constant,SW_PROJECT}/", $parsed)) {
$parsed = ReporticoApp::getConfig("project");
return $parsed;
} else
if (preg_match("/{constant,SW_DB_DRIVER}/", $parsed)) {
if (defined("SW_DB_TYPE") && SW_DB_TYPE == "framework") {
$parsed = "framework";
} else {
$parsed = preg_replace('/{constant,([^}]*)}/',
'\1',
$parsed);
if (defined($parsed)) {
$parsed = constant($parsed);
} else {
$parsed = ReporticoApp::getConfig("SW_DB_TYPE");
if ( $parsed && $parsed == "framework")
$parsed = ReporticoApp::getConfig("SW_DB_TYPE");
else
$parsed = ReporticoApp::getConfig("SW_DB_DRIVER");
}
}
return $parsed;
} else
if (
preg_match("/{constant,SW_DB_PASSWORD}/", $parsed) ||
preg_match("/{constant,SW_DB_USER}/", $parsed) ||
preg_match("/{constant,SW_DB_DATABASE}/", $parsed)
) {
if (defined("SW_DB_TYPE") && SW_DB_TYPE == "framework") {
$parsed = "";
} else if ( ReporticoApp::getConfig("SW_DB_TYPE") == "framework") {
$parsed = "";
} else {
$parsed = preg_replace('/{constant,([^}]*)}/',
'\1',
$parsed);
if (defined($parsed)) {
$parsed = constant($parsed);
} else {
$parsed = ReporticoApp::getConfig($parsed);
}
}
return $parsed;
} else
if (preg_match("/{constant,.*}/", $parsed)) {
$parsed = preg_replace('/{constant,([^}]*)}/',
'\1',
$parsed);
if (defined($parsed)) {
$parsed = constant($parsed);
} else {
$parsed = ReporticoApp::getConfig($parsed);
}
return $parsed;
} else {
return $parsed;
}
} | php | public function &deriveMetaValue($to_parse)
{
$parsed = $to_parse;
if (preg_match("/{constant,SW_PROJECT}/", $parsed)) {
$parsed = ReporticoApp::getConfig("project");
return $parsed;
} else
if (preg_match("/{constant,SW_DB_DRIVER}/", $parsed)) {
if (defined("SW_DB_TYPE") && SW_DB_TYPE == "framework") {
$parsed = "framework";
} else {
$parsed = preg_replace('/{constant,([^}]*)}/',
'\1',
$parsed);
if (defined($parsed)) {
$parsed = constant($parsed);
} else {
$parsed = ReporticoApp::getConfig("SW_DB_TYPE");
if ( $parsed && $parsed == "framework")
$parsed = ReporticoApp::getConfig("SW_DB_TYPE");
else
$parsed = ReporticoApp::getConfig("SW_DB_DRIVER");
}
}
return $parsed;
} else
if (
preg_match("/{constant,SW_DB_PASSWORD}/", $parsed) ||
preg_match("/{constant,SW_DB_USER}/", $parsed) ||
preg_match("/{constant,SW_DB_DATABASE}/", $parsed)
) {
if (defined("SW_DB_TYPE") && SW_DB_TYPE == "framework") {
$parsed = "";
} else if ( ReporticoApp::getConfig("SW_DB_TYPE") == "framework") {
$parsed = "";
} else {
$parsed = preg_replace('/{constant,([^}]*)}/',
'\1',
$parsed);
if (defined($parsed)) {
$parsed = constant($parsed);
} else {
$parsed = ReporticoApp::getConfig($parsed);
}
}
return $parsed;
} else
if (preg_match("/{constant,.*}/", $parsed)) {
$parsed = preg_replace('/{constant,([^}]*)}/',
'\1',
$parsed);
if (defined($parsed)) {
$parsed = constant($parsed);
} else {
$parsed = ReporticoApp::getConfig($parsed);
}
return $parsed;
} else {
return $parsed;
}
} | [
"public",
"function",
"&",
"deriveMetaValue",
"(",
"$",
"to_parse",
")",
"{",
"$",
"parsed",
"=",
"$",
"to_parse",
";",
"if",
"(",
"preg_match",
"(",
"\"/{constant,SW_PROJECT}/\"",
",",
"$",
"parsed",
")",
")",
"{",
"$",
"parsed",
"=",
"ReporticoApp",
"::"... | {constant,<VALUE>} - returns defined PHP constants | [
"{",
"constant",
"<VALUE",
">",
"}",
"-",
"returns",
"defined",
"PHP",
"constants"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReporticoObject.php#L58-L122 |
reportico-web/reportico | src/ReportHtml.php | ReportHtml.setPageWidgets | function setPageWidgets()
{
$sessionClass = ReporticoSession();
$forward = $sessionClass::sessionRequestItem('forward_url_get_parameters', '');
if ($forward) {
$forward .= "&";
}
if (preg_match("/\?/", $this->query->getActionUrl())) {
$url_join_char = "&";
} else {
$url_join_char = "?";
}
$title = $this->query->deriveAttribute("ReportTitle", "Unknown");
$this->jar["title"] = ReporticoLang::translate($title);
// In printable html mode dont show back box
if (!ReporticoUtility::getRequestItem("printable_html")) {
// Show Go Back Button ( if user is not in "SINGLE REPORT RUN " )- TEMPORARILY DISABLED
if (!$this->query->access_mode || ($this->query->access_mode != "REPORTOUTPUT")) {
$this->jar["buttons"]["back"] = [
"href" => $this->query->getActionUrl() . $url_join_char .
$forward . 'execute_mode=PREPARE&reportico_session_name=' . $sessionClass::reporticoSessionName(),
"class" => "reportico-back-button",
"title" => ReporticoLang::templateXlate("GO_BACK")
];
}
if ($sessionClass::getReporticoSessionParam("show_refresh_button")) {
$this->jar["buttons"]["refresh"] = [
"href" => $this->query->getActionUrl() . $url_join_char .
$forward . 'refreshReport=1&execute_mode=EXECUTE&reportico_session_name=' . $sessionClass::reporticoSessionName(),
"class" => "reportico-refresh-button",
"title" => ReporticoLang::templateXlate("GO_REFRESH")
];
}
$this->jar["buttons"]["print"] = [
"href" => $this->query->getActionUrl() . $url_join_char .
$forward . 'printReport=1&execute_mode=EXECUTE&reportico_session_name=' . $sessionClass::reporticoSessionName(),
"class" => "reportico-print-button",
"title" => ReporticoLang::templateXlate("GO_PRINT")
];
} else {
$this->jar["buttons"]["print"] = [
"href" => $this->query->getActionUrl() . $url_join_char .
$forward . 'printReport=1&execute_mode=EXECUTE&reportico_session_name=' . $sessionClass::reporticoSessionName(),
"class" => "reportico-print-button",
"title" => ReporticoLang::templateXlate("GO_PRINT")
];
}
if ( ! preg_match("/HTML/", $this->query->getAttribute("AutoPaginate")) ) {
$this->jar["buttons"]["paginate"] = [
"href" => $this->query->getActionUrl() . $url_join_char .
$forward . 'printReport=1&execute_mode=EXECUTE&reportico_session_name=' . $sessionClass::reporticoSessionName(),
"class" => "reportico-paginate-button",
"linkClass" => "reportico-paginate-button-link",
"title" => ReporticoLang::templateXlate("PAGINATE")
];
}
if ($this->line_count < 1) {
$this->jar["noDataFound"] = ReporticoLang::templateXlate("NO_DATA_FOUND");
}
} | php | function setPageWidgets()
{
$sessionClass = ReporticoSession();
$forward = $sessionClass::sessionRequestItem('forward_url_get_parameters', '');
if ($forward) {
$forward .= "&";
}
if (preg_match("/\?/", $this->query->getActionUrl())) {
$url_join_char = "&";
} else {
$url_join_char = "?";
}
$title = $this->query->deriveAttribute("ReportTitle", "Unknown");
$this->jar["title"] = ReporticoLang::translate($title);
// In printable html mode dont show back box
if (!ReporticoUtility::getRequestItem("printable_html")) {
// Show Go Back Button ( if user is not in "SINGLE REPORT RUN " )- TEMPORARILY DISABLED
if (!$this->query->access_mode || ($this->query->access_mode != "REPORTOUTPUT")) {
$this->jar["buttons"]["back"] = [
"href" => $this->query->getActionUrl() . $url_join_char .
$forward . 'execute_mode=PREPARE&reportico_session_name=' . $sessionClass::reporticoSessionName(),
"class" => "reportico-back-button",
"title" => ReporticoLang::templateXlate("GO_BACK")
];
}
if ($sessionClass::getReporticoSessionParam("show_refresh_button")) {
$this->jar["buttons"]["refresh"] = [
"href" => $this->query->getActionUrl() . $url_join_char .
$forward . 'refreshReport=1&execute_mode=EXECUTE&reportico_session_name=' . $sessionClass::reporticoSessionName(),
"class" => "reportico-refresh-button",
"title" => ReporticoLang::templateXlate("GO_REFRESH")
];
}
$this->jar["buttons"]["print"] = [
"href" => $this->query->getActionUrl() . $url_join_char .
$forward . 'printReport=1&execute_mode=EXECUTE&reportico_session_name=' . $sessionClass::reporticoSessionName(),
"class" => "reportico-print-button",
"title" => ReporticoLang::templateXlate("GO_PRINT")
];
} else {
$this->jar["buttons"]["print"] = [
"href" => $this->query->getActionUrl() . $url_join_char .
$forward . 'printReport=1&execute_mode=EXECUTE&reportico_session_name=' . $sessionClass::reporticoSessionName(),
"class" => "reportico-print-button",
"title" => ReporticoLang::templateXlate("GO_PRINT")
];
}
if ( ! preg_match("/HTML/", $this->query->getAttribute("AutoPaginate")) ) {
$this->jar["buttons"]["paginate"] = [
"href" => $this->query->getActionUrl() . $url_join_char .
$forward . 'printReport=1&execute_mode=EXECUTE&reportico_session_name=' . $sessionClass::reporticoSessionName(),
"class" => "reportico-paginate-button",
"linkClass" => "reportico-paginate-button-link",
"title" => ReporticoLang::templateXlate("PAGINATE")
];
}
if ($this->line_count < 1) {
$this->jar["noDataFound"] = ReporticoLang::templateXlate("NO_DATA_FOUND");
}
} | [
"function",
"setPageWidgets",
"(",
")",
"{",
"$",
"sessionClass",
"=",
"ReporticoSession",
"(",
")",
";",
"$",
"forward",
"=",
"$",
"sessionClass",
"::",
"sessionRequestItem",
"(",
"'forward_url_get_parameters'",
",",
"''",
")",
";",
"if",
"(",
"$",
"forward",... | /*
Draw refresh, back buttons at top of page and also deal with no rows found scenario | [
"/",
"*",
"Draw",
"refresh",
"back",
"buttons",
"at",
"top",
"of",
"page",
"and",
"also",
"deal",
"with",
"no",
"rows",
"found",
"scenario"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/ReportHtml.php#L1043-L1112 |
reportico-web/reportico | src/XmlWriter.php | XmlWriter.removeFile | public function removeFile($filename)
{
if (!$filename) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . templateXlate("SPECIFYXML"), E_USER_ERROR);
return false;
}
if (!preg_match("/\.xml$/", $filename)) {
$filename = $filename . ".xml";
}
$projdir = $this->query->projects_folder . "/" . ReporticoApp::getConfig("project");
if (!is_file($projdir)) {
ReporticoUtility::findFileToInclude($projdir, $projdir);
}
if ($projdir && is_dir($projdir)) {
$fn = $projdir . "/" . $filename;
if (!is_file($fn)) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . " $filename - " . templateXlate("NOFILE"), E_USER_ERROR);
} else if (!is_writeable($fn)) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . " $filename - " . templateXlate("NOWRITE"), E_USER_ERROR);
} else {
if (!unlink($fn)) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . " $filename - " . templateXlate("NOWRITE"), E_USER_ERROR);
} else {
ReporticoApp::handleDebug(ReporticoLang::templateXlate("REPORTFILE") . " $filename " . templateXlate("DELETEOKACT"), 0);
}
}
} else {
trigger_error("Unable to open project area " . ReporticoApp::getConfig("project") . " to save file $filename " .
$this->query->reports_path . "/" . $filename . " Not Found", E_USER_ERROR);
}
} | php | public function removeFile($filename)
{
if (!$filename) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . templateXlate("SPECIFYXML"), E_USER_ERROR);
return false;
}
if (!preg_match("/\.xml$/", $filename)) {
$filename = $filename . ".xml";
}
$projdir = $this->query->projects_folder . "/" . ReporticoApp::getConfig("project");
if (!is_file($projdir)) {
ReporticoUtility::findFileToInclude($projdir, $projdir);
}
if ($projdir && is_dir($projdir)) {
$fn = $projdir . "/" . $filename;
if (!is_file($fn)) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . " $filename - " . templateXlate("NOFILE"), E_USER_ERROR);
} else if (!is_writeable($fn)) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . " $filename - " . templateXlate("NOWRITE"), E_USER_ERROR);
} else {
if (!unlink($fn)) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . " $filename - " . templateXlate("NOWRITE"), E_USER_ERROR);
} else {
ReporticoApp::handleDebug(ReporticoLang::templateXlate("REPORTFILE") . " $filename " . templateXlate("DELETEOKACT"), 0);
}
}
} else {
trigger_error("Unable to open project area " . ReporticoApp::getConfig("project") . " to save file $filename " .
$this->query->reports_path . "/" . $filename . " Not Found", E_USER_ERROR);
}
} | [
"public",
"function",
"removeFile",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"$",
"filename",
")",
"{",
"trigger_error",
"(",
"ReporticoLang",
"::",
"templateXlate",
"(",
"\"UNABLE_TO_REMOVE\"",
")",
".",
"templateXlate",
"(",
"\"SPECIFYXML\"",
")",
","... | Remove report XML from disk | [
"Remove",
"report",
"XML",
"from",
"disk"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlWriter.php#L430-L466 |
reportico-web/reportico | src/XmlWriter.php | XmlWriter.writeFile | public function writeFile($filename)
{
if (!$filename) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_SAVE") . templateXlate("SPECIFYXML"), E_USER_ERROR);
return false;
}
if (!preg_match("/\.xml$/", $filename)) {
$filename = $filename . ".xml";
}
$projdir = $this->query->projects_folder . "/" . ReporticoApp::getConfig("project");
if (!is_file($projdir)) {
ReporticoUtility::findFileToInclude($projdir, $projdir);
}
if ($projdir && is_dir($projdir)) {
$fn = $projdir . "/" . $filename;
if (!($fd = @fopen($fn, "w"))) {
trigger_error("Unable to open project file " . $fn . " for writing. Check folder and file permissions " , E_USER_ERROR);
return false;
}
} else {
trigger_error("Unable to open project area " . ReporticoApp::getConfig("project") . " to save file $filename " .
$this->query->reports_path . "/" . $filename . " Not Found", E_USER_ERROR);
}
if (!fwrite($fd, '<?xml version="' . $this->xml_version . '"?>')) {
return false;
}
$xmltext = $this->xmldata->unserialize();
if (!fwrite($fd, $xmltext)) {
return false;
}
fclose($fd);
} | php | public function writeFile($filename)
{
if (!$filename) {
trigger_error(ReporticoLang::templateXlate("UNABLE_TO_SAVE") . templateXlate("SPECIFYXML"), E_USER_ERROR);
return false;
}
if (!preg_match("/\.xml$/", $filename)) {
$filename = $filename . ".xml";
}
$projdir = $this->query->projects_folder . "/" . ReporticoApp::getConfig("project");
if (!is_file($projdir)) {
ReporticoUtility::findFileToInclude($projdir, $projdir);
}
if ($projdir && is_dir($projdir)) {
$fn = $projdir . "/" . $filename;
if (!($fd = @fopen($fn, "w"))) {
trigger_error("Unable to open project file " . $fn . " for writing. Check folder and file permissions " , E_USER_ERROR);
return false;
}
} else {
trigger_error("Unable to open project area " . ReporticoApp::getConfig("project") . " to save file $filename " .
$this->query->reports_path . "/" . $filename . " Not Found", E_USER_ERROR);
}
if (!fwrite($fd, '<?xml version="' . $this->xml_version . '"?>')) {
return false;
}
$xmltext = $this->xmldata->unserialize();
if (!fwrite($fd, $xmltext)) {
return false;
}
fclose($fd);
} | [
"public",
"function",
"writeFile",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"$",
"filename",
")",
"{",
"trigger_error",
"(",
"ReporticoLang",
"::",
"templateXlate",
"(",
"\"UNABLE_TO_SAVE\"",
")",
".",
"templateXlate",
"(",
"\"SPECIFYXML\"",
")",
",",
... | Save report XML to disk | [
"Save",
"report",
"XML",
"to",
"disk"
] | train | https://github.com/reportico-web/reportico/blob/2b9d2a75e3a6701198be163cf3993b409c9e5232/src/XmlWriter.php#L469-L512 |
sonata-project/SonataTranslationBundle | src/Checker/TranslatableChecker.php | TranslatableChecker.isTranslatable | public function isTranslatable($object)
{
if (null === $object) {
return false;
}
if (\function_exists('class_uses')) {
// NEXT_MAJOR: remove Translateable and PersonalTrait.
$translateTraits = [
'Sonata\TranslationBundle\Traits\Translatable',
'Sonata\TranslationBundle\Traits\TranslatableTrait',
'Sonata\TranslationBundle\Traits\Gedmo\PersonalTranslatable',
'Sonata\TranslationBundle\Traits\Gedmo\PersonalTranslatableTrait',
];
$traits = class_uses($object);
if (\count(array_intersect($translateTraits, $traits)) > 0) {
return true;
}
}
$objectInterfaces = class_implements($object);
foreach ($this->getSupportedInterfaces() as $interface) {
if (\in_array($interface, $objectInterfaces, true)) {
return true;
}
}
foreach ($this->getSupportedModels() as $model) {
if ($object instanceof $model) {
return true;
}
}
return false;
} | php | public function isTranslatable($object)
{
if (null === $object) {
return false;
}
if (\function_exists('class_uses')) {
// NEXT_MAJOR: remove Translateable and PersonalTrait.
$translateTraits = [
'Sonata\TranslationBundle\Traits\Translatable',
'Sonata\TranslationBundle\Traits\TranslatableTrait',
'Sonata\TranslationBundle\Traits\Gedmo\PersonalTranslatable',
'Sonata\TranslationBundle\Traits\Gedmo\PersonalTranslatableTrait',
];
$traits = class_uses($object);
if (\count(array_intersect($translateTraits, $traits)) > 0) {
return true;
}
}
$objectInterfaces = class_implements($object);
foreach ($this->getSupportedInterfaces() as $interface) {
if (\in_array($interface, $objectInterfaces, true)) {
return true;
}
}
foreach ($this->getSupportedModels() as $model) {
if ($object instanceof $model) {
return true;
}
}
return false;
} | [
"public",
"function",
"isTranslatable",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"object",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"\\",
"function_exists",
"(",
"'class_uses'",
")",
")",
"{",
"// NEXT_MAJOR: remove Translateable... | Check if $object is translatable.
@param mixed $object
@return bool | [
"Check",
"if",
"$object",
"is",
"translatable",
"."
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/Checker/TranslatableChecker.php#L70-L105 |
sonata-project/SonataTranslationBundle | src/DependencyInjection/Compiler/AdminExtensionCompilerPass.php | AdminExtensionCompilerPass.process | public function process(ContainerBuilder $container)
{
$translationTargets = $container->getParameter('sonata_translation.targets');
$adminExtensionReferences = $this->getAdminExtensionReferenceByTypes(array_keys($translationTargets));
foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) {
$admin = $container->getDefinition($id);
$modelClass = $container->getParameterBag()->resolveValue($admin->getArgument(1));
if (!$modelClass || !class_exists($modelClass)) {
continue;
}
$modelClassReflection = new \ReflectionClass($modelClass);
foreach ($adminExtensionReferences as $type => $reference) {
foreach ($translationTargets[$type]['implements'] as $interface) {
if ($modelClassReflection->implementsInterface($interface)) {
$admin->addMethodCall('addExtension', [$reference]);
}
}
foreach ($translationTargets[$type]['instanceof'] as $class) {
if ($modelClassReflection->getName() === $class || $modelClassReflection->isSubclassOf($class)) {
$admin->addMethodCall('addExtension', [$reference]);
}
}
}
}
} | php | public function process(ContainerBuilder $container)
{
$translationTargets = $container->getParameter('sonata_translation.targets');
$adminExtensionReferences = $this->getAdminExtensionReferenceByTypes(array_keys($translationTargets));
foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) {
$admin = $container->getDefinition($id);
$modelClass = $container->getParameterBag()->resolveValue($admin->getArgument(1));
if (!$modelClass || !class_exists($modelClass)) {
continue;
}
$modelClassReflection = new \ReflectionClass($modelClass);
foreach ($adminExtensionReferences as $type => $reference) {
foreach ($translationTargets[$type]['implements'] as $interface) {
if ($modelClassReflection->implementsInterface($interface)) {
$admin->addMethodCall('addExtension', [$reference]);
}
}
foreach ($translationTargets[$type]['instanceof'] as $class) {
if ($modelClassReflection->getName() === $class || $modelClassReflection->isSubclassOf($class)) {
$admin->addMethodCall('addExtension', [$reference]);
}
}
}
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"translationTargets",
"=",
"$",
"container",
"->",
"getParameter",
"(",
"'sonata_translation.targets'",
")",
";",
"$",
"adminExtensionReferences",
"=",
"$",
"this",
"->",
"g... | {@inheritdoc} | [
"{"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/DependencyInjection/Compiler/AdminExtensionCompilerPass.php#L28-L54 |
sonata-project/SonataTranslationBundle | src/DependencyInjection/Compiler/AdminExtensionCompilerPass.php | AdminExtensionCompilerPass.getAdminExtensionReferenceByTypes | protected function getAdminExtensionReferenceByTypes(array $types)
{
$references = [];
foreach ($types as $type) {
$references[$type] = new Reference('sonata_translation.admin.extension.'.$type.'_translatable');
}
return $references;
} | php | protected function getAdminExtensionReferenceByTypes(array $types)
{
$references = [];
foreach ($types as $type) {
$references[$type] = new Reference('sonata_translation.admin.extension.'.$type.'_translatable');
}
return $references;
} | [
"protected",
"function",
"getAdminExtensionReferenceByTypes",
"(",
"array",
"$",
"types",
")",
"{",
"$",
"references",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"$",
"references",
"[",
"$",
"type",
"]",
"=",
"new",
... | @param array $types
@return Reference[] | [
"@param",
"array",
"$types"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/DependencyInjection/Compiler/AdminExtensionCompilerPass.php#L61-L69 |
sonata-project/SonataTranslationBundle | src/DependencyInjection/SonataTranslationExtension.php | SonataTranslationExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
$configuration = new Configuration();
$config = $processor->processConfiguration($configuration, $configs);
$container->setParameter('sonata_translation.locales', $config['locales']);
$container->setParameter('sonata_translation.default_locale', $config['default_locale']);
$container->setParameter('sonata_translation.locale_switcher_show_country_flags', $config['locale_switcher_show_country_flags']);
$isEnabled = false;
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
if ($config['locale_switcher']) {
$loader->load('service_locale_switcher.xml');
}
$bundles = $container->getParameter('kernel.bundles');
if (\array_key_exists('SonataDoctrineORMAdminBundle', $bundles)) {
$loader->load('service_orm.xml');
}
$translationTargets = [];
if ($config['gedmo']['enabled']) {
$isEnabled = true;
$loader->load('service_gedmo.xml');
$translationTargets['gedmo']['implements'] = array_merge(
['Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface'],
$config['gedmo']['implements']
);
$translationTargets['gedmo']['instanceof'] = $config['gedmo']['instanceof'];
}
if ($config['knplabs']['enabled']) {
$isEnabled = true;
$loader->load('service_knplabs.xml');
$translationTargets['knplabs']['implements'] = array_merge(
['Sonata\TranslationBundle\Model\TranslatableInterface'],
$config['knplabs']['implements']
);
$translationTargets['knplabs']['instanceof'] = $config['knplabs']['instanceof'];
}
if ($config['phpcr']['enabled']) {
$isEnabled = true;
$loader->load('service_phpcr.xml');
$translationTargets['phpcr']['implements'] = array_merge(
[
'Sonata\TranslationBundle\Model\Phpcr\TranslatableInterface',
'Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface',
],
$config['phpcr']['implements']
);
$translationTargets['phpcr']['instanceof'] = $config['phpcr']['instanceof'];
}
if (true === $isEnabled) {
$loader->load('block.xml');
$loader->load('listener.xml');
$loader->load('twig.xml');
}
$container->setParameter('sonata_translation.targets', $translationTargets);
$this->configureChecker($container, $translationTargets);
} | php | public function load(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
$configuration = new Configuration();
$config = $processor->processConfiguration($configuration, $configs);
$container->setParameter('sonata_translation.locales', $config['locales']);
$container->setParameter('sonata_translation.default_locale', $config['default_locale']);
$container->setParameter('sonata_translation.locale_switcher_show_country_flags', $config['locale_switcher_show_country_flags']);
$isEnabled = false;
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
if ($config['locale_switcher']) {
$loader->load('service_locale_switcher.xml');
}
$bundles = $container->getParameter('kernel.bundles');
if (\array_key_exists('SonataDoctrineORMAdminBundle', $bundles)) {
$loader->load('service_orm.xml');
}
$translationTargets = [];
if ($config['gedmo']['enabled']) {
$isEnabled = true;
$loader->load('service_gedmo.xml');
$translationTargets['gedmo']['implements'] = array_merge(
['Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface'],
$config['gedmo']['implements']
);
$translationTargets['gedmo']['instanceof'] = $config['gedmo']['instanceof'];
}
if ($config['knplabs']['enabled']) {
$isEnabled = true;
$loader->load('service_knplabs.xml');
$translationTargets['knplabs']['implements'] = array_merge(
['Sonata\TranslationBundle\Model\TranslatableInterface'],
$config['knplabs']['implements']
);
$translationTargets['knplabs']['instanceof'] = $config['knplabs']['instanceof'];
}
if ($config['phpcr']['enabled']) {
$isEnabled = true;
$loader->load('service_phpcr.xml');
$translationTargets['phpcr']['implements'] = array_merge(
[
'Sonata\TranslationBundle\Model\Phpcr\TranslatableInterface',
'Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface',
],
$config['phpcr']['implements']
);
$translationTargets['phpcr']['instanceof'] = $config['phpcr']['instanceof'];
}
if (true === $isEnabled) {
$loader->load('block.xml');
$loader->load('listener.xml');
$loader->load('twig.xml');
}
$container->setParameter('sonata_translation.targets', $translationTargets);
$this->configureChecker($container, $translationTargets);
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"processor",
"=",
"new",
"Processor",
"(",
")",
";",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"config",
"=... | {@inheritdoc} | [
"{"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/DependencyInjection/SonataTranslationExtension.php#L30-L96 |
sonata-project/SonataTranslationBundle | src/Filter/TranslationFieldFilter.php | TranslationFieldFilter.filter | public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
{
if (!$data || !\is_array($data) || !\array_key_exists('value', $data) || null === $data['value']) {
return;
}
$data['value'] = trim($data['value']);
if (0 === \strlen($data['value'])) {
return;
}
$joinAlias = 'tff';
// verify if the join is not already done
$aliasAlreadyExists = false;
foreach ($queryBuilder->getDQLParts()['join'] as $joins) {
foreach ($joins as $join) {
if ($join->getAlias() === $joinAlias) {
$aliasAlreadyExists = true;
break 2;
}
}
}
if (!$aliasAlreadyExists) {
$queryBuilder->leftJoin($alias.'.translations', $joinAlias);
}
// search on translation OR on normal field
$this->applyWhere($queryBuilder, $queryBuilder->expr()->orX(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq($joinAlias.'.field', $queryBuilder->expr()->literal($field)),
$queryBuilder->expr()->like(
$joinAlias.'.content',
$queryBuilder->expr()->literal('%'.$data['value'].'%')
)
),
$queryBuilder->expr()->like(
sprintf('%s.%s', $alias, $field),
$queryBuilder->expr()->literal('%'.$data['value'].'%')
)
));
$this->active = true;
} | php | public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
{
if (!$data || !\is_array($data) || !\array_key_exists('value', $data) || null === $data['value']) {
return;
}
$data['value'] = trim($data['value']);
if (0 === \strlen($data['value'])) {
return;
}
$joinAlias = 'tff';
// verify if the join is not already done
$aliasAlreadyExists = false;
foreach ($queryBuilder->getDQLParts()['join'] as $joins) {
foreach ($joins as $join) {
if ($join->getAlias() === $joinAlias) {
$aliasAlreadyExists = true;
break 2;
}
}
}
if (!$aliasAlreadyExists) {
$queryBuilder->leftJoin($alias.'.translations', $joinAlias);
}
// search on translation OR on normal field
$this->applyWhere($queryBuilder, $queryBuilder->expr()->orX(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq($joinAlias.'.field', $queryBuilder->expr()->literal($field)),
$queryBuilder->expr()->like(
$joinAlias.'.content',
$queryBuilder->expr()->literal('%'.$data['value'].'%')
)
),
$queryBuilder->expr()->like(
sprintf('%s.%s', $alias, $field),
$queryBuilder->expr()->literal('%'.$data['value'].'%')
)
));
$this->active = true;
} | [
"public",
"function",
"filter",
"(",
"ProxyQueryInterface",
"$",
"queryBuilder",
",",
"$",
"alias",
",",
"$",
"field",
",",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"data",
"||",
"!",
"\\",
"is_array",
"(",
"$",
"data",
")",
"||",
"!",
"\\",
"ar... | {@inheritdoc} | [
"{"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/Filter/TranslationFieldFilter.php#L27-L73 |
sonata-project/SonataTranslationBundle | src/Admin/Extension/AbstractTranslatableAdminExtension.php | AbstractTranslatableAdminExtension.getTranslatableLocale | public function getTranslatableLocale(AdminInterface $admin)
{
if (null === $this->translatableLocale) {
if ($admin->hasRequest()) {
$this->translatableLocale = $admin->getRequest()->get(self::TRANSLATABLE_LOCALE_PARAMETER);
}
if (null === $this->translatableLocale) {
$this->translatableLocale = $this->getDefaultTranslationLocale($admin);
}
}
return $this->translatableLocale;
} | php | public function getTranslatableLocale(AdminInterface $admin)
{
if (null === $this->translatableLocale) {
if ($admin->hasRequest()) {
$this->translatableLocale = $admin->getRequest()->get(self::TRANSLATABLE_LOCALE_PARAMETER);
}
if (null === $this->translatableLocale) {
$this->translatableLocale = $this->getDefaultTranslationLocale($admin);
}
}
return $this->translatableLocale;
} | [
"public",
"function",
"getTranslatableLocale",
"(",
"AdminInterface",
"$",
"admin",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"translatableLocale",
")",
"{",
"if",
"(",
"$",
"admin",
"->",
"hasRequest",
"(",
")",
")",
"{",
"$",
"this",
"->",... | Return current translatable locale
ie: the locale used to load object translations != current request locale.
@return string | [
"Return",
"current",
"translatable",
"locale",
"ie",
":",
"the",
"locale",
"used",
"to",
"load",
"object",
"translations",
"!",
"=",
"current",
"request",
"locale",
"."
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/Admin/Extension/AbstractTranslatableAdminExtension.php#L70-L82 |
sonata-project/SonataTranslationBundle | src/Admin/Extension/AbstractTranslatableAdminExtension.php | AbstractTranslatableAdminExtension.alterNewInstance | public function alterNewInstance(AdminInterface $admin, $object)
{
if (null === $object->getLocale()) {
$object->setLocale($this->getTranslatableLocale($admin));
}
} | php | public function alterNewInstance(AdminInterface $admin, $object)
{
if (null === $object->getLocale()) {
$object->setLocale($this->getTranslatableLocale($admin));
}
} | [
"public",
"function",
"alterNewInstance",
"(",
"AdminInterface",
"$",
"admin",
",",
"$",
"object",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"object",
"->",
"getLocale",
"(",
")",
")",
"{",
"$",
"object",
"->",
"setLocale",
"(",
"$",
"this",
"->",
"getT... | {@inheritdoc} | [
"{"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/Admin/Extension/AbstractTranslatableAdminExtension.php#L95-L100 |
sonata-project/SonataTranslationBundle | src/Admin/Extension/Gedmo/TranslatableAdminExtension.php | TranslatableAdminExtension.alterObject | public function alterObject(AdminInterface $admin, $object)
{
if ($this->getTranslatableChecker()->isTranslatable($object)) {
$translatableListener = $this->getTranslatableListener($admin);
$translatableListener->setTranslatableLocale($this->getTranslatableLocale($admin));
$translatableListener->setTranslationFallback(false);
$this->getContainer($admin)->get('doctrine')->getManager()->refresh($object);
$object->setLocale($this->getTranslatableLocale($admin));
}
} | php | public function alterObject(AdminInterface $admin, $object)
{
if ($this->getTranslatableChecker()->isTranslatable($object)) {
$translatableListener = $this->getTranslatableListener($admin);
$translatableListener->setTranslatableLocale($this->getTranslatableLocale($admin));
$translatableListener->setTranslationFallback(false);
$this->getContainer($admin)->get('doctrine')->getManager()->refresh($object);
$object->setLocale($this->getTranslatableLocale($admin));
}
} | [
"public",
"function",
"alterObject",
"(",
"AdminInterface",
"$",
"admin",
",",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getTranslatableChecker",
"(",
")",
"->",
"isTranslatable",
"(",
"$",
"object",
")",
")",
"{",
"$",
"translatableListener",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/Admin/Extension/Gedmo/TranslatableAdminExtension.php#L41-L51 |
sonata-project/SonataTranslationBundle | src/Admin/Extension/Gedmo/TranslatableAdminExtension.php | TranslatableAdminExtension.configureQuery | public function configureQuery(AdminInterface $admin, ProxyQueryInterface $query, $context = 'list')
{
$this->getTranslatableListener($admin)->setTranslatableLocale($this->getTranslatableLocale($admin));
$this->getTranslatableListener($admin)->setTranslationFallback(false);
} | php | public function configureQuery(AdminInterface $admin, ProxyQueryInterface $query, $context = 'list')
{
$this->getTranslatableListener($admin)->setTranslatableLocale($this->getTranslatableLocale($admin));
$this->getTranslatableListener($admin)->setTranslationFallback(false);
} | [
"public",
"function",
"configureQuery",
"(",
"AdminInterface",
"$",
"admin",
",",
"ProxyQueryInterface",
"$",
"query",
",",
"$",
"context",
"=",
"'list'",
")",
"{",
"$",
"this",
"->",
"getTranslatableListener",
"(",
"$",
"admin",
")",
"->",
"setTranslatableLocal... | {@inheritdoc} | [
"{"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/Admin/Extension/Gedmo/TranslatableAdminExtension.php#L56-L60 |
sonata-project/SonataTranslationBundle | src/Admin/Extension/Gedmo/TranslatableAdminExtension.php | TranslatableAdminExtension.getTranslatableListener | protected function getTranslatableListener(AdminInterface $admin)
{
if (null === $this->translatableListener) {
$this->translatableListener = $this->getContainer($admin)->get(
'stof_doctrine_extensions.listener.translatable'
);
}
return $this->translatableListener;
} | php | protected function getTranslatableListener(AdminInterface $admin)
{
if (null === $this->translatableListener) {
$this->translatableListener = $this->getContainer($admin)->get(
'stof_doctrine_extensions.listener.translatable'
);
}
return $this->translatableListener;
} | [
"protected",
"function",
"getTranslatableListener",
"(",
"AdminInterface",
"$",
"admin",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"translatableListener",
")",
"{",
"$",
"this",
"->",
"translatableListener",
"=",
"$",
"this",
"->",
"getContainer",
... | @param AdminInterface $admin Deprecated, set TranslatableListener in the constructor instead
@return TranslatableListener | [
"@param",
"AdminInterface",
"$admin",
"Deprecated",
"set",
"TranslatableListener",
"in",
"the",
"constructor",
"instead"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/Admin/Extension/Gedmo/TranslatableAdminExtension.php#L67-L76 |
sonata-project/SonataTranslationBundle | src/Admin/Extension/Knplabs/TranslatableAdminExtension.php | TranslatableAdminExtension.alterNewInstance | public function alterNewInstance(AdminInterface $admin, $object)
{
if ($this->getTranslatableChecker()->isTranslatable($object)) {
$object->setLocale($this->getTranslatableLocale($admin));
}
} | php | public function alterNewInstance(AdminInterface $admin, $object)
{
if ($this->getTranslatableChecker()->isTranslatable($object)) {
$object->setLocale($this->getTranslatableLocale($admin));
}
} | [
"public",
"function",
"alterNewInstance",
"(",
"AdminInterface",
"$",
"admin",
",",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getTranslatableChecker",
"(",
")",
"->",
"isTranslatable",
"(",
"$",
"object",
")",
")",
"{",
"$",
"object",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/Admin/Extension/Knplabs/TranslatableAdminExtension.php#L27-L32 |
sonata-project/SonataTranslationBundle | src/DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('sonata_translation');
// Keep compatibility with symfony/config < 4.2
if (!method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->root('sonata_translation');
} else {
$rootNode = $treeBuilder->getRootNode();
}
$rootNode
->children()
->arrayNode('locales')
->info('The list of your frontend locales in which your models will be translatable.')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->scalarNode('default_locale')
->defaultValue('en')
->info('The frontend locale that is used by default.')
->end()
->arrayNode('gedmo')
->canBeEnabled()
->children()
->arrayNode('implements')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('instanceof')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->end()
->end()
->arrayNode('knplabs')
->canBeEnabled()
->children()
->arrayNode('implements')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('instanceof')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->end()
->end()
->arrayNode('phpcr')
->canBeEnabled()
->children()
->arrayNode('implements')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('instanceof')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->end()
->end()
->booleanNode('locale_switcher')
->info('Enable the global locale switcher services.')
->defaultFalse()
->end()
// NEXT_MAJOR: Fix locale to country flag mapping OR remove country flags entirely
->booleanNode('locale_switcher_show_country_flags')
->info('Whether the language switcher should show languages as flags')
->defaultTrue()
->end()
->end()
->beforeNormalization()
->ifTrue(static function ($v) {return !isset($v['locale_switcher_show_country_flags']) || true === $v['locale_switcher_show_country_flags']; })
->then(static function ($v) {
@trigger_error(sprintf(
'Showing the country flags is deprecated. The flags will be removed in the next major version. Please set "%s" to false to avoid this message.',
'sonata_translation.locale_switcher_show_country_flags'
), E_USER_DEPRECATED);
$v['locale_switcher_show_country_flags'] = $v['locale_switcher_show_country_flags'] ?? true;
return $v;
})
->end();
return $treeBuilder;
} | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('sonata_translation');
// Keep compatibility with symfony/config < 4.2
if (!method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->root('sonata_translation');
} else {
$rootNode = $treeBuilder->getRootNode();
}
$rootNode
->children()
->arrayNode('locales')
->info('The list of your frontend locales in which your models will be translatable.')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->scalarNode('default_locale')
->defaultValue('en')
->info('The frontend locale that is used by default.')
->end()
->arrayNode('gedmo')
->canBeEnabled()
->children()
->arrayNode('implements')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('instanceof')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->end()
->end()
->arrayNode('knplabs')
->canBeEnabled()
->children()
->arrayNode('implements')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('instanceof')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->end()
->end()
->arrayNode('phpcr')
->canBeEnabled()
->children()
->arrayNode('implements')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('instanceof')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->end()
->end()
->booleanNode('locale_switcher')
->info('Enable the global locale switcher services.')
->defaultFalse()
->end()
// NEXT_MAJOR: Fix locale to country flag mapping OR remove country flags entirely
->booleanNode('locale_switcher_show_country_flags')
->info('Whether the language switcher should show languages as flags')
->defaultTrue()
->end()
->end()
->beforeNormalization()
->ifTrue(static function ($v) {return !isset($v['locale_switcher_show_country_flags']) || true === $v['locale_switcher_show_country_flags']; })
->then(static function ($v) {
@trigger_error(sprintf(
'Showing the country flags is deprecated. The flags will be removed in the next major version. Please set "%s" to false to avoid this message.',
'sonata_translation.locale_switcher_show_country_flags'
), E_USER_DEPRECATED);
$v['locale_switcher_show_country_flags'] = $v['locale_switcher_show_country_flags'] ?? true;
return $v;
})
->end();
return $treeBuilder;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
"'sonata_translation'",
")",
";",
"// Keep compatibility with symfony/config < 4.2",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"treeBuilder",
",",
"'getRo... | {@inheritdoc} | [
"{"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/DependencyInjection/Configuration.php#L27-L112 |
sonata-project/SonataTranslationBundle | src/Admin/Extension/Phpcr/TranslatableAdminExtension.php | TranslatableAdminExtension.alterObject | public function alterObject(AdminInterface $admin, $object)
{
$locale = $this->getTranslatableLocale($admin);
$documentManager = $this->getDocumentManager($admin);
$unitOfWork = $documentManager->getUnitOfWork();
if (
$this->getTranslatableChecker()->isTranslatable($object)
&& ($unitOfWork->getCurrentLocale($object) !== $locale)
) {
$object = $this->getDocumentManager($admin)->findTranslation($admin->getClass(), $object->getId(), $locale);
// if the translation did not yet exists, the locale will be
// the fallback locale. This makes sure the new locale is set.
if ($unitOfWork->getCurrentLocale($object) !== $locale) {
$documentManager->bindTranslation($object, $locale);
}
}
} | php | public function alterObject(AdminInterface $admin, $object)
{
$locale = $this->getTranslatableLocale($admin);
$documentManager = $this->getDocumentManager($admin);
$unitOfWork = $documentManager->getUnitOfWork();
if (
$this->getTranslatableChecker()->isTranslatable($object)
&& ($unitOfWork->getCurrentLocale($object) !== $locale)
) {
$object = $this->getDocumentManager($admin)->findTranslation($admin->getClass(), $object->getId(), $locale);
// if the translation did not yet exists, the locale will be
// the fallback locale. This makes sure the new locale is set.
if ($unitOfWork->getCurrentLocale($object) !== $locale) {
$documentManager->bindTranslation($object, $locale);
}
}
} | [
"public",
"function",
"alterObject",
"(",
"AdminInterface",
"$",
"admin",
",",
"$",
"object",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"getTranslatableLocale",
"(",
"$",
"admin",
")",
";",
"$",
"documentManager",
"=",
"$",
"this",
"->",
"getDocumen... | {@inheritdoc} | [
"{"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/Admin/Extension/Phpcr/TranslatableAdminExtension.php#L42-L60 |
sonata-project/SonataTranslationBundle | src/Admin/Extension/Phpcr/TranslatableAdminExtension.php | TranslatableAdminExtension.configureQuery | public function configureQuery(AdminInterface $admin, ProxyQueryInterface $query, $context = 'list')
{
$this->localeChooser->setLocale($this->getTranslatableLocale($admin));
} | php | public function configureQuery(AdminInterface $admin, ProxyQueryInterface $query, $context = 'list')
{
$this->localeChooser->setLocale($this->getTranslatableLocale($admin));
} | [
"public",
"function",
"configureQuery",
"(",
"AdminInterface",
"$",
"admin",
",",
"ProxyQueryInterface",
"$",
"query",
",",
"$",
"context",
"=",
"'list'",
")",
"{",
"$",
"this",
"->",
"localeChooser",
"->",
"setLocale",
"(",
"$",
"this",
"->",
"getTranslatable... | {@inheritdoc} | [
"{"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/Admin/Extension/Phpcr/TranslatableAdminExtension.php#L65-L68 |
sonata-project/SonataTranslationBundle | src/Model/Gedmo/AbstractPersonalTranslatable.php | AbstractPersonalTranslatable.getTranslation | public function getTranslation($field, $locale)
{
foreach ($this->getTranslations() as $translation) {
if (0 === strcmp($translation->getField(), $field) && 0 === strcmp($translation->getLocale(), $locale)) {
return $translation->getContent();
}
}
} | php | public function getTranslation($field, $locale)
{
foreach ($this->getTranslations() as $translation) {
if (0 === strcmp($translation->getField(), $field) && 0 === strcmp($translation->getLocale(), $locale)) {
return $translation->getContent();
}
}
} | [
"public",
"function",
"getTranslation",
"(",
"$",
"field",
",",
"$",
"locale",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getTranslations",
"(",
")",
"as",
"$",
"translation",
")",
"{",
"if",
"(",
"0",
"===",
"strcmp",
"(",
"$",
"translation",
"->",... | @param string $field
@param string $locale
@return string|null | [
"@param",
"string",
"$field",
"@param",
"string",
"$locale"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/Model/Gedmo/AbstractPersonalTranslatable.php#L53-L60 |
sonata-project/SonataTranslationBundle | src/SonataTranslationBundle.php | SonataTranslationBundle.build | public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new GlobalVariablesCompilerPass());
$container->addCompilerPass(new AdminExtensionCompilerPass());
} | php | public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new GlobalVariablesCompilerPass());
$container->addCompilerPass(new AdminExtensionCompilerPass());
} | [
"public",
"function",
"build",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"parent",
"::",
"build",
"(",
"$",
"container",
")",
";",
"$",
"container",
"->",
"addCompilerPass",
"(",
"new",
"GlobalVariablesCompilerPass",
"(",
")",
")",
";",
"$",
"cont... | {@inheritdoc} | [
"{"
] | train | https://github.com/sonata-project/SonataTranslationBundle/blob/403785b450f0e7ff16711a6392eabde774ebfcd1/src/SonataTranslationBundle.php#L29-L35 |
mekras/php-speller | src/Ispell/Ispell.php | Ispell.getSupportedLanguages | public function getSupportedLanguages(): array
{
if (null === $this->supportedLanguages) {
$this->supportedLanguages = [];
$files = new \DirectoryIterator($this->getDictionaryFolder());
foreach ($files as $file) {
if ($file->getExtension() === 'aff') {
$this->supportedLanguages[] = $file->getBasename('.aff');
}
}
sort($this->supportedLanguages);
}
return $this->supportedLanguages;
} | php | public function getSupportedLanguages(): array
{
if (null === $this->supportedLanguages) {
$this->supportedLanguages = [];
$files = new \DirectoryIterator($this->getDictionaryFolder());
foreach ($files as $file) {
if ($file->getExtension() === 'aff') {
$this->supportedLanguages[] = $file->getBasename('.aff');
}
}
sort($this->supportedLanguages);
}
return $this->supportedLanguages;
} | [
"public",
"function",
"getSupportedLanguages",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"supportedLanguages",
")",
"{",
"$",
"this",
"->",
"supportedLanguages",
"=",
"[",
"]",
";",
"$",
"files",
"=",
"new",
"\\",
"Directo... | Return list of supported languages.
@return string[]
@throws EnvironmentException
@throws LogicException
@throws RuntimeException
@since 1.6 | [
"Return",
"list",
"of",
"supported",
"languages",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Ispell/Ispell.php#L80-L94 |
mekras/php-speller | src/Ispell/Ispell.php | Ispell.getLanguageMapper | protected function getLanguageMapper(): LanguageMapper
{
if (null === $this->languageMapper) {
$this->languageMapper = new LanguageMapper();
}
return $this->languageMapper;
} | php | protected function getLanguageMapper(): LanguageMapper
{
if (null === $this->languageMapper) {
$this->languageMapper = new LanguageMapper();
}
return $this->languageMapper;
} | [
"protected",
"function",
"getLanguageMapper",
"(",
")",
":",
"LanguageMapper",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"languageMapper",
")",
"{",
"$",
"this",
"->",
"languageMapper",
"=",
"new",
"LanguageMapper",
"(",
")",
";",
"}",
"return",
"$... | Return language mapper.
@return LanguageMapper
@since 1.6 | [
"Return",
"language",
"mapper",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Ispell/Ispell.php#L115-L122 |
mekras/php-speller | src/Ispell/Ispell.php | Ispell.createArguments | protected function createArguments(EncodingAwareSource $source, array $languages): array
{
$args = [
'-a', // Machine readable output
];
if (count($languages) > 0) {
$language = $languages[0];
$dictionaries = $this->getLanguageMapper()
->map([$language], $this->getSupportedLanguages());
if (count($dictionaries) > 0) {
$args[] = '-d ' . $dictionaries[0];
}
}
return $args;
} | php | protected function createArguments(EncodingAwareSource $source, array $languages): array
{
$args = [
'-a', // Machine readable output
];
if (count($languages) > 0) {
$language = $languages[0];
$dictionaries = $this->getLanguageMapper()
->map([$language], $this->getSupportedLanguages());
if (count($dictionaries) > 0) {
$args[] = '-d ' . $dictionaries[0];
}
}
return $args;
} | [
"protected",
"function",
"createArguments",
"(",
"EncodingAwareSource",
"$",
"source",
",",
"array",
"$",
"languages",
")",
":",
"array",
"{",
"$",
"args",
"=",
"[",
"'-a'",
",",
"// Machine readable output",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"language... | Create arguments for external speller.
@param EncodingAwareSource $source Text source to check.
@param array $languages List of languages used in text (IETF language tag).
@return string[]
@since 1.6
@SuppressWarnings(PMD.UnusedFormalParameter) | [
"Create",
"arguments",
"for",
"external",
"speller",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Ispell/Ispell.php#L136-L152 |
mekras/php-speller | src/Ispell/Ispell.php | Ispell.parseOutput | protected function parseOutput(string $output): array
{
$lines = explode(PHP_EOL, $output);
$issues = [];
$lineNo = 1;
foreach ($lines as $line) {
$line = trim($line);
if ('' === $line) {
// Go to the next line
$lineNo++;
continue;
}
switch ($line[0]) {
case '#':
$parts = explode(' ', $line);
$word = $parts[1];
$issue = new Issue($word);
$issue->line = $lineNo;
$issue->offset = trim($parts[2]);
$issues [] = $issue;
break;
case '&':
$parts = explode(':', $line);
$parts[0] = explode(' ', $parts[0]);
$parts[1] = explode(', ', trim($parts[1]));
$word = $parts[0][1];
$issue = new Issue($word);
$issue->line = $lineNo;
$issue->offset = trim($parts[0][3]);
$issue->suggestions = $parts[1];
$issues [] = $issue;
break;
}
}
return $issues;
} | php | protected function parseOutput(string $output): array
{
$lines = explode(PHP_EOL, $output);
$issues = [];
$lineNo = 1;
foreach ($lines as $line) {
$line = trim($line);
if ('' === $line) {
// Go to the next line
$lineNo++;
continue;
}
switch ($line[0]) {
case '#':
$parts = explode(' ', $line);
$word = $parts[1];
$issue = new Issue($word);
$issue->line = $lineNo;
$issue->offset = trim($parts[2]);
$issues [] = $issue;
break;
case '&':
$parts = explode(':', $line);
$parts[0] = explode(' ', $parts[0]);
$parts[1] = explode(', ', trim($parts[1]));
$word = $parts[0][1];
$issue = new Issue($word);
$issue->line = $lineNo;
$issue->offset = trim($parts[0][3]);
$issue->suggestions = $parts[1];
$issues [] = $issue;
break;
}
}
return $issues;
} | [
"protected",
"function",
"parseOutput",
"(",
"string",
"$",
"output",
")",
":",
"array",
"{",
"$",
"lines",
"=",
"explode",
"(",
"PHP_EOL",
",",
"$",
"output",
")",
";",
"$",
"issues",
"=",
"[",
"]",
";",
"$",
"lineNo",
"=",
"1",
";",
"foreach",
"(... | Parse ispell output.
@param string $output
@return Issue[]
@since 1.6 | [
"Parse",
"ispell",
"output",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Ispell/Ispell.php#L163-L199 |
mekras/php-speller | src/Ispell/Ispell.php | Ispell.getDictionaryFolder | private function getDictionaryFolder(): string
{
if (null === $this->bundledDictFolder) {
$binary = $this->getBinary();
if (realpath($binary) === false) {
$process = new Process(['which ' . $this->getBinary()]);
$process->run();
if (!$process->isSuccessful()) {
throw new EnvironmentException(
sprintf('Can not find full path of ispell: %s', $process->getErrorOutput())
);
}
$binary = trim($process->getOutput());
}
$this->bundledDictFolder = dirname($binary, 2) . '/lib/ispell';
}
return $this->bundledDictFolder;
} | php | private function getDictionaryFolder(): string
{
if (null === $this->bundledDictFolder) {
$binary = $this->getBinary();
if (realpath($binary) === false) {
$process = new Process(['which ' . $this->getBinary()]);
$process->run();
if (!$process->isSuccessful()) {
throw new EnvironmentException(
sprintf('Can not find full path of ispell: %s', $process->getErrorOutput())
);
}
$binary = trim($process->getOutput());
}
$this->bundledDictFolder = dirname($binary, 2) . '/lib/ispell';
}
return $this->bundledDictFolder;
} | [
"private",
"function",
"getDictionaryFolder",
"(",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"bundledDictFolder",
")",
"{",
"$",
"binary",
"=",
"$",
"this",
"->",
"getBinary",
"(",
")",
";",
"if",
"(",
"realpath",
"(",
"$",
... | Return path to folder with bundled ispell dictionaries.
@return string
@throws EnvironmentException
@throws LogicException
@throws RuntimeException | [
"Return",
"path",
"to",
"folder",
"with",
"bundled",
"ispell",
"dictionaries",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Ispell/Ispell.php#L210-L228 |
mekras/php-speller | src/Source/HtmlSource.php | HtmlSource.createDomDocument | protected function createDomDocument($html): \DOMDocument
{
$document = new \DOMDocument('1.0');
$previousValue = libxml_use_internal_errors(true);
libxml_clear_errors();
$document->loadHTML($html);
/** @var \LibXMLError[] $errors */
$errors = libxml_get_errors();
libxml_clear_errors();
libxml_use_internal_errors($previousValue);
foreach ($errors as $error) {
if (LIBXML_ERR_ERROR === $error->level || LIBXML_ERR_FATAL === $error->level) {
throw new SourceException(
sprintf('%s at %d:%d', trim($error->message), $error->line, $error->column),
$error->code
);
}
}
return $document;
} | php | protected function createDomDocument($html): \DOMDocument
{
$document = new \DOMDocument('1.0');
$previousValue = libxml_use_internal_errors(true);
libxml_clear_errors();
$document->loadHTML($html);
/** @var \LibXMLError[] $errors */
$errors = libxml_get_errors();
libxml_clear_errors();
libxml_use_internal_errors($previousValue);
foreach ($errors as $error) {
if (LIBXML_ERR_ERROR === $error->level || LIBXML_ERR_FATAL === $error->level) {
throw new SourceException(
sprintf('%s at %d:%d', trim($error->message), $error->line, $error->column),
$error->code
);
}
}
return $document;
} | [
"protected",
"function",
"createDomDocument",
"(",
"$",
"html",
")",
":",
"\\",
"DOMDocument",
"{",
"$",
"document",
"=",
"new",
"\\",
"DOMDocument",
"(",
"'1.0'",
")",
";",
"$",
"previousValue",
"=",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"lib... | Create DOMDocument from HTML string.
@param string $html
@return \DOMDocument
@throws SourceException On invalid HTML.
@since 1.7 | [
"Create",
"DOMDocument",
"from",
"HTML",
"string",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Source/HtmlSource.php#L99-L120 |
mekras/php-speller | src/Aspell/Aspell.php | Aspell.getSupportedLanguages | public function getSupportedLanguages(): array
{
if (null === $this->supportedLanguages) {
$process = $this->createProcess('dump dicts');
$process->run();
if (!$process->isSuccessful()) {
throw new ExternalProgramFailedException(
$process->getCommandLine(),
$process->getErrorOutput(),
$process->getExitCode()
);
}
$languages = [];
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
$name = trim($line);
if (strpos($name, '-variant') !== false) {
// Skip variants
continue;
}
$languages[$name] = true;
}
$languages = array_keys($languages);
sort($languages);
$this->supportedLanguages = $languages;
}
return $this->supportedLanguages;
} | php | public function getSupportedLanguages(): array
{
if (null === $this->supportedLanguages) {
$process = $this->createProcess('dump dicts');
$process->run();
if (!$process->isSuccessful()) {
throw new ExternalProgramFailedException(
$process->getCommandLine(),
$process->getErrorOutput(),
$process->getExitCode()
);
}
$languages = [];
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
$name = trim($line);
if (strpos($name, '-variant') !== false) {
// Skip variants
continue;
}
$languages[$name] = true;
}
$languages = array_keys($languages);
sort($languages);
$this->supportedLanguages = $languages;
}
return $this->supportedLanguages;
} | [
"public",
"function",
"getSupportedLanguages",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"supportedLanguages",
")",
"{",
"$",
"process",
"=",
"$",
"this",
"->",
"createProcess",
"(",
"'dump dicts'",
")",
";",
"$",
"process",... | Return list of supported languages.
@return string[]
@throws ExternalProgramFailedException
@throws InvalidArgumentException
@throws LogicException
@throws RuntimeException
@since 1.6 | [
"Return",
"list",
"of",
"supported",
"languages",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Aspell/Aspell.php#L64-L95 |
mekras/php-speller | src/Aspell/Aspell.php | Aspell.createArguments | protected function createArguments(EncodingAwareSource $source, array $languages): array
{
$args = [
// Input encoding
'--encoding=' . ($source instanceof EncodingAwareSource ? $source->getEncoding(
) : 'UTF-8'),
'-a' // ispell compatible output
];
if (count($languages) > 0) {
$args[] = '--lang=' . $languages[0];
}
if ($this->personalDictionary !== null) {
$args[] = '--personal=' . $this->personalDictionary->getPath();
}
return $args;
} | php | protected function createArguments(EncodingAwareSource $source, array $languages): array
{
$args = [
// Input encoding
'--encoding=' . ($source instanceof EncodingAwareSource ? $source->getEncoding(
) : 'UTF-8'),
'-a' // ispell compatible output
];
if (count($languages) > 0) {
$args[] = '--lang=' . $languages[0];
}
if ($this->personalDictionary !== null) {
$args[] = '--personal=' . $this->personalDictionary->getPath();
}
return $args;
} | [
"protected",
"function",
"createArguments",
"(",
"EncodingAwareSource",
"$",
"source",
",",
"array",
"$",
"languages",
")",
":",
"array",
"{",
"$",
"args",
"=",
"[",
"// Input encoding",
"'--encoding='",
".",
"(",
"$",
"source",
"instanceof",
"EncodingAwareSource"... | Create arguments for external speller.
@param EncodingAwareSource $source Text source to check.
@param array $languages List of languages used in text (IETF language tag).
@return string[]
@since 1.6 | [
"Create",
"arguments",
"for",
"external",
"speller",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Aspell/Aspell.php#L115-L133 |
mekras/php-speller | src/Source/FileSource.php | FileSource.getAsString | public function getAsString(): string
{
if ('php://stdin' !== $this->filename) {
if (!file_exists($this->filename)) {
throw new SourceException(sprintf('File "%s" not exists', $this->filename));
}
if (!is_readable($this->filename)) {
throw new SourceException(sprintf('File "%s" is not readable', $this->filename));
}
}
return file_get_contents($this->filename);
} | php | public function getAsString(): string
{
if ('php://stdin' !== $this->filename) {
if (!file_exists($this->filename)) {
throw new SourceException(sprintf('File "%s" not exists', $this->filename));
}
if (!is_readable($this->filename)) {
throw new SourceException(sprintf('File "%s" is not readable', $this->filename));
}
}
return file_get_contents($this->filename);
} | [
"public",
"function",
"getAsString",
"(",
")",
":",
"string",
"{",
"if",
"(",
"'php://stdin'",
"!==",
"$",
"this",
"->",
"filename",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"filename",
")",
")",
"{",
"throw",
"new",
"SourceExce... | Return text as one string
@return string
@throws SourceException Fail to read from text source.
@since 1.6 Throws {@see SourceException}.
@since 1.2 | [
"Return",
"text",
"as",
"one",
"string"
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Source/FileSource.php#L63-L76 |
mekras/php-speller | src/Hunspell/Hunspell.php | Hunspell.getSupportedLanguages | public function getSupportedLanguages(): array
{
if (null === $this->supportedLanguages) {
$process = $this->createProcess('-D');
$process->run();
if (!$process->isSuccessful()) {
throw new ExternalProgramFailedException(
$process->getCommandLine(),
$process->getErrorOutput(),
$process->getExitCode()
);
}
$languages = [];
$output = explode(PHP_EOL, $process->getErrorOutput());
$is_win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
foreach ($output as $line) {
$line = trim($line);
if ('' === $line // Skip empty lines
|| substr($line, -1) === ':' // Skip headers
|| strpos($line, $is_win ? ';' : ':') !== false // Skip search path
) {
continue;
}
$name = basename($line);
if (strpos($name, 'hyph_') === 0) {
// Skip MySpell hyphen files
continue;
}
$name = preg_replace('/\.(aff|dic)$/', '', $name);
$languages[$name] = true;
}
$languages = array_keys($languages);
sort($languages);
$this->supportedLanguages = $languages;
}
return $this->supportedLanguages;
} | php | public function getSupportedLanguages(): array
{
if (null === $this->supportedLanguages) {
$process = $this->createProcess('-D');
$process->run();
if (!$process->isSuccessful()) {
throw new ExternalProgramFailedException(
$process->getCommandLine(),
$process->getErrorOutput(),
$process->getExitCode()
);
}
$languages = [];
$output = explode(PHP_EOL, $process->getErrorOutput());
$is_win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
foreach ($output as $line) {
$line = trim($line);
if ('' === $line // Skip empty lines
|| substr($line, -1) === ':' // Skip headers
|| strpos($line, $is_win ? ';' : ':') !== false // Skip search path
) {
continue;
}
$name = basename($line);
if (strpos($name, 'hyph_') === 0) {
// Skip MySpell hyphen files
continue;
}
$name = preg_replace('/\.(aff|dic)$/', '', $name);
$languages[$name] = true;
}
$languages = array_keys($languages);
sort($languages);
$this->supportedLanguages = $languages;
}
return $this->supportedLanguages;
} | [
"public",
"function",
"getSupportedLanguages",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"supportedLanguages",
")",
"{",
"$",
"process",
"=",
"$",
"this",
"->",
"createProcess",
"(",
"'-D'",
")",
";",
"$",
"process",
"->",... | Return list of supported languages.
@return string[]
@throws ExternalProgramFailedException
@throws InvalidArgumentException
@throws LogicException
@throws RuntimeException
@since 1.0 | [
"Return",
"list",
"of",
"supported",
"languages",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Hunspell/Hunspell.php#L73-L113 |
mekras/php-speller | src/Hunspell/Hunspell.php | Hunspell.setDictionaryPath | public function setDictionaryPath(string $path): void
{
$this->customDictPath = $path;
$this->supportedLanguages = null; // Clear cache because $path can contain new languages
} | php | public function setDictionaryPath(string $path): void
{
$this->customDictPath = $path;
$this->supportedLanguages = null; // Clear cache because $path can contain new languages
} | [
"public",
"function",
"setDictionaryPath",
"(",
"string",
"$",
"path",
")",
":",
"void",
"{",
"$",
"this",
"->",
"customDictPath",
"=",
"$",
"path",
";",
"$",
"this",
"->",
"supportedLanguages",
"=",
"null",
";",
"// Clear cache because $path can contain new langu... | Set additional dictionaries path.
Set path using DICPATH environment variable. See hunspell(1) man page for details.
@param string $path Path to dictionaries folder (e. g. "/some/path")
@link setCustomDictionaries()
@since 1.0 | [
"Set",
"additional",
"dictionaries",
"path",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Hunspell/Hunspell.php#L125-L129 |
mekras/php-speller | src/Hunspell/Hunspell.php | Hunspell.createArguments | protected function createArguments(EncodingAwareSource $source, array $languages): array
{
$args = [
// Input encoding
'-i ' . ($source instanceof EncodingAwareSource ? $source->getEncoding() : 'UTF-8'),
'-a' // Machine readable output
];
if (count($languages)) {
$dictionaries = $this->getLanguageMapper()
->map($languages, $this->getSupportedLanguages());
$dictionaries = array_merge($dictionaries, $this->customDictionaries);
if (count($dictionaries)) {
$args[] = '-d ' . implode(',', $dictionaries);
}
}
return $args;
} | php | protected function createArguments(EncodingAwareSource $source, array $languages): array
{
$args = [
// Input encoding
'-i ' . ($source instanceof EncodingAwareSource ? $source->getEncoding() : 'UTF-8'),
'-a' // Machine readable output
];
if (count($languages)) {
$dictionaries = $this->getLanguageMapper()
->map($languages, $this->getSupportedLanguages());
$dictionaries = array_merge($dictionaries, $this->customDictionaries);
if (count($dictionaries)) {
$args[] = '-d ' . implode(',', $dictionaries);
}
}
return $args;
} | [
"protected",
"function",
"createArguments",
"(",
"EncodingAwareSource",
"$",
"source",
",",
"array",
"$",
"languages",
")",
":",
"array",
"{",
"$",
"args",
"=",
"[",
"// Input encoding",
"'-i '",
".",
"(",
"$",
"source",
"instanceof",
"EncodingAwareSource",
"?",... | Create arguments for external speller.
@param EncodingAwareSource $source Text source to check.
@param array $languages List of languages used in text (IETF language tag).
@return string[]
@since 1.6 | [
"Create",
"arguments",
"for",
"external",
"speller",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Hunspell/Hunspell.php#L154-L172 |
mekras/php-speller | src/Hunspell/Hunspell.php | Hunspell.createEnvVars | protected function createEnvVars(EncodingAwareSource $source, array $languages): array
{
$vars = [];
if ($this->customDictPath) {
$vars['DICPATH'] = $this->customDictPath;
}
return $vars;
} | php | protected function createEnvVars(EncodingAwareSource $source, array $languages): array
{
$vars = [];
if ($this->customDictPath) {
$vars['DICPATH'] = $this->customDictPath;
}
return $vars;
} | [
"protected",
"function",
"createEnvVars",
"(",
"EncodingAwareSource",
"$",
"source",
",",
"array",
"$",
"languages",
")",
":",
"array",
"{",
"$",
"vars",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"customDictPath",
")",
"{",
"$",
"vars",
"[",
"'... | Create environment variables for external speller.
@param EncodingAwareSource $source Text source to check.
@param array $languages List of languages used in text (IETF language tag).
@return string[]
@since 1.6
@SuppressWarnings(PMD.UnusedFormalParameter) | [
"Create",
"environment",
"variables",
"for",
"external",
"speller",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Hunspell/Hunspell.php#L186-L194 |
mekras/php-speller | src/ExternalSpeller.php | ExternalSpeller.checkText | public function checkText(EncodingAwareSource $source, array $languages): array
{
$process = $this->createProcess($this->createArguments($source, $languages));
$process->setEnv($this->createEnvVars($source, $languages));
$process->setInput($source->getAsString());
try {
$process->run();
} catch (RuntimeException $e) {
throw new ExternalProgramFailedException(
$process->getCommandLine(),
$e->getMessage(),
0,
$e
);
}
try {
$exitCode = $process->getExitCode();
} catch (RuntimeException $e) {
throw new EnvironmentException($e->getMessage(), $e->getCode(), $e);
}
if (0 !== $exitCode) {
throw new ExternalProgramFailedException(
$process->getCommandLine(),
$process->getErrorOutput() ?: $process->getOutput(),
$exitCode
);
}
$output = $process->getOutput();
if ($source instanceof EncodingAwareSource
&& strcasecmp($source->getEncoding(), 'UTF-8') !== 0
) {
$output = iconv($source->getEncoding(), 'UTF-8', $output);
}
return $this->parseOutput($output);
} | php | public function checkText(EncodingAwareSource $source, array $languages): array
{
$process = $this->createProcess($this->createArguments($source, $languages));
$process->setEnv($this->createEnvVars($source, $languages));
$process->setInput($source->getAsString());
try {
$process->run();
} catch (RuntimeException $e) {
throw new ExternalProgramFailedException(
$process->getCommandLine(),
$e->getMessage(),
0,
$e
);
}
try {
$exitCode = $process->getExitCode();
} catch (RuntimeException $e) {
throw new EnvironmentException($e->getMessage(), $e->getCode(), $e);
}
if (0 !== $exitCode) {
throw new ExternalProgramFailedException(
$process->getCommandLine(),
$process->getErrorOutput() ?: $process->getOutput(),
$exitCode
);
}
$output = $process->getOutput();
if ($source instanceof EncodingAwareSource
&& strcasecmp($source->getEncoding(), 'UTF-8') !== 0
) {
$output = iconv($source->getEncoding(), 'UTF-8', $output);
}
return $this->parseOutput($output);
} | [
"public",
"function",
"checkText",
"(",
"EncodingAwareSource",
"$",
"source",
",",
"array",
"$",
"languages",
")",
":",
"array",
"{",
"$",
"process",
"=",
"$",
"this",
"->",
"createProcess",
"(",
"$",
"this",
"->",
"createArguments",
"(",
"$",
"source",
",... | Check text.
Check given text and return an array of spelling issues.
@param EncodingAwareSource $source Text source to check.
@param array $languages List of languages used in text (IETF language tag).
@return Issue[]
@see http://tools.ietf.org/html/bcp47
@since 1.6 | [
"Check",
"text",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/ExternalSpeller.php#L74-L115 |
mekras/php-speller | src/ExternalSpeller.php | ExternalSpeller.composeCommand | protected function composeCommand($args): string
{
$command = $this->getBinary();
if (\is_array($args)) {
$args = implode(' ', $args);
}
// Only append args if we have some
$command .= $args !== '' ? ' ' . $args : '';
return $command;
} | php | protected function composeCommand($args): string
{
$command = $this->getBinary();
if (\is_array($args)) {
$args = implode(' ', $args);
}
// Only append args if we have some
$command .= $args !== '' ? ' ' . $args : '';
return $command;
} | [
"protected",
"function",
"composeCommand",
"(",
"$",
"args",
")",
":",
"string",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"getBinary",
"(",
")",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"args",
")",
")",
"{",
"$",
"args",
"=",
"implode",
"("... | Compose shell command line
@param string|string[]|null $args Ispell arguments.
@return string
@since 1.6 | [
"Compose",
"shell",
"command",
"line"
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/ExternalSpeller.php#L139-L151 |
mekras/php-speller | src/ExternalSpeller.php | ExternalSpeller.createProcess | protected function createProcess($args = null): Process
{
$command = $this->composeCommand($args);
try {
$process = $this->composeProcess($command);
} catch (RuntimeException $e) {
throw new ExternalProgramFailedException($command, $e->getMessage(), 0, $e);
}
return $process;
} | php | protected function createProcess($args = null): Process
{
$command = $this->composeCommand($args);
try {
$process = $this->composeProcess($command);
} catch (RuntimeException $e) {
throw new ExternalProgramFailedException($command, $e->getMessage(), 0, $e);
}
return $process;
} | [
"protected",
"function",
"createProcess",
"(",
"$",
"args",
"=",
"null",
")",
":",
"Process",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"composeCommand",
"(",
"$",
"args",
")",
";",
"try",
"{",
"$",
"process",
"=",
"$",
"this",
"->",
"composeProcess... | Create new instance of external program.
@param string|string[]|null $args Command arguments.
@return Process
@throws ExternalProgramFailedException
@throws InvalidArgumentException
@since 1.6 | [
"Create",
"new",
"instance",
"of",
"external",
"program",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/ExternalSpeller.php#L222-L233 |
mekras/php-speller | src/ExternalSpeller.php | ExternalSpeller.composeProcess | private function composeProcess(string $command): Process
{
if ($this->process === null) {
$this->process = new Process([$command]);
}
$this->process->inheritEnvironmentVariables();
$this->process->setTimeout($this->timeout);
$this->process->setCommandLine($command);
return $this->process;
} | php | private function composeProcess(string $command): Process
{
if ($this->process === null) {
$this->process = new Process([$command]);
}
$this->process->inheritEnvironmentVariables();
$this->process->setTimeout($this->timeout);
$this->process->setCommandLine($command);
return $this->process;
} | [
"private",
"function",
"composeProcess",
"(",
"string",
"$",
"command",
")",
":",
"Process",
"{",
"if",
"(",
"$",
"this",
"->",
"process",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"process",
"=",
"new",
"Process",
"(",
"[",
"$",
"command",
"]",
")... | Compose a process with given command. If no process is given in current instance a new one will be created.
@param string $command
@return Process
@since 2.0 | [
"Compose",
"a",
"process",
"with",
"given",
"command",
".",
"If",
"no",
"process",
"is",
"given",
"in",
"current",
"instance",
"a",
"new",
"one",
"will",
"be",
"created",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/ExternalSpeller.php#L244-L255 |
mekras/php-speller | src/Source/IconvSource.php | IconvSource.getAsString | public function getAsString(): string
{
$text = iconv(
$this->source->getEncoding(),
$this->getEncoding(),
$this->source->getAsString()
);
if (false === $text) {
throw new SourceException('iconv failed to convert source text');
}
return $text;
} | php | public function getAsString(): string
{
$text = iconv(
$this->source->getEncoding(),
$this->getEncoding(),
$this->source->getAsString()
);
if (false === $text) {
throw new SourceException('iconv failed to convert source text');
}
return $text;
} | [
"public",
"function",
"getAsString",
"(",
")",
":",
"string",
"{",
"$",
"text",
"=",
"iconv",
"(",
"$",
"this",
"->",
"source",
"->",
"getEncoding",
"(",
")",
",",
"$",
"this",
"->",
"getEncoding",
"(",
")",
",",
"$",
"this",
"->",
"source",
"->",
... | Return text in the specified encoding.
@return string
@throws SourceException
@since 1.6 | [
"Return",
"text",
"in",
"the",
"specified",
"encoding",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Source/IconvSource.php#L52-L64 |
mekras/php-speller | src/Source/Filter/HtmlFilter.php | HtmlFilter.filter | public function filter(string $string): string
{
$result = '';
$string = $this->filterEntities($string);
$string = $this->filterMetaTags($string);
// Current/last tag name
$tagName = null;
// Current/last attribute name
$attrName = null;
// Current context
$context = self::CTX_TAG_CONTENT;
// Expected context
$expecting = null;
// By default tag content treated as text.
$ignoreTagContent = false;
// By default attribute values NOT treated as text.
$ignoreAttrValue = true;
$length = mb_strlen($string);
for ($i = 0; $i < $length; $i++) {
$char = mb_substr($string, $i, 1);
switch (true) {
case '<' === $char:
$context = self::CTX_TAG_NAME;
$tagName = null;
$char = ' ';
break;
case '>' === $char:
if ($this->isIgnoredTag($tagName)) {
$ignoreTagContent = true;
} elseif ('/' === $tagName[0]) {
$ignoreTagContent = false; // Restore to default state.
}
$context = self::CTX_TAG_CONTENT;
$expecting = null;
$char = ' ';
break;
case ' ' === $char:
case "\n" === $char:
case "\t" === $char:
switch ($context) {
case self::CTX_TAG_NAME:
$context = self::CTX_TAG_ATTRS;
break;
case self::CTX_ATTR_NAME:
$context = self::CTX_TAG_ATTRS;
break;
}
break;
case '=' === $char
&& (self::CTX_ATTR_NAME === $context || self::CTX_TAG_ATTRS === $context):
$expecting = self::CTX_ATTR_VALUE;
$char = ' ';
break;
case '"' === $char:
case "'" === $char:
switch (true) {
case self::CTX_ATTR_VALUE === $expecting:
$context = self::CTX_ATTR_VALUE;
$ignoreAttrValue
= !in_array(strtolower($attrName), self::$textAttrs, true);
$expecting = null;
$char = ' ';
break;
case self::CTX_ATTR_VALUE === $context:
$context = self::CTX_TAG_ATTRS;
$char = ' ';
break;
}
break;
default:
switch ($context) {
case self::CTX_TAG_NAME:
$tagName .= $char;
$char = ' ';
break;
/** @noinspection PhpMissingBreakStatementInspection */
case self::CTX_TAG_ATTRS:
$context = self::CTX_ATTR_NAME;
$attrName = null;
// no break needed
case self::CTX_ATTR_NAME:
$attrName .= $char;
$char = ' ';
break;
case self::CTX_ATTR_VALUE:
if ($ignoreAttrValue) {
$char = ' ';
}
break;
case self::CTX_TAG_CONTENT:
if ($ignoreTagContent) {
$char = ' ';
}
break;
}
}
$result .= $char;
}
return $result;
} | php | public function filter(string $string): string
{
$result = '';
$string = $this->filterEntities($string);
$string = $this->filterMetaTags($string);
// Current/last tag name
$tagName = null;
// Current/last attribute name
$attrName = null;
// Current context
$context = self::CTX_TAG_CONTENT;
// Expected context
$expecting = null;
// By default tag content treated as text.
$ignoreTagContent = false;
// By default attribute values NOT treated as text.
$ignoreAttrValue = true;
$length = mb_strlen($string);
for ($i = 0; $i < $length; $i++) {
$char = mb_substr($string, $i, 1);
switch (true) {
case '<' === $char:
$context = self::CTX_TAG_NAME;
$tagName = null;
$char = ' ';
break;
case '>' === $char:
if ($this->isIgnoredTag($tagName)) {
$ignoreTagContent = true;
} elseif ('/' === $tagName[0]) {
$ignoreTagContent = false; // Restore to default state.
}
$context = self::CTX_TAG_CONTENT;
$expecting = null;
$char = ' ';
break;
case ' ' === $char:
case "\n" === $char:
case "\t" === $char:
switch ($context) {
case self::CTX_TAG_NAME:
$context = self::CTX_TAG_ATTRS;
break;
case self::CTX_ATTR_NAME:
$context = self::CTX_TAG_ATTRS;
break;
}
break;
case '=' === $char
&& (self::CTX_ATTR_NAME === $context || self::CTX_TAG_ATTRS === $context):
$expecting = self::CTX_ATTR_VALUE;
$char = ' ';
break;
case '"' === $char:
case "'" === $char:
switch (true) {
case self::CTX_ATTR_VALUE === $expecting:
$context = self::CTX_ATTR_VALUE;
$ignoreAttrValue
= !in_array(strtolower($attrName), self::$textAttrs, true);
$expecting = null;
$char = ' ';
break;
case self::CTX_ATTR_VALUE === $context:
$context = self::CTX_TAG_ATTRS;
$char = ' ';
break;
}
break;
default:
switch ($context) {
case self::CTX_TAG_NAME:
$tagName .= $char;
$char = ' ';
break;
/** @noinspection PhpMissingBreakStatementInspection */
case self::CTX_TAG_ATTRS:
$context = self::CTX_ATTR_NAME;
$attrName = null;
// no break needed
case self::CTX_ATTR_NAME:
$attrName .= $char;
$char = ' ';
break;
case self::CTX_ATTR_VALUE:
if ($ignoreAttrValue) {
$char = ' ';
}
break;
case self::CTX_TAG_CONTENT:
if ($ignoreTagContent) {
$char = ' ';
}
break;
}
}
$result .= $char;
}
return $result;
} | [
"public",
"function",
"filter",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"string",
"=",
"$",
"this",
"->",
"filterEntities",
"(",
"$",
"string",
")",
";",
"$",
"string",
"=",
"$",
"this",
"->",
"fil... | Filter string.
@param string $string String to be filtered.
@return string Filtered string.
@since 1.3 | [
"Filter",
"string",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Source/Filter/HtmlFilter.php#L88-L202 |
mekras/php-speller | src/Source/Filter/HtmlFilter.php | HtmlFilter.filterEntities | private function filterEntities(string $string): string
{
return preg_replace_callback(
'/&\w+;/',
function ($match) {
return str_repeat(' ', strlen($match[0]));
},
$string
);
} | php | private function filterEntities(string $string): string
{
return preg_replace_callback(
'/&\w+;/',
function ($match) {
return str_repeat(' ', strlen($match[0]));
},
$string
);
} | [
"private",
"function",
"filterEntities",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"return",
"preg_replace_callback",
"(",
"'/&\\w+;/'",
",",
"function",
"(",
"$",
"match",
")",
"{",
"return",
"str_repeat",
"(",
"' '",
",",
"strlen",
"(",
"$",
... | Replace HTML entities.
@param string $string
@return string | [
"Replace",
"HTML",
"entities",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Source/Filter/HtmlFilter.php#L211-L220 |
mekras/php-speller | src/Source/Filter/HtmlFilter.php | HtmlFilter.filterMetaTags | private function filterMetaTags(string $string): string
{
return preg_replace_callback(
'/<meta[^>]+(http-equiv\s*=|name\s*=\s*["\']?([^>"\']+))[^>]*>/i',
function ($match) {
if (count($match) < 3
|| !in_array(strtolower($match[2]), self::$textMetaTags, true)
) {
return str_repeat(' ', strlen($match[0]));
}
return $match[0];
},
$string
);
} | php | private function filterMetaTags(string $string): string
{
return preg_replace_callback(
'/<meta[^>]+(http-equiv\s*=|name\s*=\s*["\']?([^>"\']+))[^>]*>/i',
function ($match) {
if (count($match) < 3
|| !in_array(strtolower($match[2]), self::$textMetaTags, true)
) {
return str_repeat(' ', strlen($match[0]));
}
return $match[0];
},
$string
);
} | [
"private",
"function",
"filterMetaTags",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"return",
"preg_replace_callback",
"(",
"'/<meta[^>]+(http-equiv\\s*=|name\\s*=\\s*[\"\\']?([^>\"\\']+))[^>]*>/i'",
",",
"function",
"(",
"$",
"match",
")",
"{",
"if",
"(",
... | Replace non-text meta tags.
@param string $string
@return string | [
"Replace",
"non",
"-",
"text",
"meta",
"tags",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Source/Filter/HtmlFilter.php#L229-L244 |
mekras/php-speller | src/Source/Filter/HtmlFilter.php | HtmlFilter.isIgnoredTag | private function isIgnoredTag(?string $name): bool
{
foreach (self::$ignoreTags as $tag) {
if (strcasecmp($tag, $name) === 0) {
return true;
}
}
return false;
} | php | private function isIgnoredTag(?string $name): bool
{
foreach (self::$ignoreTags as $tag) {
if (strcasecmp($tag, $name) === 0) {
return true;
}
}
return false;
} | [
"private",
"function",
"isIgnoredTag",
"(",
"?",
"string",
"$",
"name",
")",
":",
"bool",
"{",
"foreach",
"(",
"self",
"::",
"$",
"ignoreTags",
"as",
"$",
"tag",
")",
"{",
"if",
"(",
"strcasecmp",
"(",
"$",
"tag",
",",
"$",
"name",
")",
"===",
"0",... | Return true if $name is in the list of ignored tags.
@param null|string $name Tag name.
@return bool | [
"Return",
"true",
"if",
"$name",
"is",
"in",
"the",
"list",
"of",
"ignored",
"tags",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Source/Filter/HtmlFilter.php#L253-L262 |
mekras/php-speller | src/Helper/LanguageMapper.php | LanguageMapper.map | public function map(array $requested, array $supported): array
{
$index = [];
foreach ($supported as $tag) {
$key = strtolower(preg_replace('/_-\./', '', $tag));
$index[$key] = $tag;
}
$result = [];
foreach ($requested as $source) {
if (array_key_exists($source, $this->preferred)) {
$preferred = $this->preferred[$source];
foreach ($preferred as $tag) {
if (in_array($tag, $supported, true)) {
$result[] = $tag;
continue 2;
}
}
}
if (in_array($source, $supported, true)) {
$result[] = $source;
continue;
}
$tag = strtolower(preg_replace('/_-\./', '', $source));
foreach ($index as $key => $target) {
if (strpos($key, $tag) === 0) {
$result[] = $target;
break;
}
}
}
return $result;
} | php | public function map(array $requested, array $supported): array
{
$index = [];
foreach ($supported as $tag) {
$key = strtolower(preg_replace('/_-\./', '', $tag));
$index[$key] = $tag;
}
$result = [];
foreach ($requested as $source) {
if (array_key_exists($source, $this->preferred)) {
$preferred = $this->preferred[$source];
foreach ($preferred as $tag) {
if (in_array($tag, $supported, true)) {
$result[] = $tag;
continue 2;
}
}
}
if (in_array($source, $supported, true)) {
$result[] = $source;
continue;
}
$tag = strtolower(preg_replace('/_-\./', '', $source));
foreach ($index as $key => $target) {
if (strpos($key, $tag) === 0) {
$result[] = $target;
break;
}
}
}
return $result;
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"requested",
",",
"array",
"$",
"supported",
")",
":",
"array",
"{",
"$",
"index",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"supported",
"as",
"$",
"tag",
")",
"{",
"$",
"key",
"=",
"strtolower",
"(",... | Map given list of language tags to supported ones
@param string[] $requested list of requested languages
@param string[] $supported list of supported languages
@return string[]
@link http://tools.ietf.org/html/bcp47
@since 1.0 | [
"Map",
"given",
"list",
"of",
"language",
"tags",
"to",
"supported",
"ones"
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Helper/LanguageMapper.php#L43-L78 |
mekras/php-speller | src/Helper/LanguageMapper.php | LanguageMapper.setPreferredMappings | public function setPreferredMappings(array $mappings): void
{
foreach ($mappings as $language => $map) {
$this->preferred[$language] = (array) $map;
}
} | php | public function setPreferredMappings(array $mappings): void
{
foreach ($mappings as $language => $map) {
$this->preferred[$language] = (array) $map;
}
} | [
"public",
"function",
"setPreferredMappings",
"(",
"array",
"$",
"mappings",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"mappings",
"as",
"$",
"language",
"=>",
"$",
"map",
")",
"{",
"$",
"this",
"->",
"preferred",
"[",
"$",
"language",
"]",
"=",
"(",... | Set preferred mappings
Examples:
```
$mapper->setPreferredMappings(['en' => ['en_US', 'en_GB']]);
```
@param array $mappings
@since 1.1 | [
"Set",
"preferred",
"mappings"
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Helper/LanguageMapper.php#L93-L98 |
mekras/php-speller | src/Source/XliffSource.php | XliffSource.addFilter | public function addFilter(string $pattern, Filter $filter = null): void
{
$this->filters[$pattern] = $filter;
} | php | public function addFilter(string $pattern, Filter $filter = null): void
{
$this->filters[$pattern] = $filter;
} | [
"public",
"function",
"addFilter",
"(",
"string",
"$",
"pattern",
",",
"Filter",
"$",
"filter",
"=",
"null",
")",
":",
"void",
"{",
"$",
"this",
"->",
"filters",
"[",
"$",
"pattern",
"]",
"=",
"$",
"filter",
";",
"}"
] | Add custom pattern to be filtered.
Matched text will be filtered with a given filter or with
{@link Mekras\Speller\Source\Filter\StripAllFilter} if $filter is null.
@param string $pattern PCRE pattern. It is recommended to use "ums" PCRE modifiers.
@param Filter $filter Filter to be applied.
@since 1.2 | [
"Add",
"custom",
"pattern",
"to",
"be",
"filtered",
"."
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Source/XliffSource.php#L68-L71 |
mekras/php-speller | src/Source/XliffSource.php | XliffSource.getAsString | public function getAsString(): string
{
$text = $this->source->getAsString();
$stripAll = new StripAllFilter();
$htmlFilter = new HtmlFilter();
/* Removing CDATA tags */
$text = preg_replace_callback(
'#<!\[CDATA\[(.*?)\]\]>#ums',
function ($match) use ($htmlFilter) {
$string = $htmlFilter->filter($match[1]);
// <![CDATA[ ]]
return ' ' . $string . ' ';
},
$text
);
/* Processing bottom level tags */
$text = preg_replace_callback(
'#(<(\w+)(\s[^>]*?)?>)([^<>]*)(</\w+\s*>)#um',
function ($match) use ($stripAll) {
if (strtolower($match[2]) === 'target') {
$replace = $stripAll->filter($match[1]) . $match[4]
. $stripAll->filter($match[5]);
} else {
$replace = $stripAll->filter($match[0]);
}
return $replace;
},
$text
);
/* Other replacements */
foreach ($this->filters as $pattern => $filter) {
if (null === $filter) {
$filter = $stripAll;
}
$text = preg_replace_callback(
$pattern,
function ($match) use ($filter) {
return $filter->filter($match[0]);
},
$text
);
}
return $text;
} | php | public function getAsString(): string
{
$text = $this->source->getAsString();
$stripAll = new StripAllFilter();
$htmlFilter = new HtmlFilter();
/* Removing CDATA tags */
$text = preg_replace_callback(
'#<!\[CDATA\[(.*?)\]\]>#ums',
function ($match) use ($htmlFilter) {
$string = $htmlFilter->filter($match[1]);
// <![CDATA[ ]]
return ' ' . $string . ' ';
},
$text
);
/* Processing bottom level tags */
$text = preg_replace_callback(
'#(<(\w+)(\s[^>]*?)?>)([^<>]*)(</\w+\s*>)#um',
function ($match) use ($stripAll) {
if (strtolower($match[2]) === 'target') {
$replace = $stripAll->filter($match[1]) . $match[4]
. $stripAll->filter($match[5]);
} else {
$replace = $stripAll->filter($match[0]);
}
return $replace;
},
$text
);
/* Other replacements */
foreach ($this->filters as $pattern => $filter) {
if (null === $filter) {
$filter = $stripAll;
}
$text = preg_replace_callback(
$pattern,
function ($match) use ($filter) {
return $filter->filter($match[0]);
},
$text
);
}
return $text;
} | [
"public",
"function",
"getAsString",
"(",
")",
":",
"string",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"source",
"->",
"getAsString",
"(",
")",
";",
"$",
"stripAll",
"=",
"new",
"StripAllFilter",
"(",
")",
";",
"$",
"htmlFilter",
"=",
"new",
"HtmlFilt... | Return text as one string
@return string
@throws \Mekras\Speller\Exception\SourceException
@since 1.2 | [
"Return",
"text",
"as",
"one",
"string"
] | train | https://github.com/mekras/php-speller/blob/902ffa0db6833747957f6dbf6d525602a2ca425a/src/Source/XliffSource.php#L81-L131 |
sunspikes/clamav-validator | src/ClamavValidator/ClamavValidatorServiceProvider.php | ClamavValidatorServiceProvider.boot | public function boot()
{
$this->loadTranslationsFrom(__DIR__ . '/../lang', 'clamav-validator');
$this->app['validator']
->resolver(function ($translator, $data, $rules, $messages, $customAttributes = []) {
return new ClamavValidator(
$translator,
$data,
$rules,
$messages,
$customAttributes
);
});
$this->addNewRules();
} | php | public function boot()
{
$this->loadTranslationsFrom(__DIR__ . '/../lang', 'clamav-validator');
$this->app['validator']
->resolver(function ($translator, $data, $rules, $messages, $customAttributes = []) {
return new ClamavValidator(
$translator,
$data,
$rules,
$messages,
$customAttributes
);
});
$this->addNewRules();
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"this",
"->",
"loadTranslationsFrom",
"(",
"__DIR__",
".",
"'/../lang'",
",",
"'clamav-validator'",
")",
";",
"$",
"this",
"->",
"app",
"[",
"'validator'",
"]",
"->",
"resolver",
"(",
"function",
"(",
"$",
... | Bootstrap the application events.
@return void | [
"Bootstrap",
"the",
"application",
"events",
"."
] | train | https://github.com/sunspikes/clamav-validator/blob/19f690f97afadd5d3bdfb930b33fb2f36e7f68f1/src/ClamavValidator/ClamavValidatorServiceProvider.php#L29-L45 |
sunspikes/clamav-validator | src/ClamavValidator/ClamavValidatorServiceProvider.php | ClamavValidatorServiceProvider.extendValidator | protected function extendValidator($rule)
{
$method = studly_case($rule);
$translation = $this->app['translator']->get('clamav-validator::validation');
$this->app['validator']->extend($rule, ClamavValidator::class .'@validate' . $method,
isset($translation[$rule]) ? $translation[$rule] : []);
} | php | protected function extendValidator($rule)
{
$method = studly_case($rule);
$translation = $this->app['translator']->get('clamav-validator::validation');
$this->app['validator']->extend($rule, ClamavValidator::class .'@validate' . $method,
isset($translation[$rule]) ? $translation[$rule] : []);
} | [
"protected",
"function",
"extendValidator",
"(",
"$",
"rule",
")",
"{",
"$",
"method",
"=",
"studly_case",
"(",
"$",
"rule",
")",
";",
"$",
"translation",
"=",
"$",
"this",
"->",
"app",
"[",
"'translator'",
"]",
"->",
"get",
"(",
"'clamav-validator::valida... | Extend the validator with new rules.
@param string $rule
@return void | [
"Extend",
"the",
"validator",
"with",
"new",
"rules",
"."
] | train | https://github.com/sunspikes/clamav-validator/blob/19f690f97afadd5d3bdfb930b33fb2f36e7f68f1/src/ClamavValidator/ClamavValidatorServiceProvider.php#L75-L81 |
sunspikes/clamav-validator | src/ClamavValidator/ClamavValidator.php | ClamavValidator.validateClamav | public function validateClamav($attribute, $value, $parameters)
{
$file = $this->getFilePath($value);
$clamavSocket = $this->getClamavSocket();
// Create a new socket instance
$socket = (new Factory())->createClient($clamavSocket);
// Create a new instance of the Client
$quahog = new Client($socket, self::CLAMAV_SOCKET_READ_TIMEOUT, PHP_NORMAL_READ);
// Check if the file is readable
if (! is_readable($file)) {
throw new ClamavValidatorException(sprintf('The file "%s" is not readable', $file));
}
// Scan the file
$result = $quahog->scanResourceStream(fopen($file, 'rb'));
if (self::CLAMAV_STATUS_ERROR === $result['status']) {
throw new ClamavValidatorException($result['reason']);
}
// Check if scan result is not clean
return !(self::CLAMAV_STATUS_OK !== $result['status']);
} | php | public function validateClamav($attribute, $value, $parameters)
{
$file = $this->getFilePath($value);
$clamavSocket = $this->getClamavSocket();
// Create a new socket instance
$socket = (new Factory())->createClient($clamavSocket);
// Create a new instance of the Client
$quahog = new Client($socket, self::CLAMAV_SOCKET_READ_TIMEOUT, PHP_NORMAL_READ);
// Check if the file is readable
if (! is_readable($file)) {
throw new ClamavValidatorException(sprintf('The file "%s" is not readable', $file));
}
// Scan the file
$result = $quahog->scanResourceStream(fopen($file, 'rb'));
if (self::CLAMAV_STATUS_ERROR === $result['status']) {
throw new ClamavValidatorException($result['reason']);
}
// Check if scan result is not clean
return !(self::CLAMAV_STATUS_OK !== $result['status']);
} | [
"public",
"function",
"validateClamav",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parameters",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"value",
")",
";",
"$",
"clamavSocket",
"=",
"$",
"this",
"->",
"getClamav... | Validate the uploaded file for virus/malware with ClamAV
@param $attribute string
@param $value mixed
@param $parameters array
@return boolean
@throws ClamavValidatorException | [
"Validate",
"the",
"uploaded",
"file",
"for",
"virus",
"/",
"malware",
"with",
"ClamAV"
] | train | https://github.com/sunspikes/clamav-validator/blob/19f690f97afadd5d3bdfb930b33fb2f36e7f68f1/src/ClamavValidator/ClamavValidator.php#L66-L91 |
sunspikes/clamav-validator | src/ClamavValidator/ClamavValidator.php | ClamavValidator.getClamavSocket | protected function getClamavSocket()
{
if (file_exists(env('CLAMAV_UNIX_SOCKET', self::CLAMAV_UNIX_SOCKET))) {
return 'unix://' . env('CLAMAV_UNIX_SOCKET', self::CLAMAV_UNIX_SOCKET);
}
return env('CLAMAV_TCP_SOCKET', self::CLAMAV_LOCAL_TCP_SOCKET);
} | php | protected function getClamavSocket()
{
if (file_exists(env('CLAMAV_UNIX_SOCKET', self::CLAMAV_UNIX_SOCKET))) {
return 'unix://' . env('CLAMAV_UNIX_SOCKET', self::CLAMAV_UNIX_SOCKET);
}
return env('CLAMAV_TCP_SOCKET', self::CLAMAV_LOCAL_TCP_SOCKET);
} | [
"protected",
"function",
"getClamavSocket",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"env",
"(",
"'CLAMAV_UNIX_SOCKET'",
",",
"self",
"::",
"CLAMAV_UNIX_SOCKET",
")",
")",
")",
"{",
"return",
"'unix://'",
".",
"env",
"(",
"'CLAMAV_UNIX_SOCKET'",
",",
"sel... | Guess the ClamAV socket
@return string | [
"Guess",
"the",
"ClamAV",
"socket"
] | train | https://github.com/sunspikes/clamav-validator/blob/19f690f97afadd5d3bdfb930b33fb2f36e7f68f1/src/ClamavValidator/ClamavValidator.php#L98-L105 |
sunspikes/clamav-validator | src/ClamavValidator/ClamavValidator.php | ClamavValidator.getFilePath | protected function getFilePath($file)
{
// if were passed an instance of UploadedFile, return the path
if ($file instanceof UploadedFile) {
return $file->getPathname();
}
// if we're passed a PHP file upload array, return the "tmp_name"
if (is_array($file) && null !== array_get($file, 'tmp_name')) {
return $file['tmp_name'];
}
// fallback: we were likely passed a path already
return $file;
} | php | protected function getFilePath($file)
{
// if were passed an instance of UploadedFile, return the path
if ($file instanceof UploadedFile) {
return $file->getPathname();
}
// if we're passed a PHP file upload array, return the "tmp_name"
if (is_array($file) && null !== array_get($file, 'tmp_name')) {
return $file['tmp_name'];
}
// fallback: we were likely passed a path already
return $file;
} | [
"protected",
"function",
"getFilePath",
"(",
"$",
"file",
")",
"{",
"// if were passed an instance of UploadedFile, return the path",
"if",
"(",
"$",
"file",
"instanceof",
"UploadedFile",
")",
"{",
"return",
"$",
"file",
"->",
"getPathname",
"(",
")",
";",
"}",
"/... | Return the file path from the passed object
@param $file mixed
@return string | [
"Return",
"the",
"file",
"path",
"from",
"the",
"passed",
"object"
] | train | https://github.com/sunspikes/clamav-validator/blob/19f690f97afadd5d3bdfb930b33fb2f36e7f68f1/src/ClamavValidator/ClamavValidator.php#L113-L127 |
thephpleague/iso3166 | src/Guards.php | Guards.guardAgainstInvalidAlpha2 | public static function guardAgainstInvalidAlpha2($alpha2)
{
if (!is_string($alpha2)) {
throw new InvalidArgumentException(
sprintf('Expected $alpha2 to be of type string, got: %s', gettype($alpha2))
);
}
if (!preg_match('/^[a-zA-Z]{2}$/', $alpha2)) {
throw new DomainException(
sprintf('Not a valid alpha2 key: %s', $alpha2)
);
}
} | php | public static function guardAgainstInvalidAlpha2($alpha2)
{
if (!is_string($alpha2)) {
throw new InvalidArgumentException(
sprintf('Expected $alpha2 to be of type string, got: %s', gettype($alpha2))
);
}
if (!preg_match('/^[a-zA-Z]{2}$/', $alpha2)) {
throw new DomainException(
sprintf('Not a valid alpha2 key: %s', $alpha2)
);
}
} | [
"public",
"static",
"function",
"guardAgainstInvalidAlpha2",
"(",
"$",
"alpha2",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"alpha2",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Expected $alpha2 to be of type string, got: ... | Assert that input looks like an alpha2 key.
@param string $alpha2
@throws \League\ISO3166\Exception\InvalidArgumentException if input is not a string
@throws \League\ISO3166\Exception\DomainException if input does not look like an alpha2 key | [
"Assert",
"that",
"input",
"looks",
"like",
"an",
"alpha2",
"key",
"."
] | train | https://github.com/thephpleague/iso3166/blob/0e8b0e54fc73c40b93d23dbfe0945e250dd034b0/src/Guards.php#L41-L54 |
thephpleague/iso3166 | src/Guards.php | Guards.guardAgainstInvalidAlpha3 | public static function guardAgainstInvalidAlpha3($alpha3)
{
if (!is_string($alpha3)) {
throw new InvalidArgumentException(
sprintf('Expected $alpha3 to be of type string, got: %s', gettype($alpha3))
);
}
if (!preg_match('/^[a-zA-Z]{3}$/', $alpha3)) {
throw new DomainException(
sprintf('Not a valid alpha3 key: %s', $alpha3)
);
}
} | php | public static function guardAgainstInvalidAlpha3($alpha3)
{
if (!is_string($alpha3)) {
throw new InvalidArgumentException(
sprintf('Expected $alpha3 to be of type string, got: %s', gettype($alpha3))
);
}
if (!preg_match('/^[a-zA-Z]{3}$/', $alpha3)) {
throw new DomainException(
sprintf('Not a valid alpha3 key: %s', $alpha3)
);
}
} | [
"public",
"static",
"function",
"guardAgainstInvalidAlpha3",
"(",
"$",
"alpha3",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"alpha3",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Expected $alpha3 to be of type string, got: ... | Assert that input looks like an alpha3 key.
@param string $alpha3
@throws \League\ISO3166\Exception\InvalidArgumentException if input is not a string
@throws \League\ISO3166\Exception\DomainException if input does not look like an alpha3 key | [
"Assert",
"that",
"input",
"looks",
"like",
"an",
"alpha3",
"key",
"."
] | train | https://github.com/thephpleague/iso3166/blob/0e8b0e54fc73c40b93d23dbfe0945e250dd034b0/src/Guards.php#L64-L77 |
thephpleague/iso3166 | src/Guards.php | Guards.guardAgainstInvalidNumeric | public static function guardAgainstInvalidNumeric($numeric)
{
if (!is_string($numeric)) {
throw new InvalidArgumentException(
sprintf('Expected $numeric to be of type string, got: %s', gettype($numeric))
);
}
if (!preg_match('/^[0-9]{3}$/', $numeric)) {
throw new DomainException(
sprintf('Not a valid numeric key: %s', $numeric)
);
}
} | php | public static function guardAgainstInvalidNumeric($numeric)
{
if (!is_string($numeric)) {
throw new InvalidArgumentException(
sprintf('Expected $numeric to be of type string, got: %s', gettype($numeric))
);
}
if (!preg_match('/^[0-9]{3}$/', $numeric)) {
throw new DomainException(
sprintf('Not a valid numeric key: %s', $numeric)
);
}
} | [
"public",
"static",
"function",
"guardAgainstInvalidNumeric",
"(",
"$",
"numeric",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"numeric",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Expected $numeric to be of type string, g... | Assert that input looks like a numeric key.
@param string $numeric
@throws \League\ISO3166\Exception\InvalidArgumentException if input is not a string
@throws \League\ISO3166\Exception\DomainException if input does not look like a numeric key | [
"Assert",
"that",
"input",
"looks",
"like",
"a",
"numeric",
"key",
"."
] | train | https://github.com/thephpleague/iso3166/blob/0e8b0e54fc73c40b93d23dbfe0945e250dd034b0/src/Guards.php#L87-L100 |
thephpleague/iso3166 | src/ISO3166.php | ISO3166.name | public function name($name)
{
Guards::guardAgainstInvalidName($name);
return $this->lookup(self::KEY_NAME, $name);
} | php | public function name($name)
{
Guards::guardAgainstInvalidName($name);
return $this->lookup(self::KEY_NAME, $name);
} | [
"public",
"function",
"name",
"(",
"$",
"name",
")",
"{",
"Guards",
"::",
"guardAgainstInvalidName",
"(",
"$",
"name",
")",
";",
"return",
"$",
"this",
"->",
"lookup",
"(",
"self",
"::",
"KEY_NAME",
",",
"$",
"name",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/thephpleague/iso3166/blob/0e8b0e54fc73c40b93d23dbfe0945e250dd034b0/src/ISO3166.php#L41-L46 |
thephpleague/iso3166 | src/ISO3166.php | ISO3166.alpha2 | public function alpha2($alpha2)
{
Guards::guardAgainstInvalidAlpha2($alpha2);
return $this->lookup(self::KEY_ALPHA2, $alpha2);
} | php | public function alpha2($alpha2)
{
Guards::guardAgainstInvalidAlpha2($alpha2);
return $this->lookup(self::KEY_ALPHA2, $alpha2);
} | [
"public",
"function",
"alpha2",
"(",
"$",
"alpha2",
")",
"{",
"Guards",
"::",
"guardAgainstInvalidAlpha2",
"(",
"$",
"alpha2",
")",
";",
"return",
"$",
"this",
"->",
"lookup",
"(",
"self",
"::",
"KEY_ALPHA2",
",",
"$",
"alpha2",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/thephpleague/iso3166/blob/0e8b0e54fc73c40b93d23dbfe0945e250dd034b0/src/ISO3166.php#L51-L56 |
thephpleague/iso3166 | src/ISO3166.php | ISO3166.alpha3 | public function alpha3($alpha3)
{
Guards::guardAgainstInvalidAlpha3($alpha3);
return $this->lookup(self::KEY_ALPHA3, $alpha3);
} | php | public function alpha3($alpha3)
{
Guards::guardAgainstInvalidAlpha3($alpha3);
return $this->lookup(self::KEY_ALPHA3, $alpha3);
} | [
"public",
"function",
"alpha3",
"(",
"$",
"alpha3",
")",
"{",
"Guards",
"::",
"guardAgainstInvalidAlpha3",
"(",
"$",
"alpha3",
")",
";",
"return",
"$",
"this",
"->",
"lookup",
"(",
"self",
"::",
"KEY_ALPHA3",
",",
"$",
"alpha3",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/thephpleague/iso3166/blob/0e8b0e54fc73c40b93d23dbfe0945e250dd034b0/src/ISO3166.php#L61-L66 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.