protected static function checkFileContent()
 {
     $fileContent = file_get_contents(static::$tmpFilepath);
     // check encoding and convert to utf-8 when necessary
     $detectedEncoding = mb_detect_encoding($fileContent, 'UTF-8, ISO-8859-1, WINDOWS-1252', true);
     if ($detectedEncoding) {
         if ($detectedEncoding !== 'UTF-8') {
             $fileContent = iconv($detectedEncoding, 'UTF-8', $fileContent);
         }
     } else {
         echo 'Zeichensatz der CSV-Date stimmt nicht. Der sollte UTF-8 oder ISO-8856-1 sein.';
         return false;
     }
     //prepare data array
     $tmpData = str_getcsv($fileContent, PHP_EOL);
     array_shift($tmpData);
     $preparedData = [];
     $data = array_map(function ($row) use(&$preparedData) {
         $tmpDataArray = str_getcsv($row, ';');
         $tmpKey = trim($tmpDataArray[0]);
         array_shift($tmpDataArray);
         $preparedData[$tmpKey] = $tmpDataArray;
     }, $tmpData);
     // generate json
     $jsonContent = json_encode($preparedData, JSON_HEX_TAG | JSON_HEX_AMP);
     self::$jsonContent = $jsonContent;
     return true;
 }
Example #2
1
 /**
  * Create array of Sources from the given input directory.
  *
  * @param string $searchIn
  * @param string $outputTo
  * @return array
  */
 protected function findSources($searchIn, $outputTo)
 {
     $files = iterator_to_array(new FilesystemIterator($searchIn));
     return array_map(function (SplFileInfo $file) use($outputTo) {
         return $this->makeSource($file, $outputTo);
     }, $files);
 }
Example #3
1
/**
 * nv_getAllowed()
 *
 * @return
 */
function nv_getAllowed()
{
    global $module_data, $db, $admin_info;
    $sql = 'SELECT id,full_name,admins FROM ' . NV_PREFIXLANG . '_' . $module_data . '_department';
    $result = $db->query($sql);
    $contact_allowed = array('view' => array(), 'reply' => array(), 'obt' => array());
    while ($row = $result->fetch()) {
        $id = intval($row['id']);
        if (defined('NV_IS_SPADMIN')) {
            $contact_allowed['view'][$id] = $row['full_name'];
            $contact_allowed['reply'][$id] = $row['full_name'];
        }
        $admins = $row['admins'];
        $admins = array_map('trim', explode(';', $admins));
        foreach ($admins as $a) {
            if (preg_match('/^([0-9]+)\\/([0-1]{1})\\/([0-1]{1})\\/([0-1]{1})$/i', $a)) {
                $admins2 = array_map('intval', explode('/', $a));
                if ($admins2[0] == $admin_info['admin_id']) {
                    if ($admins2[1] == 1 and !isset($contact_allowed['view'][$id])) {
                        $contact_allowed['view'][$id] = $row['full_name'];
                    }
                    if ($admins2[2] == 1 and !isset($contact_allowed['reply'][$id])) {
                        $contact_allowed['reply'][$id] = $row['full_name'];
                    }
                    if ($admins2[3] == 1 and !isset($contact_allowed['obt'][$id])) {
                        $contact_allowed['obt'][$id] = $row['full_name'];
                    }
                }
            }
        }
    }
    return $contact_allowed;
}
Example #4
1
 /**
  * Sets selected items (by keys).
  * @param  array
  * @return self
  */
 public function setValue($values)
 {
     if (is_scalar($values) || $values === NULL) {
         $values = (array) $values;
     } elseif (!is_array($values)) {
         throw new Nette\InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name));
     }
     $flip = [];
     foreach ($values as $value) {
         if (!is_scalar($value) && !method_exists($value, '__toString')) {
             throw new Nette\InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name));
         }
         $flip[(string) $value] = TRUE;
     }
     $values = array_keys($flip);
     if ($this->checkAllowedValues && ($diff = array_diff($values, array_keys($this->items)))) {
         $set = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) {
             return var_export($s, TRUE);
         }, array_keys($this->items))), 70, '...');
         $vals = (count($diff) > 1 ? 's' : '') . " '" . implode("', '", $diff) . "'";
         throw new Nette\InvalidArgumentException("Value{$vals} are out of allowed set [{$set}] in field '{$this->name}'.");
     }
     $this->value = $values;
     return $this;
 }
 protected function _buildTags($tagString)
 {
     $new = array_unique(array_map('trim', explode(',', $tagString)));
     $out = [];
     $query = $this->_table->Tags->find()->contain('TaggedTags')->where(['Tags.tag IN' => $new]);
     $query->matching('TaggedTags', function ($q) {
         return $q->where(['TaggedTags.model' => $this->name()]);
     });
     /*
             foreach ($query as $tag){
                 debug($tag);die;
             }*/
     // Remove existing tags from the list of new tags.
     foreach ($query->extract('tag') as $existing) {
         $index = array_search($existing, $new);
         if ($index !== false) {
             unset($new[$index]);
         }
     }
     // Add existing tags.
     foreach ($query as $tag) {
         $tag['count'] = $tag['count'] + 1;
         $out[] = $tag;
     }
     // Add new tags.
     foreach ($new as $tag) {
         $out[] = $this->_table->Tags->newEntity(['tag' => $tag, 'count' => 1]);
         //$out->_joinData = [];
         //debug ($out);
     }
     return $out;
 }
