Esempio n. 1
0
    public function processActions(SwatTableView $view, SwatActions $actions)
    {
        $num = count($view->getSelection());
        $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':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(true, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been shown on site.', '%s authors have been shown on site.', $num), SwatString::numberFormat($num)));
                break;
            case 'disable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %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('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been hidden on site.', '%s authors have been hidden on site.', $num), SwatString::numberFormat($num)));
                break;
        }
        if ($message !== null) {
            $this->app->messages->add($message);
        }
    }
 protected function getInlineJavaScript()
 {
     $photo_id = $this->getArgument('photo_id');
     $script = sprintf("var map_obj = new PinholeMap(%s, %s, %s);\n", SwatString::quoteJavaScriptString('map'), SwatString::quoteJavaScriptString($this->tag_list->__toString()), $photo_id !== null ? $photo_id : 'null');
     $photos = $this->tag_list->getGpsData();
     $markers = array();
     foreach ($photos as $photo) {
         // group photos that are very close to each other
         $rounded_lat = round($photo->gps_latitude, 4);
         $rounded_long = round($photo->gps_longitude, 4);
         $key = $rounded_lat . '_' . $rounded_long;
         if (array_key_exists($key, $markers)) {
             $markers[$key]->photos[] = $photo->id;
         } else {
             $marker = new StdClass();
             $marker->photos = array($photo->id);
             $marker->latitude = $rounded_lat;
             $marker->longitude = $rounded_long;
             $markers[$key] = $marker;
         }
     }
     foreach ($markers as $marker) {
         $script .= sprintf("map_obj.addMarker(new PinholeMapMarker(%s, %s, [%s]));\n", (double) $marker->latitude, (double) $marker->longitude, implode(', ', $marker->photos));
     }
     return $script;
 }
 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 displayContent()
 {
     $comments = $this->getComments();
     if (count($comments) == 0) {
         echo Pinhole::_('No comments have been made.');
     } else {
         $locale = SwatI18NLocale::get();
         echo '<ul>';
         foreach ($comments as $comment) {
             echo '<li>';
             $date = new SwatDate($comment->createdate);
             $date->convertTZById($this->app->config->date->time_zone);
             $date_diff = $date->getHumanReadableDateDiff();
             $author = $comment->photographer === null ? $comment->fullname : $comment->photographer->fullname;
             $a_tag = new SwatHtmlTag('a');
             $a_tag->href = sprintf('photo/%s#comment%s', $comment->getInternalValue('photo'), $comment->id);
             $a_tag->setContent(sprintf('%s ago by %s', $date_diff, $author));
             $a_tag->display();
             $div_tag = new SwatHtmlTag('div');
             $div_tag->setContent(SwatString::ellipsizeRight(SwatString::condense($comment->bodytext), 100));
             $div_tag->display();
             echo '</li>';
         }
         echo '</ul>';
     }
 }
 protected function getInlineJavaScriptTranslations()
 {
     $accept_text = CME::_('I Have Read the CME Information / Continue');
     $cancel_text = CME::_('Cancel and Return');
     $confirm_text = CME::_('Before you view %s, please attest to reading the following:');
     return sprintf("CMEFrontMatterDisplay.accept_text = %s;\n" . "CMEFrontMatterDisplay.cancel_text = %s;\n" . "CMEFrontMatterDisplay.confirm_text = %s;\n", SwatString::quoteJavaScriptString($accept_text), SwatString::quoteJavaScriptString($cancel_text), SwatString::quoteJavaScriptString($confirm_text));
 }
