Пример #1
0
    public function Render($form = "", $response_location = "", $url = "", $args = "")
    {
        $errorMsg = '';
        $errors = FALSE;
        $Load = new Load();
        if (function_exists('is_empty') == FALSE) {
            // Load validate helper
            $Load->Helper('validate');
        }
        if (is_empty($form) == FALSE) {
            $this->form = $form;
        }
        if (is_empty($response_location) == FALSE) {
            $this->response_location = $response_location;
        }
        if (is_empty($url) == FALSE) {
            $this->url = $url;
        }
        if (is_empty($args) == FALSE) {
            $this->args = $args;
        }
        if (is_empty($this->form)) {
            $errorMsg .= ' form requerido :$obj-> Form("id-form")<br /> ';
            $errors = TRUE;
        }
        if (is_empty($this->response_location)) {
            $errorMsg .= ' response_location requerido : $obj-> ResponseLocation("id-div-location")<br /> ';
            $errors = TRUE;
        }
        if (is_empty($this->url)) {
            $errorMsg .= ' url requerida : $obj-> Url("Controller/Action")<br /> ';
            $errors = TRUE;
        }
        if ($errors == TRUE) {
            echo 'Error:<br />' . $errorMsg;
            return FALSE;
        } else {
            // Crear respuesta
            $butonsCode = $this->RenderButtons();
            $params = 'form:' . $this->form . ';url:' . $this->url . ';args:' . $this->args . ';';
            $fx = new fk_ajax('submit', $this->response_location, $params);
            $Result = ' <script type="text/javascript">
<!--
' . $butonsCode . '
$("#' . $this->form . '").validate({
	 submitHandler: function(form) {
		 ' . $fx->render() . '
		 return false;
	 },invalidHandler: function(form, validator){
      var errors = validator.numberOfInvalids();
      if (errors) { alert("Por favor, llena los campos obligatorios");}
	 }
});
//-->
</script>';
            return $Result;
        }
    }
 public function register(Load $container)
 {
     $container->bindShared('db', function () {
         return new \CODOF\Database\Connector();
     });
     $container->bindShared('i', function () {
         return new \CODOF\User\CurrentUser\CurrentUser();
     });
 }
Пример #3
0
 /**
  * @covers SysInfo\Linux\Load::__construct
  * @covers SysInfo\Linux\Load::getAvg
  */
 public function testLoadWithSystemData()
 {
     $load = new Load();
     $result = $load->getAvg();
     $this->assertInternalType('array', $result);
     $this->assertInternalType('float', $result[0]);
     $this->assertInternalType('float', $result[1]);
     $this->assertInternalType('float', $result[2]);
 }
Пример #4
0
 public function testLoading()
 {
     $sut = new Load(file_get_contents(__DIR__ . '/../.travis.yml'));
     $scripts = $sut->getScripts();
     $this->assertEquals('./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover', $scripts[0]);
     $this->assertEquals('php ocular.phar code-coverage:upload --format=php-clover coverage.clover', $scripts[1]);
     $this->assertEquals('./vendor/bin/phpcs --standard=PSR1 bin/ src/ test/', $scripts[2]);
     $this->assertEquals('./vendor/bin/phpcs --standard=PSR2 bin/ src/ test/', $scripts[3]);
 }
Пример #5
0
 function codes()
 {
     Load::model('user');
     $User = new User();
     $param['codes'] = $User->get_codes();
     Load::view('codes', $param);
 }
Пример #6
0
/**
 * Handle log errors
 *
 * @author Rafael Nexus
 * @param string $error_msg
 * @return void
 **/
function log_error($error_msg)
{
    $error = Load::factory('Config')->error;
    if ($error['log'] != 0) {
        error_log($error_msg, $error['log'], $error['log_destination'], isset($error['log_extra_headers']) ? $error['log_extra_headers'] : '');
    }
}
Пример #7
0
 /**
  * logout
  *
  * @param void
  * @return void
  */
 public static function logout()
 {
     Load::lib('auth');
     Load::lib('session');
     Session::set(SESSION_KEY, false);
     Auth::destroy_identity();
 }
