当前位置: 首页>>代码示例>>PHP>>正文


PHP io::substr方法代码示例

本文整理汇总了PHP中io::substr方法的典型用法代码示例。如果您正苦于以下问题:PHP io::substr方法的具体用法?PHP io::substr怎么用?PHP io::substr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io的用法示例。


在下文中一共展示了io::substr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getObjectsNames

 /**
  * Gets all available objects class names
  *
  * @return array(string "CMS_object_{type}")
  * @access public
  * @static
  */
 function getObjectsNames()
 {
     //Automatic listing
     $excludedFiles = array('object_catalog.php', 'object_common.php');
     $packages_dir = dir(PATH_MODULES_FS . '/' . MOD_POLYMOD_CODENAME . '/objects/');
     while (false !== ($file = $packages_dir->read())) {
         if (io::substr($file, -4) == ".php" && !in_array($file, $excludedFiles) && class_exists('CMS_' . io::substr($file, 0, -4))) {
             $objectsCatalog[] = 'CMS_' . io::substr($file, 0, -4);
         }
     }
     return $objectsCatalog;
 }
开发者ID:davidmottet,项目名称:automne,代码行数:19,代码来源:object_catalog.php

示例2: getTextDefinition

 /**
  * Get the text definition.
  *
  * @return string The text definition based on the current elements
  * @access public
  */
 function getTextDefinition()
 {
     $text = '';
     foreach ($this->_elements as $atom) {
         $text .= $atom[0];
         if ($this->_valuesByAtom == 2) {
             $text .= "," . $atom[1];
         }
         $text .= ";";
     }
     $text = io::substr($text, 0, -1);
     return $text;
 }
开发者ID:davidmottet,项目名称:automne,代码行数:19,代码来源:stack.php

