Exemple #1
0
function Fields($Param)
{
    $Today = date('Y-m-d');
    $SQL1 = "SELECT Class FROM ToDo WHERE 1=1 GROUP BY Class";
    $result = mysql_query($SQL1);
    if (isset($_GET["Long"])) {
        $Fields = "SELECT ";
        $Fields .= "STRING ToDo.Task AS Task,,";
        $Fields .= "STRING ToDo.Prio AS Prio,,";
        $Fields .= "STRING ToDo.Class AS Class,,";
        $Fields .= "STRING ToDo.Pick AS Pick,,";
        $Fields .= "STRING ToDo.TargetDate AS TargetDate,,";
        $Fields .= "STRING ToDo.id AS TaskID,,";
        $Fields .= "NoShow ToDo.Pick AS PickRaw,,";
    } else {
        $Fields = "SELECT ";
        $Fields .= "STRING ToDo.Task AS Task,,";
        $Fields .= "STRING ToDo.TargetDate AS Date,,";
        $Fields .= "STRING ToDo.Prio AS Prio,,";
        $Fields .= "STRING CONCAT(\n\t\t\tIF(ToDo.Pick=0,CONCAT('<A HREF=./ToDo.html?CType=PickUp&id=',ToDo.id,'" . buildQueryString('CType', 'id') . ">Pick</A>'),\n\t\t\t               CONCAT('<A HREF=./ToDo.html?CType=PickDown&id=',ToDo.id,'" . buildQueryString('CType', 'id') . ">Unpick</A>'))) AS Pick,,";
        $Fields .= "STRING CONCAT(if(ToDo.Prio=1,'','<A HREF=./ToDo.html?CType=PrioUp&id='),\n\t\t\tif(ToDo.Prio=1,'',ToDo.id),\n\t\t\tif(ToDo.Prio=1,'','" . buildQueryString('CType', 'id') . ">Up</A> / '),\n\t\t\tif(ToDo.Prio=3,'','<A HREF=./ToDo.html?CType=PrioDown&id='),\n\t\t\tif(ToDo.Prio=3,'',ToDo.id),\n\t\t\tif(ToDo.Prio=3,'','" . buildQueryString('CType', 'id') . ">Down</A>')) AS Ajust_Prio,,";
        //$Fields.="STRING CONCAT(ToDo.Class,' &nbsp;&nbsp;&nbsp; (',";
        //while($row=mysql_fetch_array($result)) {
        //	$Fields.="IF(ToDo.Class!='".$row['Class']."',CONCAT('<A HREF=./ToDo.html?CType=ClassCh&id=',ToDo.id,'&Class=".$row['Class'].buildQueryString('CType','id','Class').">".$row['Class']."</A> / '),''),";
        //}
        //$Fields=substr($Fields,0,-1);
        //$Fields.="')') AS Class,,";
        $Fields .= "STRING CONCAT('<A HREF=./ToDo.html?CType=DateU7&id=',\n\t\t\tToDo.id,'" . buildQueryString('CType', 'id') . ">+7</A> / <A HREF=./ToDo.html?CType=DateUp&id=',\n\t\t\tToDo.id,'" . buildQueryString('CType', 'id') . ">++</A> / <A HREF=./ToDo.html?CType=DateDown&id=',\n\t\t\tToDo.id,'" . buildQueryString('CType', 'id') . ">--</A> / <A HREF=./ToDo.html?CType=DateToday&id=',\n\t\t\tToDo.id,'" . buildQueryString('CType', 'id') . ">Today</A> / <A HREF=./ToDo.html?CType=DateLong&id=',ToDo.id,'" . buildQueryString('CType', 'id') . ">Longterm</A>') AS Adjust_Target_Date,,";
        //$Fields.="STRING ToDo.id AS TaskID,,";
        $Fields .= "STRING CONCAT('<A HREF=./ToDo.html?CType=Delete&id=',ToDo.id,'" . buildQueryString('CType', 'id') . ">delete ',ToDo.id,'</A>') AS Close,,";
        $Fields .= "INT IF(TargetDate<'" . $Today . "',-10,IF(TargetDate='" . $Today . "',-1*ToDo.Prio,ToDo.Prio)) AS Hot,,";
        $Fields .= "INT DATEDIFF(ToDo.TargetDate,NOW()) AS Over_Due,,";
        $Fields .= "NoShow ToDo.Pick AS PickRaw,,";
    }
    $Ret["From"] = " FROM ToDo";
    $Ret["Where"] = " WHERE ToDo.Status='Open'";
    if ($Param['Pick'] == 'Picked') {
        $Ret["Where"] .= " AND ToDo.Pick=1";
    }
    if ($Param['Class'] != '') {
        $Ret["Where"] .= " AND ToDo.Class='" . $Param['Class'] . "'";
    }
    $Ret["Join"] = " ";
    $Ret["Group"] = " ";
    $Ret["Ord"] = " ORDER BY PickRaw DESC,TargetDate ASC, Prio ASC, id DESC";
    $Fields = substr($Fields, 0, -2);
    $Ret["Fields"] = str_replace(",,", ",", str_replace("INT ", "", str_replace("STRING ", "", str_replace("NoShow ", "", $Fields))));
    $Ret["Header"] = $Fields;
    return $Ret;
}
function query_result($q)
{
    $db = $q['db'];
    #Build and execute the query
    $sql = buildQueryString($q);
    $sql = "select statement_id, rule_id, resource_id, value from s3db_statement where resource_id in (" . $sql . ")";
    $db->query($sql, __LINE__, __FILE__);
    #echo $sql;
    #echo '<pre>';print_r($db);
    while ($db->next_record()) {
        $resource_ids[] = $db->f('resource_id');
        $rule_values[$db->f('statement_id')] = array('rule_id' => $db->f('rule_id'), 'value' => $db->f('value'));
    }
    return array($resource_ids, $rule_values);
}
Exemple #3
0
/**
 * @param $totalRecords how much of that shit you have?
 * @param $currentPage where is you now?
 * @param $perPage soo, how much do you want?
 * @param $maxPages now i reached limit of my imagination, derp
 * @return string
 */
