Пример #1
14
 function apply_filters_ref_array($tag, $args)
 {
     global $wp_filter, $merged_filters, $wp_current_filter;
     // Do 'all' actions first
     if (isset($wp_filter['all'])) {
         $wp_current_filter[] = $tag;
         $all_args = func_get_args();
         _wp_call_all_hook($all_args);
     }
     if (!isset($wp_filter[$tag])) {
         if (isset($wp_filter['all'])) {
             array_pop($wp_current_filter);
         }
         return $args[0];
     }
     if (!isset($wp_filter['all'])) {
         $wp_current_filter[] = $tag;
     }
     // Sort
     if (!isset($merged_filters[$tag])) {
         ksort($wp_filter[$tag]);
         $merged_filters[$tag] = true;
     }
     reset($wp_filter[$tag]);
     do {
         foreach ((array) current($wp_filter[$tag]) as $the_) {
             if (!is_null($the_['function'])) {
                 $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
             }
         }
     } while (next($wp_filter[$tag]) !== false);
     array_pop($wp_current_filter);
     return $args[0];
 }
Пример #2
2
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @throws InvalidArgumentException
  * @return int|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->detectMagento($output, true);
     if (!$this->initMagento()) {
         return;
     }
     $type = $input->getArgument('type');
     $areas = array('global', 'adminhtml', 'frontend', 'crontab');
     if ($type === null) {
         $type = $this->askForArrayEntry($areas, $output, 'Please select an area:');
     }
     if (!in_array($type, $areas)) {
         throw new InvalidArgumentException('Invalid type! Use one of: ' . implode(', ', $areas));
     }
     if ($input->getOption('format') === null) {
         $this->writeSection($output, 'Observers: ' . $type);
     }
     $frontendEvents = \Mage::getConfig()->getNode($type . '/events')->asArray();
     if (true === $input->getOption('sort')) {
         // sorting for Observers is a bad idea because the order in which observers will be called is important.
         ksort($frontendEvents);
     }
     $table = array();
     foreach ($frontendEvents as $eventName => $eventData) {
         $observerList = array();
         foreach ($eventData['observers'] as $observer) {
             $observerList[] = $this->getObserver($observer, $type);
         }
         $table[] = array($eventName, implode("\n", $observerList));
     }
     $this->getHelper('table')->setHeaders(array('Event', 'Observers'))->setRows($table)->renderByFormat($output, $table, $input->getOption('format'));
 }
Пример #3
1
 /**
  * 获取返回时的签名验证结果
  * @param $para_temp 通知返回来的参数数组
  * @param $sign 返回的签名结果
  * @return 签名验证结果
  */
 protected function getSignVeryfy($param, $sign)
 {
     //除去待签名参数数组中的空值和签名参数
     $param_filter = array();
     while (list($key, $val) = each($param)) {
         if ($key == "sign" || $key == "sign_type" || $val == "") {
             continue;
         } else {
             $param_filter[$key] = $param[$key];
         }
     }
     ksort($param_filter);
     reset($param_filter);
     //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
     $prestr = "";
     while (list($key, $val) = each($param_filter)) {
         $prestr .= $key . "=" . $val . "&";
     }
     //去掉最后一个&字符
     $prestr = substr($prestr, 0, -1);
     $prestr = $prestr . $this->config['key'];
     $mysgin = md5($prestr);
     if ($mysgin == $sign) {
         return true;
     } else {
         return false;
     }
 }
Пример #4
0
 public static function parseXmlFiles($templateBaseDir = null)
 {
     // Read the template folder to find templates
     if (!$templateBaseDir) {
         $templateBaseDir = KPATH_SITE . '/template';
     }
     $data = self::parseXmlFile('', $templateBaseDir);
     if ($data) {
         // Guess template folder.
         $data->directory = preg_replace('/[^a-z0-9_]/', '', preg_replace('/\\s+/', '_', strtolower($data->name)));
         if (!$data->directory) {
             return array();
         }
         // Template found from the root (folder cannot contain more than one template)
         return array('' => $data);
     }
     $templateDirs = KunenaFolder::folders($templateBaseDir);
     $rows = array();
     // Check that the directory contains an xml file
     foreach ($templateDirs as $templateDir) {
         $data = self::parseXmlFile($templateDir, $templateBaseDir);
         if ($data) {
             $rows[$templateDir] = $data;
         }
     }
     ksort($rows);
     return $rows;
 }
Пример #5
0
/**
 * Gets all available MIME-types
 *
 * @return  array    array[mimetype], array[transformation]
 *
 * @access  public
 *
 * @author  Garvin Hicking <*****@*****.**>
 */
