Esempio n. 1
0
 public function __construct($name, module $module, $auto_load = 1)
 {
     parent::__construct($name, $name);
     $this->relative_module = $module;
     $this->SetPath("{$this->relative_module->GetPath()}" . DIRECTORY_SEPARATOR . "models" . DIRECTORY_SEPARATOR . "{$this->full_name}{$this->extension}");
     if ($auto_load) {
         $this->Load();
     }
 }
Esempio n. 2
0
 public function __construct($name, module $module)
 {
     if (preg_match('/(\\w+)controller$/i', $name)) {
         $name = preg_replace('/controller$/i', "", $name);
     }
     parent::__construct($name, "{$name}Controller");
     $this->relative_module = $module;
     $this->SetPath("{$this->relative_module->GetPath()}" . DIRECTORY_SEPARATOR . "controllers" . DIRECTORY_SEPARATOR . "{$this->full_name}{$this->extension}");
 }
Esempio n. 3
0
 public function __construct($name, controller $controller)
 {
     if (preg_match('/(\\w+)action$/i', $name)) {
         $name = preg_replace('/action$/i', "", $name);
     }
     parent::__construct($name, "{$name}Action");
     $this->relative_controller = $controller;
     $this->relative_module = $controller->relative_module;
     $this->SetPath($this->relative_controller->GetPath());
 }
Esempio n. 4
0
 public function __construct($name, action $action)
 {
     if (preg_match('/(\\w+)view$/i', $name)) {
         $name = preg_replace('/view$/i', "", $name);
     }
     parent::__construct($name, "{$name}View");
     $this->relative_action = $action;
     $this->relative_controller = $action->relative_controller;
     $this->relative_module = $action->relative_module;
     $this->extension = ".phtml";
     $this->SetViewName($this->name);
 }
Esempio n. 5
0
 public function __construct($name, $path = "", $namespace_prefix = "modules")
 {
     if (preg_match('/(\\w+)module$/i', $name)) {
         $name = preg_replace('/module$/i', "", $name);
     }
     if (!\strlen($path)) {
         $path = MODULE_ROOT . "{$name}Module";
     }
     parent::__construct($name, "{$name}Module");
     $this->SetPath($path);
     $this->namespace_prex = $namespace_prefix;
 }
