示例#1
0
 /**
  * A validation function that returns an error if the value passed in is not a valid URL.
  *
  * @param string $text A string to test if it is a valid URL
  * @param FormControl $control The control that defines the value
  * @param FormContainer $form The container that holds the control
  * @param string $warning An optional error message
  * @return array An empty array if the string is a valid URL, or an array with strings describing the errors
  */
 public static function validate_url($text, $control, $form, $warning = null, $schemes = array('http', 'https'), $guess = true)
 {
     if (!empty($text)) {
         $parsed = InputFilter::parse_url($text);
         if ($parsed['is_relative']) {
             if ($guess) {
                 // guess if they meant to use an absolute link
                 $parsed = InputFilter::parse_url('http://' . $text);
                 if ($parsed['is_error']) {
                     // disallow relative URLs
                     $warning = empty($warning) ? _t('Relative urls are not allowed') : $warning;
                     return array($warning);
                 } else {
                     $warning = empty($warning) ? _t('Relative urls are not allowed') : $warning;
                     return array($warning);
                 }
             }
         }
         if ($parsed['is_pseudo'] || !in_array($parsed['scheme'], $schemes)) {
             // allow only http(s) URLs
             $warning = empty($warning) ? _t('Only %s urls are allowed', array(Format::and_list($schemes))) : $warning;
             return array($warning);
         }
     }
     return array();
 }
示例#2
0
"><?php 
        echo $inactive_theme['info']->name;
        ?>
 <span class="version dim"><?php 
        echo $inactive_theme['info']->version;
        ?>
</span></a> <span class="dim"><?php 
        _e('by');
        ?>
</span> 
			<?php 
        $authors = array();
        foreach ($inactive_theme['info']->author as $author) {
            $authors[] = isset($author['url']) ? '<a href="' . $author['url'] . '">' . $author . '</a>' : $author;
        }
        echo Format::and_list($authors, '<span class="dim">, </span>', '<span class="dim">' . _t(' and ') . '</span>');
        ?>
		</div> 
 
		<div class="thumb">
			<img src="<?php 
        echo $inactive_theme['screenshot'];
        ?>
" class="themethumb">
			<div class="themeinfo">
				<div class="pointer"></div>
				<p class="description"><?php 
        echo $inactive_theme['info']->description;
        ?>
</p>
				<?php 
示例#3
0
if (User::identify()->can_any(array('manage_all_comments' => true, 'manage_own_post_comments' => true))) {
    if (!empty($stats['unapproved_comment_count'])) {
        $message = '<a href="' . URL::get('admin', array('page' => 'comments', 'status' => Comment::STATUS_UNAPPROVED)) . '">';
        $message .= sprintf(_n('%d ' . _t('comment awaiting approval'), '%d ' . _t('comments awaiting approval'), $stats['unapproved_comment_count']), $stats['unapproved_comment_count']);
        $message .= '</a>';
        $message_bits[] = $message;
    }
    if (!empty($stats['spam_comment_count']) && Options::get('dashboard__hide_spam_count') != true) {
        $message = '<a href="' . URL::get('admin', array('page' => 'comments', 'status' => Comment::STATUS_SPAM)) . '">';
        $message .= sprintf(_n('%d ' . _t('spam comment awaiting moderation'), '%d ' . _t('spam comments awaiting moderation'), $stats['spam_comment_count']), $stats['spam_comment_count']);
        $message .= '</a>';
        $message_bits[] = $message;
    }
}
if (!empty($message_bits)) {
    _e('You have %s', array(Format::and_list($message_bits)));
}
?>
</p>

		<?php 
