コード例 #1
0
ファイル: function.php プロジェクト: kidaa30/Swevers
 public function function_call($field, $object, $data)
 {
     $classname = ucfirst($object['contentname']);
     $function_name = strval($field['name']);
     if (class_exists($classname) && method_exists($classname, $function_name)) {
         View_Loader::get_instance()->set_path(CONTENTPATH . $object['contentname']);
         $result = call_user_func_array($classname . '::' . $function_name, array($object, $data));
         if ($result) {
             echo view("head", array("pages" => FW4_Admin::get_pages(), "title" => strval($field), "user" => FW4_User::get_user(), "site" => current_site()));
             echo '<h2>' . strval($field) . '</h2>';
             echo '<div class="input">' . $result . '</div>';
             echo '<div class="controls">';
             echo '<a class="button save" href="' . preg_replace('/[^\\/]+\\/[^\\/]+\\/?$/', '', $_SERVER['REQUEST_URI']) . '">' . l(array('nl' => 'Terug', 'fr' => 'Retour', 'en' => 'Back')) . '</a>';
             if (isset($field['allow_print'])) {
                 echo '<a class="button right" href="#" onclick="window.print();return false;">' . l(array('nl' => 'Afdrukken', 'fr' => 'Imprimer', 'en' => 'Print', 'de' => 'Drucken')) . '</a>';
             }
             echo '</div>';
             echo view("foot", array('scripts' => array()));
             exit;
         }
     }
     redirect($_SERVER['HTTP_REFERER']);
 }
コード例 #2
0
ファイル: images.php プロジェクト: kidaa30/Swevers
 public function function_comments($field, $object, $data, $id)
 {
     if ($row = where('id = %d', intval($id))->get_row($object['stack'] . '/' . $field['name'])) {
         $commentsfield = reset($field->xpath('object'));
         if (!$commentsfield) {
             error(404);
         }
         $commentsfield['stack'] = $object['stack'] . '/' . $field['name'] . '/' . $commentsfield['name'];
         $commentsquery = where($field['name'] . '_id', intval($id));
         $commentsamount = $commentsquery->count_rows($commentsfield['stack']);
         $commentsdata = $commentsquery->get($commentsfield['stack']);
         $segments = array_slice(func_get_args(), 4);
         if (count($segments)) {
             if (!FW4_Admin::handle_item($segments, $data)) {
                 error(404);
             }
         } else {
             echo view("head", array("pages" => FW4_Admin::get_pages(), "title" => isset($commentsfield['title']) ? $commentsfield['title'] : 'Comments', "user" => FW4_User::get_user(), "site" => current_site()));
             echo '<h2>' . (isset($commentsfield['title']) ? $commentsfield['title'] : 'Comments') . '</h2>';
             echo '<div class="input"><fieldset>';
             echo '<img src="' . $row->scale(100, 100) . '" class="thumbnail" style="display:inline-block;vertical-align:middle;margin-right:10px;"/><div style="display:inline-block;vertical-align:middle;">' . $row['orig_filename'] . '</div>';
             echo '</fieldset></div>';
             unset($commentsfield['title']);
             FW4_Admin::print_object_list($commentsfield, $commentsdata, $commentsamount, intval($id));
             echo '<div class="controls">';
             echo '<a class="button save" href="' . preg_replace('/[^\\/]+\\/[^\\/]+\\/[^\\/]+\\/?$/', '', $_SERVER['REQUEST_URI']) . '">' . l(array('nl' => 'Terug', 'fr' => 'Retour', 'en' => 'Back')) . '</a>';
             echo '</div>';
             echo view("foot", array('scripts' => array()));
         }
     } else {
         error(404);
     }
 }
