コード例 #1
0
 /**
  * Returns the template file
  * @return string
  */
 protected function TemplateFile()
 {
     $class = new \ReflectionClass($this);
     $classFile = String::Replace('\\', '/', $class->getFileName());
     $templatePath = String::Replace('/Snippets/', '/Templates/Snippets/', $classFile);
     return Path::AddExtension($templatePath, 'phtml', true);
 }
コード例 #2
0
ファイル: ModuleBase.php プロジェクト: agentmedia/phine-core
 /**
  * The bundle name
  * @return string
  */
 static function MyBundle()
 {
     $className = \get_class(new static());
     $endPos = strpos($className, '\\Modules\\');
     $bundleNS = String::Start($className, $endPos);
     $startPos = strrpos($bundleNS, '\\');
     return String::Part($bundleNS, $startPos + 1);
 }
コード例 #3
0
 function Parse($file)
 {
     $contents = File::GetContents($file);
     foreach ($this->replacements as $placeholder => $text) {
         $contents = String::Replace($this->phStart . $placeholder . $this->phEnd, $text, $contents);
     }
     return $contents;
 }
コード例 #4
0
 /**
  * Set the current content to retrieve customized wording texts
  * @param Content $content The content
  */
 public function SetContent(Content $content)
 {
     $this->texts = array();
     $wordings = ContentWording::Schema()->FetchByContent(false, $content);
     foreach ($wordings as $wording) {
         $prefix = String::Replace('-', '.', $content->GetType());
         $this->texts[$prefix . '.' . $wording->GetPlaceholder()] = $wording->GetText();
     }
 }
コード例 #5
0
 public function Check($value)
 {
     $isArray = is_array($value);
     $this->error = '';
     if ($this->trimValue && !$isArray) {
         $value = String::Trim($value);
     }
     if ($value === '' || $isArray && count($value) == 0) {
         $this->error = self::Missing;
     }
     return $this->error == '';
 }
コード例 #6
0
 function Check($value)
 {
     $isEqual = String::Compare($value, $this->compareValue, $this->ignoreCase);
     if ($this->equalsNot && $isEqual) {
         $this->error = self::Equals;
     } else {
         if (!$this->equalsNot && !$isEqual) {
             $this->error = self::EqualsNot;
         }
     }
     return $this->error == '';
 }
コード例 #7
0
 /**
  * Checks each line of the given value with the given validators
  * @param string $value
  * @return bool 
  */
 function Check($value)
 {
     $success = true;
     $strings = System\String::SplitLines($value);
     foreach ($strings as $string) {
         $success = parent::Check($string);
         if (!$success) {
             break;
         }
     }
     //The value is temporarily set to the substrings
     //when calling the parent check function above,
     //so we have to store it here, not before the loop:
     $this->SetValue($value);
     return $success;
 }
コード例 #8
0
 /**
  * Checks the given value
  * @param string $value
  * @return bool True if check was passed
  */
 function Check($value)
 {
     if (!ctype_digit(String::TrimLeft($value, '-'))) {
         $this->error = self::HasNonDigits;
     } else {
         $floatValue = (double) $value;
         if ($floatValue < $this->min) {
             $this->error = self::ExceedsMin;
         } else {
             if ($floatValue > $this->max) {
                 $this->error = self::ExceedsMax;
             }
         }
     }
     return $this->error == '';
 }
コード例 #9
0
 protected function OnSuccess()
 {
     $this->member = new Member();
     $this->member->SetEMail($this->Value('EMail'));
     $this->member->SetName($this->Value('Name'));
     $password = $this->Value('Password');
     $salt = String::Start(md5(uniqid(microtime())), 8);
     $pwHash = hash('sha256', $password . $salt);
     $this->member->SetPassword($pwHash);
     $this->member->SetPasswordSalt($salt);
     $this->member->SetCreated(Date::Now());
     $this->member->Save();
     $this->SendConfirmMail();
     if ($this->register->GetNextUrl()) {
         Response::Redirect(FrontendRouter::Url($this->register->GetNextUrl()));
     }
 }
コード例 #10
0
 function Check($value)
 {
     $value = (string) $value;
     if ($this->trimValue) {
         $value = trim($value);
     }
     $length = System\String::Length($value);
     if ($this->IsTooShort($length)) {
         $this->error = self::TooShort;
     } else {
         if ($this->IsTooLong($length)) {
             $this->error = self::TooLong;
         } else {
             $this->error = '';
         }
     }
     return $this->error == '';
 }