示例3: moveResourceData

 /**
  * Move the data of a resource from one data location to another.
  * May be used by every module, provided it respects the naming rules described in the modules HOWTO
  *
  * @param CMS_module $module The module who  want its data moved
  * @param string $tablesPrefix The prefix of the tables containing the data
  * @param string $resourceIDFieldName The name of the field containing the resource ID
  * @param integer $resourceID The DB ID of the resource whose data we want to move
  * @param string $locationFrom The starting location, among the available RESOURCE_DATA_LOCATION
  * @param string $locationTo The ending location, among  the available RESOURCE_DATA_LOCATION
  * @param boolean $copyOnly If set to true, the deletion from the originating tables and dirs won't occur
  * @return boolean true on success, false on failure
  * @access public
  */
 static function moveResourceData(&$module, $tablesPrefix, $resourceIDFieldName, $resourceID, $locationFrom, $locationTo, $copyOnly = false)
 {
     if (!is_a($module, "CMS_module")) {
         CMS_grandFather::raiseError("Module is not a CMS_module");
         return false;
     }
     if (!SensitiveIO::isInSet($locationFrom, CMS_resource::getAllDataLocations()) || !SensitiveIO::isInSet($locationTo, CMS_resource::getAllDataLocations())) {
         CMS_grandFather::raiseError("Locations are not in the set");
         return false;
     }
     //get the tables : named PREFIXXXXX_public
     $sql = "show tables";
     $q = new CMS_query($sql);
     $tables_prefixes = array();
     while ($data = $q->getArray()) {
         if (preg_match("#" . $tablesPrefix . "(.*)_public#", $data[0])) {
             $tables_prefixes[] = io::substr($data[0], 0, strrpos($data[0], "_") + 1);
         }
     }
     foreach ($tables_prefixes as $table_prefix) {
         //delete all in the destination table just incase and insert
         if ($locationTo != RESOURCE_DATA_LOCATION_DEVNULL) {
             $sql = "\n\t\t\t\t\tdelete from\n\t\t\t\t\t\t" . $table_prefix . $locationTo . "\n\t\t\t\t\twhere\n\t\t\t\t\t\t" . $resourceIDFieldName . "='" . $resourceID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
             $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\t" . $table_prefix . $locationTo . "\n\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t" . $table_prefix . $locationFrom . "\n\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t" . $resourceIDFieldName . "='" . $resourceID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
         }
         if (!$copyOnly) {
             //delete from the starting table
             $sql = "\n\t\t\t\t\tdelete from\n\t\t\t\t\t\t" . $table_prefix . $locationFrom . "\n\t\t\t\t\twhere\n\t\t\t\t\t\t" . $resourceIDFieldName . "='" . $resourceID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
         }
     }
     //second, move the files
     $locationFromDir = new CMS_file(PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationFrom, CMS_file::FILE_SYSTEM, CMS_file::TYPE_DIRECTORY);
     //cut here if the locationFromDir doesn't exists. That means the module doesn't have files
     if (!$locationFromDir->exists()) {
         return true;
     }
     if ($locationTo != RESOURCE_DATA_LOCATION_DEVNULL) {
         $locationToDir = new CMS_file(PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationTo, CMS_file::FILE_SYSTEM, CMS_file::TYPE_DIRECTORY);
         //cut here if the locationToDir doesn't exists.
         if (!$locationToDir->exists()) {
             CMS_grandFather::raiseError("LocationToDir does not exists : " . PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationTo);
             return false;
         }
         //delete all files of the locationToDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationTo . '/r' . $resourceID . '_*', GLOB_NOSORT);
         if (is_array($files)) {
             foreach ($files as $file) {
                 if (!CMS_file::deleteFile($file)) {
                     CMS_grandFather::raiseError("Can't delete file " . $file);
                     return false;
                 }
             }
         }
         //then copy or move them to the locationToDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationFrom . '/r' . $resourceID . '_*', GLOB_NOSORT);
         if (is_array($files)) {
             foreach ($files as $file) {
                 $to = str_replace('/' . $locationFrom . '/', '/' . $locationTo . '/', $file);
                 if ($copyOnly) {
                     if (!CMS_file::copyTo($file, $to)) {
                         CMS_grandFather::raiseError("Can't copy file " . $file . " to " . $to);
                         return false;
                     }
                 } else {
                     if (!CMS_file::moveTo($file, $to)) {
                         CMS_grandFather::raiseError("Can't move file " . $file . " to " . $to);
                         return false;
                     }
                 }
                 //then chmod new file
                 CMS_file::chmodFile(FILES_CHMOD, $to);
             }
         }
     }
     //cleans the initial dir if not a copy
     if (!$copyOnly) {
         //then get all files of the locationFromDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationFrom . '/r' . $resourceID . '_*', GLOB_NOSORT);
         if (is_array($files)) {
             foreach ($files as $file) {
                 if (!CMS_file::deleteFile($file)) {
                     CMS_grandFather::raiseError("Can't delete file " . $file);
                     return false;
//.........这里部分代码省略.........
开发者ID:davidmottet,项目名称:automne,代码行数:101,代码来源:modulescatalog.php

示例4: getDefaultLanguage

 /**
  * Get the default language.
  *
  * @param boolean guessFromNavigator : try to guess default user language from HTTP_ACCEPT_LANGUAGE (default : false)
  * @return CMS_language The default language
  * @access public
  */
 static function getDefaultLanguage($guessFromNavigator = false)
 {
     if ($guessFromNavigator) {
         //load language object from get value if any
         if (isset($_GET["language"]) && SensitiveIO::isInSet($_GET["language"], array_keys(CMS_languagesCatalog::getAllLanguages()))) {
             $language = CMS_languagesCatalog::getByCode($_GET["language"]);
             if ($language) {
                 return $language;
             }
         } elseif (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && SensitiveIO::isInSet(io::substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2), array_keys(CMS_languagesCatalog::getAllLanguages()))) {
             $language = CMS_languagesCatalog::getByCode(io::substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2));
             if ($language) {
                 return $language;
             }
         }
     }
     return CMS_languagesCatalog::getByCode(APPLICATION_DEFAULT_LANGUAGE);
 }
开发者ID:davidmottet,项目名称:automne,代码行数:25,代码来源:languagescatalog.php

示例5: getTypeObject

 /**
  * get an object instance of the field type
  *
  * @param boolean $returnDefinition, return object CMS_poly_object_definition or CMS_poly_object otherwise
  * @return mixed, the object instance
  * @access public
  */
 function getTypeObject($returnDefinition = false, $public = false)
 {
     if (!$this->_objectFieldValues['type']) {
         return false;
     }
     if (sensitiveIO::isPositiveInteger($this->_objectFieldValues['type'])) {
         if ($returnDefinition) {
             return CMS_poly_object_catalog::getObjectDefinition($this->_objectFieldValues['type']);
         } else {
             $item = new CMS_poly_object($this->_objectFieldValues['type'], 0, array(), $public);
             //object is used as field as another object so set it
             $item->setField($this);
             return $item;
         }
     } elseif (io::strpos($this->_objectFieldValues['type'], 'multi|') !== false) {
         return new CMS_multi_poly_object(io::substr($this->_objectFieldValues['type'], 6), array(), $this, $public);
     } elseif (class_exists($this->_objectFieldValues['type'])) {
         return new $this->_objectFieldValues['type'](array(), $this, $public);
     }
 }
开发者ID:davidmottet,项目名称:automne,代码行数:27,代码来源:poly_object_field.php

示例6: create_zip

 /**
  * Creates compressed file by compressing raw data contained into $this->CMS_archive
  * 
  * @return true on success, false on failure
  */
 function create_zip()
 {
     $files = 0;
     $offset = 0;
     $central = "";
     if (!empty($this->options['sfx'])) {
         if ($fp = @fopen($this->options['sfx'], "rb")) {
             $temp = fread($fp, filesize($this->options['sfx']));
             fclose($fp);
             $this->add_data($temp);
             $offset += io::strlen($temp);
             unset($temp);
         } else {
             $this->raiseError("Could not open sfx module from {$this->options['sfx']}.");
         }
     }
     $pwd = getcwd();
     chdir($this->options['basedir']);
     foreach ($this->files as $current) {
         if ($current['name'] == $this->options['name']) {
             continue;
         }
         // Special chars management
         $translate = array('Ç' => pack("C", 128), 'ü' => pack("C", 129), 'é' => pack("C", 130), 'â' => pack("C", 131), 'ä' => pack("C", 132), 'à' => pack("C", 133), 'å' => pack("C", 134), 'ç' => pack("C", 135), 'ê' => pack("C", 136), 'ë' => pack("C", 137), 'è' => pack("C", 138), 'ï' => pack("C", 139), 'î' => pack("C", 140), 'ì' => pack("C", 141), 'Ä' => pack("C", 142), 'Å' => pack("C", 143), 'É' => pack("C", 144), 'æ' => pack("C", 145), 'Æ' => pack("C", 146), 'ô' => pack("C", 147), 'ö' => pack("C", 148), 'ò' => pack("C", 149), 'û' => pack("C", 150), 'ù' => pack("C", 151), 'Ö' => pack("C", 153), 'Ü' => pack("C", 154), '£' => pack("C", 156), '¥' => pack("C", 157), 'ƒ' => pack("C", 159), 'á' => pack("C", 160), 'í' => pack("C", 161), 'ó' => pack("C", 162), 'ú' => pack("C", 163), 'ñ' => pack("C", 164), 'Ñ' => pack("C", 165));
         $current['name2'] = strtr($current['name2'], $translate);
         $timedate = explode(" ", date("Y n j G i s", $current['stat'][9]));
         $timedate = $timedate[0] - 1980 << 25 | $timedate[1] << 21 | $timedate[2] << 16 | $timedate[3] << 11 | $timedate[4] << 5 | $timedate[5];
         $block = pack("VvvvV", 0x4034b50, 0xa, 0x0, isset($current['method']) || $this->options['method'] == 0 ? 0x0 : 0x8, $timedate);
         if ($current['stat'][7] == 0 && $current['type'] == 5) {
             $block .= pack("VVVvv", 0x0, 0x0, 0x0, io::strlen($current['name2']) + 1, 0x0);
             $block .= $current['name2'] . "/";
             $this->add_data($block);
             $central .= pack("VvvvvVVVVvvvvvVV", 0x2014b50, 0x14, $this->options['method'] == 0 ? 0x0 : 0xa, 0x0, isset($current['method']) || $this->options['method'] == 0 ? 0x0 : 0x8, $timedate, 0x0, 0x0, 0x0, io::strlen($current['name2']) + 1, 0x0, 0x0, 0x0, 0x0, $current['type'] == 5 ? 0x10 : 0x0, $offset);
             $central .= $current['name2'] . "/";
             $files++;
             $offset += 31 + io::strlen($current['name2']);
         } else {
             if ($current['stat'][7] == 0) {
                 $block .= pack("VVVvv", 0x0, 0x0, 0x0, io::strlen($current['name2']), 0x0);
                 $block .= $current['name2'];
                 $this->add_data($block);
                 $central .= pack("VvvvvVVVVvvvvvVV", 0x2014b50, 0x14, $this->options['method'] == 0 ? 0x0 : 0xa, 0x0, isset($current['method']) || $this->options['method'] == 0 ? 0x0 : 0x8, $timedate, 0x0, 0x0, 0x0, io::strlen($current['name2']), 0x0, 0x0, 0x0, 0x0, $current['type'] == 5 ? 0x10 : 0x0, $offset);
                 $central .= $current['name2'];
                 $files++;
                 $offset += 30 + io::strlen($current['name2']);
             } else {
                 if ($fp = @fopen($current['name'], "rb")) {
                     $temp = fread($fp, $current['stat'][7]);
                     fclose($fp);
                     $crc32 = crc32($temp);
                     if (!isset($current['method']) && $this->options['method'] == 1) {
                         $temp = gzcompress($temp, $this->options['level']);
                         $size = io::strlen($temp) - 6;
                         $temp = io::substr($temp, 2, $size);
                     } else {
                         $size = io::strlen($temp);
                     }
                     $block .= pack("VVVvv", $crc32, $size, $current['stat'][7], io::strlen($current['name2']), 0x0);
                     $block .= $current['name2'];
                     $this->add_data($block);
                     $this->add_data($temp);
                     unset($temp);
                     $central .= pack("VvvvvVVVVvvvvvVV", 0x2014b50, 0x14, $this->options['method'] == 0 ? 0x0 : 0xa, 0x0, isset($current['method']) || $this->options['method'] == 0 ? 0x0 : 0x8, $timedate, $crc32, $size, $current['stat'][7], io::strlen($current['name2']), 0x0, 0x0, 0x0, 0x0, 0x0, $offset);
                     $central .= $current['name2'];
                     $files++;
                     $offset += 30 + io::strlen($current['name2']) + $size;
                 } else {
                     $this->raiseError("Could not open file {$current['name']} for reading. It was not added.");
                 }
             }
         }
     }
     $this->add_data($central);
     $this->add_data(pack("VvvvvVVv", 0x6054b50, 0x0, 0x0, $files, $files, io::strlen($central), $offset, !empty($this->options['comment']) ? io::strlen($this->options['comment']) : 0x0));
     if (!empty($this->options['comment'])) {
         $this->add_data($this->options['comment']);
     }
     chdir($pwd);
     return true;
 }
开发者ID:davidmottet,项目名称:automne,代码行数:85,代码来源:archive-zip.php

示例7: extract_files

 /**
  * Extract files from the archive
  * 
  * @return true on success
  */
 function extract_files()
 {
     $pwd = getcwd();
     chdir($this->options['basedir']);
     if ($fp = $this->open_archive()) {
         if ($this->options['inmemory'] == 1) {
             $this->files = array();
         }
         while ($block = fread($fp, 512)) {
             $temp = unpack("a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100temp/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp", $block);
             $file = array('name' => $temp['prefix'] . $temp['name'], 'stat' => array(2 => $temp['mode'], 4 => octdec($temp['uid']), 5 => octdec($temp['gid']), 7 => octdec($temp['size']), 9 => octdec($temp['mtime'])), 'checksum' => octdec($temp['checksum']), 'type' => $temp['type'], 'magic' => $temp['magic']);
             if ($file['checksum'] == 0x0) {
                 break;
             } else {
                 /*if ($file['magic'] != "ustar") {
                 			$this->raiseError("This script does not support extracting this type of tar file.");
                 			break;
                 		}*/
                 $block = substr_replace($block, "        ", 148, 8);
             }
             $checksum = 0;
             for ($i = 0; $i < 512; $i++) {
                 $checksum += ord(io::substr($block, $i, 1));
             }
             if ($file['checksum'] != $checksum) {
                 $this->raiseError("Could not extract from {$this->options['name']}, it is corrupt.");
             }
             if ($this->options['inmemory'] == 1) {
                 $file['data'] = @fread($fp, $file['stat'][7]);
                 @fread($fp, 512 - $file['stat'][7] % 512 == 512 ? 0 : 512 - $file['stat'][7] % 512);
                 unset($file['checksum'], $file['magic']);
                 $this->files[] = $file;
             } else {
                 if ($file['type'] == 5) {
                     if (!is_dir($file['name'])) {
                         /*if ($this->options['forceWriting']) {
                         			chmod($file['name'], 1777);
                         		}*/
                         if (!$this->options['dontUseFilePerms']) {
                             @mkdir($file['name'], $file['stat'][2]);
                             //pr($file['name'].' : '.$file['stat'][4]);
                             //pr($file['name'].' : '.$file['stat'][5]);
                             @chown($file['name'], $file['stat'][4]);
                             @chgrp($file['name'], $file['stat'][5]);
                         } else {
                             @mkdir($file['name']);
                         }
                     }
                 } else {
                     if ($this->options['overwrite'] == 0 && file_exists($file['name'])) {
                         $this->raiseError("{$file['name']} already exists.");
                     } else {
                         //check if destination dir exists
                         $dirname = dirname($file['name']);
                         if (!is_dir($dirname)) {
                             CMS_file::makeDir($dirname);
                         }
                         if ($new = @fopen($file['name'], "wb")) {
                             @fwrite($new, @fread($fp, $file['stat'][7]));
                             @fread($fp, 512 - $file['stat'][7] % 512 == 512 ? 0 : 512 - $file['stat'][7] % 512);
                             @fclose($new);
                             //pr($file['name'].' : '.$file['stat'][2]);
                             if (!$this->options['dontUseFilePerms']) {
                                 @chmod($file['name'], $file['stat'][2]);
                                 @chown($file['name'], $file['stat'][4]);
                                 @chgrp($file['name'], $file['stat'][5]);
                             }
                             /*if ($this->options['forceWriting']) {
                             			chmod($file['name'], 0777);
                             		}*/
                         } else {
                             $this->raiseError("Could not open {$file['name']} for writing.");
                         }
                     }
                 }
             }
             unset($file);
         }
     } else {
         $this->raiseError("Could not open file {$this->options['name']}");
     }
     chdir($pwd);
     return true;
 }
开发者ID:davidmottet,项目名称:automne,代码行数:89,代码来源:archive-tar.php

示例8: checkTagValues

 protected function checkTagValues(&$tag, $requirements)
 {
     if (!is_array($requirements)) {
         $this->raiseError('Tag requirements must be an array');
         return false;
     }
     foreach ($requirements as $name => $requirementType) {
         //check parameter existence
         if ($requirementType['mandatory'] && !isset($tag['attributes'][$name])) {
             if ($this->_mode == self::CHECK_PARSING_MODE) {
                 $this->_parsingError .= "\n" . 'Malformed ' . $tag['nodename'] . ' tag : missing \'' . $name . '\' attribute';
                 return false;
             } else {
                 $this->raiseError('Malformed ' . $tag['nodename'] . ' tag : missing \'' . $name . '\' attribute');
                 return false;
             }
         } elseif (isset($tag['attributes'][$name])) {
             //if any, check value requirement
             $message = false;
             switch ($requirementType['value']) {
                 case 'alphanum':
                     if ($tag['attributes'][$name] != sensitiveIO::sanitizeAsciiString($tag['attributes'][$name], '', '_')) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must only be composed with alphanumeric caracters (0-9a-z_) : ' . $tag['attributes'][$name];
                     }
                     break;
                 case 'language':
                     if (isset($this->_parameters['module'])) {
                         $languages = CMS_languagesCatalog::getAllLanguages($this->_parameters['module']);
                     } else {
                         $languages = CMS_languagesCatalog::getAllLanguages();
                     }
                     if (!isset($languages[$tag['attributes'][$name]])) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must only be a valid language code : ' . $tag['attributes'][$name];
                     }
                     break;
                 case 'object':
                     if (!sensitiveIO::isPositiveInteger(io::substr($tag['attributes'][$name], 9, -3))) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute does not represent a valid object';
                     }
                     break;
                 case 'field':
                     if (strrpos($tag['attributes'][$name], 'fields') === false || !sensitiveIO::isPositiveInteger(io::substr($tag['attributes'][$name], strrpos($tag['attributes'][$name], 'fields') + 9, -2))) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute does not represent a valid object field';
                     }
                     break;
                 case 'page':
                     if (!io::isPositiveInteger($tag['attributes'][$name])) {
                         // Assuming the structure {websitecodename:pagecodename}
                         $page = trim($tag['attributes'][$name], "{}");
                         if (strpos($page, ":") !== false) {
                             list($websiteCodename, $pageCodename) = explode(':', $page);
                             $website = CMS_websitesCatalog::getByCodename($websiteCodename);
                             if (!$website) {
                                 $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow Website codename : ' . $websiteCodename . '';
                             } else {
                                 $pageID = CMS_tree::getPageByCodename($pageCodename, $website, false, false);
                                 if (!$pageID) {
                                     $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow page codename ' . $pageCodename . ' in website : ' . $websiteCodename . '';
                                 }
                             }
                         } else {
                             $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must be an integer or use the format websitecodename:pagecodename';
                         }
                     } else {
                         if (!CMS_tree::getPageByID($tag['attributes'][$name])) {
                             $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow pageID : ' . $tag['attributes'][$name];
                         }
                     }
                     break;
                 default:
                     //check
                     if (!preg_match('#^' . $requirementType['value'] . '$#i', $tag['attributes'][$name])) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must match expression \'' . $requirementType['value'] . '\' : ' . $tag['attributes'][$name];
                     }
                     break;
             }
             if ($message) {
                 if ($this->_mode == self::CHECK_PARSING_MODE) {
                     $this->_parsingError .= "\n<br />" . $message;
                     return false;
                 } else {
                     $this->raiseError($message);
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:davidmottet,项目名称:automne,代码行数:89,代码来源:poly_definition_parsing.php

示例9: setImage

 /**
  * Sets the image. Can be empty. Must have the gif, jpg, jpeg or png extension.
  *
  * @param string $image the image to set
  * @return boolean true on success, false on failure.
  * @access public
  */
 function setImage($image = 'nopicto.gif')
 {
     if (!trim($image)) {
         $image = 'nopicto.gif';
     }
     $extension = io::substr($image, strrpos($image, ".") + 1);
     if (SensitiveIO::isInSet(io::strtolower($extension), array("jpg", "jpeg", "gif", "png"))) {
         $this->_image = $image;
         return true;
     } else {
         $this->_image = 'nopicto.gif';
         return true;
     }
 }
开发者ID:davidmottet,项目名称:automne,代码行数:21,代码来源:pagetemplate.php

示例10: download_file

 /**
  * Proceeds to archive download
  * 
  * @return binary file content to be downloaded
  */
 function download_file()
 {
     if ($this->options['inmemory'] == 0) {
         $this->raiseError("Can only use download_file() if archive is in memory. Redirect to file otherwise, it is faster.");
         return;
     }
     switch ($this->options['type']) {
         case "zip":
             header("Content-type:application/zip");
             break;
         case "bzip":
             header("Content-type:application/x-compressed");
             break;
         case "gzip":
             header("Content-type:application/x-compressed");
             break;
         case "tar":
             header("Content-type:application/x-tar");
     }
     $header = "Content-disposition: attachment; filename=\"";
     $header .= strstr($this->options['name'], "/") ? io::substr($this->options['name'], strrpos($this->options['name'], "/") + 1) : $this->options['name'];
     $header .= "\"";
     header($header);
     header("Content-length: " . io::strlen($this->CMS_archive));
     header("Content-transfer-encoding: binary");
     header("Pragma: no-cache");
     header("Expires: 0");
     print $this->CMS_archive;
 }
开发者ID:davidmottet,项目名称:automne,代码行数:34,代码来源:archive.php

示例11: decodeFieldIdDatas

 /**
  * Analyse an xhtml identifier for a CMS_forms_field object then return decoded datas
  *
  * @access public
  * @param string $datas base64 encoded xhtml identifier
  * @return array : decoded datas
  */
 function decodeFieldIdDatas($datas)
 {
     return explode('_', base64_decode(io::substr($datas, 1)));
 }
开发者ID:davidmottet,项目名称:automne,代码行数:11,代码来源:field.php

示例12: array

$modulesCodeInclude = $modulesCodes->getModulesCodes(MODULE_TREATMENT_TEMPLATES_EDITION_LABELS, PAGE_VISUALMODE_CLIENTSPACES_FORM, $template, array("language" => $cms_language, "user" => $cms_user));
$modulesTab = '';
if (is_array($modulesCodeInclude) && $modulesCodeInclude) {
    foreach ($modulesCodeInclude as $codename => $description) {
        //if user has rights on module
        if ($cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT)) {
            $module = CMS_modulesCatalog::getByCodename($codename);
            $label = sensitiveIO::sanitizeJSString($module->getLabel($cms_language));
            $description = sensitiveIO::sanitizeJSString($description);
            $modulesTab .= "{\n\t\t\t\ttitle:\t\t\t\t'{$label}',\n\t\t\t\thtml:\t\t\t\t'{$description}'\n\t\t\t},";
        }
    }
}
//remove last comma
if ($modulesTab) {
    $modulesTab = io::substr($modulesTab, 0, -1);
}
$jscontent = <<<END
\tvar helpWindow = Ext.getCmp('{$winId}');
\t//set window title
\thelpWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_PAGE_TITLE)}');
\t//set help button on top of page
\thelpWindow.tools['help'].show();
\t//add a tooltip on button
\tvar propertiesTip = new Ext.ToolTip({
\t\ttarget: \t\thelpWindow.tools['help'],
\t\ttitle: \t\t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}',
\t\thtml: \t\t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP_DESC)}',
\t\tdismissDelay:\t0
\t});
开发者ID:davidmottet,项目名称:automne,代码行数:30,代码来源:template-help.php

