/**
  * Returns the sorting buttons for table columns
  */
 public function getSortButtons(&$template)
 {
     if (empty($this->table_columns)) {
         return null;
     }
     if ($this->auto_sort) {
         $sort_columns =& $this->table_columns;
     } else {
         $sort_columns = array_keys($this->sort_headers);
     }
     //test($sort_columns);
     foreach ($sort_columns as $varname) {
         $vars = array();
         $values = $this->getLinkValues();
         if (isset($this->sort_headers[$varname])) {
             if (!empty($this->sort_headers[$varname]['hover'])) {
                 $alt = strip_tags($this->sort_headers[$varname]['hover']) . ' - ';
             } else {
                 $alt = strip_tags($this->sort_headers[$varname]['title']) . ' - ';
             }
         } else {
             $alt = '';
         }
         if (isset($values['module'])) {
             $module = $values['module'];
             unset($values['module']);
         } else {
             $module =& $this->module;
         }
         $anchor = $this->getAnchor();
         if ($anchor) {
             $values['#'] = $anchor;
         }
         $buttonname = str_replace('.', '_', $varname) . '_SORT';
         $values['orderby'] = $varname;
         if ($this->orderby == $varname) {
             if ($this->orderby_dir == 'desc') {
                 unset($values['orderby_dir']);
                 unset($values['orderby']);
                 $alt .= _('Sorted in descending order');
                 $button = Icon::get('sort-down');
             } elseif ($this->orderby_dir == "asc") {
                 $alt .= _('Sorted in ascending order');
                 $values['orderby_dir'] = 'desc';
                 $button = Icon::get('sort-up');
             } else {
                 $alt .= _('Unsorted');
                 $button = Icon::get('sort');
                 $values['orderby_dir'] = 'asc';
             }
             $button->setStyle('margin-right : 5px');
             $button->setAlt($alt);
         } else {
             $alt .= _('Unsorted');
             $button = Icon::get('sort');
             $button->setStyle('margin-right : 5px');
             $button->setAlt($alt);
             $values['orderby_dir'] = 'asc';
         }
         $button_string = $button->__toString();
         if (isset($this->sort_headers[$varname])) {
             $button_string .= $this->sort_headers[$varname]['title'];
         }
         $link = \PHPWS_Text::moduleLink($button_string, $module, $values, null, $alt);
         $template[strtoupper($buttonname)] = $link;
     }
     //var_dump($template);exit;
     return $template;
 }
Example #2
0
<?php

/**
 * @version $Id$
 * @author Matthew McNaney <mcnaney at gmail dot com>
 */
$icon = Icon::get('edit');
$icon->addStyle('float : left; margin-right : 5px;');
define('PS_EDIT', $icon->__toString());
define('PS_ALLOWED_HEADER_TAGS', '<b><strong><i><u><em>');
/**
 * PageSmith uses a text column to store data. If the data exceeds the
 * 65,535, it will cut the data off.
 * Some databases have column types with higher limits. If you want to take
 * advantage of them you will need to alter your ps_text.content column and
 * change the below to false. Do so at your own risk.
 */
define('PS_CHECK_CHAR_LENGTH', true);
Example #3
0
 public function doOldImport()
 {
     DB::delete('DELETE FROM `cache`');
     // delete old data:
     foreach (Auth::user()->accounts()->get() as $acc) {
         $acc->delete();
     }
     foreach (Auth::user()->budgets()->get() as $b) {
         $b->delete();
     }
     foreach (Auth::user()->categories()->get() as $b) {
         $b->delete();
     }
     foreach (Auth::user()->beneficiaries()->get() as $b) {
         $b->delete();
     }
     foreach (Icon::get() as $icon) {
         $icon->delete();
     }
     $data = file_get_contents('http://commondatastorage.googleapis.com/nder/import.json');
     $json = json_decode($data);
     $map = array();
     $map['accounts'] = array();
     $map['icons'] = array();
     // all accounts:
     foreach ($json->accounts as $account) {
         $newAccount = new Account();
         $newAccount->name = Crypt::encrypt($account->name);
         $newAccount->balance = floatval($account->balance);
         $newAccount->fireflyuser_id = Auth::user()->id;
         $newAccount->date = $account->date;
         $newAccount->save();
         $map['accounts'][$account->id] = $newAccount->id;
     }
     // all icons:
     foreach ($json->icons as $icon) {
         $newIcon = new Icon();
         $newIcon->file = $icon->file;
         $newIcon->save();
         $map['icons'][intval($icon->id)] = $newIcon->id;
     }
     // all beneficiaries:
     foreach ($json->beneficiaries as $ben) {
         $nb = new Beneficiary();
         $nb->fireflyuser_id = Auth::user()->id;
         $nb->name = Crypt::encrypt($ben->name);
         $nb->save();
         $map['beneficiaries'][$ben->id] = $nb->id;
     }
     // all budgets
     foreach ($json->budgets as $bd) {
         $nbg = new Budget();
         $nbg->fireflyuser_id = Auth::user()->id;
         $nbg->name = Crypt::encrypt($bd->name);
         $nbg->date = $bd->date;
         $nbg->amount = floatval($bd->amount);
         $nbg->save();
         $map['budgets'][$bd->id] = $nbg->id;
     }
     // all categories:
     foreach ($json->categories as $c) {
         $nc = new Category();
         $nc->fireflyuser_id = Auth::user()->id;
         $nc->icon_id = intval($map['icons'][intval($c->icon_id)]);
         $nc->name = Crypt::encrypt($c->name);
         $nc->showtrend = intval($c->showtrend);
         $nc->save();
         $map['categories'][$c->id] = $nc->id;
     }
     foreach ($json->targets as $t) {
         $nt = new Target();
         $nt->fireflyuser_id = Auth::user()->id;
         $nt->account_id = $map['accounts'][$t->account_id];
         $nt->description = Crypt::encrypt($t->description);
         $nt->amount = floatval($t->amount);
         $nt->duedate = $t->duedate;
         $nt->startdate = $t->startdate;
         $nt->save();
         $map['targets'][$t->id] = $nt->id;
     }
     foreach ($json->transactions as $t) {
         $nt = new Transaction();
         $nt->fireflyuser_id = Auth::user()->id;
         $nt->account_id = $map['accounts'][$t->account_id];
         $nt->budget_id = is_null($t->budget_id) ? NULL : intval($map['budgets'][$t->budget_id]);
         $nt->category_id = is_null($t->category_id) ? NULL : $map['categories'][$t->category_id];
         $nt->beneficiary_id = is_null($t->beneficiary_id) ? NULL : $map['beneficiaries'][$t->beneficiary_id];
         $nt->description = Crypt::encrypt($t->description);
         $nt->amount = floatval($t->amount);
         $nt->date = $t->date;
         $nt->onetime = intval($t->onetime);
         $nt->save();
         $map['transactions'][$t->id] = $nt->id;
     }
     foreach ($json->transfers as $t) {
         $nt = new Transfer();
         $nt->fireflyuser_id = Auth::user()->id;
         $nt->account_from = $map['accounts'][$t->account_from];
         $nt->account_to = $map['accounts'][$t->account_to];
         $nt->category_id = is_null($t->category_id) ? NULL : $map['categories'][$t->category_id];
         $nt->budget_id = is_null($t->budget_id) ? NULL : intval($map['budgets'][$t->budget_id]);
         $nt->target_id = is_null($t->target_id) ? NULL : intval($map['targets'][$t->target_id]);
         $nt->description = Crypt::encrypt($t->description);
         $nt->amount = floatval($t->amount);
         $nt->date = $t->date;
         $nt->save();
         $map['targets'][$t->id] = $nt->id;
     }
     //
     //var_dump($data);
     // create everything from this file.
     // we map the old id's to the new one to save problems.
     return 'Old data successfully imported.';
 }