Esempio n. 6
0
 protected function processActions(SwatTableView $view, SwatActions $actions)
 {
     $num = count($view->getSelection());
     $message = null;
     switch ($actions->selected->id) {
         case 'delete':
             $this->app->replacePage('MetaData/Delete');
             $this->app->getPage()->setItems($view->checked_items);
             break;
         case 'show_details':
             SwatDB::updateColumn($this->app->db, 'PinholeMetaData', 'boolean:visible', true, 'id', $view->getSelection());
             $message = new SwatMessage(sprintf(Pinhole::ngettext('One detail has been enabled.', '%s details have been enabled.', $num), SwatString::numberFormat($num)));
             break;
         case 'dont_show_details':
             SwatDB::updateColumn($this->app->db, 'PinholeMetaData', 'boolean:visible', false, 'id', $view->getSelection());
             $message = new SwatMessage(sprintf(Pinhole::ngettext('One detail has been disabled.', '%s details have been disabled.', $num), SwatString::numberFormat($num)));
             break;
         case 'show_machine':
             SwatDB::updateColumn($this->app->db, 'PinholeMetaData', 'boolean:machine_tag', true, 'id', $view->getSelection());
             $message = new SwatMessage(sprintf(Pinhole::ngettext('One machine tag has been enabled.', '%s machine tags have been enabled.', $num), SwatString::numberFormat($num)));
             break;
         case 'dont_show_machine':
             SwatDB::updateColumn($this->app->db, 'PinholeMetaData', 'boolean:machine_tag', false, 'id', $view->getSelection());
             $message = new SwatMessage(sprintf(Pinhole::ngettext('One machine tag has been disabled.', '%s machine tags have been disabled.', $num), SwatString::numberFormat($num)));
             break;
     }
     if ($message !== null) {
         $this->app->messages->add($message);
     }
 }
Esempio n. 7
0
 protected function getInlineJavaScript()
 {
     $id = SwatString::quoteJavaScriptString($this->id);
     $size = SwatString::quoteJavaScriptString($this->getValue('size'));
     $limit = $this->getValue('limit');
     return sprintf("BlorgFlickrJsonGadget.div = %s\n\t\t\tBlorgFlickrJsonGadget.size = %s;\n\t\t\tBlorgFlickrJsonGadget.limit = %s;", $id, $size, $limit);
 }
Esempio n. 8
0
    protected function processDBData()
    {
        parent::processDBData();
        $item_list = $this->getItemList('integer');
        $instance_id = $this->app->getInstanceId();
        // delete attached files using their dataobjects to remove the actual
        // files
        $sql = sprintf('select * from BlorgFile
			inner join BlorgPost on BlorgPost.id = BlorgFile.post
			where BlorgPost.instance %s %s and BlorgFile.post in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
        $files = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgFileWrapper'));
        foreach ($files as $file) {
            $file->setFileBase('../');
            $file->delete();
        }
        // delete the posts
        $sql = sprintf('delete from BlorgPost
			where instance %s %s and id in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
        $num = SwatDB::exec($this->app->db, $sql);
        if (isset($this->app->memcache)) {
            $this->app->memcache->flushNS('posts');
        }
        $message = new SwatMessage(sprintf(Blorg::ngettext('One post has been deleted.', '%s posts have been deleted.', $num), SwatString::numberFormat($num)));
        $this->app->messages->add($message);
    }
 /**
  * Gets translatable string resources for the JavaScript object for
  * this widget
  *
  * @return string translatable JavaScript string resources for this widget.
  */
 protected function getInlineJavaScriptTranslations()
 {
     $attach_text = SwatString::quoteJavaScriptString(Blorg::_('Attach'));
     $detach_text = SwatString::quoteJavaScriptString(Blorg::_('Detach'));
     $attached_text = SwatString::quoteJavaScriptString(Blorg::_('(attached)'));
     $detached_text = SwatString::quoteJavaScriptString(Blorg::_('(not attached)'));
     return "BlorgFileAttachControl.attach_text = {$attach_text};\n" . "BlorgFileAttachControl.detach_text = {$detach_text};\n" . "BlorgFileAttachControl.attached_text = {$attached_text};\n" . "BlorgFileAttachControl.detached_text = {$detached_text};\n";
 }
Esempio n. 10
0
 public function getProviderTitleList()
 {
     $titles = array();
     foreach ($this->providers as $provider) {
         $titles[] = $provider->title;
     }
     return SwatString::toList($titles);
 }
Esempio n. 11
0
 protected function getInlineJavaScript()
 {
     $config = $this->app->config->pinhole;
     $start_latitude = $config->map_last_latitude === null ? "''" : $config->map_last_latitude;
     $start_longitude = $config->map_last_longitude === null ? "''" : $config->map_last_longitude;
     $start_zoom_level = $config->map_last_zoom_level === null ? "''" : $config->map_last_zoom_level;
     $script = sprintf("var map_obj = new PinholeGeoTagMap(" . "%s, %s, %s, %s);\n", SwatString::quoteJavaScriptString('map'), $start_latitude, $start_longitude, $start_zoom_level);
     return $script;
 }
Esempio n. 12
0
 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));
 }
