Esempio n. 1
0
 static function getUri($list)
 {
     if (!$list['id'] || !$list['name']) {
         return null;
     }
     return 'http://littlesis.org/list/' . $list['id'] . '/' . LsSlug::convertNameToSlug($list['name']);
 }
Esempio n. 2
0
 public function checkEntity($request, $includeDeleted = false, $returnArray = true)
 {
     if ($returnArray) {
         $this->entity = EntityApi::get($request->getParameter('id'), $includeDeleted);
         $this->forward404Unless($this->entity);
         $this->entity = EntityTable::loadPrimaryExtensionFields($this->entity);
     } else {
         $q = LsDoctrineQuery::create()->from('Entity e')->where('e.id = ?', $request->getParameter('id'));
         if ($includeDeleted) {
             $q->andWhere('e.is_deleted IS NOT NULL');
         }
         $this->entity = $q->fetchOne();
         $this->forward404Unless($this->entity);
     }
     //check that the entity has the given name
     $slug = $request->getParameter('slug');
     $primarySlug = LsSlug::convertNameToSlug($this->entity['name']);
     //if the name isn't primary, we redirect to the url with the primary name
     if ($slug != $primarySlug) {
         $params = $request->getParameterHolder()->getAll();
         if ($params['target'] == 'view') {
             $params['target'] = null;
         }
         $url = EntityTable::generateRoute($this->entity, $params['target'], $params);
         $this->redirect($url);
     }
 }
Esempio n. 3
0
 public static function prepareEntityData($entity)
 {
     sfLoader::loadHelpers(array("Asset", "Url"));
     $primary_ext = @$entity["primary_ext"] ? $entity["primary_ext"] : (strpos($entity["url"], "person") === false ? "Org" : "Person");
     $entity["primary_ext"] = $primary_ext;
     if (@$entity["image"] && strpos(@$entity["image"], "netmap") === false && strpos(@$entity["image"], "anon") === false) {
         $image_path = $entity["image"];
     } elseif (@$entity["filename"]) {
         $image_path = image_path(ImageTable::getPath($entity['filename'], 'profile'));
     } else {
         $image_path = $primary_ext == "Person" ? image_path("system/netmap-person.png") : image_path("system/netmap-org.png");
     }
     try {
         $url = url_for(EntityTable::generateRoute($entity));
     } catch (Exception $e) {
         $url = 'http://littlesis.org/' . strtolower($primary_ext) . '/' . $entity['id'] . '/' . LsSlug::convertNameToSlug($entity['name']);
     }
     if (@$entity["blurb"]) {
         $description = $entity["blurb"];
     } else {
         $description = @$entity["description"];
     }
     return array("id" => self::integerize(@$entity["id"]), "name" => $entity["name"], "image" => $image_path, "url" => $url, "description" => $description, "x" => @$entity["x"], "y" => @$entity["y"], "fixed" => true);
 }
Esempio n. 4
0
 static function getUri($entity)
 {
     //needs to work for frontend and API
     $ext = isset($entity['primary_ext']) ? $entity['primary_ext'] : $entity['primary_type'];
     if (!$entity['id'] || !$ext || !$entity['name']) {
         return null;
     }
     return 'http://littlesis.org/' . strtolower($ext) . '/' . $entity['id'] . '/' . LsSlug::convertNameToSlug($entity['name']);
 }
Esempio n. 5
0
 static function getListCachePatternsById($id)
 {
     $list = Doctrine::getTable('LsList')->find($id);
     $actions = array_merge(array('view'), LsCacheFilter::cachedActionsByModule('list'));
     $partials = array('_page', '_action');
     $keys = array();
     foreach ($actions as $action) {
         foreach ($partials as $partial) {
             $url = 'list/' . $action . '?id=' . $id . '&slug=' . LsSlug::convertNameToSlug($list['name']) . '&_sf_cache_key=' . $partial;
             $keys[] = self::generateCacheKey($url);
         }
     }
     return $keys;
 }