Exemple #1
0
 /**
  */
 function show()
 {
     $cache_name = 'home_page_default';
     $data = cache_get($cache_name);
     if (!$data) {
         $data = ['newest_users' => module_safe('users')->_for_home_page($this->NUM_NEWEST_USERS), 'newest_news' => module_safe('news')->_for_home_page(['num_items' => $this->NUM_NEWEST_NEWS]), 'newest_forum_posts' => module_safe('forum')->_for_home_page($this->NUM_NEWEST_FORUM_POSTS, $this->NEWEST_FORUM_TEXT_LEN), 'newest_blog_posts' => module_safe('blog')->_for_home_page($this->NUM_NEWEST_BLOG_POSTS, $this->NEWEST_BLOG_TEXT_LEN), 'newest_gallery_photo' => module_safe('gallery')->_for_home_page($this->NUM_NEWEST_GALLERY_PHOTO), 'newest_article_post' => module_safe('articles')->_for_home_page($this->NUM_NEWEST_ARTICLE_POST), 'newest_comments' => module_safe('comments')->_for_home_page($this->NUM_NEWEST_COMMENTS)];
         cache_set($cache_name, $data);
     }
     $replace =& $data;
     return tpl()->parse($_GET['object'] . '/main', $replace);
 }
Exemple #2
0
 /**
  */
 function edit()
 {
     $a = $this->_get_info();
     if (!$a) {
         return _404();
     }
     $a['back_link'] = url('/@object');
     $_this = $this;
     return form((array) $_POST + (array) $a)->validate(['__before__' => 'trim', 'name' => 'required', 'text' => 'required'])->update_if_ok(self::table, ['name', 'text', 'active', 'locale'])->on_before_update(function () use($a, $_this) {
         module_safe('manage_revisions')->add(['object_name' => $_this::table, 'object_id' => $a['id'], 'old' => $a, 'new' => $_POST, 'action' => 'update']);
     })->container($this->_get_lang_links($a['locale'], $a['name'], 'edit'))->text('name')->textarea('text', ['id' => 'text', 'cols' => 200, 'rows' => 10, 'ckeditor' => ['config' => _class('admin_methods')->_get_cke_config()]])->active_box()->save_and_back();
 }
Exemple #3
0
 function show()
 {
     header('Content-Type: text/xml', $replace = true);
     $host = $_GET['host'] ?: $_SERVER['HTTP_HOST'];
     // $_GET['host'] just for debug purposes
     $prod_hosts = main()->PRODUCTION_DOMAIN ?: [];
     if (is_string($prod_hosts)) {
         $prod_hosts = [$prod_hosts];
     }
     if (!main()->is_dev() && in_array($host, $prod_hosts)) {
         // Currently we have no sitemap
         // to enable sitemap.xml calls use:
         #			return js_redirect(url('/site_map'));
         $_GET['object'] = 'site_map';
         $_GET['action'] = 'show';
         return module_safe('site_map')->show();
     } else {
         // Dev domains always return empty sitemap
         $out = '<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>';
     }
     print $out;
     exit;
 }
Exemple #4
0
 /**
  */
 function active()
 {
     $a = $this->_get_info();
     if (!empty($a['id'])) {
         $n = $a;
         $n['active'] = (int) (!$a['active']);
         module_safe('manage_revisions')->add(['object_name' => self::table, 'object_id' => $a['id'], 'old' => $a, 'new' => $n, 'action' => 'active']);
         db()->update(self::table, ['active' => (int) (!$a['active'])], (int) $a['id']);
         common()->admin_wall_add(['static page: ' . $a['name'] . ' ' . ($a['active'] ? 'inactivated' : 'activated'), $a['id']]);
         cache_del('static_pages_names');
     }
     if (is_ajax()) {
         no_graphics(true);
         echo intval(!$a['active']);
     } else {
         return js_redirect(url('/@object'));
     }
 }
