当前位置: 首页>>代码示例>>PHP>>正文


PHP NGS函数代码示例

本文整理汇总了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;
 }
开发者ID:naghashyan,项目名称:Naghashyan-PHP-Framework-Core,代码行数:30,代码来源:NgsUtils.php

示例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;
 }
开发者ID:pars5555,项目名称:hqv,代码行数:34,代码来源:SessionManager.class.php

示例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;
         }
     }
 }
开发者ID:naghashyan,项目名称:Naghashyan-PHP-Framework-Core,代码行数:27,代码来源:NgsDynamic.php

示例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());
 }
开发者ID:naghashyan,项目名称:Naghashyan-PHP-Framework-Core,代码行数:10,代码来源:AbstractSolrMapper.php

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

示例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;
 }
开发者ID:pars5555,项目名称:hqv,代码行数:8,代码来源:SetLanguageAction.class.php

示例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;
 }
开发者ID:pars5555,项目名称:crm,代码行数:17,代码来源:JsonException.class.php

示例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;
 }
开发者ID:pars5555,项目名称:hqv,代码行数:16,代码来源:MysqlDBMS.class.php

示例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);
 }
开发者ID:naghashyan,项目名称:Naghashyan-PHP-Framework-Core,代码行数:12,代码来源:FileUtils.php

示例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;
 }
开发者ID:naghashyan,项目名称:Naghashyan-PHP-Framework-Core,代码行数:12,代码来源:NgsErrorException.php

示例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();
 }
开发者ID:naghashyan,项目名称:Naghashyan-PHP-Framework-Core,代码行数:12,代码来源:NoAccessException.php

示例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");
     }
 }
开发者ID:pars5555,项目名称:crm,代码行数:15,代码来源:AbstractMongoMapper.class.php

示例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;
 }
开发者ID:pars5555,项目名称:crm,代码行数:12,代码来源:NgsErrorException.class.php

示例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;
    }
}
开发者ID:pars5555,项目名称:hqv,代码行数:69,代码来源:function.ngs.php

示例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);
 }
开发者ID:pars5555,项目名称:crm,代码行数:16,代码来源:AbstractPostgreSQLMapper.class.php


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