Example #6
1
    /**
     * Display navigation to next/previous set of posts when applicable.
     *
     * @since Farmtoyou 1.0
     *
     * @global WP_Query   $wp_query   WordPress Query object.
     * @global WP_Rewrite $wp_rewrite WordPress Rewrite object.
     */
    function farmtoyou_paging_nav()
    {
        global $wp_query, $wp_rewrite;
        // Don't print empty markup if there's only one page.
        if ($wp_query->max_num_pages < 2) {
            return;
        }
        $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
        $pagenum_link = html_entity_decode(get_pagenum_link());
        $query_args = array();
        $url_parts = explode('?', $pagenum_link);
        if (isset($url_parts[1])) {
            wp_parse_str($url_parts[1], $query_args);
        }
        $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
        $pagenum_link = trailingslashit($pagenum_link) . '%_%';
        $format = $wp_rewrite->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
        $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit($wp_rewrite->pagination_base . '/%#%', 'paged') : '?paged=%#%';
        // Set up paginated links.
        $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $wp_query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('&larr; Previous', 'farmtoyou'), 'next_text' => __('Next &rarr;', 'farmtoyou')));
        if ($links) {
            ?>
	<nav class="navigation paging-navigation" role="navigation">
		<div class="pagination loop-pagination">
			<?php 
            echo $links;
            ?>
		</div><!-- .pagination -->
	</nav><!-- .navigation -->
	<?php 
        }
    }
Example #7
1
 public function afterExample(ExampleEvent $event)
 {
     $total = $this->stats->getEventsCount();
     $counts = $this->stats->getCountsHash();
     $percents = array_map(function ($count) use($total) {
         return round($count / ($total / 100), 0);
     }, $counts);
     $lengths = array_map(function ($percent) {
         return round($percent / 2, 0);
     }, $percents);
     $size = 50;
     asort($lengths);
     $progress = array();
     foreach ($lengths as $status => $length) {
         $text = $percents[$status] . '%';
         $length = $size - $length >= 0 ? $length : $size;
         $size = $size - $length;
         if ($length > strlen($text) + 2) {
             $text = str_pad($text, $length, ' ', STR_PAD_BOTH);
         } else {
             $text = str_pad('', $length, ' ');
         }
         $progress[$status] = sprintf("<{$status}-bg>%s</{$status}-bg>", $text);
     }
     krsort($progress);
     $this->printException($event, 2);
     $this->io->writeTemp(implode('', $progress) . ' ' . $total);
 }
