Esempio n. 1
0
 /**
  * accepts the object in the form of an array structure
  * @param  [winged] $scale [description]
  * @return [winged]        [description]
  */
 public static function constructFromArray($props)
 {
     $defaults = array_fill_keys(self::$properties, null);
     $props = array_merge($defaults, $props);
     extract($props);
     return new Clef($sign, $line);
 }
 /**
  * Injects default parameters before forwarding to the inner formatter.
  *
  * @param string $locale
  * @param string $message
  * @param array(string=>mixed) $parameters
  * @return string The formatted message.
  */
 public function format($locale, $message, array $parameters)
 {
     $variables = (new MessageAnalyzer($message))->getParameters();
     $defaults = array_fill_keys($variables, null);
     $parameters = $parameters + $defaults;
     return parent::format($locale, $message, $parameters);
 }
Esempio n. 3
0
 /**
  * @Request({"path"})
  */
 public function indexAction($path)
 {
     if (!($dir = $this->getPath())) {
         return $this->error(__('Invalid path.'));
     }
     if (!is_dir($dir) || '-' === ($mode = $this->getMode($dir))) {
         throw new ForbiddenException(__('Permission denied.'));
     }
     $data = array_fill_keys(['items'], []);
     $data['mode'] = $mode;
     $finder = App::finder();
     $finder->sort(function ($a, $b) {
         return $b->getRealpath() > $a->getRealpath() ? -1 : 1;
     });
     foreach ($finder->depth(0)->in($dir) as $file) {
         if ('-' === ($mode = $this->getMode($file->getPathname()))) {
             continue;
         }
         $info = ['name' => $file->getFilename(), 'mime' => 'application/' . ($file->isDir() ? 'folder' : 'file'), 'path' => $this->normalizePath($path . '/' . $file->getFilename()), 'url' => ltrim(App::url()->getStatic($file->getPathname(), [], 'base'), '/'), 'writable' => $mode == 'w'];
         if (!$file->isDir()) {
             $info = array_merge($info, ['size' => $this->formatFileSize($file->getSize()), 'lastmodified' => date(\DateTime::ISO8601, $file->getMTime())]);
         }
         $data['items'][] = $info;
     }
     return $data;
 }
function rs_get_post_revisions($post_id, $status = 'inherit', $args = array())
{
    global $wpdb;
    $defaults = array('order' => 'DESC', 'orderby' => 'post_modified_gmt', 'use_memcache' => true, 'fields' => COLS_ALL_RS, 'return_flipped' => false, 'where' => '');
    $args = wp_parse_args($args, $defaults);
    extract($args);
    if (COL_ID_RS == $fields) {
        // performance opt for repeated calls by user_has_cap filter
        if ($use_memcache) {
            static $last_results;
            if (!isset($last_results)) {
                $last_results = array();
            } elseif (isset($last_results[$post_id][$status])) {
                return $last_results[$post_id][$status];
            }
        }
        $revisions = scoper_get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'revision' AND post_parent = '{$post_id}' AND post_status = '{$status}' {$where}");
        if ($return_flipped) {
            $revisions = array_fill_keys($revisions, true);
        }
        if ($use_memcache) {
            if (!isset($last_results[$post_id])) {
                $last_results[$post_id] = array();
            }
            $last_results[$post_id][$status] = $revisions;
        }
    } else {
        $order_clause = $order && $orderby ? "ORDER BY {$orderby} {$order}" : '';
        $revisions = scoper_get_results("SELECT * FROM {$wpdb->posts} WHERE post_type = 'revision' AND post_parent = '{$post_id}' AND post_status = '{$status}' {$order_clause}");
    }
    return $revisions;
}
Esempio n. 5
0
 /**
  * Compute the denominators which is the predicted expectation of
  * each feature given a set of weights L and a set of features for
  * each document for each class.
  * 
  * @param $feature_array All the data known about the training set
  * @param $l The current set of weights to be initialized
  * @return void
  */
 protected function prepareFprime(array &$feature_array, array &$l)
 {
     $this->denominators = array();
     foreach ($feature_array as $offset => $doc) {
         $numerator = array_fill_keys(array_keys($doc), 0.0);
         $denominator = 0.0;
         foreach ($doc as $cl => $f) {
             if (!is_array($f)) {
                 continue;
             }
             $tmp = 0.0;
             foreach ($f as $i) {
                 $tmp += $l[$i];
             }
             $tmp = exp($tmp);
             $numerator[$cl] += $tmp;
             $denominator += $tmp;
         }
         foreach ($doc as $class => $features) {
             if (!is_array($features)) {
                 continue;
             }
             foreach ($features as $fi) {
                 if (!isset($this->denominators[$fi])) {
                     $this->denominators[$fi] = 0;
                 }
                 $this->denominators[$fi] += $numerator[$class] / $denominator;
             }
         }
     }
 }
