/** * Fetches locale for a certain language application combo * * @param string $language * @param string $application * * @return array */ protected function getLocale($language, $application) { return (array) $this->database->getRecords('SELECT type, module, name, value FROM locale WHERE language = ? AND application = ? ORDER BY type ASC, name ASC, module ASC', array($language, $application)); }
/** * Build the language files * * @return void * @param SpoonDatabase $db The database connection instance. * @param string $language The language to build the locale-file for. * @param string $application The application to build the locale-file for. */ public function buildCache(SpoonDatabase $db, $language, $application) { // get types $types = $db->getEnumValues('locale', 'type'); // get locale for backend $locale = (array) $db->getRecords('SELECT type, module, name, value FROM locale WHERE language = ? AND application = ? ORDER BY type ASC, name ASC, module ASC', array((string) $language, (string) $application)); // start generating PHP $value = '<?php' . "\n"; $value .= '/**' . "\n"; $value .= ' *' . "\n"; $value .= ' * This file is generated by the Installer, it contains' . "\n"; $value .= ' * more information about the locale. Do NOT edit.' . "\n"; $value .= ' * ' . "\n"; $value .= ' * @author Installer' . "\n"; $value .= ' * @generated ' . date('Y-m-d H:i:s') . "\n"; $value .= ' */' . "\n"; $value .= "\n"; // loop types foreach ($types as $type) { // default module $modules = array('core'); // continue output $value .= "\n"; $value .= '// init var' . "\n"; $value .= '$' . $type . ' = array();' . "\n"; $value .= '$' . $type . '[\'core\'] = array();' . "\n"; // loop locale foreach ($locale as $i => $item) { // types match if ($item['type'] == $type) { // new module if (!in_array($item['module'], $modules)) { $value .= '$' . $type . '[\'' . $item['module'] . '\'] = array();' . "\n"; $modules[] = $item['module']; } // parse if ($application == 'backend') { $value .= '$' . $type . '[\'' . $item['module'] . '\'][\'' . $item['name'] . '\'] = \'' . str_replace('\\"', '"', addslashes($item['value'])) . '\';' . "\n"; } else { $value .= '$' . $type . '[\'' . $item['name'] . '\'] = \'' . str_replace('\\"', '"', addslashes($item['value'])) . '\';' . "\n"; } // unset unset($locale[$i]); } } } // close php $value .= "\n"; $value .= '?>'; // store SpoonFile::setContent(PATH_WWW . '/' . $application . '/cache/locale/' . $language . '.php', $value); }
/** * Fetch the data as an array. * * @return array * @param int[optional] $offset The offset to start from. * @param int[optional] $limit The maximum number of items to retrieve. * @param string[optional] $order The column to order on. * @param string[optional] $sort The sorting method. */ public function getData($offset = null, $limit = null, $order = null, $sort = null) { // fetch query $query = $this->query; // order & sort defined if ($order !== null && $sort !== null) { $query .= ' ORDER BY ' . $order . ' ' . $sort; } // offset & limit defined if ($offset !== null && $limit !== null) { $query .= ' LIMIT ' . $offset . ', ' . $limit; } // fetch data return (array) $this->db->getRecords($query, $this->queryParameters); }
/** * Fetch the data as an array. * * @return array * @param int[optional] $offset * @param int[optional] $limit * @param string[optional] $order * @param string[optional] $sort */ public function getData($offset = null, $limit = null, $order = null, $sort = null) { // fetch query $query = $this->query; // order & sort defined if ($order !== null && $sort !== null) { $query .= " ORDER BY {$order} {$sort}"; } // offset & limit defined if ($offset !== null && $limit !== null) { $query .= " LIMIT {$offset}, {$limit}"; } // fetch data return (array) $this->db->getRecords($query, $this->queryParameters); }
/** * Returns an array containing all widgets * * @return string */ protected function getSitemapId() { if (empty($this->sitemapId)) { $widgets = (array) $this->database->getRecords('SELECT i.id, i.module, i.action FROM modules_extras AS i WHERE i.type = ? AND i.hidden = ?', array('widget', 'N'), 'id'); // search sitemap foreach ($widgets as $id => $row) { if ($row['action'] == 'Sitemap') { $this->sitemapId = $id; break; } } } return $this->sitemapId; }
public function index() { //die(); $this->load->model("clientdb"); include __DIR__ . "/../../../../clientManager_new/cm_includes/spoon/spoon.php"; $mysql = new SpoonDatabase("mysql", "localhost", "root", "", "clienthub"); $source = $mysql->getRecords("SELECT * FROM profiles"); /*for($i=1; $i<=1683; $i++){ $gravatar = null; if(isset($source[$i-1]["photo"])){ $gravatar = $source[$i-1]['photo'].".".$source[$i-1]['photoext']; } $this->db->insert('clients', array('name' => $source[$i-1]['name'], "gravatar" => $gravatar, "status" => ($source[$i-1]['status'] == "trash" ? "trash" : "active"))); }*/ foreach ($source as $num => $row) { $data = array('id' => $row["id"], 'file' => $row["file"], 'case' => $row["case"], 'ic' => $row["ic"], 'sex' => $row["gender"] == null ? null : ($row["gender"] == "male" ? "男" : "女"), 'placeofbirth' => $row["placeofbirth"], 'education' => $row["education"], 'language' => $row["language"], 'race' => $row["race"], 'faith' => $row["faith"], 'maritalstatus' => $row["maritalstatus"] == "Married" ? "已婚" : ($row["maritalstatus"] == "Singer" ? "单身" : "不详"), 'nationality' => $row["nationality"], 'profession' => $row["profession"], 'address' => $row["address"], 'epf' => $row["epf"], 'banker' => $row["banker"], 'contactno' => $row["contactno"], 'email' => $row["email"], 'platesno' => $row["platesno"], 'asset' => $row["assets"], 'height' => $row["height"], 'weight' => $row["weight"], 'blood' => $row["blood"], 'eye' => $row["eye"], 'hair' => $row["hair"], 'skin' => $row["skin"], 'dna' => $row["dna"], 'case' => $row["casereport"], 'family' => $row["family"], 'company' => implode(" ", explode(", ", $row["company"])), 'remarks' => $row["remarks"]); $this->db->insert('clientsdata', $data); } }
date_default_timezone_set('Europe/Berlin'); // set include path ini_set("include_path", ".:../library/"); // required classes require_once 'spoon/spoon.php'; require_once 'publicApp/publicApp.php'; $tpl = new SpoonTemplate(); $tpl->setForceCompile(true); $tpl->setCompileDirectory('./compiled_templates'); // do I know you? if (SpoonSession::exists('public_uid')) { $tpl->assign('oLogout', true); $tpl->assign('oNavMe', true); $uid = SpoonSession::get('public_uid'); $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public'); $checkins = $db->getRecords('SELECT * FROM checkins WHERE user_id = ?', $uid); $user = new User($uid); $tpl->assign('daysActive', 'NOT ENOUGH DATA'); $tpl->assign('checkins', count($checkins)); $tpl->assign('avgDrinks', 'NOT ENOUGH DATA'); $tpl->assign('avgDay', 'NOT ENOUGH DATA'); $tpl->assign('topFriends', 'NOT ENOUGH DATA'); if ($user->GetTopPubs(5) !== null) { $tpl->assign('oTopPubs', true); $tpl->assign('iTopPubs', $user->GetTopPubs(5)); } else { $tpl->assign('oNoTopPubs', true); } } else { //GTFO!!! SpoonHTTP::redirect('index.php');
/** * @depends testExecute */ public function testGetRecords() { $this->assertEquals(100, count($this->db->getRecords('SELECT * FROM users WHERE id != ? LIMIT 100', 1337))); $this->assertEquals(100, count($this->db->getRecords('SELECT * FROM users WHERE id != :id LIMIT 100', array(':id' => 1337)))); }
header('Location: ' . BASE_URL . '/login.php'); } } //loading mysql system $mysql = new SpoonDatabase('mysql', MYSQL_HOST, MYSQL_UN, MYSQL_PW, MYSQL_DB); if (defined('LOAD_TEMPLATE')) { //loading template system $tpl = new SpoonTemplate(); $tpl->setForceCompile(true); $tpl->setCompileDirectory(COMPILE_PATH); //loading $tpl->assign('title', SITE_TITLE); $tpl->assign('base_url', BASE_URL); $tpl->assign('css_path', BASE_URL . '/' . CONTENTS_PATH . '/css/style.css'); $tpl->assign('jquery_path', BASE_URL . '/' . CONTENTS_PATH . '/js/jquery-1.6.4.min.js'); $tpl->assign('profiles_total', count($mysql->getRecords('SELECT `id` FROM `profiles` WHERE `status` != \'trash\''))); $tpl->assign('expired', round(($_SESSION['expired'] - time()) / 60, 1)); //expired time in minutes $tpl->assign('adminname', md5(ADMINNAME)); $tpl->assign('adminpw', md5(ADMINPASSWORD)); } if (defined('IN_LOGIN')) { $tpl->assign('login', true); } if (defined('LOAD_TEMPLATE') && defined('LOAD_HEADER')) { $tpl->display(ROOT_PATH . '/' . TEMPLATE_PATH . '/header.tpl.php'); } function setMulAttributes(&$frm, array $id, $key, $value, $type = 'Text') { $function = "add" . $type; foreach ($id as $element) {