コード例 #1
1
/**
 * determines the langauge settings of the browser, details see here:
 * http://aktuell.de.selfhtml.org/artikel/php/httpsprache/
 */
function lang_getfrombrowser($allowed_languages, $default_language, $lang_variable = null, $strict_mode = true)
{
    // $_SERVER['HTTP_ACCEPT_LANGUAGE'] verwenden, wenn keine Sprachvariable mitgegeben wurde
    if ($lang_variable === null && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        $lang_variable = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
    }
    // wurde irgendwelche Information mitgeschickt?
    if (empty($lang_variable)) {
        // Nein? => Standardsprache zurückgeben
        return $default_language;
    }
    // Den Header auftrennen
    $accepted_languages = preg_split('/,\\s*/', $lang_variable);
    // Die Standardwerte einstellen
    $current_lang = $default_language;
    $current_q = 0;
    // Nun alle mitgegebenen Sprachen abarbeiten
    foreach ($accepted_languages as $accepted_language) {
        // Alle Infos über diese Sprache rausholen
        $res = preg_match('/^([a-z]{1,8}(?:-[a-z]{1,8})*)' . '(?:;\\s*q=(0(?:\\.[0-9]{1,3})?|1(?:\\.0{1,3})?))?$/i', $accepted_language, $matches);
        // war die Syntax gültig?
        if (!$res) {
            // Nein? Dann ignorieren
            continue;
        }
        // Sprachcode holen und dann sofort in die Einzelteile trennen
        $lang_code = explode('-', $matches[1]);
        // Wurde eine Qualität mitgegeben?
        if (isset($matches[2])) {
            // die Qualität benutzen
            $lang_quality = (double) $matches[2];
        } else {
            // Kompabilitätsmodus: Qualität 1 annehmen
            $lang_quality = 1.0;
        }
        // Bis der Sprachcode leer ist...
        while (count($lang_code)) {
            // mal sehen, ob der Sprachcode angeboten wird
            if (in_array(strtolower(join('-', $lang_code)), $allowed_languages)) {
                // Qualität anschauen
                if ($lang_quality > $current_q) {
                    // diese Sprache verwenden
                    $current_lang = strtolower(join('-', $lang_code));
                    $current_q = $lang_quality;
                    // Hier die innere while-Schleife verlassen
                    break;
                }
            }
            // Wenn wir im strengen Modus sind, die Sprache nicht versuchen zu minimalisieren
            if ($strict_mode) {
                // innere While-Schleife aufbrechen
                break;
            }
            // den rechtesten Teil des Sprachcodes abschneiden
            array_pop($lang_code);
        }
    }
    // die gefundene Sprache zurückgeben
    return $current_lang;
}
コード例 #2
0
ファイル: markup.php プロジェクト: shreyanshgoel/blog
 public static function errors($array, $key, $separator = "<br />", $before = "<br />", $after = "")
 {
     if (isset($array[$key])) {
         return $before . join($separator, $array[$key]) . $after;
     }
     return "";
 }
コード例 #3
0
ファイル: example.php プロジェクト: rusli-nasir/hospitalPhp
	function service($text)
	{
		$text = str_replace("\\\"","\"",$text);
		$token = explode(",",$text);
		$last_token = $token[sizeof($token)-1];
		$last_token = trim($last_token);
		$items = array();		
		$result = mysql_query("select firstName, lastName, email from employees where CONCAT(firstName,' ',lastName,' ', email) like '%$last_token%' order by email;");
		
		while($row = mysql_fetch_assoc($result))
		{

			$text = '"'.$row["firstName"]." ".$row["lastName"].'"'."<".$row["email"].">";
			$text_array = $token;
			$text_array[sizeof($text_array)-1] = $text;
			$text = join(",",$text_array);			
			
			$html = '"'.$row["firstName"]." ".$row["lastName"].'"'."[".$row["email"]."]";
			$html = preg_replace("/".$last_token."/i","<b>$last_token</b>",$html);
			$html = str_replace("[","&lt;",$html);
			$html = str_replace("]","&gt;",$html);
			
			$item = array("text"=>$text,"html"=>$html);
			array_push($items,$item);
		}
		return $items;
	}