Esempio n. 6
0
 public static function update_group_user($group_id, $user_ids, $args = array())
 {
     $defaults = array('agent_type' => 'pp_group');
     $args = array_merge($defaults, $args);
     extract($args, EXTR_SKIP);
     // NOTE: no arg defaults because we only update columns that are explicitly passed
     if (!($cols = array_intersect_key($args, array_fill_keys(array('status', 'date_limited', 'start_date_gmt', 'end_date_gmt'), true)))) {
         return;
     }
     global $wpdb;
     $members_table = apply_filters('pp_use_group_members_table', $wpdb->pp_group_members, $agent_type);
     $user_clause = "AND user_id IN ('" . implode("', '", array_map('intval', (array) $user_ids)) . "')";
     if (isset($cols['date_limited'])) {
         $cols['date_limited'] = (int) $cols['date_limited'];
     }
     if (isset($cols['start_date_gmt'])) {
         $cols['start_date_gmt'] = self::_validate_duration_value($cols['start_date_gmt']);
     }
     if (isset($cols['end_date_gmt'])) {
         $cols['end_date_gmt'] = self::_validate_duration_value($cols['end_date_gmt']);
     }
     $prev = array();
     $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$members_table} WHERE group_id = %d {$user_clause}", $group_id));
     foreach ($results as $row) {
         $prev[$row->user_id] = $row;
     }
     foreach ((array) $user_ids as $user_id) {
         $wpdb->update($members_table, $cols, array('group_id' => $group_id, 'user_id' => $user_id));
         $_prev = isset($prev[$user_id]) ? $prev[$user_id] : '';
         do_action('pp_update_group_user', $group_id, $user_id, $status, compact('date_limited', 'start_date_gmt', 'end_date_gmt'), $_prev);
     }
 }
Esempio n. 7
0
 /**
  * Adds a row to the table with optional values.
  *
  * @param array $values
  */
 public function addRow($values = array())
 {
     $this->data[] = array_merge(
       array_fill_keys($this->getTableMetaData()->getColumns(), NULL),
       $values
     );
 }
Esempio n. 8
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     $objFaq = \FaqModel::findPublishedByPids($this->faq_categories);
     if ($objFaq === null) {
         $this->Template->faq = array();
         return;
     }
     $arrFaq = array_fill_keys($this->faq_categories, array());
     // Add FAQs
     while ($objFaq->next()) {
         $arrTemp = $objFaq->row();
         $arrTemp['title'] = specialchars($objFaq->question, true);
         $arrTemp['href'] = $this->generateFaqLink($objFaq);
         // Get the FAQ category
         $objPid = $objFaq->getRelated('pid');
         $arrFaq[$objFaq->pid]['items'][] = $arrTemp;
         $arrFaq[$objFaq->pid]['headline'] = $objPid->headline;
         $arrFaq[$objFaq->pid]['title'] = $objPid->title;
     }
     $arrFaq = array_values(array_filter($arrFaq));
     $cat_count = 0;
     $cat_limit = count($arrFaq);
     // Add classes
     foreach ($arrFaq as $k => $v) {
         $count = 0;
         $limit = count($v['items']);
         for ($i = 0; $i < $limit; $i++) {
             $arrFaq[$k]['items'][$i]['class'] = trim((++$count == 1 ? ' first' : '') . ($count >= $limit ? ' last' : '') . ($count % 2 == 0 ? ' odd' : ' even'));
         }
         $arrFaq[$k]['class'] = trim((++$cat_count == 1 ? ' first' : '') . ($cat_count >= $cat_limit ? ' last' : '') . ($cat_count % 2 == 0 ? ' odd' : ' even'));
     }
     $this->Template->faq = $arrFaq;
 }
 private function extractSenderPhone(&$data, $sender)
 {
     $keys = array_fill_keys(['senderPhone'], null);
     $keySender = array_intersect_key($data['sender']['phone'], $keys);
     $data['senderPhone'] = array_key_exists('senderPhone', $keySender) ? $sender->getPhone()->getSenderPhone() : null;
     return $this;
 }