Example #8
1
 /**
  * Append any supported $content to $parent
  *
  * @param  DOMNode $parent  Node to append to
  * @param  mixed   $content Content to append
  * @return self
  */
 protected function XMLAppend(\DOMNode &$parent = null, $content = null)
 {
     if (is_null($parent)) {
         $parent = $this->root;
     }
     if (is_string($content) or is_numeric($content) or is_object($content) and method_exists($content, '__toString')) {
         $parent->appendChild($this->createTextNode("{$content}"));
     } elseif (is_object($content) and is_subclass_of($content, '\\DOMNode')) {
         $parent->appendChild($content);
     } elseif (is_array($content) or is_object($content) and $content = get_object_vars($content)) {
         array_map(function ($node, $value) use(&$parent) {
             if (is_string($node)) {
                 if (substr($node, 0, 1) === '@') {
                     $parent->setAttribute(substr($node, 1), $value);
                 } else {
                     $node = $parent->appendChild($this->createElement($node));
                     if (is_string($value)) {
                         $this->XMLAppend($node, $this->createTextNode($value));
                     } else {
                         $this->XMLAppend($node, $value);
                     }
                 }
             } else {
                 $this->XMLAppend($parent, $value);
             }
         }, array_keys($content), array_values($content));
     } elseif (is_bool($content)) {
         $parent->appendChild($this->createTextNode($content ? 'true' : 'false'));
     } else {
         throw new \InvalidArgumentException(sprintf('Unable to append unknown content [%s] to %s', get_class($content), get_class($this)));
     }
     return $this;
 }
Example #9
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     require_once dirname(__FILE__) . '/sfLimeHarness.class.php';
     $h = new sfLimeHarness(array('force_colors' => isset($options['color']) && $options['color'], 'verbose' => isset($options['trace']) && $options['trace']));
     $h->addPlugins(array_map(array($this->configuration, 'getPluginConfiguration'), $this->configuration->getPlugins()));
     $h->base_dir = sfConfig::get('sf_test_dir');
     $status = false;
     $statusFile = sfConfig::get('sf_cache_dir') . '/.test_all_status';
     if ($options['only-failed']) {
         if (file_exists($statusFile)) {
             $status = unserialize(file_get_contents($statusFile));
         }
     }
     if ($status) {
         foreach ($status as $file) {
             $h->register($file);
         }
     } else {
         // filter and register all tests
         $finder = sfFinder::type('file')->follow_link()->name('*Test.php');
         $h->register($this->filterTestFiles($finder->in($h->base_dir), $arguments, $options));
     }
     $ret = $h->run() ? 0 : 1;
     file_put_contents($statusFile, serialize($h->get_failed_files()));
     if ($options['xml']) {
         file_put_contents($options['xml'], $h->to_xml());
     }
     return $ret;
 }
 /**
  * Handle pre save event
  *
  * @param LifecycleEventArgs $args Event arguments
  */
 protected function preSave(LifecycleEventArgs $args)
 {
     $annotations = $this->container->get('cyber_app.metadata.reader')->getUploadebleFieldsAnnotations($args->getEntity());
     if (0 === count($annotations)) {
         return;
     }
     foreach ($annotations as $field => $annotation) {
         $config = $this->container->getParameter('oneup_uploader.config.' . $annotation->endpoint);
         if (!(isset($config['use_orphanage']) && $config['use_orphanage'])) {
             continue;
         }
         $value = (array) PropertyAccess::createPropertyAccessor()->getValue($args->getEntity(), $field);
         $value = array_filter($value, 'strlen');
         $value = array_map(function ($file) {
             return pathinfo($file, PATHINFO_BASENAME);
         }, $value);
         if (empty($value)) {
             continue;
         }
         $orphanageStorage = $this->container->get('oneup_uploader.orphanage.' . $annotation->endpoint);
         $files = [];
         foreach ($orphanageStorage->getFiles() as $file) {
             if (in_array($file->getBasename(), $value, true)) {
                 $files[] = $file;
             }
         }
         $orphanageStorage->uploadFiles($files);
     }
 }
 /**
  * Parse string with indexers and return array of indexer instances
  *
  * @param string $string
  * @return array
  */
 protected function _parseIndexerString($string)
 {
     $processes = array();
     if ($string == 'all') {
         $collection = $this->_getIndexer()->getProcessesCollection();
         foreach ($collection as $process) {
             if ($process->getIndexer()->isVisible() === false) {
                 continue;
             }
             $processes[] = $process;
         }
     } else {
         if (!empty($string)) {
             $codes = explode(',', $string);
             $codes = array_map('trim', $codes);
             $processes = $this->_getIndexer()->getProcessesCollectionByCodes($codes);
             foreach ($processes as $key => $process) {
                 if ($process->getIndexer()->getVisibility() === false) {
                     unset($processes[$key]);
                 }
             }
             if ($this->_getIndexer()->hasErrors()) {
                 echo implode(PHP_EOL, $this->_getIndexer()->getErrors()), PHP_EOL;
             }
         }
     }
     return $processes;
 }
 function paginate($term = null, $paginateOptions = array())
 {
     $this->_controller->paginate = array('SearchIndex' => array_merge_recursive(array('conditions' => array(array('SearchIndex.active' => 1), 'or' => array(array('SearchIndex.published' => null), array('SearchIndex.published <= ' => date('Y-m-d H:i:s'))))), $paginateOptions));
     if (isset($this->_controller->request->params['named']['type']) && $this->_controller->request->params['named']['type'] != 'All') {
         $this->_controller->request->data['SearchIndex']['type'] = Sanitize::escape($this->_controller->request->params['named']['type']);
         $this->_controller->paginate['SearchIndex']['conditions']['model'] = $this->_controller->data['SearchIndex']['type'];
     }
     // Add term condition, and sorting
     if (!$term && isset($this->_controller->request->params['named']['term'])) {
         $term = $this->_controller->request->params['named']['term'];
     }
     if ($term) {
         $term = Sanitize::escape($term);
         $this->_controller->request->data['SearchIndex']['term'] = $term;
         $term = implode(' ', array_map(array($this, 'replace'), preg_split('/[\\s_]/', $term))) . '*';
         if ($this->like) {
             $this->_controller->paginate['SearchIndex']['conditions'][] = array('or' => array("MATCH(data) AGAINST('{$term}')", 'SearchIndex.data LIKE' => "%{$this->_controller->data['SearchIndex']['term']}%"));
         } else {
             $this->_controller->paginate['SearchIndex']['conditions'][] = "MATCH(data) AGAINST('{$term}' IN BOOLEAN MODE)";
         }
         $this->_controller->paginate['SearchIndex']['fields'] = "*, MATCH(data) AGAINST('{$term}' IN BOOLEAN MODE) AS score";
         if (empty($this->_controller->paginate['SearchIndex']['order'])) {
             $this->_controller->paginate['SearchIndex']['order'] = "score DESC";
         }
     }
     return $this->_controller->paginate('SearchIndex');
 }