コード例 #4
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $currencies = join(',', array_keys(config('base.currencies')));
     $term_types = join(',', array_keys(config('base.term_types')));
     $movement_types = join(',', array_keys(config('base.movement_types')));
     return ['coverage' => 'required|exists:ad_coverages,id', 'amount_requested' => 'required|numeric|min:1', 'currency' => 'required|in:' . $currencies, 'term' => 'required|integer|min:1', 'type_term' => 'required|in:' . $term_types, 'credit_product' => 'required|exists:ad_credit_products,id', 'movement_type' => 'required|in:' . $movement_types];
 }
コード例 #5
0
function wp_ajax_ajax_tag_search()
{
    global $wpdb;
    if (isset($_GET['tax'])) {
        $taxonomy = sanitize_key($_GET['tax']);
        $tax = get_taxonomy($taxonomy);
        if (!$tax) {
            wp_die(0);
        }
        if (!current_user_can($tax->cap->assign_terms)) {
            wp_die(-1);
        }
    } else {
        wp_die(0);
    }
    $s = stripslashes($_GET['q']);
    $comma = _x(',', 'tag delimiter');
    if (',' !== $comma) {
        $s = str_replace($comma, ',', $s);
    }
    if (false !== strpos($s, ',')) {
        $s = explode(',', $s);
        $s = $s[count($s) - 1];
    }
    $s = trim($s);
    if (strlen($s) < 2) {
        wp_die();
    }
    // require 2 chars for matching
    $results = $wpdb->get_col($wpdb->prepare("SELECT t.name FROM {$wpdb->term_taxonomy} AS tt INNER JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, '%' . like_escape($s) . '%'));
    echo join($results, "\n");
    wp_die();
}
コード例 #6
0
ファイル: feed.php プロジェクト: TyRichards/ty_the_band
/**
 * Retrieve a venue's location suitable for an iCal feed.
 *
 * @since 1.0.0
 *
 * @param int|object $post Venue post ID or object.
 * @return string Venue iCal vCard.
 */
function get_audiotheme_venue_location_ical($venue = null)
{
    $venue = get_audiotheme_venue($venue);
    $output = $venue->name;
    $address = array();
    if (!empty($venue->address)) {
        $address[] = $venue->address;
    }
    $locality = empty($venue->city) ? '' : $venue->city;
    $locality .= empty($locality) && empty($venue->state) ? '' : ', ';
    $locality .= empty($venue->state) ? '' : $venue->state;
    if (!empty($locality)) {
        $address[] = $locality;
    }
    if (!empty($venue->country)) {
        $address[] = $venue->country;
    }
    if (!empty($venue->postal_code)) {
        $address[] = $venue->postal_code;
    }
    if (!empty($address)) {
        $output .= ', ' . join($address, ', ');
    }
    return escape_ical_text($output);
}
コード例 #7
0
 /**
  * Prepare template for single add field
  *
  * @param      $field
  * @param bool $isLast
  * @return string
  */
 protected function prepareAdd($field, $isLast = false)
 {
     $field = trim($field);
     list($name, $type) = explode(':', $field);
     $textArr = ["            ->add('", $name, "', '", $type, "')", $isLast ? "" : "\n"];
     return join('', $textArr);
 }
コード例 #8
0
 /**
  * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
  * @magentoDbIsolation enabled
  * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1
  * @dataProvider saveActionDataProvider
  * @param array $inputData
  * @param array $defaultAttributes
  * @param array $attributesSaved
  * @param bool $isSuccess
  */
 public function testSaveAction($inputData, $defaultAttributes, $attributesSaved = [], $isSuccess = true)
 {
     /** @var $store \Magento\Store\Model\Store */
     $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Store\\Model\\Store');
     $store->load('fixturestore', 'code');
     $storeId = $store->getId();
     $this->getRequest()->setPostValue($inputData);
     $this->getRequest()->setParam('store', $storeId);
     $this->getRequest()->setParam('id', 2);
     $this->dispatch('backend/catalog/category/save');
     if ($isSuccess) {
         $this->assertSessionMessages($this->equalTo(['You saved the category.']), \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS);
     }
     /** @var $category \Magento\Catalog\Model\Category */
     $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Category');
     $category->setStoreId($storeId);
     $category->load(2);
     $errors = [];
     foreach ($attributesSaved as $attribute => $value) {
         $actualValue = $category->getData($attribute);
         if ($value !== $actualValue) {
             $errors[] = "value for '{$attribute}' attribute must be '{$value}'" . ", but '{$actualValue}' is found instead";
         }
     }
     foreach ($defaultAttributes as $attribute => $exists) {
         if ($exists !== $category->getExistsStoreValueFlag($attribute)) {
             if ($exists) {
                 $errors[] = "custom value for '{$attribute}' attribute is not found";
             } else {
                 $errors[] = "custom value for '{$attribute}' attribute is found, but default one must be used";
             }
         }
     }
     $this->assertEmpty($errors, "\n" . join("\n", $errors));
 }
コード例 #9
0
ファイル: Walker_nav_menu.php プロジェクト: alispx/calibrefx
 function start_el(&$output, $item, $depth = 0, $args = array(), $current_object_id = 0)
 {
     global $wp_query;
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $class_names = $value = '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = 'menu-item-' . $item->ID;
     if ($args->has_children) {
         $classes[] = 'dropdown';
     }
     $icon_html = '';
     if (isset($item->custom_icon) && !empty($item->custom_icon)) {
         $icon_html = '<i class="' . $item->custom_icon . '"></i><span>&nbsp;&nbsp;</span>';
     }
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
     $class_names = ' class="' . esc_attr($class_names) . '"';
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
     $id = strlen($id) ? ' id="' . esc_attr($id) . '"' : '';
     $output .= $indent . '<li' . $id . $value . $class_names . '>';
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . $icon_html . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }
コード例 #10
0
ファイル: css.php プロジェクト: noccy80/lepton-ng
 public function read(DOMElement $e) {
     $tn = end(explode(':',$e->tagName));
     switch($tn) {
       case 'function':
       
         foreach($e->childNodes as $cnn) {
             if (typeOf($cnn) == 'DOMElement') {
                 $cnt = end(explode(':',$cnn->tagName));
                 if ($cnt == 'from') {
                     $this->from[] = $cnn->nodeValue;
                 } elseif ($cnt == 'to') {
                     $this->to = $cnn->nodeValue;
                 } else {
                     printf("Warning: Didn't expect %s here\n", $cnn->nodeName); 
                 }
             }
         }
         
         printf(__astr("[\b{phprefactor}] Refactoring{%s} --> %s\n"), join(', ',$this->from), $this->to);
         break;
         
       default:
         printf("I don't know what to do with %s!\n", $tn);
         
     }
 }
コード例 #11
0
 /**
  * Call external Method
  *
  * @param \Smarty_Internal_Data $data
  * @param string                $name external method names
  * @param array                 $args argument array
  *
  * @return mixed
  * @throws SmartyException
  */
 public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args)
 {
     /* @var Smarty $data ->smarty */
     $smarty = isset($data->smarty) ? $data->smarty : $data;
     if (!isset($smarty->ext->{$name})) {
         $class = 'Smarty_Internal_Method_' . ucfirst($name);
         if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
             if (!isset($this->_property_info[$prop = $match[2]])) {
                 // convert camel case to underscored name
                 $this->resolvedProperties[$prop] = $pn = strtolower(join('_', preg_split('/([A-Z][^A-Z]*)/', $prop, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)));
                 $this->_property_info[$prop] = property_exists($data, $pn) ? 1 : ($data->_objType == 2 && property_exists($smarty, $pn) ? 2 : 0);
             }
             if ($this->_property_info[$prop]) {
                 $pn = $this->resolvedProperties[$prop];
                 if ($match[1] == 'get') {
                     return $this->_property_info[$prop] == 1 ? $data->{$pn} : $data->smarty->{$pn};
                 } else {
                     return $this->_property_info[$prop] == 1 ? $data->{$pn} = $args[0] : ($data->smarty->{$pn} = $args[0]);
                 }
             } elseif (!class_exists($class)) {
                 throw new SmartyException("property '{$pn}' does not exist.");
             }
         }
         if (class_exists($class)) {
             $callback = array($smarty->ext->{$name} = new $class(), $name);
         }
     } else {
         $callback = array($smarty->ext->{$name}, $name);
     }
     array_unshift($args, $data);
     if (isset($callback) && $callback[0]->objMap | $data->_objType) {
         return call_user_func_array($callback, $args);
     }
     return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args);
 }
