Exemplo n.º 1
0
 public static function adminRemoveTags($core, dcPostsActionsPage $ap, $post)
 {
     if (!empty($post['meta_id']) && $core->auth->check('delete,contentadmin', $core->blog->id)) {
         $meta =& $core->meta;
         $posts = $ap->getRS();
         while ($posts->fetch()) {
             foreach ($_POST['meta_id'] as $v) {
                 $meta->delPostMeta($posts->post_id, 'tag', $v);
             }
         }
         dcPage::addSuccessNotice(sprintf(__('Tag has been successfully removed from selected entries', 'Tags have been successfully removed from selected entries', count($_POST['meta_id']))));
         $ap->redirect(true);
     } else {
         $meta =& $core->meta;
         $tags = array();
         foreach ($ap->getIDS() as $id) {
             $post_tags = $meta->getMetadata(array('meta_type' => 'tag', 'post_id' => (int) $id))->toStatic()->rows();
             foreach ($post_tags as $v) {
                 if (isset($tags[$v['meta_id']])) {
                     $tags[$v['meta_id']]++;
                 } else {
                     $tags[$v['meta_id']] = 1;
                 }
             }
         }
         if (empty($tags)) {
             throw new Exception(__('No tags for selected entries'));
         }
         $ap->beginPage(dcPage::breadcrumb(array(html::escapeHTML($core->blog->name) => '', __('Entries') => 'posts.php', __('Remove selected tags from this selection') => '')));
         $posts_count = count($_POST['entries']);
         echo '<form action="' . $ap->getURI() . '" method="post">' . $ap->getCheckboxes() . '<div><p>' . __('Following tags have been found in selected entries:') . '</p>';
         foreach ($tags as $k => $n) {
             $label = '<label class="classic">%s %s</label>';
             if ($posts_count == $n) {
                 $label = sprintf($label, '%s', '<strong>%s</strong>');
             }
             echo '<p>' . sprintf($label, form::checkbox(array('meta_id[]'), html::escapeHTML($k)), html::escapeHTML($k)) . '</p>';
         }
         echo '<p><input type="submit" value="' . __('ok') . '" />' . $core->formNonce() . $ap->getHiddenFields() . form::hidden(array('action'), 'tags_remove') . '</p></div></form>';
         $ap->endPage();
     }
 }
Exemplo n.º 2
0
 public static function doChangePostLang($core, dcPostsActionsPage $ap, $post)
 {
     $posts_ids = $ap->getIDs();
     if (empty($posts_ids)) {
         throw new Exception(__('No entry selected'));
     }
     if (isset($post['new_lang'])) {
         $new_lang = $post['new_lang'];
         $cur = $core->con->openCursor($core->prefix . 'post');
         $cur->post_lang = $new_lang;
         $cur->update('WHERE post_id ' . $core->con->in($posts_ids));
         dcPage::addSuccessNotice(sprintf(__('%d entry has been successfully set to language "%s"', '%d entries have been successfully set to language "%s"', count($posts_ids)), count($posts_ids), html::escapeHTML(l10n::getLanguageName($new_lang))));
         $ap->redirect(true);
     } else {
         $ap->beginPage(dcPage::breadcrumb(array(html::escapeHTML($core->blog->name) => '', $ap->getCallerTitle() => $ap->getRedirection(true), __('Change language for this selection') => '')));
         # lang list
         # Languages combo
         $rs = $core->blog->getLangs(array('order' => 'asc'));
         $all_langs = l10n::getISOcodes(0, 1);
         $lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(1, 1));
         while ($rs->fetch()) {
             if (isset($all_langs[$rs->post_lang])) {
                 $lang_combo[__('Most used')][$all_langs[$rs->post_lang]] = $rs->post_lang;
                 unset($lang_combo[__('Available')][$all_langs[$rs->post_lang]]);
             } else {
                 $lang_combo[__('Most used')][$rs->post_lang] = $rs->post_lang;
             }
         }
         unset($all_langs);
         unset($rs);
         echo '<form action="' . $ap->getURI() . '" method="post">' . $ap->getCheckboxes() . '<p><label for="new_lang" class="classic">' . __('Entry language:') . '</label> ' . form::combo('new_lang', $lang_combo, '');
         echo $core->formNonce() . $ap->getHiddenFields() . form::hidden(array('action'), 'lang') . '<input type="submit" value="' . __('Save') . '" /></p>' . '</form>';
         $ap->endPage();
     }
 }