function mywordsBlockRecentEdit($options)
{
    $options[5] = isset($options[5]) ? $options[5] : 0;
    $form = '<strong>' . __('Posts Number:', 'mywords') . '</strong><br />
            <input type="text" size="10" value="' . $options[0] . '" name="options[0]" /><br /><br />
            <strong>' . __('Block type:', 'mywords') . '</strong><br />
            <label><input type="radio" name="options[1]"' . (!isset($options[1]) || $options[1] == 'recent' ? ' checked="checked"' : '') . ' value="recent" />
            ' . __('Recent Posts', 'mywords') . '</label>
            <label><input type="radio" name="options[1]"' . (isset($options[1]) && $options[1] == 'popular' ? ' checked="checked"' : '') . ' value="popular" />
            ' . __('Popular Posts', 'mywords') . '</label>
            <label><input type="radio" name="options[1]"' . (isset($options[1]) && $options[1] == 'comm' ? ' checked="checked"' : '') . ' value="comm" />
            ' . __('Most Commented', 'mywords') . '</label><br /><br />
            <strong>' . __('Show text:', 'mywords') . '</strong><br />
            <label><input type="radio" name="options[2]" value="1"' . (isset($options[2]) && $options[2] == 1 ? ' checked="checked"' : '') . ' /> ' . __('Yes', 'mywords') . '</label> 
            <label><input type="radio" name="options[2]" value="0"' . (!isset($options[2]) || $options[2] == 0 ? ' checked="checked"' : '') . ' /> ' . __('No', 'mywords') . '</label>
            <br /><br />
            <strong>Text lenght:</strong> <input type="text" size="10" value="' . (isset($options[3]) ? $options[3] : 50) . '" name="options[3]" />
            <br /><br /><strong>' . __('Show date:', 'mywords') . '</strong> 
            <label><input type="radio" name="options[4]" value="1"' . (isset($options[4]) && $options[4] == 1 ? ' checked="checked"' : '') . ' /> ' . __('Yes', 'mywords') . '</label> 
            <label><input type="radio" name="options[4]" value="0"' . (!isset($options[4]) || $options[4] == 0 ? ' checked="checked"' : '') . ' /> ' . __('No', 'mywords') . '</label>
            <br /><br />';
    $cats = array();
    MWFunctions::categos_list($cats);
    $form .= '<strong>' . __('Posts form category:', 'mywords') . '</strong><br />
            <select name="options[5]">
            <option value="0"' . ($options[5] == 0 ? ' selected="selected"' : '') . '>' . __('Select category...', 'mywords') . '</option>';
    foreach ($cats as $cat) {
        $form .= '<option value="' . $cat['id_cat'] . '"' . ($options[5] == $cat['id_cat'] ? ' selected="selected"' : '') . '>' . str_repeat("&#8212;", $cat['indent']) . $cat['name'] . '</option>';
    }
    $form .= "</select><br /><br />";
    return $form;
}
 /**
  * Get all categories from database arranged by parents
  * 
  * @param mixed $categories
  * @param mixed $parent
  * @param mixed $indent
  * @param mixed $include_subs
  * @param mixed $exclude
  * @param mixed $order
  */
 public function categos_list(&$categories, $parent = 0, $indent = 0, $include_subs = true, $exclude = 0, $order = "id_cat DESC")
 {
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $sql = "SELECT * FROM " . $db->prefix("mw_categories") . " WHERE parent='{$parent}' ORDER BY {$order}";
     $result = $db->query($sql);
     while ($row = $db->fetchArray($result)) {
         if ($row['id_cat'] == $exclude) {
             continue;
         }
         $row['indent'] = $indent;
         $categories[] = $row;
         if ($include_subs) {
             MWFunctions::categos_list($categories, $row['id_cat'], $indent + 1, $include_subs, $exclude);
         }
     }
 }