function PMA_getAvailableMIMEtypes()
{
    $handle = opendir('./libraries/transformations');
    $stack = array();
    $filestack = array();
    while (($file = readdir($handle)) != false) {
        $filestack[$file] = $file;
    }
    closedir($handle);
    if (is_array($filestack)) {
        @ksort($filestack);
        foreach ($filestack as $key => $file) {
            if (preg_match('|^.*__.*\\.inc\\.php$|', trim($file))) {
                // File contains transformation functions.
                $base = explode('__', str_replace('.inc.php', '', $file));
                $mimetype = str_replace('_', '/', $base[0]);
                $stack['mimetype'][$mimetype] = $mimetype;
                $stack['transformation'][] = $mimetype . ': ' . $base[1];
                $stack['transformation_file'][] = $file;
            } elseif (preg_match('|^.*\\.inc\\.php$|', trim($file))) {
                // File is a plain mimetype, no functions.
                $base = str_replace('.inc.php', '', $file);
                if ($base != 'global') {
                    $mimetype = str_replace('_', '/', $base);
                    $stack['mimetype'][$mimetype] = $mimetype;
                    $stack['empty_mimetype'][$mimetype] = $mimetype;
                }
            }
        }
    }
    return $stack;
}
Пример #6
0
 protected function _renderCellTemplate($columnName)
 {
     $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
     if ($columnName == "template") {
         $collection = Mage::getResourceModel('core/email_template_collection')->load();
         $arr_select = $collection->toOptionArray();
         array_unshift($arr_select, array('label' => Mage::helper('rewardpoints')->__('Default'), 'value' => ''));
         return $this->_getTemplateRenderer()->setName($inputName)->setTitle($columnName)->setExtraParams('style="width:260px"')->setOptions($arr_select)->toHtml();
     } else {
         if ($columnName == "sender") {
             $arr_select = array();
             $config = Mage::getSingleton('adminhtml/config')->getSection('trans_email')->groups->children();
             foreach ($config as $node) {
                 $nodeName = $node->getName();
                 $label = (string) $node->label;
                 $sortOrder = (int) $node->sort_order;
                 $arr_select[$sortOrder] = array('value' => preg_replace('#^ident_(.*)$#', '$1', $nodeName), 'label' => Mage::helper('adminhtml')->__($label));
             }
             ksort($arr_select);
             /*array_unshift(
                   $arr_select,
                   array(
                       'label' => Mage::helper('rewardpoints')->__('Default'),
                       'value' => ''
                   )
               );*/
             return $this->_getSenderRenderer()->setName($inputName)->setTitle($columnName)->setExtraParams('style="width:260px"')->setOptions($arr_select)->toHtml();
         }
     }
     return parent::_renderCellTemplate($columnName);
 }
Пример #7
0
 /**
  * Add site preferences
  */
 public function __addPreferences($context)
 {
     // Get selected languages
     $selection = Symphony::Configuration()->get('datetime');
     if (empty($selection)) {
         $selection = array();
     }
     // Build default options
     $options = array();
     foreach ($this->languages as $name => $codes) {
         $options[$name] = array($name . '::' . $codes, array_key_exists($name, $selection) ? true : false, __(ucfirst($name)));
     }
     // Add custom options
     foreach (array_diff_key($selection, $this->languages) as $name => $codes) {
         $options[$name] = array($name . '::' . $codes, true, __(ucfirst($name)));
     }
     // Sort options
     ksort($options);
     // Add fieldset
     $group = new XMLElement('fieldset', '<legend>' . __('Date and Time') . '</legend>', array('class' => 'settings'));
     $select = Widget::Select('settings[datetime][]', $options, array('multiple' => 'multiple'));
     $label = Widget::Label('Languages included in the Date and Time Data Source', $select);
     $group->appendChild($label);
     $help = new XMLElement('p', __('You can add more languages in you configuration file.'), array('class' => 'help'));
     $group->appendChild($help);
     $context['wrapper']->appendChild($group);
 }
