Example #1
0
 /**
  * Strip the undesired HTML markup
  *
  * @param string $value The input string with HTML markup
  *
  * @return string Filtered string
  *
  *
  */
 public function filter($value)
 {
     // start by stripping the comments, if necessary
     if (!$this->allowComments) {
         $value = preg_replace('/<!\\-\\-.*\\-\\->/U', '', $value);
     }
     // strip unallowed tags
     $allowed = '';
     foreach ($this->allowedTags as $tag) {
         $allowed .= "<{$tag}>";
     }
     $value = strip_tags($value, $allowed);
     // strip unallowed attributes - only if there are allowed tags,
     // otherwise all attributes have already been removed with the tags
     if (!empty($this->allowedTags)) {
         $allowed = $this->allowedAttributes;
         do {
             $old = $value;
             $value = preg_replace_callback('/<[a-zA-Z]+ *(([a-zA-Z_:][\\-a-zA-Z0-9_:\\.]+) *=.*["\'].*["\']).*>/U', function ($matches) use($allowed) {
                 if (in_array($matches[2], $allowed)) {
                     return $matches[0];
                 } else {
                     return repl(' ' . $matches[1], '', $matches[0]);
                 }
             }, $value);
         } while ($old != $value);
     }
     // we're left with the filtered value
     return $value;
 }
Example #2
0
 public function __construct($table, $fields)
 {
     /* polymorphism */
     $fields = !Arrays::is($fields) ? strstr($fields, ',') ? explode(',', repl(' ', '', $fields)) : [$fields] : $fields;
     $this->table = $table;
     $this->fields = $fields;
 }
Example #3
0
 /**
  * Strip all newline characters and convert them to spaces
  *
  * @param string $value The input string
  *
  * @return string Filtered string
  */
 public function filter($value)
 {
     // replace Windows line endings
     $value = repl("\r\n", " ", $value);
     // replace Unix line endings
     $value = repl("\n", " ", $value);
     return $value;
 }
Example #4
0
 public function keys($pattern)
 {
     $collection = array();
     if (strstr($pattern, '%%') or strstr($pattern, '*')) {
         $pattern = repl('%%', '', repl('*', '', $pattern));
     }
     return $this->search($pattern);
 }
Example #5
0
 public function __construct($db, $table, $fields)
 {
     /* CLI case */
     if (!defined('APPLICATION_ENV')) {
         define('APPLICATION_ENV', 'production');
     }
     /* polymorphism */
     $fields = !Arrays::is($fields) ? strstr($fields, ',') ? explode(',', repl(' ', '', $fields)) : [$fields] : $fields;
     $this->table = $table;
     $this->fields = $fields;
     $this->model = jdb($db, $this->table);
 }
Example #6
0
 public function keys($pattern)
 {
     $collection = array();
     $pattern = repl('*', '', $pattern);
     $rows = $this->search($pattern);
     if (count($rows)) {
         foreach ($rows as $row) {
             array_push($collection, $row);
         }
     }
     return $collection;
 }
Example #7
0
 public static function getInfosVideo($videoId, $returnObject = true)
 {
     $xml = dwn(repl('##videoId##', $videoId, static::VIDEO_INFOS_URI));
     $xml = simplexml_load_string($xml);
     $json = json_encode($xml);
     $array = json_decode($json, true);
     if (true === $returnObject) {
         $obj = new Container($array);
         return $obj;
     }
     return $array;
 }
Example #8
0
 public function keys($pattern)
 {
     $pattern = repl('*', '%', $pattern);
     $res = $this->db->where("key LIKE {$pattern}")->exec();
     $collection = array();
     if (count($res)) {
         foreach ($res as $row) {
             array_push($collection, $row['key']);
         }
     }
     return $collection;
 }
Example #9
0
 public function write($file, $data)
 {
     $dirStore = $this->model->dirStore();
     self::fp($this->hashFile($file), $data);
     if (count($this->replicas)) {
         $raw = repl($dirStore, '', $this->hashFile($file));
         foreach ($this->replicas as $replica) {
             $rawFile = $replica . $raw;
             self::fp($rawFile, $data);
         }
     }
     return $this;
 }
