Example #1
0
 public function __construct($buttons = array())
 {
     if ($GLOBALS['toolbar_stylesheet'] === false) {
         Application::preAddStylesheet("css/toolbar.css", Application::getWyfHome("toolbar/"));
     } else {
         Application::preAddStylesheet($GLOBALS['toolbar_stylesheet']);
     }
     $this->buttons = $buttons;
 }
Example #2
0
File: Table.php Project: nthc/cfx
 public function __construct($prefix, $headers = null, $data = null, $operations = null, $headerParams = null)
 {
     if (class_exists("Application")) {
         Application::addStyleSheet("/tapi.css", Application::getWyfHome('tapi/css'));
     }
     $this->prefix = $prefix;
     $this->headers = $headers;
     $this->data = $data;
     $this->operations = $operations;
 }
Example #3
0
 public function __construct($prefix, $headers = null, $data = null, $operations = null, $headerParams = null)
 {
     if ($GLOBALS['fapi_stylesheet'] === false) {
         Application::preAddStylesheet("css/tapi.css", Application::getWyfHome("tapi/"));
     } else {
         Application::preAddStylesheet($GLOBALS['tapi_stylesheet']);
     }
     $this->prefix = $prefix;
     $this->headers = $headers;
     $this->data = $data;
     $this->operations = $operations;
 }
Example #4
0
add_include_path($directoryPath . "constraints", false);
add_include_path($directoryPath . "login", false);
add_include_path($directoryPath . "logout", false);
add_include_path($directoryPath . "password_history", false);
add_include_path($directoryPath . "role_validity", false);
add_include_path($directoryPath . "roles", false);
add_include_path($directoryPath . "users", false);
add_include_path($directoryPath . "users_roles", false);
//Add lib for auth
add_include_path(__DIR__ . "/lib", false);
// Load the applications configuration file and define the home
require "app/config.php";
define("SOFTWARE_HOME", $config['home']);
// Add the script which contains the third party libraries
require "app/includes.php";
// Setup the global variables needed by the redirected packages
global $redirectedPackage;
global $packageSchema;
$selected = getenv('CFX_SELECTED_DATABASE') !== false ? getenv('CFX_SELECTED_DATABASE') : $selected;
// Setup the database driver and other boilerplate stuff
$dbDriver = $config['db'][$selected]['driver'];
$dbDriverClass = Application::camelize($dbDriver);
add_include_path(Application::getWyfHome("models/datastores/databases/{$dbDriver}"));
Db::$defaultDatabase = $selected;
SQLDBDataStore::$activeDriverClass = $dbDriverClass;
Application::$config = $config;
Application::$prefix = $config['prefix'];
Cache::init($config['cache']['method']);
define('CACHE_MODELS', $config['cache']['models']);
define('CACHE_PREFIX', "");
define('ENABLE_AUDIT_TRAILS', $config['audit_trails']);
Example #5
0
 public function __construct($buttons = array())
 {
     Application::addStyleSheet("css/toolbar.css", Application::getWyfHome("toolbar/"));
     $this->buttons = $buttons;
 }
Example #6
0
 /**
  * Provides all the necessary forms needed to start an update.
  * @param $params
  * @return string
  */
 public function import()
 {
     $this->label = "Import " . $this->label;
     $form = new Form();
     $form->add(Element::create("UploadField", "File", "file", "Select the file you want to upload."), Element::create("Checkbox", "Break on errors", "break_on_errors", "", "1")->setValue("1"));
     $form->addAttribute("style", "width:50%");
     $form->setCallback($this->getClassName() . '::importCallback', $this);
     $form->setSubmitValue('Import Data');
     return $this->arbitraryTemplate(Application::getWyfHome('model_controller/import.tpl'), array('form' => $form->render(), 'template' => "{$this->path}/export/csv?template=yes"));
 }
Example #7
0
 public function getContents()
 {
     $form = $this->getForm();
     $data = array("script" => $this->script, "filters" => $form->render());
     return $this->arbitraryTemplate(Application::getWyfHome("controllers/reports.tpl"), $data);
 }