Пример #8
0
Файл: S3.php Проект: rikaix/zf2
 /**
  * Add the S3 Authorization signature to the request headers
  *
  * @param  string $method
  * @param  string $path
  * @param  array &$headers
  * @return string
  */
 public function generateSignature($method, $path, &$headers)
 {
     if (!is_array($headers)) {
         $headers = array($headers);
     }
     $type = $md5 = $date = '';
     // Search for the Content-type, Content-MD5 and Date headers
     foreach ($headers as $key => $val) {
         if (strcasecmp($key, 'content-type') == 0) {
             $type = $val;
         } else {
             if (strcasecmp($key, 'content-md5') == 0) {
                 $md5 = $val;
             } else {
                 if (strcasecmp($key, 'date') == 0) {
                     $date = $val;
                 }
             }
         }
     }
     // If we have an x-amz-date header, use that instead of the normal Date
     if (isset($headers['x-amz-date']) && isset($date)) {
         $date = '';
     }
     $sig_str = "{$method}\n{$md5}\n{$type}\n{$date}\n";
     // For x-amz- headers, combine like keys, lowercase them, sort them
     // alphabetically and remove excess spaces around values
     $amz_headers = array();
     foreach ($headers as $key => $val) {
         $key = strtolower($key);
         if (substr($key, 0, 6) == 'x-amz-') {
             if (is_array($val)) {
                 $amz_headers[$key] = $val;
             } else {
                 $amz_headers[$key][] = preg_replace('/\\s+/', ' ', $val);
             }
         }
     }
     if (!empty($amz_headers)) {
         ksort($amz_headers);
         foreach ($amz_headers as $key => $val) {
             $sig_str .= $key . ':' . implode(',', $val) . "\n";
         }
     }
     $sig_str .= '/' . parse_url($path, PHP_URL_PATH);
     if (strpos($path, '?location') !== false) {
         $sig_str .= '?location';
     } else {
         if (strpos($path, '?acl') !== false) {
             $sig_str .= '?acl';
         } else {
             if (strpos($path, '?torrent') !== false) {
                 $sig_str .= '?torrent';
             }
         }
     }
     $signature = base64_encode(Crypt\Hmac::compute($this->_secretKey, 'sha1', utf8_encode($sig_str), Crypt\Hmac::BINARY));
     $headers['Authorization'] = 'AWS ' . $this->_accessKey . ':' . $signature;
     return $sig_str;
 }
Пример #9
0
 /**
  * Save tab preference order
  *
  * @return	@e void
  */
 protected function _saveTabs()
 {
     //-----------------------------------------
     // Store order
     //-----------------------------------------
     $order = array();
     $append = array();
     foreach ($this->tabKeys as $pos => $key) {
         if ($this->request['pos_' . $key]) {
             $order[$this->request['pos_' . $key]] = $key;
         } else {
             $append[] = $key;
         }
     }
     if (count($append)) {
         $order = array_merge($order, $append);
     }
     ksort($order);
     //-----------------------------------------
     // Save preference
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->staffSaveCookie('tabOrder', $order);
     //-----------------------------------------
     // Return new order
     //-----------------------------------------
     $this->returnJsonArray(array('order' => $order));
 }
Пример #10
0
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     ob_start();
     CollectionsPrinter::printFunctionLinks();
     $layout = new Block(ob_get_contents(), STANDARD_BLOCK);
     ob_end_clean();
     $actionRows->add($layout, null, null, CENTER, CENTER);
     $type = HarmoniType::fromString(urldecode(RequestContext::value('type')));
     $repositoryManager = Services::getService("Repository");
     // Get the Repositories
     $allRepositories = $repositoryManager->getRepositoriesByType($type);
     // put the repositories into an array and order them.
     // @todo, do authorization checking
     $repositoryArray = array();
     while ($allRepositories->hasNext()) {
         $repository = $allRepositories->next();
         $repositoryArray[$repository->getDisplayName()] = $repository;
     }
     ksort($repositoryArray);
     // print the Results
     $resultPrinter = new ArrayResultPrinter($repositoryArray, 2, 20, "printrepositoryShort", $harmoni);
     $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
     $resultLayout = $resultPrinter->getLayout();
     $actionRows->add($resultLayout, null, null, CENTER, CENTER);
 }
Пример #11
0
/**
 * Zikula_View function to use the _dgettext() function
 *
 * This function takes a identifier and returns the corresponding language constant.
 *
 * Available parameters:
 *   - text:     (required) string to translate
 *   - tagN:     (optional) replace for sprintf() e.g. %s or %1$s
 *   - domain:   (optional) textdomain to be used (not required, the system will fill this out automatically
 *   - comment:  (optional) comment to the translator (this is not processed by this code)
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *
 * Examples
 * {gettext}Hello world{/gettext}
 * {gettext tag1=$name}Hello %s{/gettext}
 * {gettext  tag1=$city tag2=$country comment="%1 is a name %2 is the place"}Hello %1$s, welcome to %2$s{/gettext}
 *
 * String replacement follows the rules at http://php.net/sprintf but please note Smarty seems to pass
 * all variables as strings so %s and %n$s are mostly used.
 *
 * @param array       $params  All attributes passed to this function from the template.
 * @param string      $content The block content.
 * @param Zikula_View $view    Reference to the Zikula_View object.
 *
 * @return string Translation if it was available.
 */