Example #13
0
 /**
  * [untappd-menu] shortcode.
  *
  */
 static function menu_shortcode($atts, $content = '')
 {
     // Let's bail if we don't have location or theme.
     if (!isset($atts['location']) || !isset($atts['theme'])) {
         if (current_user_can('edit_posts')) {
             return __('No location or theme ID provided in the untappd-menu shortcode.', 'jetpack');
         }
         return;
     }
     // Let's apply some defaults.
     $atts = shortcode_atts(array('location' => '', 'theme' => ''), $atts, 'untappd-menu');
     // We're going to clean the user input.
     $atts = array_map('absint', $atts);
     if ($atts['location'] < 1 || $atts['theme'] < 1) {
         return;
     }
     static $untappd_menu = 1;
     $html = '<div id="menu-container-untappd-' . $untappd_menu . '" class="untappd-menu"></div>';
     $html .= '<script type="text/javascript">' . PHP_EOL;
     $html .= '!function(e,n){var t=document.createElement("script"),a=document.getElementsByTagName("script")[0];' . PHP_EOL;
     $html .= 't.async=1,a.parentNode.insertBefore(t,a),t.onload=t.onreadystatechange=function(e,a){' . PHP_EOL;
     $html .= '(a||!t.readyState||/loaded|complete/.test(t.readyState))&&(t.onload=t.onreadystatechange=null,t=void 0,a||n&&n())},' . PHP_EOL;
     $html .= 't.src=e}("https://embed-menu-preloader.untappdapi.com/embed-menu-preloader.min.js",function(){' . PHP_EOL;
     $html .= 'PreloadEmbedMenu( "menu-container-untappd-' . $untappd_menu . '",' . $atts["location"] . ',' . $atts["theme"] . ' )});' . PHP_EOL;
     $html .= '</script>';
     $untappd_menu++;
     return $html;
 }