示例13: function

//
// Search Panel
//
$searchPanel = '';
// Keywords
$searchPanel .= "{\n\tfieldLabel:\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_BY_NAME_DESCRIPTION)}',\n\txtype:\t\t\t'textfield',\n\tname: \t\t\t'keyword',\n\tvalue:\t\t\t'',\n\tminLength:\t\t3,\n\tanchor:\t\t\t'-20px',\n\tvalidateOnBlur:\tfalse,\n\tlisteners:\t\t{\n\t\t'valid':{\n\t\t\tfn: \t\t\trowWindow.search, \n\t\t\toptions:\t\t{buffer:300}\n\t\t},\n\t\t'invalid':{\n\t\t\tfn: function(field, event) {\n\t\t\t\tif (!isNaN(parseInt(field.getValue()))) {\n\t\t\t\t\tfield.clearInvalid();\n\t\t\t\t\tfield.fireEvent('valid', field);\n\t\t\t\t} else if (!field.getValue()) {\n\t\t\t\t\tfield.clearInvalid();\n\t\t\t\t}\n\t\t\t}, \n\t\t\toptions:\t\t{buffer:300}\n\t\t}\n\t}\n},";
$allGroups = CMS_rowsCatalog::getAllGroups();
natcasesort($allGroups);
if ($allGroups) {
    $columns = sizeof($allGroups) < 2 ? sizeof($allGroups) : 2;
    $searchPanel .= "{\n\t\txtype: \t\t'checkboxgroup',\n\t\tfieldLabel: '{$cms_language->getJSMessage(MESSAGE_PAGE_GROUPS)}',\n\t\tcolumns: \t{$columns},\n\t\titems: [";
    foreach ($allGroups as $aGroup) {
        $searchPanel .= "{boxLabel: '{$aGroup}', inputValue:'{$aGroup}', name: 'groups[]', listeners: {'check':rowWindow.search}},";
    }
    //remove last comma from groups
    $searchPanel = io::substr($searchPanel, 0, -1);
    $searchPanel .= "\n\t\t]\n\t},";
}
$modules = CMS_modulesCatalog::getAll();
if (sizeof($modules) > 1) {
    $modulesDatas = array();
    $modulesDatas['module'] = array(array('id' => 0, 'label' => '-'));
    foreach ($modules as $module) {
        $modulesDatas['module'][] = array('id' => $module->getCodename(), 'label' => $module->getLabel($cms_language));
    }
    //json encode websites datas
    $modulesDatas = sensitiveIO::jsonEncode($modulesDatas);
    $searchPanel .= "{\n\t\txtype:\t\t\t\t'combo',\n\t\tid:\t\t\t\t\t'moduleField',\n\t\tname:\t\t\t\t'module',\n\t\tfieldLabel:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_MODULES)}',\n\t\tanchor:\t\t\t\t'-20px',\n\t\tforceSelection:\t\ttrue,\n\t\tmode:\t\t\t\t'local',\n\t\ttriggerAction:\t\t'all',\n\t\tvalueField:\t\t\t'id',\n\t\thiddenName: \t\t'module',\n\t\tdisplayField:\t\t'label',\n\t\tstore:\t\t\t\tnew Ext.data.JsonStore({\n\t\t\tid:\t\t\t\t'id',\n\t\t\troot: \t\t\t'module',\n\t\t\tfields: \t\t['id', 'label'],\n\t\t\tdata:\t\t\t{$modulesDatas}\n\t\t}),\n\t\tvalidateOnBlur:\t\tfalse,\n\t\tallowBlank: \t\ttrue,\n\t\tselectOnFocus:\t\ttrue,\n\t\teditable:\t\t\ttrue,\n\t\ttypeAhead:\t\t\ttrue,\n\t\tlisteners:\t\t\t{'valid':rowWindow.search}\n\t},";
}
$searchPanel .= "{\n\txtype:\t\t\t'atmPageField',\n\tfieldLabel:\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_PAGE)}',\n\tname:\t\t\t'page',\n\tvalue:\t\t\t'',\n\tanchor:\t\t\t'-20px',\n\tallowBlank:\t\ttrue,\n\tvalidateOnBlur:\tfalse,\n\tlisteners:\t\t{'valid':{\n\t\tfn: \t\t\trowWindow.search,\n\t\toptions:\t\t{buffer:300}\n\t}}\n},";
$searchPanel .= "{\n\thideLabel:\t\ttrue,\n\tlabelSeparator:\t'',\n\tlabelAlign:\t\t'left',\n\txtype:\t\t\t'checkbox',\n\tboxLabel: \t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_VIEW_INACTIVE_ROWS)}',\n\tname: \t\t\t'viewinactive',\n\tinputValue:\t\t'1',\n\tchecked:\t\ttrue,\n\tlisteners: \t\t{'check':rowWindow.search}\n}";
开发者ID:davidmottet,项目名称:automne,代码行数:31,代码来源:templates-row.php