function smarty_block_gettext($params, $content, Zikula_View $view)
{
    if ($content) {
        if (isset($params['domain'])) {
            $domain = strtolower($params['domain']) == 'zikula' ? null : $params['domain'];
        } else {
            $domain = $view->getDomain();
            // default domain
        }
        // build array for tags (for %s, %1$s etc) if applicable
        ksort($params);
        $tags = array();
        foreach ($params as $key => $value) {
            if (preg_match('#^tag([0-9]{1,2})$#', $key)) {
                $tags[] = $value;
            }
        }
        $tags = count($tags) == 0 ? null : $tags;
        // perform gettext
        $output = isset($tags) ? __f($content, $tags, $domain) : __($content, $domain);
        if (isset($params['assign'])) {
            $render->assign($params['assign'], $output);
        } else {
            return $output;
        }
    }
}
Пример #12
0
 /**
  * Returns the price item with the lowest price for the given quantity.
  *
  * @param array $priceItems List of price items implementing \Aimeos\MShop\Price\Item\Iface
  * @param integer $quantity Number of products
  * @param string|null $currencyId Three letter ISO currency code or null for all
  * @throws \Aimeos\MShop\Price\Exception if no price item is available
  */
 public function getLowestPrice(array $priceItems, $quantity, $currencyId = null)
 {
     $priceList = array();
     foreach ($priceItems as $priceItem) {
         $iface = '\\Aimeos\\MShop\\Price\\Item\\Iface';
         if ($priceItem instanceof $iface === false) {
             throw new \Aimeos\MShop\Price\Exception(sprintf('Object is not of required type "%1$s"', $iface));
         }
         if ($currencyId !== null && $currencyId !== $priceItem->getCurrencyId()) {
             continue;
         }
         $priceList[$priceItem->getQuantity()] = $priceItem;
     }
     ksort($priceList);
     if (($price = reset($priceList)) === false) {
         throw new \Aimeos\MShop\Price\Exception(sprintf('Price item not available'));
     }
     if ($price->getQuantity() > $quantity) {
         $msg = sprintf('Price for the given quantity "%1$d" not available', $quantity);
         throw new \Aimeos\MShop\Price\Exception($msg);
     }
     foreach ($priceList as $qty => $priceItem) {
         if ($qty <= $quantity && $qty > $price->getQuantity()) {
             $price = $priceItem;
         }
     }
     return $price;
 }
Пример #13
0
 private function _remakeURI($baseurl, $params)
 {
     // Timestamp パラメータを追加します
     // - 時間の表記は ISO8601 形式、タイムゾーンは UTC(GMT)
     $params['Timestamp'] = gmdate('Y-m-d\\TH:i:s\\Z');
     // パラメータの順序を昇順に並び替えます
     ksort($params);
     // canonical string を作成します
     $canonical_string = '';
     foreach ($params as $k => $v) {
         $canonical_string .= '&' . $this->_urlencode_rfc3986($k) . '=' . $this->_urlencode_rfc3986($v);
     }
     $canonical_string = substr($canonical_string, 1);
     // 署名を作成します
     // - 規定の文字列フォーマットを作成
     // - HMAC-SHA256 を計算
     // - BASE64 エンコード
     $parsed_url = parse_url($baseurl);
     $string_to_sign = "GET\n{$parsed_url['host']}\n{$parsed_url['path']}\n{$canonical_string}";
     $signature = base64_encode(hash_hmac('sha256', $string_to_sign, SECRET_KEY, true));
     // URL を作成します
     // - リクエストの末尾に署名を追加
     $url = $baseurl . '?' . $canonical_string . '&Signature=' . $this->_urlencode_rfc3986($signature);
     return $url;
 }
Пример #14
0
 /**
  * Tries to match one of the URL routes to the current URL, otherwise
  * execute the default function.
  * Sets the callback that needs to be returned
  *
  * @param string $request
  */
 private static function _run($request)
 {
     // Whether or not we have matched the URL to a route
     $matched_route = false;
     $request = '/' . $request;
     //make sure the request has a trailing slash
     $request = rtrim($request, '/') . '/';
     $request = str_replace("//", "/", $request);
     // Sort the array by priority
     ksort(self::$_routes);
     // Loop through each priority level
     foreach (self::$_routes as $priority => $routes) {
         // Loop through each route for this priority level
         foreach ($routes as $source => $destination) {
             // Does the routing rule match the current URL?
             if (preg_match($source, $request, $matches)) {
                 // A routing rule was matched
                 $matched_route = TRUE;
                 $attr = implode('/', array_intersect_key($matches, array_flip(array_filter(array_keys($matches), 'is_string'))));
                 self::$_attr = explode('/', trim($attr, '/'));
                 self::_set_callback($destination);
             }
         }
     }
     if (!$matched_route) {
         if ($request != '/') {
             self::_set_callback($request);
         }
     }
 }