コード例 #3
0
ファイル: admin.php プロジェクト: kidaa30/Swevers
 private static function object_list_details($field)
 {
     $shownfields = array();
     $headers = array();
     $typemanager = FW4_Type_Manager::get_instance();
     $filters = array();
     $searchable = false;
     $delete_limits = array();
     $i = 0;
     $user = FW4_User::get_user();
     $recursive_name = false;
     foreach ($field->children() as $subfield) {
         if (isset($subfield['hidden'])) {
             continue;
         }
         $i++;
         $dolimit = true;
         if (isset($subfield['limit_condition'])) {
             $invert = false;
             $condition = $subfield['limit_condition'];
             if (substr($condition, 0, 1) == '!') {
                 $invert = true;
                 $condition = substr($condition, 1);
             }
             $limit_fields = explode('.', $condition);
             $limit_field = $user;
             foreach ($limit_fields as $current_field) {
                 if (isset($limit_field->{$current_field})) {
                     $limit_field = $limit_field->{$current_field};
                 } else {
                     if (isset($limit_field->{$current_field})) {
                         $limit_field = false;
                         break;
                     } else {
                         $limit_field = true;
                         break;
                     }
                 }
             }
             if ($limit_field) {
                 $limit_field = true;
             }
             $dolimit = $invert ? !$limit_field : $limit_field;
         }
         if (isset($subfield['limit']) && $user->id != 0) {
             if ($dolimit) {
                 continue;
             }
         }
         if (isset($subfield['limit_delete']) && $user->id != 0) {
             if ($dolimit) {
                 $limit_fields = explode('.', $subfield['limit_delete']);
                 $limit_field = $user;
                 foreach ($limit_fields as $current_field) {
                     if (isset($limit_field[$current_field])) {
                         $limit_field = $limit_field[$current_field];
                     } else {
                         $limit_field = false;
                         break;
                     }
                 }
                 $delete_limits[strval($subfield['name'])] = $limit_field;
             }
         }
         if (isset($subfield['summary_label'])) {
             $subfield['label'] = $subfield['summary_label'];
         }
         if ($subfield->getName() == "string" || $subfield->getName() == "email") {
             if (isset($subfield['filterable'])) {
                 $searchable = true;
             }
             if (count($shownfields) > 6 || isset($subfield['summary']) && $subfield['summary'] == 'false') {
                 continue;
             }
             $headers[] = isset($subfield['label']) ? $subfield['label'] : ucwords(strval($subfield['name']));
             $shownfields[strval($subfield['name'])] = $subfield;
         } elseif ($subfield->getName() == "fieldset") {
             $fielddetails = self::object_list_details($subfield);
             $shownfields = array_merge($shownfields, $fielddetails['shownfields']);
             $headers = array_merge($headers, $fielddetails['headers']);
             $searchable = $searchable || $fielddetails['searchable'];
             $filters = array_merge($filters, $fielddetails['filters']);
         } elseif ($subfield->getName() == "date" || $subfield->getName() == "timedate" || $subfield->getName() == "bool") {
             if (isset($subfield['filterable'])) {
                 if ($subfield->getName() == "bool") {
                     $filters[strval($subfield['name'])] = array('label' => isset($subfield['label']) ? $subfield['label'] : ucwords(strval($subfield['name'])), 'values' => array(1 => l(array('nl' => 'Ja', 'fr' => 'Oui', 'en' => 'Yes')), 0 => l(array('nl' => 'Nee', 'fr' => 'Non', 'en' => 'No'))));
                 } else {
                     $filters[strval($subfield['name'])] = array('label' => isset($subfield['label']) ? $subfield['label'] : ucwords(strval($subfield['name'])), 'values' => array(1 => l(array('nl' => 'Vandaag', 'fr' => 'Vandaag', 'en' => 'Vandaag')), 2 => l(array('nl' => 'Gisteren', 'fr' => 'Gisteren', 'en' => 'Gisteren')), 3 => l(array('nl' => 'Voorbije 7 dagen', 'fr' => 'Voorbije 7 dagen', 'en' => 'Voorbije 7 dagen')), 6 => l(array('nl' => 'Deze maand', 'fr' => 'Deze maand', 'en' => 'Deze maand')), 9 => ucfirst(strftime('%B', mktime(0, 0, 0, date("n") - 1, 1))), 10 => ucfirst(strftime('%B', mktime(0, 0, 0, date("n") - 2, 1))), 11 => ucfirst(strftime('%B', mktime(0, 0, 0, date("n") - 3, 1))), 4 => l(array('nl' => 'Voorbije 30 dagen', 'fr' => 'Voorbije 30 dagen', 'en' => 'Voorbije 30 dagen')), 7 => l(array('nl' => 'Dit kwartaal', 'fr' => 'Dit kwartaal', 'en' => 'Dit kwartaal')), 8 => l(array('nl' => 'Vorig kwartaal', 'fr' => 'Vorig kwartaal', 'en' => 'Vorig kwartaal')), 5 => l(array('nl' => 'Voorbije jaar', 'fr' => 'Voorbije jaar', 'en' => 'Voorbije jaar'))));
                 }
             }
             if (count($shownfields) > 6 || isset($subfield['summary']) && $subfield['summary'] == 'false') {
                 continue;
             }
             $headers[] = isset($subfield['label']) ? $subfield['label'] : ucwords(strval($subfield['name']));
             $shownfields[strval($subfield['name'])] = $subfield;
         } elseif ($subfield->getName() == "filter") {
             $values = array();
             foreach ($subfield->children() as $child) {
                 $value = isset($child['value']) ? strval($child['value']) : strval($child);
                 $values[$value] = strval($child);
             }
             $filters[strval($subfield['name'])] = array('label' => isset($subfield['label']) ? $subfield['label'] : ucwords(strval($subfield['name'])), 'values' => $values);
         } elseif ($subfield->getName() == "number") {
             if (count($shownfields) > 6 || isset($subfield['summary']) && $subfield['summary'] == 'false') {
                 continue;
             }
             $headers[] = isset($subfield['label']) ? $subfield['label'] : ucwords(strval($subfield['name']));
             $shownfields[strval($subfield['name'])] = $subfield;
         } elseif ($subfield->getName() == "float") {
             if (count($shownfields) > 6 || isset($subfield['summary']) && $subfield['summary'] == 'false') {
                 continue;
             }
             $headers[] = isset($subfield['label']) ? $subfield['label'] : ucwords(strval($subfield['name']));
             $shownfields[strval($subfield['name'])] = $subfield;
         } elseif ($subfield->getName() == "text") {
             if (isset($subfield['filterable'])) {
                 $searchable = true;
             }
             if (count($shownfields) > 6 || !isset($subfield['summary']) || $subfield['summary'] != 'excerpt' && $subfield['summary'] != 'bool') {
                 continue;
             }
             $headers[] = isset($subfield['label']) ? $subfield['label'] : ucwords(strval($subfield['name']));
             $shownfields[strval($subfield['name'])] = $subfield;
         } elseif ($subfield->getName() == "recursive") {
             $recursive_name = strval($subfield['name']);
         } elseif ($type = $typemanager->get_type(strval($subfield->getName()))) {
             if ($subfield->getName() == "choice" && isset($subfield['filterable'])) {
                 $parent_item = self::$parent_item;
                 self::$parent_item = self::$current_item;
                 $values = array();
                 if (isset($subfield['source'])) {
                     if (!($structure = FW4_Structure::get_object_structure(strval($subfield['source']), false))) {
                         continue;
                     }
                     $titlefields = $structure->xpath('string');
                     if (!($titlefield = reset($titlefields))) {
                         continue;
                     }
                     $titlefield = strval($titlefield['name']);
                     foreach ($type->get_source_rows(strval($subfield['source']), $subfield) as $child) {
                         $value = $child->id;
                         if (isset($subfield['format'])) {
                             $displayvalue = $subfield['format'];
                             preg_match_all('/\\[([a-z0-9\\_]+)\\]/is', $subfield['format'], $matches, PREG_SET_ORDER);
                             foreach ($matches as $match) {
                                 $match_name = $match[1];
                                 $displayvalue = str_ireplace($match[0], $child->{$match_name}, $displayvalue);
                             }
                             $values[$value] = $displayvalue;
                         } else {
                             $values[$value] = $child->{$titlefield};
                         }
                     }
                 } else {
                     foreach ($subfield->children() as $child) {
                         $value = isset($child['value']) ? strval($child['value']) : strval($child);
                         $values[$value] = strval($child);
                     }
                 }
                 $filters[strval($subfield['name'])] = array('label' => isset($subfield['label']) ? $subfield['label'] : ucwords(strval($subfield['name'])), 'values' => $values);
                 self::$parent_item = $parent_item;
             }
             if (!method_exists($type, 'summary') || count($shownfields) > 6 || isset($subfield['summary']) && $subfield['summary'] == 'false') {
                 continue;
             }
             $headers[] = isset($subfield['label']) ? $subfield['label'] : ucwords(strval($subfield['name']));
             $shownfields[strval($subfield['name'])] = $subfield;
         }
     }
     return array('shownfields' => $shownfields, 'headers' => $headers, 'searchable' => $searchable, 'filters' => $filters, 'delete_limits' => $delete_limits, 'recursive_name' => $recursive_name);
 }