Пример #8
0
 public function formatos()
 {
     $this->render(null, null);
     Load::lib("formato");
     echo "UTF8: " . Formato::utf8("México") . "<br />";
     echo "Normal: " . "México" . "<br />";
     echo "ISO8859-1: " . Formato::iso88591("México") . "<br />";
     echo "<br />";
     echo "Numero: " . Formato::numero(738374) . "<br />";
     echo "Dinero: " . Formato::dinero(738374) . "<br />";
     echo "Ceros: " . Formato::ceros(73, 5) . "<br />";
     echo "<br />";
     echo "Numero con Letra: " . Formato::numeroLetra(738374) . "<br />";
     echo "<br />";
     echo "Mayusculas: " . Formato::mayusculas("Lorem Ipsum is simply dummy text of the printing and typesetting industry") . "<br />";
     echo "Minusculas: " . Formato::minusculas("Lorem Ipsum is simply dummy text of the printing and typesetting industry") . "<br />";
     echo "Capital: " . Formato::capital("Lorem Ipsum is simply dummy text of the printing and typesetting industry") . "<br />";
     echo "Texto: " . Formato::texto("clientes_distinguidos") . "<br />";
     echo "Camello: " . Formato::camello("clientes_distinguidos") . "<br />";
     echo "InversaCamello: " . Formato::inversaCamello("facturasEmitidasMes") . "<br />";
     echo "<br />";
     echo "Fecha: " . Formato::fecha(date("Y-m-d")) . "<br />";
     echo "Fecha DB: " . Formato::fechaDB(date("d/m/Y")) . "<br />";
     echo "Hora: " . Formato::hora(452) . "<br />";
 }
Пример #9
0
 public function logout()
 {
     Load::lib('SdAuth');
     SdAuth::logout();
     View::template('login2');
     Router::redirect('');
 }
Пример #10
0
 /**
  * Starting point for every page request. Loads required core modules, gets data from url and calls
  * necessary modules to make things happen.
  */
 public static function init()
 {
     if (!self::$_inited) {
         self::$_inited = true;
         foreach (self::$_requiredCore as $module) {
             require_once ROOT . 'core/' . $module . '/' . $module . EXT;
         }
         // Set the Load::auto method to handle all class loading from now on
         spl_autoload_register('Load::auto');
         Load::loadSetupFiles();
         // If CLI mode, everything thats needed has been loaded
         if (IS_CLI) {
             return;
         }
         date_default_timezone_set(Config::get('system.timezone'));
         Event::trigger('caffeine.started');
         // If maintenance mode has been set in the config, stop everything and load mainteance view
         if (Config::get('system.maintenance_mode')) {
             View::error(ERROR_MAINTENANCE);
         } else {
             list($route, $data) = Router::getRouteData();
             if ($data) {
                 if (self::_hasPermission($route, $data)) {
                     list($module, $controller, $method) = $data['callback'];
                     $params = Router::getParams();
                     // Make sure controller words are upper-case
                     $conBits = explode('_', $controller);
                     foreach ($conBits as &$bit) {
                         $bit = ucfirst($bit);
                     }
                     $controller = implode('_', $conBits);
                     $controller = sprintf('%s_%sController', ucfirst($module), ucwords($controller));
                     // Call the routes controller and method
                     if (method_exists($controller, $method)) {
                         $response = call_user_func_array(array($controller, $method), $params);
                         if (!self::_isErrorResponse($response)) {
                             Event::trigger('module.response', array($response));
                             View::load($module, $controller, $method);
                         } else {
                             View::error($response);
                         }
                     } else {
                         Log::error($module, sprintf('The method %s::%s() called by route %s doesn\'t exist.', $controller, $method, $route));
                         View::error(ERROR_500);
                     }
                 } else {
                     View::error(ERROR_ACCESSDENIED);
                 }
             } else {
                 if ($route !== '[index]' || !View::directLoad('index')) {
                     View::error(ERROR_404);
                 }
             }
         }
         View::output();
         Event::trigger('caffeine.finished');
     } else {
         die('Why are you trying to re-initialize Caffeine?');
     }
 }
Пример #11
0
 public function __construct()
 {
     // load the config object
     $config = Load::library('Config');
     // get the connection name based off the enviroment
     $connection = $config->getEnvironment();
     // load the connection details
     $details = $config->get('connections.' . $connection);
     try {
         // instantiate the PDO object
         $this->dbh = parent::__construct($details[0], $details[1], $details[2]);
     } catch (PDOException $e) {
         if ($config->isDev()) {
             // throw the original exception
             throw new Exception('PDO exception caught: ' . $e->getMessage());
         } else {
             // throw the generic DB exception
             throw new Exception('Database connection error');
         }
     }
     // set the PDO error mode to exception
     parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     // return the DB handle
     return $this->dbh;
 }