Exemple #5
0
 /**
  */
 function _view_widget_items($widgets = [])
 {
     $_orig_object = $_GET['object'];
     $_orig_action = $_GET['action'];
     $is_cloneable_item = true;
     $module_name = '';
     $method_name = '';
     $content = '';
     if ($is_cloneable_item) {
         if ($widgets["type"] == 'php') {
             /*
             				if (strlen($info['code'])) {
             					//						$content = eval('<?'.'php '.$info['code']);
             				} elseif ($info['method_name']) {
             					//						list($module_name, $method_name) = explode('.', $info['method_name']);
             				}
             */
             list($module_name, $method_name) = explode('.', $widgets['val']);
         } elseif ($widgets["type"] == 'block') {
             $content = _class('core_blocks')->show_block(['block_id' => $info['block_name']]);
         } elseif ($widgets["type"] == 'stpl') {
             /*
             				if (strlen($info['code'])) {
             					$content = tpl()->parse_string($info['code']);
             				} elseif ($info['stpl_name']) {
             					$content = tpl()->parse($info['stpl_name']);
             				}
             */
         }
     } else {
         //		list($module_name, $method_name) = explode('::', $info['full_name']);
     }
     if ($module_name && $method_name) {
         // This is needed to correctly execute widget (maybe not nicest method, I know...)
         //$_GET['object'] = $module_name;
         //$_GET['action'] = $method_name;
         //
         $_time_start = microtime(true);
         $module_obj = module_safe($module_name);
         if (is_object($module_obj) && method_exists($module_obj, $method_name)) {
             $content = $module_obj->{$method_name}($saved_config);
             $this->_debug_info['widgets'][] = ['class_name' => $module_name, 'action' => $method_name, 'time' => round(microtime(true) - $_time_start, 5)];
         } else {
             trigger_error(__CLASS__ . ': called module.method from widget not exists: ' . $module_name . '.' . $method_name . '', E_USER_WARNING);
         }
         $_GET['object'] = $_orig_object;
         $_GET['action'] = $_orig_action;
     }
     return $content;
     /*
     $items[$info['auto_id']] = tpl()->parse(__CLASS__.'/view_item', array(
     	//	'id'			=> $info['auto_id'].'_'.$info['auto_id'],
     	'name'			=> _prepare_html($widgets["type"]),
     	'content'		=> $content,
     	'has_config'	=> 0,
     	//				'css_class'		=> $saved_config['color'],
     	'hide_header'	=> 1,
     	'hide_border'	=> 1,
     ));
     
     if (!$items) {
     	return '';
     }
     return implode(PHP_EOL, $items);
     */
 }
Exemple #6
0
<?php

return function () {
    $module = 'payment_test';
    $method = '_fast_init';
    $class = module_safe($module);
    if (!method_exists($class, $method)) {
        return null;
    }
    $result = $class->{$method}();
    return $result;
};
Exemple #7
0
 /**
  */
 function active()
 {
     $id = (int) $_GET['id'];
     if ($a = $this->_get_info()) {
         $n = $a;
         $n['active'] = (int) (!$a['active']);
         module_safe('manage_revisions')->add(['object_name' => self::table, 'object_id' => $a['id'], 'old' => $a, 'new' => $n, 'action' => 'active']);
         db()->update_safe(self::table, ['active' => (int) (!$a['active'])], 'id=' . intval($a['id']));
         common()->admin_wall_add(['Email template: ' . $a['name'] . ' ' . ($a['active'] ? 'inactivated' : 'activated'), $a['id']]);
     }
     if (is_ajax()) {
         no_graphics(true);
         return print intval(!$a['active']);
     }
     return js_redirect(url('/@object'));
 }
