コード例 #1
0
ファイル: Boolean.php プロジェクト: BGCX261/zibo-svn-to-git
 /**
  * Gets the XML boolean value for the provided value
  * @param mixed $value
  * @return string true or false
  */
 public static function getBoolean($value)
 {
     if ($value === null) {
         return null;
     }
     $value = CoreBoolean::getBoolean($value);
     return $value ? self::VALUE_TRUE : self::VALUE_FALSE;
 }
コード例 #2
0
 /**
  * Truncates the provided value
  * @param string $value Value to truncate
  * @param array $arguments Array with arguments for the truncate function:
  *                         <ul>
  *                         <li>1 (integer): length to truncate (120)</li>
  *                         <li>2 (string) : etc string (...)</li>
  *                         <li>3 (boolean): flag to break words or not (false)</li>
  *                         </ul>
  * @return string
  */
 public function modifyValue($value, array $arguments)
 {
     $length = 120;
     $etc = '...';
     $breakWords = false;
     if (array_key_exists(0, $arguments)) {
         $length = $arguments[0];
     }
     if (array_key_exists(1, $arguments)) {
         $etc = $arguments[1];
     }
     if (array_key_exists(2, $arguments)) {
         $breakWords = Boolean::getBoolean($arguments[2]);
     }
     return String::truncate($value, $length, $etc, $breakWords);
 }
コード例 #3
0
 /**
  * Gets a preview of the provided HTML value
  * @param string $value HTML
  * @param array $arguments Array with arguments for the truncate function:
  *                         <ul>
  *                         <li>0 (boolean): flag to strip the HTML tags or not (true)</li>
  *                         <li>1 (integer): length to truncate (120)</li>
  *                         <li>2 (string) : etc string (...)</li>
  *                         <li>3 (boolean): flag to break words or not (false)</li>
  *                         </ul>
  * @return string
  */
 public function modifyValue($value, array $arguments)
 {
     $stripTags = true;
     $length = 120;
     $etc = '...';
     $breakWords = false;
     if (array_key_exists(0, $arguments)) {
         $stripTags = Boolean::getBoolean($arguments[0]);
     }
     if (array_key_exists(1, $arguments)) {
         $length = $arguments[1];
     }
     if (array_key_exists(2, $arguments)) {
         $etc = $arguments[2];
     }
     if (array_key_exists(3, $arguments)) {
         $breakWords = Boolean::getBoolean($arguments[3]);
     }
     return String::getPreviewString($value, $stripTags, $length, $etc, $breakWords);
 }
コード例 #4
0
 /**
  * Get a boolean argument of this environment
  * @param string $name name of the boolean argument
  * @param boolean $default default value for when the argument is not set
  * @return boolean the value of the argument or the provided default value if the value is not set
  * @see zibo\library\Boolean::getBoolean()
  */
 public function getBooleanArgument($name, $default = null)
 {
     $value = $this->getArgument($name, $default);
     return Boolean::getBoolean($value);
 }
コード例 #5
0
 /**
  * Enable or disable the cache
  *
  * When caching is disabled, all calls will be passed directly to the ConfigIO implementation it is
  * decorating.
  *
  * @param mixed $flag a boolean, true enables the cache, false disables it
  * @return null
  */
 public function setIsCacheEnabled($flag)
 {
     $this->isCacheEnabled = Boolean::getBoolean($flag);
 }
コード例 #6
0
ファイル: BaseView.php プロジェクト: BGCX261/zibo-svn-to-git
 /**
  * Runs the CSS and JS optimizers if enabled through the Zibo configuration
  * @return null
  */
 protected function preRender()
 {
     $zibo = Zibo::getInstance();
     $optimizeCss = $zibo->getConfigValue(self::CONFIG_OPTIMIZE_CSS, self::DEFAULT_OPTIMIZE_CSS);
     if (Boolean::getBoolean($optimizeCss) && !empty($this->styles)) {
         $optimizer = new CssOptimizer();
         $style = $optimizer->optimize($this->styles);
         $this->styles = array($style => $style);
     }
     $optimizeJs = $zibo->getConfigValue(self::CONFIG_OPTIMIZE_JS, self::DEFAULT_OPTIMIZE_JS);
     if (Boolean::getBoolean($optimizeJs) && !empty($this->scripts)) {
         $optimizer = new JsOptimizer();
         $script = $optimizer->optimize($this->scripts);
         $this->scripts = array($script => $script);
     }
 }