Example #10
0
 public function write($file, $data)
 {
     $key = $this->redisKey($file);
     $source = $this->fp($file, $data);
     if (count($this->replicas)) {
         $dirStore = $this->model->dirStore();
         $raw = repl($dirStore, '', $file);
         foreach ($this->replicas as $replica) {
             $rawFile = $replica . $raw;
             $copy = $this->fp($rawFile, $data);
         }
     }
     $this->model->cache()->set($key, $data);
 }
Example #11
0
 public function __construct($language, $segment = '')
 {
     if (Inflector::length($segment)) {
         $fileTranslation = LANGUAGE_PATH . DS . ucwords(Inflector::lower(repl('.', DS, $segment))) . DS . Inflector::lower($language) . '.ini';
     } else {
         $fileTranslation = LANGUAGE_PATH . DS . Inflector::lower($language) . '.ini';
     }
     if (File::exists($fileTranslation)) {
         $ini = new Ini($fileTranslation);
         $translations = $ini->parseIni();
         $this->setSentences($translations);
         Utils::set('ThinTranslate', $this);
     } else {
         throw new Exception('The translation file ' . $fileTranslation . ' does not exist.');
     }
 }
Example #12
0
function start_repl()
{
    $dot = isPOSIX() ? '·' : '-';
    echo <<<LICENSE
Quack {$dot} Copyright (C) 2016 Marcelo Camargo
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type 'show c' for details.

LICENSE;
    echo "Use quack --help for more information", PHP_EOL;
    if (args_have('-h', '--help')) {
        open_repl_help();
        return;
    }
    repl();
}
Example #13
0
 public static function getInfosMovie($id)
 {
     $html = dwn('http://vod.canalplay.com/films/cinema/holiday,297,308,' . $id . '.aspx');
     if (strstr($html, 'Object moved to')) {
         $url = 'http://vod.canalplay.com' . urldecode(Utils::cut('<h2>Object moved to <a href="', '"', $html));
         $html = dwn($url);
     }
     $story = Utils::cut('alt="L\'histoire" title="L\'histoire" /></h2><p>', '</p>', $html);
     $title = Utils::cut('var title="', '"', $html);
     $image = 'http://canalplay-publishing.canal-plus.com/movies/' . $id . '/pictures/' . $id . '_pivot.jpg';
     $purpose = Utils::cut('title="A propos du film" /></h2><p>', '</p></div></div>', $html);
     $distribution = array();
     $tab = explode("title=\"Voir tous les films de/avec '", $html);
     if (count($tab)) {
         for ($i = 1; $i < count($tab) - 1; $i++) {
             $seg = trim($tab[$i]);
             if (strstr($seg, "</a>") && strstr($seg, "underline")) {
                 $person = Utils::cut('\'">', '</a>', $seg);
                 if (!Arrays::inArray($person, $distribution)) {
                     $distribution[] = $person;
                 }
             }
         }
     }
     $director = null;
     $actors = array();
     if (count($distribution)) {
         $director = current($distribution);
         $actors = array();
         if (1 < count($distribution)) {
             for ($j = 1; $j < count($distribution); $j++) {
                 $actors[] = $distribution[$j];
             }
         }
     }
     $other = Utils::cut('<li style="clear:left;"><strong><br />', '</li>', $html);
     list($first, $second) = explode('</strong>- ', $other, 2);
     list($country, $year) = explode("-", $first, 2);
     $country = substr($country, 0, -1);
     $year = repl("\n", '', $year);
     $year = repl("\r", '', $year);
     $year = repl("\n", '', $year);
     list($duration, $dummy) = @explode("\n", $second, 2);
     $infos = array('title' => $title, 'story' => $story, 'image' => $image, 'purpose' => $purpose, 'director' => $director, 'actors' => $actors, 'country' => $country, 'year' => $year, 'duration' => $duration);
     return $infos;
 }
Example #14
0
 public function keys($pattern)
 {
     $collection = $this->data($pattern);
     if (!Arrays::is($collection)) {
         $oldPattern = $pattern;
         $pattern .= '*#*';
         $pattern = repl('**', '*', $pattern);
         $files = $this->glob($this->dir . DS . $pattern);
         $collection = array();
         if (count($files)) {
             foreach ($files as $row) {
                 array_push($collection, $row);
             }
         }
         $this->setData($oldPattern, $collection);
     }
     return $collection;
 }
