コード例 #1
0
ファイル: Blog_Form.php プロジェクト: HaldunA/phpwebsite
 public static function settings()
 {
     $form = new PHPWS_Form();
     $form->addHidden('module', 'blog');
     $form->addHidden('action', 'admin');
     $form->addHidden('command', 'post_settings');
     $form->addText('blog_limit', PHPWS_Settings::get('blog', 'blog_limit'));
     $form->setSize('blog_limit', 2, 2);
     $form->setLabel('blog_limit', dgettext('blog', 'Entries shown per page'));
     $form->addCssClass('blog_limit', 'form-control');
     $form->addText('past_entries', PHPWS_Settings::get('blog', 'past_entries'));
     $form->setLabel('past_entries', dgettext('blog', 'Previous entries shown'));
     $form->setSize('past_entries', 2, 2);
     $form->addCssClass('past_entries', 'form-control');
     // Show/hide posted on date
     $form->addCheck('show_posted_date', 1);
     $form->setLabel('show_posted_date', dgettext('blog', 'Show the date the post was made'));
     $form->setMatch('show_posted_date', PHPWS_Settings::get('blog', 'show_posted_date'));
     // Show/hide posted by user full name
     $form->addCheck('show_posted_by', 1);
     $form->setLabel('show_posted_by', dgettext('blog', 'Show the author\'s name'));
     $form->setMatch('show_posted_by', PHPWS_Settings::get('blog', 'show_posted_by'));
     $form->addCheck('simple_image', 1);
     $form->setLabel('simple_image', dgettext('blog', 'Use Image Manager'));
     $form->setMatch('simple_image', PHPWS_Settings::get('blog', 'simple_image'));
     $form->addCheck('mod_folders_only', 1);
     $form->setLabel('mod_folders_only', dgettext('blog', 'Hide general image folders'));
     $form->setMatch('mod_folders_only', PHPWS_Settings::get('blog', 'mod_folders_only'));
     $form->addCheck('home_page_display', 1);
     $form->setLabel('home_page_display', dgettext('blog', 'Show blog on home page'));
     $form->setMatch('home_page_display', PHPWS_Settings::get('blog', 'home_page_display'));
     $form->addCheck('logged_users_only', 1);
     $form->setLabel('logged_users_only', dgettext('blog', 'Logged user view only'));
     $form->setMatch('logged_users_only', PHPWS_Settings::get('blog', 'logged_users_only'));
     PHPWS_Core::initModClass('users', 'Action.php');
     $groups = User_Action::getGroups('group');
     if (!empty($groups)) {
         $group_match = array();
         $group_match_str = PHPWS_Settings::get('blog', 'view_only');
         if (!empty($group_match_str)) {
             $group_match = explode(':', $group_match_str);
         }
         $form->addMultiple('view_only', $groups);
         $form->setLabel('view_only', dgettext('blog', 'Limit blog to specific groups'));
         $form->setMatch('view_only', $group_match);
         $form->addCssClass('view_only', 'form-control');
     }
     $show[0] = dgettext('blog', 'Do not show');
     $show[1] = dgettext('blog', 'Only on home page');
     $show[2] = dgettext('blog', 'Always');
     $form->addSelect('show_recent', $show);
     $form->setLabel('show_recent', dgettext('blog', 'Show recent entries'));
     $form->setMatch('show_recent', PHPWS_Settings::get('blog', 'show_recent'));
     $form->addCssClass('show_recent', 'form-control');
     $form->addTextField('max_width', PHPWS_Settings::get('blog', 'max_width'));
     $form->setLabel('max_width', dgettext('blog', 'Maximum image width (50-2048)'));
     $form->setSize('max_width', 4, 4);
     $form->addCssClass('max_width', 'form-control');
     $form->addTextField('max_height', PHPWS_Settings::get('blog', 'max_height'));
     $form->setLabel('max_height', dgettext('blog', 'Maximum image height (50-2048)'));
     $form->setSize('max_height', 4, 4);
     $form->addCssClass('max_height', 'form-control');
     $form->addTextArea('comment_script', PHPWS_Settings::get('blog', 'comment_script'));
     $form->setLabel('comment_script', dgettext('blog', 'Paste in your comment code here (e.g. Disqus, Livefyre, Facebook, etc.)'));
     $form->addCssClass('comment_script', 'form-control');
     $form->addSubmit(dgettext('blog', 'Save settings'));
     if (Current_User::isDeity()) {
         $date_script = javascript('datetimepicker', array('format' => 'Y/m/d', 'timepicker' => false, 'id' => 'phpws_form_purge_date'), false, true, true);
         $form->addText('purge_date', date('Y/m/d', time() - 31536000));
         $form->setLabel('purge_date', dgettext('blog', 'Purge all entries before this date'));
         $form->addCssClass('purge_date', 'form-control datetimepicker');
         $form->addSubmit('purge_confirm', dgettext('blog', 'Confirm purge'));
         $form->setClass('purge_confirm', 'btn btn-danger');
     } else {
         $date_script = null;
     }
     $template = $form->getTemplate();
     $template['date_script'] = $date_script;
     if (PHPWS_Settings::get('blog', 'allow_anonymous_submits')) {
         $template['MENU_LINK'] = PHPWS_Text::secureLink(dgettext('blog', 'Clip for menu'), 'blog', array('action' => 'admin', 'command' => 'menu_submit_link'));
     }
     $template['VIEW_LABEL'] = dgettext('blog', 'View');
     $template['SUBMISSION_LABEL'] = dgettext('blog', 'Submission');
     $template['PAST_NOTE'] = dgettext('blog', 'Set to zero to prevent display');
     $template['COMMENTS_LABEL'] = dgettext('blog', 'Commenting');
     return PHPWS_Template::process($template, 'blog', 'settings.tpl');
 }