コード例 #12
0
 public static function getLoader()
 {
     if (null !== self::$loader) {
         return self::$loader;
     }
     spl_autoload_register(array('ComposerAutoloaderInit0ff06a20d13931ad3d71bf10770c91f3', 'loadClassLoader'), true, true);
     self::$loader = $loader = new \Composer\Autoload\ClassLoader();
     spl_autoload_unregister(array('ComposerAutoloaderInit0ff06a20d13931ad3d71bf10770c91f3', 'loadClassLoader'));
     $vendorDir = dirname(__DIR__);
     $baseDir = dirname($vendorDir);
     $includePaths = (require __DIR__ . '/include_paths.php');
     array_push($includePaths, get_include_path());
     set_include_path(join(PATH_SEPARATOR, $includePaths));
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->set($namespace, $path);
     }
     $map = (require __DIR__ . '/autoload_psr4.php');
     foreach ($map as $namespace => $path) {
         $loader->setPsr4($namespace, $path);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register(true);
     $includeFiles = (require __DIR__ . '/autoload_files.php');
     foreach ($includeFiles as $file) {
         composerRequire0ff06a20d13931ad3d71bf10770c91f3($file);
     }
     return $loader;
 }
コード例 #13
0
ファイル: Algos.php プロジェクト: hongbo819/APILJL
 /**
  * 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;
 }
コード例 #14
0
ファイル: textbin.php プロジェクト: igorsimdyanov/php7
function makeHex($st)
{
    for ($i = 0; $i < strlen($st); $i++) {
        $hex[] = sprintf("%02X", ord($st[$i]));
    }
    return join(" ", $hex);
}
コード例 #15
0
ファイル: TextNotifier.php プロジェクト: avramishin/alishop
 public function notify($errno, $errstr, $errfile, $errline, $trace)
 {
     $body = array();
     $body[] = $this->_makeSection("", join("\n", array(@$_SERVER['GATEWAY_INTERFACE'] ? "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" : "", "{$errno}: {$errstr}", "at {$errfile} on line {$errline}")));
     if ($this->_whatToLog & self::LOG_TRACE && $trace) {
         $body[] = $this->_makeSection("TRACE", Debug_ErrorHook_Util::backtraceToString($trace));
     }
     /*if ($this->_whatToLog & self::LOG_SERVER) {
           $body[] = $this->_makeSection("SERVER", Debug_ErrorHook_Util::varExport($_SERVER));
       }*/
     if (!empty($_COOKIE) && $this->_whatToLog & self::LOG_COOKIE) {
         $body[] = $this->_makeSection("COOKIES", Debug_ErrorHook_Util::varExport($_COOKIE));
     }
     if (!empty($_GET) && $this->_whatToLog & self::LOG_GET) {
         $body[] = $this->_makeSection("GET", Debug_ErrorHook_Util::varExport($_GET));
     }
     if (!empty($_POST) && $this->_whatToLog & self::LOG_POST) {
         $body[] = $this->_makeSection("POST", Debug_ErrorHook_Util::varExport($_POST));
     }
     if (!empty($_SESSION) && $this->_whatToLog & self::LOG_SESSION) {
         $body[] = $this->_makeSection("SESSION", Debug_ErrorHook_Util::varExport(@$_SESSION));
     }
     // Append body suffix?
     $suffix = $this->_bodySuffix && is_callable($this->_bodySuffix) ? call_user_func($this->_bodySuffix) : $this->_bodySuffix;
     if ($suffix) {
         $body[] = $this->_makeSection("ADDITIONAL INFO", $suffix);
     }
     // Remain only 1st line for subject.
     $errstr = preg_replace("/\r?\n.*/s", '', $errstr);
     $this->_notifyText("{$errno}: {$errstr} at {$errfile} on line {$errline}", join("\n", $body));
 }