コード例 #11
0
 /**
  * Fetches the lines of a text and serializes them to an array of key value pairs
  * @param string $text The text representation of the array
  * @return array Returns the array representation as associative array
  */
 function LinesToArray($text)
 {
     $result = array();
     $lines = String::SplitLines($text);
     foreach ($lines as $line) {
         $line = trim($line);
         if (!$line) {
             continue;
         }
         $pos = strpos($line, $this->separator);
         $key = $line;
         $value = '';
         if ($pos !== false) {
             $key = substr($line, 0, $pos);
             $value = substr($line, $pos + strlen($this->separator));
         }
         $result[trim($key)] = trim($value);
     }
     return $result;
 }
コード例 #12
0
 protected function PostedGroupIDs()
 {
     $result = array();
     $post = Request::PostArray();
     foreach ($post as $name => $value) {
         if (!String::StartsWith('Usergroup_', $name)) {
             continue;
         }
         $result[] = $value;
     }
     return $result;
 }
コード例 #13
0
ファイル: Functions.php プロジェクト: agentmedia/phine-core
/**
 * Returns a quoted string usable as javascipt variable
 * @param string $string
 * @param boolean $htmlEncode True if shall be hmtl encoded before
 */
function JsVarOut($string, $htmlEncode = false)
{
    echo String::ToJavascript($string, $htmlEncode);
}
コード例 #14
0
ファイル: ContentForm.php プロジェクト: agentmedia/phine-core
 private function WordingFieldName($name)
 {
     return String::Replace('.', '-', $name);
 }
コード例 #15
0
 public function RelativeNamespace($tableName)
 {
     foreach ($this->prefixNamespaces as $prefix => $namespace) {
         if (System\String::StartsWith($prefix, $tableName, !$this->prefixesCaseSensitive)) {
             return $namespace;
         }
     }
     return '';
 }
コード例 #16
0
ファイル: Path.php プロジェクト: agentmedia/phine-framework
 /**
  * Adds given extension, leading dot is optional.
  * @param string $path
  * @param string $extension
  * @param bool $replaceExisting If true and extension exists, it is replaced. 
  * @return string
  */
 static function AddExtension($path, $extension, $replaceExisting = false)
 {
     $result = $path;
     if ($replaceExisting) {
         $result = self::RemoveExtension($path);
     }
     return join('.', array($result, System\String::TrimLeft($extension, '.')));
 }
コード例 #17
0
 /**
  * The url protocol string without versioning
  * @return string returns either http or https
  */
 static function Protocol()
 {
     $sp = Server::Variable('SERVER_PROTOCOL');
     $protocol = substr($sp, 0, strpos($sp, '/'));
     if (self::IsHttps() && !String::EndsWith('s', $protocol)) {
         $protocol .= 's';
     }
     return String::ToLower($protocol);
 }
コード例 #18
0
 function HtmlAttributesAsString()
 {
     $result = '';
     foreach ($this->attributes as $key => $val) {
         if ($result) {
             $result .= ' ';
         }
         $result .= System\String::ToHtml($key) . '="' . System\String::ToHtml($val) . '"';
     }
     return $result;
 }
コード例 #19
0
ファイル: PathUtil.php プロジェクト: agentmedia/phine-core
 /**
  * Gets the translations folder for a module
  * @param ModuleBase $module
  * @return string Returns the folder of the module translationss
  */
 static function ModuleTranslationsFolder(ModuleBase $module)
 {
     $class = new \ReflectionClass($module);
     $classFile = String::Replace('\\', '/', $class->getFileName());
     return String::Replace('/Modules/', '/Translations/', Path::RemoveExtension($classFile));
 }
コード例 #20
0
ファイル: Form.php プロジェクト: agentmedia/phine-core
 /**
  * The form value as submitted
  * @param string $name The field name
  * @param boolean $trim If false, no string trimming is performed
  * @return string Returns the submitted field value 
  */
 protected function Value($name, $trim = true)
 {
     $value = Request::MethodData($this->Method(), $name);
     if ($trim) {
         return String::Trim($value);
     }
     return $value;
 }
コード例 #21
0
 private function CleanAllForeignKeys()
 {
     $tables = $this->connection->GetTables();
     foreach ($tables as $table) {
         if (String::StartsWith('pc_' . String::ToLower($this->manifest->BundleName() . '_'), $table)) {
             $this->CleanForeignKeys($table);
         }
     }
 }