Пример #12
0
 function ModuleObject($config)
 {
     $this->MasterObject($config);
     Load::logic('vote');
     $this->VoteLogic = new VoteLogic($this);
     $this->Execute();
 }
Пример #13
0
	function ModuleObject( $config )
	{
		$this->MasterObject($config);
		$this->iniz();
		$runCode = Load::moduleCode($this);
		$this->$runCode();
	}
Пример #14
0
 public function logout()
 {
     Load::lib('SdAuth');
     SdAuth::logout();
     $this->render(null, 'login2');
     $this->redirect('');
 }
Пример #15
0
 function delete($id)
 {
     $article_title = $this->article->getArticleTitleById($id);
     $result = $this->article->delete($id) ? 'Article <b>' . $article_title . '</b> deleted' : 'Error deleting the article';
     $data = array('title' => 'All articles', 'notice' => array('type' => 'success', 'message' => $result));
     Load::view('notice.php', $data);
 }
Пример #16
0
	function ModuleObject(& $config)
	{
		$this->MasterObject($config);
		$this->ID=$this->Post['id']?(int)$this->Post['id']:(int)$this->Get['id'];

		Load::moduleCode($this);$this->Execute();
	}
Пример #17
0
 /**
  * Returns an array of all possible models within the system.
  */
 private static function _getModels()
 {
     if (is_null(self::$_models)) {
         self::$_models = array();
         $paths = Load::getModulePaths();
         foreach ($paths as $path) {
             $modules = scandir($path);
             foreach ($modules as $module) {
                 if ($module[0] == '.') {
                     continue;
                 }
                 $modelsPath = sprintf('%s%s/models/', $path, $module);
                 if (file_exists($modelsPath)) {
                     $models = scandir($modelsPath);
                     foreach ($models as $model) {
                         if ($model[0] == '.') {
                             continue;
                         }
                         $class = sprintf('%s_%sModel', ucfirst($module), ucfirst(str_replace(EXT, '', $model)));
                         if (!in_array($class, self::$_models)) {
                             self::$_models[] = $class;
                         }
                     }
                 }
             }
         }
     }
     return self::$_models;
 }
Пример #18
0
 function ModuleObject($config)
 {
     $this->MasterObject($config);
     Load::logic('talk');
     $this->TalkLogic = new TalkLogic($this);
     $this->Execute();
 }
Пример #19
0
 public function __construct()
 {
     //parent::__construct();
     $this->load = Load::getInstance();
     $this->load->_autoloadComplement();
     $this->http = new http();
 }
Пример #20
0
 function translate($lang = 'ru')
 {
     $config = App;
     $content = ob_get_contents();
     ob_end_clean();
     if (self::$active) {
         self::$locale = self::getAppLocale($lang);
         preg_match_all(LOCALE_TEMPLATE, $content, $mathes);
         if (sizeof($mathes[1]) > 0) {
             foreach ($mathes[1] as $word) {
                 if (array_key_exists($word, self::$locale)) {
                     $content = str_replace(sprintf(LOCALE_TEMPLATE_CHANGE, $word), self::$locale[$word], $content);
                 }
             }
         }
     }
     if (($selector = Request::post('html_element')) || ($selector = Request::get('html_element'))) {
         Load::dependence('simple_html_dom');
         $html = str_get_html($content);
         $elements = $html->find($selector);
         if (sizeof($elements) > 0) {
             echo $elements[0]->innertext;
         } else {
             echo $content;
         }
     } else {
         echo $content;
     }
 }
Пример #21
0
function app_check($item, $item_id = null)
{
    $app_list = app_get_list();
    if (in_array($item, $app_list)) {
        if (is_null($item_id)) {
            return true;
        }
    } else {
        return false;
    }
    #if NEDU
    if (defined('NEDU_MOYO')) {
        $r = nlogic('feeds.app.jsg')->check_item($item, $item_id);
        if (is_array($r) && $r['checked'] === true) {
            return (bool) $r['result'];
        }
    }
    #endif
    $item = $item == 'company' ? 'cp' : $item;
    if (!Load::logic($item)) {
        return false;
    }
    $class_name = ucwords($item) . 'Logic';
    if (method_exists($class_name, 'is_exists')) {
        $ret = call_user_func(array($class_name, 'is_exists'), $item_id);
        if (empty($ret)) {
            return false;
        }
        return true;
    }
    return false;
}
Пример #22
0
 public function initialize($smarty, $sessionManager, $config, $loadMapper, $args)
 {
     parent::initialize($smarty, $sessionManager, $config, $loadMapper, $args);
     $customer = $this->getCustomer();
     $this->addParam("user", $customer);
     $this->addParam('load_class_name', get_called_class());
 }