Example #15
0
 public function keys($pattern)
 {
     $pattern = repl('*', '%', $pattern);
     $q = "SELECT kvs_db_id FROM kvs_db WHERE kvs_db_id LIKE '{$pattern}'";
     $res = $this->execute($q);
     if (Arrays::is($res)) {
         $count = count($res);
     } else {
         $count = $res->rowCount();
     }
     if ($count < 1) {
         return array();
     }
     $collection = array();
     foreach ($res as $row) {
         array_push($collection, $row['kvs_db_id']);
     }
     return $collection;
 }
Example #16
0
 public function keys($pattern = 'all')
 {
     $data = $this->data();
     $data = !strstr($data, '{') ? array() : json_decode($data, true);
     $keys = array_keys($data);
     if ($pattern == 'all') {
         return $keys;
     }
     $pattern = repl('*', '', $pattern);
     $collection = array();
     if (count($keys)) {
         foreach ($keys as $key) {
             if (strstr($key, $pattern)) {
                 array_push($collection, $key);
             }
         }
     }
     return $collection;
 }
Example #17
0
 public function out()
 {
     $bad = array('&', '<');
     $good = array('&#x26;', '&#x3c;');
     $title = repl($bad, $good, $this->title);
     $out = "<item>\n";
     $out .= "<title>" . $title . "</title>\n";
     $out .= "<link>" . $this->link . "</link>\n";
     $out .= "<description>" . $this->cdata($this->description) . "</description>\n";
     $out .= "<pubDate>" . $this->pubDate . "</pubDate>\n";
     if (is_null($this->guid)) {
         $this->guid = $this->link;
     }
     $out .= "<guid>" . $this->guid . "</guid>\n";
     if (!is_null($this->enclosureUrl)) {
         $out .= "<enclosure url='{$this->enclosureUrl}' length='{$this->enclosureLength}' type='{$this->enclosureType}' />\n";
     }
     foreach ($this->tags as $k => $v) {
         $out .= "<{$k}>{$v}</{$k}>\n";
     }
     $out .= "</item>\n";
     return $out;
 }
Example #18
0
File: Rss.php Project: noikiy/inovi
 public function out()
 {
     $bad = array('&', '<');
     $good = array('&#x26;', '&#x3c;');
     $title = repl($bad, $good, $this->title);
     $description = repl($bad, $good, $this->description);
     $out = $this->header();
     $out .= "<channel>\n";
     $out .= "<title>" . $title . "</title>\n";
     $out .= "<link>" . $this->link . "</link>\n";
     $out .= "<description>" . $description . "</description>\n";
     $out .= "<language>" . $this->language . "</language>\n";
     $out .= "<pubDate>" . $this->pubDate . "</pubDate>\n";
     $out .= '<atom:link href="' . $this->url . '" rel="self" type="application/rss+xml" />' . "\n";
     foreach ($this->tags as $k => $v) {
         $out .= "<{$k}>{$v}</{$k}>\n";
     }
     foreach ($this->items as $item) {
         $out .= $item->out();
     }
     $out .= "</channel>\n";
     $out .= $this->footer();
     return $out;
 }
Example #19
0
 /**
  * Check the version of the given property in the User-Agent.
  * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  *
  * @param string $propertyName The name of the property. See self::getProperties() array
  *                              keys for all possible properties.
  * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  *                      self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  *                      is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  *                      invalid parameter will default to the this type as well.
  *
  * @return string|float The version of the property we are trying to extract.
  */
 public function version($propertyName, $type = self::VERSION_TYPE_STRING)
 {
     if (empty($propertyName)) {
         return false;
     }
     //set the $type to the default if we don't recognize the type
     if ($type != self::VERSION_TYPE_STRING && $type != self::VERSION_TYPE_FLOAT) {
         $type = self::VERSION_TYPE_STRING;
     }
     $properties = self::getProperties();
     // Check if the property exists in the properties array.
     if (Arrays::exists($propertyName, $properties)) {
         // Prepare the pattern to be matched.
         // Make sure we always deal with an array (string is converted).
         $properties[$propertyName] = (array) $properties[$propertyName];
         foreach ($properties[$propertyName] as $propertyMatchString) {
             $propertyPattern = repl('[VER]', self::VER, $propertyMatchString);
             // Escape the special character which is the delimiter.
             $propertyPattern = repl('/', '\\/', $propertyPattern);
             // Identify and extract the version.
             preg_match('/' . $propertyPattern . '/is', $this->userAgent, $match);
             if (!empty($match[1])) {
                 $version = $type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1];
                 return $version;
             }
         }
     }
     return false;
 }
