Пример #1
0
Файл: Group.php Проект: rjha/sc
 function process($params, $options)
 {
     if (is_null($params) || empty($params)) {
         $controller = new \com\indigloo\sc\controller\Http400();
         $controller->process();
         exit;
     }
     $token = Util::getArrayKey($params, "name");
     // group controller is invoked via the fixed links
     // (as opposed to users typing in search box)
     // so we (exact) match this token against post_groups index.
     $sphinx = new \com\indigloo\sc\search\SphinxQL();
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $pageSize = Config::getInstance()->get_value("search.page.items");
     $paginator = new Pagination($qparams, $pageSize);
     $ids = $sphinx->getPagedPostByGroup($token, $paginator);
     $sphinx->close();
     $template = NULL;
     $searchTitle = NULL;
     $groupName = \com\indigloo\util\StringUtil::convertKeyToName($token);
     if (sizeof($ids) > 0) {
         $pageHeader = "{$groupName}";
         $pageBaseUrl = "/group/{$token}";
         $template = APP_WEB_DIR . '/view/tiles-page.php';
         $postDao = new \com\indigloo\sc\dao\Post();
         $postDBRows = $postDao->getOnSearchIds($ids);
     } else {
         $pageHeader = "No results";
         $template = APP_WEB_DIR . '/view/notiles.php';
     }
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, $groupName);
     $metaKeywords = SeoData::getMetaKeywords($groupName);
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, $groupName);
     include $template;
 }
Пример #2
0
Файл: Post.php Проект: rjha/sc
 static function createPostView($row, $voptions = NULL)
 {
     $voptions = empty($voptions) ? array() : $voptions;
     //default options
     $options = array();
     $options["abbreviate"] = false;
     $options["image"] = true;
     $options["group"] = false;
     //override defaults
     foreach ($voptions as $key => $value) {
         $options[$key] = $value;
     }
     $imagesJson = $row["images_json"];
     $images = json_decode($imagesJson);
     $view = new \stdClass();
     $view->hasImage = false;
     $view->images = NULL;
     $view->hasGroups = false;
     $view->groups = array();
     $view->id = $row['id'];
     $view->itemId = PseudoId::encode($view->id);
     // title in DB is 128 chars long.
     // here on page we want to use a 70 char title.
     // also used in item images alt text
     // clean up bad utf-8 data for display
     $view->title = Util::filterBadUtf8($row['title']);
     $view->title = Util::abbreviate($view->title, 70);
     $view->description = Util::filterBadUtf8($row['description']);
     if ($options["abbreviate"]) {
         $view->description = Util::abbreviate($view->description, 160);
     }
     $view->userName = $row['user_name'];
     $view->createdOn = AppUtil::convertDBTime($row['created_on']);
     $view->pubUserId = PseudoId::encode($row['login_id']);
     $view->loginId = $row['login_id'];
     $view->userPageURI = "/pub/user/" . $view->pubUserId;
     //process post image.
     if (!empty($images) && sizeof($images) > 0 && $options["image"]) {
         /* process image #1 */
         $view->hasImage = true;
         $image = $images[0];
         $imgv = self::convertImageJsonObj($image);
         $view->thumbnail = $imgv["thumbnail"];
         $view->height = $imgv["height"];
         $view->width = $imgv["width"];
         $view->srcImage = $imgv["source"];
         /* assign all images */
         $view->images = $images;
     }
     //process groups
     if ($options["group"] === true) {
         $group_slug = $row['group_slug'];
         $groups = array();
         if (!is_null($group_slug) && strlen($group_slug) > 0) {
             $slugs = explode(Constants::SPACE, $group_slug);
             $display = NULL;
             foreach ($slugs as $slug) {
                 if (empty($slug)) {
                     continue;
                 }
                 //@imp @todo @hack
                 // dirty hack - for single quotes in group name - for old data
                 // anything indexed as flury's - should be converted to flury
                 // now we ignore the single quote in group name so we should be fine
                 $slug = str_replace("'s", "", $slug);
                 $display = StringUtil::convertKeyToName($slug);
                 $groups[] = array("slug" => $slug, "display" => $display);
             }
         }
         if (sizeof($groups) > 0) {
             $view->hasGroups = true;
             $view->groups = $groups;
         }
     }
     return $view;
 }