Пример #15
0
 /**
  * @inheritdoc
  */
 public function render($context, $targetDir)
 {
     parent::render($context, $targetDir);
     if ($this->controller !== null) {
         $this->controller->stdout("writing packages file...");
     }
     $packages = [];
     $notNamespaced = [];
     foreach (array_merge($context->classes, $context->interfaces, $context->traits) as $type) {
         /* @var $type TypeDoc */
         if (empty($type->namespace)) {
             $notNamespaced[] = str_replace('\\', '-', $type->name);
         } else {
             $packages[$type->namespace][] = str_replace('\\', '-', $type->name);
         }
     }
     ksort($packages);
     $packages = array_merge(['Not namespaced' => $notNamespaced], $packages);
     foreach ($packages as $name => $classes) {
         sort($packages[$name]);
     }
     file_put_contents($targetDir . '/packages.txt', serialize($packages));
     if ($this->controller !== null) {
         $this->controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
     }
 }
Пример #16
0
 /**
  * Register a plugin.
  *
  * @param  Zend_Controller_Plugin_Abstract $plugin
  * @param  int $stackIndex
  * @return Zend_Controller_Plugin_Broker
  */
 public function registerPlugin(Zend_Controller_Plugin_Abstract $plugin, $stackIndex = null)
 {
     if (false !== array_search($plugin, $this->_plugins, true)) {
         #require_once 'Zend/Controller/Exception.php';
         throw new Zend_Controller_Exception('Plugin already registered');
     }
     $stackIndex = (int) $stackIndex;
     if ($stackIndex) {
         if (isset($this->_plugins[$stackIndex])) {
             #require_once 'Zend/Controller/Exception.php';
             throw new Zend_Controller_Exception('Plugin with stackIndex "' . $stackIndex . '" already registered');
         }
         $this->_plugins[$stackIndex] = $plugin;
     } else {
         $stackIndex = count($this->_plugins);
         while (isset($this->_plugins[$stackIndex])) {
             ++$stackIndex;
         }
         $this->_plugins[$stackIndex] = $plugin;
     }
     $request = $this->getRequest();
     if ($request) {
         $this->_plugins[$stackIndex]->setRequest($request);
     }
     $response = $this->getResponse();
     if ($response) {
         $this->_plugins[$stackIndex]->setResponse($response);
     }
     ksort($this->_plugins);
     return $this;
 }
Пример #17
0
 /**
  * URL的签名算法,返回一个token字符串
  */
 public static function urlSign($paramArr)
 {
     $options = array('queryParam' => '', 'cryptkey' => '', 'timeInfo' => 0);
     if (is_array($paramArr)) {
         $options = array_merge($options, $paramArr);
     }
     extract($options);
     if (!$queryParam) {
         return '';
     }
     if (is_string($queryParam)) {
         parse_str($queryParam, $queryParam);
     }
     #对参数数组进行排序,保证参数传入的顺序不同,同样能得到结果
     ksort($queryParam);
     $queryString = array();
     foreach ($queryParam as $key => $val) {
         array_push($queryString, $key . '=' . $val);
     }
     $queryString = join('&', $queryString);
     if ($timeInfo) {
         //为了获取时间 可逆
         $queryString .= "#" . time();
         #将时间戳并入
         $sign = self::fastEncode(array('value' => $queryString, 'cryptkey' => $cryptkey));
     } else {
         //没有时间信息 不可逆
         $sign = hash_hmac("sha1", $queryString, $cryptkey);
     }
     return $sign;
 }
 protected function renderScriptBatch(array $scripts)
 {
     $html = '';
     $scriptBatches = array();
     foreach ($scripts as $scriptValue) {
         if (is_array($scriptValue)) {
             $scriptContent = $scriptValue['content'];
             unset($scriptValue['content']);
             $scriptHtmlOptions = $scriptValue;
         } else {
             $scriptContent = $scriptValue;
             $scriptHtmlOptions = array();
         }
         $key = serialize(ksort($scriptHtmlOptions));
         $scriptBatches[$key]['htmlOptions'] = $scriptHtmlOptions;
         $scriptBatches[$key]['scripts'][] = $scriptContent;
     }
     foreach ($scriptBatches as $scriptBatch) {
         if (!empty($scriptBatch['scripts'])) {
             if ($this->enableRenderingForAjaxResponse) {
                 if (isset($this->scriptStore["js_code"])) {
                     $this->scriptStore["js_code"] = $this->scriptStore["js_code"] . implode("\n", $scriptBatch['scripts']);
                 } else {
                     $this->scriptStore["js_code"] = implode("\n", $scriptBatch['scripts']);
                 }
             } else {
                 $html .= CHtml::script(implode("\n", $scriptBatch['scripts']), $scriptBatch['htmlOptions']) . "\n";
             }
         }
     }
     return $html;
 }
