public function action_generate()
 {
     $sitemaps = array();
     $components = Component::getActive();
     foreach ($components as $component) {
         if ($filename = $this->generateSitemap($component['name'])) {
             $sitemaps[] = array('location' => SITE_LINK . basename($filename));
         }
     }
     if (count($sitemaps)) {
         $fp = fopen(WEB_FOLDER . '/sitemap_index.xml', 'w');
         if (!$fp) {
             Backend::addError('Could not generate sitemap index: Could not open file');
             return false;
         }
         fwrite($fp, Render::file('backend_sitemap/index.tpl.php', array('sitemaps' => $sitemaps)));
         return WEB_FOLDER . '/sitemap_index.xml';
     }
     return false;
 }
Exemple #2
0
 public function action_execute()
 {
     $return_boolean = empty($_REQUEST['return_boolean']) ? false : true;
     $components = Component::getActive();
     if (!$components) {
         return false;
     }
     $end_result = true;
     $results = array();
     foreach (Component::getActive() as $component) {
         $results[$component['name']] = array();
         if (method_exists($component['name'], 'test')) {
             $results[$component['name']]['component'] = call_user_func(array($component['name'], 'test'));
         }
         $methods = get_class_methods($component['name']);
         if (!$methods) {
             continue;
         }
         $component_obj = new $component['name']();
         foreach ($methods as $method) {
             if (substr($method, 0, 7) == 'action_') {
                 $test_method = preg_replace('/^action_/', 'test_', $method);
                 if (in_array($test_method, $methods)) {
                     set_time_limit(30);
                     if ($result = $component_obj->{$test_method}()) {
                     } else {
                         Backend::addError($component['name'] . '::' . $method . ' Failed');
                         $end_result = false;
                     }
                     $results[$component['name']][$method] = $result;
                 }
             }
         }
     }
     $results = array_filter($results, 'count');
     ksort($results);
     return $return_boolean ? $end_result : $results;
 }
Exemple #3
0
 public static function reportCoverage(array $options = array())
 {
     $app_only = array_key_exists('app_only', $options) ? $options['app_only'] : true;
     $components = array();
     $documented = 0;
     $undocumented = 0;
     foreach (Component::getActive() as $component) {
         $methods = get_class_methods($component['name']);
         if (!$methods) {
             continue;
         }
         $action_methods = array_filter($methods, create_function('$var', '$temp = explode(\'_\', $var, 2); return count($temp) == 2 && in_array(strtolower($temp[0]), array(\'action\', \'get\', \'post\', \'put\', \'delete\'));'));
         $action_methods = array_map(create_function('$var', 'return preg_replace(\'/^(action|get|post|put|delete)_/\', \'\', $var);'), $action_methods);
         if (!count($action_methods)) {
             continue;
         }
         $docu_methods = array_filter($methods, create_function('$var', 'return substr($var, 0, 7) == \'define_\';'));
         $docu_methods = array_map(create_function('$var', 'return preg_replace(\'/^(define)_/\', \'\', $var);'), $docu_methods);
         $components[$component['name']] = array('documented' => $docu_methods, 'undocumented' => array_diff($action_methods, $docu_methods));
         $documented += count($components[$component['name']]['documented']);
         $undocumented += count($components[$component['name']]['undocumented']);
     }
     ksort($components);
     return array('documented' => $documented, 'undocumented' => $undocumented, 'components' => $components);
 }
Exemple #4
0
 function html_index($result)
 {
     Backend::add('Sub Title', 'Manage Application');
     Backend::add('result', $result);
     $admin_links = array();
     $components = Component::getActive();
     foreach ($components as $component) {
         if (method_exists($component['name'], 'adminLinks')) {
             $links = call_user_func(array($component['name'], 'adminLinks'));
             if (is_array($links) && count($links)) {
                 $admin_links[$component['name']] = $links;
             }
         }
     }
     Backend::add('admin_links', $admin_links);
     Backend::addContent(Render::file('admin.index.tpl.php'));
 }
Exemple #5
0
 public static function getConnection($table)
 {
     if ($table instanceof DBObject) {
         return $table->getConnection();
     } else {
         if (is_array($table)) {
             $table = current($table);
             return self::getConnection($table);
         } else {
             if ($components = Component::getActive()) {
                 if (substr($table, -3) == 'Obj') {
                     $table = substr($table, 0, strlen($table) - 3);
                 }
                 $components = array_flatten($components, null, 'name');
                 if (in_array($table, $components) && class_exists($table . 'Obj', true)) {
                     $name = $table . 'Obj';
                     $table = new $name();
                     return $table->getConnection();
                 }
             }
         }
     }
     return false;
 }