Пример #3
0
Файл: Group.php Проект: rjha/sc
 function nameToSlug($group_names)
 {
     $group_slug = "";
     if (!Util::tryEmpty($group_names)) {
         $slugs = array();
         $names = explode(",", $group_names);
         foreach ($names as $name) {
             if (Util::tryEmpty($name)) {
                 continue;
             }
             // remove single quotes from group names
             // it is a bit difficult to deal with single quotes and sphinx
             $name = str_replace("'", "", $name);
             $slug = \com\indigloo\util\StringUtil::convertNameToKey($name);
             array_push($slugs, $slug);
         }
         $group_slug = implode(Constants::SPACE, $slugs);
     }
     return $group_slug;
 }
Пример #4
0
Файл: Group.php Проект: rjha/sc
 static function process($postId, $loginId, $version, $catCode, $group_slug)
 {
     //sanitize input
     settype($postId, "integer");
     settype($loginId, "integer");
     settype($version, "integer");
     $sqlm1 = "insert ignore into sc_group_master(token,name,cat_code,created_on) values('%s','%s','%s',now()) ";
     $sqlm2 = "insert ignore into sc_user_group(login_id,token,name,created_on) values('%d','%s', '%s', now()) ";
     $sqlm3 = "update sc_site_tracker set group_flag = 1 where post_id = %d and version = %d ";
     $dbh = NULL;
     try {
         $dbh = PDOWrapper::getHandle();
         //Tx start
         $dbh->beginTransaction();
         $slugs = explode(Constants::SPACE, $group_slug);
         foreach ($slugs as $slug) {
             if (Util::tryEmpty($slug)) {
                 continue;
             }
             //do processing
             $name = \com\indigloo\util\StringUtil::convertKeyToName($slug);
             $sql = sprintf($sqlm1, $slug, $name, $catCode);
             $dbh->exec($sql);
             $sql = sprintf($sqlm2, $loginId, $slug, $name);
             $dbh->exec($sql);
         }
         //All group slugs for post processed
         $sql = sprintf($sqlm3, $postId, $version);
         $dbh->exec($sql);
         //Tx end
         $dbh->commit();
         $dbh = null;
     } catch (\PDOException $e) {
         $dbh->rollBack();
         $dbh = null;
         throw new DBException($e->getMessage(), $e->getCode());
     } catch (\Exception $ex) {
         $dbh->rollBack();
         $dbh = null;
         $message = $ex->getMessage();
         throw new DBException($message);
     }
 }
Пример #5
0
Файл: Lists.php Проект: rjha/sc
 function edit($loginId, $listId, $name, $description)
 {
     //md5 hash as hex string and bytes
     $hash = md5($name);
     $seoName = StringUtil::convertNameToKey($name);
     $bin_hash = md5($seoName, TRUE);
     mysql\Lists::edit($loginId, $listId, $name, $seoName, $hash, $bin_hash, $description);
 }
Пример #6
0
Файл: Site.php Проект: rjha/sc
 static function renderSlugPanel($dbslug)
 {
     $records = array();
     //explode DB slug on space
     $slugs = explode(Constants::SPACE, $dbslug);
     //sort slugs on alpha
     sort($slugs);
     foreach ($slugs as $slug) {
         if (Util::tryEmpty($slug)) {
             continue;
         }
         $slug = trim($slug);
         $name = StringUtil::convertKeyToName($slug);
         $records[] = array("slug" => $slug, "name" => $name, "checked" => "checked");
     }
     $view = new \stdClass();
     $template = "/fragments/ui/slug-panel.tmpl";
     $view->records = $records;
     $view->total = sizeof($records);
     $html = Template::render($template, $view);
     return $html;
 }