示例#1
0
 static function getUri($list)
 {
     if (!$list['id'] || !$list['name']) {
         return null;
     }
     return 'http://littlesis.org/list/' . $list['id'] . '/' . LsSlug::convertNameToSlug($list['name']);
 }
示例#2
0
 public function executeSlug($request)
 {
     $this->checkList($request);
     //check that the entity has the given name
     $name = LsSlug::convertSlugToName($request->getParameter('slug'));
     if ($this->list->name != $name) {
         $this->forward404();
     }
     $this->forward('list', $request->getParameter('target', 'view'));
 }
示例#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);
 }
示例#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']);
 }
示例#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;
 }
示例#6
0
 public function executeOrg($request)
 {
     if ($id = $request->getParameter('id')) {
         //id given, we check that the id exists
         $this->checkEntity($request);
         $this->forward404Unless($this->entity['primary_ext'] == 'Org');
         //check that the entity has the given name
         $name = LsSlug::convertSlugToName($request->getParameter('slug'));
         //if the name isn't primary, we redirect to the url with the primary name
         if ($this->entity->rawGet('name') != $name) {
             $params = $request->getParameterHolder()->getAll();
             if ($params['target'] == 'view') {
                 $params['target'] = null;
             }
             $url = EntityTable::generateRoute($this->entity, $params['target'], $params);
             $this->redirect($url);
         }
     } else {
         $entities = EntityTable::getBySlug($request->getParameter('slug'), 'Org', $useAliases = true);
         switch ($q->count()) {
             case 0:
                 $this->forward404();
                 break;
             case 1:
                 $this->entity = $entities[0];
                 $request->setParameter('id', $this->entity->id);
                 break;
             default:
                 $request->setParameter('extension', 'Org');
                 $this->forward('entity', 'disambiguation');
                 break;
         }
     }
     $this->forward('entity', $request->getParameter('target', 'view'));
 }