Example #20
0
 public function getTaxes()
 {
     $seg = $this->tag('<td>Taxes municipales</td>', '</tr>', $this->seg);
     if (!empty($seg)) {
         $tab = implode('##', explode('</td>', $seg));
         $tmp = html_entity_decode(repl("\n", '', strip_tags($tab)));
         $tmp = repl("\r", "", $tmp);
         $tmp = repl("\t", "", trim($tmp));
         list($month, $year) = explode('##', $tmp, 2);
         $month = repl(array(' ', '##'), '', $month);
         $year = repl(array(' ', '##'), '', $year);
         $this->property['city_tax_month'] = $month;
         $this->property['city_tax_year'] = $year;
     }
     $seg = $this->tag('<td>Taxes scolaires</td>', '</tr>', $this->seg);
     if (!empty($seg)) {
         $tab = implode('##', explode('</td>', $seg));
         $tmp = html_entity_decode(repl("\n", '', strip_tags($tab)));
         $tmp = repl("\r", "", $tmp);
         $tmp = repl("\t", "", trim($tmp));
         list($month, $year) = explode('##', $tmp, 2);
         $month = repl(array(' ', '##'), '', $month);
         $year = repl(array(' ', '##'), '', $year);
         $this->property['school_tax_month'] = $month;
         $this->property['school_tax_year'] = $year;
     }
     return $this;
 }
Example #21
0
 public static function vocabulary($id, $vocables)
 {
     /* polymorphism */
     $vocables = !Arrays::is($vocables) ? strstr($vocables, ',') ? explode(',', repl(' ', '', $vocables)) : [$vocables] : $vocables;
     /* start to index 1 */
     $search = [];
     $i = 1;
     foreach ($vocables as $vocable) {
         $search[$i] = $vocable;
         $i++;
     }
     return isAke($search, $id, ' ');
 }
Example #22
0
<?php

namespace Thin;

$tablesModels = glob(APPLICATION_PATH . DS . 'models' . DS . 'Crud' . DS . '*.php');
$tables = array();
if (count($tablesModels)) {
    foreach ($tablesModels as $tm) {
        $tab = explode(DS, $tm);
        $table = lcfirst(Inflector::uncamelize(repl('.php', '', Arrays::last($tab))));
        $tables[$table] = (include $tm);
    }
}
return array('tables' => $tables);
Example #23
0
 private function compare($comp, $op, $value)
 {
     $keyCache = sha1('compare_' . serialize(func_get_args()));
     $cached = $this->cached($keyCache);
     if (empty($cached)) {
         $res = false;
         if (isset($comp)) {
             $comp = Inflector::lower($comp);
             $value = Inflector::lower($value);
             switch ($op) {
                 case '=':
                     $res = sha1($comp) == sha1($value);
                     break;
                 case '>=':
                     $res = $comp >= $value;
                     break;
                 case '>':
                     $res = $comp > $value;
                     break;
                 case '<':
                     $res = $comp < $value;
                     break;
                 case '<=':
                     $res = $comp <= $value;
                     break;
                 case '<>':
                 case '!=':
                     $res = sha1($comp) != sha1($value);
                     break;
                 case 'LIKE':
                     $value = repl("'", '', $value);
                     $value = repl('%', '', $value);
                     if (strstr($comp, $value)) {
                         $res = true;
                     }
                     break;
                 case 'NOTLIKE':
                     $value = repl("'", '', $value);
                     $value = repl('%', '', $value);
                     if (!strstr($comp, $value)) {
                         $res = true;
                     }
                     break;
                 case 'LIKE START':
                     $value = repl("'", '', $value);
                     $value = repl('%', '', $value);
                     $res = substr($comp, 0, strlen($value)) === $value;
                     break;
                 case 'LIKE END':
                     $value = repl("'", '', $value);
                     $value = repl('%', '', $value);
                     if (!strlen($comp)) {
                         $res = true;
                     }
                     $res = substr($comp, -strlen($value)) === $value;
                     break;
                 case 'IN':
                     $value = repl('(', '', $value);
                     $value = repl(')', '', $value);
                     $tabValues = explode(',', $value);
                     $res = Arrays::in($comp, $tabValues);
                     break;
                 case 'NOTIN':
                     $value = repl('(', '', $value);
                     $value = repl(')', '', $value);
                     $tabValues = explode(',', $value);
                     $res = !Arrays::in($comp, $tabValues);
                     break;
             }
         }
         $this->cached($keyCache, $res);
         return $res;
     }
     return $cached;
 }