コード例 #2
0
ファイル: Whatsnew.php プロジェクト: HaldunA/phpwebsite
 function getKeyMods($match = null, $select_name = 'exclude', $multiple = true, $count = true)
 {
     PHPWS_Core::initCoreClass('Key.php');
     $db = new PHPWS_DB('phpws_key');
     $db->addOrder('module asc');
     $result = $db->getObjects('Key');
     if ($result) {
         foreach ($result as $item) {
             if ($count) {
                 $db = new PHPWS_DB('phpws_key');
                 $db->addWhere('module', $item->module);
                 $qty = $db->count();
                 if ($qty == 1) {
                     $qty_label = dgettext('whatsnew', 'item');
                 } else {
                     $qty_label = dgettext('whatsnew', 'items');
                 }
                 $items[$item->module] = $item->module . ' (' . $qty . ' ' . $qty_label . ')';
             } else {
                 $items[$item->module] = $item->module;
             }
         }
     }
     if ($items) {
         if ($multiple) {
             $form = new PHPWS_Form();
             $form->addMultiple($select_name, $items);
             if (!empty($match) && is_array($match)) {
                 $form->setMatch($select_name, $match);
             }
             return $form->get($select_name);
         } else {
             $form = new PHPWS_Form();
             $form->addSelect($select_name, $items);
             if (!empty($match) && is_string($match)) {
                 $form->setMatch($select_name, $match);
             }
             return $form->get($select_name);
         }
     } else {
         return dgettext('whatsnew', 'No keyed items.');
     }
 }