示例14: setLocalizedDate

 /**
  * Sets the value from a formatted date
  *
  * @param string $date The date formatted with the current format
  * @param boolean $canBeNull If set to true, the function won't complain if the date is set to a null value
  * @return boolean true is successful to set it
  * @access public
  */
 function setLocalizedDate($date, $canBeNull = false)
 {
     if (!$this->_format) {
         $this->raiseError("Format not set");
         return false;
     }
     if (!$date) {
         if ($canBeNull) {
             $this->_day = $this->_month = $this->_hours = $this->_minutes = $this->_seconds = "00";
             $this->_year = "0000";
             return true;
         } else {
             $this->raiseError("Date null");
             return false;
         }
     }
     //analyse format
     $year_found = 0;
     switch (io::substr($this->_format, 0, 1)) {
         case "d":
             $day_pos = 0;
             break;
         case "m":
             $month_pos = 0;
             break;
         case "Y":
             $year_pos = 0;
             $year_found = 1;
             break;
     }
     switch (io::substr($this->_format, 2, 1)) {
         case "d":
             $day_pos = 3 + $year_found * 2;
             break;
         case "m":
             $month_pos = 3 + $year_found * 2;
             break;
         case "Y":
             $year_pos = 3;
             $year_found = 1;
             break;
     }
     switch (io::substr($this->_format, 4, 1)) {
         case "d":
             $day_pos = 6 + $year_found * 2;
             break;
         case "m":
             $month_pos = 6 + $year_found * 2;
             break;
         case "Y":
             $year_pos = 6;
             break;
     }
     return $this->setDay(io::substr($date, $day_pos, 2)) && $this->setMonth(io::substr($date, $month_pos, 2)) && $this->setYear(io::substr($date, $year_pos, 4));
 }