Example #14
0
 public static function buildRoute($route)
 {
     $result = static::snakeCase(array_shift($route));
     return $result . join("", array_map(function ($e) {
         return "['" . Helpers::snakeCase($e) . "']";
     }, $route));
 }
Example #15
0
 /**
  * Generate ASN.1 structure.
  *
  * @return Sequence
  */
 public function toASN1()
 {
     $elements = array_values(array_map(function ($ext) {
         return $ext->toASN1();
     }, $this->_extensions));
     return new Sequence(...$elements);
 }
Example #16
0
 public function partition(...$partitions)
 {
     $this->partitions = array_merge($this->partitions, array_map(function ($partition) {
         return is_string($partition) ? new SqlLiteral($partition) : $partition;
     }, $partitions));
     return $this;
 }
 public function login()
 {
     function callback($v)
     {
         if (empty($v)) {
             return $v = '';
         } else {
             return $v;
         }
     }
     $userinfo = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find();
     $data = array('store_id' => intval($_GET['store_id']), 'wecha_id' => $this->wecha_id, 'token' => $this->token, 'wechaname' => $userinfo['wechaname'], 'portrait' => $userinfo['portrait'], 'tel' => $userinfo['tel'], 'address' => $userinfo['address'], 'return_url' => '');
     $sort_data = $data;
     $sort_data['salt'] = $this->SALT;
     ksort($sort_data);
     $sort_data = array_map('callback', $sort_data);
     $sign_key = sha1(http_build_query($sort_data));
     $data['sign_key'] = $sign_key;
     $data['request_time'] = time();
     $url = $this->Micrstore_URL . '/api/fans.php';
     $return = json_decode($this->curl_post($url, $data), true);
     $return_data = $sort_data;
     unset($return_data['salt']);
     unset($return_data['return_url']);
     $return_data['sessid'] = $return['sessid'];
     $return_url = $this->_get('return_url') . '&' . http_build_query(array('token' => $data['token'], 'wecha_id' => $data['wecha_id'], 'sessid' => $return['sessid']));
     header('Location: ' . $return_url);
 }
Example #18
0
 /**
  * Create a new SetCookie object from a string
  *
  * @param string $cookie Set-Cookie header string
  *
  * @return self
  */
 public static function fromString($cookie)
 {
     // Create the default return array
     $data = self::$defaults;
     // Explode the cookie string using a series of semicolons
     $pieces = array_filter(array_map('trim', explode(';', $cookie)));
     // The name of the cookie (first kvp) must include an equal sign.
     if (empty($pieces) || !strpos($pieces[0], '=')) {
         return new self($data);
     }
     // Add the cookie pieces into the parsed data array
     foreach ($pieces as $part) {
         $cookieParts = explode('=', $part, 2);
         $key = trim($cookieParts[0]);
         $value = isset($cookieParts[1]) ? trim($cookieParts[1], " \n\r\t\v\"") : true;
         // Only check for non-cookies when cookies have been found
         if (empty($data['Name'])) {
             $data['Name'] = $key;
             $data['Value'] = $value;
         } else {
             foreach (array_keys(self::$defaults) as $search) {
                 if (!strcasecmp($search, $key)) {
                     $data[$search] = $value;
                     continue 2;
                 }
             }
             $data[$key] = $value;
         }
     }
     return new self($data);
 }