if (isset($updates) && count($updates) > 0) {
    foreach ($updates as $update) {
        $class = implode(' ', $update['severity']);
        if (in_array('critical', $update['severity'])) {
            $update_text = _t('<a href="%1s">%2s %3s</a> is a critical update.');
        } elseif (count($update['severity']) > 1) {
            $update_text = _t('<a href="%1s">%2s %3s</a> contains bug fixes and additional features.');
        } elseif (in_array('bugfix', $update['severity'])) {
            $update_text = _t('<a href="%1s">%2s %3s</a> contains bug fixes.');
        } elseif (in_array('feature', $update['severity'])) {
示例#4
0
    }
    $message_bits = array();
    $post_statuses = Post::list_post_statuses();
    unset($post_statuses[array_search('any', $post_statuses)]);
    foreach ($post_statuses as $status_name => $status_id) {
        $status_name = Plugins::filter('post_status_display', $status_name);
        $count = Posts::count_by_author($user->id, $status_id);
        if ($count > 0) {
            $message = '<strong><a href="' . Utils::htmlspecialchars(URL::get('admin', array('page' => 'posts', 'user_id' => $user->id, 'type' => Post::type('any'), 'status' => $status_id))) . '">';
            $message .= _n(_t('%1$d %2$s post', array($count, $status_name)), _t('%1$d %2$s posts', array($count, $status_name)), $count);
            $message .= '</a></strong>';
            $message_bits[] = $message;
        }
    }
    if (!empty($message_bits)) {
        $string = _t('%1$s and currently has %2$s', array($last_login_message, Format::and_list($message_bits)));
    } else {
        $string = $last_login_message;
    }
    echo $string;
    ?>

			</span>
		</div>
	</li>

	<?php 
}
?>
</ul>
<?php 
示例#5
0
        $last_login_message = sprintf($last_login_message, '<strong>' . date('M j, Y', strtotime($user->info->authenticate_time)) . '</strong>', '<strong>' . date('H:i', strtotime($user->info->authenticate_time)) . '</strong>');
    }
    $message_bits = array();
    $post_statuses = Post::list_post_statuses();
    unset($post_statuses[array_search('any', $post_statuses)]);
    foreach ($post_statuses as $status_name => $status_id) {
        $count = Posts::count_by_author($user->id, $status_id);
        if ($count > 0) {
            $message = '<strong><a href="' . Utils::htmlspecialchars(URL::get('admin', array('page' => 'posts', 'user_id' => $user->id, 'type' => Post::type('any'), 'status' => $status_id))) . '">';
            $message .= sprintf('%d ' . _n(_t($status_name . ' post'), _t($status_name . ' posts'), $count), $count);
            $message .= '</a></strong>';
            $message_bits[] = $message;
        }
    }
    if (!empty($message_bits)) {
        $string = sprintf(_t('%1$s and currently has %2$s'), $last_login_message, Format::and_list($message_bits));
    } else {
        $string = $last_login_message;
    }
    echo $string;
    ?>

			</span>
		</div>
	</li>

	<?php 
}
?>
</ul>
示例#6
0
</div>


<div class="container transparent userstats">
<?php 
$message_bits = array();
$post_statuses = Post::list_post_statuses();
unset($post_statuses[array_search('any', $post_statuses)]);
foreach ($post_statuses as $status_name => $status_id) {
    $count = Posts::count_by_author($edit_user->id, $status_id);
    if ($count > 0) {
        $message = '<strong><a href="' . URL::get('admin', array('page' => 'posts', 'user_id' => $edit_user->id, 'type' => Post::type('any'), 'status' => $status_id)) . '">';
        $message .= sprintf('%d ' . _n(_t($status_name . ' post'), _t($status_name . ' posts'), $count), $count);
        $message .= '</a></strong>';
        $message_bits[] = $message;
    }
}
if (count($message_bits) == 0) {
    echo "<p>" . _t('No published posts.') . "</p>\n";
} else {
    echo Format::and_list($message_bits);
}
?>
</div>

<?php 
echo $form;
?>

<?php 
include 'footer.php';
示例#7
0
" title="<?php 
    echo $action['title'];
    ?>
"><?php 
    echo $action['label'];
    ?>
</a></li>
			<?php 
}
?>
		</ul>
	</div>
	<?php 
