function getNice() { if ($this->config['source']['type'] == 'table' && isset($this->config['source']['name'])) { global $thinkedit; $config = new config(); //$table = $thinkedit->newTable($this->config['source']['name']); // //$source->filter('id', '=', $this->getRaw()); $source_table = $this->config['source']['name']; $title_fields = $config->getTitleFields($source_table); require_once 'query.class.php'; $query = new query(); $query->addTable($this->config['source']['name']); $query->addWhere('id', '=', $this->getRaw()); $results = $query->select(); if (count($results) > 0) { foreach ($config->getTitleFields($source_table) as $field) { $out .= $results[0][$field] . ' '; } return $out; } else { return $this->getRaw(); } } else { return $this->getRaw(); } }
/** * Create a image from a file. Do not add the file to the object library * @param string Path to the source file * @param string Description Text for ALT-Tag * @param string Copright text for the image * @param string Variation-ID of the image */ function createImageFromFile($sourceFile, $alt = "", $copyright = "", $variation = 1, $categoryId = 1) { global $c, $db; $id = nextGUID(); $info = pathinfo($sourceFile); $extension = $info["extension"]; $extension2 = strtoupper($extension); $name = parseSQL($info["basename"]); if ($extension2 == "JPG" || $extension2 == "GIF" || $extension2 == "PNG") { $size = getimagesize($sourceFile); $width = $size[0]; $height = $size[1]; copy($sourceFile, $c["devfilespath"] . $id . "." . $extension); $thumb = new Img2Thumb($c["devfilespath"] . $id . "." . $extension, 120, 120, $c["devfilespath"] . "t" . $id); $sql = "INSERT INTO pgn_image (FKID, FILENAME, ALT, COPYRIGHT, WIDTH, HEIGHT) VALUES "; $sql .= "({$id}, '{$id}.{$extension}', '{$alt}', '{$copyright}', {$width}, {$height})"; $query = new query($db, $sql); $query->free(); // Create Library Entry for this image $cid = nextGUID(); $imageModule = getDBCell("modules", "MODULE_ID", "MODULE_NAME='Image'"); $sql = "INSERT INTO content (CID, MODULE_ID, NAME, CATEGORY_ID, MT_ID) VALUES "; $sql .= "({$cid}, {$imageModule}, '{$name}', {$categoryId}, 0)"; $query = new query($db, $sql); $query->free(); $sql = "INSERT INTO content_variations (CID, VARIATION_ID, FK_ID) VALUES "; $sql .= "({$cid}, {$variation}, {$id})"; $query = new query($db, $sql); $query->free(); return $cid; } else { return null; } }
public static function get_by_report($report_id) { $q = new query(RUDE_DATABASE_TABLE_EDUCATION_PREVIEW); $q->where(RUDE_DATABASE_FIELD_REPORT_ID, (int) $report_id); $q->query(); return $q->get_object_list(); }
/** * @return query */ public function getQuery() { $query = new query(); $query->setArguments($this->args); $query->setQueryString($this->query); return $query; }
public static function get_by_shortname($shortname) { $q = new query(RUDE_DATABASE_TABLE_FACULTIES); $q->where(RUDE_DATABASE_FIELD_SHORTNAME, $shortname); $q->query(); return $q->get_object(); }
/** * syncronize variations with entered data to the database. * The configuration for this function must be set manually. * I.E. there must be the $oid-Variable set and there must(!) * be also the global vars content_variations_VARIATION_ID_XX * and content_MODULE_ID * set which are automatically set by the SelectMultiple2Input. */ function syncVariations() { global $db, $oid, $content_MODULE_ID; $module = value("content_MODULE_ID", "NUMERIC"); if ($module == "0") { $module = $content_MODULE_ID; } includePGNSource($module); //delete all variations first. $del = "UPDATE content_variations SET DELETED=1 WHERE CID = {$oid}"; $query = new query($db, $del); // get list of variations $variations = createNameValueArray("variations", "NAME", "VARIATION_ID", "DELETED=0"); for ($i = 0; $i < count($variations); $i++) { $id = $variations[$i][1]; if (value("content_variations_VARIATION_ID_" . $id) != "0") { // create or restore variation // check, if variations already exists and is set to deleted. $sql = "SELECT COUNT(CID) AS ANZ FROM content_variations WHERE CID = {$oid} AND VARIATION_ID = {$id}"; $query = new query($db, $sql); $query->getrow(); $amount = $query->field("ANZ"); if ($amount > 0) { $sql = "UPDATE content_variations SET DELETED=0 WHERE CID = {$oid} AND VARIATION_ID = {$id}"; } else { $fk = nextGUID(); $sql = "INSERT INTO content_variations (CID, VARIATION_ID, FK_ID, DELETED) VALUES ( {$oid}, {$id}, {$fk}, 0)"; $PGNRef = createPGNRef($module, $fk); $PGNRef->sync(); } $query = new query($db, $sql); } } }
/** * Find clusters, in which a plugin-entry is used. * @param integer ID of the plugin-Key */ function findContentUsageClusterNodes($oid) { global $db; // Initializing Array $clusters = array(); // Determine cluster_templates using the object as static content... $sql = "SELECT CLT_ID FROM cluster_template_items WHERE FKID = {$oid}"; $query = new query($db, $sql); while ($query->getrow()) { // Determine clusters using this template $sql = "SELECT CLNID FROM cluster_node WHERE CLT_ID = " . $query->field("CLT_ID"); $subquery = new query($db, $sql); while ($subquery->getrow()) { array_push($clusters, $subquery->field("CLNID")); } $subquery->free(); } $query->free(); // determine clusters using this content as library link... $sql = "SELECT CLID FROM cluster_content WHERE FKID = {$oid} OR CLCID = {$oid}"; $query = new query($db, $sql); while ($query->getrow()) { // Determine clusters using this template $sql = "SELECT CLNID FROM cluster_variations WHERE CLID=" . $query->field("CLID"); $subquery = new query($db, $sql); while ($subquery->getrow()) { array_push($clusters, $subquery->field("CLNID")); } $subquery->free(); } $query->free(); $clusters = array_unique($clusters); return $clusters; }
/** * save the changes... */ function process() { global $errors, $selected, $create, $sitepage_CLNID, $cluster_node_NAME, $db, $oid, $sid, $clt; $this->check(); if ($selected != "0" && $sitepage_CLNID != "0" && $sitepage_CLNID != "") { $mid = getVar("mid"); $sql = "UPDATE sitepage SET CLNID = {$sitepage_CLNID} WHERE SPID = {$oid}"; $query = new query($db, $sql); $query->free(); // reload page, now in editing mode... global $db; $db->close(); header("Location: sitepagebrowser.php?sid={$sid}&mid={$mid}&action=editobject&go=update&oid={$oid}"); exit; } else { if ($create != "0" && $errors == "") { $mid = getVar("mid"); $nextId = nextGUID(); $sql = "INSERT INTO cluster_node (CLNID, CLT_ID, NAME, DELETED) VALUES({$nextId}, {$clt}, '{$cluster_node_NAME}', 0)"; $query = new query($db, $sql); $sql = "UPDATE sitepage SET CLNID = {$nextId} WHERE SPID = {$oid}"; $query = new query($db, $sql); $query->free(); $backup = $oid; $oid = $nextId; syncClusterVariations(); $oid = $backup; global $db; $db->close(); header("Location: sitepagebrowser.php?sid={$sid}&mid={$mid}&action=editobject&go=update&oid={$oid}"); exit; } } }
public static function get_by_name($name) { $q = new query(RUDE_DATABASE_TABLE_QUALIFICATIONS); $q->where(RUDE_DATABASE_FIELD_NAME, $name); $q->query(); return $q->get_object(); }
/** * scope by detail to be used by google maps in dashboard * @param query $query query object * @return mixed new query object */ public function scopeMap($query) { $attrs = ['data_type', 'problem_type', 'code', 'name', 'lat', 'lng', 'tambon_name', 'amphoe_name', 'province_name', 'part', 'basin']; // $attrs = ['problem_type', 'code', 'name', 'lat', 'lng', 'tambon_name', 'amphoe_name', 'province_name', 'part', 'basin']; $query->join('tele_station', 'problems.station_code', '=', 'tele_station.code')->selectRaw(implode(", ", $attrs) . ', sum(num) as num')->groupBy($attrs); return $query; }
public static function get_by_order($education_id) { $q = new query(RUDE_DATABASE_TABLE_EDUCATION_ITEMS_VALUES); $q->where('education_id', (int) $education_id); $q->order_by('order_num', 'ASC'); $q->query(); return $q->get_object_list(); }
public static function get_popup($user_id) { $q = new query(RUDE_DATABASE_TABLE_SETTINGS); $q->where(RUDE_DATABASE_FIELD_USER_ID, (int) $user_id); $q->where(RUDE_DATABASE_FIELD_NAME, 'popup'); $q->query(); return $q->get_object(); }
function loginUser($user_id) { $query = new query(); $row = $query->getRow("idusuario, nombreusuario, tipousuario", "usuario", "WHERE idusuario = {$user_id}"); $_SESSION['logged'] = 1; $_SESSION['nombreusuario'] = $row['nombreusuario']; $_SESSION['idusuario'] = $row['idusuario']; $_SESSION['tipousuario'] = $row['tipousuario']; }
/** * Draw a teaser defined with the teaser plugin * @id internal id of the teaser. matched pgn_teaser.fkid. */ function drawPGNTeaser($id) { global $cds, $db; $result = ''; $query = new query($db, "Select * FROM pgn_teaser Where FKID=" . $id); if ($query->getrow()) { $href = $query->field("HREF"); if (substr($href, 0, 4) == "www.") { $href = 'http://' . $href; } $popup = $href != ""; $spid = $query->field('SPID'); if ($spid != "0" && $href == "") { $menu = new Menu(null, $spid, $cds->variation, $cds->level); $href = $menu->getLink(); } $imageid = $query->field("IMAGEID"); $aTag = '<a href="' . $href . '"'; if ($popup) { $aTag .= ' target="_blank"'; } $aTag .= '>'; // image teaser if ($query->field("ISIMAGETEASER") == "1") { $result = $aTag . $cds->content->getById($imageid) . '</a>'; } else { // usual teaser $headline = $query->field("HEADLINE"); $body = $query->field("BODY"); $linktext = $query->field("LINKTEXT"); if ($linktext == "") { $linktext = "read more"; } $result = '<div class="teaser">'; if ($headline != "") { $result .= '<b>' . $headline . '</b><br>'; } if ($imageid != "0") { $result .= $aTag . $cds->content->getById($imageid) . '</a><br>'; } if ($body != "") { $result .= $body; } if ($query->field("RESOLVECHILDS") != "1" || $spid == "0" && $href == "") { $result .= ' ' . $aTag . $linktext . '</a>'; } else { $childs = $menu->lowerLevel(); for ($i = 0; $i < count($childs); $i++) { $result .= '<br/>'; $result .= $childs[$i]->getTag(); } } $result .= '</div>'; } } return $result; }
/** * Deletes a variable from the variable stack * @param string name of the variable */ function delVar($name) { $back = ""; global $auth, $db; $userId = $auth->userId; $sql = "DELETE FROM temp_vars WHERE USER_ID=$userId and NAME='$name'"; $query = new query($db, $sql); $query->free(); }
public static function is_exists($name) { $q = new query(RUDE_DATABASE_TABLE_TRAINING_FORM); $q->where(RUDE_DATABASE_FIELD_NAME, $name); $q->query(); if ($q->get_object()) { return true; } return false; }
public static function is_exists($id) { $q = new query(RUDE_DATABASE_TABLE_USERS); $q->where(RUDE_DATABASE_FIELD_ID, (int) $id); $q->query(); if ($q->get_object()) { return true; } return false; }
function syncClids() { global $db, $form; $counter = 0; $sql = "SELECT cv.CLID FROM cluster_variations cv, cluster_node cn WHERE cv.DELETED=0 AND cv.CLNID=cn.CLNID AND cn.VERSION=0"; $query = new query($db, $sql); while ($query->getrow()) { syncCluster($query->field("CLID")); $counter++; } //$form->addToTopText("<br/>".$lang->get("num_cl_sync", "Number of cluster who were synchronized").": ".$counter); }
/** * Store a vote * @param integer Vote of user (1-8) * @param string comment of user */ function saveData($vote, $comment = "", $sourceId) { if ($vote > 0 && $vote < 10) { global $db; $sql = "INSERT INTO pgn_rating (VOTE, COMMENT, SOURCEID) VALUES({$vote}, '" . addslashes($comment) . "', {$sourceId})"; $query = new query($db, $sql); $query->free(); return true; } return false; }
public static function get($report_id = null, $year = null) { $q = new query(RUDE_DATABASE_TABLE_CALENDAR_ITEMS); if ($year !== null) { $q->where(RUDE_DATABASE_FIELD_YEAR, (int) $year); } if ($report_id !== null) { $q->where(RUDE_DATABASE_FIELD_REPORT_ID, (int) $report_id); } $q->query(); return $q->get_object_list(); }
public function query() { //get connection object $connection = new connection(); //get query object $query = new query(); //get database connection $pdo = $connection->connect(); //set database connection on query object $query->setConnection($pdo); return $query; }
function _get_message_tree($id) { global $PHORUM, $DB; $q = new query($DB); $SQL = "Select id from {$PHORUM['ForumTableName']} where parent={$id}"; $q->query($DB, $SQL); $tree = "{$id}"; while ($rec = $q->getrow()) { $tree .= "," . _get_message_tree($rec["id"]); } return $tree; }
/** * on va récuperer l'id */ public function existe($valeur, $tableau, $champ = "id", $selecteur = "*") { $existe = new query(); //echo "SELECT $selecteur from $tableau where $champ_id = $id "; $existe->execute_requet("SELECT {$selecteur} from {$tableau} where {$champ} Like '%{$valeur}%' "); //echo "<div>".$existe->num_rows." div </div>"; if ($existe->num_rows == 0) { //echo "<div>".$existe->num_rows." ***</div>"; return false; } else { return $existe->result; } }
/** * @param query $query * @return query */ public function execute($query) { $stmt = $this->resource->prepare($query->getQueryString()); foreach ($query->getArguments() as $value) { $stmt->bind_param($value['type'], $value['argument']); } $stmt->execute(); $result = $stmt->get_result(); $query->setResult($result->fetch_all())->setAffectedRows($stmt->affected_rows)->setInsertId($this->resource->insert_id); $stmt->close(); $result->close(); return $query; }
function nextid($sequence) { $esequence = ereg_replace("'", "''", $sequence) . "_seq"; $query = new query($this, "Select * from {$esequence} limit 1"); $query->query($this, "REPLACE INTO {$esequence} values ('', nextval+1)"); if ($query->result) { $result = @mysql_insert_id($this->connect_id); } else { $query->query($this, "CREATE TABLE {$esequence} ( seq char(1) DEFAULT '' NOT NULL, nextval bigint(20) unsigned DEFAULT '0' NOT NULL auto_increment, PRIMARY KEY (seq), KEY (nextval) )"); $query->query($this, "REPLACE INTO {$esequence} values ('', nextval+1)"); $result = @mysql_insert_id($this->connect_id); } return $result; }
/** * Return the XML-Code for a Sitepage-Master * @param integer GUID of the sitepage-master */ function XmlExportSitepageMaster($spm) { global $db, $xmlExchange, $c; $xmlOptions = array(XML_OPTION_CASE_FOLDING => TRUE, XML_OPTION_SKIP_WHITE => TRUE); $xml =& new XPath(FALSE, $xmlOptions); $sql = "SELECT * FROM sitepage_master WHERE SPM_ID = {$spm}"; $query = new query($db, $sql); if ($query->getrow()) { $name = urlencode($query->field("NAME")); $description = urlencode($query->field("DESCRIPTION")); $templatePath = $query->field("TEMPLATE_PATH"); $clt = $query->field("CLT_ID"); $type = $query->field("SPMTYPE_ID"); $template = ""; $fp = @fopen($c["devpath"] . $templatePath, "r"); if ($fp != "") { while (!feof($fp)) { $template .= fgets($fp, 128); } @fclose($fp); } $template = urlencode($template); $templatePath = urlencode($templatePath); $xml->appendChild('', '<NX:SITEPAGEMASTER ID="' . $spm . '" NAME="' . $name . '" DESCRIPTION="' . $description . '" TYPE="' . $type . '" FILENAME="' . $templatePath . '" CLUSTERTEMPLATE="' . $clt . '">' . $template . '</NX:SITEPAGEMASTER>'); $query->free(); $xmlExchange[] = array("clt" => $clt); } return $xml->exportAsXml('', ''); }
/** * This function is used for drawing the html-code out to the templates. * It just returns the code * @param string Optional parameters for the draw-function. There are none supported. * @return string HTML-CODE to be written into the template. */ function draw($param = "") { global $cds, $db; $label = getDBCell("pgn_config_store", "TEXT1", "CLTI_ID=".$this->fkid); echo "<br><h2>$label</h2>"; $label = getDBCell("pgn_config_store", "TEXT3", "CLTI_ID=".$this->fkid); echo $label; br(); br(); // draw the linklist... $sql = "Select * FROM pgn_linkexchange WHERE APPROVED=1 AND SOURCEID=".$cds->pageId. " ORDER BY INSERTTIMESTAMP DESC"; $query = new query($db, $sql); $counter = 0; while ($query->getrow()) { $title = $query->field("TITLE"); $description = $query->field("DESCRIPTION"); $url = $query->field("URL"); echo '<b><a href="'.$url.'" target="_blank">'.$title.'</a></b><br>'; echo $description; br(); echo '<a style="font-size:11px;text-decoration:none;" href="'.$url.'" target="blank"><span style="color:#008000;">'.$url.'</span></a>'; br(); br(); } echo '<script language="javascript" type="text/javascript"> <!-- var win=null; function NewWindow2(mypage,myname,w,h,scroll,pos){ if(pos=="random") {LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100; TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;} if(pos=="center") {LeftPosition=(screen.width)?(screen.width-w)/2:100; TopPosition=(screen.height)?(screen.height-h)/2:100;} else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20} settings=\'width=\'+w+\',height=\'+h+\',top=\'+TopPosition+\',left=\'+LeftPosition+\',scrollbars=\'+scroll+\',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes\'; win=window.open(mypage,myname,settings);} // --> </script>'; $label = getDBCell("pgn_config_store", "TEXT2", "CLTI_ID=".$this->fkid); echo '<a class="breadcrumb" href="#" onclick="NewWindow'."('".$cds->docroot."sys/linkexchange/addurl.php?id=".$cds->pageId."','addurl','600','450','no','center');return false".'" onfocus="this.blur()">'.$label.'</a> '; }
public function compileQuery(query $query) { $querystr = ''; $parts = $query->getPart(); foreach ($parts as $part) { $identifier = array_keys($part); $identname = '\\Moya\\core\\orm\\drivers\\compiler\\' . $this->dbtype . '\\' . strtolower($identifier[0]); try { $identcompiler = new $identname(); $querystr .= $identcompiler->compile($query, $part[$identifier[0]]); } catch (\Exception $e) { throw new \Exception('Invalid query syntax: unknown identifier \'' . strtolower($type) . '\''); } } return $querystr; }
/** * This function is used for drawing the html-code out to the templates. * It just returns the code * @param string Optional parameters for the draw-function. There are none supported. * @return string HTML-CODE to be written into the template. */ function draw($param = "") { global $db; $result = null; $sql = "SELECT * FROM pgn_quote ORDER BY RAND() LIMIT 1"; $query = new query($db, $sql); if ($query->getrow()) { $result["QUOTE"] = $query->field("QUOTE"); $result["TITLE"] = $query->field("TITLE"); } $query->free(); return $result; }
function formField ($name, $title, $value = null, $linkfield, $properties) { $cvs = metaclass::getClassVars($properties['requirements']['real']); if (metaclass::$db->tableExists($cvs['table'])) { $query = new query(); $query->select(array ( 'id' , 'title' ))->from($cvs['table']); $result = metaclass::$db->query($query); $return .= '<label for="' . $name . '"> ' . $title . ' </label><br/> <select id="' . $name . '" name="' . $name . '">'; while ($row = metaclass::$db->assoc($result)) { $return .= '<option value="' . $row['id'] . '"' . ($row['id'] == $value ? ' selected' : null) . '>' . $row['title'] . '</option>'; } $return .= '</select> <br/>'; } else { $return .= '<label for="' . $name . '"> ' . $title . ' </label><br/>'; $return .= '<p class="error">' . text::get('form/foreignTableNotExist', $cvs['title']) . '</p>'; } return $return; }