Example #8
0
 public function render($headers = true)
 {
     global $redirectedPackage;
     $results = $this->tableData;
     $this->fields = $results["fieldInfos"];
     foreach ($this->fields as $field) {
         if ($field["type"] == "number" || $field["type"] == "double" || $field["type"] == "integer") {
             $this->headerParams[$field["name"]]["type"] = "number";
         }
     }
     $this->headers = $results["headers"];
     array_shift($this->headers);
     if ($headers === true) {
         $table = $this->renderHeader();
     }
     if ($this->useAjax) {
         $table .= "<tr>\n                <td align='center' colspan='" . count($this->headers) . "'>\n                    <img style='margin:80px' src='/" . Application::getLink(Application::getWyfHome("tapi/images/loading-image-big.gif")) . "' />\n                </td></tr>";
     } else {
         $this->data = $results["data"];
         $table .= parent::render(false);
     }
     if ($headers === true) {
         $table .= $this->renderFooter();
     }
     if ($this->useAjax) {
         $this->params['redirected_package'] = $redirectedPackage;
         $table .= "<div id='{$this->name}-operations'></div>\n            <script type='text/javascript'>\n                wyf.tapi.addTable('{$this->name}',(" . json_encode($this->params) . "));\n                var externalConditions = [];\n                var externalBoundData = [];\n                function {$this->name}Search()\n                {\n                    var conditions = '';\n                    var boundData = [];\n                    {$this->searchScript}\n                    wyf.tapi.tables['{$this->name}'].filter = conditions;\n                    wyf.tapi.tables['{$this->name}'].bind = boundData;\n                    if(externalConditions['{$this->name}'])\n                    {\n                        wyf.tapi.tables['{$this->name}'].filter += ((conditions != '' ?' AND ':'') + externalConditions['{$this->name}']);\n                        wyf.tapi.tables['{$this->name}'].bind = boundData.concat(externalBoundData);\n                    }\n                    wyf.tapi.tables['{$this->name}'].page = 0;\n                    wyf.tapi.render(wyf.tapi.tables['{$this->name}']);\n                }\n            </script>";
     }
     return $table;
 }
Example #9
0
<?php

add_include_path(Application::getWyfHome('modules/system/audit_trail'));
/**
 * A model represents an abstract data storing entity. Models are used to access
 * data.
 *  
 * @author james
 */