Esempio n. 10
0
 public function renderBreadcrumbs($slug)
 {
     $ancestor_handles = array();
     $ancestral_slugs = PhabricatorSlug::getAncestry($slug);
     $ancestral_slugs[] = $slug;
     if ($ancestral_slugs) {
         $empty_slugs = array_fill_keys($ancestral_slugs, null);
         $ancestors = id(new PhrictionDocumentQuery())->setViewer($this->getRequest()->getUser())->withSlugs($ancestral_slugs)->execute();
         $ancestors = mpull($ancestors, null, 'getSlug');
         $ancestor_phids = mpull($ancestors, 'getPHID');
         $handles = array();
         if ($ancestor_phids) {
             $handles = $this->loadViewerHandles($ancestor_phids);
         }
         $ancestor_handles = array();
         foreach ($ancestral_slugs as $slug) {
             if (isset($ancestors[$slug])) {
                 $ancestor_handles[] = $handles[$ancestors[$slug]->getPHID()];
             } else {
                 $handle = new PhabricatorObjectHandle();
                 $handle->setName(PhabricatorSlug::getDefaultTitle($slug));
                 $handle->setURI(PhrictionDocument::getSlugURI($slug));
                 $ancestor_handles[] = $handle;
             }
         }
     }
     $breadcrumbs = array();
     foreach ($ancestor_handles as $ancestor_handle) {
         $breadcrumbs[] = id(new PHUICrumbView())->setName($ancestor_handle->getName())->setHref($ancestor_handle->getUri());
     }
     return $breadcrumbs;
 }
Esempio n. 11
0
 public function __construct()
 {
     $this->tokenMap = $this->createTokenMap();
     // map of tokens to drop while lexing (the map is only used for isset lookup,
     // that's why the value is simply set to 1; the value is never actually used.)
     $this->dropTokens = array_fill_keys(array(T_WHITESPACE, T_OPEN_TAG), 1);
 }
Esempio n. 12
0
 public final function getData($slides, $startIndex, $group)
 {
     $data = array();
     $linearData = $this->_getData($slides * $group, $startIndex - 1);
     $keys = array();
     for ($i = 0; $i < count($linearData); $i++) {
         $keys = array_merge($keys, array_keys($linearData[$i]));
     }
     $columns = array_fill_keys($keys, '');
     for ($i = 0; $i < count($linearData); $i++) {
         $firstIndex = intval($i / $group);
         if (!isset($data[$firstIndex])) {
             $data[$firstIndex] = array();
         }
         $data[$firstIndex][$i % $group] = array_merge($columns, $linearData[$i]);
     }
     if (count($data) && count($data[count($data) - 1]) != $group) {
         if (count($data) - 1 == 0 && count($data[count($data) - 1]) > 0) {
             for ($i = 0; count($data[0]) < $group; $i++) {
                 $data[0][] = $data[0][$i];
             }
         } else {
             array_pop($data);
         }
     }
     return $data;
 }
Esempio n. 13
0
 /**
  *
  */
 protected function replacements(array $patterns, $entry, array $options = null)
 {
     $field = $this->_field;
     $fieldname = $field->name;
     $edit = !empty($options['edit']);
     $replacements = array_fill_keys(array_keys($patterns), '');
     if ($edit) {
         foreach ($patterns as $pattern => $cleanpattern) {
             if ($noedit = $this->is_noedit($pattern)) {
                 continue;
             }
             $params = array('required' => $this->is_required($pattern));
             $replacements[$pattern] = array(array($this, 'display_edit'), array($entry, $params));
         }
         return $replacements;
     }
     // Browse mode.
     foreach ($patterns as $pattern => $cleanpattern) {
         $parts = explode(':', trim($cleanpattern, '[]'));
         if (!empty($parts[1])) {
             $type = $parts[1];
         } else {
             $type = '';
         }
         $replacements[$pattern] = $this->display_browse($entry, $type);
     }
     return $replacements;
 }
