protected function displayContent() { $stats = $this->getPhotoStats(); if ($stats->last_date === null) { echo Pinhole::_('No photos have been added.'); } else { $locale = SwatI18NLocale::get(); $first_date = new SwatDate($stats->first_date); $last_date = new SwatDate($stats->last_date); echo '<ul>'; $li_tag = new SwatHtmlTag('li'); $li_tag->setContent(sprintf(Pinhole::_('%s photos have been uploaded since ' . '<a href="%stag?date.date=%s">%s</a>'), $locale->formatNumber($stats->photo_count), $this->app->config->pinhole->path, $first_date->formatLikeIntl('yyyy-MM-dd'), $first_date->formatLikeIntl(SwatDate::DF_DATE)), 'text/xml'); $li_tag->display(); $days = $last_date->diff($first_date)->days; $avg = round((double) $stats->photo_count / (double) $days, 2); $li_tag = new SwatHtmlTag('li'); $li_tag->setContent(sprintf(Pinhole::_('Approximately %s photos have been uploaded ' . 'per day'), $locale->formatNumber($avg))); $li_tag->display(); $li_tag->setContent(sprintf(Pinhole::_('Last photo uploaded on ' . '<a href="%stag?date=%s">%s</a>'), $this->app->config->pinhole->path, $last_date->formatLikeIntl('yyyy-MM-dd'), $last_date->formatLikeIntl(SwatDate::DF_DATE)), 'text/xml'); $li_tag->display(); $tag_stats = $this->getTagStats(); if ($tag_stats->tag_count > 0) { $li_tag = new SwatHtmlTag('li'); $li_tag->setContent(sprintf(Pinhole::_('<a href="%s/tags/alphabetical">%s tags</a> ' . 'have been added'), $this->app->config->pinhole->path, $locale->formatNumber($tag_stats->tag_count)), 'text/xml'); $li_tag->display(); $a_tag = new SwatHtmlTag('a'); $a_tag->setContent($tag_stats->popular_tag_title); $a_tag->href = $this->app->config->pinhole->path . 'tag?' . SwatString::minimizeEntities($tag_stats->popular_tag_name); $li_tag = new SwatHtmlTag('li'); $li_tag->setContent(sprintf(Pinhole::_('The most popular tag “%s” has %s photos'), (string) $a_tag, $locale->formatNumber($tag_stats->popular_tag_count)), 'text/xml'); $li_tag->display(); } echo '</ul>'; } }
protected function buildTitle() { $this->layout->data->html_title = Blorg::_('Authors'); $authors = array(); foreach ($this->authors as $author) { $authors[] = sprintf(Blorg::_('%s - %s'), $author->name, SwatString::ellipsizeRight(SwatString::condense($author->description), 200)); } $this->layout->data->meta_description = SwatString::minimizeEntities(implode('; ', $authors)); }
protected function displayContent() { $username = $this->getValue('username'); if ($username == '') { $what = 'front/all'; } else { $username = SwatString::minimizeEntities(urlencode($username)); $what = 'user/dugg/' . $username; } printf('<script type="text/javascript" ' . 'src="http://digg.com/diggjs/%s/3"></script>', $what); }
protected function displayTitle() { $list = $this->tag_list; if ($list->getGeoTaggedPhotoCount() == $list->getPhotoCount()) { $message = Pinhole::_('View all of these photos on a map.'); } else { $locale = SwatI18NLocale::get(); $message = sprintf(Pinhole::_('View %s of these photos on a map.'), $locale->formatNumber($list->getGeoTaggedPhotoCount())); } echo SwatString::minimizeEntities($message); }
public function display() { if (!$this->visible) { return; } if ($this->tag_list === null) { return; } if ($this->sub_tag_list === null || count($this->sub_tag_list) == 0) { return; } parent::display(); $div_tag = new SwatHtmlTag('div'); $div_tag->class = 'pinhole-sub-tag-list-view'; $div_tag->id = $this->id; $div_tag->open(); if (count($this->tag_list) > 0) { $titles = array(); foreach ($this->tag_list as $tag) { $titles[] = $tag->getTitle(); } $header_tag = new SwatHtmlTag('h2'); $header_tag->setContent(sprintf(Pinhole::_('View photos tagged “%s” and:'), implode('”, “', $titles))); $header_tag->display(); } elseif ($this->title !== null) { $header_tag = new SwatHtmlTag('h2'); $header_tag->setContent($this->title); $header_tag->display(); } $ul_tag = new SwatHtmlTag('ul'); $ul_tag->id = $this->id . '_list'; $ul_tag->open(); $li_tag = new SwatHtmlTag('li'); foreach ($this->sub_tag_list as $tag) { $add_list = clone $this->tag_list; $add_list->add($tag); $li_tag->open(); $add_anchor_tag = new SwatHtmlTag('a'); $add_anchor_tag->class = 'pinhole-tag-list-view-tag'; $add_anchor_tag->rel = 'tag'; $add_anchor_tag->href = $this->base . '?' . $add_list->__toString(); $add_anchor_tag->setContent($tag->getTitle()); if ($tag->photo_count !== null) { $add_anchor_tag->title = sprintf('%s %s', SwatString::minimizeEntities(SwatString::numberFormat($tag->photo_count)), SwatString::minimizeEntities(Pinhole::ngettext('Photo', 'Photos', $tag->photo_count))); } $add_anchor_tag->display(); $li_tag->close(); unset($add_list); } $ul_tag->close(); $div_tag->close(); }
protected function displayHeaderTitleText() { $site_title = $this->app->config->site->title; $h1_tag = new SwatHtmlTag('h1'); $h1_tag->title = $site_title; $h1_tag->open(); echo '<span>'; $source = $this->app->getPage()->getSource(); if ($source != '') { $a_tag = new SwatHtmlTag('a'); $a_tag->accesskey = '1'; $a_tag->href = '.'; $a_tag->open(); } $words = explode(' ', $site_title); $count = 0; $word_span = new SwatHtmlTag('span'); $letter_span = new SwatHtmlTag('span'); $letter_span->class = 'first-letter'; $num_words = count($words); foreach ($words as $word) { $word = trim($word); if ($word != '') { $count++; $word_span->class = sprintf('title-%s', $count); $word_span->open(); $letter_span->setContent(substr($word, 0, 1)); $letter_span->display(); echo SwatString::minimizeEntities(substr($word, 1)); $word_span->close(); // don't display a space for the last word if ($count < $num_words) { echo ' '; } } } if ($source != '') { $a_tag->close(); } echo '</span>'; $h1_tag->close(); }
public function getCreditTitle($hours, $credit_count = 1, $is_free = false) { $locale = SwatI18NLocale::get(); return sprintf(SwatString::minimizeEntities($is_free ? CME::_('%s Free %s%s%s certified by %s') : CME::_('%s %s%s%s certified by %s')), SwatString::minimizeEntities($locale->formatNumber($hours)), '<em>', abs($hours - 1.0) < 0.01 ? SwatString::minimizeEntities($this->credit_title) : SwatString::minimizeEntities($this->credit_title_plural), '</em>', SwatString::minimizeEntities($this->title)); }
protected function buildInternal() { parent::buildInternal(); if ($this->author->shortname === null) { $uri = Blorg::_('this author’s public page'); } else { $uri = $this->app->getFrontendBaseHref() . $this->app->config->blorg->path . 'author/' . $this->author->shortname; $uri = '<em>' . SwatString::minimizeEntities($uri) . '</em>'; } $note = $this->ui->getWidget('openid_note'); $note->content = sprintf($note->content, $uri); }
protected function buildTitle() { $this->layout->data->html_title = $this->author->name; $this->layout->data->meta_description = SwatString::minimizeEntities(SwatString::ellipsizeRight(SwatString::condense($this->author->bodytext), 300)); }
protected function displayHeaderTitleText() { $source = $this->app->getPage()->getSource(); $site_title = $this->app->config->site->title; $h1_tag = new SwatHtmlTag('h1'); $h1_tag->title = $site_title; $h1_tag->open(); echo '<span>'; if ($source == '') { echo SwatString::minimizeEntities($site_title); } else { $a_tag = new SwatHtmlTag('a'); $a_tag->accesskey = '1'; $a_tag->href = '.'; $a_tag->setContent($site_title); $a_tag->display(); } echo '</span>'; $h1_tag->close(); }
protected function getDescription() { $description = trim($this->gadget_description); $description = SwatString::minimizeEntities($description); $description = SwatString::linkify($description); // normalize whitespace $description = str_replace("\r\n", "\n", $description); $description = str_replace("\r", "\n", $description); // convert double line breaks to paragraphs $description = preg_replace('/[\\xa0\\s]*\\n[\\xa0\\s]*\\n[\\xa0\\s]*/su', '</p><p>', $description); $description = '<p>' . $description . '</p>'; return $description; }
protected function buildTagsContent() { $sql = sprintf('select * from PinholeTag where PinholeTag.id in ( select tag from PinholePhotoTagBinding inner join PinholePhoto on PinholePhoto.id = PinholePhotoTagBinding.photo inner join ImageSet on PinholePhoto.image_set = ImageSet.id where %1$s) and PinholeTag.id not in ( select tag from PinholePhotoTagBinding where photo not in (select PinholePhoto.id from PinholePhoto inner join ImageSet on PinholePhoto.image_set = ImageSet.id where %1$s) )', $this->getWhereClause()); $tags = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('PinholeTagDataObjectWrapper')); if (count($tags) == 0) { $this->ui->getWidget('processing_tags')->classes[] = 'swat-hidden'; } ob_start(); foreach ($tags as $tag) { $div_tag = new SwatHtmlTag('div'); $div_tag->open(); echo SwatString::minimizeEntities($tag->title) . ' ('; $a_tag = new SwatHtmlTag('a'); $a_tag->setContent('edit'); $a_tag->href = 'Tag/Edit?id=' . $tag->id; $a_tag->display(); echo ', '; $a_tag = new SwatHtmlTag('a'); $a_tag->setContent('merge'); $a_tag->href = 'Tag/Merge?id=' . $tag->id; $a_tag->display(); echo ', '; $a_tag = new SwatHtmlTag('a'); $a_tag->setContent('delete'); $a_tag->href = 'Tag/Delete?id=' . $tag->id; $a_tag->display(); echo ')'; $div_tag->close(); } $this->ui->getWidget('processing_tags_content')->content = ob_get_clean(); }
/** * Creates a new tag * * @throws SwatException if no database connection is set on this tag * entry control. */ protected function insertTag($title, $index) { if ($this->app === null) { throw new SwatException('An application must be set on the tag entry control during ' . 'the widget init phase.'); } // check to see if the tag already exists $instance_id = $this->app->getInstanceId(); $sql = sprintf('select * from PinholeTag where lower(title) = lower(%s) and instance %s %s', $this->app->db->quote($title, 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer')); $tags = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('PinholeTagDataObjectWrapper')); // only insert if no tag already exists (prevents creating two tags on // reloading) if (count($tags) > 0) { $tag_obj = $tags->getFirst(); } else { $tag_obj = new PinholeTagDataObject(); $tag_obj->setDatabase($this->app->db); $tag_obj->instance = $instance_id; $tag_obj->title = $title; $tag_obj->save(); $message = new SwatMessage(sprintf(Pinhole::_('“%s” tag has been added'), SwatString::minimizeEntities($tag_obj->title))); $message->content_type = 'text/xml'; $message->secondary_content = sprintf(Pinhole::_('You can <a href="Tag/Edit?id=%d">edit this tag</a> ' . 'to customize it.'), $tag_obj->id); $this->app->messages->add($message); } $this->tag_array[$tag_obj->name] = $tag_obj->title; $this->selected_tag_array[$tag_obj->name] = $tag_obj->title; }
protected function getListOptionTitle(CMEFrontMatter $front_matter) { $account = $this->app->session->account; $hours = $account->getEarnedCMECreditHoursByFrontMatter($front_matter); $locale = SwatI18NLocale::get(); ob_start(); $this->displayTitle($front_matter); $field = abs($hours - 1.0) < 0.01 ? 'credit_title' : 'credit_title_plural'; $titles = array(); foreach ($front_matter->providers as $provider) { $em_tag = new SwatHtmlTag('em'); $em_tag->setContent($provider->{$field}); $titles[] = $em_tag->__toString(); } $formatted_provider_credit_title = SwatString::toList($titles); $hours_span = new SwatHtmlTag('span'); $hours_span->class = 'hours'; $hours_span->setContent(sprintf(CME::_('%s %s from %s'), SwatString::minimizeEntities($locale->formatNumber($hours)), $formatted_provider_credit_title, SwatString::minimizeEntities($front_matter->getProviderTitleList())), 'text/xml'); $hours_span->display(); $details = $this->getFrontMatterDetails($front_matter); if ($details != '') { $details_span = new SwatHtmlTag('span'); $details_span->class = 'details'; $details_span->setContent($details); $details_span->display(); } return ob_get_clean(); }
protected function buildTitle() { $this->layout->data->title = sprintf(CME::_('%s Evaluation'), SwatString::minimizeEntities($this->front_matter->getProviderTitleList())); }
protected function displayTag(PinholeTag $tag) { $add_list = clone $this->tag_list; $add_list->add($tag); $add_anchor_tag = new SwatHtmlTag('a'); $add_anchor_tag->rel = 'tag'; $add_anchor_tag->href = $this->app->config->pinhole->path . 'tag?' . $add_list->__toString(); $add_anchor_tag->setContent($tag->getTitle()); if ($tag->photo_count !== null) { $add_anchor_tag->title = sprintf('%s %s', SwatString::minimizeEntities(SwatString::numberFormat($tag->photo_count)), SwatString::minimizeEntities(Pinhole::ngettext('Photo', 'Photos', $tag->photo_count))); } $add_anchor_tag->display(); }
protected function buildMetaDescription() { $this->layout->data->meta_description = SwatString::minimizeEntities(SwatString::ellipsizeRight(SwatString::condense($this->post->bodytext), 300)); }
public function processActions(SwatTableView $view, SwatActions $actions) { $message = null; $items = SwatDB::implodeSelection($this->app->db, $view->getSelection(), 'integer'); switch ($actions->selected->id) { case 'delete': $this->app->replacePage($this->getComponentName() . '/Delete'); $this->app->getPage()->setItems($view->getSelection()); break; case 'enable': $this->publishPosts($view->getSelection()); break; case 'disable': $instance_id = $this->app->getInstanceId(); $num = SwatDB::exec($this->app->db, sprintf('update BlorgPost set enabled = %s where instance %s %s and id in (%s)', $this->app->db->quote(false, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items)); if ($num > 0 && isset($this->app->memcache)) { $this->app->memcache->flushNs('posts'); } $message = new SwatMessage(sprintf(Blorg::ngettext('One post has been hidden on site.', '%s posts have been hidden on site.', $num), SwatString::numberFormat($num))); break; case 'tags_action': $tag_array = $this->ui->getWidget('tags')->getSelectedTagArray(); if (count($tag_array) > 0) { $posts = $this->getPostsFromSelection($view->getSelection()); foreach ($posts as $post) { $post->addTagsByShortname($tag_array); } if (isset($this->app->memcache)) { $this->app->memcache->flushNs('posts'); $this->app->memcache->flushNs('tags'); } $num = count($view->getSelection()); $num_tags = count($tag_array); if ($num_tags === 1) { $tag = reset($tag_array); $message = new SwatMessage(sprintf(Blorg::ngettext('The tag “%s” has been added to one post.', 'The tag “%s” has been added to %s posts.', $num), SwatString::minimizeEntities($tag), SwatString::numberFormat($num))); } else { $message = new SwatMessage(sprintf(Blorg::ngettext('%s tags have been added to one post.', '%s tags have been added to %s posts.', $num), SwatString::numberFormat($num_tags), SwatString::numberFormat($num))); } // clear selected tags $this->ui->getWidget('tags')->setSelectedTagArray(array()); } break; } if ($message !== null) { $this->app->messages->add($message); } }