Пример #19
0
 /**
  * @return array
  */
 public static function getThemes()
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $files = Folder::all('gantry-themes://', ['recursive' => false]);
     /** @var array|ThemeDetails[] $list */
     $list = [];
     ksort($files);
     foreach ($files as $theme) {
         if (!is_dir($theme)) {
             continue;
         }
         if ($locator('gantry-themes://' . $theme . '/gantry/theme.yaml')) {
             $details = new ThemeDetails($theme);
             // Stream needs to be valid URL.
             $streamName = 'gantry-themes-' . preg_replace('|[^a-z\\d+.-]|ui', '-', $theme);
             if (!$locator->schemeExists($streamName)) {
                 $locator->addPath($streamName, '', $details->getPaths());
             }
             $details['name'] = $theme;
             $details['title'] = $details['details.name'];
             $details['preview_url'] = $locator('gantry-themes://' . $theme);
             // FIXME:
             $details['admin_url'] = 'FIXME';
             $details['params'] = [];
             $list[$details->name] = $details;
         }
     }
     // Add Thumbnails links after adding all the paths to the locator.
     foreach ($list as $details) {
         $details['thumbnail'] = $details->getUrl("details.images.thumbnail");
     }
     return $list;
 }
Пример #20
0
 public function process()
 {
     if (!parent::process()) {
         $this->redirectNoSession();
     }
     $containers = array();
     $containerClassFiles = scandir(\base_config::$baseDir . '/inc/dashcontainers/');
     foreach ($containerClassFiles as $containerClassFile) {
         if (strpos($containerClassFile, '.php') === false) {
             continue;
         }
         $containerClassFile = str_replace('.php', '', $containerClassFile);
         $containerObject = new $containerClassFile($this);
         if (is_a($containerObject, '\\interfaces\\dashcontainer')) {
             $containerPosition = $containerObject->getPosition();
             if (isset($containers[$containerPosition])) {
                 $containerPosition++;
             }
             $containers[$containerPosition] = new \model\dashboard_container($containerObject->getBoxName(), $containerObject->getBoxHeadline(), $containerObject->getBoxContent(), $containerObject->getSize(), $containerObject->getHeight());
         } else {
             $message = \language::replaceLanguageConstant(\language::returnLanguageConstant('DASH_CONTAINER_INSTANCE'), array('{{dashcontainer}}' => $containerClassFile));
             \messages::registerError($message);
         }
     }
     if (count($containers) >= 1) {
         ksort($containers);
     }
     $view = new \model\view_acp('dashboard');
     $view->assign('statsContainers', $containers);
     $view->render();
 }
