예제 #1
0
 /**
  * Format value.
  *
  * @access   public
  * @param    string $value
  * @return   string
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function format($value)
 {
     if ($this->bStripTags) {
         $value = strip_tags($value);
     }
     if ($this->substringLength > 0) {
         if ($this->bSaveWords === FALSE) {
             $value = substr($value, 0, $this->substringLength);
         } else {
             $value = Helper\String::substrWords($value, $this->substringLength, $this->sEndSubstrWith);
         }
     }
     return $this->sPrefix . $value . $this->sSuffix;
 }
예제 #2
0
파일: profile.php 프로젝트: ktrzos/plethora
echo __('Nickname');
?>
:</td>
            <td><?php 
echo \Plethora\Helper\String::placeholder($oUser->getNickname(), '-');
?>
</td>
        </tr>
        <tr>
            <td><?php 
echo __('City');
?>
:</td>
            <td><?php 
echo \Plethora\Helper\String::placeholder($oUser->getCity(), '-');
?>
</td>
        </tr>
        <tr>
            <td><?php 
echo __('Description');
?>
:</td>
            <td><?php 
echo \Plethora\Helper\String::placeholder($oUser->getDescription(), '-');
?>
</td>
        </tr>
        </tbody>
    </table>
</div>
예제 #3
0
 /**
  * Setting file name
  *
  * @access   public
  * @param    string $sValue
  * @return   $this
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function setName($sValue)
 {
     $this->sFileName = \Plethora\Helper\String::prepareToURL($sValue);
     return $this;
 }
예제 #4
0
 /**
  * Format value.
  *
  * @access   public
  * @param    string $value
  * @return   string
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function format($value)
 {
     $oLink = Helper\Link::factory();
     // set title attribute
     $sTitle = '';
     $sURL = '';
     $oModel = $this->getField()->getEntity()->getModel();
     $oLocales = $oModel->getLocales();
     if ($oModel->hasField($this->getConfigTitle())) {
         $sTitle = $oModel->{$this->getConfigTitle()};
     } elseif ($oLocales !== NULL && $oLocales->hasField($this->getConfigTitle())) {
         $sTitle = $oLocales->{$this->getConfigTitle()};
     }
     $sTitle = $this->titlePrefix . $sTitle . $this->titleSuffix;
     if (!empty($sTitle)) {
         $oLink->setTitle($sTitle);
     }
     // set URL of the link
     if ($this->bValueAsURL) {
         $sURL = $value;
     } elseif (!empty($this->valueFromField)) {
         $sURL = $this->getField()->getEntity()->getModel()->getValue($this->valueFromField);
     } elseif ($this->getUrl() !== NULL) {
         $sURL = $this->getUrl();
     } elseif ($this->getRouteName() !== NULL) {
         $aArgs = $this->getRouteAttributes();
         foreach ($aArgs as $sAttrKey => $sField) {
             $sAttrValue = NULL;
             if ($oModel->hasField($sField)) {
                 $sAttrValue = $oModel->{$sField};
             } elseif ($oLocales !== NULL && $oLocales->hasField($sField)) {
                 $sAttrValue = $oLocales->{$sField};
             }
             $aArgs[$sAttrKey] = Helper\String::prepareToURL($sAttrValue);
         }
         $sURL = Route::factory($this->getRouteName())->url($aArgs);
     }
     // return newly generated link code
     return $this->sPrefix . $oLink->code($value, $sURL) . $this->sSuffix;
 }
예제 #5
0
 /**
  * Fast method using image styles.
  *
  * @static
  * @access     public
  * @param      string $sImageStyle
  * @param      string $sArgImageDir
  * @param      string $sImageName
  * @return     string
  * @since      1.0.0-alpha
  * @version    1.0.0-alpha
  */
 public static function useStyle($sImageStyle, $sArgImageDir, $sImageName = NULL)
 {
     $sImageDir = str_replace(DIRECTORY_SEPARATOR, '/', $sArgImageDir);
     if (!file_exists($sImageDir)) {
         return 'file_do_not_exist';
     }
     if ($sImageName === NULL) {
         $aExploded = explode('/', $sImageDir);
         $sImageName = array_pop($aExploded);
         $sImageDir = implode('/', $aExploded);
     }
     if (substr($sImageDir, 0, strlen(static::DIR_UPLOADS)) == static::DIR_UPLOADS) {
         $sImageStyleDirPath = substr($sImageDir, strlen(static::DIR_UPLOADS));
     } else {
         $sImageStyleDirPath = $sImageDir;
     }
     if (static::isImageStyled($sImageStyle, $sImageStyleDirPath, $sImageName)) {
         return static::DIR_IMG_STYLES . $sImageStyle . '/' . $sImageStyleDirPath . '/' . $sImageName;
     } else {
         $sMethodName = 'style' . Helper\String::camelize($sImageStyle);
         return call_user_func(['\\' . get_called_class(), $sMethodName], $sImageDir, $sImageName);
     }
 }
예제 #6
0
 /**
  * @access     public
  * @param    string $sValue
  * @return    Controller
  * @since      1.0.0-alpha
  * @version    1.0.0-alpha
  */
 public function setDescription($sValue)
 {
     $this->addMetaTagRegular('description', StringHelper::substrWords($sValue, 155));
     return $this;
 }