Esempio n. 6
0
 public function __construct($name, module $module, $auto_load = 1)
 {
     if (preg_match('/(\\w+)helper$/i', $name)) {
         $name = preg_replace('/helper$/i', "", $name);
     }
     parent::__construct($name, "{$name}Helper");
     $this->relative_module = $module;
     $this->SetPath("{$this->relative_module->GetPath()}" . DIRECTORY_SEPARATOR . "views" . DIRECTORY_SEPARATOR . "helper" . DIRECTORY_SEPARATOR . "{$this->full_name}{$this->extension}");
     if ($auto_load) {
         $this->Load();
     }
 }
 /**
  * Routes requests and sets return data
  */
 public function __construct()
 {
     if (class_exists('mvc')) {
         mvc::$view = '#moadmin';
     }
     $this->mongo['dbs'] = self::$model->listDbs();
     if (isset($_GET['db'])) {
         if (strpos($_GET['db'], '.') !== false) {
             $_GET['db'] = $_GET['newdb'];
         }
         self::$model->setDb($_GET['db']);
     }
     if (isset($_POST['limit'])) {
         $_SESSION['limit'] = (int) $_POST['limit'];
     } else {
         if (!isset($_SESSION['limit'])) {
             $_SESSION['limit'] = OBJECT_LIMIT;
         }
     }
     if (isset($_FILES['import']) && is_uploaded_file($_FILES['import']['tmp_name']) && isset($_GET['collection'])) {
         $data = json_decode(file_get_contents($_FILES['import']['tmp_name']));
         self::$model->import($_GET['collection'], $data, $_POST['importmethod']);
     }
     $action = isset($_GET['action']) ? $_GET['action'] : 'listCollections';
     if (isset($_POST['object'])) {
         if (self::$model->saveObject($_GET['collection'], $_POST['object'])) {
             return $this->_dumpFormVals();
         } else {
             $action = 'editObject';
             $_POST['errors']['object'] = 'Error: object could not be saved - check your array syntax.';
         }
     } else {
         if ($action == 'createCollection') {
             self::$model->{$action}($_GET['collection']);
         } else {
             if ($action == 'renameCollection' && isset($_POST['collectionto']) && $_POST['collectionto'] != $_POST['collectionfrom']) {
                 self::$model->{$action}($_POST['collectionfrom'], $_POST['collectionto']);
                 $_GET['collection'] = $_POST['collectionto'];
                 $action = 'listRows';
             }
         }
     }
     if (isset($_GET['sort'])) {
         self::$model->sort = array($_GET['sort'] => $_GET['sortdir']);
     }
     $this->mongo['listCollections'] = self::$model->listCollections();
     if ($action == 'editObject') {
         $this->mongo[$action] = isset($_GET['_id']) ? self::$model->{$action}($_GET['collection'], $_GET['_id'], $_GET['idtype']) : '';
         return;
     } else {
         if ($action == 'removeObject') {
             self::$model->{$action}($_GET['collection'], $_GET['_id'], $_GET['idtype']);
             return $this->_dumpFormVals();
         } else {
             if ($action == 'ensureIndex') {
                 foreach ($_GET['index'] as $key => $field) {
                     $indexes[$field] = isset($_GET['isdescending'][$key]) && $_GET['isdescending'][$key] ? -1 : 1;
                 }
                 self::$model->{$action}($_GET['collection'], $indexes, $_GET['unique'] == 'Unique' ? array('unique' => true) : array());
                 $action = 'listCollections';
             } else {
                 if ($action == 'deleteIndex') {
                     self::$model->{$action}($_GET['collection'], unserialize($_GET['index']));
                     return $this->_dumpFormVals();
                 } else {
                     if ($action == 'getStats') {
                         $this->mongo[$action] = self::$model->{$action}();
                         unset($this->mongo['listCollections']);
                     } else {
                         if ($action == 'repairDb' || $action == 'getStats') {
                             $this->mongo[$action] = self::$model->{$action}();
                             $action = 'listCollections';
                         } else {
                             if ($action == 'dropDb') {
                                 self::$model->{$action}();
                                 load::redirect(get::url());
                                 return;
                             }
                         }
                     }
                 }
             }
         }
     }
     if (isset($_GET['collection']) && $action != 'listCollections' && method_exists(self::$model, $action)) {
         $this->mongo[$action] = self::$model->{$action}($_GET['collection']);
         $this->mongo['count'] = self::$model->count;
         $this->mongo['colKeys'] = self::$model->colKeys;
     }
     if ($action == 'listRows') {
         $this->mongo['listIndexes'] = self::$model->listIndexes($_GET['collection']);
     } else {
         if ($action == 'dropCollection') {
             return load::redirect(get::url() . '?db=' . urlencode($_GET['db']));
         }
     }
 }
 /**
  * Routes requests and sets return data
  */
 public function __construct()
 {
     if (class_exists('mvc')) {
         mvc::$view = '#moadmin';
     }
     $this->mongo['dbs'] = self::$model->listDbs();
     if (isset($_GET['db'])) {
         if (strpos($_GET['db'], '.') !== false) {
             $_GET['db'] = $_GET['newdb'];
         }
         self::$model->setDb($_GET['db']);
     }
     if (isset($_POST['limit'])) {
         $_SESSION['limit'] = (int) $_POST['limit'];
     } else {
         if (!isset($_SESSION['limit'])) {
             $_SESSION['limit'] = OBJECT_LIMIT;
         }
     }
     $action = isset($_GET['action']) ? $_GET['action'] : 'listCollections';
     if (isset($_POST['object'])) {
         $obj = self::$model->saveObject($_GET['collection'], $_POST['object']);
         $_GET['_id'] = $obj['_id'];
         $action = 'listRows';
     } else {
         if ($action == 'createCollection') {
             self::$model->{$action}($_GET['collection']);
         }
     }
     if (isset($_GET['sort']) && is_array($_GET['sort'])) {
         self::$model->sort = $_GET['sort'];
     }
     $this->mongo['listCollections'] = self::$model->listCollections();
     if ($action == 'editObject') {
         $this->mongo[$action] = isset($_GET['_id']) ? self::$model->{$action}($_GET['collection'], $_GET['_id'], $_GET['idtype']) : '';
         return;
     } else {
         if ($action == 'removeObject') {
             self::$model->{$action}($_GET['collection'], $_GET['_id'], $_GET['idtype']);
             $action = 'listRows';
         } else {
             if ($action == 'ensureIndex') {
                 foreach ($_GET['index'] as $key => $field) {
                     $indexes[$field] = isset($_GET['isdescending'][$key]) && $_GET['isdescending'][$key] ? -1 : 1;
                 }
                 self::$model->{$action}($_GET['collection'], $indexes, $_GET['unique'] == 'Unique' ? array('unique' => true) : array());
                 $action = 'listCollections';
             } else {
                 if ($action == 'deleteIndex') {
                     self::$model->{$action}($_GET['collection'], unserialize($_GET['index']));
                     $action = 'listRows';
                 } else {
                     if ($action == 'getStats') {
                         $this->mongo[$action] = self::$model->{$action}();
                         unset($this->mongo['listCollections']);
                     } else {
                         if ($action == 'repairDb' || $action == 'getStats') {
                             $this->mongo[$action] = self::$model->{$action}();
                             $action = 'listCollections';
                         } else {
                             if ($action == 'dropDb') {
                                 self::$model->{$action}();
                                 header('Location: ' . $_SERVER['SCRIPT_NAME']);
                                 return;
                             }
                         }
                     }
                 }
             }
         }
     }
     if (isset($_GET['collection']) && $action != 'listCollections' && method_exists(self::$model, $action)) {
         $this->mongo[$action] = self::$model->{$action}($_GET['collection']);
         $this->mongo['count'] = self::$model->count;
         $this->mongo['colKeys'] = self::$model->colKeys;
     }
     if ($action == 'listRows') {
         $this->mongo['listIndexes'] = self::$model->listIndexes($_GET['collection']);
     } else {
         if ($action == 'dropCollection') {
             $this->mongo['listCollections'] = self::$model->listCollections();
         }
     }
 }