コード例 #3
0
ファイル: Checkin_Admin.php プロジェクト: HaldunA/phpwebsite
 public function editStaff()
 {
     $form = new PHPWS_Form('edit-staff');
     $form->addHidden('module', 'checkin');
     $form->addHidden('aop', 'post_staff');
     if (!$this->staff->id) {
         javascript('jquery');
         javascriptMod('checkin', 'search_user');
         $this->title = dgettext('checkin', 'Add staff member');
         $form->addText('username');
         $form->setLabel('username', dgettext('checkin', 'Staff user name'));
         $form->addSubmit(dgettext('checkin', 'Add staff'));
     } else {
         $this->title = dgettext('checkin', 'Edit staff member');
         $form->addHidden('staff_id', $this->staff->id);
         $form->addTplTag('USERNAME', $this->staff->display_name);
         $form->addTplTag('USERNAME_LABEL', dgettext('checkin', 'Staff user name'));
         $form->addSubmit(dgettext('checkin', 'Update staff'));
     }
     // array of values to use with setMatch()
     $checks = array();
     $checks['last_name'] = $this->staff->filter_type & LAST_NAME_BITMASK ? 'yes' : 'no';
     $checks['reason'] = $this->staff->filter_type & REASON_BITMASK ? 'yes' : 'no';
     $checks['gender'] = $this->staff->filter_type & GENDER_BITMASK ? 'yes' : 'no';
     $checks['birthdate'] = $this->staff->filter_type & BIRTHDATE_BITMASK ? 'yes' : 'no';
     // Add checkbox for "Last Name" filter
     $form->addCheck('last_name', 'yes');
     $form->setMatch('last_name', $checks['last_name']);
     $form->setLabel('last_name', dgettext('checkin', 'Last Name'));
     $form->addText('last_name_filter', $this->staff->lname_filter);
     $form->setLabel('last_name_filter', dgettext('checkin', 'Example: a,b,ca-cf,d'));
     // Add checkbox for "Reasons" filter
     $reasons = $this->getReasons();
     if (!empty($reasons)) {
         $form->addCheck('reason', 'yes');
         $form->setMatch('reason', $checks['reason']);
         $form->setLabel('reason', dgettext('checkin', 'Reason'));
         $form->addMultiple('reason_filter', $reasons);
         $form->setMatch('reason_filter', $this->staff->_reasons);
     }
     // Add checkbox for "Gender" filter
     if (PHPWS_Settings::get('checkin', 'gender')) {
         $form->addCheck('gender', 'yes');
         $form->setMatch('gender', $checks['gender']);
         $form->setLabel('gender', dgettext('checkin', 'Gender'));
         $form->addSelect('gender_filter', array('male' => 'Male', 'female' => 'Female'));
         $form->setMatch('gender_filter', $this->staff->gender_filter);
     }
     // Add checkbox for "Birthdate" filter
     if (PHPWS_Settings::get('checkin', 'birthdate')) {
         javascript('datepicker');
         $form->addCheck('birthdate', 'yes');
         $form->setMatch('birthdate', $checks['birthdate']);
         $form->setLabel('birthdate', dgettext('checkin', 'Birthdate'));
         // Fill the date picker with the current filter start date if it is set
         if (isset($this->staff->birthdate_filter_start)) {
             $form->addText('start_date', date('m/d/Y', $this->staff->birthdate_filter_start));
         } else {
             $form->addText('start_date', date('m/d/Y'));
         }
         $form->setSize('start_date', 10);
         $form->setExtra('start_date', 'class="datepicker"');
         // Fill the date picker with the current filter end date if it is set
         if (isset($this->staff->birthdate_filter_end)) {
             $form->addText('end_date', date('m/d/Y', $this->staff->birthdate_filter_end));
         } else {
             $form->addText('end_date', date('m/d/Y'));
         }
         $form->setSize('end_date', 10);
         $form->setExtra('end_date', 'class="datepicker"');
     }
     $tpl = $form->getTemplate();
     $tpl['FILTER_LEGEND'] = dgettext('checkin', 'Visitor filter');
     $tpl['STAFF_NOTE'] = dgettext('checkin', 'Note: Staff members with no filters will not have visitors automatically assigned to them.');
     $this->content = PHPWS_Template::process($tpl, 'checkin', 'edit_staff.tpl');
 }