Beispiel #3
0
function mywordsBlockCats($options)
{
    global $xoopsModuleConfig, $xoopsModule;
    $categos = array();
    MWFunctions::categos_list($categos, 0, 0, $options[0]);
    $block = array();
    $mc = $xoopsModule && $xoopsModule->getVar('dirname') == 'mywords' ? $xoopsModuleConfig : RMSettings::module_settings('mywords');
    foreach ($categos as $k) {
        $ret = array();
        $cat = new MWCategory();
        $cat->assignVars($k);
        $cat->loadPosts();
        $ret['id'] = $cat->id();
        $ret['name'] = $cat->getVar('name');
        if (isset($options[1]) && $options[1]) {
            $ret['posts'] = $cat->getVar('posts');
        }
        $ret['indent'] = $k['indent'] * 2;
        $ret['link'] = $cat->permalink();
        $block['categos'][] = $ret;
    }
    RMTemplate::get()->add_style('mwblocks.css', 'mywords');
    return $block;
}
Beispiel #4
0
    /**
     * Return the feed options to show in RSS Center
     */
    public function eventRmcommonGetFeedsList($feeds)
    {
        include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwfunctions.php';
        load_mod_locale('mywords');
        $module = RMFunctions::load_module('mywords');
        $config = RMUtilities::module_config('mywords');
        $data = array('title' => $module->name(), 'url' => XOOPS_URL . $config['basepath'], 'module' => 'mywords');
        $options[] = array('title' => __('All Recent Posts', 'mywords'), 'params' => 'show=all', 'description' => __('Show all recent posts', 'mywords'));
        $categories = array();
        MWFunctions::categos_list($categories);
        $table = '<table cellpadding="2" cellspacing="2" width="100%"><tr class="even">';
        $count = 0;
        foreach ($categories as $cat) {
            if ($count >= 3) {
                $count = 0;
                $table .= '</tr><tr class="' . tpl_cycle("odd,even") . '">';
            }
            $table .= '<td width="33%"><a href="' . XOOPS_URL . '/backend.php?action=showfeed&amp;mod=mywords&amp;show=cat&amp;cat=' . $cat['id_cat'] . '">' . $cat['name'] . '</a></td>';
            $count++;
        }
        $table .= '</tr></table>';
        $options[] = array('title' => __('Posts by category', 'mywords'), 'description' => __('Select a category to see the posts published recently.', 'mywords') . ' <a href="javascript:;" onclick="$(\'#categories-feed\').slideToggle(\'slow\');">Show Categories</a>
						    <div id="categories-feed" style="padding: 10px; display: none;">' . $table . '</div>');
        unset($categories);
        $tags = MWFunctions::get_tags("*", '', '', 99);
        $table = '<table cellpadding="2" cellspacing="2" width="100%"><tr class="even">';
        $count = 0;
        foreach ($tags as $tag) {
            if ($count >= 3) {
                $count = 0;
                $table .= '</tr><tr class="' . tpl_cycle("odd,even") . '">';
            }
            $table .= '<td width="33%"><a href="' . XOOPS_URL . '/backend.php?action=showfeed&amp;mod=mywords&amp;show=tag&amp;tag=' . $tag['id_tag'] . '">' . $tag['tag'] . '</a></td>';
            $count++;
        }
        $table .= '</tr></table>';
        $options[] = array('title' => __('Show posts by tag', 'mywords'), 'description' => __('Select a tag to see the posts published recently.', 'mywords') . ' <a href="javascript:;" onclick="$(\'#tags-feed\').slideToggle(\'slow\');">Show Tags</a>
						    <div id="tags-feed" style="padding: 10px; display: none;">' . $table . '</div>');
        unset($tags);
        $db = XoopsDatabaseFactory::getDatabaseConnection();
        $sql = "SELECT * FROM " . $db->prefix("mw_editors") . " ORDER BY name";
        $result = $db->query($sql);
        $editors = array();
        while ($row = $db->fetchArray($result)) {
            $editors[] = $row;
        }
        asort($editors);
        $table = '<table cellpadding="2" cellspacing="2" width="100%"><tr class="even">';
        $count = 0;
        foreach ($editors as $ed) {
            if ($count >= 3) {
                $count = 0;
                $table .= '</tr><tr class="' . tpl_cycle("odd,even") . '">';
            }
            $table .= '<td width="33%"><a href="' . XOOPS_URL . '/backend.php?action=showfeed&amp;mod=mywords&amp;show=author&amp;author=' . $ed['id_editor'] . '">' . $ed['name'] . '</a></td>';
            $count++;
        }
        $table .= '</tr></table>';
        $options[] = array('title' => __('Show posts by author', 'mywords'), 'description' => __('Select an author to see the posts published recently.', 'mywords') . ' <a href="javascript:;" onclick="$(\'#editor-feed\').slideToggle(\'slow\');">Show Authors</a>
						    <div id="editor-feed" style="padding: 10px; display: none;">' . $table . '</div>');
        unset($editors);
        unset($table);
        RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.min.js');
        RMTemplate::get()->add_script(RMCURL . '/include/js/jquery-ui.min.js');
        $feed = array('data' => $data, 'options' => $options);
        $feeds[] = $feed;
        return $feeds;
    }
Beispiel #5
0
function mywordsBlockRecentEdit($options)
{
    $options[5] = isset($options[5]) ? $options[5] : 0;
    ob_start();
    $cats = array();
    MWFunctions::categos_list($cats);
    ?>

    <div class="form-horizontal">
        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Posts Number:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <input type="text" size="10" value="<?php 
    echo $options[0];
    ?>
" name="options[0]" />
            </div>

        </div>

        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Block type:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <label class="radio">
                    <input type="radio" name="options[1]"<?php 
    echo !isset($options[1]) || $options[1] == 'recent' ? ' checked="checked"' : '';
    ?>
 value="recent" />
                    <?php 
    _e('Recent Posts', 'mywords');
    ?>
                </label>
                <label class="radio">
                    <input type="radio" name="options[1]"<?php 
    echo !isset($options[1]) || $options[1] == 'popular' ? ' checked="checked"' : '';
    ?>
 value="popular" />
                    <?php 
    _e('Popular Posts', 'mywords');
    ?>
                </label>
                <label class="radio">
                    <input type="radio" name="options[1]"<?php 
    echo !isset($options[1]) || $options[1] == 'comm' ? ' checked="checked"' : '';
    ?>
 value="comm" />
                    <?php 
    _e('Most Commented', 'mywords');
    ?>
                </label>
            </div>

        </div>

        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Show text:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <label class="radio inline"><input type="radio" name="options[2]" value="1"<?php 
    echo isset($options[2]) && $options[2] == 1 ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e('Yes', 'mywords');
    ?>
</label>
                <label class="radio inline"><input type="radio" name="options[2]" value="0"<?php 
    echo !isset($options[2]) || $options[2] == 0 ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e('No', 'mywords');
    ?>
</label>
            </div>

        </div>

        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Text length:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <input type="text" size="10" value="<?php 
    echo isset($options[3]) ? $options[3] : 50;
    ?>
" name="options[3]" />
            </div>

        </div>

        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Show date:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <label class="radio inline"><input type="radio" name="options[4]" value="1"<?php 
    echo isset($options[4]) && $options[4] == 1 ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e('Yes', 'mywords');
    ?>
</label>
                <label class="radio inline"><input type="radio" name="options[4]" value="0"<?php 
    echo !isset($options[4]) || $options[4] == 0 ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e('No', 'mywords');
    ?>
</label>
            </div>

        </div>

        <div class="control-group">

            <label class="control-label"><strong><?php 
    _e('Posts from category:', 'mywords');
    ?>
</strong></label>
            <div class="controls">
                <select name="options[5]">
                    <option value="0"<?php 
    echo $options[5] == 0 ? ' selected="selected"' : '';
    ?>
><?php 
    _e('Select category...', 'mywords');
    ?>
</option>';
                    <?php 
    foreach ($cats as $cat) {
        ?>
                    <option value="<?php 
        echo $cat['id_cat'];
        ?>
"<?php 
        echo $options[5] == $cat['id_cat'] ? ' selected="selected"' : '';
        ?>
><?php 
        echo str_repeat("&#8212;", $cat['indent']) . $cat['name'];
        ?>
</option>
                    <?php 
    }
    ?>
                </select>
            </div>

        </div>
    </div>

    <?php 
    $form = ob_get_clean();
    return $form;
}
Beispiel #6
0
/**
 * Presenta un formulario para la creación de una nueva
 * categoría para los artículos
 */
function newForm()
{
    global $xoopsModule;
    $id = isset($_GET['id']) ? $_GET['id'] : 0;
    if ($id <= 0) {
        redirectMsg('categories.php', __('You must specify a valid category', 'mywords'), 1);
        die;
    }
    // Cargamos la categoría
    $catego = new MWCategory($id);
    // Si no existe entonces devolvemos un error
    if ($catego->isNew()) {
        redirectMsg('cats.php', __('Specified category not exists!', 'mywords'), 1);
        die;
    }
    MWFunctions::include_required_files();
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; ' . __('New Category', 'mywords'));
    xoops_cp_header();
    $cats = array();
    MWFunctions::categos_list($cats, 0, 0, true, $id);
    $form = new RMForm($edit ? __('Edit Category', 'mywords') : __('Edit Category', 'mywords'), 'frmNew', 'categories.php');
    $form->styles('width: 30%;', 'odd');
    $form->addElement(new RMFormText(__('Category name', 'mywords'), 'name', 50, 150, $catego->getVar('name')), true);
    $form->addElement(new RMFormText(__('Category slug', 'mywords'), 'shortname', '', '150', $catego->getVar('shortname', 'n')));
    $form->addElement(new RMFormTextArea(__('Category description', 'mywords'), 'desc', 5, 45, $catego->getVar('description', 'e')));
    $ele = new RMFormSelect(__('Category Parent', 'mywords'), 'parent');
    $ele->addOption(0, _SELECT, $catego->getVar('parent') == 0 ? 1 : 0);
    foreach ($cats as $k) {
        $ele->addOption($k['id_cat'], str_repeat("-", $k['indent']) . ' ' . $k['name'], $catego->getVar('parent') == $k['id_cat'] ? 1 : 0);
    }
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('op', 'saveedit'));
    $form->addElement(new RMFormHidden('id', $id));
    $ele = new RMFormButtonGroup('', ' ');
    $ele->addButton('sbt', __('Update Category', 'mywords'), 'submit');
    $ele->addButton('cancel', __('Cancel', 'mywords'), 'button');
    $ele->setExtra('cancel', "onclick='history.go(-1);'");
    $form->addElement($ele);
    $form->display();
    xoops_cp_footer();
}
/**
* Categories widget
*/
function mw_widget_categories()
{
    global $xoopsUser, $allowed_cats;
    $widget['title'] = __('Categories', 'admin_mywords');
    $widget['icon'] = '';
    $id = rmc_server_var($_REQUEST, 'id', 0);
    $postcat = array();
    $edit = false;
    if ($id > 0) {
        $post = new MWPost($id);
        if ($post->isNew()) {
            unset($post);
            $postcat = array();
        } else {
            $edit = true;
            $postcat = $post->get_categos(true);
        }
    }
    ob_start();
    ?>
<div class="rmc_widget_content_reduced">
<form id="mw-post-categos-form">
<div class="w_categories" id="w-categos-container">
<?php 
    $categories = array();
    MWFunctions::categos_list($categories);
    foreach ($categories as $catego) {
        ?>
<label class="cat_label" style="padding-left: <?php 
        echo $catego['indent'] * 10;
        ?>
px;"><input type="checkbox" name="categories[]" id="categories[]" value="<?php 
        echo $catego['id_cat'];
        ?>
"<?php 
        echo in_array($catego['id_cat'], $postcat) ? ' checked="checked"' : '';
        ?>
 /> <?php 
        echo $catego['name'];
        ?>
</label>
<?php 
    }
    ?>
</div>
<?php 
    if ($xoopsUser->isAdmin() || $allowed_cats) {
        ?>
<div class="w_catnew_container">
    <a href="javascript:;" id="a-show-new"><strong><?php 
        _e('+ Add Categories', 'admin_mywords');
        ?>
</strong></a>
    <div id="w-catnew-form">
    	<label class="error" style="display: none;" for="w-name"><?php 
        _e('Please provide a name', 'admin_mywords');
        ?>
</label>
    	<input type="text" name="name" id="w-name" value="" class="required" />
    	<select name="parent" id="w-parent">
    		<option value="0"><?php 
        _e('Parent category', 'admin_mywords');
        ?>
</option>
    		<?php 
        foreach ($categories as $catego) {
            ?>
    		<option value="<?php 
            _e($catego['id_cat']);
            ?>
"><?php 
            _e($catego['name']);
            ?>
</option>
    		<?php 
        }
        ?>
    	</select>
    	<input type="button" id="create-new-cat" value="<?php 
        _e('Add', 'admin_mywords');
        ?>
" />
    	<a href="javascript:;"><?php 
        _e('Cancel', 'admin_mywords');
        ?>
</a>
    </div>
</div>
<?php 
    }
    ?>
</form>
</div>
<?php 
    $widget['content'] = ob_get_clean();
    return $widget;
}