function filter($filter, $alias) { $columns = $this->getColumns(); $column = Util::tryArrayKey($columns, $filter->name); if (is_null($column)) { $message = sprintf("No column %s in model", $filter->name); trigger_error($message, E_USER_ERROR); } //find condition for this column using model $sql = $this->getValue($alias, $column, $filter->condition, $filter->value); return $sql; }
function filter($filters) { if (is_null($filters) || empty($filters)) { return; } foreach ($filters as $filter) { $model = $filter->model; $alias = Util::tryArrayKey($this->amap, get_class($model)); $value = $filter->value; //sanitize input $value = $this->mysqli->real_escape_string($value); $filter->sanitize($value); $condition = $model->filter($filter, $alias); $this->addCondition($condition); } }
static function render($rows, $options) { $name = Util::getArrayKey($options, 'name'); $default = Util::tryArrayKey($options, 'default'); $showEmpty = Util::tryArrayKey($options, 'empty'); if (!is_null($showEmpty) && $showEmpty) { array_unshift($rows, array('ui_code' => '', 'name' => '--')); } $buffer = ''; $option = '<option value="{ui_code}" {flag}> {name}</option>'; foreach ($rows as $row) { $flag = !is_null($default) && $row['ui_code'] == $default ? 'selected' : ''; $str = str_replace(array("{ui_code}", "{name}", "{flag}"), array($row['ui_code'], $row['name'], $flag), $option); $buffer = $buffer . $str; } $buffer = '<select name="' . $name . '"> ' . $buffer . ' </select>'; return $buffer; }
function process($params, $options) { if (is_null($params) || empty($params)) { $controller = new \com\indigloo\sc\controller\Http400(); $controller->process(); exit; } $siteId = Util::tryArrayKey($params, "site_id"); $cname = Url::tryQueryParam("cname"); if (empty($siteId) || empty($cname)) { $controller = new \com\indigloo\sc\controller\Http400(); $controller->process(); exit; } $siteDao = new \com\indigloo\sc\dao\Site(); $postDBRows = $siteDao->getPostsOnId($siteId, 50); $pageHeader = $cname; $pageTitle = SeoData::getHomePageTitle(); $metaDescription = SeoData::getHomeMetaDescription(); $metaKeywords = SeoData::getHomeMetaKeywords(); $file = APP_WEB_DIR . '/view/tiles.php'; include $file; }
include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; use com\indigloo\Util; use com\indigloo\sc\auth\Login; use com\indigloo\sc\ui\Constants as UIConstants; set_exception_handler('webgloo_ajax_exception_handler'); //use login is required for bookmarking if (!Login::hasSession()) { $message = array("code" => 401, "message" => "Authentication failure: You need to login!"); $html = json_encode($message); echo $html; exit; } $params = new \stdClass(); $login = Login::getLoginInSession(); $params->loginId = $login->id; $params->name = $login->name; $params->action = Util::tryArrayKey($_POST, "action"); $params->followerId = Util::tryArrayKey($_POST, "followerId"); $params->followingId = Util::tryArrayKey($_POST, "followingId"); //use login is required for bookmarking if ($params->followerId == $params->followingId) { $message = array("code" => 200, "message" => "No need to follow yourself!"); $html = json_encode($message); echo $html; exit; } $command = new \com\indigloo\sc\command\SocialGraph(); $response = $command->execute($params); $html = json_encode($response); echo $html;
use com\indigloo\Constants; use com\indigloo\sc\util\Nest; use com\indigloo\Util; use com\indigloo\Url; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler("web-form-1", $_POST); $fvalues = $fhandler->getValues(); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $group_slug = ""; $slugs = Util::tryArrayKey($fvalues, "g"); if (!is_null($slugs)) { //remove duplicate entries $slugs = array_unique($slugs); //input - new groups are names / old ones are slugs $slugs = array_map(array("\\com\\indigloo\\util\\StringUtil", "convertNameToKey"), $slugs); //db slugs are space separated for sphinx indexing $group_slug = implode(Constants::SPACE, $slugs); } $collectionDao = new \com\indigloo\sc\dao\Collection(); $collectionDao->glset(Nest::fgroups(), $group_slug); //success $gWeb->store(Constants::FORM_MESSAGES, array("featured groups list updated!")); header("Location: " . $fUrl); } catch (UIException $ex) { $gWeb->store(Constants::STICKY_MAP, $fvalues);
$fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler("web-form-1", $_POST); $fvalues = $fhandler->getValues(); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $gSessionLogin = \com\indigloo\sc\auth\Login::getLoginInSession(); $loginId = $gSessionLogin->id; // p array would be missing when no checkbox is ticked. // that also happens when user de-selects everything // for user selections - p array would contain only those // keys that user has selected. we have to map the rest of them // to false in preferences data. $parr = Util::tryArrayKey($fvalues, "p"); $pdata = array(); if (is_null($parr)) { //user has not selected any checckbox. $pdata = array("follow" => false, "comment" => false, "bookmark" => false); } else { // p array is not empty. // user has ticked some checkboxes. // set to false the keys that user has not selected. $pdata["follow"] = isset($parr["follow"]) ? true : false; $pdata["comment"] = isset($parr["comment"]) ? true : false; $pdata["bookmark"] = isset($parr["bookmark"]) ? true : false; } //save data for this loginId $pDataObj = json_encode($pdata); $preferenceDao = new \com\indigloo\sc\dao\Preference();
unset($fparams["ft"]); unset($fparams["gt"]); //ft urls start with page 1 $fparams["gpage"] = 1; //create filter Urls $ftBaseUrl = Url::createUrl("/monitor/users.php", $fparams); //search clear link $sparams = $qparams; unset($sparams["gt"]); $clearSearchUrl = Url::createUrl("/monitor/users.php", $sparams); //filters $filters = array(); $model = new \com\indigloo\sc\model\User(); $ft = Url::tryQueryParam("ft"); $ftname = ""; $gtoken = Util::tryArrayKey($qparams, "gt"); $userId = NULL; if (empty($ft) && strlen($gtoken) > 5 && strcmp(substr($gtoken, 0, 5), "user:"******"user"; $userId = substr($gtoken, 5); //reset search token $gtoken = NULL; } if (empty($ft) && !empty($gtoken)) { $ft = "name"; } if (!is_null($ft)) { switch ($ft) { case "24HR": $filter = new Filter($model); $filter->add($model::CREATED_ON, Filter::GT, "24 HOUR");
<?php header('Content-type: application/json'); include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; use com\indigloo\Util; use com\indigloo\sc\auth\Login; set_exception_handler('webgloo_ajax_exception_handler'); $message = NULL; //user login is required for bookmarking if (!Login::hasSession()) { $message = array("code" => 401, "message" => "Authentication failure: You need to login!"); $html = json_encode($message); echo $html; exit; } // params //@todo - pass parameters w/o any processing to command. $params = new \stdClass(); $login = Login::getLoginInSession(); $params->loginId = $login->id; $params->name = $login->name; $params->action = Util::tryArrayKey($_POST, "action"); $params->itemId = Util::getArrayKey($_POST, "itemId"); $command = new \com\indigloo\sc\command\Bookmark(); $response = $command->execute($params); $html = json_encode($response); echo $html;
<?php // normal HTML output include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; use com\indigloo\Util; use com\indigloo\Url; use com\indigloo\sc\auth\Login; use com\indigloo\sc\ui\Constants as UIConstants; set_exception_handler('webgloo_ajax_exception_handler'); $hkey = Util::tryArrayKey($_GET, "hkey"); if (empty($hkey)) { echo "No help key supplied"; exit; } $html = \com\indigloo\sc\html\Site::getHelp($hkey); echo $html;