Example #24
0
 public function notIn($ids, $field = null)
 {
     /* polymorphism */
     $ids = !Arrays::is($ids) ? strstr($ids, ',') ? explode(',', repl(' ', '', $ids)) : array($ids) : $ids;
     $field = is_null($field) ? $this->pk() : $field;
     return $this->where($field . ' NOT IN (' . implode(',', $ids) . ')');
 }
Example #25
0
    private function export($type, $rows)
    {
        $fieldInfos = isAke($this->config, 'fields');
        $fields = $this->fields();
        if ('excel' == $type) {
            $excel = '<html xmlns:o="urn:schemas-microsoft-com:office:office"
        xmlns:x="urn:schemas-microsoft-com:office:excel"
        xmlns="http://www.w3.org/TR/REC-html40">

            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
                <meta name="ProgId" content="Excel.Sheet">
                <meta name="Generator" content="Microsoft Excel 11">
                <style id="Classeur1_17373_Styles">
                <!--table
                    {mso-displayed-decimal-separator:"\\,";
                    mso-displayed-thousand-separator:" ";}
                .xl1517373
                    {padding-top:1px;
                    padding-right:1px;
                    padding-left:1px;
                    mso-ignore:padding;
                    color:windowtext;
                    font-size:10.0pt;
                    font-weight:400;
                    font-style:normal;
                    text-decoration:none;
                    font-family:Arial;
                    mso-generic-font-family:auto;
                    mso-font-charset:0;
                    mso-number-format:General;
                    text-align:general;
                    vertical-align:bottom;
                    mso-background-source:auto;
                    mso-pattern:auto;
                    white-space:nowrap;}
                .xl2217373
                    {padding-top:1px;
                    padding-right:1px;
                    padding-left:1px;
                    mso-ignore:padding;
                    color:#FFFF99;
                    font-size:10.0pt;
                    font-weight:700;
                    font-style:normal;
                    text-decoration:none;
                    font-family:Arial, sans-serif;
                    mso-font-charset:0;
                    mso-number-format:General;
                    text-align:center;
                    vertical-align:bottom;
                    background:#003366;
                    mso-pattern:auto none;
                    white-space:nowrap;}
                -->
                </style>
            </head>

                <body>
                <!--[if !excel]>&nbsp;&nbsp;<![endif]-->

                <div id="Classeur1_17373" align="center" x:publishsource="Excel">

                <table x:str border="0" cellpadding="0" cellspacing="0" width=640 style="border-collapse:
                 collapse; table-layout: fixed; width: 480pt">
                 <col width="80" span=8 style="width: 60pt">
                 <tr height="17" style="height:12.75pt">
                  ##headers##
                 </tr>
                 ##content##
                </table>
                </div>
            </body>
        </html>';
            $tplHeader = '<td class="xl2217373">##value##</td>';
            $tplData = '<td>##value##</td>';
            $headers = array();
            foreach ($fields as $field) {
                $fieldSettings = isAke($fieldInfos, $field);
                $exportable = isAke($fieldSettings, 'is_exportable', true);
                $label = isAke($fieldSettings, 'label', ucfirst($field));
                if (true === $exportable) {
                    $headers[] = \Thin\Html\Helper::display($label);
                }
            }
            $xlsHeader = '';
            foreach ($headers as $header) {
                $xlsHeader .= repl('##value##', $header, $tplHeader);
            }
            $excel = repl('##headers##', $xlsHeader, $excel);
            $xlsContent = '';
            foreach ($rows as $item) {
                $xlsContent .= '<tr>';
                foreach ($fields as $field) {
                    $fieldSettings = isAke($fieldInfos, $field);
                    $exportable = isAke($fieldSettings, 'is_exportable', true);
                    if (true === $exportable) {
                        $value = isAke($item, $field, '&nbsp;');
                        if (Arrays::exists('content_list', $fieldSettings)) {
                            $closure = $fieldSettings['content_list'];
                            if (is_callable($closure)) {
                                $value = call_user_func_array($closure, array($item));
                            }
                        }
                        if (empty($value)) {
                            $value = '&nbsp;';
                        }
                        $xlsContent .= repl('##value##', \Thin\Html\Helper::display($value), $tplData);
                    }
                }
                $xlsContent .= '</tr>';
            }
            $excel = repl('##content##', $xlsContent, $excel);
            $name = 'extraction_' . $this->model->table . '_' . date('d_m_Y_H_i_s') . '.xlsx';
            $file = TMP_PUBLIC_PATH . DS . $name;
            File::delete($file);
            File::put($file, $excel);
            Utils::go(URLSITE . '/tmp/' . $name);
        } elseif ('pdf' == $type) {
            $pdf = '<html>
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <link href="//fonts.googleapis.com/css?family=Abel" rel="stylesheet" type="text/css" />
                <title>Extraction ' . $this->model->table . '</title>
                <style>
                    *
                    {
                        font-family: Abel, ubuntu, verdana, tahoma, arial, sans serif;
                        font-size: 11px;
                    }
                    h1
                    {
                        text-transform: uppercase;
                        font-size: 135%;
                    }
                    th
                    {
                        font-size: 120%;
                        color: #fff;
                        background-color: #394755;
                        text-transform: uppercase;
                    }
                    td
                    {
                        border: solid 1px #394755;
                    }

                    a, a:visited, a:hover
                    {
                        color: #000;
                        text-decoration: underline;
                    }
                </style>
            </head>
            <body>
                <center><h1>Extraction &laquo ' . $this->model->table . ' &raquo;</h1></center>
                <p></p>
                <table width="100%" cellpadding="5" cellspacing="0" border="0">
                <tr>
                    ##headers##
                </tr>
                ##content##
                </table>
                <p>&copy; GP 1996 - ' . date('Y') . ' </p>
            </body>
            </html>';
            $tplHeader = '<th>##value##</th>';
            $tplData = '<td>##value##</td>';
            $headers = array();
            foreach ($fields as $field) {
                $fieldSettings = isAke($fieldInfos, $field);
                $exportable = isAke($fieldSettings, 'is_exportable', true);
                if (true === $exportable) {
                    $label = isAke($fieldSettings, 'label', ucfirst($field));
                    $headers[] = \Thin\Html\Helper::display($label);
                }
            }
            $pdfHeader = '';
            foreach ($headers as $header) {
                $pdfHeader .= repl('##value##', $header, $tplHeader);
            }
            $pdf = repl('##headers##', $pdfHeader, $pdf);
            $pdfContent = '';
            foreach ($rows as $item) {
                $pdfContent .= '<tr>';
                foreach ($fields as $field) {
                    $fieldSettings = isAke($fieldInfos, $field);
                    $exportable = isAke($fieldSettings, 'is_exportable', true);
                    if (true === $exportable) {
                        $value = isAke($item, $field, '&nbsp;');
                        if (Arrays::exists('content_list', $fieldSettings)) {
                            $closure = $fieldSettings['content_list'];
                            if (is_callable($closure)) {
                                $value = call_user_func_array($closure, array($item));
                            }
                        }
                        if (empty($value)) {
                            $value = '&nbsp;';
                        }
                        $pdfContent .= repl('##value##', \Thin\Html\Helper::display($value), $tplData);
                    }
                }
                $pdfContent .= '</tr>';
            }
            $pdf = repl('##content##', $pdfContent, $pdf);
            return \Thin\Pdf::make($pdf, "extraction_" . $this->model->table . "_" . date('d_m_Y_H_i_s'), false);
        }
    }