Пример #21
0
 /**
  * {@inheritdoc}
  *
  * @throws \LogicException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->validateInput($input);
     $this->containerBuilder = $this->getContainerBuilder();
     if ($input->getOption('parameters')) {
         $parameters = $this->getContainerBuilder()->getParameterBag()->all();
         // Sort parameters alphabetically
         ksort($parameters);
         $this->outputParameters($output, $parameters);
         return;
     }
     $parameter = $input->getOption('parameter');
     if (null !== $parameter) {
         $output->write($this->formatParameter($this->getContainerBuilder()->getParameter($parameter)));
         return;
     }
     if ($input->getOption('tags')) {
         $this->outputTags($output, $input->getOption('show-private'));
         return;
     }
     $tag = $input->getOption('tag');
     if (null !== $tag) {
         $serviceIds = array_keys($this->containerBuilder->findTaggedServiceIds($tag));
     } else {
         $serviceIds = $this->containerBuilder->getServiceIds();
     }
     // sort so that it reads like an index of services
     asort($serviceIds);
     $name = $input->getArgument('name');
     if ($name) {
         $this->outputService($output, $name);
     } else {
         $this->outputServices($output, $serviceIds, $input->getOption('show-private'), $tag);
     }
 }
Пример #22
0
 public function __construct()
 {
     // Carbon Language
     Carbon::setLocale('tr');
     // create home page if non exist
     count(Menu::where('slug', '/anasayfa')->get()) == 0 ? Menu::create(['title' => 'Anasayfa', 'slug' => '/anasayfa', 'eng_title' => 'Home', 'eng_slug' => '/home'])->save() : null;
     // create config file if non exist
     !\File::exists(storage_path('.config')) ? \File::put(storage_path('.config'), json_encode(['brand' => 'Brand Name', 'mail' => '*****@*****.**', 'active' => 1, 'eng' => '0', 'one_page' => '0', 'googlemap' => '', 'header' => ''])) : null;
     $this->config = json_decode(\File::get(storage_path('.config')));
     !\File::exists(storage_path('app/custom/css')) ? \File::makeDirectory(storage_path('app/custom/css'), 0755, true) : null;
     !\File::exists(storage_path('app/custom/js')) ? \File::makeDirectory(storage_path('app/custom/js'), 0755, true) : null;
     // get css & js files from custom folder
     // css
     $css = \File::allFiles(storage_path('app/custom/css'));
     if (!empty($css)) {
         foreach ($css as $cs) {
             $this->css[$cs->getCtime()] = $cs->getRelativePathname();
         }
         // sort by date
         ksort($this->css);
     }
     // js
     $js = \File::allFiles(storage_path('app/custom/js'));
     if (!empty($js)) {
         foreach ($js as $j) {
             $this->js[$j->getCtime()] = $j->getRelativePathname();
         }
         // sort by date
         ksort($this->js);
     }
 }
 public function __construct(array $outputs, $confirms = 1)
 {
     $this->data = $outputs;
     $this->minimumConfirms = $confirms;
     $this->total = count($outputs);
     // do calculation only if at least 1 output
     if ($this->total > 0) {
         $amounts = array_column($outputs, 'amount');
         $this->amountsSum = array_sum($amounts);
         $amountPairs = [];
         foreach ($amounts as $amount) {
             $amount = (string) $amount;
             // cast float to string, because array_key_exists can handle only string or integer
             // if key exists, then add +1 to value that means that amount already was counted
             if (array_key_exists($amount, $amountPairs)) {
                 $amountPairs[$amount] = $amountPairs[$amount] + 1;
             } else {
                 // new result, just add initial 1
                 $amountPairs[$amount] = 1;
             }
         }
         $this->amountPairs = $amountPairs;
         ksort($this->amountPairs);
         // sort incrementing by amount
     }
 }
Пример #24
0
    /**
     * Print all options
     * 
     * @return void
     * @since 1.0.0
     */
    public function display_page()
    {
        $this->get_header('theme_option');
        $this->get_form(array('id' => 'theme_option', 'action' => 'panel', 'subpage' => strtolower(str_replace('YIT_Submenu_', '', get_class($this)))));
        foreach ($this->_tabClasses as $slug => $fields) {
            ?>
        <div id="yit_<?php 
            echo $slug;
            ?>
" class="yit-box">
            <div class="yit-options">
                <?php 
            ksort($fields->fields);
            foreach ($fields->fields as $priority => $tab) {
                if ($priority < 0) {
                    continue;
                }
                YIT_Type::display($tab);
            }
            ?>
            </div>
        </div>
        <?php 
        }
        $this->get_footer();
    }