开发者ID:davidmottet,项目名称:automne,代码行数:63,代码来源:date.php

示例15: getInput

 /**
  * Return the needed form field tag for current object field
  *
  * @param array $values : parameters values array(parameterName => parameterValue) in :
  *     id : the form field id to set
  * @param multidimentionnal array $tags : xml2Array content of atm-function tag
  * @return string : the form field HTML tag
  * @access public
  */
 function getInput($fieldID, $language, $inputParams)
 {
     //hidden field : use parent method
     if (isset($inputParams['hidden']) && ($inputParams['hidden'] == 'true' || $inputParams['hidden'] == 1)) {
         return parent::getInput($fieldID, $language, $inputParams);
     }
     global $cms_user;
     $params = $this->getParamsValues();
     if (isset($inputParams['prefix'])) {
         $prefixName = $inputParams['prefix'];
     } else {
         $prefixName = '';
     }
     //serialize all htmlparameters
     //$htmlParameters = $this->serializeHTMLParameters($inputParams);
     $html = '';
     //create fieldname
     $fieldName = $prefixName . $this->_field->getID() . '_0';
     //create field value
     $value = $this->_subfieldValues[0]->getValue();
     if ($params['html']) {
         // Insert prefered text editor for textarea field
         $module = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
         $toolbarset = !$params['toolbar'] ? $module : $params['toolbar'];
         if (class_exists('CMS_wysiwyg_toolbar')) {
             $toolbar = CMS_wysiwyg_toolbar::getByCode($toolbarset, $cms_user);
             $value = $toolbar->hasModulePlugins() ? CMS_textEditor::parseInnerContent($value, $module) : $value;
         }
         $CKEditor = new CKEditor(PATH_MAIN_WR . '/ckeditor/');
         $CKEditor->returnOutput = true;
         $html .= $CKEditor->editor($fieldName, $value, array('language' => $language->getCode(), 'width' => $params['toolbarWidth'] ? $params['toolbarWidth'] : '100%', 'height' => sensitiveIO::isPositiveInteger($params['toolbarHeight']) ? $params['toolbarHeight'] : 200, 'customConfig' => PATH_MAIN_WR . '/ckeditor/config.php?toolbar=' . $toolbarset));
     } else {
         //serialize all htmlparameters
         $htmlParameters = $this->serializeHTMLParameters($inputParams);
         //append field id to html field parameters (if not already exists)
         $htmlParameters .= !isset($inputParams['id']) ? ' id="' . $prefixName . $this->_field->getID() . '_0"' : '';
         $width = '100%';
         if ($params['toolbarWidth']) {
             $width = io::substr($params['toolbarWidth'], -1, 1) == '%' ? $params['toolbarWidth'] : $params['toolbarWidth'] . 'px';
         }
         $html .= '<textarea type="text" name="' . $fieldName . '"' . $htmlParameters . ' style="width:' . $width . ';height:' . (sensitiveIO::isPositiveInteger($params['toolbarHeight']) ? $params['toolbarHeight'] : 200) . 'px">' . str_replace('<br />', "\n", str_replace(array("\n", "\r"), "", $value)) . '</textarea>' . "\n";
     }
     if (POLYMOD_DEBUG) {
         $html .= ' <span class="admin_text_alert">(Field : ' . $this->_field->getID() . ' - SubField : 0)</span>';
     }
     //append html hidden field which store field name
     if ($html) {
         $html .= '<input type="hidden" name="polymodFields[' . $this->_field->getID() . ']" value="' . $this->_field->getID() . '" />';
     }
     return $html;
 }
开发者ID:davidmottet,项目名称:automne,代码行数:60,代码来源:object_text.php


注:本文中的io::substr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。