Ejemplo n.º 1
0
 public static function realImgSrc($imgSrc, $type = "main", $size = "normal", $title = '')
 {
     if ($imgSrc) {
         $path = "/uploads/images_thumbs/" . UploadedFile::fileNameToPath($imgSrc);
     } else {
         $imgSrc = "DefaultMainPhoto.jpg";
         $path = "/templates/arfooo/images/";
     }
     switch ($size) {
         case "small":
             $imgSrc = "s" . $imgSrc;
             break;
         case "medium":
             $imgSrc = "m" . $imgSrc;
             break;
         case "nano":
             $imgSrc = "n" . $imgSrc;
             break;
     }
     if ($title) {
         $path .= NameTool::strToAscii($title) . '-';
     }
     $imgSrc = $path . $imgSrc;
     return AppRouter::getResourceUrl($imgSrc);
 }
Ejemplo n.º 2
0
 function createUrlNames()
 {
     $withParents = Config::get('advancedUrlRewritingParentsEnabled');
     set_time_limit(600);
     $categories = $this->category->findAll(null, "categoryId, parentCategoryId, name, urlName");
     $tree = new NavigationTree();
     foreach ($categories as $category) {
         $tree->addNode($category['categoryId'], $category['parentCategoryId'], array("name" => $category['name'], "urlName" => $category['urlName']));
     }
     $connections = $tree->getAllConnections();
     $urlNames = array("");
     foreach ($connections as $connection) {
         $urlName = NameTool::strToAscii($connection['value']['name']);
         if ($withParents) {
             $urlName = ltrim($urlNames[$connection['depth'] - 1] . "\\" . $urlName, "\\");
             $urlNames[$connection['depth']] = $urlName;
         }
         $urlName = $this->category->getFreeUrlName($urlName, $connection['categoryId']);
         if ($connection['value']['urlName'] && $connection['value']['urlName'] != $urlName && !$this->rewrite->findByPk($connection['value']['urlName'])) {
             $rewrite = new RewriteRecord();
             $rewrite->originalUrl = $connection['value']['urlName'];
             $rewrite->rewrittedUrl = $urlName;
             $rewrite->save();
         }
         $this->category->updateByPk(array("urlName" => $urlName), $connection['categoryId']);
     }
 }
Ejemplo n.º 3
0
 function getFreeUrlName($baseUrlName, $excludeCategoryId = false)
 {
     $baseUrlName = NameTool::strToAscii($baseUrlName, "_\\");
     $lp = 0;
     do {
         $lp++;
         $urlName = $baseUrlName;
         $urlName .= $lp > 1 ? $lp : "";
         if (in_array($urlName, array('admin', 'moderation', 'webmaster'))) {
             $exists = true;
         } else {
             $c = new Criteria();
             $c->add("urlName", $urlName);
             if ($excludeCategoryId) {
                 $c->add("categoryId", $excludeCategoryId, "!=");
             }
             $exists = $this->category->getCount($c);
         }
     } while ($exists);
     return $urlName;
 }
Ejemplo n.º 4
0
 /**
  * Display sites which contain tag
  */
 function tagAction($tagId, $tag, $page = 1)
 {
     $searchTag = $this->searchTag->findByPk($tagId);
     if (empty($searchTag) || NameTool::strToAscii($searchTag->tag) != $tag || $searchTag->banned) {
         return $this->return404();
     }
     //set adPage for ads
     Display::set("adPage", "tag" . $tagId);
     $searchedSites = array();
     //get sites which containt searched phrase
     $searchedSites = $this->siteSearcher->searchValidated(array("phrase" => $searchTag->tag), $page);
     //prepare data for pagination
     $totalPages = ceil($this->siteSearcher->getFoundRowsCount() / Config::get("sitesPerPageInSearch"));
     //set founded sites and paginations data
     $this->set("searchTag", $searchTag);
     $this->set("searchedSites", $searchedSites);
     $this->set("pageNavigation", array("baseLink" => "/site/tag/{$tagId}/" . NameTool::strToAscii($tag) . "/", "totalPages" => $totalPages, "currentPage" => $page, "title" => $tag));
 }
Ejemplo n.º 5
0
 public static function getObjectUrl($object, $type, $absolute = false)
 {
     switch ($type) {
         case "tag":
             $urlParts = array("/site/tag/%d/%s/%d", $object['tagId'], NameTool::strToAscii($object['tag']), isset($object['page']) ? $object['page'] : 1);
             break;
         case "keyword":
             $urlParts = array("/site/keyword/%d/%s/%d", $object['keywordId'], NameTool::strToAscii($object['keyword']), isset($object['page']) ? $object['page'] : 1);
             break;
         case "category":
             $urlParts = array("/site/category/%d/%s/%d", $object['categoryId'], Config::get("advancedUrlRewritingEnabled") ? $object['urlName'] : NameTool::strToAscii($object['name']), isset($object['page']) ? $object['page'] : 1);
             break;
         case "keyword":
             $urlParts = array("/site/keyword/%d/%s/%d", $object['keywordId'], $object['keyword'], isset($object['page']) ? $object['page'] : 1);
             break;
         case "siteDetails":
             $titleUrl = NameTool::strToAscii($object['siteTitle']);
             if (Config::get("advancedUrlRewritingEnabled")) {
                 $categoryUrl = "";
                 $categoryParents = $object['categoryParents'];
                 foreach ($categoryParents as $categoryParent) {
                     if ($categoryUrl) {
                         $categoryUrl .= "\\";
                     }
                     $categoryUrl .= NameTool::strToAscii($categoryParent['name']);
                 }
                 $urlParts = array("/site/details/%d/%s/%s", $object['siteId'], $categoryUrl, $titleUrl);
             } else {
                 $urlParts = array("/site/details/%d/%s", $object['siteId'], $titleUrl);
             }
             break;
     }
     $url = AppRouter::getRewrittedUrl($urlParts);
     if ($absolute) {
         $url = Config::get("siteDomainUrl") . $url;
     }
     return $url;
 }