Esempio n. 13
0
 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);
 }
Esempio n. 14
0
 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);
 }
Esempio n. 15
0
    protected function processDBData()
    {
        parent::processDBData();
        $instance_id = $this->app->getInstanceId();
        $sql = 'delete from PinholePhotographer where id in (%s)
			and instance %s %s';
        $item_list = $this->getItemList('integer');
        $sql = sprintf($sql, $item_list, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $num = SwatDB::exec($this->app->db, $sql);
        $message = new SwatMessage(sprintf(Pinhole::ngettext('One photographer has been deleted.', '%s photographers have been deleted.', $num), SwatString::numberFormat($num)));
        $this->app->messages->add($message);
    }
Esempio n. 16
0
 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();
 }
Esempio n. 17
0
 /**
  * Gets the inline JavaScript for this embed markup view
  *
  * @return string the inline JavaScript for this embed markup view.
  */
 protected function getInlineJavaScript()
 {
     $options = $this->getOptions();
     $values = array();
     $titles = array();
     foreach ($options as $option) {
         $values[] = SwatString::quoteJavaScriptString($option->value);
         $titles[] = SwatString::quoteJavaScriptString($option->title);
     }
     $values = implode(', ', $values);
     $titles = implode(', ', $titles);
     return sprintf("var %s_obj = new BlorgMarkupView('%s', [%s], [%s]);", $this->id, $this->id, $values, $titles);
 }
Esempio n. 18
0
 protected function processDBData()
 {
     parent::processDBData();
     $item_list = $this->getItemList('integer');
     $sql = sprintf('delete from BlorgTag where id in (%s)', $item_list);
     $num = SwatDB::exec($this->app->db, $sql);
     if (isset($this->app->memcache)) {
         $this->app->memcache->flushNs('tags');
         $this->app->memcache->flushNs('posts');
     }
     $message = new SwatMessage(sprintf(Blorg::ngettext('One tag has been deleted.', '%s tags have been deleted.', $num), SwatString::numberFormat($num)));
     $this->app->messages->add($message);
 }