Esempio n. 14
0
 /**
  *
  */
 protected function replacements(array $patterns, $entry, array $options = null)
 {
     $field = $this->_field;
     $fieldname = $field->name;
     $edit = !empty($options['edit']);
     $replacements = array_fill_keys(array_keys($patterns), '');
     $editdisplayed = false;
     foreach ($patterns as $pattern => $cleanpattern) {
         // Edit.
         if ($edit and !$editdisplayed and !$this->is_noedit($pattern)) {
             $params = array('required' => $this->is_required($pattern));
             if ($cleanpattern == "[[{$fieldname}:addnew]]") {
                 $params['addnew'] = true;
             }
             $replacements[$pattern] = array(array($this, 'display_edit'), array($entry, $params));
             $editdisplayed = true;
             continue;
         }
         // Browse.
         if ($cleanpattern == "[[{$fieldname}:options]]") {
             $replacements[$pattern] = $this->display_browse($entry, array('options' => true));
         } else {
             if ($cleanpattern == "[[{$fieldname}:key]]") {
                 $replacements[$pattern] = $this->display_browse($entry, array('key' => true));
             } else {
                 if ($cleanpattern == "[[{$fieldname}:cat]]") {
                     $replacements[$pattern] = $this->display_category($entry);
                 } else {
                     $replacements[$pattern] = $this->display_browse($entry);
                 }
             }
         }
     }
     return $replacements;
 }
Esempio n. 15
0
 public function componentWhiteboardTransitionSelector()
 {
     foreach ($this->board->getColumns() as $column) {
         if ($column->hasIssue($this->issue)) {
             $this->current_column = $column;
             break;
         }
     }
     $transition_ids = array();
     $same_transition_statuses = array();
     foreach ($this->transitions as $status_id => $transitions) {
         if (!in_array($status_id, $this->statuses)) {
             continue;
         }
         foreach ($transitions as $transition) {
             if (in_array($transition->getID(), $transition_ids)) {
                 $same_transition_statuses[] = $status_id;
             } else {
                 $transition_ids[] = $transition->getID();
             }
         }
     }
     $this->same_transition_statuses = $same_transition_statuses;
     $this->statuses_occurred = array_fill_keys($this->statuses, 0);
 }
 /**
  * {@inheritdoc}
  *
  * Override of CsvWriter flush method to use the file buffer
  */
 public function flush()
 {
     if (!is_file($this->bufferFile)) {
         return;
     }
     $exportDirectory = dirname($this->getPath());
     if (!is_dir($exportDirectory)) {
         $this->localFs->mkdir($exportDirectory);
     }
     $this->writtenFiles[$this->getPath()] = basename($this->getPath());
     if (false === ($csvFile = fopen($this->getPath(), 'w'))) {
         throw new RuntimeErrorException('Failed to open file %path%', ['%path%' => $this->getPath()]);
     }
     $header = $this->isWithHeader() ? $this->headers : [];
     if (false === fputcsv($csvFile, $header, $this->delimiter)) {
         throw new RuntimeErrorException('Failed to write to file %path%', ['%path%' => $this->getPath()]);
     }
     $bufferHandle = fopen($this->bufferFile, 'r');
     $hollowProduct = array_fill_keys($this->headers, '');
     while (null !== ($bufferedProduct = $this->readProductFromBuffer($bufferHandle))) {
         $fullProduct = array_replace($hollowProduct, $bufferedProduct);
         if (false === fputcsv($csvFile, $fullProduct, $this->delimiter, $this->enclosure)) {
             throw new RuntimeErrorException('Failed to write to file %path%', ['%path%' => $this->getPath()]);
         } elseif (null !== $this->stepExecution) {
             $this->stepExecution->incrementSummaryInfo('write');
         }
     }
     fclose($bufferHandle);
     unlink($this->bufferFile);
     fclose($csvFile);
 }
Esempio n. 17
0
 public function parseCookie($cookie, $host = null, $path = null, $decode = false)
 {
     $pieces = array_filter(array_map('trim', explode(';', $cookie)));
     if (empty($pieces) || !strpos($pieces[0], '=')) {
         return false;
     }
     $data = array_merge(array_fill_keys(array_keys(self::$cookieParts), null), array('cookies' => array(), 'data' => array(), 'path' => $path ?: '/', 'http_only' => false, 'discard' => false, 'domain' => $host));
     $foundNonCookies = 0;
     foreach ($pieces as $part) {
         $cookieParts = explode('=', $part, 2);
         $key = trim($cookieParts[0]);
         if (count($cookieParts) == 1) {
             $value = true;
         } else {
             $value = trim($cookieParts[1], " \n\r\t\v\"");
             if ($decode) {
                 $value = urldecode($value);
             }
         }
         if (!empty($data['cookies'])) {
             foreach (self::$cookieParts as $mapValue => $search) {
                 if (!strcasecmp($search, $key)) {
                     $data[$mapValue] = $mapValue == 'port' ? array_map('trim', explode(',', $value)) : $value;
                     $foundNonCookies++;
                     continue 2;
                 }
             }
         }
         $data[$foundNonCookies ? 'data' : 'cookies'][$key] = $value;
     }
     if (!$data['expires'] && $data['max_age']) {
         $data['expires'] = time() + (int) $data['max_age'];
     }
     return $data;
 }