Пример #25
0
 public function getModules()
 {
     $my_modules = array();
     $nodes = Kernel::getMyNodes();
     if (sizeof($nodes)) {
         foreach ($nodes as $node_key => $node) {
             $modules = Kernel::getModEnabled($node->type, $node->id, _currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
             foreach ($modules as $modules_key => $module) {
                 if ($module->module_type != "MOD_PREFS" && preg_match('#^MOD_(.+)$#', $module->module_type, $regs)) {
                     $mod_tmp = new CopixPPO();
                     $mod_tmp->type = $module->module_type;
                     $mod_tmp->nom = $module->module_nom;
                     $mod_tmp->rep = strtolower($regs[1]);
                     $my_modules[$module->module_type] = $mod_tmp;
                     unset($mod_tmp);
                 }
             }
         }
     }
     ksort($my_modules);
     $pref_module['MOD_PREFS'] = new CopixPPO();
     $pref_module['MOD_PREFS']->type = 'MOD_PREFS';
     $pref_module['MOD_PREFS']->nom = CopixI18N::get('prefs|prefs.string.generalprefs');
     $pref_module['MOD_PREFS']->rep = 'prefs';
     $all_modules = array_merge($pref_module, $my_modules);
     return $all_modules;
 }
Пример #26
0
 public function getMainMenu()
 {
     $modulesDb = new Application_Model_DbTable_Module();
     $modules = $modulesDb->fetchAll();
     $mainmenu = array();
     foreach ($modules as $module) {
         if ($module->active && $module->menu) {
             $data = Zend_Json::decode($module->menu);
             foreach ($data as $key => $value) {
                 if (isset($mainmenu[$key]['childs'])) {
                     foreach ($value['childs'] as $ordering => $child) {
                         $mainmenu[$key]['childs'][$ordering] = $child;
                     }
                 } else {
                     $mainmenu[$key] = $value;
                 }
             }
         }
     }
     foreach ($mainmenu as $key => $value) {
         if (isset($value['childs'])) {
             ksort($mainmenu[$key]['childs']);
         }
     }
     return $mainmenu;
 }
 protected function _getAll()
 {
     $result = array();
     $_temp = array();
     global $wpdb;
     $key_prefix = $this->_getOptionName('');
     $terms = $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE '{$key_prefix}%'");
     foreach ($terms as $term) {
         if (is_serialized($term->option_value)) {
             $_term = unserialize($term->option_value);
             $key = str_replace($key_prefix, '', $term->option_name);
             if (trim($_term['description'])) {
                 $_temp[$_term['description']][] = array('key' => $key, 'term' => $_term);
             } else {
                 $_temp[] = array('key' => $key, 'term' => $_term);
             }
         }
     }
     ksort($_temp);
     foreach ($_temp as $temp) {
         if (!isset($temp['key'])) {
             foreach ($temp as $t) {
                 $result[$t['key']] = $t['term'];
             }
         } else {
             $result[$temp['key']] = $temp['term'];
         }
     }
     return $result;
 }
Пример #28
0
 public static function getPopularTags($max = 30)
 {
     $connection = Propel::getConnection();
     $query = 'SELECT %s as query, COUNT(*) as count
           FROM %s
           INNER JOIN %s ON %s = %s
           INNER JOIN %s ON %s = %s
           WHERE %s = %s
           GROUP BY query
           ORDER BY count DESC';
     $query = sprintf($query, QueryPeer::QUERY, QueryPeer::TABLE_NAME, ReportQueryPeer::TABLE_NAME, QueryPeer::ID, ReportQueryPeer::QUERY_ID, ReportPeer::TABLE_NAME, ReportQueryPeer::REPORT_ID, ReportPeer::ID, ReportPeer::PUBLIC_RECORD, true);
     $statement = $connection->prepareStatement($query);
     $statement->setLimit($max);
     $resultset = $statement->executeQuery();
     $tags = array();
     $max_count = 0;
     while ($resultset->next()) {
         if (!$max_count) {
             $max_count = $resultset->getInt('count');
         }
         $queries[] = array('query' => $resultset->getString('query'), 'rank' => floor($resultset->getInt('count') / $max_count * 9 + 1), 'count' => $resultset->getInt('count'));
     }
     ksort($queries);
     return $queries;
 }
 /**
  * Creates a Redisent interface to a cluster of Redis servers
  * @param array $servers The Redis servers in the cluster. Each server should be in the format array('host' => hostname, 'port' => port)
  */
 function __construct($servers)
 {
     $this->ring = array();
     $this->aliases = array();
     foreach ($servers as $alias => $server) {
         $this->redisents[] = new Redisent($server['host'], $server['port']);
         if (is_string($alias)) {
             // 用key作为alias标记redis实例
             $this->aliases[$alias] = $this->redisents[count($this->redisents) - 1];
         }
         for ($replica = 1; $replica <= $this->replicas; $replica++) {
             // crc32 — 计算一个字符串的 crc32 多项式,生成 str 的 32 位循环冗余校验码多项式。这通常用于检查传输的数据是否完整。返回值为int类型。
             $this->ring[crc32($server['host'] . ':' . $server['port'] . '-' . $replica)] = $this->redisents[count($this->redisents) - 1];
         }
     }
     // ksort — 对数组按照键名排序
     // 排序类型标记:
     // SORT_REGULAR - 正常比较单元(不改变类型)
     // SORT_NUMERIC - 单元被作为数字来比较
     // SORT_STRING - 单元被作为字符串来比较
     // SORT_LOCALE_STRING - 根据当前的区域(locale)设置来把单元当作字符串比较,可以用 setlocale() 来改变。
     // SORT_NATURAL - 和 natsort() 类似对每个单元以“自然的顺序”对字符串进行排序。 PHP 5.4.0 中新增的。
     // SORT_FLAG_CASE - 能够与 SORT_STRING 或 SORT_NATURAL 合并(OR 位运算),不区分大小写排序字符串。
     ksort($this->ring, SORT_NUMERIC);
     // 将redis实例集合的索引放到$this->nodes中
     $this->nodes = array_keys($this->ring);
 }
Пример #30
0
 public function isValidCall()
 {
     if (!$this->request->request->has('SHASIGN') && !$this->request->query->has('SHASIGN')) {
         return false;
     }
     // Check sign
     $toSign = array();
     if ($this->request->query->has('SHASIGN')) {
         foreach ($this->request->query->all() as $key => $val) {
             if ($val != '') {
                 $toSign[strtoupper($key)] = $val;
             }
         }
     } else {
         foreach ($this->request->request->all() as $key => $val) {
             if ($val != '') {
                 $toSign[strtoupper($key)] = $val;
             }
         }
     }
     unset($toSign["SHASIGN"]);
     ksort($toSign);
     $toHash = '';
     foreach ($toSign as $key => $val) {
         $toHash .= $key . '=' . $val . $this->secureConfigurationContainer->getShaOutKey();
     }
     return $this->request->get('SHASIGN') === strtoupper(hash($this->secureConfigurationContainer->getAlgorithm(), $toHash));
 }