if (count($users) > 0) {
    ?>
		<p class="users"><?php 
    echo _t('Members: ') . Format::and_list($users);
    ?>
</p>
	<?php 
} else {
    ?>
		<p class="users"><?php 
    _e('No members');
    ?>
</p>
	<?php 
}
?>
</div>
示例#8
0
	/**
	 * Returns a friendlier string version of the time, ie: 3 days, 1 hour, and 5 minutes ago
	 * 
	 * @param int $precision Only display x intervals. Note that this does not round, it only limits the display length.
	 * @param boolean $include_suffix Include the 'ago' or 'from now' suffix?
	 * @return string Time passed in the specified units.
	 */
	public function friendly ( $precision = 7, $include_suffix = true )
	{
				
		$difference = self::difference( self::date_create(), $this );
				
		
		$result = array();
		
		if ( $difference['y'] ) {
			$result[] = sprintf( '%d %s', $difference['y'], _n( 'year', 'years', $difference['y'] ) );
		}
		
		if ( $difference['m'] ) {
			$result[] = sprintf( '%d %s', $difference['m'], _n( 'month', 'months', $difference['m'] ) );
		}
		
		if ( $difference['w'] ) {
			$result[] = sprintf( '%d %s', $difference['w'], _n( 'week', 'weeks', $difference['w'] ) );
		}
		
		if ( $difference['d'] ) {
			$result[] = sprintf( '%d %s', $difference['d'], _n( 'day', 'days', $difference['d'] ) );
		}
		
		if ( $difference['h'] ) {
			$result[] = sprintf( '%d %s', $difference['h'], _n( 'hour', 'hours', $difference['h'] ) );
		}
		
		if ( $difference['i'] ) {
			$result[] = sprintf( '%d %s', $difference['i'], _n( 'minute', 'minutes', $difference['i'] ) );
		}
		
		if ( $difference['s'] ) {
			$result[] = sprintf( '%d %s', $difference['s'], _n( 'second', 'seconds', $difference['s'] ) );
		}
		
		// limit the precision
		$result = array_slice( $result, 0, $precision );
		
		$result = Format::and_list( $result );
		
		if ( $include_suffix ) {
			
			if ( $difference['invert'] == true ) {
				$result = _t( '%s from now', array( $result ) );
			}
			else {
				$result = _t( '%s ago', array( $result ) );
			}
			
		}
		
		return $result;
		
	}
</a></h4>
					<span>by <?php 
    echo AddonCatalogPlugin::name_url_list($addon->info->authors);
    ?>
</span>
					<?php 
    if ($addon->versions) {
        ?>
					<?php 
        $hvers = array();
        foreach ($addon->versions as $version) {
            $hvers[$version->info->habari_version] = $version->info->habari_version;
        }
        unset($hvers['?.?.?']);
        if (count($hvers) > 0) {
            $hvers = Format::and_list($hvers);
            ?>
					<hr>						
					<span class="meta">Habari <?php 
            echo $hvers;
            ?>
</span>
					<?php 
        }
        ?>
					<?php 
    }
    ?>
				</div>
				<div class="body columns eight">
					<p>
示例#10
0
文件: themes.php 项目: habari/system
        echo $inactive_theme['info']->name;
        ?>
 <?php 
        echo $inactive_theme['info']->version;
        ?>
</a> <?php 
        _e('by');
        ?>
 
				<?php 
        $authors = array();
        foreach ($inactive_theme['info']->author as $author) {
            $authors[] = isset($author['url']) ? '<a href="' . $author['url'] . '">' . $author . '</a>' : $author;
        }
        // @locale The string used between the last two items in the list of authors of a theme on the admin page (one, two, three *and* four).
        echo Format::and_list($authors, _t(' and '));
        ?>
			</div>

		    <?php 
        if ($inactive_theme['info']->getName() != 'pluggable' || (string) $inactive_theme['info']->attributes()->type != 'theme') {
            ?>
			<p class="legacy"><?php 
            _e('Legacy theme.');
            ?>
</p>
	      <?php 
        } elseif (isset($inactive_theme['req_parent'])) {
            ?>
			<p class="legacy"><?php 
            _e('This theme requires the parent theme named "%s".', array($inactive_theme['req_parent']));
示例#11
0
        $u_strings = array();
        foreach ($beacon['updates'] as $u_version => $u) {
            if (!empty($u['date'])) {
                $u_title = _t('%1$s update released on %2$s: %3$s', array(MultiByte::ucfirst($u['severity']), HabariDateTime::date_create($u['date'])->format('Y-m-d'), Utils::htmlspecialchars($u['text'])));
            } else {
                $u_title = _t('%1$s update: %3$s', array(MultiByte::ucfirst($u['severity']), $u['date'], Utils::htmlspecialchars($u['text'])));
            }
            if (!empty($u['url'])) {
                $u_string = sprintf('<a href="%1$s" title="%2$s" class="%3$s">%4$s</a>', $u['url'], $u_title, $u['severity'], $u['version']);
            } else {
                $u_string = sprintf('<span title="%1$s" class="%2$s">%3$s</span>', $u_title, $u['severity'], $u['version']);
            }
            // add it to the array of updates available for this plugin
            $u_strings[$u['version']] = $u_string;
        }
        $u_strings = Format::and_list($u_strings);
        ?>
								
									<li class="update">
										<?php 
        echo _t('%1$s <a href="%2$s">%3$s</a> has the following updates available: %4$s', array(MultiByte::ucfirst($beacon['type']), $beacon['url'], $beacon['name'], $u_strings));
        ?>
									</li>
								
								<?php 
    }
    ?>
						
					</ul>
					
				<?php 