Esempio n. 18
0
 /**
  * @param string|SplFileObject $file The file to write
  * @param Dialect|null $dialect The delimiter dialect to use
  * @param array $headers The CSV file headers
  * @param int $invalidBehavior What to do with invalid columns
  */
 public function __construct($file, Dialect $dialect = null, array $fields, $errorBehavior = self::IGNORE_INVALID, $restValue = '')
 {
     $this->writer = new SimpleWriter($file, $dialect);
     $this->fields = array_fill_keys(array_values($fields), true);
     $this->errorBehavior = $errorBehavior;
     $this->restValue = $restValue;
 }
 /**
  * @param string $name Image name
  * @param string $module Module name
  * @param string|array $descriptor Path to image file, or array structure containing paths
  * @param string $basePath Directory to which paths in descriptor refer
  * @param array $variants
  * @throws InvalidArgumentException
  */
 public function __construct($name, $module, $descriptor, $basePath, $variants)
 {
     $this->name = $name;
     $this->module = $module;
     $this->descriptor = $descriptor;
     $this->basePath = $basePath;
     $this->variants = $variants;
     // Expand shorthands:
     // array( "en,de,fr" => "foo.svg" )
     // → array( "en" => "foo.svg", "de" => "foo.svg", "fr" => "foo.svg" )
     if (is_array($this->descriptor) && isset($this->descriptor['lang'])) {
         foreach (array_keys($this->descriptor['lang']) as $langList) {
             if (strpos($langList, ',') !== false) {
                 $this->descriptor['lang'] += array_fill_keys(explode(',', $langList), $this->descriptor['lang'][$langList]);
                 unset($this->descriptor['lang'][$langList]);
             }
         }
     }
     // Ensure that all files have common extension.
     $extensions = array();
     $descriptor = (array) $descriptor;
     array_walk_recursive($descriptor, function ($path) use(&$extensions) {
         $extensions[] = pathinfo($path, PATHINFO_EXTENSION);
     });
     $extensions = array_unique($extensions);
     if (count($extensions) !== 1) {
         throw new InvalidArgumentException("File type for different image files of '{$name}' not the same");
     }
     $ext = $extensions[0];
     if (!isset(self::$fileTypes[$ext])) {
         throw new InvalidArgumentException("Invalid file type for image files of '{$name}' (valid: svg, png, gif, jpg)");
     }
     $this->extension = $ext;
 }
 public function willApplyRules(PhabricatorUser $viewer, array $values, array $objects)
 {
     $viewer_phid = $viewer->getPHID();
     if (!$viewer_phid) {
         return;
     }
     if (empty($this->memberships[$viewer_phid])) {
         $this->memberships[$viewer_phid] = array();
     }
     foreach ($objects as $key => $object) {
         $cache = $this->getTransactionHint($object);
         if ($cache === null) {
             continue;
         }
         unset($objects[$key]);
         if (isset($cache[$viewer_phid])) {
             $this->memberships[$viewer_phid][$object->getPHID()] = true;
         }
     }
     if (!$objects) {
         return;
     }
     $object_phids = mpull($objects, 'getPHID');
     $edge_query = id(new PhabricatorEdgeQuery())->withSourcePHIDs(array($viewer_phid))->withDestinationPHIDs($object_phids)->withEdgeTypes(array(PhabricatorProjectMemberOfProjectEdgeType::EDGECONST));
     $edge_query->execute();
     $memberships = $edge_query->getDestinationPHIDs();
     if (!$memberships) {
         return;
     }
     $this->memberships[$viewer_phid] += array_fill_keys($memberships, true);
 }
 public function save()
 {
     if (!$this->object) {
         throw new Exception('Call setObject() before save()!');
     }
     $actor = $this->requireActor();
     $src = $this->object->getPHID();
     if ($this->implicitSubscribePHIDs) {
         $unsub = PhabricatorEdgeQuery::loadDestinationPHIDs($src, PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER);
         $unsub = array_fill_keys($unsub, true);
         $this->implicitSubscribePHIDs = array_diff_key($this->implicitSubscribePHIDs, $unsub);
     }
     $add = $this->implicitSubscribePHIDs + $this->explicitSubscribePHIDs;
     $del = $this->unsubscribePHIDs;
     // If a PHID is marked for both subscription and unsubscription, treat
     // unsubscription as the stronger action.
     $add = array_diff_key($add, $del);
     if ($add || $del) {
         $u_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER;
         $s_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_SUBSCRIBER;
         $editor = new PhabricatorEdgeEditor();
         foreach ($add as $phid => $ignored) {
             $editor->removeEdge($src, $u_type, $phid);
             $editor->addEdge($src, $s_type, $phid);
         }
         foreach ($del as $phid => $ignored) {
             $editor->removeEdge($src, $s_type, $phid);
             $editor->addEdge($src, $u_type, $phid);
         }
         $editor->save();
     }
 }