Exemple #8
0
 /**
  * Show metatags
  */
 function show_metatags($meta = [])
 {
     if (empty($meta)) {
         $meta = $this->META_DEFAULT;
     }
     if (!is_array($meta)) {
         $meta = [];
     }
     $meta['charset'] = $meta['charset'] ?: (conf('charset') ?: 'utf-8');
     $meta['keywords'] = $meta['keywords'] ?: (conf('meta_keywords') ?: $this->META_KEYWORDS);
     $meta['description'] = $meta['description'] ?: (conf('meta_description') ?: $this->META_DESCRIPTION);
     // Override by hook method
     // TODO: maybe need to check permissions at first
     $obj = module_safe($_GET['object']);
     if (is_object($obj)) {
         $hook_names = ['_hook_meta_tags', '_hook_meta'];
         foreach ($hook_names as $method_name) {
             if (method_exists($obj, $method_name)) {
                 $meta = $obj->{$method_name}($meta);
                 break;
             }
         }
     }
     foreach ((array) $this->META_ADD as $k => $v) {
         if (!is_string($v) && is_callable($v)) {
             $meta = $v($meta);
         } elseif (isset($meta[$k])) {
             continue;
         } else {
             $meta[$k] = $v;
         }
     }
     // Quick fixes for common meta "og:" and "fb:"
     foreach ((array) $meta as $name => $value) {
         if (substr($name, 0, 3) === 'og_') {
             $meta['og:' . substr($name, 3)] = $value;
             unset($meta[$name]);
         } elseif (substr($name, 0, 3) === 'fb_') {
             $meta['og:' . substr($name, 3)] = $value;
             unset($meta[$name]);
         }
     }
     if (isset($meta['og:title']) && !isset($meta['og:type'])) {
         $meta['og:type'] = 'website';
     }
     $robots_no_index = main()->is_ajax() || MAIN_TYPE_ADMIN || conf('ROBOTS_NO_INDEX') || DEBUG_MODE || defined('DEVELOP') && DEVELOP || defined('TEST_MODE') && TEST_MODE;
     if ($robots_no_index) {
         $meta['robots'] = 'noindex,nofollow,noarchive,nosnippet';
     }
     $out = [];
     foreach ((array) $meta as $name => $values) {
         $name = trim($name);
         if (!strlen($name) || !$values) {
             continue;
         }
         $_name = _prepare_html($name);
         if (!is_array($values)) {
             $values = [$values];
         }
         foreach ((array) $values as $value) {
             $value = trim($value);
             if (!strlen($name) || !strlen($value)) {
                 continue;
             }
             $value = str_replace(["\r\n\r\n\r\n", "\r\n\r\n", "\r\n", "\r", "\n"], ' ', $value);
             $value = _prepare_html($value);
             if ($name === 'canonical') {
                 $out[$name] = '<link rel="canonical" href="' . $value . '" />';
             } elseif ($name === 'charset') {
                 $out[$name] = '<meta http-equiv="Content-Type" content="text/html; charset=' . $value . '" />';
             } elseif (false !== strpos($name, ':')) {
                 $out[$name] = '<meta property="' . $_name . '" content="' . $value . '" />';
             } else {
                 $out[$name] = '<meta name="' . $_name . '" content="' . $value . '" />';
             }
         }
     }
     if (DEBUG_MODE) {
         debug('_DEBUG_META', $meta);
         debug('_DEBUG_META_OUT', $out);
     }
     return implode(PHP_EOL, $out);
 }
Exemple #9
0
 protected function _firewall($class = null, $class_path = null, $method = null, $options = [])
 {
     $_method = '_api_' . $method;
     // try module
     $_class = module_safe($class);
     $_status = method_exists($_class, $_method);
     if (!$_status) {
         // try class
         $_class = _class_safe($class, $class_path);
         $_status = method_exists($_class, $_method);
     }
     if (!$_status) {
         $this->_reject();
     }
     $request = $this->_parse_request();
     return $_class->{$_method}($request, $options);
 }
