public function executeMenu() { $this->items = array(); if ($this->getUser()->isAuthenticated() && $this->getUser()->getGuardUser()) { $name = $this->getUser()->getGuardUser()->getProfile()->public_name; $network_name = LsListTable::getNameById(sfGuardUserTable::getHomeNetworkId()); $network_path = LsListTable::getDisplayNameById(sfGuardUserTable::getHomeNetworkId()); $this->items[$name]['highlighted'] = true; $this->items[$name]['url'] = 'home/notes'; $this->items[$name]['items'][$this->getContext()->getI18N()->__('Notes')] = 'home/notes'; $this->items[$name]['items'][$this->getContext()->getI18N()->__('Groups')] = 'home/groups'; $this->items[$name]['items'][$this->getContext()->getI18N()->__('Edits')] = 'home/modifications'; $this->items[$name]['items'][$this->getContext()->getI18N()->__('Maps')] = 'home/maps'; $this->items[$name]['items']['divider1'] = 'divider'; $this->items[$name]['items'][$network_name] = '@localHome?name=' . $network_path; $this->items[$name]['items']['divider2'] = 'divider'; $this->items[$name]['items'][$this->getContext()->getI18N()->__('Settings')] = 'home/settings'; $this->items[$name]['items'][$this->getContext()->getI18N()->__('Logout')] = '@sf_guard_signout'; //recent views if ($this->getUser()->getGuardUser()->getProfile()->enable_recent_views && ($entityIds = $this->getUser()->getAttribute('viewed_entity_ids'))) { $this->items[$this->getContext()->getI18N()->__('Recent')] = array('url' => null, 'highlighted' => true, 'items' => array()); //flip entity ids from user session $flippedEntityIds = array_flip($entityIds); $orderedEntities = array(); //get viewed entities from db $entities = LsDoctrineQuery::create()->from('Entity e')->whereIn('e.id', $entityIds)->setHydrationMode(Doctrine::HYDRATE_ARRAY)->execute(); //order entities foreach ($entities as $entity) { $orderedEntities[$flippedEntityIds[$entity['id']]] = $entity; } ksort($orderedEntities); foreach ($orderedEntities as $entity) { $this->items[$this->getContext()->getI18N()->__('Recent')]['items'][$entity['name']] = EntityTable::generateRoute($entity); } } } else { if (sfConfig::get('app_login_enabled')) { $this->items[$this->getContext()->getI18N()->__("Login")] = array('url' => '@sf_guard_signin'); $this->items[$this->getContext()->getI18N()->__("Sign Up")] = array('url' => '@join'); } } $this->items = array_merge($this->items, array($this->getContext()->getI18N()->__('Explore') => array('items' => array($this->getContext()->getI18N()->__('Maps') => '@maps', $this->getContext()->getI18N()->__('Lists') => 'list/list', $this->getContext()->getI18N()->__('Groups') => '@groups', $this->getContext()->getI18N()->__('Notes') => '@notes', $this->getContext()->getI18N()->__('Users') => '@users', $this->getContext()->getI18N()->__('Edits') => '@edits')), $this->getContext()->getI18N()->__('Add') => null, $this->getContext()->getI18N()->__('Help') => array('items' => array($this->getContext()->getI18n()->__('Search Help Pages') => '@help', $this->getContext()->getI18N()->__('Beginner') => '@beginnerhelp', $this->getContext()->getI18N()->__('Advanced') => '@advancedhelp')), $this->getContext()->getI18N()->__('About') => array('items' => array('LittleSis' => '@about', $this->getContext()->getI18N()->__('Features') => '@features', $this->getContext()->getI18N()->__('Our Team') => '@team', $this->getContext()->getI18N()->__('Blog') => 'http://blog.littlesis.org', $this->getContext()->getI18N()->__('Press') => '@press', $this->getContext()->getI18N()->__('Data API') => 'http://api.littlesis.org', $this->getContext()->getI18N()->__('Source Code') => 'https://github.com/littlesis-org/littlesis', $this->getContext()->getI18N()->__('Disclaimer') => '@disclaimer', $this->getContext()->getI18N()->__('Contact Us') => '@contact')))); if (!$this->getUser()->isAuthenticated()) { unset($this->items[$this->getContext()->getI18N()->__('About')]['items'][$this->getContext()->getI18N()->__('Blog')]); $this->items[$this->getContext()->getI18N()->__('Blog')] = array('url' => 'http://blog.littlesis.org'); } if ($this->getUser()->isAuthenticated()) { $this->items[$this->getContext()->getI18N()->__('Add')] = array('items' => array($this->getContext()->getI18N()->__('Person') => 'entity/addPerson', $this->getContext()->getI18N()->__('Organization') => 'entity/addOrg', $this->getContext()->getI18N()->__('List') => 'list/add')); } }
function entity_link($entity, $class = 'text_big', $strong = true, $link_text = null, $htmlOptions = array()) { if (!$link_text) { $link_text = $entity['name']; } if (!isset($htmlOptions['title'])) { $htmlOptions['title'] = $entity['blurb'] ? $entity['blurb'] : 'view profile'; } $link = link_to($link_text, EntityTable::generateRoute($entity), $htmlOptions); if ($strong) { $strongTag = $class ? '<strong class="' . $class . '">' : '<strong>'; $link = $strongTag . $link . '</strong>'; } else { $link = '<span class= "' . $class . '">' . $link . '</span>'; } return $link; }
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); }
<div id="image_gallery" style="visibility: hidden;<?php echo isset($max_height) ? ' max-height: ' . $max_height . ';' : ''; ?> "> <?php foreach ($images as $image) { ?> <?php echo link_to(image_tag('small/' . $image['filename'], array('title' => $image['Entity']['name'], 'alt' => '')), EntityTable::generateRoute($image['Entity'])); } ?> </div> <script type="text/javascript"> if (window.innerHeight !== undefined) { document.getElementById('image_gallery').style.height = window.innerHeight + 'px'; } else { document.getElementById('image_gallery').style.height = document.documentElement.clientHeight + 'px'; } window.onload = function() { gallery = document.getElementById('image_gallery'); gallery.style.visibility = 'visible'; } </script>
<div id="no-relationships" class="cleanup text_big"> This <?php echo strtolower($entity['primary_ext']); ?> has no relationships. Be the first to <?php echo link_to('add one', EntityTable::generateRoute($entity, 'addRelationship')); ?> . </div>
</form> <br /> <br /> <?php if (isset($results_pager)) { ?> <?php include_partial('global/section', array('title' => 'Results', 'pager' => $results_pager)); ?> <div class="padded"> <?php foreach ($results_pager->execute() as $list) { ?> <?php include_partial('list/oneliner', array('list' => $list, 'actions' => array(array('name' => 'add', 'url' => EntityTable::generateRoute($entity, 'addList', array('list_id' => $list->id)), 'options' => 'post=true')))); ?> <?php } ?> </div> <?php } ?>
/** * Generates internal url for any Entity action * * @return string */ public function getInternalUrl($action = null, array $params = null, $hideParams = false) { return EntityTable::generateRoute($this, $action, $params, $hideParams); }
<br /> <br /> <span class="entity-carousel-count">Related <?php echo $entity['primary_ext'] == 'Person' ? 'people' : 'orgs'; ?> : </span> <?php $related_links = array(); ?> <?php foreach ($interlocks as $related) { ?> <?php $related_links[] = entity_link($related, 'entity-carousel-related', false, excerpt($related['name'], 40)); ?> <?php } ?> <?php $related_links[] = '<nobr><strong>' . link_to('More »', EntityTable::generateRoute($entity, 'interlocks')) . '</strong></nobr>'; ?> <?php echo implode(" • ", $related_links); ?> </div> </div> <?php }
<?php if ($entity) { ?> <div class="entity-mini" <?php echo isset($border) ? 'style="border: ' . $border . ';"' : ''; ?> > <div class="entity-mini-image"> <?php $anonFile = $entity['primary_ext'] == 'Person' ? 'mini-anon.png' : 'mini-anons.png'; ?> <?php $image_path = $entity['image_path'] ? 'profile' . DIRECTORY_SEPARATOR . $entity['image_path'] : 'system' . DIRECTORY_SEPARATOR . $anonFile; ?> <?php echo link_to(image_tag($image_path, array('alt' => '')), EntityTable::generateRoute($entity), array('title' => $entity['name'])); ?> </div> <div class="entity-mini-text"> <?php echo entity_link($entity, 'entity-mini-name'); ?> <br /> <?php if ($entity['blurb']) { ?> <span class="entity-mini-description"><?php echo $entity['blurb']; ?>
</tr> <?php } ?> </table> <?php } ?> <?php if ($total == 0) { ?> <br /> No names found on that page. <?php echo link_to("Try again", EntityTable::generateRoute($entity, 'addBoard')); ?> . <?php } elseif ($start > $total) { ?> <br /> All done. <?php echo link_to("Return to " . $entity->getName(), EntityTable::getInternalUrl($entity)); ?> . <?php } else { ?> <br /> <br />
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')); }