コード例 #7
0
 /**
  * Sets whether to allow symbols before the open symbol
  * @param boolean $flag
  * @return null
  */
 public function setAllowsSymbolsBeforeOpen($flag)
 {
     $this->allowsSymbolsBeforeOpen = Boolean::getBoolean($flag);
 }
コード例 #8
0
 /**
  * Sets the to retrieve only distinctive rows
  * @param boolean $distinct
  * @return null
  */
 public function setDistinct($distinct)
 {
     $this->distinct = Boolean::getBoolean($distinct);
 }
コード例 #9
0
 /**
  * Sets the unique flag
  * @param boolean $flag True to let a user authenticate only at one client at a time, false otherwise
  * @return null
  * @throws zibo\ZiboException when the provided flag is invalid
  */
 public function setIsUnique($flag)
 {
     $this->isUnique = Boolean::getBoolean($flag);
 }
コード例 #10
0
 /**
  * Gets the inline javascript for this TinyMCE field
  * @return string
  */
 private function getInitializationScript()
 {
     $request = Zibo::getInstance()->getRequest();
     $baseUrl = $request->getBaseUrl();
     $script = "\n\$('#" . $this->getId() . "').tinymce({\n";
     $script .= "\tscript_url : '" . $baseUrl . self::SCRIPT_TINYMCE . "',\n";
     $script .= "\texternal_image_list_url : '" . $baseUrl . self::ROUTE_IMAGES . "',\n";
     $script .= "\texternal_link_list_url : '" . $baseUrl . self::ROUTE_LINKS . "',\n";
     foreach ($this->tinymceParams as $key => $value) {
         try {
             Boolean::getBoolean($value);
             $script .= "\t" . $key . ' : ' . $value . ",\n";
         } catch (ZiboException $e) {
             $script .= "\t" . $key . " : '" . $value . "',\n";
         }
     }
     $script = substr($script, 0, -2) . "\n";
     $script .= "});\n";
     return $script;
 }
コード例 #11
0
 /**
  * @dataProvider providerGetBooleanThrowsExceptionWhenNonBooleanValueIsPassed
  * @expectedException zibo\ZiboException
  */
 public function testGetBooleanThrowsExceptionWhenNonBooleanValueIsPassed($value)
 {
     Boolean::getBoolean($value);
 }
コード例 #12
0
 /**
  * Sets whether this model will block deletes when a record is still in use by another record
  * @param boolean $flag True to block deletes, false otherwise
  * @return null
  */
 public function setWillBlockDeleteWhenUsed($flag)
 {
     $this->willBlockDeleteWhenUsed = Boolean::getBoolean($flag);
 }
コード例 #13
0
ファイル: FileField.php プロジェクト: BGCX261/zibo-svn-to-git
 /**
  * Sets whether this field will overwrite existing files
  * @param boolean $flag true to overwrite, false otherwise
  * @return null
  */
 public function setWillOverwrite($flag)
 {
     $this->willOverwrite = Boolean::getBoolean($flag);
 }
コード例 #14
0
 /**
  * Set whether this field is localized or not
  * @param boolean $isLocalized
  * @return null
  */
 public function setIsLocalized($isLocalized)
 {
     $this->isLocalized = Boolean::getBoolean($isLocalized);
 }