コード例 #16
0
ファイル: PDO.php プロジェクト: uedcw/webstory
 public function exec($statement)
 {
     if (isset($this->dsn) and stristr($this->dsn, 'anjuke_db') and preg_match('/\\sajk_propertys\\s/i', $statement)) {
         if (stristr($statement, 'select CITYID') or stristr($statement, 'insert') or stristr($statement, 'update ')) {
         } else {
             $dir = '/home/www/logs/propsql';
             if (!is_dir($dir)) {
                 mkdir($dir, 0755, true);
                 $content = '-=-=-=-=-=-=-=-=-=-=' . PHP_EOL;
                 $content .= 'DSN: ' . $this->dsn . PHP_EOL;
                 $content .= 'URI: ' . $_SERVER['REQUEST_URI'] . PHP_EOL;
                 $content .= 'JOB: ' . var_export($_SERVER['argv'], true) . PHP_EOL;
                 $content .= 'SQL: ' . $statement . PHP_EOL;
                 file_put_contents($dir . '/' . date('Ymd'), $content, FILE_APPEND);
             }
         }
     }
     if (APF::get_instance()->is_debug_enabled()) {
         APF::get_instance()->debug(__CLASS__ . '[' . $this->name . ']' . "->exec: {$statement}");
     }
     $logger = APF::get_instance()->get_logger();
     $logger->debug(__CLASS__, '[' . $this->name . ']->exec: ', $statement);
     $stmt = parent::exec($statement);
     if ($stmt instanceof PDOStatement) {
         $stmt->setFetchMode($this->default_fetch_mode);
     } else {
         $error_info = parent::errorInfo();
         if (parent::errorCode() !== '00000') {
             throw new APF_Exception_SqlException(parent::errorCode(), $this->get_name() . ' | ' . $this->config['dsn'] . ' | ' . $statement . ' | ' . join(' | ', $error_info));
         }
     }
     return $stmt;
 }
