本文整理汇总了PHP中Options::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Options::get方法的具体用法?PHP Options::get怎么用?PHP Options::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_init
public function action_init()
{
$class_name = strtolower(get_class($this));
$this->config['provider'] = Options::get($class_name . '__provider');
$this->config['identity'] = Options::get($class_name . '__identity');
$this->config['is2'] = Options::get($class_name . '__is2');
}
示例2: __construct
public function __construct(Options $options)
{
$this->token = $options->get('token');
if (empty($this->token)) {
SS_Envato_API()->notices->add_warning('Please, set up your Envato API token.', true);
}
}
示例3: go
/**
* Upload Proccess Function.
* This will do the upload proccess. This function need some variables, eg:
* @param string $input This is the input field name.
* @param string $path This is the path the file will be stored.
* @param array $allowed This is the array of the allowed file extension.
* @param false $uniq Set to true if want to use a unique name.
* @param int $size File size maximum allowed.
* @param int $width The width of the dimension.
* @param int $height The height of the dimension.
*
* @return array
*
* @author Puguh Wijayanto (www.metalgenix.com)
* @since 0.0.1
*/
public static function go($input, $path, $allowed = '', $uniq = false, $size = '', $width = '', $height = '')
{
$filename = Typo::cleanX($_FILES[$input]['name']);
$filename = str_replace(' ', '_', $filename);
if (isset($_FILES[$input]) && $_FILES[$input]['error'] == 0) {
if ($uniq == true) {
$site = Typo::slugify(Options::get('sitename'));
$uniqfile = $site . '-' . sha1(microtime() . $filename) . '-';
} else {
$uniqfile = '';
}
$extension = pathinfo($_FILES[$input]['name'], PATHINFO_EXTENSION);
$filetmp = $_FILES[$input]['tmp_name'];
$filepath = GX_PATH . $path . $uniqfile . $filename;
if (!in_array(strtolower($extension), $allowed)) {
$result['error'] = 'File not allowed';
} else {
if (move_uploaded_file($filetmp, $filepath)) {
$result['filesize'] = filesize($filepath);
$result['filename'] = $uniqfile . $filename;
$result['path'] = $path . $uniqfile . $filename;
$result['filepath'] = $filepath;
$result['fileurl'] = Site::$url . $path . $uniqfile . $filename;
} else {
$result['error'] = 'Cannot upload to directory, please check
if directory is exist or You had permission to write it.';
}
}
} else {
//$result['error'] = $_FILES[$input]['error'];
$result['error'] = '';
}
return $result;
}
示例4: check_posts
public static function check_posts($nolimit = false)
{
$autoclosed = array();
$age_in_days = Options::get('autoclose__age_in_days');
if (is_null($age_in_days)) {
return;
}
$age_in_days = abs(intval($age_in_days));
$search = array('content_type' => 'entry', 'before' => HabariDateTime::date_create()->modify('-' . $age_in_days . ' days'), 'nolimit' => true, 'status' => 'published');
if (!$nolimit) {
$search['after'] = HabariDateTime::date_create()->modify('-' . ($age_in_days + 30) . ' days');
}
$posts = Posts::get($search);
foreach ($posts as $post) {
if (!$post->info->comments_disabled && !$post->info->comments_autoclosed) {
$post->info->comments_disabled = true;
$post->info->comments_autoclosed = true;
$post->info->commit();
$autoclosed[] = sprintf('<a href="%s">%s</a>', $post->permalink, htmlspecialchars($post->title));
}
}
if (count($autoclosed)) {
if (count($autoclosed) > 5) {
Session::notice(sprintf(_t('Comments autoclosed for: %s and %d other posts', 'autoclose'), implode(', ', array_slice($autoclosed, 0, 5)), count($autoclosed) - 5));
} else {
Session::notice(sprintf(_t('Comments autoclosed for: %s', 'autoclose'), implode(', ', $autoclosed)));
}
} else {
Session::notice(sprintf(_t('Found no posts older than %d days with comments enabled.', 'autoclose'), $age_in_days));
}
return true;
}
示例5: add_template_vars
/**
* Add some variables to the template output
*/
public function add_template_vars()
{
if (!$this->template_engine->assigned('pages')) {
$this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
}
$page = Controller::get_var('page');
$page = isset($page) ? $page : 1;
if (!$this->template_engine->assigned('page')) {
$this->assign('page', $page);
}
$this->assign('show_previously', false);
$this->assign('show_latest', false);
$action = Controller::get_action();
if ($action == 'display_home' || $action == 'display_entries') {
$offset = (int) (($page + 1 - 1) * Options::get('pagination'));
$this->assign('previously', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $offset, 'limit' => self::PREVIOUSLY_ITEMS)));
$this->assign('show_previously', true);
}
if ($action != 'display_home') {
$this->assign('latest', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => 0, 'limit' => self::LATEST_ITEMS)));
$this->assign('show_latest', true);
}
$this->assign('controller_action', $action);
parent::add_template_vars();
}
示例6: requires_upgrade
/**
* Determine if the database needs to be updated based on the source database version being newer than the schema last applied to the database
*
* @return boolean True if an update is needed
*/
public static function requires_upgrade()
{
if ( Options::get( 'db_version' ) < Version::DB_VERSION ) {
return true;
}
return false;
}
示例7: __construct
public function __construct()
{
$this->connection = @mysqli_connect(Options::get("mysql_host"), Options::get("mysql_user"), Options::get("mysql_password"), Options::get("mysql_db"));
if (!$this->connection) {
throw new Exception("Couldn't connect to database.", 1);
}
}
示例8: action_add_template_vars
function action_add_template_vars($theme)
{
$username = Options::get('freshsurf__username');
$password = Options::get('freshsurf__password');
$count = Options::get('freshsurf__count');
if ($username != '' && $password != '') {
if (Cache::has('freshsurf__' . $username)) {
$response = Cache::get('freshsurf__' . $username);
} else {
$request = new RemoteRequest("https://{$username}:{$password}@" . self::BASE_URL . "posts/recent?count={$count}", 'GET', 20);
$request->execute();
$response = $request->get_response_body();
Cache::set('freshsurf__' . $username, $response);
}
$delicious = @simplexml_load_string($response);
if ($delicious instanceof SimpleXMLElement) {
$theme->delicious = $delicious;
} else {
$theme->delicious = @simplexml_load_string('<posts><post href="#" description="Could not load feed from delicious. Is username/password correct?"/></posts>');
Cache::expire('freshsurf__' . $username);
}
} else {
$theme->delicious = @simplexml_load_string('<posts></posts>');
}
}
示例9: execute
/**
* Runs this job.
*
* Executes the Cron Job callback. Deletes the Cron Job if end_time is reached
* or if it failed to execute the last # consecutive attempts. Also sends notification
* by email to specified address.
* Note: end_time can be null, ie. "The Never Ending Cron Job".
*
* Callback is passed a param_array of the Cron Job fields and the execution time
* as the 'now' field. The 'result' field contains the result of the last execution; either
* 'executed' or 'failed'.
*
* @todo send notification of execution/failure.
*/
public function execute()
{
$paramarray = array_merge(array('now' => $this->now), $this->to_array());
// this is an ugly hack that we could probably work around better by forking each cron into its own process
// we increment the failure count now so that if we don't return after calling the callback (ie: a fatal error) it still counts against it, rather than simply never running
// and preventing all those queued up after it from running
$this->failures = $this->failures + 1;
// check to see if we have failed too many times before we update, we might go ahead and skip this one
if ($this->failures > Options::get('cron_max_failures', 10)) {
EventLog::log(_t('CronJob %s has failed %d times and is being deactivated!', array($this->name, $this->failures - 1)), 'alert', 'cron');
$this->active = 0;
}
// update before we run it
$this->update();
// if the check has been deactivated, just return
if ($this->active == 0) {
return;
}
if (is_callable($this->callback)) {
// this is a callable we can actually call, so do it
$result = call_user_func($this->callback, $paramarray);
} else {
if (!is_string($this->callback) && is_callable($this->callback, true, $callable_name)) {
// this looks like a callable to PHP, but it cannot be called at present and should not be assumed to be a plugin filter name
// there is nothing for us to do, but it was a specifically-named function for us to call, so assume this is a failure
$result = false;
} else {
// this is not callable and doesn't look like one - it should simply be a textual plugin filter name
// is this plugin filter actually implemented?
if (Plugins::implemented($this->callback, 'filter')) {
// then run it and use that result
$result = true;
$result = Plugins::filter($this->callback, $result, $paramarray);
} else {
// the filter isn't implemented, consider that a failure
$result = false;
}
}
}
if ($result === false) {
$this->result = 'failed';
// simply increment the failure counter. if it's over the limit it'll be deactivated on the next go-around
$this->failures = $this->failures + 1;
EventLog::log(_t('CronJob %s failed.', array($this->name)), 'err', 'cron');
} else {
$this->result = 'executed';
// reset failures, we were successful
$this->failures = 0;
EventLog::log(_t('CronJob %s completed successfully.', array($this->name)), 'debug', 'cron');
// it ran successfully, so check if it's time to delete it.
if (!is_null($this->end_time) && $this->now >= $this->end_time) {
EventLog::log(_t('CronJob %s is not scheduled to run again and is being deleted.', array($this->name)), 'debug', 'cron');
$this->delete();
return;
}
}
$this->last_run = $this->now;
$this->next_run = $this->now->int + $this->increment;
$this->update();
}
示例10: embed_gists
public function embed_gists($content)
{
$gists_regex = '/<script[^>]+src="(http:\\/\\/gist.github.com\\/[^"]+)"[^>]*><\\/script>/i';
// remove gists from multiple-post templates
if (Options::get('gistextras__removefrommultiple')) {
if (!in_array(URL::get_matched_rule()->name, array('display_entry', 'display_page'))) {
return preg_replace($gists_regex, '', $content);
}
}
preg_match_all($gists_regex, $content, $gists);
for ($i = 0, $n = count($gists[0]); $i < $n; $i++) {
if (Options::get('gistextras__cachegists')) {
if (Cache::has($gists[1][$i])) {
$gist = Cache::get($gists[1][$i]);
} else {
if ($gist = RemoteRequest::get_contents($gists[1][$i])) {
$gist = $this->process_gist($gist);
Cache::set($gists[1][$i], $gist, 86400);
// cache for 1 day
}
}
} else {
$gist = RemoteRequest::get_contents($gists[1][$i]);
$gist = $this->process_gist($gist);
}
// replace the script tag
$content = str_replace($gists[0][$i], $gist, $content);
}
return $content;
}
示例11: theme_page_dropdown
/**
* Build a selection input of paginated paths to be used for pagination.
*
* @param string The RewriteRule name used to build the links.
* @param array Various settings used by the method and the RewriteRule.
* @return string Collection of paginated URLs built by the RewriteRule.
*/
function theme_page_dropdown($theme, $rr_name = NULL, $settings = array())
{
$output = "";
$current = $theme->page;
$items_per_page = isset($theme->posts->get_param_cache['limit']) ? $theme->posts->get_param_cache['limit'] : Options::get('pagination');
$total = Utils::archive_pages($theme->posts->count_all(), $items_per_page);
// Make sure the current page is valid
if ($current > $total) {
$current = $total;
} else {
if ($current < 1) {
$current = 1;
}
}
$output = '<select onchange="location.href=options[selectedIndex].value">';
for ($page = 1; $page < $total; ++$page) {
$settings['page'] = $page;
$caption = $page == $current ? $current : $page;
// Build the path using the supplied $settings and the found RewriteRules arguments.
$url = URL::get($rr_name, $settings, false, false, false);
// Build the select option.
$output .= '<option value="' . $url . '"' . ($page == $current ? ' selected="selected"' : '') . '>' . $caption . '</option>' . "\n";
}
$output .= "</select>";
return $output;
}
示例12: add_template_vars
/**
* Add additional template variables to the template output.
*
* This function gets executed *after* regular data is assigned to the
* template. So the values here, unless checked, will overwrite any existing
* values.
*/
public function add_template_vars()
{
parent::add_template_vars();
if (!$this->template_engine->assigned('pages')) {
$this->assign('pages', Posts::get('page_list'));
}
if (!$this->template_engine->assigned('asides')) {
//For Asides loop in sidebar.php
$this->assign('asides', Posts::get('asides'));
}
if (!$this->template_engine->assigned('recent_comments')) {
//for recent comments loop in sidebar.php
$this->assign('recent_comments', Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')));
}
if (!$this->template_engine->assigned('more_posts')) {
//Recent posts in sidebar.php
//visiting page/2 will offset to the next page of posts in the footer /3 etc
$pagination = Options::get('pagination');
$this->assign('more_posts', Posts::get(array('content_type' => 'entry', 'status' => 'published', 'vocabulary' => array('tags:not:tag' => 'asides'), 'offset' => $pagination * $this->page, 'limit' => 5)));
}
if (!$this->template_engine->assigned('all_tags')) {
// List of all the tags
$this->assign('all_tags', Tags::vocabulary()->get_tree());
}
if (!$this->template_engine->assigned('all_entries')) {
// List of all the entries
$this->assign('all_entries', Posts::get(array('content_type' => 'entry', 'status' => 'published', 'nolimit' => 1)));
}
}
示例13: action_template_footer
/**
* Ouputs the default menu in the template footer, and runs the 'habmin_bar' plugin filter.
* You can add menu items via the filter. See the 'filter_habminbar' method for
* an example.
*/
public function action_template_footer()
{
if ( User::identify()->loggedin ) {
$bar = '<div id="habminbar"><div>';
$bar.= '<div id="habminbar-name"><a href="' . Options::get('base_url') . '">' . Options::get('title') . '</a></div>';
$bar.= '<ul>';
$menu = array();
$menu['dashboard']= array( 'Dashboard', URL::get( 'admin', 'page=dashboard' ), "view the admin dashboard" );
$menu['write']= array( 'Write', URL::get( 'admin', 'page=publish' ), "create a new entry" );
$menu['option']= array( 'Options', URL::get( 'admin', 'page=options' ), "configure site options" );
$menu['comment']= array( 'Moderate', URL::get( 'admin', 'page=comments' ),"moderate comments" );
$menu['user']= array( 'Users', URL::get( 'admin', 'page=users' ), "administer users" );
$menu['plugin']= array( 'Plugins', URL::get( 'admin', 'page=plugins' ), "activate and configure plugins" );
$menu['theme']= array( 'Themes', URL::get( 'admin', 'page=themes' ), "select a theme" );
$menu = Plugins::filter( 'habminbar', $menu );
$menu['logout']= array( 'Logout', URL::get( 'user', 'page=logout' ), "logout" );
foreach ( $menu as $name => $item ) {
list( $label, $url, $tooltip )= array_pad( $item, 3, "" );
$bar.= "\n\t<li><a href=\"$url\" class=\"$name\"" .
( ( $tooltip ) ? " title=\"$tooltip\"" : "" ) .">$label</a></li>";
}
$bar.= '</ul><br style="clear:both;" /></div></div>';
echo $bar;
}
}
示例14: filter_template_where_filters
public function filter_template_where_filters($where_filters)
{
if (Options::get('customquery__' . URL::get_matched_rule()->name)) {
$where_filters['limit'] = Options::get('customquery__' . URL::get_matched_rule()->name);
}
return $where_filters;
}
示例15: action_init
/**
* On plugin init
**/
public function action_init()
{
$this->class_name = strtolower(get_class($this));
foreach (self::default_options() as $name => $value) {
$this->config[$name] = Options::get($this->class_name . '__' . $name);
}
}