/** * Execute on theme init to apply these filters to output */ public function action_init_theme() { if (!Plugins::is_loaded('HabariMarkdown')) { // Apply Format::autop() to post content... Format::apply('autop', 'post_content_out'); } // Truncate content excerpt at "<!--more-->"... Format::apply_with_hook_params('more', 'post_content_out'); // Apply Format::autop() to comment content... Format::apply('autop', 'comment_content_out'); // Apply Format::tag_and_list() to post tags... Format::apply('tag_and_list', 'post_tags_out'); $this->load_text_domain('demorgan'); }
/** * Execute on theme init to apply these filters to output */ public function action_init_theme() { if (!Plugins::is_loaded('HabariMarkdown')) { // Apply Format::autop() to post content... Format::apply('autop', 'post_content_out'); } // Apply Format::autop() to comment content... Format::apply('autop', 'comment_content_out'); // Apply Format::tag_and_list() to post tags... Format::apply('tag_and_list', 'post_tags_out'); // Apply Format::nice_date() to post date... Format::apply('nice_date', 'post_pubdate_out', 'F j, Y'); // Apply Format::nice_date() to post date... Format::apply('nice_date', 'post_pubdate_time', 'g:i a'); // Format post date to ISO-8601... Format::apply('nice_date', 'post_pubdate_iso', 'c'); // Apply Format::nice_date() to comment date... Format::apply('nice_date', 'comment_date_out', 'F j, Y ‒ g:i a'); // Format comment date to ISO-8601... Format::apply('nice_date', 'comment_date_iso', 'c'); // Truncate content excerpt at "more" or 100 characters... Format::apply_with_hook_params('more', 'post_content_excerpt', '', 100, 1); //Format::apply_with_hook_params( 'more', 'post_content_out', 'more', 100, 1 ); }
?> "><?php echo $comment->id; ?> </a> <span class="commentauthor"><a href="<?php echo $comment->url; ?> " rel="external"><?php if (Plugins::is_loaded('twitteravatar')) { ?> <? echo $comment->twitter_avatar ?> <?php } ?> <?php if (Plugins::is_loaded('gravatar')) { ?> <img class="twitter_avatar" src="<? echo $comment->gravatar ?>"> <?php } echo $comment->name; ?> </a></span><br/> <small class="comment-meta"><a href="#comment-<?php echo $comment->id; ?> " title="<?php _e('Time of this Comment'); ?> "><?php echo $comment->date->out(); ?>
<?php // Warning: This is PHP template written as RAW. // Do not delete these lines if (!defined('HABARI_PATH')) { die(_t('Please do not load this page directly.')); } ?> <div id="tag-list" class="vcol"> <h3>Tags</h3> <?php if (Plugins::is_loaded('RN Tag Cloud')) { ?> <?php $theme->tag_cloud(); ?> <?php } else { ?> <ul> <?php foreach ($taglist as $tag) { ?> <li><a href="<?php echo $tag->url; ?> " title="<?php echo $tag->text; ?> " rel="tag"><?php echo $tag->text;
<input type="text" id="criteria" name="criteria" value="<?php if (isset($criteria)) { echo htmlentities($criteria, ENT_COMPAT, 'UTF-8'); } ?> " /> <input id="search-submit" type="submit" value="Search" /> </fieldset> </form> </div> <ul id="sidebar-1" class="xoxo"> <?php if (Plugins::is_loaded('RelatedPosts')) { $theme->display('relatedposts.widget'); } if (Plugins::is_loaded('RelatedTags')) { $theme->display('relatedtags.widget'); } ?> </ul> <ul id="sidebar-2" class="xoxo"> <?php $theme->display('recententries.widget'); $theme->display('feedlink.widget'); $theme->display('admin.widget'); ?> </ul> </div> <hr /> <!-- /sidebar.single -->
use_as_large_photo: function(fileindex, fileobj) {set_photo(fileindex, fileobj);} }); $.extend(habari.media.output.image_png, { use_as_large_photo: function(fileindex, fileobj) {set_photo(fileindex, fileobj);} }); $.extend(habari.media.output.image_gif, { use_as_large_photo: function(fileindex, fileobj) {set_photo(fileindex, fileobj);} }); function set_photo(fileindex, fileobj) { $('#pb_photo_src').val(fileobj.originalsecret).focus(); } <?php } ?> <?php if (Plugins::is_loaded('Flickr Media Silo')) { ?> $.extend(habari.media.output.flickr, { use_small_photo: function(fileindex, fileobj) {set_flickr_photo(fileindex, fileobj, '_m.');}, use_medium_photo: function(fileindex, fileobj) {set_flickr_photo(fileindex, fileobj, '_-.');}, use_large_photo: function(fileindex, fileobj) {set_flickr_photo(fileindex, fileobj, '_b.');}, use_original_photo: function(fileindex, fileobj) {set_flickr_photo(fileindex, fileobj, '_o.');} }); function set_flickr_photo(fileindex, fileobj, filesize) { if (filesize == '_o.') { if (fileobj.originalsecret && fileobj.originalformat) { fileobj_secret = fileobj.originalsecret; fileobj_size = '_o.'; fileobj_format = fileobj.originalformat; } else {
<div id="sidebar"> <div id="blurb"> <?php if (Plugins::is_loaded('colophon')) { echo $theme->colophon; } else { echo '<p>' . $da_blurbtext . '</p>'; } ?> </div> <?php $theme->twitter(); ?> <?php if ($sidenotes->count()) { ?> <div id="sidenotes"> <h3><a href="<?php URL::out('atom_feed_tag', array('tag' => $theme->da_sidenotes_tag)); ?> " title="Side Notes Feed"><img alt="Side Notes Feed" src="<?php echo $this->theme_url; ?> /images/feed.png" /></a> Side Notes</h3> <ul> <?php foreach ($sidenotes as $sidenote) { ?> <li><?php
<?php if (!defined('HABARI_PATH')) { die('No direct access'); } ?> </div> <div id="bottom-secondary"> <div id="tags"><?php echo Plugins::is_loaded('tagcloud') ? $theme->tag_cloud() : $theme->show_tags(); ?> </div> </div> <div id="footer"> <p> <?php _e('%1$s is powered by %2$s', array(Options::get('title'), '<a href="http://www.habariproject.org/" title="Habari">Habari ' . Version::get_habariversion() . '</a>')); ?> - <?php _e('<a href="%1$s">Atom Entries</a> and <a href="%2$s">Atom Comments</a>', array(URL::get('atom_feed', array('index' => 1)), URL::get('atom_feed_comments'))); ?> </p> </div> <div class="clear"></div> </div> </div> <?php echo $theme->footer(); ?> </body>
<li><?php _e('Twitter'); ?> <ul id="twitter"> <?php $theme->twitter(); ?> </ul></li> <?php } ?> <?php if (Plugins::is_loaded('Brightkite')) { ?> <div id="brightkite"> <?php $theme->bk_location(); ?> </div> <?php } ?> <li class="user"><?php _e('User'); ?>
/** * Plugin UI * * @access public * @return void */ public function action_plugin_ui_configure() { $this->add_template('hbap_checkbox', dirname($this->get_file()) . '/lib/formcontrols/hbap_checkbox.php'); $this->add_template('hbap_text', dirname($this->get_file()) . '/lib/formcontrols/hbap_text.php'); $this->add_template('hbap_select', dirname($this->get_file()) . '/lib/formcontrols/hbap_select.php'); $options = Options::get(self::OPTNAME); $ui = new FormUI(strtolower(__CLASS__)); $ui->append('wrapper', 'colourselector', 'formcontrol'); // First all the hidden settings foreach ($options['colorScheme'] as $opt => $value) { $ui->colourselector->append('hidden', "cs_" . $opt, 'null:null'); $optn = "cs_{$opt}"; if ($optn == 'cs_pagebg') { continue; } $ui->colourselector->{$optn}->value = '#' . $value; $ui->colourselector->{$optn}->id = $optn . "color"; } if (Plugins::is_loaded('Habari Media Silo')) { // Get a list of all the directories available in the loaded Habari Silo $dirs = self::siloDirs(); $dirs['custom'] = _t('Custom', 'audio-player'); } $ui->append('fieldset', 'genfs', _t('General', 'audio-player')); $ui->genfs->append('select', 'defaultPath', 'null:null', _t('Default Audio Path', 'audio-player')); $ui->genfs->defaultPath->template = 'hbap_select'; $ui->genfs->defaultPath->id = 'defaultPath'; $ui->genfs->defaultPath->pct = 80; $ui->genfs->defaultPath->value = $options['defaultPath']; $ui->genfs->defaultPath->helptext = _t('This is the default location for your audio files. When you use the [audio] syntax and don\'t provide an absolute URL for the mp3 file (the full URL including "http://") Audio Player will automatically look for the file in this location. You can set this to a folder located inside your blog folder structure or, alternatively, if you wish to store your audio files outside your blog (maybe even on a different server), choose "Custom" from the drop down and enter the absolute URL to that location.', 'audio-player'); $ui->genfs->defaultPath->options = $dirs; $ui->genfs->append('text', 'customPath', 'null:null', _t('Custom Audio Path:', 'audio-player'), 'hbap_text'); $ui->genfs->customPath->value = $options['customPath']; $ui->genfs->customPath->pct = 80; $ui->genfs->customPath->id = 'customPath'; if ($options['defaultPath'] != 'custom') { $ui->genfs->customPath->disabled = TRUE; } $ui->append('fieldset', 'appfs', _t('Appearance', 'audio-player')); $ui->appfs->append('text', 'width', 'null:null', _t('Player Width', 'audio-player'), 'hbap_text'); $ui->appfs->width->value = $options['width']; $ui->appfs->width->helptext = _t('You can enter a value in pixels (e.g. 200) or as a percentage (e.g. 100%)', 'audio-player'); $ui->appfs->append('select', 'fieldsel', 'null:null', _t('Colour Scheme Selector', 'audio-player')); $ui->appfs->fieldsel->id = 'fieldsel'; $ui->appfs->fieldsel->template = 'hbap_select'; $ui->appfs->fieldsel->options = array('bg' => _t('Background', 'audio-player'), 'leftbg' => _t('Left Background', 'audio-player'), 'lefticon' => _t('Left Icon', 'audio-player'), 'volslider' => _t('Volume Control Slider', 'audio-player'), 'voltrack' => _t('Volume Control Track', 'audio-player'), 'rightbg' => _t('Right Background', 'audio-player'), 'rightbghover' => _t('Right Background (hover)', 'audio-player'), 'righticon' => _t('Right Icon', 'audio-player'), 'righticonhover' => _t('Right Icon (hover)', 'audio-player'), 'text' => _t('Text', 'audio-player'), 'track' => _t('Progress Bar Track', 'audio-player'), 'tracker' => _t('Progress Bar', 'audio-player'), 'loader' => _t('Loading Bar', 'audio-player'), 'border' => _t('Progress Bar Border', 'audio-player'), 'skip' => _t('Next/Previous Buttons', 'audio-player')); $ui->appfs->fieldsel->helptext = '<input name="colorvalue" type="text" id="colorvalue" size="10" maxlength="7" /> <span id="colorsample"></span>'; // IFF we've managed to find the theme/style.css file and parse it, we'll show the "Theme Colours" selection tool $themeColors = self::getThemeColors(); if (is_array($themeColors) && !empty($themeColors)) { $themeColorStr = ''; foreach (self::getThemeColors() as $themeColor) { $themeColorStr .= "<li style='background:#{$themeColor}' title='#{$themeColor}'>#{$themeColor}</li>"; } $ui->appfs->fieldsel->helptext .= '<span id="themecolor-btn">' . _t('Theme Colours', 'audio-player') . '</span> <div id="themecolor"> <span>' . _t('Theme Colours', 'audio-player') . '</span> <ul>' . $themeColorStr . '</ul></div>'; } $ui->appfs->fieldsel->helptext .= '<input type="button" class="submit" id="doresetcolors" value="' . _t('Reset Color Scheme', 'audio-player') . '">'; $ui->appfs->append('hidden', 'resetColors', 'null:null'); $ui->appfs->resetColors->id = 'resetColors'; $ui->appfs->append('wrapper', 'colour_selector_demo', 'formcontrol'); $ui->appfs->colour_selector_demo->append('static', 'demo', ' <div id="demoplayer">Audio Player</div> <script type="text/javascript"> AudioPlayer.embed("demoplayer", {demomode:"yes"}); </script> '); $ui->appfs->append('text', 'cs_pagebg', 'null:null', _t('Page Background', 'audio-player'), 'hbap_text'); $ui->appfs->cs_pagebg->value = '#' . $options['colorScheme']['pagebg']; $ui->appfs->cs_pagebg->id = 'cs_pagebg'; if ($options['colorScheme']['transparentpagebg']) { $ui->appfs->cs_pagebg->disabled = TRUE; } $ui->appfs->cs_pagebg->helptext = _t('In most cases, simply select "transparent" and it will match the background of your page. In some rare cases, the player will stop working in Firefox if you use the transparent option. If this happens, untick the transparent box and enter the color of your page background in the box below (in the vast majority of cases, it will be white: #FFFFFF).', 'audio-player'); $ui->appfs->append('checkbox', 'cs_transparentpagebg', 'null:null', _t('Transparent Page Background', 'audio-player')); $ui->appfs->cs_transparentpagebg->value = $options['colorScheme']['transparentpagebg']; $ui->appfs->append('checkbox', 'enableAnimation', 'null:null', _t('Enable Animation', 'audio-player'), 'hbap_checkbox'); $ui->appfs->enableAnimation->value = $options['enableAnimation']; $ui->appfs->enableAnimation->helptext = _t('If you don\'t like the open/close animation, you can disable it here.', 'audio-player'); $ui->appfs->append('checkbox', 'showRemaining', 'null:null', _t('Show Remaining', 'audio-player'), 'hbap_checkbox'); $ui->appfs->showRemaining->value = $options['showRemaining']; $ui->appfs->showRemaining->helptext = _t('This will make the time display count down rather than up.', 'audio-player'); $ui->appfs->append('checkbox', 'disableTrackInformation', 'null:null', _t('Disable Track Information', 'audio-player'), 'hbap_checkbox'); $ui->appfs->disableTrackInformation->value = $options['disableTrackInformation']; $ui->appfs->disableTrackInformation->helptext = _t('Select this if you wish to disable track information display (the player won\'t show titles or artist names even if they are available.)', 'audio-player'); $ui->appfs->append('checkbox', 'rtlMode', 'null:null', _t('Switch to RTL Layout', 'audio-player'), 'hbap_checkbox'); $ui->appfs->rtlMode->value = $options['rtlMode']; $ui->appfs->rtlMode->helptext = _t('Select this to switch the player layout to RTL mode (right to left) for Arabic and Hebrew language blogs.', 'audio-player'); $ui->append('fieldset', 'feedfs', _t('Feed', 'audio-player')); $ui->feedfs->append('select', 'feedAlt', 'null:null', _t('Alternate Content', 'audio-player')); $ui->feedfs->feedAlt->id = 'feedAlt'; $ui->feedfs->feedAlt->template = 'hbap_select'; $ui->feedfs->feedAlt->value = $options['feedAlt']; $ui->feedfs->feedAlt->options = array('enclosure' => _t('Enclosure', 'audio-player'), 'download' => _t('Download Link', 'audio-player'), 'nothing' => _t('Nothing', 'audio-player'), 'custom' => _t('Custom', 'audio-player')); $ui->feedfs->feedAlt->helptext = _t('The following options determine what is included in your feeds. The plugin doesn\'t place a player instance in the feed. Instead, you can choose what the plugin inserts. You have four choices:<br /><br /> <strong>Enclosure</strong>: Choose this if you want your audio file included as an enclosure in your feed.<br> <strong>Download link</strong>: Choose this if you are OK with subscribers downloading the file.<br> <strong>Nothing</strong>: Choose this if you feel that your feed shouldn\'t contain any reference to the audio file.<br> <strong>Custom</strong>: Choose this to use your own alternative content for all player instances. You can use this option to tell subscribers that they can listen to the audio file if they read the post on your blog.', 'audio-player'); $ui->feedfs->append('text', 'feedCustom', 'null:null', _t('Custom alternate content', 'audio-player'), 'hbap_text'); $ui->feedfs->feedCustom->value = $options['feedCustom']; $ui->feedfs->feedCustom->pct = 80; $ui->feedfs->feedCustom->id = 'feedCustom'; if ($options['feedAlt'] != 'custom') { $ui->feedfs->feedCustom->disabled = TRUE; } $ui->append('fieldset', 'advfs', _t('Advanced', 'audio-player')); $ui->advfs->append('text', 'initVol', 'null:null', _t('Initial Volume', 'audio-player'), 'hbap_text'); $ui->advfs->initVol->value = $options['initVol']; $ui->advfs->initVol->helptext = _t('This is the volume at which the player defaults to (0 is off, 100 is full volume)', 'audio-player'); $ui->advfs->append('text', 'buffer', 'null:null', _t('Buffer time (in seconds)', 'audio-player'), 'hbap_text'); $ui->advfs->buffer->value = $options['buffer']; $ui->advfs->buffer->helptext = _t('If you think your target audience is likely to have a slow internet connection, you can increase the player\'s buffering time (for standard broadband connections, 5 seconds is enough)', 'audio-player'); $ui->advfs->append('checkbox', 'chkPolicy', 'null:null', _t('Check for policy file', 'audio-player'), 'hbap_checkbox'); $ui->advfs->chkPolicy->value = $options['chkPolicy']; $ui->advfs->chkPolicy->helptext = _t('Enable this to tell Audio Player to check for a policy file on the server. This allows Flash to read ID3 tags on remote servers. Only enable this if all your mp3 files are located on a server with a policy file.', 'audio-player'); $ui->advfs->append('checkbox', 'encode', 'null:null', _t('Encode MP3 URLs', 'audio-player'), 'hbap_checkbox'); $ui->advfs->encode->value = $options['encode']; $ui->advfs->encode->helptext = _t('Enable this to encode the URLs to your mp3 files. This is the only protection possible against people downloading the mp3 file to their computers.', 'audio-player'); $ui->append('submit', 'save', _t('Save', 'audio-player')); $ui->on_success(array($this, 'storeOpts')); //$ui->set_option( 'success_message', _t( 'Options successfully saved.' ) ); $form_output = $ui->get(); echo '<script type="text/javascript">AudioPlayer.setup("' . URL::get_from_filesystem(__FILE__) . '/lib/player.swf",' . self::php2js(self::getPlayerOptions()) . ');</script>'; echo $form_output; }
"> <div class="searchimg"></div> <div><input type="text" id="f" value="" name="criteria" size="15"></div> </form> </div> <h2><a href="<?php Site::out_url('habari'); ?> /"><?php Options::out('title'); ?> </a></h2> <table><tr><td> <?php if (Plugins::is_loaded('Twitter') && $theme->twitter_in == 'header') { ?> <p><?php $theme->twitter(); ?> <a href="http://twitter.com/<?php echo urlencode(Options::get('twitter:username')); ?> ">via Twitter</a></p> <?php } else { ?> <?php if (Options::out('tagline') != '') { ?> <p><?php
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?> </div> <div id="bottom-secondary"> <div id="tags"><?php echo (Plugins::is_loaded('tagcloud')) ? $theme->tag_cloud() : $theme->show_tags();?></div> </div> <div id="footer"> <p> <?php printf( _t('%1$s is powered by %2$s'), Options::get('title'),' <a href="http://www.habariproject.org/" title="Habari">Habari ' . Version::HABARI_VERSION . '</a>' ); ?> - <a href="<?php URL::out( 'atom_feed', array( 'index' => '1' ) ); ?>"><?php _e( 'Atom Entries' ); ?></a><?php _e( ' and ' ); ?> <a href="<?php URL::out( 'atom_feed_comments' ); ?>"><?php _e( 'Atom Comments' ); ?></a> </p> </div> <div class="clear"></div> </div> </div> <?php echo $theme->footer(); ?> </body> </html>
<?php if (Plugins::is_loaded('RN Monthly Archives')) { // RN Monthly Archives Plugin required $theme->monthly_archives($theme->rn_archives_months); } else { ?> Please install/activate the RN Archives Plugins. Thanx. <?php }
<div id="fireeagle"> <?php if (!empty($fireeagle_location)) { ?> <h2><?php echo _t('Location', 'fireeagle'); ?> </h2> <?php echo sprintf(_t('I\'m at %s.', 'fireeagle'), htmlspecialchars($fireeagle_location)); ?> <?php if (Plugins::is_loaded('14c8414f-6cdf-11dd-b14a-001b210f913f')) { ?> <a href="http://maps.google.com/?ll=<?php echo $fireeagle_latitude . ',' . $fireeagle_longitude; ?> &z=<?php echo $zoom; ?> &_markers=<?php echo $fireeagle_latitude . ',' . $fireeagle_longitude; ?> &_size=180x180&_controls=none"><?php echo htmlspecialchars($fireeagle_location); ?> </a> <?php } ?>
</div> <div id="bottom-secondary"> <div id="tags"><?php if (Plugins::is_loaded('tagcloud')) { $theme->tag_cloud(); } else { $theme->show_tags(); } ?> </div> </div> <div id="footer"> <p> <?php printf(_t('%1$s is powered by %2$s'), Options::get('title'), ' <a href="http://www.habariproject.org/" title="Habari">Habari ' . Version::HABARI_VERSION . '</a>'); ?> - <a href="<?php URL::out('atom_feed', array('index' => '1')); ?> "><?php _e('Atom Entries'); ?> </a><?php _e(' and '); ?> <a href="<?php URL::out('atom_feed_comments'); ?> "><?php
<?php /* vim: set expandtab tabstop=1 shiftwidth=1 softtabstop=1 foldmethod=marker */ // Warning: This is PHP template written as RAW. // Do not delete these lines if (!defined('HABARI_PATH')) { die(_t('Please do not load this page directly.')); } if (Plugins::is_loaded('Colophon Plugin')) { ?> <div id="colophon" class="vcol"> <h3><?php echo $theme->colophon_title; ?> </h3> <?php echo nl2br($theme->colophon_text); ?> </div> <?php }
</ul> <?php } ?> </div> <div class="pluginhelp"<?php if ($helpaction == '_help') { ?> class="active"<?php } ?> > <?php if (Plugins::is_loaded((string) $plugin['info']->name)) { Plugins::act_id('plugin_ui', $plugin['plugin_id'], $plugin['plugin_id'], '_help'); } elseif (isset($plugin['info']->help)) { foreach ($plugin['info']->help as $help) { if ((string) $help['name'] == '') { echo '<div class="help">' . $help->value . '</div>'; } } } ?> </div> <?php if (isset($this->engine_vars['configure']) && $configure == $plugin['plugin_id']) { ?> <div id="pluginconfigure">
<input id="search-submit" type="submit" value="Search" /> </fieldset> </form> </div> <ul id="sidebar-1" class="xoxo"> <?php $theme->display('recententries.widget'); $theme->freshcomments(); $theme->show_recentcomments(); $theme->flickrfeed(); if (Plugins::is_loaded('FlickrRSS')) { $theme->display('flickrrss.widget'); } $theme->show_blogroll(); $theme->deliciousfeed(); if (Plugins::is_loaded('FreshSurf')) { $theme->display('freshsurf.widget'); } ?> </ul> <ul id="sidebar-2" class="xoxo"> <?php if (strlen(Options::get('about')) > 0) { ?> <li id="widget-about" class="widget"> <h3><?php _e('About', 'demorgan'); ?> </h3> <p><?php Options::out('about');
/** * Create the UI for stage two of the WP import process * * This stage kicks off the actual import process. * * @return string The UI for the second stage of the import process */ private function stage3() { $valid_fields = array('db_name', 'db_host', 'db_port', 'db_user', 'db_pass', 'db_prefix', 's9y_version', 's9y_root_web', 's9y_input_version', 'category_import', 'comments_ignore_unapproved', 'rewrites_import', 'merge_user', 'merge_user_matched', 'import_user'); $inputs = $this->get_valid_inputs($valid_fields); extract($inputs); /* * Cache some local private variables for use in * the import_xxx() private functions */ $this->comments_ignore_unapproved = $comments_ignore_unapproved; $this->category_import = $category_import; $this->s9y_db_prefix = $db_prefix; $this->port_rewrites = $rewrites_import; if ($rewrites_import) { // atom feed link: $rew_url = URL::get('atom_feed', array('index' => 1), true, false, false); $rewrite = new RewriteRule(array('name' => 'from_s9yimporter_atom_feed', 'parse_regex' => '%^feeds/atom(?P<r>.*)$%i', 'build_str' => $rew_url . '(/{$p})', 'handler' => 'actionHandler', 'action' => 'redirect', 'priority' => 1, 'is_active' => 1, 'rule_class' => RewriteRule::RULE_CUSTOM, 'description' => 'redirects s9y atom feed to habari feed')); $rewrite->insert(); // rss feed link: $rew_url = Plugins::is_loaded('RSS 2.0') ? URL::get('rss_feed', array('index' => 1), true, false, false) : URL::get('atom_feed', array('index' => 1), true, false, false); $rewrite = new RewriteRule(array('name' => 'from_s9yimporter_rss_feed', 'parse_regex' => '%^feeds/index.rss(?P<r>.*)$%i', 'build_str' => $rew_url . '(/{$p})', 'handler' => 'actionHandler', 'action' => 'redirect', 'priority' => 1, 'is_active' => 1, 'rule_class' => RewriteRule::RULE_CUSTOM, 'description' => 'redirects s9y rss feed to habari feed')); $rewrite->insert(); // comments feed link: $rew_url = Plugins::is_loaded('RSS 2.0') ? URL::get('rss_feed_comments', array(), true, false, false) : URL::get('atom_feed_comments', array(), true, false, false); $rewrite = new RewriteRule(array('name' => 'from_s9yimporter_comments_feed', 'parse_regex' => '%^feeds/comments.rss(?P<r>.*)$%i', 'build_str' => $rew_url . '(/{$p})', 'handler' => 'actionHandler', 'action' => 'redirect', 'priority' => 1, 'is_active' => 1, 'rule_class' => RewriteRule::RULE_CUSTOM, 'description' => 'redirects s9y rss feed to habari feed')); $rewrite->insert(); } if (FALSE !== ($this->s9ydb = $this->s9y_connect($db_host, $db_name, $db_user, $db_pass, $db_prefix, $db_port))) { /* * First step is to go through our import_user and * merge_user arrays and see if we need to merge the * incoming authoring user with an existing user in * Habari, ignore the user, or create a new Habari user. * * $import_user= array( [imported_user_id] => [1 | null], [next_imported_user_id] => [1 | null], ...) * $merge_user= array( [imported_user_id] => [habari_user_id | "__new_user"], ...) */ $users = array(); foreach ($import_user as $import_user_id => $import_this) { /* Is this s9y user selected for import? */ if ($import_this != 1) { continue; } $users[$import_user_id] = array('imported_user_id' => $import_user_id); /* Was there a direct match for this imported user? */ if (in_array($import_user_id, array_keys($merge_user_matched))) { $users[$import_user_id]['habari_user_id'] = $merge_user_matched[$import_user_id]; } /* Is this s9y user manually selected to merge with a habari user? */ if (isset($merge_user) && in_array($import_user_id, array_keys($merge_user))) { if ($merge_user[$import_user_id] != '__new_user') { $users[$import_user_id]['habari_user_id'] = $merge_user[$import_user_id]; } } } echo "Starting import transaction.<br />"; $this->s9ydb->begin_transaction(); if ($category_import) { /* * If we are importing the categories as taxonomy, * let's go ahead and import the base category tags * now, and during the post import, we'll attach * the category tag to the relevant posts. * * mysql> desc s9y_category; * +----------------------+--------------+------+-----+---------+----------------+ * | Field | Type | Null | Key | Default | Extra | * +----------------------+--------------+------+-----+---------+----------------+ * | categoryid | int(11) | | PRI | NULL | auto_increment | * | category_name | varchar(255) | YES | | NULL | | * | category_icon | varchar(255) | YES | | NULL | | * | category_description | text | YES | | NULL | | * | authorid | int(11) | YES | MUL | NULL | | * | category_left | int(11) | YES | MUL | 0 | | * | category_right | int(11) | YES | | 0 | | * | parentid | int(11) | | MUL | 0 | | * +----------------------+--------------+------+-----+---------+----------------+ */ $sql = <<<ENDOFSQL SELECT categoryid, category_name FROM `{$db_prefix}category ENDOFSQL; if (FALSE !== ($imported_categories = $this->s9ydb->get_results($sql, array(), 'QueryRecord'))) { $num_categories_imported = 0; foreach ($imported_categories as $imported_category) { if ($tag_check = Tags::get_one($imported_category->category_name)) { // tag already exists $this->imported_categories[$imported_category->categoryid] = $tag_check->id; $this->imported_category_names[$imported_category->categoryid] = $imported_category->category_name; ++$num_categories_imported; continue; } if ($new_tag = Tag::create(array('tag_text' => $imported_category->category_name))) { $this->imported_categories[$imported_category->categoryid] = $new_tag->id; $this->imported_category_names[$imported_category->categoryid] = $imported_category->category_name; ++$num_categories_imported; } else { $this->s9ydb->rollback(); return FALSE; } } printf("%d categories imported as tags...<br />", $num_categories_imported); } } /* * Now that we have an array of the users to import, * let's grab some information about those users and * call the import_user() method for each one. * * mysql> desc s9y_authors; * +-----------------+-----------------+------+-----+---------+----------------+ * | Field | Type | Null | Key | Default | Extra | * +-----------------+-----------------+------+-----+---------+----------------+ * | realname | varchar(255) | NO | | | | * | username | varchar(20) | YES | | NULL | | * | password | varchar(32) | YES | | NULL | | * | authorid | int(11) | NO | PRI | NULL | auto_increment | * | mail_comments | int(1) | YES | | 1 | | * | mail_trackbacks | int(1) | YES | | 1 | | * | email | varchar(128) | NO | | | | * | userlevel | int(4) unsigned | NO | | 0 | | * | right_publish | int(1) | YES | | 1 | | * +-----------------+-----------------+------+-----+---------+----------------+ */ $sql = <<<ENDOFSQL SELECT a.authorid, a.realname, a.username, a.email FROM `{$db_prefix}authors` a ENDOFSQL; $sql .= " WHERE a.authorid IN (" . implode(',', array_keys($users)) . ")"; $import_users = $this->s9ydb->get_results($sql, array(), 'QueryRecord'); $result = TRUE; foreach ($import_users as $import_user) { $result &= $this->import_user($import_user->authorid, $import_user, isset($users[$import_user->authorid]['habari_user_id']) ? (int) $users[$import_user->authorid]['habari_user_id'] : NULL); } if ($result) { echo "Committing import transaction.<br />"; $this->s9ydb->commit(); return "import finished."; /* Display success */ } else { echo "Rolling back failed import transaction.<br />"; $this->s9ydb->rollback(); /* Display failure -- but how..? */ return FALSE; } } }