コード例 #17
0
ファイル: youtube.php プロジェクト: jahrmando/botijon
 public function process($args)
 {
     $this->output = "";
     if (strlen(trim($args)) > 0) {
         try {
             $url = "https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&maxResults=3&type=video&q=" . urlencode($args) . "&key=" . $this->apikey;
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
             $respuesta = curl_exec($ch);
             curl_close($ch);
             $resultados = json_decode($respuesta);
             if (isset($resultados->error)) {
                 $this->output = "Ocurrió un problema al realizar la busqueda: " . $resultados->error->errors[0]->reason;
             } else {
                 if (count($resultados->items) > 0) {
                     $videos = array();
                     foreach ($resultados->items as $video) {
                         array_push($videos, "http://www.youtube.com/watch?v=" . $video->id->videoId . " - " . $video->snippet->title);
                     }
                     $this->output = join("\n", $videos);
                 } else {
                     $this->output = "No se pudieron obtener resultados al realizar la busqueda indicada.";
                 }
             }
         } catch (Exception $e) {
             $this->output = "Ocurrió un problema al realizar la busqueda: " . $e->getMessage();
         }
     } else {
         $this->output = "Digame que buscar que no soy adivino.";
     }
 }
コード例 #18
0
ファイル: autoload_real.php プロジェクト: ever4vr/maestro
 public static function getLoader()
 {
     if (null !== self::$loader) {
         return self::$loader;
     }
     spl_autoload_register(array('ComposerAutoloaderInit1eb5cffb2cab52b785cc53528b1e13a2', 'loadClassLoader'), true, true);
     self::$loader = $loader = new \Composer\Autoload\ClassLoader();
     spl_autoload_unregister(array('ComposerAutoloaderInit1eb5cffb2cab52b785cc53528b1e13a2', 'loadClassLoader'));
     $includePaths = (require __DIR__ . '/include_paths.php');
     array_push($includePaths, get_include_path());
     set_include_path(join(PATH_SEPARATOR, $includePaths));
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->set($namespace, $path);
     }
     $map = (require __DIR__ . '/autoload_psr4.php');
     foreach ($map as $namespace => $path) {
         $loader->setPsr4($namespace, $path);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register(true);
     return $loader;
 }