Esempio n. 22
0
 public function listDocuments()
 {
     if (!Auth::check()) {
         return Redirect::to('/')->with('error', 'You must be logged in');
     }
     $raw_docs = Doc::allOwnedBy(Auth::user()->id);
     // Get all user groups and create array from their names
     $groups = Auth::user()->groups()->get();
     $group_names = array();
     foreach ($groups as $group) {
         array_push($group_names, $group->getDisplayName());
     }
     // Create master documents array and prefill group subarray
     $documents = array('independent' => array(), 'group' => array());
     $documents['group'] = array_fill_keys($group_names, array());
     // Copy document to appropriate array
     foreach ($raw_docs as $doc) {
         if ($doc->userSponsor()->exists()) {
             array_push($documents['independent'], $doc);
         } elseif ($doc->groupSponsor()->exists()) {
             array_push($documents['group'][$doc->sponsor()->first()->getDisplayName()], $doc);
         }
     }
     return View::make('documents.list', array('doc_count' => count($raw_docs), 'documents' => $documents));
 }
 /**
  * Loop over all the content in the main loop and do a request for all the items present so that we're only getting
  * a few API hits instead of all of them. Then, when anything else calls `easyazon_get_item` it will get the cached
  * data and not have to hit the API.
  */
 public static function prefetch_items()
 {
     global $wp_query;
     $identifiers = array_fill_keys(array_keys(easyazon_get_locales()), array());
     $preparsed = array();
     $shortcodes = easyazon_get_shortcodes();
     foreach ($wp_query->posts as $post) {
         preg_match_all('/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER);
         foreach ($matches as $match) {
             $shortcode = trim($match[2]);
             if (in_array($shortcode, $shortcodes)) {
                 $attributes = shortcode_parse_atts($match[3]);
                 $locale = isset($attributes['locale']) ? $attributes['locale'] : false;
                 $identifier = isset($attributes['identifier']) ? $attributes['identifier'] : false;
                 if (!is_array($preparsed[$shortcode])) {
                     $preparsed[$shortcode] = array();
                 }
                 $preparsed[$shortcode][] = $attributes;
                 if ($locale && $identifier) {
                     $identifiers[$locale][] = $identifier;
                 }
             }
         }
     }
     foreach ($identifiers as $locale => $queryable) {
         $cached_items = easyazon_get_items($queryable, $locale);
     }
     self::$preparsed_shortcodes = $preparsed;
 }
 protected function init()
 {
     try {
         $this->data['timestamp'] = time();
         $this->data['direction'] = waRequest::post('direction', 'import');
         $type_model = new shopTypeModel();
         $this->data['types'] = array_map('intval', array_keys($type_model->getTypes()));
         switch ($this->data['direction']) {
             case 'export':
                 $this->initExport();
                 break;
             case 'import':
             default:
                 $this->data['direction'] = 'import';
                 $this->initImport();
                 break;
         }
         $stages = array_keys($this->data['count']);
         $this->data['current'] = array_fill_keys($stages, 0);
         $value = $this->data['direction'] == 'import' ? $this->emulate(null) ? array('add' => 0, 'found' => 0, 'skip' => 0, 'rights' => 0, 'currency' => 0) : array('new' => 0, 'update' => 0, 'skip' => 0, 'error' => 0, 'rights' => 0, 'currency' => 0) : 0;
         $this->data['processed_count'] = array_fill_keys($stages, $value);
         $this->data['map'] = array();
         $this->data['memory'] = memory_get_peak_usage();
         $this->data['memory_avg'] = memory_get_usage();
         $this->data['timestamp'] = time();
     } catch (waException $ex) {
         $this->error($ex->getMessage());
         echo $this->json(array('error' => $ex->getMessage()));
         exit;
     }
 }
Esempio n. 25
0
 function show()
 {
     global $USER, $LNG, $reslist;
     $db = Database::get();
     $sql = "SELECT elementID, level, userID, username\n\t\tFROM %%USERS%%\n\t\tINNER JOIN %%RECORDS%% ON userID = id\n\t\tWHERE universe = :universe;";
     $recordResult = $db->select($sql, array(':universe' => Universe::current()));
     $defenseList = array_fill_keys($reslist['defense'], array());
     $fleetList = array_fill_keys($reslist['fleet'], array());
     $researchList = array_fill_keys($reslist['tech'], array());
     $buildList = array_fill_keys($reslist['build'], array());
     foreach ($recordResult as $recordRow) {
         if (in_array($recordRow['elementID'], $reslist['defense'])) {
             $defenseList[$recordRow['elementID']][] = $recordRow;
         } elseif (in_array($recordRow['elementID'], $reslist['fleet'])) {
             $fleetList[$recordRow['elementID']][] = $recordRow;
         } elseif (in_array($recordRow['elementID'], $reslist['tech'])) {
             $researchList[$recordRow['elementID']][] = $recordRow;
         } elseif (in_array($recordRow['elementID'], $reslist['build'])) {
             $buildList[$recordRow['elementID']][] = $recordRow;
         }
     }
     require_once 'includes/classes/Cronjob.class.php';
     $this->assign(array('defenseList' => $defenseList, 'fleetList' => $fleetList, 'researchList' => $researchList, 'buildList' => $buildList, 'update' => _date($LNG['php_tdformat'], Cronjob::getLastExecutionTime('statistic'), $USER['timezone'])));
     $this->display('page.records.default.tpl');
 }
Esempio n. 26
0
 function __toString()
 {
     $this->applyOptions();
     $smarty = \TikiLib::lib('smarty');
     $smarty->assign('control', ['field' => $this->fieldName, 'options' => $this->options, 'values' => array_fill_keys($this->values, true)]);
     return $smarty->fetch('filter_control/inline_checkboxes.tpl');
 }
Esempio n. 27
0
 /**
  * Provides an array of the settings with the setting name as the key and the default value as the value
  * This cannot be called get_settings() or it will override WP_Widget::get_settings()
  */
 function woo_get_settings()
 {
     // Set the default to a blank string
     $settings = array_fill_keys($this->settings, '');
     // Now set the more specific defaults
     return $settings;
 }
Esempio n. 28
0
 public function __construct($properties = null)
 {
     $this->_properties = array_fill_keys(self::get_properties_keys(), null);
     if ($properties) {
         $this->set_properties($properties, null);
     }
 }
Esempio n. 29
0
 protected function requireRouteNames()
 {
     if ($this->names === null) {
         $this->names = $this->resolversConfig->keys();
         $this->resolverMap = array_fill_keys($this->names, null);
     }
 }
 /**
  * @return Status
  */
 public function validate()
 {
     $this->outputIndented("\tValidating shard allocation settings...");
     $actual = $this->fetchActualAllocation();
     $changed = false;
     foreach (array('include', 'exclude', 'require') as $type) {
         $desired = $this->indexAllocation[$type];
         if ($desired) {
             $this->output("\n");
             $this->outputIndented("\t\tUpdating '{$type}' allocations...");
             $this->set($type, $desired);
             $this->output("done");
             $changed = true;
         }
         if (isset($actual[$type])) {
             $undesired = array_filter(array_keys($actual[$type]), function ($key) use($actual, $type, $desired) {
                 return $actual[$type][$key] !== '' && !isset($desired[$key]);
             });
             if ($undesired) {
                 $this->output("\n");
                 $this->outputIndented("\t\tClearing '{$type}' allocations...");
                 $this->set($type, array_fill_keys($undesired, ''));
                 $this->output("done");
                 $changed = true;
             }
         }
     }
     if ($changed) {
         $this->output("\n");
     } else {
         $this->output("done\n");
     }
     return Status::newGood();
 }