function createLinks($totalRecords, $currentPage, $perPage, $maxPages = 4){
		global $config;

        $pages = getPages($totalRecords, $perPage, $currentPage, $maxPages);
        $prevLiClass = 'prev';
        $prevLinkHref = 'javascript:void(0)';

        if ($currentPage == 1) {
            $prevLiClass = 'disabled';
        } else {
            $prevLinkHref = buildQueryString($currentPage - 1);
        }
        $nextLiClass = 'next';
        $nextLinkHref = 'javascript:void(0)';
        if ($currentPage == $totalRecords) {
            $nextLiClass = 'disabled';
        } else {
            $nextLinkHref = buildQueryString($currentPage + 1);
        }
        $output = '<ul class="pagination">';
        $output .= '<li class="' . $prevLiClass . '"><a href="' . $prevLinkHref . '">&laquo;</a></li>';
        foreach($pages as $page) {
            $currentClass = $page == $currentPage ? "active current " . $config['theme'] : '';
            $output .= '<li class="' . $currentClass . '"><a href="' . buildQueryString($page) . '">' . $page . '</a></li>';
        }
        $output .= '<li class="' . $nextLiClass . '"><a href="' . $nextLinkHref . '">&raquo;</a></li>';
        $output .= '</ul>';
        return $output;
}
Exemple #4
0
    }
    for ($p = $start; $p <= $end; $p++) {
        if ($p < $num_page) {
            $pagesInRange[] = $p;
        }
    }
    if (!empty($pagesInRange)) {
        foreach ($pagesInRange as $i) {
            echo '<li><a ' . ($selectedPage == $i ? 'class="active"' : '');
            if ($offset / $max != $i) {
                echo ' href="' . $uri . buildQueryString(array('p' => $i + 1)) . '"';
            }
            echo '>' . ($i + 1) . '</a></li>';
        }
    }
    ?>
         <?php 
    if ($offset < $total - $max) {
        ?>
           <li><a href="<?php 
        echo $uri . buildQueryString(array('p' => $offset / $max + 2));
        ?>
" aria-label="Next"><span aria-hidden="true">&raquo;</span></a></li>
        <?php 
    }
    ?>
        </ul>
      </div>
    </div>
    <?php 
}
function handleTokenResponse($token, $error = null)
{
    $authCookie = $_COOKIE[AUTHCOOKIE];
    $cookieValues = parseQueryString($authCookie);
    if (!empty($token)) {
        $cookieValues[ACCESSTOKEN] = $token->{ACCESSTOKEN};
        $cookieValues[SCOPE] = $token->{SCOPE};
        $cookieValues[EXPIRESIN] = $token->{EXPIRESIN};
        if (!empty($token->{REFRESHTOKEN})) {
            saveRefreshToken($token->{REFRESHTOKEN});
        }
    }
    if (!empty($error)) {
        $cookieValues[ERRORCODE] = $error[ERRORCODE];
        $cookieValues[ERRORDESC] = $error[ERRORDESC];
    }
    setrawcookie(AUTHCOOKIE, buildQueryString($cookieValues), 0, '/', $_SERVER[SERVER_NAME]);
}
function handleTokenResponse($token, $error = null)
{
    $resp = array();
    if (!empty($token)) {
        $resp[ACCESSTOKEN] = $token->{ACCESSTOKEN};
        $resp[SCOPE] = $token->{SCOPE};
        $resp[EXPIRESIN] = $token->{EXPIRESIN};
        if (!empty($token->{REFRESHTOKEN})) {
            saveRefreshToken($token->{REFRESHTOKEN});
        }
    }
    if (!empty($error)) {
        $resp[ERRORCODE] = $error[ERRORCODE];
        $resp[ERRORDESC] = $error[ERRORDESC];
    }
    $responseUrl = ENDURL . '?' . buildQueryString($resp);
    header('Location: ' . $responseUrl);
}
Exemple #7
0
					</div>
				</div>
			</nav>
			<div class="container body">
				<div class="row">
					<div class="col s12">
						<?
						$page = isset($_GET['page']) ? intval($_GET['page']) : 1;

						$data = getImages($page - 1);

						$total = $data['total_count'];
						$perPage = $data['requested_count'];
						$lastPage = ceil($total / $perPage);
						
						$lastPageLink = buildQueryString($lastPage);
						$reversedLink = getReversedQueryString();
						$blogLink = $data['blog_url'];
						
						$images = $data['images'];

						if (!empty($images)) {?>
							<div class="row">
								<div class="col s12">
									<a href="<?php 
echo $lastPageLink;
?>
" class="waves-effect waves-light btn tooltipped <?php 
echo $config['theme'];
?>
" data-position="bottom" data-delay="50" data-tooltip="Navigate to last page">Last Page</a>
 /** Costruttore della classe: 
  * $rowsNum (numero di righe) e' il parametro fondamentale il numero di elementi TOTALE da visualizzare. 
  * $anchor è il nome dell'ancora dei collegamenti generati per il cambio di pagina o di risultati per pagina 
  * (infatti queste operazioni implicano il ricaricamento della pagina).
  * $result_per_page e' autoesplicativo.
  * $name è un nome utile nel qual caso si utilizzassero due PageNavigator sulla stessa pagina. Infatti $name viene usato come suffisso per i nomi dei parametri $_GET.
  * 
  *  @param int $rowsNum Il numero totale di elementi di cui creare la paginazione 
  *  @param string $anchor Ancora HTML da usare per il passaggio tra' le varie pagine 
  *  @param string $style Classe del foglio di stile da applicare alle select 
  *  @param int $results_per_page Il numero di risultati per pagina.
  *  @param string $name */
 function PageNavigator($rowsNum, $anchor = "", $style = "", $results_per_page = 5, $name = "")
 {
     $this->name = $name;
     $this->realName = str_replace("_", " ", ucfirst($name));
     $this->page = isset($_GET['Page_' . $this->name]) ? $_GET['Page_' . $this->name] : 0;
     $this->anchor = $anchor;
     $this->rowsNum = $rowsNum;
     $this->style = $style == "" ? "" : "class=\"{$style}\"";
     $this->ORIGINAL_results_per_page = $results_per_page;
     $this->results_per_page = isset($_GET['results_per_page_' . $this->name]) ? $_GET['results_per_page_' . $this->name] : $results_per_page;
     $this->pages = ceil($this->rowsNum / $this->results_per_page);
     $this->query_string = buildQueryString("Page_{$this->name}", "results_per_page_{$this->name}");
     if ($this->page != 0) {
         //se il numero di elementi è minore dell'elemento di partenza da visualizzare
         //allora c'è stato un cambio di risultati per pagina....
         while ($this->rowsNum <= $this->page * $this->results_per_page) {
             $this->page--;
         }
         // ...quindi corregge la variabile page decrementandola
     }
     $this->setLanguage('italiano');
 }