本文整理匯總了PHP中NGS函數的典型用法代碼示例。如果您正苦於以下問題:PHP NGS函數的具體用法?PHP NGS怎麽用?PHP NGS使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NGS函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createObjectFromArray
public function createObjectFromArray($arr, $trim = false)
{
$stdObj = NGS()->getDynObject();
foreach ($arr as $key => $value) {
$last = substr(strrchr($key, '.'), 1);
if (!$last) {
$last = $key;
}
$node = $stdObj;
foreach (explode('.', $key) as $key2) {
if (!isset($node->{$key2})) {
$node->{$key2} = new \stdclass();
}
if ($key2 == $last) {
if (is_string($value)) {
if ($trim == true) {
$node->{$key2} = trim(htmlspecialchars(strip_tags($value)));
} else {
$node->{$key2} = $value;
}
} else {
$node->{$key2} = $value;
}
} else {
$node = $node->{$key2};
}
}
}
return $stdObj;
}
示例2: getUser
/**
* return ngs current logined or not
* user object
*
* @return userObject
*/
public function getUser()
{
if ($this->user != null) {
return $this->user;
}
try {
if (!isset($_COOKIE["ut"])) {
$user = new \hqv\security\users\GuestUser();
$user->register();
$this->setUser($user, true, true);
} else {
$user = $this->getUserByLevel($_COOKIE["ut"]);
}
$user->validate();
} catch (InvalidUserException $ex) {
$this->deleteUser($user);
NGS()->redirect(substr($_SERVER["REQUEST_URI"], 1));
exit;
}
if ($user->getLevel() != UserGroups::$GUEST) {
$user->updateActivity();
if ($user->getLevel() != UserGroups::$API) {
$this->updateUserUniqueId($user);
}
}
$this->user = $user;
return $this->user;
}
示例3: __call
public function __call($m, $a)
{
if (!isset($m)) {
throw new \Exception("Fatal error: Call to undefined method stdObject::{$m}()");
}
if (\is_callable($this->{$m})) {
return \call_user_func_array($this->{$m}, $a);
}
// retrieving the method type (setter or getter)
$type = substr($m, 0, 3);
// retrieving the field name
$fieldName = NGS()->getNgsUtils()->lowerFirstLetter(substr($m, 3));
if ($type == 'set') {
if (count($a) == 1) {
$this->{$fieldName} = $a[0];
} else {
$this->{$fieldName} = $a;
}
} else {
if ($type == 'get') {
if (isset($this->{$fieldName})) {
return $this->{$fieldName};
}
return null;
}
}
}
示例4: __construct
/**
* Initializes DBMS pointer.
*/
function __construct()
{
$host = NGS()->getConfig()->DB->solr->host;
$user = NGS()->getConfig()->DB->solr->port;
$path = NGS()->getConfig()->DB->solr->path;
$this->dbms = new SolrDBMS($host, $user, $path, $this->getTableName());
}
示例5: smarty_function_nest
/**
* Smarty {math} function plugin
*
* Type: function<br>
* Name: nest<br>
* Purpose: handle math computations in template
* <br>
*
* @author Levon Naghashyan <levon at naghashyan dot com>
* @site http://naghashyan.com
* @mail levon@naghashyan.com
* @year 2012-2015
* @version 2.0.0
* @param array $params parameters
* @param object $template template object
* @return render template|null
*/
function smarty_function_nest($params, $template)
{
if (!isset($params['ns'])) {
trigger_error("nest: missing 'ns' parameter");
return;
}
if (!$template->tpl_vars["ns"]) {
$template->tpl_vars["ns"] = $template->smarty->smarty->tpl_vars["ns"];
}
$nsValue = $template->tpl_vars["ns"]->value;
$pmValue = $template->tpl_vars["pm"]->value;
$namespace = $nsValue["inc"][$params["ns"]]["namespace"];
$include_file = $nsValue["inc"][$params["ns"]]["filename"];
$_tpl = $template->smarty->createTemplate($include_file, null, null, $nsValue["inc"][$params["ns"]]["params"]);
foreach ($template->tpl_vars as $key => $tplVars) {
$_tpl->assign($key, $tplVars);
}
$_tpl->assign("ns", $nsValue["inc"][$params["ns"]]["params"]);
$_tpl->assign("pm", $pmValue);
if ($_tpl->mustCompile()) {
$_tpl->compileTemplateSource();
}
//$_tpl->renderTemplate();
$_output = $_tpl->display();
if (NGS()->isJsFrameworkEnable() && !NGS()->getHttpUtils()->isAjaxRequest()) {
$jsonParams = $nsValue["inc"][$params["ns"]]["jsonParam"];
$parentLoad = $nsValue["inc"][$params["ns"]]["parent"];
$jsString = '<script type="text/javascript">';
$jsString .= 'NGS.setNestedLoad("' . $parentLoad . '", "' . $namespace . '", ' . json_encode($jsonParams) . ')';
$jsString .= '</script>';
$_output = $jsString . $_output;
}
return $_output;
}
示例6: service
public function service()
{
if (isset(NGS()->args()->lang) && in_array(NGS()->args()->lang, ['am', 'en', 'ru'])) {
setcookie('ul', NGS()->args()->lang, time() + 60 * 60 * 24 * 365, "/", NGS()->getHttpUtils()->getHttpHost());
}
header("location: " . $_SERVER['HTTP_REFERER']);
exit;
}
示例7: __construct
/**
* Return a thingie based on $paramie
* @abstract
* @access
* @param boolean $paramie
* @return integer|babyclass
*/
public function __construct($msg, $code = false)
{
NGS()->getTemplateEngine()->assignJson("status", "error");
if ($code != false) {
NGS()->getTemplateEngine()->assignJson("code", $code);
}
NGS()->getTemplateEngine()->assignJson("msg", $msg);
NGS()->getTemplateEngine()->display();
exit;
}
示例8: getInstance
/**
* Returns an singleton instance of class.
*
* @return
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$db_host = NGS()->getConfig()->DB_host;
self::$db_user = NGS()->getConfig()->DB_user;
self::$db_pass = NGS()->getConfig()->DB_pass;
self::$db_name = NGS()->getConfig()->DB_name;
self::$instance = new ImprovedDBMS();
}
return self::$instance;
}
示例9: streamFile
public function streamFile($module, $file)
{
$filePath = realpath(NGS()->getPublicDir($module) . "/" . $file);
if ($filePath == false) {
throw new DebugException("File Not Found");
}
$options = array();
if (NGS()->getEnvironment() != "production") {
$options["cache"] = false;
}
$this->sendFile($filePath, $options);
}
示例10: __construct
public function __construct($msg = "", $code = -1, $params = array())
{
if (!NGS()->getHttpUtils()->isAjaxRequest()) {
//throw new DebugException();
}
NGS()->getTemplateEngine()->setHttpStatusCode(400);
NGS()->getTemplateEngine()->assignJson("code", $code);
NGS()->getTemplateEngine()->assignJson("msg", $msg);
NGS()->getTemplateEngine()->assignJson("params", $params);
NGS()->getTemplateEngine()->display();
exit;
}
示例11: displayJsonInvalidError
public function displayJsonInvalidError($msg, $redirectTo, $redirectToLoad)
{
NGS()->getTemplateEngine()->setHttpStatusCode(403);
NGS()->getTemplateEngine()->assignJson("msg", $msg);
if ($redirectTo != "") {
NGS()->getTemplateEngine()->assignJson("redirect_to", $redirectTo);
}
if ($redirectToLoad != "") {
NGS()->getTemplateEngine()->assignJson("redirect_to_load", $redirectToLoad);
}
NGS()->getTemplateEngine()->display();
}
示例12: __construct
/**
* Initializes DBMS pointer.
*/
function __construct()
{
try {
$host = NGS()->getConfig()->DB->mongo->host;
$user = NGS()->getConfig()->DB->mongo->user;
$pass = NGS()->getConfig()->DB->mongo->pass;
$name = NGS()->getConfig()->DB->mongo->name;
$this->dbms = \ngs\framework\dal\connectors\MongoDBMS::getInstance($host, $user, $pass, $name);
} catch (\Exception $e) {
throw new DebugException($e->getMessage(), "Mongo DB");
}
}
示例13: __construct
public function __construct($msg = "", $code = -1, $params = array())
{
if (!NGS()->getHttpUtils()->isAjaxRequest()) {
throw NGS()->getNotFoundException();
}
NGS()->getTemplateEngine()->assignJson("status", "error");
NGS()->getTemplateEngine()->assignJson("code", $code);
NGS()->getTemplateEngine()->assignJson("msg", $msg);
NGS()->getTemplateEngine()->assignJson("params", $params);
NGS()->getTemplateEngine()->display();
exit;
}
示例14: smarty_function_ngs
/**
* Smarty {math} function plugin
*
* Type: function<br>
* Name: nest<br>
* Purpose: helper function gor access global NGS Object
* <br>
*
* @author Levon Naghashyan <levon at naghashyan dot com>
* @site http://naghashyan.com
* @mail levon@naghashyan.com
* @year 2015
* @version 2.0.0
* @param array $params parameters
* @param object $template template object
* @return render template|null
*/
function smarty_function_ngs($params, $template)
{
if (!isset($params['cmd'])) {
trigger_error("NGS: missing 'cmd' parameter");
return;
}
$ns = "";
if (isset($params['ns'])) {
$ns = $params['ns'];
}
switch ($params['cmd']) {
case 'get_js_out_dir':
$protocol = false;
if (isset($params['protocol']) && $params['protocol'] == true) {
$protocol = true;
}
return NGS()->getPublicOutputHost($ns, $protocol) . "/js";
break;
case 'get_css_out_dir':
$protocol = false;
if (isset($params['protocol']) && $params['protocol'] == true) {
$protocol = true;
}
return NGS()->getPublicOutputHost($ns, $protocol) . "/css";
break;
case 'get_less_out_dir':
$protocol = false;
if (isset($params['protocol']) && $params['protocol'] == true) {
$protocol = true;
}
return NGS()->getPublicOutputHost($ns, $protocol) . "/less";
break;
case 'get_template_dir':
return NGS()->getTemplateDir($ns);
break;
case 'get_static_path':
if (isset(NGS()->getConfig()->static_path)) {
return "//" . NGS()->getConfig()->static_path;
}
$protocol = false;
if (isset($params['protocol']) && $params['protocol'] == true) {
$protocol = true;
}
return NGS()->getHttpUtils()->getNgsStaticPath($ns, $protocol);
break;
case 'get_version':
return NGS()->getVersion();
break;
default:
break;
}
}
示例15: __construct
/**
* Initializes DBMS pointer.
*/
function __construct()
{
$config = NGS()->getConfig();
if (!isset($config->DB->mysql)) {
$config = NGS()->getNgsConfig();
}
$host = NGS()->getNgsConfig()->DB->pgsql->host;
$user = NGS()->getNgsConfig()->DB->pgsql->user;
$pass = NGS()->getNgsConfig()->DB->pgsql->pass;
$name = NGS()->getNgsConfig()->DB->pgsql->name;
$port = NGS()->getNgsConfig()->DB->pgsql->port;
$this->dbms = \ngs\framework\dal\connectors\PgsqlPDO::getInstance($host, $user, $pass, $name, $port);
}