abstract class Model implements ArrayAccess
{
    const MODE_ASSOC = "assoc";
    const MODE_ARRAY = "array";
    const TRANSACTION_MODE_ADD = "add";
    const TRANSACTION_MODE_EDIT = "edit";
    /**
     * @todo rename this to hooks
     * @var unknown_type
     */
    //protected $services;
    public $name;
    public $prefix;
    public $package;
    public $database;
    public $label;
    public $description;
    public $showInMenu;
    public $queryResolve = true;
    public $queryExplicitRelations = false;
    public $queryMode = Model::MODE_ASSOC;
    public $storedFields;
Example #10
0
                    $i++;
                }
                $item = str_replace("_", " ", $item);
                $item = ucwords($item);
                $top_menu .= "<a href='" . Application::getLink($link) . "'><span>{$item}</span></a>";
            }
            Application::$templateEngine->assign('top_menu', $top_menu);
        }
    }
}
// Log the route into the audit trail if it is enabled
if ($_SESSION['logged_in'] == true && $_GET['q'] != 'system/api/table' && ENABLE_AUDIT_TRAILS === true) {
    $data = json_encode(array('route' => $_GET['q'], 'request' => $_REQUEST, 'get' => $_GET, 'post' => $_POST));
    if (class_exists("SystemAuditTrailModel", false) && ENABLE_ROUTING_TRAILS === true) {
        SystemAuditTrailModel::log(array('item_id' => '0', 'item_type' => 'routing_activity', 'description' => "Accessed [{$_GET['q']}]", 'type' => SystemAuditTrailModel::AUDIT_TYPE_ROUTING, 'data' => $data));
    }
}
// Load the styleseets and the javascripts
if ($GLOBALS['fapi_stylesheet'] === false) {
    Application::preAddStylesheet("css/fapi.css", Application::getWyfHome("fapi/"));
} else {
    Application::preAddStylesheet($GLOBALS['fapi_stylesheet']);
}
Application::preAddStylesheet("kalendae/kalendae.css", Application::getWyfHome('assets/js/'));
Application::preAddStylesheet("css/main.css");
Application::addStylesheet('css/rapi.css', Application::getWyfHome('rapi/'));
Application::addJavaScript(Application::getLink(Application::getWyfHome("fapi/js/fapi.js")));
Application::addJavaScript(Application::getLink(Application::getWyfHome("assets/js/jquery.js")));
Application::addJavaScript(Application::getLink(Application::getWyfHome("assets/js/kalendae/kalendae.js")));
// Blast the HTML code to the browser!
Application::render();
Example #11
0
 public function notes($params)
 {
     $noteAttachments = Model::load('system.note_attachments');
     if ($params[1] == 'delete') {
         $model = Model::load('system.notes');
         $model->delete('note_id', $params[2]);
         Application::redirect("{$this->path}/notes/{$params[0]}");
     }
     if (isset($_POST['is_form_sent'])) {
         $model = Model::load('system.notes');
         $model->datastore->beginTransaction();
         $data = array('note' => $_POST['note'], 'note_time' => time(), 'item_id' => $params[0], 'user_id' => $_SESSION['user_id'], 'item_type' => $this->model->package);
         $model->setData($data);
         $id = $model->save();
         for ($i = 1; $i < 5; $i++) {
             $file = $_FILES["attachment_{$i}"];
             if ($file['error'] == 0) {
                 $noteAttachments->setData(array('note_id' => $id, 'description' => $file['name'], 'object_id' => PgFileStore::addFile($file['tmp_name'])));
                 $noteAttachments->save();
             }
         }
         $model->datastore->endTransaction();
         Application::redirect("{$this->urlPath}/notes/{$params[0]}");
     }
     $notes = SQLDBDataStore::getMulti(array('fields' => array('system.notes.note_id', 'system.notes.note', 'system.notes.note_time', 'system.users.first_name', 'system.users.last_name'), 'conditions' => Model::condition(array('item_type' => $this->model->package, 'item_id' => $params[0]))));
     foreach ($notes as $i => $note) {
         $attachments = $noteAttachments->getWithField2('note_id', $note['note_id']);
         foreach ($attachments as $j => $attachment) {
             $attachments[$j]['path'] = PgFileStore::getFilePath($attachment['object_id'], $attachment['description']);
         }
         $notes[$i]['attachments'] = $attachments;
     }
     $this->label = "Notes on item";
     $form = Element::create('Form')->add(Element::create('TextArea', 'Note', 'note'), Element::create('FieldSet', 'Add Attachments')->add(Element::create('UploadField', 'Attachment', 'attachment_1'), Element::create('UploadField', 'Attachment', 'attachment_2'), Element::create('UploadField', 'Attachment', 'attachment_3'), Element::create('UploadField', 'Attachment', 'attachment_4'))->setId('attachments')->setCollapsible(true))->setRenderer('default');
     return $this->arbitraryTemplate(Application::getWyfHome('controllers/notes.tpl'), array('form' => $form->render(), 'notes' => $notes, 'route' => $this->path, 'id' => $params[0]));
 }
Example #12
0
 /**
  * Provides all the necessary forms needed to start an update.
  * @param $params
  * @return string
  */
 public function import()
 {
     $this->label = "Import " . $this->label;
     $entity = $this->model->getEntity();
     $path = $this->urlPath;
     $form = new Form();
     $form->setRenderer('default');
     $form->add(Element::create("HTMLBox", "This import utility would assist you to import new {$entity} into your database. You are expected to upload a CSV file which contains the data you want to import." . " <p>Please click <a href='{$path}/export/csv?template=yes'>here</a> to download a template csv file.</p>"), Element::create("UploadField", "File", "file", "Select the file you want to upload."));
     $form->addAttribute("style", "width:50%");
     $form->setCallback($this->getClassName() . '::importCallback', $this);
     $form->setSubmitValue('Import Data');
     return $this->arbitraryTemplate(Application::getWyfHome('utils/model_controller/templates/import.tpl'), array('form' => $form->render()));
 }