Esempio n. 19
0
    protected function processDBData()
    {
        AdminDBDelete::processDBData();
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('select parent from Article
			where id = %s and instance %s %s', $this->app->db->quote($this->getFirstItem(), 'integer'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $this->parent_id = SwatDB::queryOne($this->app->db, $sql);
        $item_list = $this->getItemList('integer');
        $sql = sprintf('delete from Article
			where id in (%s) and instance %s %s', $item_list, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $num = SwatDB::exec($this->app->db, $sql);
        $message = new SwatMessage(sprintf(Site::ngettext('One article has been deleted.', '%s articles have been deleted.', $num), SwatString::numberFormat($num)));
        $this->app->messages->add($message);
    }
Esempio n. 20
0
 protected function processDBData()
 {
     parent::processDBData();
     if ($this->ui->getWidget('photo_time_zone')->value !== null && $this->ui->getWidget('camera_time_zone')->value !== null) {
         $num = $this->adjustTimeZone();
     } else {
         $num = $this->addDateParts();
     }
     $message = new SwatMessage(sprintf(Pinhole::ngettext('One photo has been updated.', '%s photos have been updated.', $num), SwatString::numberFormat($num)));
     $this->app->messages->add($message);
     if (isset($this->app->memcache)) {
         $this->app->memcache->flushNs('photos');
     }
 }
Esempio n. 21
0
 /**
  * Gets an article id from the given article path
  *
  * @param string $path
  *
  * @return integer the database identifier corresponding to the given
  *                  article path or null if no such identifier exists.
  */
 protected function getArticleId($path)
 {
     // don't try to find articles with invalid UTF-8 in the path
     if (!SwatString::validateUtf8($path)) {
         require_once 'Site/exceptions/SitePathInvalidUtf8Exception.php';
         throw new SitePathInvalidUtf8Exception(sprintf('Path is not valid UTF-8: ‘%s’', SwatString::escapeBinary($path)), 0, $path);
     }
     // don't try to find articles with more than 254 characters in the path
     if (strlen($path) > 254) {
         require_once 'Site/exceptions/SitePathTooLongException.php';
         throw new SitePathTooLongException(sprintf('Path is too long: ‘%s’', $path));
     }
     $instance_id = $this->app->getInstanceId();
     return SwatDB::executeStoredProcOne($this->app->db, 'findArticle', array($this->app->db->quote($path, 'text'), $this->app->db->quote($instance_id, 'integer')));
 }
Esempio n. 22
0
    protected function processDBData()
    {
        parent::processDBData();
        $item_list = $this->getItemList('integer');
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('delete from BlorgAuthor where id in (%s)
			and instance %s %s', $item_list, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $num = SwatDB::exec($this->app->db, $sql);
        if (isset($this->app->memcache)) {
            $this->app->memcache->flushNs('authors');
            $this->app->memcache->flushNs('posts');
        }
        $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been deleted.', '%s authors have been deleted.', $num), SwatString::numberFormat($num)));
        $this->app->messages->add($message);
    }
Esempio n. 23
0
 protected function processDBData()
 {
     parent::processDBData();
     $photos = $this->getPhotos();
     $num = count($photos);
     foreach ($photos as $photo) {
         $photo->setFileBase('../../photos');
         $photo->delete();
     }
     $message = new SwatMessage(sprintf(Pinhole::ngettext('One photo has been deleted.', '%s photos have been deleted.', $num), SwatString::numberFormat($num)));
     $this->app->messages->add($message);
     if (isset($this->app->memcache)) {
         $this->app->memcache->flushNs('photos');
     }
 }
Esempio n. 24
0
 /**
  * Processes photographer actions
  *
  * @param SwatTableView $view the table-view to get selected photographers
  *                             from.
  * @param SwatActions $actions the actions list widget.
  */
 protected function processActions(SwatTableView $view, SwatActions $actions)
 {
     switch ($actions->selected->id) {
         case 'delete':
             $this->app->replacePage('Photographer/Delete');
             $this->app->getPage()->setItems($view->checked_items);
             break;
         case 'status_action':
             $num = count($view->checked_items);
             $status = $this->ui->getWidget('status_flydown')->value;
             SwatDB::updateColumn($this->app->db, 'PinholePhotographer', 'integer:status', $status, 'id', $view->checked_items);
             $message = new SwatMessage(sprintf(Pinhole::ngettext('The status of one photographer has been changed.', 'The status of %s photographers has been changed.', $num), SwatString::numberFormat($num)));
             $this->app->messages->add($message);
             break;
     }
 }
Esempio n. 25
0
 protected function displayContent()
 {
     $comment = $this->data_object;
     $div_tag = new SwatHtmlTag('div');
     $div_tag->setContent($this->data_object->post->getTitle());
     $div_tag->display();
     $h2_tag = new SwatHtmlTag('h2');
     $h2_tag->setContent($this->data_object->fullname);
     $h2_tag->display();
     $abbr_tag = new SwatHtmlTag('abbr');
     $date = clone $comment->createdate;
     $date->convertTZ($this->app->default_time_zone);
     $abbr_tag->setContent(sprintf(Blorg::_('Posted: %s'), $date->formatLikeIntl(SwatDate::DF_DATE)));
     $abbr_tag->display();
     echo SwatString::toXHTML($comment->bodytext);
 }
Esempio n. 26
0
    private function generateShortname($instance, $text, $iteration = 0)
    {
        $shortname = SwatString::condenseToName($text);
        if ($iteration != 0) {
            $shortname = $shortname . (string) $iteration;
        }
        $sql = 'select id from BlorgAuthor
			where shortname = %s and instance = %s';
        $sql = sprintf($sql, $this->table->process->dst_db->quote($shortname, 'text'), $this->table->process->dst_db->quote($instance, 'integer'));
        $rs = SwatDB::query($this->table->process->dst_db, $sql);
        if (count($rs) == 0) {
            return $shortname;
        } else {
            return $this->generateShortname($instance, $text, $iteration + 1);
        }
    }
Esempio n. 27
0
 /**
  * Gets translatable string resources for the JavaScript object for
  * this gadget
  *
  * @return string translatable JavaScript string resources for this gadget.
  */
 protected function getInlineJavaScriptTranslations()
 {
     $throbber_text = Blorg::_('loading …');
     $visit_text = Blorg::_('Visit the Last.fm page for this track');
     $none_text = Blorg::_('‹none›');
     $months = array();
     $short_months = array();
     $date = new SwatDate('2000-01-01T00:00:00Z');
     for ($i = 1; $i <= 12; $i++) {
         $months[] = SwatString::quoteJavaScriptString($date->formatLikeIntl('MMMM'));
         $short_months[] = SwatString::quoteJavaScriptString($date->formatLikeIntl('MMM'));
         $date->setMonth($i + 1);
     }
     $months = implode(', ', $months);
     $short_months = implode(', ', $short_months);
     return sprintf("BlorgLastFmGadget.throbber_text = '%s';\n" . "BlorgLastFmGadget.visit_text = '%s';\n" . "BlorgLastFmGadget.none_text = '%s';\n" . "BlorgLastFmGadget.months = [%s];\n" . "BlorgLastFmGadget.short_months = [%s];\n", $throbber_text, $visit_text, $none_text, $months, $short_months);
 }
 protected function displayBody(BuildingBlock $block)
 {
     if ($block->bodytext != '') {
         if ($this->getMode('body') === SiteView::MODE_ALL) {
             $div = new SwatHtmlTag('div');
             $div->class = 'building-block-bodytext';
             $div->setContent($block->bodytext, 'text/xml');
             $div->display();
         } elseif ($this->getMode('body') === SiteView::MODE_SUMMARY) {
             $bodytext = SwatString::condense($block->bodytext, $this->body_summary_length);
             $div = new SwatHtmlTag('div');
             $div->class = 'building-block-bodytext';
             $div->setContent($bodytext, 'text/xml');
             $div->display();
         }
     }
 }
Esempio n. 29
0
 protected function processDBData()
 {
     parent::processDBData();
     $sql = 'delete from PinholeTag where instance %s %s';
     $item_list = $this->getItemList('integer');
     $instance_id = $this->app->getInstanceId();
     $sql = sprintf($sql, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
     if (!$this->extended_selected) {
         $sql .= sprintf(' and id in (%s)', $item_list);
     }
     $num = SwatDB::exec($this->app->db, $sql);
     if (isset($this->app->memcache)) {
         $this->app->memcache->flushNs('photos');
     }
     $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been deleted.', '%s tags have been deleted.', $num), SwatString::numberFormat($num)));
     $this->app->messages->add($message);
 }
Esempio n. 30
0
    private function generateShortname($text, $iteration = 0)
    {
        if ($iteration === 0 && preg_match('/^[a-z0-9_-]+$/', $text)) {
            return $text;
        }
        $shortname = SwatString::condenseToName($text);
        if ($iteration != 0) {
            $shortname = $shortname . (string) $iteration;
        }
        $sql = sprintf('select id from BlorgPost where shortname = %s
			and instance = %s', $this->table->process->dst_db->quote($shortname, 'text'), $this->table->process->dst_db->quote($this->table->process->instance, 'integer'));
        $rs = SwatDB::query($this->table->process->dst_db, $sql);
        if (count($rs) == 0) {
            return $shortname;
        } else {
            return $this->generateShortname($text, $iteration + 1);
        }
    }