コード例 #19
0
ファイル: Cron.php プロジェクト: nja78/magento2
 /**
  * Cron settings after save
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function afterSave()
 {
     $enabled = $this->getData('groups/log/fields/enabled/value');
     $time = $this->getData('groups/log/fields/time/value');
     $frequency = $this->getData('groups/log/fields/frequency/value');
     $frequencyWeekly = \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY;
     $frequencyMonthly = \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY;
     if ($enabled) {
         $cronExprArray = [intval($time[1]), intval($time[0]), $frequency == $frequencyMonthly ? '1' : '*', '*', $frequency == $frequencyWeekly ? '1' : '*'];
         $cronExprString = join(' ', $cronExprArray);
     } else {
         $cronExprString = '';
     }
     try {
         /** @var $configValue \Magento\Framework\App\Config\ValueInterface */
         $configValue = $this->_configValueFactory->create();
         $configValue->load(self::CRON_STRING_PATH, 'path');
         $configValue->setValue($cronExprString)->setPath(self::CRON_STRING_PATH)->save();
         /** @var $configValue \Magento\Framework\App\Config\ValueInterface */
         $configValue = $this->_configValueFactory->create();
         $configValue->load(self::CRON_MODEL_PATH, 'path');
         $configValue->setValue($this->_runModelPath)->setPath(self::CRON_MODEL_PATH)->save();
     } catch (\Exception $e) {
         throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t save the Cron expression.'));
     }
 }
コード例 #20
0
 function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     global $wp_query;
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $class_names = $value = '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item));
     $class_names = ' class="' . esc_attr($class_names) . '"';
     $output .= $indent . '<li id="shopkeeper-menu-item-' . $item->ID . '"' . $value . $class_names . '>';
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     $prepend = '';
     $append = '';
     //$description  = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';
     if ($depth != 0) {
         $description = $append = $prepend = "";
     }
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . $prepend . apply_filters('the_title', $item->title, $item->ID) . $append;
     //$item_output .= $description.$args->link_after;
     //$item_output .= ' '.$item->background_url.'</a>';
     $item_output .= '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
     apply_filters('walker_nav_menu_start_lvl', $item_output, $depth, $args->background_url = $item->background_url);
 }
コード例 #21
0
 public function render($placeholder, array $options = array())
 {
     $dataString = '';
     $optionsString = '';
     //{ label: "sin(x)",  data: d1}
     $list = array();
     foreach ($this->getDatas() as $item) {
         $datas = array();
         foreach ($item[self::FIELD_DATA] as $key => $value) {
             $datas[] = '[' . $key . ', ' . $value . ']';
         }
         $optionsList = array();
         foreach ($item as $name => $value) {
             if ($name == self::FIELD_DATA) {
                 continue;
             }
             $optionsList[] = $name . ':"' . $value . '"';
         }
         $list[] = '    {' . join(', ', $optionsList) . (!empty($optionsList) ? ', ' : '') . 'data: [' . join(', ', $datas) . ']}';
     }
     $dataString = '[' . PHP_EOL . join(', ', $list) . PHP_EOL . ']';
     $buffer = '$.plot($("' . $placeholder . '"),' . PHP_EOL;
     $buffer .= $dataString . PHP_EOL;
     $buffer .= $optionsString ? ', ' . $optionsString . PHP_EOL : '';
     $buffer .= ');';
     return $buffer;
 }
