/** * Smarty {script src="" type="javascript"} function plugin * * Type: function * Name: * Date: * Purpose: * Examples: {script} * Output: * @link * @author Gerits Aurelien * @version 1.0 * @param array * @param Smarty * @return string */ function smarty_function_script($params, $template) { $src = $params['src']; $type = $params['type']; if (!isset($src)) { trigger_error("src: missing 'src' parameter in link", E_USER_WARNING); return; } if (!isset($type)) { trigger_error("type: missing 'type' parameter in type", E_USER_WARNING); return; } $ini = new helpers_headScript(); $concat = $params['concat']; if ($concat == '1') { $system = new component_core_system(); if (defined('PATHADMIN')) { $url = $system->getUrlConcat(array('src' => $src, 'caches' => 'caching/caches', 'filesgroups' => 'min/groupsConfig.php', 'minDir' => '/' . PATHADMIN . '/min/', 'callback' => '/admin')); } else { $url = $system->getUrlConcat(array('src' => $src, 'caches' => 'var/caches', 'filesgroups' => 'min/groupsConfig.php', 'minDir' => '/min/', 'callback' => '')); } } elseif ($concat == '0') { $url = $src; } else { $url = $src; } $head = $ini->src($url, $type); return $head; }
/** * Smarty {headlink rel="" href="" optionnal(media="")} function plugin * * Type: function * Name: * Date: * Purpose: * Examples: {headlink} * Output: * @link * @author Gerits Aurelien * @version 1.0 * @param array * @param Smarty * @return string */ function smarty_function_headlink($params, $template) { $rel = $params['rel']; if (!isset($rel)) { trigger_error("rel: missing 'rel' parameter in link"); return; } $href = $params['href']; if (!isset($href)) { trigger_error("href: missing 'href' parameter in link"); return; } $concat = $params['concat']; if ($concat == '1') { $system = new component_core_system(); if (defined('PATHADMIN')) { $url = $system->getUrlConcat(array('href' => $href, 'caches' => 'caching/caches', 'filesgroups' => 'min/groupsConfig.php', 'minDir' => '/' . PATHADMIN . '/min/', 'callback' => '/admin')); } else { $url = $system->getUrlConcat(array('href' => $href, 'caches' => 'var/caches', 'filesgroups' => 'min/groupsConfig.php', 'minDir' => '/min/', 'callback' => '')); } } elseif ($concat == '0') { $url = $href; } else { $url = $href; } $ini = new helpers_headLink(); switch ($rel) { case 'stylesheet': $head = $ini->linkStyleSheet($url, $params['media']); break; case 'rss': $head = $ini->linkRss($href); break; } return $head; }
/** * Envoi une image sur le serveur avec la méthode upload * @param files $img * @param dir $path * @param bool $setOption * @param bool|\debug $debug $debug * @return null|string|\true */ public static function uploadImg($img, $path, $setOption = false, $debug = false) { $error = null; $makefile = new filesystem_makefile(); $firebug = new debug_firephp(); if (is_array($setOption)) { if (array_key_exists('maxwidth', $setOption)) { $maxwidth = $setOption['maxwidth']; } else { $maxwidth = 2500; } if (array_key_exists('maxheight', $setOption)) { $maxheight = $setOption['maxheight']; } else { $maxheight = 2500; } if (array_key_exists('minheight', $setOption)) { $minheight = $setOption['minheight']; } else { $minheight = 5; } if (array_key_exists('minwidth', $setOption)) { $minwidth = $setOption['minwidth']; } else { $minwidth = 5; } } else { $maxwidth = 2500; $maxheight = 2500; $minheight = 5; $minwidth = 5; } /** * Envoi de l'image */ if (isset($_FILES[$img])) { if ($_FILES[$img]['error'] == UPLOAD_ERR_OK) { if (self::imageValid($_FILES[$img]['tmp_name']) === false) { $error .= 'Invalid image format (gif, png, jpeg only)'; } else { if (!is_readable($_FILES[$img]["tmp_name"])) { //$tmp_img = chmod($_FILES[$img]["tmp_name"],0777); $tmp_img = $makefile->chmod(array($_FILES[$img]["tmp_name"]), 0777); } else { $tmp_img = $_FILES[$img]["tmp_name"]; } //if(chmod($_FILES[$img]["tmp_name"],0777)){ if (is_uploaded_file($_FILES[$img]["tmp_name"])) { $source = $tmp_img; $cible = component_core_system::basePath() . $path . '/' . http_url::clean($_FILES[$img]["name"]); if (self::imgSizeMax($source, $maxwidth, $maxheight) == false) { $error .= 'Exceeds the maximum size ' . $maxwidth . ' x ' . $maxheight; } elseif (self::imgSizeMin($source, $minwidth, $minheight) == false) { $error .= 'The file is too small: ' . $minwidth . ' x ' . $minheight; } else { if (!move_uploaded_file($source, $cible)) { $error .= 'Error in temporary file'; } else { if ($debug != false) { $firebug->group('Upload image infos'); $firebug->log('Success', 'Status'); $firebug->log($source, 'Source'); $firebug->log($cible, 'Cible'); $firebug->groupEnd(); } } } } else { $error .= 'Disk write error'; } //} } } elseif (UPLOAD_ERR_INI_SIZE == true) { $error .= 'The file is too large'; } elseif (UPLOAD_ERR_CANT_WRITE == true) { $error .= 'Disk write error'; } elseif (UPLOAD_ERR_FORM_SIZE == true) { $error .= 'The file is too large: maximum size ' . $maxwidth . ' x ' . $maxheight; } } elseif (UPLOAD_ERR_NO_FILE == true) { $error .= 'No file'; } else { $error .= 'Disk write error'; } if ($error != null) { $n = $firebug->group('Upload image analyse'); $n .= $firebug->log($error); $n .= $firebug->groupEnd(); } else { $n = NULL; } return $n; }
private function setPath() { return component_core_system::basePath(); }