コード例 #15
0
 /**
  * Get the ModelField from a relation field element
  * @param DOMElement $fieldElement field element in the model element
  * @param zibo\library\filesystem\File $file the file which is being read
  * @param string $modelName the model which is currently being processed
  * @param string $fieldName the field which is currently being processed
  * @param string $relationModelName the name of the model for which this field is a relation
  * @return zibo\library\orm\definition\field\ModelField
  * @throws zibo\library\orm\exception\OrmException when an invalid relation type has been defined
  */
 protected function getRelationFieldFromElement(DOMElement $fieldElement, File $file, $modelName, $fieldName, $relationModelName)
 {
     $relationType = $fieldElement->hasAttribute(self::ATTRIBUTE_RELATION) ? $fieldElement->getAttribute(self::ATTRIBUTE_RELATION) : self::DEFAULT_FIELD_RELATION;
     switch ($relationType) {
         case self::RELATION_BELONGS_TO:
             $field = new BelongsToField($fieldName, $relationModelName);
             break;
         case self::RELATION_HAS_ONE:
             $field = new HasOneField($fieldName, $relationModelName);
             break;
         case self::RELATION_HAS_MANY:
             $field = new HasManyField($fieldName, $relationModelName);
             $relationOrder = $fieldElement->hasAttribute(self::ATTRIBUTE_RELATION_ORDER) ? $fieldElement->getAttribute(self::ATTRIBUTE_RELATION_ORDER) : null;
             $field->setRelationOrder($relationOrder);
             $indexOn = $fieldElement->hasAttribute(self::ATTRIBUTE_INDEX_ON) ? $fieldElement->getAttribute(self::ATTRIBUTE_INDEX_ON) : null;
             $field->setIndexOn($indexOn);
             $linkModelName = $fieldElement->hasAttribute(self::ATTRIBUTE_LINK_MODEL) ? $fieldElement->getAttribute(self::ATTRIBUTE_LINK_MODEL) : null;
             $field->setLinkModelName($linkModelName);
             break;
         default:
             throw new OrmException("{$fieldName} of {$modelName} has an invalid relation ({$relationType}) in {$file->getPath()}");
             break;
     }
     $dependant = $fieldElement->hasAttribute(self::ATTRIBUTE_DEPENDANT) ? Boolean::getBoolean($fieldElement->getAttribute(self::ATTRIBUTE_DEPENDANT)) : false;
     $field->setIsDependant($dependant);
     $foreignKey = $fieldElement->hasAttribute(self::ATTRIBUTE_FOREIGN_KEY) ? $fieldElement->getAttribute(self::ATTRIBUTE_FOREIGN_KEY) : null;
     if ($foreignKey) {
         $field->setForeignKeyName($foreignKey);
     }
     return $field;
 }
コード例 #16
0
 /**
  * Constructs a new extension filter
  * @param string|array $extensions String or array with extensions
  * @param boolean $include True to allow files with an extension set to this filter, false otherwise
  * @return null
  */
 public function __construct($extensions, $include = true)
 {
     $this->setExtensions($extensions);
     $this->include = Boolean::getBoolean($include);
 }
コード例 #17
0
 public function setInvert($flag)
 {
     $this->invert = Boolean::getBoolean($flag);
 }
コード例 #18
0
 /**
  * Sets whether to include defined symbols in the tokenize result
  * @param boolean $flag
  * @return null
  */
 public function setWillIncludeSymbols($flag)
 {
     $this->willIncludeSymbols = Boolean::getBoolean($flag);
 }
コード例 #19
0
 /**
  * Set the dependency of the relation model
  * @param boolean $isDependant true to delete the relations when the the main object is deleted, false otherwise
  * @return null
  */
 public function setIsDependant($isDependant)
 {
     $this->isDependant = Boolean::getBoolean($isDependant);
 }
コード例 #20
0
 /**
  * Enable or disable the cache
  *
  * When caching is disabled, all calls will be passed directly to the
  * ConfigIO implementation it is decorating.
  *
  * @param mixed $flag a boolean, true enables the cache, false disables it
  * @return null
  */
 public function setIsCacheEnabled($flag)
 {
     $this->isCacheEnabled = Boolean::getBoolean($flag);
     if ($this->isCacheEnabled && $this->cache === null) {
         $this->cache = $this->createCache();
     }
 }