コード例 #22
0
ファイル: SitemapRepository.php プロジェクト: Okipa/una.app
 /**
  * @return string
  */
 public function buildSiteMap()
 {
     // we get all site pages
     $site_pages = $this->getSitePages();
     // we only take the last mod column from the site pages
     $dates = array_column($site_pages, 'last_mod');
     // we sort it
     sort($dates);
     // we get the website last modification date
     $lastmod = last($dates);
     // we get the base url from the website
     $url = route('home');
     $xml = [];
     $xml[] = '<?xml version="1.0" encoding="UTF-8"?' . '>';
     $xml[] = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     $xml[] = '  <url>';
     $xml[] = "    <loc>{$url}</loc>";
     $xml[] = "    <lastmod>{$lastmod}</lastmod>";
     $xml[] = '    <changefreq>daily</changefreq>';
     $xml[] = '    <priority>0.8</priority>';
     $xml[] = '  </url>';
     foreach ($site_pages as $page) {
         $xml[] = "  <url>";
         $xml[] = "    <loc>{$page['url']}</loc>";
         $xml[] = "    <lastmod>{$page['last_mod']}</lastmod>";
         $xml[] = "  </url>";
     }
     $xml[] = '</urlset>';
     return join("\n", $xml);
 }
コード例 #23
0
 public function index()
 {
     $opus = D('Opus');
     //实例化问题表
     $user = D('User');
     //实例化用户表
     //dump(I('get.'));
     /*姓名判断*/
     if (I('get.user')) {
         $name = I('get.user');
         $map['name'] = array('exp', "like '%{$name}%' ");
         $ulist = $user->where($map)->select();
         $name = '';
         foreach ($ulist as $key => $value) {
             $name[$key] = $value['id'];
         }
         $where = join(" or 'user_id' = ", $name);
         $map['user_id'] = $where;
         unset($map['name']);
     }
     /*标题判断*/
     if (I('get.title')) {
         $title = I('get.title');
         $map['ques'] = array('exp', "like '%{$title}%' ");
     }
     $total = $opus->where($map)->count();
     $page = new \Think\Page($total, 8);
     $oplist = $opus->where($map)->limit($page->firstRow . ',' . $page->listRows)->getOpus();
     $pageButton = $page->show();
     //dump($oplist);
     $this->assign('list', $oplist);
     $this->assign('pageButton', $pageButton);
     $this->display();
 }
コード例 #24
0
ファイル: Helpers.php プロジェクト: yurykabanov/xsd2blade
 public static function buildRoute($route)
 {
     $result = static::snakeCase(array_shift($route));
     return $result . join("", array_map(function ($e) {
         return "['" . Helpers::snakeCase($e) . "']";
     }, $route));
 }
コード例 #25
0
ファイル: autoload_real.php プロジェクト: robStack/CoDev
 public static function getLoader()
 {
     if (null !== self::$loader) {
         return self::$loader;
     }
     spl_autoload_register(array('ComposerAutoloaderInit46390df264f3e25339b844dea17d85e4', 'loadClassLoader'), true, true);
     self::$loader = $loader = new \Composer\Autoload\ClassLoader();
     spl_autoload_unregister(array('ComposerAutoloaderInit46390df264f3e25339b844dea17d85e4', 'loadClassLoader'));
     $includePaths = (require __DIR__ . '/include_paths.php');
     array_push($includePaths, get_include_path());
     set_include_path(join(PATH_SEPARATOR, $includePaths));
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->set($namespace, $path);
     }
     $map = (require __DIR__ . '/autoload_psr4.php');
     foreach ($map as $namespace => $path) {
         $loader->setPsr4($namespace, $path);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register(true);
     $includeFiles = (require __DIR__ . '/autoload_files.php');
     foreach ($includeFiles as $file) {
         composerRequire46390df264f3e25339b844dea17d85e4($file);
     }
     return $loader;
 }