Example #4
0
 /**
  * Displays the blog entry
  *
  * @param boolean edit       If true, show edit link
  * @param boolean summarized If true, this is a summarized entry
  */
 public function view($edit = true, $summarized = true)
 {
     if (!$this->id) {
         PHPWS_Core::errorPage(404);
     }
     $key = new Key($this->key_id);
     if (!$key->allowView() || !Blog_User::allowView()) {
         Current_User::requireLogin();
         return dgettext('blog', 'You do not have permission to view this entry.');
     }
     $template['TITLE'] = sprintf('<a href="%s" rel="bookmark">%s</a>', $this->getViewLink(true), $this->title);
     $template['TITLE_NO_LINK'] = $this->title;
     if ($this->publish_date > time()) {
         $template['UNPUBLISHED'] = dgettext('blog', 'Unpublished');
     } elseif ($this->expire_date && $this->expire_date < time()) {
         $template['UNPUBLISHED'] = dgettext('blog', 'Expired');
     }
     $template['LOCAL_DATE'] = $this->getPublishDate();
     $summary = $this->getSummary(true);
     $entry = $this->getEntry(true);
     if ($summarized) {
         if (empty($summary)) {
             $template['SUMMARY'] = PHPWS_Text::parseTag($entry);
         } else {
             if (!empty($entry)) {
                 $template['READ_MORE'] = PHPWS_Text::rewriteLink(Icon::get('chevron-circle-down') . '&nbsp;' . dgettext('blog', 'Read more'), 'blog', array('id' => $this->id), null, 'Read more of this entry', 'btn btn-default');
             }
             $template['SUMMARY'] = PHPWS_Text::parseTag($summary);
         }
     } else {
         $template['SUMMARY'] = PHPWS_Text::parseTag($summary);
         $template['ENTRY'] = PHPWS_Text::parseTag($entry);
     }
     $template['IMAGE'] = $this->getFile($this->thumbnail && $summarized);
     if ($edit && (Current_User::allow('blog', 'edit_blog', $this->id, 'entry') || Current_User::allow('blog', 'edit_blog') && $this->author_id == Current_User::getId())) {
         $vars['blog_id'] = $this->id;
         $vars['action'] = 'admin';
         $vars['command'] = 'edit';
         $template['EDIT_LINK'] = PHPWS_Text::secureLink(dgettext('blog', 'Edit'), 'blog', $vars);
         $template['EDIT_URI'] = PHPWS_Text::linkAddress('blog', $vars, true);
         if (!$summarized) {
             MiniAdmin::add('blog', array(PHPWS_Text::secureLink(dgettext('blog', 'Edit blog'), 'blog', $vars)));
         }
     }
     // Check setting for showing when the entry was posted
     if (PHPWS_Settings::get('blog', 'show_posted_by')) {
         $template['POSTED_BY'] = dgettext('blog', 'By');
         $template['AUTHOR'] = $this->author;
     }
     // Check settings for showing the author of the entry
     if (PHPWS_Settings::get('blog', 'show_posted_date')) {
         $template['PUBLISHED'] = dgettext('blog', 'Published');
         $template['POSTED_ON'] = dgettext('blog', 'Posted on');
         $template['PUBLISHED_DATE'] = $this->getPublishDateShort();
     }
     if ($summarized) {
         $view_tpl = 'view_list.tpl';
     } else {
         $template['COMMENT_SCRIPT'] = PHPWS_Settings::get('blog', 'comment_script');
         $key->flag();
         $view_tpl = 'view_full.tpl';
     }
     return PHPWS_Template::process($template, 'blog', $view_tpl);
 }