Exemple #10
0
 /**
  * Replace standard patterns
  */
 function _replace_std_patterns($string, $name = '', array &$replace, $params = [])
 {
     $_this = $this;
     $tpl = tpl();
     $patterns = ['/\\{const\\(\\s*["\']{0,1}([a-z_][a-z0-9_]+?)["\']{0,1}\\s*\\)\\}/i' => function ($m) {
         return defined($m[1]) ? constant($m[1]) : '';
     }, '/\\{conf\\(\\s*["\']{0,1}([a-z_][a-z0-9_:]+?)["\']{0,1}\\s*\\)\\}/i' => function ($m) {
         return conf($m[1]);
     }, '/\\{module_conf\\(\\s*["\']{0,1}([a-z_@][a-z0-9_:]+?)["\']{0,1}\\s*,\\s*["\']{0,1}([a-z_][a-z0-9_:]+?)["\']{0,1}\\s*\\)\\}/i' => function ($m) {
         return module_conf($m[1], $m[2]);
     }, '/\\{(t|translate|i18n)\\(\\s*["\']{0,1}(.*?)["\']{0,1}\\s*\\)\\}/ims' => function ($m) use($replace, $name, $tpl) {
         return $tpl->_i18n_wrapper($m[2], $replace);
     }, '/\\{cleanup\\(\\s*\\)\\}(.*?)\\{\\/cleanup\\}/ims' => function ($m) {
         return trim(str_replace(["\r", "\n", "\t"], '', stripslashes($m[1])));
     }, '/\\{(tip|itip)\\(\\s*["\']{0,1}(?P<raw>[^"\'\\)\\}]*)["\']{0,1}\\s*\\)\\}/ims' => function ($m) use($replace, $name) {
         return _class_safe('graphics')->tip(['raw' => $m['raw'], 'replace' => $replace, 'tpl_name' => $name]);
     }, '/\\{(e|user_error)\\(\\s*["\']{0,1}([\\w\\-\\.]+)["\']{0,1}\\s*\\)\\}/ims' => function ($m) {
         return common()->_show_error_inline($m[2]);
     }, '/\\{ad\\(\\s*["\']{0,1}([^"\'\\)\\}]*)["\']{0,1}\\s*\\)\\}/ims' => function ($m) {
         return module_safe('advertising')->_show(['ad' => $m[1]]);
     }, '/\\{url\\(\\s*["\']{0,1}([^"\'\\)\\}]*)["\']{0,1}\\s*\\)\\}/ims' => function ($m) use($tpl) {
         return $tpl->_url_wrapper($m[1]);
     }, '/\\{form_row\\(\\s*["\']{0,1}[\\s\\t]*([a-z0-9\\-_]+)[\\s\\t]*["\']{0,1}([\\s\\t]*,[\\s\\t]*["\']{1}([^"\']*)["\']{1})?([\\s\\t]*,' . '[\\s\\t]*["\']{1}([^"\']*)["\']{1})?([\\s\\t]*,[\\s\\t]*["\']{1}([^"\']*)["\']{1})?\\s*\\)\\}/ims' => function ($m) use($replace, $name) {
         return _class('form2')->tpl_row($m[1], $replace, $m[3], $m[5], $m[7]);
     }, '/\\{([a-z0-9\\-\\_]+)\\|([a-z0-9\\-\\_\\|]+)\\}/ims' => function ($m) use($replace, $name, $tpl) {
         return $tpl->_process_var_filters($replace[$m[1]], $m[2]);
     }, '/\\{([a-z0-9\\-\\_]+)\\.([a-z0-9\\-\\_]+)\\|([a-z0-9\\-\\_\\|]+)\\}/ims' => function ($m) use($replace, $name, $tpl) {
         $val = $replace[$m[1]][$m[2]];
         return $tpl->_process_var_filters($val ?: $class_prop, $m[3]);
     }];
     // Evaluate custom PHP code pattern. Examples: {eval_code(print_r(_class('forum')))}
     if ($tpl->ALLOW_EVAL_PHP_CODE) {
         $patterns['/(\\{eval_code\\()([^\\}]+?)(\\)\\})/i'] = function ($m) {
             return eval('return ' . $m[2] . ' ;');
         };
     }
     // Custom patterns support (intended to be used inside modules/plugins)
     foreach ((array) $tpl->_custom_patterns_funcs as $pattern => $func) {
         $patterns[$pattern] = function ($m) use($replace, $name, $_this, $func) {
             return $func($m, $replace, $name, $_this);
         };
     }
     if (DEBUG_MODE) {
         // Evaluate custom PHP code pattern special for the DEBUG_MODE. Examples: {_debug_get_replace()}
         $patterns['/(\\{_debug_get_replace\\(\\)\\})/i'] = function ($m) use($replace, $name) {
             return is_array($replace) ? '<pre>' . print_r(array_keys($replace), 1) . '</pre>' : '';
         };
         // Evaluate custom PHP code pattern special for the DEBUG_MODE. Examples: {_debug_stpl_vars()}
         $patterns['/(\\{_debug_get_vars\\(\\)\\})/i'] = function ($m) use($string, $tpl) {
             return $tpl->_debug_get_vars($string);
         };
     }
     foreach ((array) $patterns as $pattern => $callback) {
         $string = preg_replace_callback($pattern, $callback, $string);
     }
     return $string;
 }
Exemple #11
0
 /**
  */
 function show_side_column_hooked()
 {
     $obj = module_safe($_GET['object']);
     $method = '_hook_side_column';
     if (method_exists($obj, $method)) {
         return $obj->{$method}();
     }
 }
Exemple #12
0
 /**
  */
 function clone_item($params = [])
 {
     if (is_string($params)) {
         $params = ['table' => $params];
     }
     if (!is_array($params)) {
         $params = [];
     }
     $params += (array) $this->params;
     $db = is_object($params['db']) ? $params['db'] : db();
     $table = $db->_fix_table_name($params['table']);
     if (!$table) {
         return false;
     }
     $fields = $params['fields'];
     $primary_field = $params['id'] ? $params['id'] : 'id';
     $id = isset($params['input_' . $primary_field]) ? $params['input_' . $primary_field] : $_GET['id'];
     if (!empty($id)) {
         $info = $db->query_fetch('SELECT * FROM ' . $db->es($table) . ' WHERE `' . $db->es($primary_field) . '`="' . $db->es($id) . '" LIMIT 1');
     }
     if ($info) {
         $sql = $info;
         unset($sql[$primary_field]);
         if (is_callable($params['on_before_update'])) {
             $params['on_before_update']($sql);
         }
         $db->insert_safe($table, $sql);
         $new_id = $db->insert_id();
         if ($params['revisions']) {
             module_safe('manage_revisions')->add($params['table'], $new_id, 'add');
         }
         common()->admin_wall_add([$_GET['object'] . ': item cloned in table ' . $table, $new_id]);
         if (is_callable($params['on_after_update'])) {
             $params['on_after_update']($sql, $new_id);
         }
     }
     if (conf('IS_AJAX')) {
         echo $new_id ? 1 : 0;
     } else {
         return js_redirect(url('/@object/' . _add_get() . $params['links_add']));
     }
 }