コード例 #26
0
ファイル: lib_shortcode.php プロジェクト: 1upon0/ui
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);
}
コード例 #27
0
 /**
  * start_el function.
  * 
  * @access public
  * @param mixed &$output
  * @param mixed $item
  * @param int $depth (default: 0)
  * @param array $args (default: array())
  * @param int $id (default: 0)
  * @return void
  */
 function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $li_attributes = '';
     $class_names = $value = '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = $args->has_children ? 'dropdown' : '';
     $classes[] = $item->current || $item->current_item_ancestor ? 'active' : '';
     $classes[] = 'menu-item-' . $item->ID;
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
     $class_names = ' class="' . esc_attr($class_names) . '"';
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
     $id = strlen($id) ? ' id="' . esc_attr($id) . '"' : '';
     $output .= $indent . '<li' . $id . $value . $class_names . $li_attributes . '>';
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     $attributes .= $args->has_children ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= $args->has_children ? ' <b class="caret"></b></a>' : '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }
コード例 #28
0
ファイル: class.php プロジェクト: laiello/mystep-cms
    public static function uninstall()
    {
        global $db, $setting, $admin_cat;
        $info = self::info();
        $db->delete($setting['db']['pre'] . "news_mark");
        $db->exec("drop", "table", $setting['db']['pre'] . "news_mark");
        $db->delete($setting['db']['pre'] . "admin_cat", array("file", "=", "news_mark.php"));
        $db->delete($setting['db']['pre'] . "plugin", array("idx", "=", $info['idx']));
        deleteCache("admin_cat");
        deleteCache("plugin");
        $err = array();
        if ($db->GetError($err)) {
            showInfo($setting['language']['plugin_err_uninstall'] . "\r\n\t\t\t<br />\r\n\t\t\t<pre>\r\n\t\t\t" . join("\n------------------------\n", $err) . "\r\n\t\t\t</pre>\r\n\t\t\t");
        } else {
            includeCache("admin_cat");
            $admin_cat = toJson($admin_cat, $setting['gen']['charset']);
            echo <<<mystep
<script language="javascript">
parent.admin_cat = {$admin_cat};
parent.setNav();
</script>
mystep;
            buildParaList("plugin");
            echo showInfo($setting['language']['plugin_uninstall_done'], false);
        }
    }
コード例 #29
0
ファイル: valider.php プロジェクト: genma/spip_ynh
 function validerAttribut($phraseur, $name, $val, $bal)
 {
     // Si la balise est inconnue, eviter d'insister
     if (!isset($this->dtc->attributs[$bal])) {
         return;
     }
     $a = $this->dtc->attributs[$bal];
     if (!isset($a[$name])) {
         $bons = join(', ', array_keys($a));
         if ($bons) {
             $bons = " title=' " . _T('zxml_connus_attributs') . '&nbsp;: ' . $bons . "'";
         }
         $bons .= " style='font-weight: bold'";
         coordonnees_erreur($this, " <b>{$name}</b> " . _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de') . " <a{$bons}>{$bal}</a> (" . _T('zxml_survoler') . ")");
     } else {
         $type = $a[$name][0];
         if (!preg_match('/^\\w+$/', $type)) {
             $this->valider_motif($phraseur, $name, $val, $bal, $type);
         } else {
             if (method_exists($this, $f = 'validerAttribut_' . $type)) {
                 $this->{$f}($phraseur, $name, $val, $bal);
             }
         }
         #		else spip_log("$type type d'attribut inconnu");
     }
 }
コード例 #30
-7
 function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = 'menu-item-' . $item->ID;
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args, $depth));
     /**
      * Change WP's default classes to match Foundation's required classes
      */
     $class_names = str_replace(array('menu-item-has-children'), array('has-submenu'), $class_names);
     // ==========================
     $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth);
     $id = $id ? ' id="' . esc_attr($id) . '"' : '';
     $output .= $indent . '<li' . $id . $class_names . '>';
     $atts = array();
     $atts['title'] = !empty($item->attr_title) ? $item->attr_title : '';
     $atts['target'] = !empty($item->target) ? $item->target : '';
     $atts['rel'] = !empty($item->xfn) ? $item->xfn : '';
     $atts['href'] = !empty($item->url) ? $item->url : '';
     $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args, $depth);
     $attributes = '';
     foreach ($atts as $attr => $value) {
         if (!empty($value)) {
             $value = 'href' === $attr ? esc_url($value) : esc_attr($value);
             $attributes .= ' ' . $attr . '="' . $value . '"';
         }
     }
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }