Skip to content

Commit

Permalink
import stuff from zicworld
Browse files Browse the repository at this point in the history
  • Loading branch information
rair committed Feb 18, 2015
1 parent 4be12db commit 6a05302
Show file tree
Hide file tree
Showing 82 changed files with 3,680 additions and 843 deletions.
2 changes: 1 addition & 1 deletion articles/article.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ function load_by_id($id, $mutable=FALSE) {
* [/php]
*
* @see agents/messages.php
$ @see agents/uploads.php
* @see agents/uploads.php
* @see services/blog.php
*
* @param string the input text
Expand Down
21 changes: 15 additions & 6 deletions articles/articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -2976,6 +2976,7 @@ public static function post(&$fields) {
$query[] = "source='".SQL::escape(isset($fields['source']) ? $fields['source'] : '')."'";
$query[] = "introduction='".SQL::escape(isset($fields['introduction']) ? $fields['introduction'] : '')."'";
$query[] = "description='".SQL::escape(isset($fields['description']) ? $fields['description'] : '')."'";
$query[] = "file_overlay='".SQL::escape(isset($fields['file_overlay']) ? $fields['file_overlay'] : '')."'";
$query[] = "language='".SQL::escape(isset($fields['language']) ? $fields['language'] : '')."'";
$query[] = "locked='".SQL::escape(isset($fields['locked']) ? $fields['locked'] : 'N')."'";
$query[] = "overlay='".SQL::escape(isset($fields['overlay']) ? $fields['overlay'] : '')."'";
Expand Down Expand Up @@ -3012,6 +3013,7 @@ public static function post(&$fields) {
if(!isset($fields['handle']) || (strlen($fields['handle']) < 32))
$fields['handle'] = md5(mt_rand());
$query[] = "handle='".SQL::escape($fields['handle'])."'";
$query[] = "rating_count='".SQL::escape(isset($fields['rating_count']) ? $fields['rating_count'] : '0')."'";

// allow anonymous surfer to access this page during his session
if(!Surfer::get_id())
Expand Down Expand Up @@ -3180,6 +3182,7 @@ public static function put(&$fields) {
$query[] = "nick_name='".SQL::escape(isset($fields['nick_name']) ? $fields['nick_name'] : '')."'";
$query[] = "behaviors='".SQL::escape(isset($fields['behaviors']) ? $fields['behaviors'] : '')."'";
$query[] = "extra='".SQL::escape(isset($fields['extra']) ? $fields['extra'] : '')."'";
$query[] = "file_overlay='".SQL::escape(isset($fields['file_overlay']) ? $fields['file_overlay'] : '')."'";
$query[] = "icon_url='".SQL::escape(isset($fields['icon_url']) ? $fields['icon_url'] : '')."'";
$query[] = "thumbnail_url='".SQL::escape(isset($fields['thumbnail_url']) ? $fields['thumbnail_url'] : '')."'";
$query[] = "rank='".SQL::escape($fields['rank'])."'";
Expand Down Expand Up @@ -3227,6 +3230,7 @@ public static function put(&$fields) {
$query[] = "assign_id=0";
$query[] = "assign_address=''";
$query[] = "assign_date='".SQL::escape(NULL_DATE)."'";
$query[] = "rating_count='".SQL::escape(isset($fields['rating_count']) ? $fields['rating_count'] : '0')."'";

// update an existing record
$query = "UPDATE ".SQL::table_name('articles')." SET ".implode(', ', $query)." WHERE id = ".SQL::escape($fields['id']);
Expand Down Expand Up @@ -3303,6 +3307,8 @@ public static function put_attributes(&$fields) {
$query[] = "extra='".SQL::escape($fields['extra'])."'";
if(isset($fields['description']))
$query[] = "description='".SQL::escape($fields['description'])."'";
if(isset($fields['file_overlay']) )
$query[] = "file_overlay='".SQL::escape($fields['file_overlay'])."'";
if(isset($fields['handle']) && $fields['handle'])
$query[] = "handle='".SQL::escape($fields['handle'])."'";
if(isset($fields['icon_url']))
Expand Down Expand Up @@ -3425,7 +3431,8 @@ public static function &search($pattern, $offset=1.0, $count=50, $layout='search
}

/**
* search for some keywords articles anchored to one precise section
* search for some keywords articles anchored to one precise section
* (and its subsections) or array of sections.
*
* This function also searches in sub-sections, with up to three levels of depth.
*
Expand All @@ -3435,7 +3442,7 @@ public static function &search($pattern, $offset=1.0, $count=50, $layout='search
*
* @link http://www.artfulcode.net/articles/full-text-searching-mysql/
*
* @param int the id of the section to look in
* @param mixed the id of the section or array of sections to look in
* @param string the search string
* @param float maximum score to look at
* @param int the number of items to display
Expand All @@ -3455,16 +3462,17 @@ public static function &search_in_section($section_id, $pattern, $offset=1.0, $c
$where = Articles::get_sql_where();

// search is restricted to one section
$sections_where = '';
if($section_id) {
if(is_numeric($section_id)) {

// look for children
$anchors = Sections::get_branch_at_anchor('section:'.$section_id);

// the full set of sections searched
$where .= " AND (anchor IN ('".join("', '", $anchors)."'))";

}
} elseif(is_array($section_id)) {
$where .= " AND (anchor IN ('".join("', '", $section_id)."'))";
}

// anonymous surfers and subscribers will see only published articles
if(!Surfer::is_member())
Expand Down Expand Up @@ -3521,6 +3529,7 @@ public static function setup() {
$fields['edit_name'] = "VARCHAR(128) DEFAULT '' NOT NULL";
$fields['expiry_date'] = "DATETIME";
$fields['extra'] = "TEXT NOT NULL";
$fields['file_overlay'] = "VARCHAR(64) DEFAULT '' NOT NULL";
$fields['handle'] = "VARCHAR(128) DEFAULT '' NOT NULL";
$fields['hits'] = "INT UNSIGNED DEFAULT 0 NOT NULL";
$fields['icon_url'] = "VARCHAR(255) DEFAULT '' NOT NULL";
Expand All @@ -3544,7 +3553,7 @@ public static function setup() {
$fields['review_date'] = "DATETIME";
$fields['source'] = "VARCHAR(255) DEFAULT '' NOT NULL";
$fields['suffix'] = "TEXT NOT NULL";
$fields['tags'] = "VARCHAR(255) DEFAULT '' NOT NULL";
$fields['tags'] = "TEXT DEFAULT '' NOT NULL";
$fields['thumbnail_url']= "VARCHAR(255) DEFAULT '' NOT NULL";
$fields['title'] = "VARCHAR(255) DEFAULT '' NOT NULL";
$fields['trailer'] = "TEXT NOT NULL";
Expand Down
37 changes: 30 additions & 7 deletions articles/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@

// page title
if(isset($item['id']))
$context['page_title'] = sprintf(i18n::s('%s: %s'), i18n::s('Delete'), $item['title']);
if(is_object($overlay))
$title = $overlay->get_text('title', $item);
else
$title = $item['title'];

$context['page_title'] = sprintf(i18n::s('%s: %s'), i18n::s('Delete'), $title);

// handle overlaid view
global $render_overlaid;

// not found
if(!isset($item['id'])) {
Expand Down Expand Up @@ -95,9 +103,9 @@
Cache::clear();

// back to the anchor page or to the index page
if($back_url = $overlay->get_url_after_deleting()) {
Safe::redirect($back_url);
} elseif(!is_object($anchor))
if(is_object($overlay) && $back_url = $overlay->get_url_after_deleting()) {
Safe::redirect($back_url);
} elseif(!is_object($anchor))
Safe::redirect($context['url_to_home'].$context['url_to_root'].'articles/');
elseif($anchor->is_viewable())
Safe::redirect($context['url_to_home'].$context['url_to_root'].$anchor->get_url());
Expand All @@ -122,16 +130,31 @@

// commands
$menu = array();
$menu[] = Skin::build_submit_button(i18n::s('Yes, I want to delete this page'), NULL, NULL, 'confirmed');
if(isset($item['id']))

$class_submit = ( $render_overlaid )?'submit-overlaid':'button';
if(is_object($overlay))
$delete_text = strtolower($overlay->get_label('delete_command'));

if(!isset($delete_text)) $delete_text = i18n::s('delete this page');

$menu[] = Skin::build_submit_button(sprintf(i18n::s('Yes, I want to %s'),$delete_text), NULL, NULL, 'confirmed', $class_submit);
if(isset($item['id']) && !$render_overlaid) {
$menu[] = Skin::build_link(Articles::get_permalink($item), i18n::s('Cancel'), 'span');
} else {
if(isset($_REQUEST['follow_up']) && $_REQUEST['follow_up'] === 'close')
$menu[] = '<a href="javascript:;" onclick="Yacs.closeModalBox()">'.i18n::s('Cancel').'</a>'."\n";
else
$menu[] = Skin::build_link(Articles::get_permalink($item), i18n::s('Cancel'), 'overlaid');
}


// render commands
$context['text'] .= '<form method="post" action="'.$context['script_url'].'" id="main_form"><p>'."\n"
.Skin::finalize_list($menu, 'menu_bar')
.'<input type="hidden" name="id" value="'.$item['id'].'" />'."\n"
.'<input type="hidden" name="action" value="delete" />'."\n"
.'</p></form>'."\n";
.((isset($_REQUEST['follow_up']))?'<input type="hidden" name="follow_up" value="'.$_REQUEST['follow_up'].'" />'."\n":'')
.'</p></form>'."\n";

// set the focus
Page::insert_script('$("#confirmed").focus();');
Expand Down
13 changes: 4 additions & 9 deletions articles/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,8 @@
} elseif(isset($_REQUEST['options']) && preg_match('/\bedit_as_[a-zA-Z0-9_\.]+?\b/i', $_REQUEST['options'], $matches) && is_readable($matches[0].'.php')) {
include $matches[0].'.php';
return;
} elseif(is_object($overlay) && $overlay->get_value('edit_as_simple')) {
include 'edit_as_simple.php';
return;
} elseif(is_object($overlay) && $overlay->get_value('edit_as_thread')) {
include 'edit_as_thread.php';
} elseif(is_object($overlay) && ($deputy = $overlay->get_value('edit_as')) && is_readable('edit_as_'.$deputy.'.php')) {
include 'edit_as_'.$deputy.'.php';
return;
} elseif(is_object($anchor) && ($deputy = $anchor->has_option('edit_as')) && is_readable('edit_as_'.$deputy.'.php')) {
include 'edit_as_'.$deputy.'.php';
Expand Down Expand Up @@ -743,10 +740,8 @@
$branching = '';
if(isset($item['options']) && preg_match('/\bedit_as_[a-zA-Z0-9_\.]+?\b/i', $item['options'], $matches) && is_readable($matches[0].'.php'))
$branching = $matches[0].'.php';
elseif(is_object($overlay) && $overlay->get_value('edit_as_simple'))
$branching = 'edit_as_simple.php';
elseif(is_object($overlay) && $overlay->get_value('edit_as_thread'))
$branching = 'edit_as_thread.php';
elseif(is_object($overlay) && ($deputy = $overlay->get_value('edit_as')) && is_readable('edit_as_'.$deputy.'.php'))
$branching = 'edit_as_'.$deputy.'.php';
elseif(is_object($anchor) && ($deputy = $anchor->has_option('edit_as')) && is_readable('edit_as_'.$deputy.'.php'))
$branching = 'edit_as_'.$deputy.'.php';

Expand Down
2 changes: 1 addition & 1 deletion articles/edit_as_simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
$fields[] = array($label, $input, $hint);

// else preserve attribute given by template, if any
} else
} elseif(isset($item['active_set']))
$context['text'] .= '<input type="hidden" name="active_set" value="'.$item['active_set'].'" />';

// end of regular fields
Expand Down
4 changes: 2 additions & 2 deletions articles/publish.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@

// adjust date from server time zone to surfer time zone
$value = strftime('%Y-%m-%d %H:%M:%S', time() + ((Surfer::get_gmt_offset() - intval($context['gmt_offset'])) * 3600));
$input = Skin::build_input('publish_date', $value, 'date_time');
$input = Skin::build_input_time('publish_date', $value, 'date_time');
$hint = i18n::s('Indicate a date (YYYY-MM-DD) in the future and let YACS make the page appear automatically.');
$fields[] = array($label, $input, $hint);

Expand Down Expand Up @@ -247,7 +247,7 @@
if(isset($item['expiry_date']))
$value = Surfer::from_GMT($item['expiry_date']);

$input = Skin::build_input('expiry_date', $value, 'date_time');
$input = Skin::build_input_time('expiry_date', $value, 'date_time');
$hint = i18n::s('Use this field to limit the life time of published pages.');
$fields[] = array($label, $input, $hint);

Expand Down
6 changes: 3 additions & 3 deletions articles/stamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
$context['text'] .= '<form method="post" action="'.$context['script_url'].'" name="form_2"><div>'."\n";

// catch user input
$context['text'] .= sprintf(i18n::s('Expire the page after the %s'), Skin::build_input('expiry_date', $value, 'date_time'));
$context['text'] .= sprintf(i18n::s('Expire the page after the %s'), Skin::build_input_time('expiry_date', $value, 'date_time'));

// the submit button
$context['text'] .= Skin::build_submit_button(i18n::s('Save the date'))."\n"
Expand All @@ -241,7 +241,7 @@
$context['text'] .= '<form method="post" action="'.$context['script_url'].'" name="form_2"><div>'."\n";

// catch user input
$context['text'] .= sprintf(i18n::s('Expire the page after the %s'), Skin::build_input('expiry_date', NULL, 'date_time'));
$context['text'] .= sprintf(i18n::s('Expire the page after the %s'), Skin::build_input_time('expiry_date', NULL, 'date_time'));

// the submit button
$context['text'] .= Skin::build_submit_button(i18n::s('Save the date'))."\n"
Expand All @@ -264,7 +264,7 @@
$context['text'] .= '<form method="post" action="'.$context['script_url'].'" name="form_3"><div>'."\n";

// catch user input
$context['text'] .= sprintf(i18n::s('Change the publication date to %s'), Skin::build_input('publish_date', $value, 'date_time'));
$context['text'] .= sprintf(i18n::s('Change the publication date to %s'), Skin::build_input_time('publish_date', $value, 'date_time'));

// the submit button
$context['text'] .= Skin::build_submit_button(i18n::s('Save the date'))."\n"
Expand Down
42 changes: 26 additions & 16 deletions articles/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,13 @@
$zoom_index = $context['arguments'][2];
}

// wrapper tag you may use in template (html5, microdata...)
$context['content_wrap'] = 'article';

global $render_overlaid;
$whole_rendering = !$render_overlaid;
if($render_overlaid)
$context['text'] .= '<div class="hidden require-overlaid"></div>'."\n";

// view.php/12/nick name induces no particular processing

Expand Down Expand Up @@ -449,7 +454,12 @@
$context['page_header'] .= "\n".'<link rel="service.comment" href="'.$context['url_to_root'].Comments::get_url('article:'.$item['id'], 'service.comment').'" title="Comment Interface" type="text/xml" />';

// set specific headers
if(isset($item['introduction']) && $item['introduction'])
if(is_object($overlay) && is_callable(array($overlay,'get_meta_introduction_text')) && ($more = $overlay->get_text('meta_introduction', $item))) {
$order = array("\r\n", "\n", "\r");
$replace = ' ';
$context['page_meta'] = str_replace($order, $replace,strip_tags(Codes::beautify_introduction($more)));
}
elseif(isset($item['introduction']) && $item['introduction'])
$context['page_meta'] = strip_tags(Codes::beautify_introduction($item['introduction']));
if(isset($item['create_name']) && $item['create_name'])
$context['page_author'] = $item['create_name'];
Expand Down Expand Up @@ -531,7 +541,7 @@

// signal articles to be published
if(($item['publish_date'] <= NULL_DATE)) {
if(Articles::allow_publication($item,$anchor))
if($cur_article->allows('publication'))
$label = Skin::build_link(Articles::get_url($item['id'], 'publish'), i18n::s('not published'));
else
$label = i18n::s('not published');
Expand Down Expand Up @@ -940,7 +950,7 @@
$discussion = '';

// the list of related comments, if not at another follow-up page
if(!$zoom_type || ($zoom_type == 'comments')) {
if(!$render_overlaid && !$zoom_type || ($zoom_type == 'comments')) {

// title label
$title_label = '';
Expand Down Expand Up @@ -977,10 +987,6 @@
// build a complete box
$box = array('bar' => array(), 'prefix_bar' => array(), 'text' => '');

// feed the wall
if($cur_article->allows('creation','comment'))
$box['text'] .= Comments::get_form('article:'.$item['id']);

// a navigation bar for these comments
if($count = Comments::count_for_anchor('article:'.$item['id'])) {
if($count > 20)
Expand All @@ -1000,6 +1006,10 @@
$box['bar'] = array_merge($box['bar'],
Skin::navigate(NULL, $prefix, $count, $items_per_page, $zoom_index));
}

// feed the wall
if($cur_article->allows('creation','comment'))
$box['text'] .= Comments::get_form('article:'.$item['id'], 'json', ucfirst(i18n::s('comment')), false);

// show commands
if(count($box['bar'])) {
Expand Down Expand Up @@ -1231,10 +1241,12 @@
}

// publish this page
if((!isset($item['publish_date']) || ($item['publish_date'] <= NULL_DATE)) && $cur_article->allows('publication')) {
Skin::define_img('ARTICLES_PUBLISH_IMG', 'articles/publish.gif');
$context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'publish'), ARTICLES_PUBLISH_IMG.i18n::s('Publish'));
}
if($cur_article->allows('publication')) {
if(!isset($item['publish_date'] || ($item['publish_date'] <= NULL_DATE)) {
Skin::define_img('ARTICLES_PUBLISH_IMG', 'articles/publish.gif');
$context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'publish'), ARTICLES_PUBLISH_IMG.i18n::s('Publish'));
}
}

// review various dates
if($cur_article->allows('publication')) {
Expand All @@ -1243,7 +1255,7 @@
}

// lock command provided to container and page owners
if($cur_article->is_owned()) {
if($cur_article->allows('locking')) {

if(!isset($item['locked']) || ($item['locked'] == 'N')) {
Skin::define_img('ARTICLES_LOCK_IMG', 'articles/lock.gif');
Expand All @@ -1263,7 +1275,7 @@
}

// duplicate command provided to container owners
if($cur_article->anchor->is_owned()) {
if($cur_article->allows('duplicate')) {
Skin::define_img('ARTICLES_DUPLICATE_IMG', 'articles/duplicate.gif');
if(!is_object($overlay) || (!$label = $overlay->get_label('duplicate_command', 'articles')))
$label = i18n::s('Duplicate this page');
Expand All @@ -1274,6 +1286,4 @@
}

// render the skin
render_skin();

?>
render_skin();
6 changes: 5 additions & 1 deletion categories/categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,10 @@ public static function &list_inactive_by_title($offset=0, $count=10, $variant='f
// or dead categories
$where = '('.$where.')'
." OR ((categories.expiry_date > '".NULL_DATE."') AND (categories.expiry_date <= '".$context['now']."'))";

// limit the scope to root categories
$where = '('.$where.')'
." AND categories.anchor = ''";

// the list of categories
$query = "SELECT categories.* FROM ".SQL::table_name('categories')." AS categories"
Expand Down Expand Up @@ -1565,7 +1569,7 @@ public static function put(&$fields) {
."expiry_date='".SQL::escape($fields['expiry_date'])."',"
."extra='".SQL::escape(isset($fields['extra']) ? $fields['extra'] : '')."',"
."icon_url='".SQL::escape($fields['icon_url'])."',"
."introduction='".SQL::escape($fields['introduction'])."',"
."introduction='".SQL::escape(isset($fields['introduction']) ? $fields['introduction'] : '')."',"
."keywords='".SQL::escape($fields['keywords'])."',"
."options='".SQL::escape($fields['options'])."',"
."overlay='".SQL::escape(isset($fields['overlay']) ? $fields['overlay'] : '')."',"
Expand Down
2 changes: 1 addition & 1 deletion categories/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@
if(isset($item['expiry_date']) && ($item['expiry_date'] > NULL_DATE))
$value = Surfer::from_GMT($item['expiry_date']);

$input = Skin::build_input('expiry_date', $value, 'date_time');
$input = Skin::build_input_time('expiry_date', $value, 'date_time');
$hint = i18n::s('Remove content on dead-line - automatically');
$fields[] = array($label, $input, $hint);

Expand Down
Loading

0 comments on commit 6a05302

Please sign in to comment.