コード例 #4
0
ファイル: router.php プロジェクト: kidaa30/Swevers
 public static function go()
 {
     ob_start();
     // Global buffer
     start_benchmark('global');
     // Determine URI string
     $path = str_ireplace("index.php", "", $_SERVER['PHP_SELF']);
     $uri = $_SERVER['REQUEST_URI'];
     if (stripos($uri, $path) === 0) {
         $uri = substr($uri, strlen($path));
     }
     $uri = explode("?", $uri);
     $uri = rawurldecode(reset($uri));
     use_library('text');
     // Load up text modification functions. We'll need them for translation.
     use_library('files');
     self::$segments = array_filter(explode("/", $uri));
     // Split string into segments
     parse_str(parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY), $_GET);
     // Apache rewrite might mess up our GET parameters. Let's just parse them ourselves.
     // Get current site based on URL
     $site = current_site();
     // Redirect to HTTPS if needed
     if (Config::https() && !(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) {
         redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
     }
     set_error_handler('_error_handler');
     if ($site->live) {
         //ini_set('display_errors',1);error_reporting(-1);
         register_shutdown_function('_shutdown_handler');
         // Set up function that will catch any coding errors
     } else {
         ini_set('display_errors', 1);
         error_reporting(-1);
         header("X-Robots-Tag: noindex, nofollow", true);
         // Prevent google from indexing us while we're not live yet
     }
     // Show admin page if requested
     if (segment(0) == ADMINDIR && Config::admin_enabled()) {
         array_shift(self::$segments);
         self::load_page_files();
         // Load content pages
         require BASEPATH . 'admin/admin.php';
         return FW4_Admin::show();
         // Download file if requested
     } else {
         if (count(self::$segments) == 2 && self::segment(0) == '_download') {
             $file = where('id = %d', intval(self::segment(1)))->get_row('site/downloads');
             if ($file) {
                 force_download(FILESPATH . $file->filename, $file->orig_filename);
                 exit;
             } else {
                 return false;
             }
             // Determine which page to load
         } else {
             use_library('piwik');
             Piwik::track_page_view();
             register_shutdown_function(function () {
                 close_connection();
                 Piwik::process();
             });
             // Load requested global libraries
             foreach (Config::global_libraries() as $library) {
                 use_library($library);
             }
             $has_correct_language = self::determine_language();
             self::load_page_files();
             // Load content pages
             if (self::route(ROUTE_EARLY)) {
                 return true;
             }
             if (!$has_correct_language) {
                 self::language_redirect();
             }
             if (self::route(ROUTE_DEFAULT)) {
                 return true;
             }
             // If no segments are defined, apply default segments
             $orig_segments = self::$segments;
             if (!isset(self::$segments[0])) {
                 self::$segments[0] = "home";
             }
             if (!isset(self::$segments[1])) {
                 self::$segments[1] = "index";
             }
             if (self::route(ROUTE_DEFAULT)) {
                 return true;
             }
             // There's no appropriate content with or without applying rules. Let's see if there's anything in the postprocessing rules.
             self::$segments = $orig_segments;
             if (self::route(ROUTE_LATE)) {
                 return true;
             }
             // Absolutely nothing matches. No content exist for requested segments.
             return false;
         }
     }
 }