示例#12
0
 /**
  * function get_title
  *
  * creates the html title for the page being displayed
  *
  * @return string the html title for the page
  */
 private function get_title()
 {
     $months = array(1 => _t('January', 'metaseo'), _t('February', 'metaseo'), _t('March', 'metaseo'), _t('April', 'metaseo'), _t('May', 'metaseo'), _t('June', 'metaseo'), _t('July', 'metaseo'), _t('August', 'metaseo'), _t('September', 'metaseo'), _t('October', 'metaseo'), _t('November', 'metaseo'), _t('December', 'metaseo'));
     $out = '';
     $matched_rule = URL::get_matched_rule();
     if (is_object($matched_rule)) {
         $rule = $matched_rule->name;
         switch ($rule) {
             case 'display_home':
             case 'display_entries':
                 $out = Options::get('title');
                 if (Options::get('tagline')) {
                     $out .= ' - ' . Options::get('tagline');
                 }
                 break;
             case 'display_entries_by_date':
                 $out = 'Archive for ';
                 if (isset($this->theme->day)) {
                     $out .= $this->theme->day . ' ';
                 }
                 if (isset($this->theme->month)) {
                     $out .= $months[$this->theme->month] . ' ';
                 }
                 if (isset($this->theme->year)) {
                     $out .= $this->theme->year . ' ';
                 }
                 $out .= ' - ' . Options::get('title');
                 break;
             case 'display_entries_by_tag':
                 // parse the tags out of the URL, just like the handler does
                 $tags = Tags::parse_url_tags(Controller::get_var('tag'));
                 // build the pieces we'll use for text
                 $include_tag_text = array();
                 $exclude_tag_text = array();
                 foreach ($tags['include_tag'] as $include_tag) {
                     $include_tag_text[] = Tags::vocabulary()->get_term($include_tag)->term_display;
                 }
                 foreach ($tags['exclude_tag'] as $exclude_tag) {
                     $exclude_tag_text[] = Tags::vocabulary()->get_term($exclude_tag)->term_display;
                 }
                 $out = Format::and_list($include_tag_text);
                 if (!empty($exclude_tag_text)) {
                     $out .= ' but not ' . Format::and_list($exclude_tag_text);
                 }
                 $out .= ' Archive - ' . Options::get('title');
                 break;
             case 'display_entry':
             case 'display_page':
                 if (strlen($this->theme->post->info->html_title)) {
                     $out = $this->theme->post->info->html_title;
                 } else {
                     $out = $this->theme->post->title;
                 }
                 $out .= ' - ' . Options::get('title');
                 break;
             case 'display_search':
                 if (isset($_GET['criteria'])) {
                     $out = 'Search Results for ' . $_GET['criteria'] . ' - ';
                 }
                 $out .= Options::get('title');
                 break;
             case 'display_404':
                 $out = 'Page Not Found';
                 $out .= ' - ' . Options::get('title');
                 break;
         }
         if (strlen($out)) {
             $out = Utils::htmlspecialchars(strip_tags($out));
             $out = stripslashes($out);
         }
     }
     return $out;
 }
 /**
  * Show stuff in the comment form
  */
 public function action_form_comment_edit($form, $comment)
 {
     $form->comment_controls->append('fieldset', 'discussion_tab', _t('Discussion'));
     $discussion = $form->discussion_tab->append('wrapper', 'discussion');
     $discussion->class = 'container';
     if (count($comment->parents) > 0) {
         $parents = array();
         foreach ($comment->parents as $parent) {
             $parents[] = '<a href="' . URL::get('admin', 'page=comment&id=' . $parent->id) . '">' . $parent->name . '</a>';
         }
         $str = 'This comment is descended from comments by ' . Format::and_list($parents) . '.';
     } else {
         $str = 'This comment has no parents.';
     }
     $discussion->append('static', 'parents', '<div class="container"><p class="pct25">' . _t('Parents') . '</p><p>' . $str . '</p></div><hr />');
     if (count($comment->children) > 0) {
         $children = array();
         foreach ($comment->children as $child) {
             $children[] = '<a href="' . URL::get('admin', 'page=comment&id=' . $child->id) . '">' . $child->name . '</a>';
         }
         $str = 'There are children of this comment by ' . Format::and_list($children) . '.';
     } else {
         $str = 'This comment has no children.';
     }
     $discussion->append('static', 'children', '<div class="container"><p class="pct25">' . _t('Children') . '</p><p>' . $str . '</p></div><hr />');
 }