Exemple #13
0
 /**
  * Sitemap format generator (compatible with Google, Yahoo, MSN etc)
  *
  * https://www.google.com/webmasters/sitemaps/docs/en/about.html
  * XML-Specification: https://www.google.com/webmasters/sitemaps/docs/en/protocol.html
  * 
  * You can use the gzip feature or compress your Sitemap files using gzip. 
  * Please note that your uncompressed Sitemap file may not be larger than 10MB.
  *
  * No support for more the 50.000 URLs at the moment. See
  * http://www.google.com/webmasters/sitemaps/docs/en/protocol.html#sitemapFileRequirements
  */
 function _generate_sitemap()
 {
     main()->NO_GRAPHICS = true;
     if (!$this->SITE_MAP_ENABLED) {
         return false;
     }
     // !! Important !!
     // Turn off rewrite adding url params into sitemap urls
     _class('rewrite')->URL_ADD_BUILTIN_PARAMS = false;
     $_sitemap_base_name = $this->SITEMAP_FILE_NAME;
     // Check if needed to recreate sitemap files
     $_path = $this->SITEMAP_STORE_FOLDER . $this->SITEMAP_FILE_NAME . '_index' . $this->_file_extension;
     if (file_exists($_path) && filemtime($_path) + $this->SITEMAP_LIVE_TIME > time() && !$this->TEST_MODE) {
         // send headers
         $this->_redirect_sitemap($this->SITEMAP_WEB_PATH . $this->SITEMAP_FILE_NAME . '_index' . $this->_file_extension);
         return false;
     }
     if (!file_exists($_path)) {
         $_path = $this->SITEMAP_STORE_FOLDER . $this->SITEMAP_FILE_NAME . '1' . $this->_file_extension;
         if (file_exists($_path) && filemtime($_path) + $this->SITEMAP_LIVE_TIME > time() && !$this->TEST_MODE) {
             // send headers
             $this->_redirect_sitemap($this->SITEMAP_WEB_PATH . $this->SITEMAP_FILE_NAME . '1' . $this->_file_extension);
             return false;
         }
     }
     // Start generate sitemap
     @ignore_user_abort(true);
     @set_time_limit($this->LOCK_TIMEOUT);
     if ($this->USE_LOCKING) {
         clearstatcache();
         if (file_exists($this->LOCK_FILE_NAME)) {
             if (time() - filemtime($this->LOCK_FILE_NAME) > $this->LOCK_TIMEOUT) {
                 unlink($this->LOCK_FILE_NAME);
             } else {
                 return false;
             }
         }
         file_put_contents($this->LOCK_FILE_NAME, time());
     }
     $this->_sitemap_file_counter = 1;
     _mkdir_m($this->SITEMAP_STORE_FOLDER);
     _class('dir')->delete_files($this->SITEMAP_STORE_FOLDER, '/' . $_sitemap_base_name . '.*/i');
     $this->_fp = fopen($this->SITEMAP_STORE_FOLDER . $this->SITEMAP_FILE_NAME . $this->_sitemap_file_counter . $this->_file_extension, 'w+');
     $this->_total_length = 0;
     $this->_entries_counter = 0;
     $this->_output($this->_tpl_sitemap_header());
     $this->_total_length = strlen($header_text);
     foreach ((array) $this->MODULES_TO_INCLUDE as $module_name) {
         $module_obj = module_safe($module_name);
         if ($this->LIMIT_REACHED || !is_object($module_obj)) {
             continue;
         }
         $hook_name = '';
         foreach ((array) $this->HOOK_NAMES as $_hook_name) {
             if (method_exists($module_obj, $_hook_name)) {
                 $hook_name = $_hook_name;
                 break;
             }
         }
         if ($hook_name) {
             $items = $module_obj->{$hook_name}($this);
             if (is_array($items)) {
                 foreach ((array) $items as $item) {
                     $this->_add($item);
                 }
             }
         }
     }
     if (!$this->LIMIT_REACHED) {
         $this->_output($this->_tpl_sitemap_footer());
         @fclose($this->_fp);
     }
     $files = _class('dir')->scan($this->SITEMAP_STORE_FOLDER);
     foreach ((array) $files as $file_name) {
         if (false !== strpos($file_name, '.svn') || false !== strpos($file_name, '.git')) {
             continue;
         }
         $path_info = pathinfo($file_name);
         $_sitemap_filename_pattern = '/^(' . $this->SITEMAP_FILE_NAME . ')([0-9]{1,3})(\\.xml)$/';
         if (!preg_match($_sitemap_filename_pattern, $path_info['basename'])) {
             continue;
         } else {
             $sitemaps[$file_name] = $file_name;
         }
     }
     if ($sitemaps) {
         foreach ((array) $sitemaps as $filename) {
             $this->_process_sitemap_file($filename);
         }
     }
     $this->_file_for_google = str_replace(PROJECT_PATH, WEB_PATH, $this->SITEMAP_STORE_FOLDER) . $this->SITEMAP_FILE_NAME . '1' . $this->_file_extension;
     if ($sitemaps && count($sitemaps) > 1) {
         $this->_output($this->_tpl_sitemap_index_header());
         // Create sitemap index
         $this->_fp = fopen($this->SITEMAP_STORE_FOLDER . $this->SITEMAP_FILE_NAME . '_index' . $this->_file_extension, 'w+');
         foreach ((array) $sitemaps as $sitemap_file) {
             $string = "\t<sitemap>\n";
             $string .= "\t\t<loc>" . str_replace(PROJECT_PATH, WEB_PATH, $sitemap_file) . "</loc>\n";
             $last_mod = $this->_iso8601_date(filemtime($sitemap_file));
             if ($last_mod) {
                 $string .= "\t\t<lastmod>" . $last_mod . "</lastmod>\n";
             }
             $string .= "\t</sitemap>\n";
             // Store entry data to file
             $this->_output($string);
         }
         fclose($this->_fp);
         $this->_output($this->_tpl_sitemap_index_footer());
         $this->_file_for_google = str_replace(PROJECT_PATH, WEB_PATH, $this->SITEMAP_STORE_FOLDER) . $this->SITEMAP_FILE_NAME . '_index' . $this->_file_extension;
     }
     // Release lock
     if ($this->USE_LOCKING) {
         unlink($this->LOCK_FILE_NAME);
     }
     $this->_redirect_sitemap($this->_file_for_google);
     $this->_do_notify_google();
 }