Example #19
0
 /**
  * Connect to server
  */
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->server = $sqlserver;
     $this->dbname = $database;
     $port = !$port ? NULL : $port;
     // Persistant connections not supported by the mysqli extension?
     $this->db_connect_id = @mysqli_connect($this->server, $this->user, $sqlpassword, $this->dbname, $port);
     if ($this->db_connect_id && $this->dbname != '') {
         @mysqli_query($this->db_connect_id, "SET NAMES 'utf8'");
         // enforce strict mode on databases that support it
         if (version_compare($this->sql_server_info(true), '5.0.2', '>=')) {
             $result = @mysqli_query($this->db_connect_id, 'SELECT @@session.sql_mode AS sql_mode');
             $row = @mysqli_fetch_assoc($result);
             @mysqli_free_result($result);
             $modes = array_map('trim', explode(',', $row['sql_mode']));
             // TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES
             if (!in_array('TRADITIONAL', $modes)) {
                 if (!in_array('STRICT_ALL_TABLES', $modes)) {
                     $modes[] = 'STRICT_ALL_TABLES';
                 }
                 if (!in_array('STRICT_TRANS_TABLES', $modes)) {
                     $modes[] = 'STRICT_TRANS_TABLES';
                 }
             }
             $mode = implode(',', $modes);
             @mysqli_query($this->db_connect_id, "SET SESSION sql_mode='{$mode}'");
         }
         return $this->db_connect_id;
     }
     return $this->sql_error('');
 }
Example #20
0
 private static function GetNumbersFromList($Admins)
 {
     $Function = function ($Admin) {
         return $Admin[0];
     };
     return array_map($Function, $Admins);
 }
Example #21
0
 /**
  * Dump & Die
  *
  * @codeCoverageIgnore
  */
 function dd()
 {
     array_map(function ($x) {
         var_dump($x);
     }, func_get_args());
     die;
 }
Example #22
0
 private function _set($style)
 {
     $escape = "[" . implode(';', array_map(function ($style, $name) {
         return $this->_style($style, $name);
     }, array_keys($style), $style)) . 'm';
     return $escape === "" ? null : $escape;
 }
Example #23
0
function register($tag, $func)
{
    $tags =& \ui\global_var('shortcode_tags', array());
    $tags[] = $tag;
    \ui\global_var('shortcode_tags_regx', join('|', array_map('preg_quote', $tags)), 1);
    \ui\register_hook('shortcode_tag_' . $tag, $func);
}
 /**
  * Parses the arguments for ":nth-child()" and friends.
  *
  * @param Token[] $tokens
  *
  * @throws SyntaxErrorException
  *
  * @return array
  */
 public static function parseSeries(array $tokens)
 {
     foreach ($tokens as $token) {
         if ($token->isString()) {
             throw SyntaxErrorException::stringAsFunctionArgument();
         }
     }
     $joined = trim(implode('', array_map(function (Token $token) {
         return $token->getValue();
     }, $tokens)));
     $int = function ($string) {
         if (!is_numeric($string)) {
             throw SyntaxErrorException::stringAsFunctionArgument();
         }
         return (int) $string;
     };
     switch (true) {
         case 'odd' === $joined:
             return array(2, 1);
         case 'even' === $joined:
             return array(2, 0);
         case 'n' === $joined:
             return array(1, 0);
         case false === strpos($joined, 'n'):
             return array(0, $int($joined));
     }
     $split = explode('n', $joined);
     $first = isset($split[0]) ? $split[0] : null;
     return array($first ? '-' === $first || '+' === $first ? $int($first . '1') : $int($first) : 1, isset($split[1]) && $split[1] ? $int($split[1]) : 0);
 }