コード例 #22
0
ファイル: Login.php プロジェクト: agentmedia/phine-builtin
 /**
  * 
  * @return string
  * @throws \LogicException Raises an error if no different redirect page is found
  */
 private function NextUrl()
 {
     $nextUrl = String::Trim(Request::GetData('nextUrl'));
     if ($nextUrl) {
         return $nextUrl;
     }
     $nextPageUrl = $this->login->GetNextUrl();
     if ($nextPageUrl) {
         return FrontendRouter::Url($nextPageUrl);
     }
     return '';
 }
コード例 #23
0
 /**
  * Gets the value by pure name
  * @param string $name The name without prefix
  * @return string Returns the value
  */
 private function Value($name)
 {
     $value = Request::PostData($this->prefix . $name);
     return String::Trim($value);
 }
コード例 #24
0
ファイル: UserForm.php プロジェクト: agentmedia/phine-core
 private function SavePassword()
 {
     $password = $this->Value('Password');
     if ($password) {
         $salt = String::Start(md5(uniqid(microtime())), 8);
         $pwHash = hash('sha256', $password . $salt);
         $this->user->SetPassword($pwHash);
         $this->user->SetPasswordSalt($salt);
     }
 }
コード例 #25
0
 /**
  * Realizes a wording placeholder with formatting arguments as array
  * @param string $placeholder The placeholder for the wording
  * @param array $args Optional array of format arguments
  * @return string The realized placeholder string
  */
 function RealizeArgs($placeholder, array $args = array())
 {
     $result = $this->GetReplacement($placeholder);
     return System\String::FormatArgs($result, $args);
 }
コード例 #26
0
ファイル: LayoutForm.php プロジェクト: agentmedia/phine-core
 private function SaveAreas()
 {
     $names = explode(',', $this->Value('Areas'));
     $prev = null;
     foreach ($names as $name) {
         $name = String::Trim($name);
         if (!$this->AreaNameExists($name)) {
             $area = new Area();
             $area->SetPrevious($prev);
             $area->SetLayout($this->layout);
             $area->SetName($name);
             $area->Save();
             $prev = $area;
         }
     }
 }
コード例 #27
0
ファイル: Reader.php プロジェクト: agentmedia/phine-core
 private function ParseProperty($tokenString, &$nextStop)
 {
     $trimString = trim(substr($tokenString, $nextStop));
     if (!String::StartsWith(self::PropertySeparator, $trimString)) {
         return false;
     }
     $propStart = strpos($tokenString, self::PropertySeparator, $nextStop) + strlen(self::PropertySeparator);
     $nextStart = strpos($tokenString, self::ParamsStart, $propStart);
     if ($nextStart === false) {
         $nextStart = strpos($tokenString, self::FilterSeparator, $propStart);
     }
     $propEnd = $nextStart ?: false;
     $strProp = $propEnd !== false ? substr($tokenString, $propStart, $propEnd - $propStart) : substr($tokenString, $propStart);
     $prop = trim($strProp);
     $nextStop = $nextStart ?: false;
     $result = ctype_alnum($prop) ? $prop : '';
     return $result;
 }
コード例 #28
0
 private function GetNiceName($name)
 {
     $reader = new System\StringReader($name);
     $result = '';
     $prevIsLower = false;
     $idx = 0;
     while (false !== ($ch = $reader->ReadChar())) {
         if ($idx == 0) {
             $result .= System\String::ToLower($ch);
         } else {
             if (ctype_upper($ch)) {
                 if ($prevIsLower) {
                     $result .= ' ' . System\String::ToLower($ch);
                 } else {
                     $result .= System\String::ToLower($ch);
                 }
             } else {
                 $result .= $ch;
             }
         }
         $prevIsLower = ctype_lower($ch);
         ++$idx;
     }
     return $result;
 }
コード例 #29
0
 /**
  * Sets element html content as a typical action of a modal form call
  * @param string $element The element specifier; typically starting with '#'
  * @param string $html The html string
  */
 protected function SetJSHtml($element, $html)
 {
     $jsElement = String::ToJavascript($element, false);
     $jsHtml = String::ToJavascript($html, false);
     echo "<script>\$({$jsElement}).html({$jsHtml});</script>";
 }