コード例 #5
0
ファイル: header.php プロジェクト: kidaa30/Swevers
    public function print_field($field, $data, $object)
    {
        $user = FW4_User::get_user();
        if (!isset($data->id)) {
            $has_siblings = false;
            foreach ($field->xpath('following-sibling::*') as $sibling) {
                if ($sibling->getName() == 'header') {
                    break;
                }
                if (isset($sibling['require']) && $user->id !== 0) {
                    $require_fields = explode('.', $sibling['require']);
                    $require_field = $user;
                    foreach ($require_fields as $current_field) {
                        if (isset($require_field[$current_field]) && $require_field[$current_field]) {
                            $require_field = $require_field[$current_field];
                        } else {
                            $require_field = false;
                            break;
                        }
                    }
                    if (!$require_field) {
                        continue;
                    }
                }
                if ($sibling->getName() != 'object' && $sibling->getName() != 'recursive' && $sibling->getName() != 'slug' && $sibling->getName() != 'family') {
                    $has_siblings = true;
                }
            }
            if (!$has_siblings) {
                return false;
            }
        } else {
            $has_siblings = false;
            foreach ($field->xpath('following-sibling::*') as $sibling) {
                if ($sibling->getName() == 'header') {
                    break;
                }
                if (isset($sibling['require']) && $user->id !== 0) {
                    $require_fields = explode('.', $sibling['require']);
                    $require_field = $user;
                    foreach ($require_fields as $current_field) {
                        if (isset($require_field[$current_field]) && $require_field[$current_field]) {
                            $require_field = $require_field[$current_field];
                        } else {
                            $require_field = false;
                            break;
                        }
                    }
                    if (!$require_field) {
                        continue;
                    }
                }
                if (isset($object['is_version']) && $sibling->getName() == 'object') {
                    continue;
                }
                if ($sibling->getName() == 'recursive' && (isset($sibling['levels']) && FW4_Admin::$recursive_levels >= $sibling['levels'] || isset($object['editing_disabled']))) {
                    continue;
                }
                if ($sibling->getName() == 'family' && isset($object['editing_disabled'])) {
                    continue;
                }
                if ($sibling->getName() != 'slug' && $sibling->getName() != 'creator' && $sibling->getName() != 'export') {
                    $has_siblings = true;
                }
            }
            if (!$has_siblings) {
                return false;
            }
        }
        FW4_Admin::$has_headers = true;
        ?>
    	<h2><?php 
        echo strval($field);
        ?>
</h2><?php 
    }