コード例 #1
1
ファイル: options.form.php プロジェクト: Val-Git/icms2
 public function init()
 {
     $photo = cmsCore::getController('photos');
     return array(array('type' => 'fieldset', 'title' => LANG_OPTIONS, 'childs' => array(new fieldCheckbox('options:auto_user', array('title' => LANG_PHOTOS_O_AUTO_USER, 'hint' => LANG_PHOTOS_O_AUTO_USER_HINT, 'default' => 1)), new fieldCheckbox('options:auto_group', array('title' => LANG_PHOTOS_O_AUTO_GROUP, 'hint' => LANG_PHOTOS_O_AUTO_GROUP_HINT, 'default' => 1)), new fieldCheckbox('options:auto_ctype_item', array('title' => LANG_PHOTOS_O_AUTO_CTYPE_ITEM, 'hint' => LANG_PHOTOS_O_AUTO_CTYPE_ITEM_HINT, 'default' => 1)), new fieldList('options:target', array('title' => LANG_PHOTOS_O_TARGET, 'items' => array(LANG_ALL, LANG_PHOTOS_PUBLIC_ALBUMS, LANG_PHOTOS_USER_ALBUMS), 'default' => 0)), new fieldList('options:album_id', array('title' => LANG_PHOTOS_ALBUM, 'generator' => function () {
         $_items = cmsCore::getModel('content')->limit(false)->disablePrivacyFilter()->getContentItemsForSitemap('albums', array('id', 'title'));
         $items = array('' => '');
         if ($_items) {
             foreach ($_items as $item) {
                 $items[$item['id']] = $item['title'];
             }
         }
         return $items;
     }, 'default' => '')), new fieldList('options:ordering', array('title' => LANG_SORTING, 'items' => array('' => '') + modelPhotos::getOrderList(), 'default' => '')), new fieldList('options:orientation', array('title' => LANG_PHOTOS_O_ORIENTATION, 'items' => modelPhotos::getOrientationList(), 'default' => '')), new fieldList('options:type', array('title' => LANG_PHOTOS_O_TYPE, 'items' => !empty($photo->options['types']) ? array('' => LANG_PHOTOS_ALL) + $photo->options['types'] : array(), 'default' => '')), new fieldNumber('options:width', array('title' => LANG_PHOTOS_SIZE_W . ', ' . mb_strtolower(LANG_PHOTOS_MORE_THAN), 'units' => 'px', 'default' => '')), new fieldNumber('options:height', array('title' => LANG_PHOTOS_SIZE_H . ', ' . mb_strtolower(LANG_PHOTOS_MORE_THAN), 'units' => 'px', 'default' => '')), new fieldNumber('options:limit', array('title' => LANG_LIST_LIMIT, 'default' => 10, 'rules' => array(array('required')))))));
 }
コード例 #2
0
 public function run($data)
 {
     list($ctype, $album, $fields) = $data;
     $is_allow = $album['is_public'] || $album['user_id'] == $this->cms_user->id || $this->cms_user->is_admin;
     if ($is_allow && cmsUser::isAllowed($ctype['name'], 'add')) {
         $this->cms_template->addToolButton(array('class' => 'images', 'title' => LANG_PHOTOS_UPLOAD, 'href' => href_to($this->name, 'upload', $album['id'])));
     }
     $album['filter_panel'] = array('ordering' => modelPhotos::getOrderList(), 'types' => !empty($this->options['types']) ? array('' => LANG_PHOTOS_ALL) + $this->options['types'] : array(), 'orientation' => modelPhotos::getOrientationList(), 'width' => '', 'height' => '');
     $album['filter_values'] = array('ordering' => $this->cms_core->request->get('ordering', $this->options['ordering']), 'types' => $this->cms_core->request->get('types', ''), 'orientation' => $this->cms_core->request->get('orientation', ''), 'width' => $this->cms_core->request->get('width', 0) ?: '', 'height' => $this->cms_core->request->get('height', 0) ?: '');
     $album['url_params'] = array_filter($album['filter_values']);
     $album['filter_selected'] = $album['url_params'];
     if ($album['filter_selected']['ordering'] == $this->options['ordering']) {
         unset($album['filter_selected']['ordering']);
     }
     if (!in_array($album['filter_values']['ordering'], array_keys($album['filter_panel']['ordering']))) {
         $album['filter_values']['ordering'] = 'date_pub';
     }
     if ($album['filter_values']['types'] && !in_array($album['filter_values']['types'], array_keys($album['filter_panel']['types']))) {
         $album['filter_values']['types'] = '';
     }
     if ($album['filter_values']['orientation'] && !in_array($album['filter_values']['orientation'], array_keys($album['filter_panel']['orientation']))) {
         $album['filter_values']['orientation'] = '';
     }
     $album['base_url'] = href_to($ctype['name'], $album['slug'] . '.html') . '?' . http_build_query($album['url_params']);
     foreach ($album['filter_selected'] as $key => $value) {
         if (isset($album['filter_panel'][$key][$value])) {
             $title[] = $album['filter_panel'][$key][$value];
         }
     }
     if (!empty($title)) {
         $album['title'] .= ' — ' . mb_strtolower(implode(', ', $title));
         $album['seo_desc'] .= ' ' . $album['title'];
     }
     return array($ctype, $album, $fields);
 }