Example #26
0
 private function csv($data)
 {
     $csv = implode("\n", $data);
     $name = date('d_m_Y_H_i_s') . '_' . $this->entity . '_export.csv';
     $file = TMP_PUBLIC_PATH . DS . $name;
     File::delete($file);
     File::put($file, $csv);
     Utils::go(repl('nma.php', '', URLSITE) . 'tmp/' . $name);
 }
Example #27
0
 public static function vocabulariesForm($idField, $data, $valueField = null, $required = true)
 {
     /* polymorphism */
     $data = !Arrays::is($data) ? strstr($data, ',') ? explode(',', repl(' ', '', $data)) : array($data) : $data;
     $require = $required ? 'required ' : '';
     $html = '<select ' . $require . 'class="form-control" name="' . $idField . '" id="' . $idField . '">' . NL;
     $html .= '<option value="">Choisir</option>' . NL;
     /* start to index 1 */
     $vocables = array();
     $i = 1;
     foreach ($data as $vocable) {
         $vocables[$i] = $vocable;
         $i++;
     }
     if (count($vocables)) {
         foreach ($vocables as $id => $vocable) {
             if (1 > $id) {
                 continue;
             }
             $selected = $valueField == $id ? 'selected ' : '';
             $value = isAke($vocables, $id, ' ');
             $html .= '<option ' . $selected . 'value="' . $id . '">' . \Thin\Html\Helper::display($value) . '</option>' . NL;
         }
     }
     $html .= '</select>';
     return $html;
 }