Example #25
0
 function index()
 {
     $path = \GCore\C::get('GCORE_ADMIN_PATH') . 'extensions' . DS . 'chronoforms' . DS;
     $files = \GCore\Libs\Folder::getFiles($path, true);
     $strings = array();
     //function to prepare strings
     $prepare = function ($str) {
         /*$path = \GCore\C::get('GCORE_FRONT_PATH');
         		if(strpos($str, $path) !== false AND strpos($str, $path) == 0){
         			return '//'.str_replace($path, '', $str);
         		}*/
         $val = !empty(\GCore\Libs\Lang::$translations[$str]) ? \GCore\Libs\Lang::$translations[$str] : '';
         return 'const ' . trim($str) . ' = "' . str_replace("\n", '\\n', $val) . '";';
     };
     foreach ($files as $file) {
         if (substr($file, -4, 4) == '.php') {
             // AND strpos($file, DS.'extensions'.DS) === TRUE){
             //$strings[] = $file;
             $file_code = file_get_contents($file);
             preg_match_all('/l_\\(("|\')([^(\\))]*?)("|\')\\)/i', $file_code, $langs);
             if (!empty($langs[2])) {
                 $strings = array_merge($strings, $langs[2]);
             }
         }
     }
     $strings = array_unique($strings);
     $strings = array_map($prepare, $strings);
     echo '<textarea rows="20" cols="80">' . implode("\n", $strings) . '</textarea>';
 }
 public function audio_albums()
 {
     if ($no_auth = $this->checkAuth()) {
         return $no_auth;
     }
     $allGenre = $this->db->getAllFromTable('audio_genres');
     $allGenre = $this->getUCArray($this->setLocalization($allGenre, 'name'), 'name');
     $this->app['allAudioGenres'] = $allGenre;
     $this->app['allAudioYears'] = $this->db->getAllFromTable('audio_years');
     $locale = substr($this->app["language"], 0, 2);
     $this->app['allCountries'] = $locale != 'ru' ? array_map(function ($row) use($locale) {
         $row['name'] = $row['name_en'];
         return $row;
     }, $this->db->getAllFromTable('countries')) : $this->db->getAllFromTable('countries');
     $this->app['allLanguages'] = $this->db->getAllFromTable('audio_languages');
     $this->app['allStatus'] = $this->allStatus;
     $attribute = $this->getDropdownAttributeAudioClub();
     $this->checkDropdownAttribute($attribute);
     $this->app['dropdownAttribute'] = $attribute;
     $list = $this->audio_albums_list_json();
     $this->app['allAudioAlbums'] = $list['data'];
     $this->app['totalRecords'] = $list['recordsTotal'];
     $this->app['recordsFiltered'] = $list['recordsFiltered'];
     return $this->app['twig']->render($this->getTemplateName(__METHOD__));
 }
 /**
  * Implements EntityReferenceHandler::getReferencableEntities().
  */
 public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0)
 {
     $settings = $this->field['settings']['handler_settings'];
     $include_space = $settings['include_space'];
     $all_groups = oa_core_get_all_groups();
     $groups = array_map(create_function('$group', 'return $group->title;'), $all_groups);
     $group_options = array();
     $count = 0;
     foreach ($groups as $nid => $group_name) {
         $count++;
         if (!$match || stripos($group_name, $match) !== FALSE) {
             $group_options[$nid] = $group_name;
         }
         if ($limit && $count == $limit) {
             break;
         }
     }
     if ($space_id = oa_core_get_space_context()) {
         // Bring current group to front.
         if (!empty($group_options[$space_id])) {
             $group_options = array($space_id => t('!name (current)', array('!name' => $group_options[$space_id]))) + $group_options;
         } elseif ($include_space) {
             $group_options = array($space_id => t('- All space members -')) + $group_options;
         }
     }
     return array(OA_GROUP_TYPE => $group_options);
 }
Example #28
0
 /**
  * Normal escape or iterated for arrays
  *
  * @param mixed $value
  * @return string
  */
 public function __invoke($value)
 {
     if (is_array($value)) {
         return array_map([$this, 'escape'], $value);
     }
     return $this->escape($value);
 }
 public function run(&$parms)
 {
     //安装时不执行
     if (defined('BIND_MODULE') && BIND_MODULE === 'Install') {
         return;
     }
     $data = S('global_hooks');
     if (!$data) {
         $hooks = M('Hooks', "common_")->getField('name,addons');
         foreach ($hooks as $key => $value) {
             if ($value) {
                 $map['status'] = 1;
                 $names = explode(',', $value);
                 $map['name'] = array('IN', $names);
                 $data = M('Addons', "common_")->where($map)->getField('id,name');
                 if ($data) {
                     $addons = array_intersect($names, $data);
                     Hook::add($key, array_map('get_addon_class', $addons));
                 }
             }
         }
         S('global_hooks', Hook::get());
     } else {
         Hook::import($data, false);
     }
 }
Example #30
0
 /**
  * Extract files ($_FILES).
  *
  * @param ReactRequest $request
  *
  * @return array
  */
 private function extractFiles(ReactRequest $request)
 {
     return array_map(function (array $file) {
         return $this->uploadReactFile($file);
     }, []);
     // FIXME
 }