Esempio n. 9
0
 /**
  * Merges the existing data if there is with this one. Chainable.
  *
  * @return void 
  */
 public function add($d, $data = array())
 {
     $o = new mvc($d, $this, $data);
     if ($o->check()) {
         return $o;
     }
     return false;
 }
Esempio n. 10
0
    switch ($key) {
        case 0:
            $array_uri['controller'] = $val;
            break;
        case 1:
            $array_uri['method'] = $val;
            break;
        default:
            $array_uri['var'][] = $val;
    }
}
if (isset($_SESSION['log'])) {
    // Show the header for user. -> Only show it when the user is logged in.. otherwize the login view will be very weird.
    include_once "../application/view/user/_header.php";
}
$app = new mvc($array_uri);
$app->loadController($array_uri['controller']);
?>

  <!-- footer -->
  <footer>
    <div class="footer">
      Copyright &copy; Sin Limites, 2014
    </div><!-- /footer -->
  </footer>
</div><!-- /container -->

  </body>
  <!-- key=AIzaSyDGwUpTVd6XKuYSpd2dJeEBfC4KDCYxNIs& -->

</html>
 public static function log($name, $data)
 {
     @file_put_contents(mvc::app()->getUploadPath() . mvc::DIR_SEP . 'log' . mvc::DIR_SEP . basename($name) . '_' . date('YmdHis') . '.txt', print_r($data, 1));
 }