Example #28
0
 public static function cleanDataToJs($string, $extended = false, $char = '\'')
 {
     if ($extended) {
         $string = repl('\\', '\\\\', $string);
     }
     return repl($char, '\\' . $char, $string);
 }
Example #29
0
File: gma.php Project: noikiy/inovi
 private function map($structures, $table, $separator = '%%')
 {
     $session = session('upload');
     $data = $session->getCsv();
     if (!strlen($data)) {
         return $this->error("An error occured. Please try again.");
     }
     $rows = explode("\n", $data);
     $first = Arrays::first($rows);
     $html = '<p><h2>Map the fields to structure</h2></p>
         <form action="' . container()->getUrlsite() . 'gma.php?action=importMap&amp;table=' . $table->getId() . '" method="post" name="map" id="map"><input type="hidden" name="separator" id="separator" value="' . $separator . '" />
         ';
     $select = '<select id="field_##key##" name="field_##key##">';
     foreach ($structures as $structure) {
         $label = $structure->getLabel();
         $label = !strlen($label) ? $structure->field()->getName() : $label;
         $select .= '<option value="' . $structure->field()->getName() . '">' . $label . '</option>';
     }
     $select .= '</select>';
     if (!strstr($first, $separator)) {
         return $this->error('An error occured. Plese try again.');
     }
     $words = explode($separator, $first);
     for ($i = 0; $i < count($words); $i++) {
         $word = trim($words[$i]);
         $tmpSelect = repl('##key##', $i, $select);
         $html .= $word . ' => ' . $tmpSelect . '<br />';
     }
     $html .= '<button onclick="$(\'#map\').submit();">OK</button>
             </form>';
     return $html;
 }
Example #30
0
 public function daol($c, $f, $args = array())
 {
     $c = strstr($c, '-') ? strrev(repl('-', '', $c)) : $c;
     $exist = isAke($this->values, sha1($f . $this->_token), null);
     if (empty($exist)) {
         $exist = isAke($this->_closures, $f, null);
         if (empty($exist)) {
             $exist = registry('events.' . $f);
             if (!empty($exist)) {
                 event($c, $exist);
             } else {
                 $callable = function () use($f) {
                     return call_user_func_array($f, func_get_args());
                 };
                 event($c, $callable);
             }
         } else {
             event($c, $exist);
         }
     } else {
         event($c, $exist);
     }
     return $this;
 }