Esempio n. 1
0
     $Call['Data'] = $Call['Current'];
 } else {
     if (isset($Call['Data'])) {
     } else {
         $Call['Data'] = [];
     }
     foreach ($Call['Nodes'] as $Name => $Node) {
         $UpdatedValue = F::Dot($Call['Updates'], $Name);
         if (null === $UpdatedValue) {
             if (isset($Node['Nullable']) && $Node['Nullable']) {
                 $Call['Data'] = F::Dot($Call['Data'], $Name, null);
             } else {
                 $Call['Data'] = F::Dot($Call['Data'], $Name, F::Dot($Call['Current'], $Name));
             }
         } else {
             $Call['Data'] = F::Dot($Call['Data'], $Name, F::Dot($Call['Updates'], $Name));
         }
     }
 }
 $Call['Data']['EV'] = $Call['EV'];
 $Call = F::Hook('beforeEntityUpdate', $Call);
 $Call = F::Hook('beforeEntityCreateOrUpdate', $Call);
 $Call = F::Hook('beforeEntityWrite', $Call);
 /*
 TODO: необходимо щепитильно проверить обновлялку
 */
 if (isset($Call['Failure']) and $Call['Failure']) {
     F::Log('Update Skipped due Failure Flag', LOG_WARNING, 'Administrator');
     $Call['Data'] = null;
 } else {
     if (isset($Call['Dry'])) {
Esempio n. 2
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Log', function ($Call) {
    if (preg_match_all('@\\$([\\.\\w]+)@', $Call['Message'], $Vars)) {
        foreach ($Vars[0] as $IX => $Key) {
            $Call['Message'] = str_replace($Key, F::Dot($Call, $Vars[1][$IX]), $Call['Message']);
        }
    }
    F::Log($Call['Message'], $Call['Type']);
    return $Call;
});
Esempio n. 3
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('beforeIOWrite', function ($Call) {
    if (F::Dot($Call, 'Storages.' . $Call['Storage'] . '.Journal') == true) {
        F::Log([F::Dot($Call, 'Storage'), F::Dot($Call, 'Where'), F::Dot($Call, 'Data'), F::Dot($Call, 'Reason')], LOG_WARNING, 'Administrator');
    }
    return $Call;
});
Esempio n. 4
0
        }
    }
    if (!isset($Call['Call']['locale'])) {
        $Call['Call']['locale'] = $Call['Facebook']['Default Locale'];
    }
    if (isset($Call['Call'])) {
        $Query = '?' . http_build_query($Call['Call']);
    } else {
        $Query = '';
    }
    $URL = $Call['Facebook']['Entry Point'] . $Call['Method'] . $Query;
    $Result = F::Run($Call['Backend']['Service'], $Call['Backend']['Method'], $Call['Backend']['Options'], ['Where' => $URL]);
    $Result = array_pop($Result);
    if (isset($Call['Return Key'])) {
        if (F::Dot($Result, $Call['Return Key'])) {
            $Result = F::Dot($Result, $Call['Return Key']);
        } else {
            $Result = null;
        }
    }
    return $Result;
});
setFn('Access Token', function ($Call) {
    $Result = null;
    if (isset($Call['Data']['Facebook']['Auth'])) {
        F::Log('Using FB Token from Data', LOG_INFO);
        $Result['Auth'] = $Call['Data']['Facebook']['Auth'];
    } elseif (isset($Call['Session']['User']['Facebook']['Auth'])) {
        F::Log('Using FB Token from Session', LOG_INFO);
        $Result['Auth'] = $Call['Session']['User']['Facebook']['Auth'];
    } else {
Esempio n. 5
0
setFn('Do', function ($Call) {
    $Call = F::Apply('Entity', 'Load', $Call);
    $Call = F::Hook('beforeTouch', $Call);
    $Old = F::Run('Entity', 'Read', $Call, ['One' => false]);
    if (empty($Old)) {
    } else {
        foreach ($Old as $IX => $Object) {
            $New = F::Run('Entity', 'Update', $Call, ['Entity' => $Call['Entity'], 'Data' => $Object, 'Where' => $Object['ID'], 'One' => false]);
            if (isset($Object['ID'])) {
                $Table = [['ID', $Object['ID']]];
            } else {
                $Table = [];
            }
            foreach ($Call['Nodes'] as $Name => $Node) {
                $NewValue = F::Dot($New, $Name);
                $OldValue = F::Dot($Old[$IX], $Name);
                if ($OldValue == $NewValue || $Name == 'ID') {
                } else {
                    $Table[] = ['<l>' . $Call['Entity'] . '.Entity:' . $Name . '</l>', $OldValue, $NewValue];
                }
            }
            $Call['Output']['Content'][] = ['Type' => 'Table', 'Value' => $Table];
        }
        $Call['Output']['Content'][] = ['Type' => 'Block', 'Class' => 'alert alert-success', 'Value' => count($New) . ' object touched'];
    }
    $Call = F::Hook('afterTouch', $Call);
    return $Call;
});
setFn('All', function ($Call) {
    $Call = F::Apply('Entity', 'Load', $Call);
    $Total = F::Run('Entity', 'Count', $Call);
Esempio n. 6
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Process', function ($Call) {
    if ($Call['Locale'] !== $Call['Default']['Locale']) {
        if (F::Dot($Call, 'LocalizedURLs.Enabled') && preg_match_all('@a href="(/.*)"@SsUu', $Call['Output'], $Links)) {
            $Pair = [];
            foreach ($Links[1] as $IX => $Link) {
                $Localize = true;
                if (in_array($Link, F::Dot($Call, 'LocalizedURLs.Excluded'))) {
                    $Localize = false;
                }
                foreach ($Call['Locales']['Available'] as $Locale) {
                    if (preg_match('@^/' . $Locale . '/@Ssu', $Link)) {
                        $Localize = false;
                    }
                }
                if ($Link == '/') {
                    $Localize = false;
                }
                if ($Localize) {
                    $Pair['href="' . $Link] = 'href="/' . $Call['Locale'] . $Link;
                }
            }
            $Call['Output'] = strtr($Call['Output'], $Pair);
        }
Esempio n. 7
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Run', function ($Call) {
    if (isset($Call['Hooks'])) {
        if ($Hooks = F::Dot($Call, 'Hooks.' . $Call['On'])) {
            foreach ($Hooks as $Name => $Hook) {
                $Call = F::Apply($Hook['Service'], $Hook['Method'], $Call, isset($Hook['Call']) ? $Hook['Call'] : array());
            }
        }
    }
    return $Call;
});
Esempio n. 8
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description Default value support 
 * @package Codeine
 * @version 8.x
 */
setFn('Process', function ($Call) {
    if (isset($Call['Data'])) {
        foreach ($Call['Nodes'] as $Name => $Node) {
            foreach ($Call['Data'] as &$Data) {
                if (empty(F::Dot($Data, $Name))) {
                    $Data = F::Dot($Data, $Name, null);
                }
            }
        }
    }
    return $Call;
});
Esempio n. 9
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description HTML Textfield Driver 
 * @package Codeine
 * @version 8.x
 */
setFn('Make', function ($Call) {
    if (is_array($Call['Value'])) {
        $Call['Value'] = implode(F::Dot($Call, 'Textarea.Delimiter'), $Call['Value']);
    }
    $Call = F::Apply('View.HTML.Widget.Base', 'Make', $Call, ['Tag' => 'textarea']);
    return $Call;
});
Esempio n. 10
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 */
setFn('Get', function ($Call) {
    $Total = 0;
    $Filled = 0;
    $Data = $Call['Data'];
    foreach ($Call['Nodes'] as $Name => $Node) {
        if (isset($Node['Widgets']['Write'])) {
            $Total++;
            $Value = F::Dot($Data, $Name);
            if ($Value !== null) {
                $Filled++;
            }
        }
    }
    return round($Filled / $Total * 100);
});
Esempio n. 11
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Generate', function ($Call) {
    $Call['Value'] = '';
    if (is_array($Call['Key'])) {
        foreach ($Call['Key'] as $cKey) {
            if (F::Dot($Call['Data'], $cKey) != null) {
                $Call['Data'][$cKey] = trim(F::Dot($Call['Data'], $cKey));
                if (!empty($Call['Data'][$cKey])) {
                    $Call['Value'][] = F::Dot($Call['Data'], $cKey);
                }
            }
        }
        if (!empty($Call['Value'])) {
            $Call['Value'] = implode($Call['Delimiter'], $Call['Value']);
        }
    } else {
        if (isset($Call['Data'][$Call['Key']])) {
            $Call['Value'] = trim($Call['Data'][$Call['Key']]);
        }
    }
    if (empty($Call['Value'])) {
        return null;
    }
    $Call['Value'] = mb_strtolower($Call['Value']);
Esempio n. 12
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Get', function ($Call) {
    $Index = [];
    foreach ($Call['Nodes'] as $Name => $Node) {
        if (isset($Node['Index']) && $Node['Index']) {
            if (preg_match_all('/(\\w+)/Ssu', F::Dot($Call['Data'], $Name), $Pockets)) {
                foreach ($Pockets[1] as $Pocket) {
                    $Index[] = mb_strtolower(strip_tags($Pocket));
                }
            }
        }
    }
    return array_unique($Index);
    // TODO Relevancy
});
Esempio n. 13
0
            $Call['User'] = F::Run('Entity', 'Read', $Call, ['Entity' => 'User', 'One' => true, 'Sort' => ['ID' => true], 'Where' => ['Facebook.ID' => $Facebook['id']]]);
        }
        if (empty($Call['User'])) {
            $Call['User'] = F::Run('Entity', 'Create', $Call, ['Entity' => 'User', 'One' => true, 'Data' => ['Facebook' => ['Active' => true, 'ID' => $Facebook['id'], 'Auth' => $Result['access_token'], 'Expire' => time() + $Result['expires']], 'Status' => 1]]);
        }
        $Call = F::Hook('afterFacebookIdentification', $Call);
        $Updated = $Call['User'];
        $Updated['Facebook'] = ['Active' => true, 'ID' => $Facebook['id'], 'Auth' => $Result['access_token'], 'Expire' => time() + $Result['expires'], 'Logged' => time()];
        if (isset($Call['User']['Facebook']['LoginCount'])) {
            $Call['User']['Facebook']['LoginCount']++;
        } else {
            $Call['User']['Facebook']['LoginCount'] = 1;
        }
        $Updated['Facebook']['LoginCount'] = $Call['User']['Facebook']['LoginCount'];
        if ($Updated['Facebook']['LoginCount'] == 1) {
            $Call = F::Hook('Facebook.FirstLogin', $Call);
        }
        foreach ($Call['Facebook']['Mapping'] as $FacebookField => $CodeineField) {
            if (isset($Facebook[$FacebookField]) && !empty($Facebook[$FacebookField])) {
                $Updated = F::Dot($Updated, $CodeineField, $Facebook[$FacebookField]);
            }
        }
        F::Run('Entity', 'Update', ['Entity' => 'User', 'Where' => $Call['User']['ID'], 'Data' => $Updated]);
    }
    $Call = F::Hook('afterFacebookAuthenticate', $Call);
    return $Call;
});
setFn('Annulate', function ($Call) {
    F::Run('Entity', 'Update', ['Entity' => 'User', 'Where' => $Call['Session']['User']['ID'], 'Data' => ['Facebook' => ['ID' => null]]]);
    return $Call;
});
Esempio n. 14
0
    if (isset($Test) && isset($Test['Suites'])) {
        F::Log('Test *' . $Call['Test']['Name'] . '* loaded', LOG_INFO);
        foreach ($Test['Suites'] as $SuiteName => $Suite) {
            foreach ($Suite as $CaseName => $Call['Case']) {
                $Call['Case']['Result']['Actual'] = F::Live($Call['Case']['Run'], $Call);
                if (isset($Call['Case']['Output']['Content'])) {
                    $Call['Case']['Result']['Actual'] = print_r($Call['Return']['Output']['Content'], true);
                }
                foreach ($Call['Case']['Assert'] as $Assert => $Call['Checker']) {
                    $TestTime = microtime(true);
                    // FIXME
                    $Call['Decision'] = F::Run('Test.Assert.' . $Assert, 'Do', $Call);
                    $TestTime = microtime(true) - $TestTime;
                }
                if (isset($Call['Case']['Result Key'])) {
                    $Call['Case']['Result']['Actual'] = F::Dot($Call['Case']['Result']['Actual'], $Call['Case']['Result Key']);
                }
                $Call['Test']['Report'][$Call['Test']['Name'] . $SuiteName . $CaseName] = [$Call['Test']['Name'], $SuiteName, $CaseName, '<pre>' . j($Call['Case']['Result']['Actual']) . '</pre>', round($TestTime, 5) * 1000, '_Class' => $Call['Decision'] ? 'success' : 'danger'];
                $Call['Decision'] ? F::Log('Test case ' . $CaseName . ' passed', LOG_INFO) : F::Log('Test case ' . $CaseName . ' failed', LOG_ERR);
            }
        }
    } else {
        $Call = F::Hook('onTestNotFound', $Call);
    }
    return $Call;
});
setFn('Do', function ($Call) {
    $Paths = F::getPaths();
    $Options = [];
    if (isset($Call['Test']['Name'])) {
        F::Log('Test *' . $Call['Test']['Name'] . '* selected', LOG_INFO);
Esempio n. 15
0
 foreach ($Call['Parsed'][1] as $IX => $Match) {
     if (mb_strpos($Match, ':') !== false) {
         list($Options, $Key) = explode(':', $Match);
         $Call = F::Dot($Call, $Options, F::loadOptions($Options));
         $Match = $Options . '.' . $Key;
     }
     if (mb_strpos($Match, ',') !== false) {
         $Submatches = explode(',', $Match);
         foreach ($Submatches as $Submatch) {
             if (($Matched = F::Dot($Call, $Submatch)) !== null) {
                 $Match = $Submatch;
                 break;
             }
         }
     }
     if (($Matched = F::Dot($Call, $Match)) !== null) {
         if (is_array($Matched)) {
             $Matched = j($Matched);
         }
         if ($Matched === false || $Matched === 0) {
             $Matched = '0';
         }
         $Call['Parsed'][1][$IX] = $Matched;
         F::Log('Call to *' . $Match . '* resolved as ' . $Call['Parsed'][1][$IX], LOG_DEBUG);
     } else {
         F::Log('Call to *' . $Match . '* cannot resolved', $Call['Verbosity']['Calltag']['Unresolved']);
         if (isset($Call['Remove empty'])) {
             $Call['Parsed'][1][$IX] = '';
         } else {
             unset($Call['Parsed'][0][$IX], $Call['Parsed'][1][$IX]);
         }
Esempio n. 16
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description Default value support 
 * @package Codeine
 * @version 8.x
 */
setFn('Process', function ($Call) {
    $Data = [];
    foreach ($Call['Nodes'] as $Name => $Node) {
        if (F::Dot($Call['Nodes'], $Name) !== null) {
            $Data = F::Dot($Data, $Name, F::Dot($Call['Data'], $Name));
        }
    }
    $Call['Data'] = $Data;
    return $Call;
});
Esempio n. 17
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Do', function ($Call) {
    $Result = '';
    foreach ($Call['Keys'] as $Key) {
        $Result .= F::Dot($Call, $Key);
    }
    return $Result;
});
Esempio n. 18
0
 */
setFn('beforeOperation', function ($Call) {
    // Если в Where скалярная переменная - это ID.
    if (isset($Call['Where'])) {
        $Call['Where'] = F::Live($Call['Where'], $Call);
        if (is_scalar($Call['Where'])) {
            if (strpos($Call['Where'], ',') !== false) {
                $Call['Where'] = ['ID' => explode(',', $Call['Where'])];
            } else {
                $Call['Where'] = ['ID' => $Call['Where']];
            }
        }
        $Where = [];
        if (isset($Call['Nodes'])) {
            foreach ($Call['Nodes'] as $Name => $Node) {
                if (($Value = F::Dot($Call['Where'], $Name)) !== null) {
                    if (isset($Node['Type'])) {
                        if (is_array($Value)) {
                            foreach ($Value as $Relation => $cValue) {
                                if (is_array($cValue)) {
                                    foreach ($cValue as $ccKey => $ccValue) {
                                        $Value[$Relation][$ccKey] = F::Run('Data.Type.' . $Node['Type'], 'Where', ['Name' => $Name, 'Node' => $Node, 'Value' => $ccValue]);
                                    }
                                } else {
                                    $Value[$Relation] = F::Run('Data.Type.' . $Node['Type'], 'Where', ['Name' => $Name, 'Node' => $Node, 'Value' => $cValue]);
                                }
                            }
                            // FIXME Нативные массивы?
                            if (isset($Node['Array Like']) && $Node['Array Like']) {
                                $Value = ['$elemMatch' => $Value];
                            }
Esempio n. 19
0
                } elseif (isset($Rule['Regex'])) {
                    if (preg_match($Rule['Regex'], $Call['Markup'], $Pockets)) {
                        if (isset($Pockets[1])) {
                            $Value = [$Pockets[1]];
                        }
                    } else {
                        $Value = null;
                    }
                    $Data = F::Dot($Data, $Key, $Value);
                }
                $Value = F::Dot($Data, $Key);
                if (null !== $Value) {
                    $Keys++;
                }
                if (count($Value) == 1) {
                    $Data = F::Dot($Data, $Key, $Value[0]);
                }
                $Call['Data'] = $Data;
            }
            $Data['Percent'] = floor($Keys / count($Call['Nodes']) * 100);
            $Call = F::Apply('Parser.' . $Call['Schema'], 'Do', $Call);
            phpQuery::unloadDocuments();
        }
    } else {
        F::Log('Parser Nodes *not defined*', LOG_ERR);
    }
    return $Call;
});
setFn('Discovery', function ($Call) {
    foreach ($Call['Parser']['Discovery'] as $Rule) {
        if (preg_match($Rule['Match'], $Call['URL'])) {
Esempio n. 20
0
 * @version 8.x
 */
setFn('Parse', function ($Call) {
    $Call['Parsed'] = F::Run('Text.Regex', 'All', ['Pattern' => $Call['Key Pattern'], 'Value' => $Call['Value']]);
    if ($Call['Parsed'] && isset($Call['Data'])) {
        $Call['Parsed'][0] = array_unique($Call['Parsed'][0]);
        $Call['Parsed'][1] = array_unique($Call['Parsed'][1]);
        foreach ($Call['Parsed'][1] as $IX => &$Match) {
            if (mb_strpos($Match, ',') !== false) {
                $Match = explode(',', $Match);
            } else {
                $Match = [$Match];
            }
            $Matched = '';
            foreach ($Match as $CMatch) {
                $Matched = F::Live(F::Dot($Call['Data'], $CMatch));
                if (empty($Matched)) {
                } else {
                    if ((array) $Matched === $Matched) {
                        $Matched = array_shift($Matched);
                    }
                    if ($Matched === false or $Matched === 0) {
                        $Matched = '0';
                    }
                    break;
                }
            }
            if (is_array($Matched)) {
                $Match = array_pop($Matched);
            } else {
                $Match = $Matched;
Esempio n. 21
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Do', function ($Call) {
    $Output = [];
    foreach ($Call['Keys'] as $Key) {
        $OutputTemp = F::Dot($Call['Data'], $Key);
        $Output[] = is_array($OutputTemp) ? implode($Call['Glue'], $OutputTemp) : $OutputTemp;
    }
    $Output = implode($Call['Glue'], $Output);
    if (isset($Call['Hash']) && $Call['Hash'] === true) {
        $Output = sha1($Output);
    }
    return $Output;
});
Esempio n. 22
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description <k> tag 
 * @package Codeine
 * @version 8.x
 */
setFn('Parse', function ($Call) {
    if (preg_match_all('@<treekey(.*)>(.*)</treekey>@SsUu', $Call['Value'], $Call['Parsed'])) {
        foreach ($Call['Parsed'][2] as $IX => $Match) {
            $Root = simplexml_load_string('<forkey' . $Call['Parsed'][1][$IX] . '></forkey>');
            $Output = '';
            $Key = (string) $Root->attributes()->key;
            if (($Matched = F::Live(F::Dot($Call['Data'], $Key))) !== null) {
                if (is_array($Matched)) {
                    $Rows = [];
                    F::Map($Matched, function ($Key, $Value, $Data, $NewFullKey, $Array) use(&$Rows) {
                        if (!is_array($Value)) {
                            $Rows[] = [substr($NewFullKey, 1), $Value];
                        }
                    });
                    foreach ($Rows as $Row) {
                        $Output .= strtr($Match, ['<treek/>' => $Row[0], '<treev/>' => $Row[1]]);
                    }
                    $Call['Value'] = str_replace($Call['Parsed'][0][$IX], $Output, $Call['Value']);
                }
            } else {
                $Call['Value'] = str_replace($Call['Parsed'][0][$IX], '', $Call['Value']);
            }
        }
Esempio n. 23
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description Data.Types.Input
 * @package Codeine
 * @version 8.x
 */
setFn('Write', function ($Call) {
    if (isset($Call['Dry'])) {
    } else {
        foreach ($Call['Nodes'] as $Name => $Node) {
            if (isset($Node['Type']) && F::Dot($Call['Data'], $Name) !== null) {
                $Call['Data'] = F::Dot($Call['Data'], $Name, F::Run('Data.Type.' . $Node['Type'], 'Write', $Call, $Node, ['Entity' => $Call['Entity'], 'Name' => $Name, 'Node' => $Node, 'Data' => $Call['Data'], 'Purpose' => isset($Call['Purpose']) ? $Call['Purpose'] : '', 'Value' => F::Dot($Call, 'Data.' . $Name), 'Old' => F::Dot($Call, 'Current.' . $Name)]));
            }
        }
    }
    return $Call;
});
setFn('Read', function ($Call) {
    foreach ($Call['Nodes'] as $Name => $Node) {
        if (isset($Node['Type']) && F::Dot($Call['Data'], $Name) !== null or isset($Node['External'])) {
            $Call['Data'] = F::Dot($Call['Data'], $Name, F::Run('Data.Type.' . $Node['Type'], 'Read', $Call, ['Entity' => $Call['Entity'], 'Name' => $Name, 'Node' => $Node, 'Data' => $Call['Data'], 'Purpose' => isset($Call['Purpose']) ? $Call['Purpose'] : '', 'Value' => F::Dot($Call['Data'], $Name)]));
        }
    }
    return $Call;
});
Esempio n. 24
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Detect', function ($Call) {
    $Call = F::Hook('beforeLocaleDetect', $Call);
    if (isset($Call['Locale'])) {
        F::Log('Locale selected: *' . $Call['Locale'] . '*', LOG_INFO);
    } else {
        $Call['Locale'] = $Call['Default']['Locale'];
        if (F::Dot($Call, 'Locales.Detect.Accept-language')) {
            $Call = F::Apply(null, 'Check Accept-language', $Call);
        }
    }
    setlocale(LC_ALL, $Call['Locales']['PHP'][$Call['Locale']]);
    $Call = F::Hook('afterLocaleDetect', $Call);
    return $Call;
});
setFn('Check Accept-language', function ($Call) {
    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\\s*(;\\s*q\\s*=\\s*(1|0\\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $Parsed);
        $Locales = array_combine($Parsed[1], $Parsed[4]);
        foreach ($Locales as $Locale => $Q) {
            if ($Q === '') {
                $Locales[$Locale] = 1;
            }
        }
Esempio n. 25
0
        $Root = simplexml_load_string('<root ' . $Call['Parsed'][1][$IX] . '></root>');
        $Inner = $Call['Parsed'][2][$IX];
        if (F::Dot($Call, 'View.HTML.Parslet.Cut.StripTags.Enabled') or $Root->attributes()->strip) {
            $Inner = strip_tags($Inner, F::Dot($Call, 'View.HTML.Parslet.Cut.StripTags.Allowed'));
        }
        $Outer = $Inner;
        if ($Root->attributes()->chars) {
            $Outer = F::Run('Text.Cut', 'Do', ['Cut' => 'Chars', 'Value' => $Inner, 'Chars' => (int) $Root->attributes()->chars]);
        }
        if ($Root->attributes()->words) {
            $Outer = F::Run('Text.Cut', 'Do', ['Cut' => 'Words', 'Value' => $Inner, 'Words' => (int) $Root->attributes()->words]);
        }
        if ($Root->attributes()->sentences) {
            $Outer = F::Run('Text.Cut', 'Do', ['Cut' => 'Sentences', 'Value' => $Inner, 'Sentences' => (int) $Root->attributes()->sentences]);
        }
        if ($Root->attributes()->hellip) {
            $Hellip = (string) $Root->attributes()->hellip;
        } else {
            $Hellip = F::Dot($Call, 'View.HTML.Parslet.Cut.Hellip');
        }
        if ($Root->attributes()->more) {
            $Hellip = '<a href="' . (string) $Root->attributes()->more . '" class="hellip">' . $Hellip . '</a>';
        }
        if (strlen($Outer) < strlen($Inner)) {
            $Outer .= strtr($Hellip, ['\\n' => '<br/>']);
        }
        // nl2br is unusable here
        $Call['Output'] = str_replace($Call['Parsed'][0][$IX], $Outer, $Call['Output']);
    }
    return $Call;
});
Esempio n. 26
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Run', function ($Call) {
    F::Log('API Call *' . $Call['Run']['Service'] . ':' . $Call['Run']['Method'] . '* started', LOG_NOTICE);
    $Call = F::Hook('beforeAPIRun', $Call);
    // В этом месте, практически всегда, происходит роутинг.
    if (F::Dot($Call, 'API.Run.' . $Call['Run']['Service'] . '.' . $Call['Run']['Method'] . '.Allowed')) {
        $AllowedCall = F::Dot($Call, 'API.Run.' . $Call['Run']['Service'] . '.' . $Call['Run']['Method'] . '.Params');
        $Call['Run']['Call'] = $Call['Request'];
        $Run = [];
        foreach ($AllowedCall as $Key) {
            if (isset($Call['Run']['Call'][$Key])) {
                $Run[$Key] = $Call['Run']['Call'][$Key];
            }
        }
        $Call = F::Run($Call['Run']['Service'], $Call['Run']['Method'], $Call, $Run);
    }
    $Call = F::Hook('afterAPIRun', $Call);
    // А здесь - рендеринг
    F::Log('Application *' . $Call['Run']['Service'] . ':' . $Call['Run']['Method'] . '* finished', LOG_INFO);
    return $Call;
});
Esempio n. 27
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Do', function ($Call) {
    $Call = F::Hook('beforeIncreaseDo', $Call);
    $Call = F::Run('Entity', 'Load', $Call);
    if (isset($Call['Nodes'][$Call['Key']]['Widgets']['Write']) or isset($Call['Nodes'][$Call['Key']]['Widgets']['Update'])) {
        $Data = F::Run('Entity', 'Read', $Call, ['One' => true]);
        $Data = F::Dot($Data, $Call['Key'], F::Dot($Data, $Call['Key']) + $Call['Value']);
        F::Run('Entity', 'Update', $Call, ['Data' => $Data]);
        $Call['Output']['Content'][] = 'OK';
    }
    $Call = F::Hook('afterIncreaseDo', $Call);
    return $Call;
});
Esempio n. 28
0
 $Widget['ID'] = strtr($Name, '.', '_');
 $Widget['Context'] = $Call['Context'];
 $Widget = F::Merge($Node, $Widget);
 if (isset($Call['Data'])) {
     $Widget['Data'] = $Call['Data'];
 }
 if (isset($Widget['Options'])) {
     $Widget['Options'] = F::Live($Widget['Options'], $Call);
 } else {
     $Widget['Options'] = [];
 }
 /*                    if($ic == 0)
                       $Widget['Autofocus'] = true;*/
 // Если есть значение, добавляем
 if (isset($Call['Data'])) {
     if (($Widget['Value'] = F::Dot($Call['Data'], $Name)) === null) {
         if (isset($Node['Default'])) {
             $Widget['Value'] = F::Live($Node['Default']);
         }
     }
 }
 // Упростить
 if (isset($Widget['Value'])) {
     $Widget['Value'] = F::Live($Widget['Value']);
 } else {
     $Widget['Value'] = null;
 }
 // Помещаем виджет в поток
 $ic++;
 $Call = F::Apply('Entity.Form.Layout.' . $Call['FormLayout'], 'Add', $Call, ['IC' => $ic, 'Name' => $Name, 'Widget' => $Widget]);
 $Call['Widget'] = null;
Esempio n. 29
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description: Фронт контроллер
 * @package Codeine
 * @version 8.x
 * @date 31.08.11
 * @time 1:12
 */
setFn('Run', function ($Call) {
    // В этом месте, практически всегда, происходит роутинг.
    $Call = F::Hook('beforeFrontRun', $Call);
    // Если передан нормальный вызов, совершаем его
    F::Log('Front Controlled *' . $Call['Service'] . ':' . $Call['Method'] . '* started', LOG_NOTICE);
    if (F::Dot($Call, 'Skip Front')) {
        F::Log('Front Skip Enabled', LOG_NOTICE);
    } else {
        if (F::isCall($Call['Run'])) {
            if (!isset($Call['Run']['Method'])) {
                $Call['Run']['Method'] = 'Do';
            }
            list($Call['Service'], $Call['Method']) = [$Call['Run']['Service'], $Call['Run']['Method']];
            if (isset($Call['Run']['Call'])) {
                F::Log($Call['Run']['Call'], LOG_INFO);
            }
            $Call = F::Live($Call['Run'], $Call);
        }
    }
    // А здесь - рендеринг
    $Call = F::Hook('afterFrontRun', $Call);
Esempio n. 30
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Write', function ($Call) {
    $Index = [];
    foreach ($Call['Nodes'] as $Name => $Node) {
        if (isset($Node['Index']) && $Node['Index']) {
            $Call['Value'] = F::Dot($Call['Data'], $Name);
            if (is_scalar($Call['Value'])) {
                $Call = F::Hook('beforeTokenize', $Call);
                $Call['Words'] = preg_split('/[\\W]+/Ssu', $Call['Value']);
                $Call = F::Hook('afterTokenize', $Call);
                $Index = array_merge($Index, $Call['Words']);
            }
        }
    }
    $Index = array_unique($Index);
    sort($Index);
    return $Index;
});