Пример #23
0
 function ModuleObject($config)
 {
     $this->MasterObject($config);
     $this->ShowConfig = jconf::get('show');
     Load::logic('vote');
     $this->VoteLogic = new VoteLogic();
     $this->TopicLogic = jlogic('topic');
     if (MEMBER_ROLE_TYPE != 'admin') {
         if (!$this->Config['vote_open']) {
             $this->Messager("当前站点没有开放投票功能", null);
         }
     }
     $code =& $this->Code;
     ob_start();
     if (!empty($this->Get['vid']) && empty($code)) {
         $code = 'view';
     } else {
         if (empty($code)) {
             $code = 'index';
             if (!empty($this->Get['uid']) && empty($this->Get['view'])) {
                 $this->Get['view'] = 'me';
             }
         }
     }
     if (in_array($code, array('create'))) {
         $this->_check_login();
     }
     if (method_exists('ModuleObject', $code)) {
         $this->{$code}();
     } else {
         $this->index();
     }
     $body = ob_get_clean();
     $this->ShowBody($body);
 }
Пример #24
0
 function display()
 {
     Load::model('transaction');
     $Transaction = new Transaction();
     $param['data'] = $Transaction->viewAll();
     Load::view('request', $param);
 }
Пример #25
0
 /**
  * Genera Img Captcha
  *
  */
 public function captcha()
 {
     Load::lib('captcha/captcha');
     View::select(NULL, NULL);
     $captcha = new Captcha();
     $captcha->run();
 }
Пример #26
0
 /**
  * 获取配置信息
  * // 键为字符串并以'.'分隔,第一部份为配置文件
  *
  * @param string $key 选项的键值
  * @param string $package 包名
  *
  * @return mixed
  */
 public function get($key, $package = null)
 {
     if (empty($key)) {
         return null;
     }
     ///
     if (empty($package)) {
         $package = self::PCK_DEFAULT;
     }
     ///
     $keys = explode('.', $key);
     $name = array_shift($keys);
     if (!isset($this->data[$package][$name])) {
         $file = $this->_getFile($name, $package);
         $this->data[$package][$name] = Load::file($file, APP_DIR);
     }
     ///
     $exists = true;
     $conf = $this->data[$package][$name];
     foreach ($keys as $k) {
         if (is_array($conf) && isset($conf[$k])) {
             $conf = $conf[$k];
         } else {
             $exists = false;
             break;
         }
     }
     ///
     return $exists ? $conf : null;
 }
Пример #27
0
 public function __construct()
 {
     $this->load = Load::getInstance();
     $this->load->_autoloadComplement();
     $this->load->library('db');
     $this->db = new db();
 }
Пример #28
0
 function MTagLogic()
 {
     Load::logic('topic');
     $this->TopicLogic = new TopicLogic();
     $this->Config = jconf::get();
     $this->DatabaseHandler =& Obj::registry('DatabaseHandler');
 }
Пример #29
0
    function ModuleObject( $config )
    {
        $this->MasterObject($config);
                $rtype = user()->get('role_type');
        $rtype || $rtype = 'normal';
        $artypes = explode(',', ini('upload.role'));
        if (false === array_search($rtype, $artypes))
        {
            $msg = 'Access Deined';
			if ($this->Code == 'image')
			{
				$ops = array(
					'status' => 'fails',
					'msg' => $msg
				);
			}
			elseif ($this->Code == 'editor')
			{
				$ops = array(
					'error' => 1,
					'message' => $msg
				);
			}
			else
			{
				exit($msg);
			}
			exit(jsonEncode($ops));
        }
        $runCode = Load::moduleCode($this);
        $this->$runCode();
    }
Пример #30
0
 function ModuleObject($config)
 {
     $this->MasterObject($config);
     Load::logic('wall');
     $this->WallLogic = new WallLogic();
     $this->Execute();
 }