Exemple #14
0
 /**
  */
 function _get_available_widgets_hooks()
 {
     if (isset($this->_avail_widgets)) {
         return $this->_avail_widgets;
     }
     $method_prefix = '_hook_widget_';
     $r = ['_hook_widget__' => '', '_' => '', ':' => ''];
     $_widgets = [];
     foreach ((array) _class('user_modules', 'admin_modules/')->_get_methods(['private' => '1']) as $module_name => $module_methods) {
         foreach ((array) $module_methods as $method_name) {
             if (substr($method_name, 0, strlen($method_prefix)) != $method_prefix) {
                 continue;
             }
             $full_name = $module_name . '::' . $method_name;
             $_widgets[$module_name][$method_name] = $full_name;
         }
     }
     $widgets = [];
     foreach ((array) $_widgets as $module_name => $module_widgets) {
         foreach ((array) $module_widgets as $method_name => $full_name) {
             $auto_id = str_replace(array_keys($r), array_values($r), $full_name);
             $widgets[$auto_id] = module_safe($module_name)->{$method_name}(['describe_self' => true]);
             if (!$widgets[$auto_id]['name']) {
                 unset($widgets[$auto_id]);
                 continue;
                 //					$widgets[$auto_id]['name'] = 'TODO: '.str_replace('_', ' ', substr($method_name, strlen($method_prefix)));
                 $widgets[$auto_id]['name'] = str_replace('_', ' ', substr($method_name, strlen($method_prefix)));
             }
             if (!$widgets[$auto_id]['desc']) {
                 //					$widgets[$auto_id]['name'] = $module_name.':'.str_replace('_', ' ', substr($method_name, strlen($method_prefix)));
                 $widgets[$auto_id]['name'] = 'TODO: ' . str_replace('_', ' ', substr($method_name, strlen($method_prefix)));
             }
             $widgets[$auto_id]['full_name'] = $full_name;
             $widgets[$auto_id]['auto_id'] = $auto_id;
         }
     }
     if (is_array($widgets)) {
         ksort($widgets);
     }
     $this->_avail_widgets = $widgets;
     return $widgets;
 }
Exemple #15
0
 /**
  */
 function view_poll_results()
 {
     return module_safe('poll')->owner_view($this->_poll_params);
 }
Exemple #16
0
 /**
  */
 function active()
 {
     $id = (int) $_GET['id'];
     if ($id) {
         $a = from(self::table)->whereid($id)->get();
     }
     if ($a) {
         $n = $a;
         $n['active'] = (int) (!$a['active']);
         module_safe('manage_revisions')->add(['object_name' => self::table, 'object_id' => $a['id'], 'old' => $a, 'new' => $n, 'action' => 'active']);
         db()->update_safe(self::table, ['active' => (int) (!$a['active'])], $id);
     }
     if (is_ajax()) {
         no_graphics(true);
         echo (int) (!$a['active']);
     } else {
         return js_redirect(url('/@object'));
     }
 }
Exemple #17
0
 /**
  */
 function _show_suggesting_messages()
 {
     $admin_modules = module("admin_modules")->_get_modules();
     $user_modules_methods = module("admin_modules")->_get_methods(["private" => "1"]);
     $suggests = [];
     foreach ((array) $user_modules_methods as $module_name => $module_methods) {
         if (!isset($admin_modules[$module_name])) {
             continue;
         }
         foreach ((array) $module_methods as $method_name) {
             if (substr($method_name, 0, 17) != "_account_suggests") {
                 continue;
             }
             $module_suggests = module_safe($module_name)->{$method_name}();
             foreach ((array) $module_suggests as $val) {
                 $suggests[] = $val;
             }
         }
     }
     if (!empty($suggests)) {
         $replace = ["suggests" => $suggests];
         return tpl()->parse(__CLASS__ . "/suggests", $replace);
     }
 }